@cuekit-ai/react 1.1.0 → 1.1.2
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 +80 -11
- package/dist/index.d.mts +8 -3
- package/dist/index.d.ts +8 -3
- package/dist/index.js +716 -160
- package/dist/index.mjs +712 -160
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -41,9 +41,17 @@ import { CuekitProvider } from '@cuekit-ai/react'
|
|
|
41
41
|
|
|
42
42
|
function App() {
|
|
43
43
|
return (
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
<CuekitProvider
|
|
45
|
+
apiKey="your-api-key"
|
|
46
|
+
appId="your-app-id"
|
|
47
|
+
deviceId="optional-device-id"
|
|
48
|
+
navigationHandler={(path, params) => {
|
|
49
|
+
const qs = params ? `?${new URLSearchParams(params).toString()}` : ''
|
|
50
|
+
// Example with Next.js App Router
|
|
51
|
+
router.push(`${path}${qs}`)
|
|
52
|
+
// Or with React Router v6
|
|
53
|
+
// navigate(`${path}${qs}`)
|
|
54
|
+
}}
|
|
47
55
|
)
|
|
48
56
|
}
|
|
49
57
|
```
|
|
@@ -120,11 +128,18 @@ The context provider that initializes the voice assistant.
|
|
|
120
128
|
|
|
121
129
|
```tsx
|
|
122
130
|
import { CuekitProvider } from '@cuekit-ai/react'
|
|
131
|
+
|
|
123
132
|
;<CuekitProvider
|
|
124
133
|
apiKey="your-api-key"
|
|
125
134
|
appId="your-app-id"
|
|
126
135
|
deviceId="optional-device-id"
|
|
127
|
-
|
|
136
|
+
navigationHandler={(path, params) => {
|
|
137
|
+
const qs = params ? `?${new URLSearchParams(params).toString()}` : ''
|
|
138
|
+
// Example with Next.js App Router
|
|
139
|
+
router.push(`${path}${qs}`)
|
|
140
|
+
// Or with React Router v6
|
|
141
|
+
// navigate(`${path}${qs}`)
|
|
142
|
+
}}
|
|
128
143
|
>
|
|
129
144
|
{children}
|
|
130
145
|
</CuekitProvider>
|
|
@@ -132,13 +147,67 @@ import { CuekitProvider } from '@cuekit-ai/react'
|
|
|
132
147
|
|
|
133
148
|
#### Props
|
|
134
149
|
|
|
135
|
-
| Prop
|
|
136
|
-
|
|
|
137
|
-
| `apiKey`
|
|
138
|
-
| `appId`
|
|
139
|
-
| `deviceId`
|
|
140
|
-
| `
|
|
141
|
-
| `children`
|
|
150
|
+
| Prop | Type | Required | Description |
|
|
151
|
+
| ------------------- | ------------------------------------------------------ | -------- | -------------------------------------------------------------------------- |
|
|
152
|
+
| `apiKey` | `string` | ✅ | Your CueKit API key |
|
|
153
|
+
| `appId` | `string` | ✅ | Your application ID |
|
|
154
|
+
| `deviceId` | `string` | ❌ | Unique device identifier (auto-generated if not provided) |
|
|
155
|
+
| `navigationHandler` | `(path: string, params?: Record<string, any>) => void` | ❌ | Custom router handler. If not provided, falls back to internal navigation. |
|
|
156
|
+
| `children` | `ReactNode` | ✅ | Your app components |
|
|
157
|
+
|
|
158
|
+
### Routing integration
|
|
159
|
+
|
|
160
|
+
You can integrate your app's router by passing a `navigationHandler` to `CuekitProvider`.
|
|
161
|
+
|
|
162
|
+
Next.js App Router example:
|
|
163
|
+
|
|
164
|
+
```tsx
|
|
165
|
+
'use client'
|
|
166
|
+
import { useEffect } from 'react'
|
|
167
|
+
import { useRouter } from 'next/navigation'
|
|
168
|
+
import { CuekitProvider } from '@cuekit-ai/react'
|
|
169
|
+
|
|
170
|
+
export default function Providers({ children }: { children: React.ReactNode }) {
|
|
171
|
+
const router = useRouter()
|
|
172
|
+
|
|
173
|
+
return (
|
|
174
|
+
<CuekitProvider
|
|
175
|
+
apiKey={process.env.NEXT_PUBLIC_CUEKIT_API_KEY!}
|
|
176
|
+
appId={process.env.NEXT_PUBLIC_CUEKIT_APP_ID!}
|
|
177
|
+
navigationHandler={(path, params) => {
|
|
178
|
+
const qs = params ? `?${new URLSearchParams(params).toString()}` : ''
|
|
179
|
+
router.push(`${path}${qs}`)
|
|
180
|
+
}}
|
|
181
|
+
>
|
|
182
|
+
{children}
|
|
183
|
+
</CuekitProvider>
|
|
184
|
+
)
|
|
185
|
+
}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
React Router v6 example:
|
|
189
|
+
|
|
190
|
+
```tsx
|
|
191
|
+
import { useNavigate } from 'react-router-dom'
|
|
192
|
+
import { CuekitProvider } from '@cuekit-ai/react'
|
|
193
|
+
|
|
194
|
+
function AppProviders({ children }: { children: React.ReactNode }) {
|
|
195
|
+
const navigate = useNavigate()
|
|
196
|
+
|
|
197
|
+
return (
|
|
198
|
+
<CuekitProvider
|
|
199
|
+
apiKey={import.meta.env.VITE_CUEKIT_API_KEY}
|
|
200
|
+
appId={import.meta.env.VITE_CUEKIT_APP_ID}
|
|
201
|
+
navigationHandler={(path, params) => {
|
|
202
|
+
const qs = params ? `?${new URLSearchParams(params).toString()}` : ''
|
|
203
|
+
navigate(`${path}${qs}`)
|
|
204
|
+
}}
|
|
205
|
+
>
|
|
206
|
+
{children}
|
|
207
|
+
</CuekitProvider>
|
|
208
|
+
)
|
|
209
|
+
}
|
|
210
|
+
```
|
|
142
211
|
|
|
143
212
|
## 🔧 Hooks
|
|
144
213
|
|
package/dist/index.d.mts
CHANGED
|
@@ -19,7 +19,7 @@ type Props = {
|
|
|
19
19
|
deviceId?: string;
|
|
20
20
|
appId: string;
|
|
21
21
|
children: ReactNode;
|
|
22
|
-
|
|
22
|
+
navigationHandler?: (path: string, params?: Record<string, any>) => void;
|
|
23
23
|
};
|
|
24
24
|
declare const CuekitProvider: React.FC<Props>;
|
|
25
25
|
|
|
@@ -29,6 +29,11 @@ declare const useAudioController: () => {
|
|
|
29
29
|
play: (url: string) => Promise<void>;
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
+
type NavigationHandler = (path: string, params?: Record<string, any>) => void;
|
|
33
|
+
declare const setNavigator: (navigator: any) => void;
|
|
34
|
+
declare const setNavigationHandler: (handler: NavigationHandler | null) => void;
|
|
35
|
+
declare const navigate: (path: string, params?: Record<string, any>) => void;
|
|
36
|
+
declare const safeNavigate: (name: string | undefined, params?: Record<string, any>) => void;
|
|
32
37
|
declare function onStateChange(): void;
|
|
33
38
|
|
|
34
39
|
type ScreenPosition = 'bottom-center' | 'bottom-left' | 'bottom-right';
|
|
@@ -46,7 +51,7 @@ type MicButtonProps = {
|
|
|
46
51
|
|
|
47
52
|
declare const MicButton: React.FC<MicButtonProps>;
|
|
48
53
|
|
|
49
|
-
declare function InitCuekit(apiKey: string
|
|
54
|
+
declare function InitCuekit(apiKey: string): void;
|
|
50
55
|
|
|
51
56
|
declare const useVoiceRecognition: (lang?: string) => {
|
|
52
57
|
isListening: boolean;
|
|
@@ -55,4 +60,4 @@ declare const useVoiceRecognition: (lang?: string) => {
|
|
|
55
60
|
speechText: string;
|
|
56
61
|
};
|
|
57
62
|
|
|
58
|
-
export { CuekitProvider, InitCuekit, MicButton, onStateChange, processVoice, useAudioController, useVoiceRecognition };
|
|
63
|
+
export { CuekitProvider, InitCuekit, MicButton, navigate, onStateChange, processVoice, safeNavigate, setNavigationHandler, setNavigator, useAudioController, useVoiceRecognition };
|
package/dist/index.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ type Props = {
|
|
|
19
19
|
deviceId?: string;
|
|
20
20
|
appId: string;
|
|
21
21
|
children: ReactNode;
|
|
22
|
-
|
|
22
|
+
navigationHandler?: (path: string, params?: Record<string, any>) => void;
|
|
23
23
|
};
|
|
24
24
|
declare const CuekitProvider: React.FC<Props>;
|
|
25
25
|
|
|
@@ -29,6 +29,11 @@ declare const useAudioController: () => {
|
|
|
29
29
|
play: (url: string) => Promise<void>;
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
+
type NavigationHandler = (path: string, params?: Record<string, any>) => void;
|
|
33
|
+
declare const setNavigator: (navigator: any) => void;
|
|
34
|
+
declare const setNavigationHandler: (handler: NavigationHandler | null) => void;
|
|
35
|
+
declare const navigate: (path: string, params?: Record<string, any>) => void;
|
|
36
|
+
declare const safeNavigate: (name: string | undefined, params?: Record<string, any>) => void;
|
|
32
37
|
declare function onStateChange(): void;
|
|
33
38
|
|
|
34
39
|
type ScreenPosition = 'bottom-center' | 'bottom-left' | 'bottom-right';
|
|
@@ -46,7 +51,7 @@ type MicButtonProps = {
|
|
|
46
51
|
|
|
47
52
|
declare const MicButton: React.FC<MicButtonProps>;
|
|
48
53
|
|
|
49
|
-
declare function InitCuekit(apiKey: string
|
|
54
|
+
declare function InitCuekit(apiKey: string): void;
|
|
50
55
|
|
|
51
56
|
declare const useVoiceRecognition: (lang?: string) => {
|
|
52
57
|
isListening: boolean;
|
|
@@ -55,4 +60,4 @@ declare const useVoiceRecognition: (lang?: string) => {
|
|
|
55
60
|
speechText: string;
|
|
56
61
|
};
|
|
57
62
|
|
|
58
|
-
export { CuekitProvider, InitCuekit, MicButton, onStateChange, processVoice, useAudioController, useVoiceRecognition };
|
|
63
|
+
export { CuekitProvider, InitCuekit, MicButton, navigate, onStateChange, processVoice, safeNavigate, setNavigationHandler, setNavigator, useAudioController, useVoiceRecognition };
|