@cuekit-ai/react 1.0.0 → 1.1.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 +220 -164
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,34 +1,43 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @cuekit-ai/react
|
|
2
2
|
|
|
3
|
-
A powerful
|
|
3
|
+
A powerful React SDK for integrating AI-powered voice interactions into your web applications. Built with TypeScript and designed for seamless voice navigation, commands, and interactions.
|
|
4
|
+
|
|
5
|
+
[](https://badge.fury.io/js/%40cuekit-ai%2Freact)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
4
7
|
|
|
5
8
|
## 🚀 Features
|
|
6
9
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
10
|
+
- **🎤 Voice Recognition**: Real-time speech-to-text with high accuracy
|
|
11
|
+
- **🤖 AI-Powered Navigation**: Intelligent voice commands for app navigation
|
|
12
|
+
- **🎯 Intent Recognition**: Understands user intent and performs actions
|
|
13
|
+
- **🔊 Text-to-Speech**: Natural voice responses using ElevenLabs
|
|
14
|
+
- **🎨 Beautiful UI**: Modern, animated voice assistant interface
|
|
15
|
+
- **📱 Responsive Design**: Works seamlessly across all devices
|
|
16
|
+
- **⚡ Real-time Processing**: Instant voice command processing
|
|
17
|
+
- **🔄 State Management**: Robust state handling for voice interactions
|
|
18
|
+
- **🎭 Portal Rendering**: Modal components render at document body level
|
|
19
|
+
- **✨ Visual Feedback**: Border glow effects and animations
|
|
15
20
|
|
|
16
21
|
## 📦 Installation
|
|
17
22
|
|
|
18
23
|
```bash
|
|
19
|
-
npm install cuekit-
|
|
20
|
-
# or
|
|
21
|
-
yarn add cuekit-web-sdk
|
|
24
|
+
npm install @cuekit-ai/react
|
|
22
25
|
```
|
|
23
26
|
|
|
24
|
-
|
|
27
|
+
```bash
|
|
28
|
+
yarn add @cuekit-ai/react
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pnpm add @cuekit-ai/react
|
|
33
|
+
```
|
|
25
34
|
|
|
26
|
-
|
|
35
|
+
## 🎯 Quick Start
|
|
27
36
|
|
|
28
|
-
Wrap your app with
|
|
37
|
+
### 1. Wrap your app with CuekitProvider
|
|
29
38
|
|
|
30
39
|
```tsx
|
|
31
|
-
import { CuekitProvider } from 'cuekit-
|
|
40
|
+
import { CuekitProvider } from '@cuekit-ai/react'
|
|
32
41
|
|
|
33
42
|
function App() {
|
|
34
43
|
return (
|
|
@@ -39,251 +48,298 @@ function App() {
|
|
|
39
48
|
}
|
|
40
49
|
```
|
|
41
50
|
|
|
42
|
-
### 2. Add
|
|
43
|
-
|
|
44
|
-
Add the `MicButton` component to enable voice interactions:
|
|
51
|
+
### 2. Add the MicButton component
|
|
45
52
|
|
|
46
53
|
```tsx
|
|
47
|
-
import { MicButton } from 'cuekit-
|
|
54
|
+
import { MicButton } from '@cuekit-ai/react'
|
|
48
55
|
|
|
49
56
|
function YourApp() {
|
|
50
57
|
return (
|
|
51
58
|
<div>
|
|
52
|
-
|
|
53
|
-
<MicButton
|
|
59
|
+
<h1>My Voice-Enabled App</h1>
|
|
60
|
+
<MicButton
|
|
61
|
+
screenPosition="bottom-right"
|
|
62
|
+
buttonStyle={{
|
|
63
|
+
backgroundColor: 'blue',
|
|
64
|
+
borderRadius: '50%',
|
|
65
|
+
}}
|
|
66
|
+
/>
|
|
54
67
|
</div>
|
|
55
68
|
)
|
|
56
69
|
}
|
|
57
70
|
```
|
|
58
71
|
|
|
59
|
-
|
|
72
|
+
## 🎨 Components
|
|
60
73
|
|
|
61
|
-
|
|
74
|
+
### MicButton
|
|
62
75
|
|
|
63
|
-
|
|
64
|
-
import { InitCuekit } from 'cuekit-web-sdk'
|
|
76
|
+
The main voice interaction component with a beautiful animated interface.
|
|
65
77
|
|
|
66
|
-
|
|
67
|
-
|
|
78
|
+
```tsx
|
|
79
|
+
import { MicButton } from '@cuekit-ai/react'
|
|
80
|
+
;<MicButton
|
|
81
|
+
screenPosition="bottom-right" // 'bottom-left' | 'bottom-center' | 'bottom-right'
|
|
82
|
+
buttonStyle={
|
|
83
|
+
{
|
|
84
|
+
/* custom styles */
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
buttonSize={60}
|
|
88
|
+
hasText={false}
|
|
89
|
+
text="Voice Assistant"
|
|
90
|
+
textStyle={
|
|
91
|
+
{
|
|
92
|
+
/* text styles */
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
imageSource="path/to/image.png"
|
|
96
|
+
imageStyle={
|
|
97
|
+
{
|
|
98
|
+
/* image styles */
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/>
|
|
68
102
|
```
|
|
69
103
|
|
|
70
|
-
|
|
104
|
+
#### Props
|
|
105
|
+
|
|
106
|
+
| Prop | Type | Default | Description |
|
|
107
|
+
| ---------------- | ---------------------------------------------------- | ---------------- | ------------------------------------ |
|
|
108
|
+
| `screenPosition` | `'bottom-left' \| 'bottom-center' \| 'bottom-right'` | `'bottom-right'` | Position of the mic button |
|
|
109
|
+
| `buttonStyle` | `React.CSSProperties` | `{}` | Custom styles for the button |
|
|
110
|
+
| `buttonSize` | `number` | `60` | Size of the button in pixels |
|
|
111
|
+
| `hasText` | `boolean` | `false` | Whether to show text with the button |
|
|
112
|
+
| `text` | `string` | `'CueKit VC'` | Text to display with the button |
|
|
113
|
+
| `textStyle` | `React.CSSProperties` | `{}` | Styles for the text |
|
|
114
|
+
| `imageSource` | `string` | `undefined` | Image source for the button |
|
|
115
|
+
| `imageStyle` | `React.CSSProperties` | `{}` | Styles for the image |
|
|
71
116
|
|
|
72
117
|
### CuekitProvider
|
|
73
118
|
|
|
74
|
-
The
|
|
119
|
+
The context provider that initializes the voice assistant.
|
|
75
120
|
|
|
76
121
|
```tsx
|
|
77
|
-
|
|
122
|
+
import { CuekitProvider } from '@cuekit-ai/react'
|
|
123
|
+
;<CuekitProvider
|
|
78
124
|
apiKey="your-api-key"
|
|
79
125
|
appId="your-app-id"
|
|
80
126
|
deviceId="optional-device-id"
|
|
81
|
-
navigator={
|
|
127
|
+
navigator={yourNavigator}
|
|
82
128
|
>
|
|
83
129
|
{children}
|
|
84
130
|
</CuekitProvider>
|
|
85
131
|
```
|
|
86
132
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
- `apiKey` (required): Your CueKit API key
|
|
90
|
-
- `appId` (required): Your application ID
|
|
91
|
-
- `deviceId` (optional): Unique device identifier
|
|
92
|
-
- `navigator` (optional): Router instance for navigation
|
|
93
|
-
- `children`: React components to wrap
|
|
133
|
+
#### Props
|
|
94
134
|
|
|
95
|
-
|
|
135
|
+
| Prop | Type | Required | Description |
|
|
136
|
+
| ----------- | ----------- | -------- | --------------------------------------------------------- |
|
|
137
|
+
| `apiKey` | `string` | ✅ | Your CueKit API key |
|
|
138
|
+
| `appId` | `string` | ✅ | Your application ID |
|
|
139
|
+
| `deviceId` | `string` | ❌ | Unique device identifier (auto-generated if not provided) |
|
|
140
|
+
| `navigator` | `any` | ❌ | Navigation object for routing |
|
|
141
|
+
| `children` | `ReactNode` | ✅ | Your app components |
|
|
96
142
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
```tsx
|
|
100
|
-
<MicButton
|
|
101
|
-
hasText={false}
|
|
102
|
-
text="Voice Control"
|
|
103
|
-
screenPosition="bottom-right"
|
|
104
|
-
buttonSize={60}
|
|
105
|
-
imageSource="path/to/mic-icon.png"
|
|
106
|
-
buttonStyle={{ backgroundColor: '#007bff' }}
|
|
107
|
-
/>
|
|
108
|
-
```
|
|
143
|
+
## 🔧 Hooks
|
|
109
144
|
|
|
110
|
-
|
|
145
|
+
### useVoice
|
|
111
146
|
|
|
112
|
-
|
|
113
|
-
- `text` (optional): Button text when `hasText` is true
|
|
114
|
-
- `textStyle` (optional): Custom styles for text
|
|
115
|
-
- `imageSource` (optional): Custom microphone icon URL
|
|
116
|
-
- `imageStyle` (optional): Custom styles for image
|
|
117
|
-
- `buttonStyle` (optional): Custom button styles
|
|
118
|
-
- `screenPosition` (optional): Button position (`'bottom-right'`, `'bottom-left'`, `'bottom-center'`)
|
|
119
|
-
- `buttonSize` (optional): Button size in pixels
|
|
120
|
-
|
|
121
|
-
## 🎤 Voice Recognition
|
|
122
|
-
|
|
123
|
-
### useVoice Hook
|
|
124
|
-
|
|
125
|
-
Custom hook for voice recognition functionality:
|
|
147
|
+
Hook for voice recognition and processing.
|
|
126
148
|
|
|
127
149
|
```tsx
|
|
128
|
-
import { useVoice } from 'cuekit-
|
|
150
|
+
import { useVoice } from '@cuekit-ai/react'
|
|
129
151
|
|
|
130
|
-
function
|
|
152
|
+
function MyComponent() {
|
|
131
153
|
const { isListening, start, stop, transcript } = useVoice()
|
|
132
154
|
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
await stop()
|
|
136
|
-
} else {
|
|
137
|
-
await start('Hello, how can I help you?')
|
|
138
|
-
}
|
|
155
|
+
const handleVoiceStart = () => {
|
|
156
|
+
start('Hello, how can I help you?')
|
|
139
157
|
}
|
|
140
158
|
|
|
141
|
-
|
|
159
|
+
const handleVoiceStop = () => {
|
|
160
|
+
stop()
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return (
|
|
164
|
+
<div>
|
|
165
|
+
<p>Listening: {isListening ? 'Yes' : 'No'}</p>
|
|
166
|
+
<p>Transcript: {transcript}</p>
|
|
167
|
+
<button onClick={handleVoiceStart}>Start Listening</button>
|
|
168
|
+
<button onClick={handleVoiceStop}>Stop Listening</button>
|
|
169
|
+
</div>
|
|
170
|
+
)
|
|
142
171
|
}
|
|
143
172
|
```
|
|
144
173
|
|
|
145
|
-
###
|
|
174
|
+
### useAudioController
|
|
146
175
|
|
|
147
|
-
|
|
176
|
+
Hook for audio playback control.
|
|
148
177
|
|
|
149
178
|
```tsx
|
|
150
|
-
import {
|
|
179
|
+
import { useAudioController } from '@cuekit-ai/react'
|
|
151
180
|
|
|
152
|
-
function
|
|
153
|
-
const {
|
|
181
|
+
function AudioComponent() {
|
|
182
|
+
const { play, pause, stop, isPlaying } = useAudioController()
|
|
154
183
|
|
|
155
|
-
|
|
184
|
+
return (
|
|
185
|
+
<div>
|
|
186
|
+
<button onClick={play}>Play</button>
|
|
187
|
+
<button onClick={pause}>Pause</button>
|
|
188
|
+
<button onClick={stop}>Stop</button>
|
|
189
|
+
<p>Playing: {isPlaying ? 'Yes' : 'No'}</p>
|
|
190
|
+
</div>
|
|
191
|
+
)
|
|
156
192
|
}
|
|
157
193
|
```
|
|
158
194
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
### Custom Voice Processing
|
|
195
|
+
### useVoiceRecognition
|
|
162
196
|
|
|
163
|
-
|
|
197
|
+
Hook for advanced voice recognition features.
|
|
164
198
|
|
|
165
199
|
```tsx
|
|
166
|
-
import {
|
|
200
|
+
import { useVoiceRecognition } from '@cuekit-ai/react'
|
|
167
201
|
|
|
168
|
-
|
|
169
|
-
const
|
|
202
|
+
function VoiceRecognitionComponent() {
|
|
203
|
+
const { isListening, transcript, startListening, stopListening, resetTranscript } =
|
|
204
|
+
useVoiceRecognition()
|
|
170
205
|
|
|
171
|
-
|
|
206
|
+
return (
|
|
207
|
+
<div>
|
|
208
|
+
<button onClick={startListening}>Start</button>
|
|
209
|
+
<button onClick={stopListening}>Stop</button>
|
|
210
|
+
<button onClick={resetTranscript}>Reset</button>
|
|
211
|
+
<p>Transcript: {transcript}</p>
|
|
212
|
+
</div>
|
|
213
|
+
)
|
|
172
214
|
}
|
|
173
215
|
```
|
|
174
216
|
|
|
175
|
-
|
|
217
|
+
## 🛠️ Utilities
|
|
218
|
+
|
|
219
|
+
### processVoice
|
|
176
220
|
|
|
177
|
-
|
|
221
|
+
Process voice commands and execute actions.
|
|
178
222
|
|
|
179
223
|
```tsx
|
|
180
|
-
import {
|
|
224
|
+
import { processVoice } from '@cuekit-ai/react'
|
|
181
225
|
|
|
182
|
-
|
|
183
|
-
const
|
|
226
|
+
const handleVoiceCommand = async (transcript: string) => {
|
|
227
|
+
const result = await processVoice(transcript, apiKey, appId, deviceId)
|
|
184
228
|
|
|
185
|
-
|
|
186
|
-
|
|
229
|
+
if (result) {
|
|
230
|
+
console.log('Voice command processed:', result)
|
|
187
231
|
}
|
|
188
|
-
|
|
189
|
-
return (
|
|
190
|
-
<div>
|
|
191
|
-
<button onClick={handleSpeak}>Speak</button>
|
|
192
|
-
<button onClick={stop}>Stop</button>
|
|
193
|
-
{isSpeaking && <span>Speaking...</span>}
|
|
194
|
-
</div>
|
|
195
|
-
)
|
|
196
232
|
}
|
|
197
233
|
```
|
|
198
234
|
|
|
199
|
-
###
|
|
235
|
+
### onStateChange
|
|
200
236
|
|
|
201
|
-
|
|
237
|
+
Handle navigation state changes.
|
|
202
238
|
|
|
203
239
|
```tsx
|
|
204
|
-
import { onStateChange } from 'cuekit-
|
|
240
|
+
import { onStateChange } from '@cuekit-ai/react'
|
|
205
241
|
|
|
206
|
-
//
|
|
207
|
-
|
|
242
|
+
// Automatically called by CuekitProvider
|
|
243
|
+
// Handles route changes and voice command re-triggering
|
|
208
244
|
```
|
|
209
245
|
|
|
210
|
-
##
|
|
246
|
+
## 🎯 Voice Commands
|
|
247
|
+
|
|
248
|
+
The SDK supports various voice commands for navigation and interaction:
|
|
249
|
+
|
|
250
|
+
### Navigation Commands
|
|
251
|
+
|
|
252
|
+
- "Go to home"
|
|
253
|
+
- "Navigate to settings"
|
|
254
|
+
- "Open profile page"
|
|
255
|
+
- "Go back"
|
|
256
|
+
|
|
257
|
+
### Action Commands
|
|
258
|
+
|
|
259
|
+
- "Click the submit button"
|
|
260
|
+
- "Press the login button"
|
|
261
|
+
- "Select the first option"
|
|
262
|
+
- "Scroll down"
|
|
263
|
+
|
|
264
|
+
### Information Commands
|
|
265
|
+
|
|
266
|
+
- "What's on this page?"
|
|
267
|
+
- "Tell me about this screen"
|
|
268
|
+
- "What can I do here?"
|
|
269
|
+
|
|
270
|
+
## 🎨 Styling
|
|
211
271
|
|
|
212
|
-
###
|
|
272
|
+
### Custom Button Styling
|
|
213
273
|
|
|
214
274
|
```tsx
|
|
215
275
|
<MicButton
|
|
216
276
|
buttonStyle={{
|
|
217
|
-
backgroundColor: '#
|
|
218
|
-
boxShadow: '0 4px
|
|
219
|
-
|
|
220
|
-
}}
|
|
221
|
-
textStyle={{
|
|
222
|
-
fontSize: '16px',
|
|
223
|
-
fontWeight: 'bold',
|
|
224
|
-
color: '#fff',
|
|
277
|
+
backgroundColor: 'linear-gradient(45deg, #667eea 0%, #764ba2 100%)',
|
|
278
|
+
boxShadow: '0 4px 15px rgba(0, 0, 0, 0.2)',
|
|
279
|
+
transform: 'scale(1.1)',
|
|
225
280
|
}}
|
|
226
281
|
/>
|
|
227
282
|
```
|
|
228
283
|
|
|
229
|
-
### Custom
|
|
284
|
+
### Custom Modal Styling
|
|
230
285
|
|
|
231
|
-
|
|
232
|
-
// Bottom right (default)
|
|
233
|
-
<MicButton screenPosition="bottom-right" />
|
|
286
|
+
The modal automatically adapts to your app's theme and provides:
|
|
234
287
|
|
|
235
|
-
|
|
236
|
-
|
|
288
|
+
- Beautiful gradient backgrounds
|
|
289
|
+
- Smooth animations
|
|
290
|
+
- Responsive design
|
|
291
|
+
- Accessibility features
|
|
237
292
|
|
|
238
|
-
|
|
239
|
-
|
|
293
|
+
```env
|
|
294
|
+
CUEKIT_API_KEY=your-api-key
|
|
295
|
+
CUEKIT_APP_ID=your-app-id
|
|
296
|
+
CUEKIT_DEVICE_ID=optional-device-id
|
|
240
297
|
```
|
|
241
298
|
|
|
242
|
-
|
|
299
|
+
### API Configuration
|
|
243
300
|
|
|
244
|
-
The SDK
|
|
301
|
+
The SDK communicates with the CueKit API for:
|
|
245
302
|
|
|
246
|
-
-
|
|
247
|
-
-
|
|
248
|
-
-
|
|
249
|
-
-
|
|
303
|
+
- Voice command processing
|
|
304
|
+
- Intent recognition
|
|
305
|
+
- Navigation handling
|
|
306
|
+
- Text-to-speech synthesis
|
|
250
307
|
|
|
251
|
-
|
|
308
|
+
## 🔒 Security
|
|
252
309
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
component?: {
|
|
258
|
-
hash: string
|
|
259
|
-
text: string
|
|
260
|
-
componentType: string
|
|
261
|
-
}
|
|
262
|
-
text?: string
|
|
263
|
-
claudeError?: boolean
|
|
264
|
-
errorMessage?: string
|
|
265
|
-
}
|
|
266
|
-
```
|
|
310
|
+
- All API calls are made over HTTPS
|
|
311
|
+
- API keys are stored securely
|
|
312
|
+
- No sensitive data is logged
|
|
313
|
+
- Device IDs are anonymized
|
|
267
314
|
|
|
268
|
-
##
|
|
315
|
+
## 🚀 Performance
|
|
316
|
+
|
|
317
|
+
- Lightweight bundle (~40KB gzipped)
|
|
318
|
+
- Optimized for React 18+
|
|
319
|
+
- Efficient re-rendering
|
|
320
|
+
- Minimal memory footprint
|
|
321
|
+
|
|
322
|
+
## 🐛 Troubleshooting
|
|
269
323
|
|
|
270
|
-
|
|
271
|
-
- Device IDs are automatically generated and persisted
|
|
272
|
-
- Network requests are validated and error-handled
|
|
273
|
-
- No sensitive data is logged to console
|
|
324
|
+
### Common Issues
|
|
274
325
|
|
|
275
|
-
|
|
326
|
+
1. **Mic not working**
|
|
276
327
|
|
|
277
|
-
-
|
|
278
|
-
-
|
|
279
|
-
-
|
|
280
|
-
- Edge
|
|
328
|
+
- Check browser permissions
|
|
329
|
+
- Ensure HTTPS connection
|
|
330
|
+
- Verify API key is valid
|
|
281
331
|
|
|
282
|
-
**
|
|
332
|
+
2. **Voice commands not recognized**
|
|
283
333
|
|
|
284
|
-
|
|
334
|
+
- Check internet connection
|
|
335
|
+
- Verify app ID is correct
|
|
336
|
+
- Ensure proper CuekitProvider setup
|
|
285
337
|
|
|
286
|
-
|
|
338
|
+
3. **Modal not appearing**
|
|
339
|
+
- Check z-index conflicts
|
|
340
|
+
- Verify portal rendering
|
|
341
|
+
- Ensure proper state management
|
|
287
342
|
|
|
343
|
+
---
|
|
288
344
|
|
|
289
|
-
**
|
|
345
|
+
**Made with ❤️ by [CueKit](https://cuekit.ai)**
|