@revrag-ai/embed-react-native 1.0.16 → 1.0.17
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 +6 -108
- package/dist/commonjs/api/api.js +6 -5
- package/dist/commonjs/api/api.js.map +1 -1
- package/dist/commonjs/components/Embed/EmbedButton.js +138 -345
- package/dist/commonjs/components/Embed/EmbedButton.js.map +1 -1
- package/dist/commonjs/components/Embed/EmbedVoice.js +16 -4
- package/dist/commonjs/components/Embed/EmbedVoice.js.map +1 -1
- package/dist/commonjs/context/EmbedProvider.js +638 -0
- package/dist/commonjs/context/EmbedProvider.js.map +1 -0
- package/dist/commonjs/events/embed.event.js +141 -54
- package/dist/commonjs/events/embed.event.js.map +1 -1
- package/dist/commonjs/hooks/EmbedButton.animations.js +181 -0
- package/dist/commonjs/hooks/EmbedButton.animations.js.map +1 -0
- package/dist/commonjs/hooks/EmbedButton.helpers.js +90 -0
- package/dist/commonjs/hooks/EmbedButton.helpers.js.map +1 -0
- package/dist/commonjs/hooks/EmbedButton.hooks.js +165 -0
- package/dist/commonjs/hooks/EmbedButton.hooks.js.map +1 -0
- package/dist/commonjs/hooks/initialize.js +65 -25
- package/dist/commonjs/hooks/initialize.js.map +1 -1
- package/dist/commonjs/hooks/voiceagent.js +1 -18
- package/dist/commonjs/hooks/voiceagent.js.map +1 -1
- package/dist/commonjs/index.js +16 -1
- package/dist/commonjs/index.js.map +1 -1
- package/dist/commonjs/index.types.js +1 -2
- package/dist/commonjs/index.types.js.map +1 -1
- package/dist/commonjs/utils/constant.js +88 -0
- package/dist/commonjs/utils/constant.js.map +1 -0
- package/dist/commonjs/utils/reanimated.helper.js +2 -3
- package/dist/commonjs/utils/reanimated.helper.js.map +1 -1
- package/dist/module/api/api.js +6 -6
- package/dist/module/api/api.js.map +1 -1
- package/dist/module/components/Embed/EmbedButton.js +140 -347
- package/dist/module/components/Embed/EmbedButton.js.map +1 -1
- package/dist/module/components/Embed/EmbedVoice.js +16 -4
- package/dist/module/components/Embed/EmbedVoice.js.map +1 -1
- package/dist/module/context/EmbedProvider.js +626 -0
- package/dist/module/context/EmbedProvider.js.map +1 -0
- package/dist/module/events/embed.event.js +143 -53
- package/dist/module/events/embed.event.js.map +1 -1
- package/dist/module/hooks/EmbedButton.animations.js +172 -0
- package/dist/module/hooks/EmbedButton.animations.js.map +1 -0
- package/dist/module/hooks/EmbedButton.helpers.js +80 -0
- package/dist/module/hooks/EmbedButton.helpers.js.map +1 -0
- package/dist/module/hooks/EmbedButton.hooks.js +160 -0
- package/dist/module/hooks/EmbedButton.hooks.js.map +1 -0
- package/dist/module/hooks/initialize.js +66 -26
- package/dist/module/hooks/initialize.js.map +1 -1
- package/dist/module/hooks/voiceagent.js +1 -17
- package/dist/module/hooks/voiceagent.js.map +1 -1
- package/dist/module/index.js +4 -2
- package/dist/module/index.js.map +1 -1
- package/dist/module/index.types.js +1 -2
- package/dist/module/index.types.js.map +1 -1
- package/dist/module/utils/constant.js +82 -0
- package/dist/module/utils/constant.js.map +1 -0
- package/dist/module/utils/reanimated.helper.js +2 -3
- package/dist/module/utils/reanimated.helper.js.map +1 -1
- package/dist/typescript/src/api/api.d.ts +4 -3
- package/dist/typescript/src/api/api.d.ts.map +1 -1
- package/dist/typescript/src/api/types/embed.api.types.d.ts +1 -1
- package/dist/typescript/src/api/types/embed.api.types.d.ts.map +1 -1
- package/dist/typescript/src/components/Embed/EmbedButton.d.ts +5 -25
- package/dist/typescript/src/components/Embed/EmbedButton.d.ts.map +1 -1
- package/dist/typescript/src/components/Embed/EmbedVoice.d.ts.map +1 -1
- package/dist/typescript/src/context/EmbedProvider.d.ts +306 -0
- package/dist/typescript/src/context/EmbedProvider.d.ts.map +1 -0
- package/dist/typescript/src/events/embed.event.d.ts +74 -10
- package/dist/typescript/src/events/embed.event.d.ts.map +1 -1
- package/dist/typescript/src/hooks/EmbedButton.animations.d.ts +38 -0
- package/dist/typescript/src/hooks/EmbedButton.animations.d.ts.map +1 -0
- package/dist/typescript/src/hooks/EmbedButton.helpers.d.ts +49 -0
- package/dist/typescript/src/hooks/EmbedButton.helpers.d.ts.map +1 -0
- package/dist/typescript/src/hooks/EmbedButton.hooks.d.ts +49 -0
- package/dist/typescript/src/hooks/EmbedButton.hooks.d.ts.map +1 -0
- package/dist/typescript/src/hooks/initialize.d.ts.map +1 -1
- package/dist/typescript/src/hooks/types/initialize.types.d.ts +1 -1
- package/dist/typescript/src/hooks/types/initialize.types.d.ts.map +1 -1
- package/dist/typescript/src/hooks/voiceagent.d.ts.map +1 -1
- package/dist/typescript/src/index.d.ts +10 -4
- package/dist/typescript/src/index.d.ts.map +1 -1
- package/dist/typescript/src/index.types.d.ts +2 -3
- package/dist/typescript/src/index.types.d.ts.map +1 -1
- package/dist/typescript/src/utils/constant.d.ts +45 -0
- package/dist/typescript/src/utils/constant.d.ts.map +1 -0
- package/dist/typescript/src/utils/reanimated.helper.d.ts.map +1 -1
- package/package.json +6 -3
- package/react-native.config.js +1 -0
- package/dist/commonjs/events/eventEmitter.js +0 -43
- package/dist/commonjs/events/eventEmitter.js.map +0 -1
- package/dist/module/events/eventEmitter.js +0 -39
- package/dist/module/events/eventEmitter.js.map +0 -1
- package/dist/typescript/src/events/eventEmitter.d.ts +0 -9
- package/dist/typescript/src/events/eventEmitter.d.ts.map +0 -1
|
@@ -1,36 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @file
|
|
3
|
-
* @description A customizable floating action button component for
|
|
4
|
-
*
|
|
2
|
+
* @file EmbedButton.tsx
|
|
3
|
+
* @description A customizable floating action button component for voice agent interactions.
|
|
4
|
+
* Features: draggable, expandable, animated, with call controls and auto-trigger support.
|
|
5
5
|
*/
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* EmbedButton - Main voice agent floating action button
|
|
8
8
|
*
|
|
9
|
-
* A floating action button that can be dragged around the screen and expanded to show additional content.
|
|
10
|
-
* Features include:
|
|
11
|
-
* - Draggable functionality
|
|
12
|
-
* - Expandable menu
|
|
13
|
-
* - Animated transitions
|
|
14
|
-
* - Gradient background
|
|
15
|
-
* - Customizable styling
|
|
16
|
-
*
|
|
17
|
-
* @component
|
|
18
9
|
* @example
|
|
19
10
|
* ```tsx
|
|
20
|
-
* <
|
|
21
|
-
* isOpen={false}
|
|
22
|
-
* onPress={(isOpen) => console.log('Button pressed:', isOpen)}
|
|
23
|
-
* menuComponent={<YourMenuComponent />}
|
|
24
|
-
* />
|
|
11
|
+
* <EmbedButton />
|
|
25
12
|
* ```
|
|
26
13
|
*/
|
|
27
|
-
/**
|
|
28
|
-
* Generates random sentences for testing or placeholder content
|
|
29
|
-
* @param count - Number of sentences to generate (default: 1)
|
|
30
|
-
* @param minWords - Minimum words per sentence (default: 5)
|
|
31
|
-
* @param maxWords - Maximum words per sentence (default: 15)
|
|
32
|
-
* @returns Array of random sentences
|
|
33
|
-
*/
|
|
34
14
|
export declare function EmbedButton(): import("react/jsx-runtime").JSX.Element | null;
|
|
35
15
|
export default EmbedButton;
|
|
36
16
|
//# sourceMappingURL=EmbedButton.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmbedButton.d.ts","sourceRoot":"","sources":["../../../../../src/components/Embed/EmbedButton.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"EmbedButton.d.ts","sourceRoot":"","sources":["../../../../../src/components/Embed/EmbedButton.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAyDH;;;;;;;GAOG;AACH,wBAAgB,WAAW,mDAyQ1B;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmbedVoice.d.ts","sourceRoot":"","sources":["../../../../../src/components/Embed/EmbedVoice.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,KAAK,SAAS,EAA+B,MAAM,OAAO,CAAC;AAEpE,UAAU,UAAU;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,OAAO,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;CAC1B;AASD,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB;AAUD,QAAA,MAAM,KAAK,GAAI,OAAO,UAAU,
|
|
1
|
+
{"version":3,"file":"EmbedVoice.d.ts","sourceRoot":"","sources":["../../../../../src/components/Embed/EmbedVoice.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,KAAK,SAAS,EAA+B,MAAM,OAAO,CAAC;AAEpE,UAAU,UAAU;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,OAAO,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;CAC1B;AASD,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB;AAUD,QAAA,MAAM,KAAK,GAAI,OAAO,UAAU,mDAsH/B,CAAC;AAEF,eAAe,KAAK,CAAC"}
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file EmbedProvider.tsx
|
|
3
|
+
* @description Core provider component for the Embed React Native library.
|
|
4
|
+
*
|
|
5
|
+
* This provider:
|
|
6
|
+
* - Tracks navigation state and screen changes
|
|
7
|
+
* - Conditionally renders the EmbedButton based on current screen
|
|
8
|
+
* - Provides utilities for extracting navigation hierarchy information
|
|
9
|
+
* - Manages event tracking integration with the Embed system
|
|
10
|
+
*
|
|
11
|
+
* @module EmbedProvider
|
|
12
|
+
*/
|
|
13
|
+
import type { NavigationContainerRef } from '@react-navigation/native';
|
|
14
|
+
import React from 'react';
|
|
15
|
+
/**
|
|
16
|
+
* Props for the EmbedProvider component
|
|
17
|
+
* @interface EmbedProviderProps
|
|
18
|
+
*/
|
|
19
|
+
interface EmbedProviderProps {
|
|
20
|
+
/** Child components to render within the provider */
|
|
21
|
+
children: React.ReactNode;
|
|
22
|
+
/** Optional navigation ref for tracking navigation state */
|
|
23
|
+
navigationRef?: React.RefObject<NavigationContainerRef<any>>;
|
|
24
|
+
/**
|
|
25
|
+
* Optional list of screen names where the EmbedButton SHOULD be displayed.
|
|
26
|
+
* If provided, the button is rendered only on these screens.
|
|
27
|
+
* If omitted/empty, the button is shown on all screens (subject to backend config).
|
|
28
|
+
* @example ['Home', 'Profile']
|
|
29
|
+
*/
|
|
30
|
+
includeScreens?: string[];
|
|
31
|
+
/**
|
|
32
|
+
* Optional app version information from the host app
|
|
33
|
+
* Pass this to include accurate version tracking in analytics
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* import packageJson from './package.json';
|
|
37
|
+
* <EmbedProvider appVersion={packageJson.version}>
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
appVersion: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Represents the complete hierarchical structure of the current navigation state
|
|
44
|
+
* @interface RouteHierarchy
|
|
45
|
+
*/
|
|
46
|
+
export interface RouteHierarchy {
|
|
47
|
+
/** The active/deepest screen name (leaf node in the navigation tree) */
|
|
48
|
+
currentScreen: string;
|
|
49
|
+
/** Complete navigation path (e.g., "Root > Tab > Screen") */
|
|
50
|
+
fullPath: string;
|
|
51
|
+
/** Array of route names from root to current [Level0, Level1, Level2, ...] */
|
|
52
|
+
allRoutes: string[];
|
|
53
|
+
/** Navigation depth (number of levels in the tree) */
|
|
54
|
+
depth: number;
|
|
55
|
+
/** Map of route names by level: { 0: "RootScreen", 1: "TabScreen", 2: "InnerScreen" } */
|
|
56
|
+
routesByLevel: Record<number, string>;
|
|
57
|
+
/** The immediate parent route (one level up from current) */
|
|
58
|
+
parentRoute?: string;
|
|
59
|
+
/** Parameters of the current/active route */
|
|
60
|
+
routeParams?: Record<string, any>;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Represents a node in the navigation tree structure
|
|
64
|
+
* @interface NavigationTreeNode
|
|
65
|
+
*/
|
|
66
|
+
export interface NavigationTreeNode {
|
|
67
|
+
/** Route name */
|
|
68
|
+
name: string;
|
|
69
|
+
/** Navigation level/depth (0 = root) */
|
|
70
|
+
level: number;
|
|
71
|
+
/** Route parameters, if any */
|
|
72
|
+
params?: Record<string, any>;
|
|
73
|
+
/** Child routes (nested navigators) */
|
|
74
|
+
children?: NavigationTreeNode[];
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Extracts complete route hierarchy information from navigation state
|
|
78
|
+
*
|
|
79
|
+
* This function traverses the navigation state tree recursively to build
|
|
80
|
+
* a comprehensive hierarchy object containing the current screen, full path,
|
|
81
|
+
* depth, and route information at each level.
|
|
82
|
+
*
|
|
83
|
+
* @param {any} state - Navigation state from navigationRef.current?.getRootState()
|
|
84
|
+
* @returns {RouteHierarchy | null} Complete route hierarchy or null if state is invalid
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```typescript
|
|
88
|
+
* const routeInfo = getRouteHierarchy(navigationRef.current?.getRootState());
|
|
89
|
+
* console.log(routeInfo);
|
|
90
|
+
* // {
|
|
91
|
+
* // currentScreen: "Product",
|
|
92
|
+
* // fullPath: "MainApp > Home > Product",
|
|
93
|
+
* // allRoutes: ["MainApp", "Home", "Product"],
|
|
94
|
+
* // depth: 3,
|
|
95
|
+
* // routesByLevel: { 0: "MainApp", 1: "Home", 2: "Product" },
|
|
96
|
+
* // parentRoute: "Home",
|
|
97
|
+
* // routeParams: { id: "123" }
|
|
98
|
+
* // }
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
export declare const getRouteHierarchy: (state: any) => RouteHierarchy | null;
|
|
102
|
+
/**
|
|
103
|
+
* Extracts ALL available routes (both mounted and defined) from navigation state
|
|
104
|
+
*
|
|
105
|
+
* This function traverses the navigation state and returns a flat array of:
|
|
106
|
+
* 1. Currently MOUNTED routes (routes that are rendered in the navigation tree)
|
|
107
|
+
* 2. DEFINED routes (from routeNames - routes that exist but may not be rendered yet)
|
|
108
|
+
*
|
|
109
|
+
* This is particularly useful because nested navigators (like tab navigators)
|
|
110
|
+
* won't appear in the state until you navigate to them, but their route names
|
|
111
|
+
* are still defined in the navigator configuration.
|
|
112
|
+
*
|
|
113
|
+
* @param {any} state - Navigation state from navigationRef.current?.getRootState()
|
|
114
|
+
* @returns {string[]} Array of unique route names
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```typescript
|
|
118
|
+
* const allRoutes = getAllRoutes(navigationRef.current?.getRootState());
|
|
119
|
+
* console.log(allRoutes);
|
|
120
|
+
* // ["Splash", "Welcome", "MainApp", "Home", "Transactions", "Profile"]
|
|
121
|
+
*
|
|
122
|
+
* // Check if a specific route is available
|
|
123
|
+
* const hasProfileScreen = allRoutes.includes("Profile");
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
126
|
+
export declare const getAllRoutes: (state: any) => string[];
|
|
127
|
+
/**
|
|
128
|
+
* Builds a complete navigation tree structure showing all routes and their relationships
|
|
129
|
+
*
|
|
130
|
+
* This function creates a hierarchical tree structure representing the entire
|
|
131
|
+
* navigation state, including all routes at all levels (not just the active path).
|
|
132
|
+
* Useful for visualizing or debugging your navigation structure.
|
|
133
|
+
*
|
|
134
|
+
* @param {any} state - Navigation state from navigationRef.current?.getRootState()
|
|
135
|
+
* @returns {NavigationTreeNode[]} Array of NavigationTreeNode representing the complete tree
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```typescript
|
|
139
|
+
* const tree = getNavigationTree(navigationRef.current?.getRootState());
|
|
140
|
+
* console.log(JSON.stringify(tree, null, 2));
|
|
141
|
+
*
|
|
142
|
+
* // Example output:
|
|
143
|
+
* // [
|
|
144
|
+
* // {
|
|
145
|
+
* // "name": "MainApp",
|
|
146
|
+
* // "level": 0,
|
|
147
|
+
* // "children": [
|
|
148
|
+
* // {
|
|
149
|
+
* // "name": "Home",
|
|
150
|
+
* // "level": 1,
|
|
151
|
+
* // "children": [
|
|
152
|
+
* // { "name": "HomeMain", "level": 2 },
|
|
153
|
+
* // { "name": "Product", "level": 2, "params": { "id": "123" } }
|
|
154
|
+
* // ]
|
|
155
|
+
* // },
|
|
156
|
+
* // { "name": "Profile", "level": 1 }
|
|
157
|
+
* // ]
|
|
158
|
+
* // }
|
|
159
|
+
* // ]
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
162
|
+
export declare const getNavigationTree: (state: any) => NavigationTreeNode[];
|
|
163
|
+
/**
|
|
164
|
+
* Legacy alias for getAllRoutes()
|
|
165
|
+
* @deprecated Use getAllRoutes() instead
|
|
166
|
+
*
|
|
167
|
+
* Note: React Navigation limitation - nested navigator routes (like tabs inside a stack)
|
|
168
|
+
* only appear in the state AFTER they're mounted/rendered.
|
|
169
|
+
*
|
|
170
|
+
* @param {any} state - Navigation state
|
|
171
|
+
* @returns {string[]} Array of route names
|
|
172
|
+
*/
|
|
173
|
+
export declare const getAllDefinedRoutes: (state: any) => string[];
|
|
174
|
+
/**
|
|
175
|
+
* Interface for app version information
|
|
176
|
+
* @interface AppVersionInfo
|
|
177
|
+
*/
|
|
178
|
+
export interface AppVersionInfo {
|
|
179
|
+
/** App version name/string (e.g., "1.2.3") */
|
|
180
|
+
version: string;
|
|
181
|
+
/** App build number (iOS: CFBundleVersion, Android: versionCode) */
|
|
182
|
+
buildNumber: string;
|
|
183
|
+
/** Platform (iOS or Android) */
|
|
184
|
+
platform: string;
|
|
185
|
+
/** Full version string combining version and build */
|
|
186
|
+
fullVersion: string;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Track custom events with the Embed system
|
|
190
|
+
*
|
|
191
|
+
* This function provides a simple interface to send custom event data
|
|
192
|
+
* to the Embed analytics system. All errors are caught and handled silently
|
|
193
|
+
* to prevent analytics issues from affecting app functionality.
|
|
194
|
+
*
|
|
195
|
+
* @param {string} eventName - Name of the event to track
|
|
196
|
+
* @param {Record<string, any>} properties - Event properties/metadata (optional)
|
|
197
|
+
*
|
|
198
|
+
* @example
|
|
199
|
+
* ```typescript
|
|
200
|
+
* // Track a button click
|
|
201
|
+
* trackEmbedEvent('button_clicked', {
|
|
202
|
+
* buttonId: 'submit_form',
|
|
203
|
+
* screenName: 'Profile',
|
|
204
|
+
* });
|
|
205
|
+
*
|
|
206
|
+
* // Track a purchase
|
|
207
|
+
* trackEmbedEvent('purchase_completed', {
|
|
208
|
+
* amount: 99.99,
|
|
209
|
+
* currency: 'USD',
|
|
210
|
+
* items: ['item1', 'item2'],
|
|
211
|
+
* });
|
|
212
|
+
* ```
|
|
213
|
+
*/
|
|
214
|
+
export declare const trackEmbedEvent: (eventName: string, properties?: Record<string, any>) => void;
|
|
215
|
+
/**
|
|
216
|
+
* Track rage clicks (repeated rapid clicks indicating user frustration)
|
|
217
|
+
*
|
|
218
|
+
* Rage clicks are detected when a user clicks the same element multiple times
|
|
219
|
+
* in rapid succession, which can indicate frustration with unresponsive UI.
|
|
220
|
+
* This data helps identify problem areas in the user experience.
|
|
221
|
+
*
|
|
222
|
+
* @param {string} elementId - Unique identifier of the clicked element
|
|
223
|
+
* @param {string} elementType - Type of element (e.g., 'button', 'link', 'text')
|
|
224
|
+
* @param {{ x: number; y: number }} coordinates - Screen coordinates of the clicks
|
|
225
|
+
* @param {number} clickCount - Number of rapid clicks detected
|
|
226
|
+
*
|
|
227
|
+
* @example
|
|
228
|
+
* ```typescript
|
|
229
|
+
* trackRageClick('submit_button', 'button', { x: 100, y: 200 }, 5);
|
|
230
|
+
* ```
|
|
231
|
+
*/
|
|
232
|
+
export declare const trackRageClick: (elementId: string, elementType: string, coordinates: {
|
|
233
|
+
x: number;
|
|
234
|
+
y: number;
|
|
235
|
+
}, clickCount: number) => void;
|
|
236
|
+
/**
|
|
237
|
+
* Track form-related events (changes, submissions, errors)
|
|
238
|
+
*
|
|
239
|
+
* This function tracks various form interactions to help understand
|
|
240
|
+
* user behavior and identify potential issues in form flows.
|
|
241
|
+
*
|
|
242
|
+
* @param {string} formId - Unique identifier of the form
|
|
243
|
+
* @param {'form_change' | 'form_submit' | 'form_error'} eventType - Type of form event
|
|
244
|
+
* @param {Record<string, any>} formData - Form data/metadata (optional)
|
|
245
|
+
*
|
|
246
|
+
* @example
|
|
247
|
+
* ```typescript
|
|
248
|
+
* // Track form field change
|
|
249
|
+
* trackFormEvent('signup_form', 'form_change', {
|
|
250
|
+
* field: 'email',
|
|
251
|
+
* value: 'user@example.com',
|
|
252
|
+
* });
|
|
253
|
+
*
|
|
254
|
+
* // Track form submission
|
|
255
|
+
* trackFormEvent('signup_form', 'form_submit', {
|
|
256
|
+
* success: true,
|
|
257
|
+
* userId: '12345',
|
|
258
|
+
* });
|
|
259
|
+
*
|
|
260
|
+
* // Track form error
|
|
261
|
+
* trackFormEvent('signup_form', 'form_error', {
|
|
262
|
+
* field: 'password',
|
|
263
|
+
* error: 'Password too short',
|
|
264
|
+
* });
|
|
265
|
+
* ```
|
|
266
|
+
*/
|
|
267
|
+
export declare const trackFormEvent: (formId: string, eventType: "form_change" | "form_submit" | "form_error", formData?: Record<string, any>) => void;
|
|
268
|
+
/**
|
|
269
|
+
* EmbedProvider Component
|
|
270
|
+
*
|
|
271
|
+
* Core provider component that wraps your application to enable Embed functionality.
|
|
272
|
+
* This provider:
|
|
273
|
+
* - Monitors navigation state changes
|
|
274
|
+
* - Automatically shows/hides the EmbedButton based on current screen
|
|
275
|
+
* - Tracks screen views and navigation hierarchy
|
|
276
|
+
* - Integrates with the Embed analytics system
|
|
277
|
+
*
|
|
278
|
+
* @param {EmbedProviderProps} props - Component props
|
|
279
|
+
* @returns {JSX.Element} Provider component with children and conditional EmbedButton
|
|
280
|
+
*
|
|
281
|
+
* @example
|
|
282
|
+
* ```typescript
|
|
283
|
+
* import { NavigationContainer } from '@react-navigation/native';
|
|
284
|
+
* import { EmbedProvider } from '@revrag/embed-react-native';
|
|
285
|
+
* import { useRef } from 'react';
|
|
286
|
+
*
|
|
287
|
+
* function App() {
|
|
288
|
+
* const navigationRef = useRef<NavigationContainerRef<any>>(null);
|
|
289
|
+
*
|
|
290
|
+
* return (
|
|
291
|
+
* // IMPORTANT: EmbedProvider must WRAP NavigationContainer
|
|
292
|
+
* <EmbedProvider
|
|
293
|
+
* navigationRef={navigationRef}
|
|
294
|
+
* includeScreens={['Home', 'Profile', 'Dashboard']}
|
|
295
|
+
* >
|
|
296
|
+
* <NavigationContainer ref={navigationRef}>
|
|
297
|
+
* {/* Your navigation stack *\/}
|
|
298
|
+
* </NavigationContainer>
|
|
299
|
+
* </EmbedProvider>
|
|
300
|
+
* );
|
|
301
|
+
* }
|
|
302
|
+
* ```
|
|
303
|
+
*/
|
|
304
|
+
export declare const EmbedProvider: React.FC<EmbedProviderProps>;
|
|
305
|
+
export default EmbedProvider;
|
|
306
|
+
//# sourceMappingURL=EmbedProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EmbedProvider.d.ts","sourceRoot":"","sources":["../../../../src/context/EmbedProvider.tsx"],"names":[],"mappings":"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"}
|
|
@@ -1,28 +1,92 @@
|
|
|
1
|
-
import TypedEventEmitter from './eventEmitter';
|
|
2
1
|
type EventCallback = (data: any) => void;
|
|
3
2
|
export declare enum EventKeys {
|
|
4
3
|
USER_DATA = "user_data",
|
|
5
4
|
SCREEN_STATE = "screen_state",
|
|
6
5
|
OFFER_STATE = "offer_state",
|
|
7
|
-
|
|
8
|
-
FORM_STATE = "form_state"
|
|
6
|
+
CUSTOM_EVENT = "custom_event",
|
|
7
|
+
FORM_STATE = "form_state",
|
|
8
|
+
ACTION_STATE = "action_state",
|
|
9
|
+
ERROR_STATE = "error_state",
|
|
10
|
+
SUCCESS_STATE = "success_state",
|
|
11
|
+
WARNING_STATE = "warning_state",
|
|
12
|
+
INFO_STATE = "info_state",
|
|
13
|
+
DEBUG_STATE = "debug_state"
|
|
9
14
|
}
|
|
10
15
|
export declare enum AgentEvent {
|
|
11
16
|
AGENT_CONNECTED = "agent_connected",
|
|
12
17
|
AGENT_DISCONNECTED = "agent_disconnected",
|
|
13
18
|
POPUP_MESSAGE_VISIBLE = "popup_message_visible"
|
|
14
19
|
}
|
|
20
|
+
export interface AgentConnectedData {
|
|
21
|
+
timestamp: string;
|
|
22
|
+
metadata?: Record<string, any>;
|
|
23
|
+
}
|
|
24
|
+
export interface AgentDisconnectedData {
|
|
25
|
+
timestamp: string;
|
|
26
|
+
metadata?: Record<string, any>;
|
|
27
|
+
}
|
|
28
|
+
export interface PopupMessageVisibleData {
|
|
29
|
+
value: boolean;
|
|
30
|
+
metadata?: {
|
|
31
|
+
trigger?: string;
|
|
32
|
+
[key: string]: any;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Agent Event Emitter
|
|
37
|
+
* Handles listening to agent state changes (connection, disconnection, popup visibility)
|
|
38
|
+
* Also sends agent events to the backend API
|
|
39
|
+
*/
|
|
40
|
+
declare class AgentEventEmitter {
|
|
41
|
+
private agentListeners;
|
|
42
|
+
/**
|
|
43
|
+
* Add an event listener for agent events
|
|
44
|
+
* @param eventKey - The agent event to listen for
|
|
45
|
+
* @param callback - Callback function to execute when event fires
|
|
46
|
+
*/
|
|
47
|
+
on(eventKey: AgentEvent, callback: EventCallback): void;
|
|
48
|
+
/**
|
|
49
|
+
* Remove an event listener for agent events
|
|
50
|
+
* @param eventKey - The agent event to stop listening to
|
|
51
|
+
* @param callback - The callback function to remove
|
|
52
|
+
*/
|
|
53
|
+
off(eventKey: AgentEvent, callback: EventCallback): void;
|
|
54
|
+
/**
|
|
55
|
+
* Emit an agent event to all registered listeners AND send to backend
|
|
56
|
+
* @param eventKey - The agent event to emit
|
|
57
|
+
* @param data - Data to pass to listeners
|
|
58
|
+
* @internal - Used internally by the library
|
|
59
|
+
*/
|
|
60
|
+
emit(eventKey: AgentEvent, data: any): Promise<void>;
|
|
61
|
+
/**
|
|
62
|
+
* Send agent event data to backend API
|
|
63
|
+
* @param eventKey - The agent event type
|
|
64
|
+
* @param data - Event data
|
|
65
|
+
* @private
|
|
66
|
+
*/
|
|
67
|
+
private sendToBackend;
|
|
68
|
+
/**
|
|
69
|
+
* Remove all listeners for a specific event
|
|
70
|
+
* @param eventKey - The agent event to clear listeners for
|
|
71
|
+
*/
|
|
72
|
+
removeAllListeners(eventKey?: AgentEvent): void;
|
|
73
|
+
}
|
|
15
74
|
declare class Embed {
|
|
16
75
|
private events;
|
|
17
|
-
event:
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
76
|
+
event: AgentEventEmitter;
|
|
77
|
+
constructor();
|
|
78
|
+
private ensureDefaultListener;
|
|
79
|
+
/**
|
|
80
|
+
* Send an event to the AI agent
|
|
81
|
+
* @param eventKey - The event type to send
|
|
82
|
+
* @param data - Event data payload
|
|
83
|
+
*/
|
|
23
84
|
Event(eventKey: string, data: any): Promise<void>;
|
|
85
|
+
/**
|
|
86
|
+
* Add listener for data events (legacy support)
|
|
87
|
+
* @deprecated Use event.on() for agent events instead
|
|
88
|
+
*/
|
|
24
89
|
on(eventKey: EventKeys, callback: EventCallback): void;
|
|
25
|
-
isUserDataInitialized(): boolean;
|
|
26
90
|
}
|
|
27
91
|
declare const embed: Embed;
|
|
28
92
|
export default embed;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"embed.event.d.ts","sourceRoot":"","sources":["../../../../src/events/embed.event.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"embed.event.d.ts","sourceRoot":"","sources":["../../../../src/events/embed.event.ts"],"names":[],"mappings":"AAIA,KAAK,aAAa,GAAG,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC;AAGzC,oBAAY,SAAS;IACnB,SAAS,cAAc;IACvB,YAAY,iBAAiB;IAC7B,WAAW,gBAAgB;IAC3B,YAAY,iBAAiB;IAC7B,UAAU,eAAe;IACzB,YAAY,iBAAiB;IAC7B,WAAW,gBAAgB;IAC3B,aAAa,kBAAkB;IAC/B,aAAa,kBAAkB;IAC/B,UAAU,eAAe;IACzB,WAAW,gBAAgB;CAC5B;AAGD,oBAAY,UAAU;IACpB,eAAe,oBAAoB;IACnC,kBAAkB,uBAAuB;IACzC,qBAAqB,0BAA0B;CAChD;AAGD,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAChC;AAED,MAAM,WAAW,qBAAqB;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAChC;AAED,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,OAAO,CAAC;IACf,QAAQ,CAAC,EAAE;QACT,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,CAAC;CACH;AAED;;;;GAIG;AACH,cAAM,iBAAiB;IACrB,OAAO,CAAC,cAAc,CAAiD;IAEvE;;;;OAIG;IACH,EAAE,CAAC,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,aAAa,GAAG,IAAI;IAOvD;;;;OAIG;IACH,GAAG,CAAC,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,aAAa,GAAG,IAAI;IASxD;;;;;OAKG;IACG,IAAI,CAAC,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAc1D;;;;;OAKG;YACW,aAAa;IAuC3B;;;OAGG;IACH,kBAAkB,CAAC,QAAQ,CAAC,EAAE,UAAU,GAAG,IAAI;CAOhD;AAED,cAAM,KAAK;IACT,OAAO,CAAC,MAAM,CAAgD;IAGvD,KAAK,EAAE,iBAAiB,CAAC;;IAOhC,OAAO,CAAC,qBAAqB;IAW7B;;;;OAIG;IACG,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG;IA2CvC;;;OAGG;IACH,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,aAAa;CAMhD;AAED,QAAA,MAAM,KAAK,OAAc,CAAC;AAC1B,eAAe,KAAK,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file EmbedButton.animations.ts
|
|
3
|
+
* @description Animation logic and hooks for the EmbedButton component
|
|
4
|
+
*/
|
|
5
|
+
declare const Animated: any;
|
|
6
|
+
export { Animated };
|
|
7
|
+
/**
|
|
8
|
+
* Hook to initialize and manage all animation shared values
|
|
9
|
+
*/
|
|
10
|
+
export declare const useAnimationValues: () => {
|
|
11
|
+
isPressed: any;
|
|
12
|
+
offset: any;
|
|
13
|
+
start: any;
|
|
14
|
+
menuAnimation: any;
|
|
15
|
+
buttonWidth: any;
|
|
16
|
+
buttonScale: any;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Hook to handle button expand/collapse animations
|
|
20
|
+
*/
|
|
21
|
+
export declare const useButtonAnimations: (isOpen: boolean, menuAnimation: any, buttonWidth: any) => void;
|
|
22
|
+
/**
|
|
23
|
+
* Hook to handle breathing animation when auto-popup is shown
|
|
24
|
+
*/
|
|
25
|
+
export declare const useBreathingAnimation: (isOpen: boolean, isAutoOpen: boolean, buttonScale: any) => void;
|
|
26
|
+
/**
|
|
27
|
+
* Hook to create animated styles for the button
|
|
28
|
+
*/
|
|
29
|
+
export declare const useButtonAnimatedStyles: (isOpen: boolean, offset: any, buttonWidth: any, isPressed: any, buttonScale: any) => any;
|
|
30
|
+
/**
|
|
31
|
+
* Hook to create animated styles for the popup text
|
|
32
|
+
*/
|
|
33
|
+
export declare const usePopupAnimatedStyles: (offset: any, isPressed: any) => any;
|
|
34
|
+
/**
|
|
35
|
+
* Create pan gesture for drag functionality
|
|
36
|
+
*/
|
|
37
|
+
export declare const createPanGesture: (isPressed: any, offset: any, start: any, isOpen: boolean, setIsAutoOpen: (value: boolean) => void) => import("react-native-gesture-handler/lib/typescript/handlers/gestures/panGesture").PanGesture;
|
|
38
|
+
//# sourceMappingURL=EmbedButton.animations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EmbedButton.animations.d.ts","sourceRoot":"","sources":["../../../../src/hooks/EmbedButton.animations.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAkBH,QAAA,MASE,QAAQ,KAEY,CAAC;AAQvB,OAAO,EAAE,QAAQ,EAAE,CAAC;AAGpB;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;;;;;CAgB9B,CAAC;AAGF;;GAEG;AACH,eAAO,MAAM,mBAAmB,GAC9B,QAAQ,OAAO,EACf,eAAe,GAAG,EAClB,aAAa,GAAG,SAUjB,CAAC;AAGF;;GAEG;AACH,eAAO,MAAM,qBAAqB,GAChC,QAAQ,OAAO,EACf,YAAY,OAAO,EACnB,aAAa,GAAG,SAwBjB,CAAC;AAGF;;GAEG;AACH,eAAO,MAAM,uBAAuB,GAClC,QAAQ,OAAO,EACf,QAAQ,GAAG,EACX,aAAa,GAAG,EAChB,WAAW,GAAG,EACd,aAAa,GAAG,QAkBjB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,sBAAsB,GAAI,QAAQ,GAAG,EAAE,WAAW,GAAG,QAajE,CAAC;AAGF;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAC3B,WAAW,GAAG,EACd,QAAQ,GAAG,EACX,OAAO,GAAG,EACV,QAAQ,OAAO,EACf,eAAe,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,kGA2BxC,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file EmbedButton.helpers.ts
|
|
3
|
+
* @description Helper functions and utilities for the EmbedButton component
|
|
4
|
+
*/
|
|
5
|
+
export declare const SCREEN_WIDTH: number, SCREEN_HEIGHT: number;
|
|
6
|
+
export declare const BUTTON_DIMENSIONS: {
|
|
7
|
+
readonly WIDTH: 60;
|
|
8
|
+
readonly HEIGHT: 60;
|
|
9
|
+
readonly EXPANDED_WIDTH: number;
|
|
10
|
+
};
|
|
11
|
+
export declare const ICON_URLS: {
|
|
12
|
+
readonly MIC_ON: "https://revrag-dev.s3.ap-south-1.amazonaws.com/Avatars/Mute+button.png";
|
|
13
|
+
readonly MIC_OFF: "https://revrag-dev.s3.ap-south-1.amazonaws.com/Avatars/unmute.png";
|
|
14
|
+
readonly END_CALL: "https://revrag-dev.s3.ap-south-1.amazonaws.com/Avatars/end+button.png";
|
|
15
|
+
readonly AMPLIFY_ANIMATION: "https://revrag-dev.s3.ap-south-1.amazonaws.com/Avatars/amplify.json";
|
|
16
|
+
};
|
|
17
|
+
export declare const DEFAULT_GRADIENT_COLORS: string[];
|
|
18
|
+
export declare const DEFAULT_POPUP_DELAY_MS = 15000;
|
|
19
|
+
export interface ConfigData {
|
|
20
|
+
inactivity_behaviour?: 'show_popup' | 'auto_trigger' | 'none';
|
|
21
|
+
popup_delay_ms?: number | string;
|
|
22
|
+
popup_description?: string;
|
|
23
|
+
icon_animation?: string;
|
|
24
|
+
gradient?: string[];
|
|
25
|
+
agent_name?: string;
|
|
26
|
+
agent_type?: string;
|
|
27
|
+
connect_button_title?: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Safely parse delay value to ensure it's a valid number
|
|
31
|
+
*/
|
|
32
|
+
export declare const parseDelayMs: (delay: number | string | undefined) => number;
|
|
33
|
+
/**
|
|
34
|
+
* Format seconds to MM:SS format
|
|
35
|
+
*/
|
|
36
|
+
export declare const formatDuration: (seconds: number) => string;
|
|
37
|
+
/**
|
|
38
|
+
* Calculate the max X position for button drag constraints
|
|
39
|
+
*/
|
|
40
|
+
export declare const calculateMaxX: (isOpen: boolean) => number;
|
|
41
|
+
/**
|
|
42
|
+
* Calculate the max Y position for button drag constraints
|
|
43
|
+
*/
|
|
44
|
+
export declare const calculateMaxY: () => number;
|
|
45
|
+
/**
|
|
46
|
+
* Clamp a value between a min and max
|
|
47
|
+
*/
|
|
48
|
+
export declare const clamp: (value: number, min: number, max: number) => number;
|
|
49
|
+
//# sourceMappingURL=EmbedButton.helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EmbedButton.helpers.d.ts","sourceRoot":"","sources":["../../../../src/hooks/EmbedButton.helpers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,eAAO,MAAe,YAAY,UAAU,aAAa,QAC/B,CAAC;AAE3B,eAAO,MAAM,iBAAiB;;;;CAIpB,CAAC;AAEX,eAAO,MAAM,SAAS;;;;;CAQZ,CAAC;AAEX,eAAO,MAAM,uBAAuB,UAAyB,CAAC;AAE9D,eAAO,MAAM,sBAAsB,QAAQ,CAAC;AAG5C,MAAM,WAAW,UAAU;IACzB,oBAAoB,CAAC,EAAE,YAAY,GAAG,cAAc,GAAG,MAAM,CAAC;IAC9D,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACjC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAID;;GAEG;AACH,eAAO,MAAM,YAAY,GAAI,OAAO,MAAM,GAAG,MAAM,GAAG,SAAS,KAAG,MAOjE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,GAAI,SAAS,MAAM,KAAG,MAMhD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,GAAI,QAAQ,OAAO,KAAG,MAM/C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,QAAO,MAGhC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,KAAK,GAAI,OAAO,MAAM,EAAE,KAAK,MAAM,EAAE,KAAK,MAAM,KAAG,MAG/D,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file EmbedButton.hooks.ts
|
|
3
|
+
* @description Custom hooks for the EmbedButton component
|
|
4
|
+
*/
|
|
5
|
+
import type { ConfigData } from './EmbedButton.helpers';
|
|
6
|
+
/**
|
|
7
|
+
* Hook to fetch and manage agent configuration data
|
|
8
|
+
*/
|
|
9
|
+
export declare const useConfigData: () => ConfigData | null;
|
|
10
|
+
/**
|
|
11
|
+
* Hook to track call duration when connected
|
|
12
|
+
*/
|
|
13
|
+
export declare const useCallDuration: (connectionState: string) => {
|
|
14
|
+
callDuration: number;
|
|
15
|
+
resetDuration: () => void;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Hook to handle inactivity behavior (show_popup or auto_trigger)
|
|
19
|
+
*/
|
|
20
|
+
interface UseInactivityBehaviorParams {
|
|
21
|
+
configData: ConfigData | null;
|
|
22
|
+
isOpen: boolean;
|
|
23
|
+
isLoading: boolean;
|
|
24
|
+
hasActiveToken: boolean;
|
|
25
|
+
onStartCall: () => Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
export declare const useInactivityBehavior: ({ configData, isOpen, isLoading, hasActiveToken, onStartCall, }: UseInactivityBehaviorParams) => {
|
|
28
|
+
isAutoOpen: boolean;
|
|
29
|
+
setIsAutoOpen: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Hook to manage call lifecycle (start, end, mute)
|
|
33
|
+
*/
|
|
34
|
+
interface UseCallManagementParams {
|
|
35
|
+
initializeVoiceAgent: () => Promise<void>;
|
|
36
|
+
endCall: () => Promise<void>;
|
|
37
|
+
muteMic: () => void;
|
|
38
|
+
unmuteMic: () => void;
|
|
39
|
+
isMicMuted: boolean;
|
|
40
|
+
resetDuration: () => void;
|
|
41
|
+
setIsOpen: (open: boolean) => void;
|
|
42
|
+
}
|
|
43
|
+
export declare const useCallManagement: ({ initializeVoiceAgent, endCall, muteMic, unmuteMic, isMicMuted, resetDuration, setIsOpen, }: UseCallManagementParams) => {
|
|
44
|
+
handleStartCall: () => Promise<void>;
|
|
45
|
+
handleEndCall: () => Promise<void>;
|
|
46
|
+
handleMicToggle: () => void;
|
|
47
|
+
};
|
|
48
|
+
export {};
|
|
49
|
+
//# sourceMappingURL=EmbedButton.hooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EmbedButton.hooks.d.ts","sourceRoot":"","sources":["../../../../src/hooks/EmbedButton.hooks.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAIxD;;GAEG;AACH,eAAO,MAAM,aAAa,yBAiBzB,CAAC;AAGF;;GAEG;AACH,eAAO,MAAM,eAAe,GAAI,iBAAiB,MAAM;;;CAiCtD,CAAC;AAGF;;GAEG;AACH,UAAU,2BAA2B;IACnC,UAAU,EAAE,UAAU,GAAG,IAAI,CAAC;IAC9B,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,cAAc,EAAE,OAAO,CAAC;IACxB,WAAW,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAClC;AAED,eAAO,MAAM,qBAAqB,GAAI,iEAMnC,2BAA2B;;;CAkD7B,CAAC;AAGF;;GAEG;AACH,UAAU,uBAAuB;IAC/B,oBAAoB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1C,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7B,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,UAAU,EAAE,OAAO,CAAC;IACpB,aAAa,EAAE,MAAM,IAAI,CAAC;IAC1B,SAAS,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;CACpC;AAED,eAAO,MAAM,iBAAiB,GAAI,8FAQ/B,uBAAuB;;;;CA0BzB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialize.d.ts","sourceRoot":"","sources":["../../../../src/hooks/initialize.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"initialize.d.ts","sourceRoot":"","sources":["../../../../src/hooks/initialize.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EACV,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,0BAA0B,CAAC;AAMlC,wBAAgB,aAAa,CAAC,EAC5B,MAAM,EACN,QAAQ,GACT,EAAE,kBAAkB,GAAG,mBAAmB,CAgG1C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialize.types.d.ts","sourceRoot":"","sources":["../../../../../src/hooks/types/initialize.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"initialize.types.d.ts","sourceRoot":"","sources":["../../../../../src/hooks/types/initialize.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,aAAa,EAAE,OAAO,CAAC;IACvB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"voiceagent.d.ts","sourceRoot":"","sources":["../../../../src/hooks/voiceagent.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"voiceagent.d.ts","sourceRoot":"","sources":["../../../../src/hooks/voiceagent.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AA+DpE,eAAO,MAAM,aAAa,QAAO,mBAmRhC,CAAC"}
|