@revrag-ai/embed-react-native 1.0.16 → 1.0.18

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.
Files changed (123) hide show
  1. package/README.md +6 -108
  2. package/android/build.gradle +3 -3
  3. package/dist/commonjs/api/api.js +6 -5
  4. package/dist/commonjs/api/api.js.map +1 -1
  5. package/dist/commonjs/components/Embed/EmbedButton.js +138 -345
  6. package/dist/commonjs/components/Embed/EmbedButton.js.map +1 -1
  7. package/dist/commonjs/components/Embed/EmbedVoice.js +16 -4
  8. package/dist/commonjs/components/Embed/EmbedVoice.js.map +1 -1
  9. package/dist/commonjs/context/EmbedProvider.js +638 -0
  10. package/dist/commonjs/context/EmbedProvider.js.map +1 -0
  11. package/dist/commonjs/events/agent-event-emitter.js +114 -0
  12. package/dist/commonjs/events/agent-event-emitter.js.map +1 -0
  13. package/dist/commonjs/events/embed.event.js +93 -79
  14. package/dist/commonjs/events/embed.event.js.map +1 -1
  15. package/dist/commonjs/events/embed.types.js +32 -0
  16. package/dist/commonjs/events/embed.types.js.map +1 -0
  17. package/dist/commonjs/events/embed.validators.js +36 -0
  18. package/dist/commonjs/events/embed.validators.js.map +1 -0
  19. package/dist/commonjs/events/index.js +47 -0
  20. package/dist/commonjs/events/index.js.map +1 -0
  21. package/dist/commonjs/hooks/EmbedButton.animations.js +181 -0
  22. package/dist/commonjs/hooks/EmbedButton.animations.js.map +1 -0
  23. package/dist/commonjs/hooks/EmbedButton.helpers.js +90 -0
  24. package/dist/commonjs/hooks/EmbedButton.helpers.js.map +1 -0
  25. package/dist/commonjs/hooks/EmbedButton.hooks.js +165 -0
  26. package/dist/commonjs/hooks/EmbedButton.hooks.js.map +1 -0
  27. package/dist/commonjs/hooks/initialize.js +65 -25
  28. package/dist/commonjs/hooks/initialize.js.map +1 -1
  29. package/dist/commonjs/hooks/voiceagent.js +1 -18
  30. package/dist/commonjs/hooks/voiceagent.js.map +1 -1
  31. package/dist/commonjs/index.js +16 -1
  32. package/dist/commonjs/index.js.map +1 -1
  33. package/dist/commonjs/index.types.js +1 -2
  34. package/dist/commonjs/index.types.js.map +1 -1
  35. package/dist/commonjs/utils/constant.js +99 -0
  36. package/dist/commonjs/utils/constant.js.map +1 -0
  37. package/dist/commonjs/utils/permision.js +48 -1
  38. package/dist/commonjs/utils/permision.js.map +1 -1
  39. package/dist/commonjs/utils/reanimated.helper.js +2 -3
  40. package/dist/commonjs/utils/reanimated.helper.js.map +1 -1
  41. package/dist/module/api/api.js +6 -6
  42. package/dist/module/api/api.js.map +1 -1
  43. package/dist/module/components/Embed/EmbedButton.js +140 -347
  44. package/dist/module/components/Embed/EmbedButton.js.map +1 -1
  45. package/dist/module/components/Embed/EmbedVoice.js +16 -4
  46. package/dist/module/components/Embed/EmbedVoice.js.map +1 -1
  47. package/dist/module/context/EmbedProvider.js +626 -0
  48. package/dist/module/context/EmbedProvider.js.map +1 -0
  49. package/dist/module/events/agent-event-emitter.js +109 -0
  50. package/dist/module/events/agent-event-emitter.js.map +1 -0
  51. package/dist/module/events/embed.event.js +82 -80
  52. package/dist/module/events/embed.event.js.map +1 -1
  53. package/dist/module/events/embed.types.js +33 -0
  54. package/dist/module/events/embed.types.js.map +1 -0
  55. package/dist/module/events/embed.validators.js +32 -0
  56. package/dist/module/events/embed.validators.js.map +1 -0
  57. package/dist/module/events/index.js +12 -0
  58. package/dist/module/events/index.js.map +1 -0
  59. package/dist/module/hooks/EmbedButton.animations.js +172 -0
  60. package/dist/module/hooks/EmbedButton.animations.js.map +1 -0
  61. package/dist/module/hooks/EmbedButton.helpers.js +80 -0
  62. package/dist/module/hooks/EmbedButton.helpers.js.map +1 -0
  63. package/dist/module/hooks/EmbedButton.hooks.js +160 -0
  64. package/dist/module/hooks/EmbedButton.hooks.js.map +1 -0
  65. package/dist/module/hooks/initialize.js +66 -26
  66. package/dist/module/hooks/initialize.js.map +1 -1
  67. package/dist/module/hooks/voiceagent.js +1 -17
  68. package/dist/module/hooks/voiceagent.js.map +1 -1
  69. package/dist/module/index.js +4 -2
  70. package/dist/module/index.js.map +1 -1
  71. package/dist/module/index.types.js +1 -2
  72. package/dist/module/index.types.js.map +1 -1
  73. package/dist/module/utils/constant.js +93 -0
  74. package/dist/module/utils/constant.js.map +1 -0
  75. package/dist/module/utils/permision.js +48 -1
  76. package/dist/module/utils/permision.js.map +1 -1
  77. package/dist/module/utils/reanimated.helper.js +2 -3
  78. package/dist/module/utils/reanimated.helper.js.map +1 -1
  79. package/dist/typescript/src/api/api.d.ts +4 -3
  80. package/dist/typescript/src/api/api.d.ts.map +1 -1
  81. package/dist/typescript/src/api/types/embed.api.types.d.ts +1 -1
  82. package/dist/typescript/src/api/types/embed.api.types.d.ts.map +1 -1
  83. package/dist/typescript/src/components/Embed/EmbedButton.d.ts +5 -25
  84. package/dist/typescript/src/components/Embed/EmbedButton.d.ts.map +1 -1
  85. package/dist/typescript/src/components/Embed/EmbedVoice.d.ts.map +1 -1
  86. package/dist/typescript/src/context/EmbedProvider.d.ts +306 -0
  87. package/dist/typescript/src/context/EmbedProvider.d.ts.map +1 -0
  88. package/dist/typescript/src/events/agent-event-emitter.d.ts +41 -0
  89. package/dist/typescript/src/events/agent-event-emitter.d.ts.map +1 -0
  90. package/dist/typescript/src/events/embed.event.d.ts +39 -21
  91. package/dist/typescript/src/events/embed.event.d.ts.map +1 -1
  92. package/dist/typescript/src/events/embed.types.d.ts +39 -0
  93. package/dist/typescript/src/events/embed.types.d.ts.map +1 -0
  94. package/dist/typescript/src/events/embed.validators.d.ts +17 -0
  95. package/dist/typescript/src/events/embed.validators.d.ts.map +1 -0
  96. package/dist/typescript/src/events/index.d.ts +10 -0
  97. package/dist/typescript/src/events/index.d.ts.map +1 -0
  98. package/dist/typescript/src/hooks/EmbedButton.animations.d.ts +38 -0
  99. package/dist/typescript/src/hooks/EmbedButton.animations.d.ts.map +1 -0
  100. package/dist/typescript/src/hooks/EmbedButton.helpers.d.ts +49 -0
  101. package/dist/typescript/src/hooks/EmbedButton.helpers.d.ts.map +1 -0
  102. package/dist/typescript/src/hooks/EmbedButton.hooks.d.ts +49 -0
  103. package/dist/typescript/src/hooks/EmbedButton.hooks.d.ts.map +1 -0
  104. package/dist/typescript/src/hooks/initialize.d.ts.map +1 -1
  105. package/dist/typescript/src/hooks/types/initialize.types.d.ts +1 -1
  106. package/dist/typescript/src/hooks/types/initialize.types.d.ts.map +1 -1
  107. package/dist/typescript/src/hooks/voiceagent.d.ts.map +1 -1
  108. package/dist/typescript/src/index.d.ts +10 -4
  109. package/dist/typescript/src/index.d.ts.map +1 -1
  110. package/dist/typescript/src/index.types.d.ts +2 -3
  111. package/dist/typescript/src/index.types.d.ts.map +1 -1
  112. package/dist/typescript/src/utils/constant.d.ts +46 -0
  113. package/dist/typescript/src/utils/constant.d.ts.map +1 -0
  114. package/dist/typescript/src/utils/permision.d.ts.map +1 -1
  115. package/dist/typescript/src/utils/reanimated.helper.d.ts.map +1 -1
  116. package/package.json +16 -8
  117. package/react-native.config.js +1 -0
  118. package/dist/commonjs/events/eventEmitter.js +0 -43
  119. package/dist/commonjs/events/eventEmitter.js.map +0 -1
  120. package/dist/module/events/eventEmitter.js +0 -39
  121. package/dist/module/events/eventEmitter.js.map +0 -1
  122. package/dist/typescript/src/events/eventEmitter.d.ts +0 -9
  123. package/dist/typescript/src/events/eventEmitter.d.ts.map +0 -1
@@ -1,18 +1,27 @@
1
1
  "use strict";
2
2
 
3
3
  import { PermissionsAndroid, Platform } from 'react-native';
4
+ import { buildEventPayload } from "./constant.js";
5
+ import { APIService } from "../api/api.js";
6
+ import { getAgentData } from "../store/store.key.js";
7
+ import { EventKeys } from "../events/embed.event.js";
4
8
  export const checkPermissions = async () => {
5
9
  try {
10
+ console.error('RECORD_AUDIO permission not available');
6
11
  // Check for required permissions on Android
7
12
  if (Platform.OS === 'android') {
8
13
  const recordAudioPermission = PermissionsAndroid.PERMISSIONS.RECORD_AUDIO;
9
14
  if (!recordAudioPermission) {
10
- throw new Error('RECORD_AUDIO permission not available');
15
+ const error = new Error('RECORD_AUDIO permission not available');
16
+ await sendPermissionDeniedEvent('RECORD_AUDIO permission not available');
17
+ throw error;
11
18
  }
12
19
  const permissions = [recordAudioPermission];
13
20
  const results = await Promise.all(permissions.map(permission => PermissionsAndroid.request(permission)));
14
21
  const allGranted = results.every(result => result === PermissionsAndroid.RESULTS.GRANTED);
15
22
  if (!allGranted) {
23
+ const deniedPermissions = permissions.filter((_, index) => results[index] !== PermissionsAndroid.RESULTS.GRANTED);
24
+ await sendPermissionDeniedEvent('Required permissions not granted', deniedPermissions);
16
25
  throw new Error('Required permissions not granted');
17
26
  }
18
27
  }
@@ -21,4 +30,42 @@ export const checkPermissions = async () => {
21
30
  throw new Error(errorMessage);
22
31
  }
23
32
  };
33
+
34
+ /**
35
+ * Send permission denied event to backend
36
+ * @param reason - The reason for permission denial
37
+ * @param deniedPermissions - List of denied permissions
38
+ */
39
+ async function sendPermissionDeniedEvent(reason, deniedPermissions) {
40
+ try {
41
+ // Get user identity to include app_user_id
42
+ const userIdentity = await getAgentData(EventKeys.USER_DATA);
43
+ if (!userIdentity?.app_user_id) {
44
+ console.warn('[Permission] Cannot send permission denied event: User identity not found');
45
+ return;
46
+ }
47
+
48
+ // Build event payload
49
+ const payload = buildEventPayload({
50
+ eventKey: EventKeys.ANALYTICS_DATA,
51
+ app_user_id: userIdentity.app_user_id,
52
+ error_type: 'permission_denied',
53
+ event_name: 'mic_permission_denied',
54
+ error_message: reason,
55
+ denied_permissions: deniedPermissions,
56
+ platform: Platform.OS,
57
+ timestamp: new Date().toISOString()
58
+ });
59
+
60
+ // Send to backend
61
+ const apiService = APIService.getInstance();
62
+ const response = await apiService.updateUserData(payload);
63
+ if (!response.success) {
64
+ console.error('[Permission] Failed to send permission denied event:', response.error);
65
+ }
66
+ } catch (error) {
67
+ console.error('[Permission] Error sending permission denied event:', error);
68
+ // Fail silently - permission events should not break the app
69
+ }
70
+ }
24
71
  //# sourceMappingURL=permision.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["PermissionsAndroid","Platform","checkPermissions","OS","recordAudioPermission","PERMISSIONS","RECORD_AUDIO","Error","permissions","results","Promise","all","map","permission","request","allGranted","every","result","RESULTS","GRANTED","err","errorMessage","message"],"sourceRoot":"../../../src","sources":["utils/permision.ts"],"mappings":";;AAAA,SAASA,kBAAkB,EAAEC,QAAQ,QAAQ,cAAc;AAE3D,OAAO,MAAMC,gBAAgB,GAAG,MAAAA,CAAA,KAA2B;EACzD,IAAI;IACF;IACA,IAAID,QAAQ,CAACE,EAAE,KAAK,SAAS,EAAE;MAC7B,MAAMC,qBAAqB,GAAGJ,kBAAkB,CAACK,WAAW,CAACC,YAAY;MACzE,IAAI,CAACF,qBAAqB,EAAE;QAC1B,MAAM,IAAIG,KAAK,CAAC,uCAAuC,CAAC;MAC1D;MAEA,MAAMC,WAAW,GAAG,CAACJ,qBAAqB,CAAC;MAE3C,MAAMK,OAAO,GAAG,MAAMC,OAAO,CAACC,GAAG,CAC/BH,WAAW,CAACI,GAAG,CAAEC,UAAU,IAAKb,kBAAkB,CAACc,OAAO,CAACD,UAAU,CAAC,CACxE,CAAC;MAED,MAAME,UAAU,GAAGN,OAAO,CAACO,KAAK,CAC7BC,MAAM,IAAKA,MAAM,KAAKjB,kBAAkB,CAACkB,OAAO,CAACC,OACpD,CAAC;MAED,IAAI,CAACJ,UAAU,EAAE;QACf,MAAM,IAAIR,KAAK,CAAC,kCAAkC,CAAC;MACrD;IACF;EACF,CAAC,CAAC,OAAOa,GAAG,EAAE;IACZ,MAAMC,YAAY,GAChBD,GAAG,YAAYb,KAAK,GAAGa,GAAG,CAACE,OAAO,GAAG,6BAA6B;IACpE,MAAM,IAAIf,KAAK,CAACc,YAAY,CAAC;EAC/B;AACF,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["PermissionsAndroid","Platform","buildEventPayload","APIService","getAgentData","EventKeys","checkPermissions","console","error","OS","recordAudioPermission","PERMISSIONS","RECORD_AUDIO","Error","sendPermissionDeniedEvent","permissions","results","Promise","all","map","permission","request","allGranted","every","result","RESULTS","GRANTED","deniedPermissions","filter","_","index","err","errorMessage","message","reason","userIdentity","USER_DATA","app_user_id","warn","payload","eventKey","ANALYTICS_DATA","error_type","event_name","error_message","denied_permissions","platform","timestamp","Date","toISOString","apiService","getInstance","response","updateUserData","success"],"sourceRoot":"../../../src","sources":["utils/permision.ts"],"mappings":";;AAAA,SAASA,kBAAkB,EAAEC,QAAQ,QAAQ,cAAc;AAC3D,SAASC,iBAAiB,QAAQ,eAAY;AAC9C,SAASC,UAAU,QAAQ,eAAY;AACvC,SAASC,YAAY,QAAQ,uBAAoB;AACjD,SAASC,SAAS,QAAQ,0BAAuB;AAEjD,OAAO,MAAMC,gBAAgB,GAAG,MAAAA,CAAA,KAA2B;EACzD,IAAI;IACFC,OAAO,CAACC,KAAK,CAAC,uCAAuC,CAAC;IACtD;IACA,IAAIP,QAAQ,CAACQ,EAAE,KAAK,SAAS,EAAE;MAC7B,MAAMC,qBAAqB,GAAGV,kBAAkB,CAACW,WAAW,CAACC,YAAY;MACzE,IAAI,CAACF,qBAAqB,EAAE;QAC1B,MAAMF,KAAK,GAAG,IAAIK,KAAK,CAAC,uCAAuC,CAAC;QAChE,MAAMC,yBAAyB,CAC7B,uCACF,CAAC;QACD,MAAMN,KAAK;MACb;MAEA,MAAMO,WAAW,GAAG,CAACL,qBAAqB,CAAC;MAE3C,MAAMM,OAAO,GAAG,MAAMC,OAAO,CAACC,GAAG,CAC/BH,WAAW,CAACI,GAAG,CAAEC,UAAU,IAAKpB,kBAAkB,CAACqB,OAAO,CAACD,UAAU,CAAC,CACxE,CAAC;MAED,MAAME,UAAU,GAAGN,OAAO,CAACO,KAAK,CAC7BC,MAAM,IAAKA,MAAM,KAAKxB,kBAAkB,CAACyB,OAAO,CAACC,OACpD,CAAC;MAED,IAAI,CAACJ,UAAU,EAAE;QACf,MAAMK,iBAAiB,GAAGZ,WAAW,CAACa,MAAM,CAC1C,CAACC,C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O,CAACC,KAAK,CACX,sDAAsD,EACtD4C,QAAQ,CAAC5C,KACX,CAAC;IACH;EACF,CAAC,CAAC,OAAOA,KAAK,EAAE;IACdD,OAAO,CAACC,KAAK,CAAC,qDAAqD,EAAEA,KAAK,CAAC;IAC3E;EACF;AACF","ignoreList":[]}
@@ -39,9 +39,8 @@ export function getReanimatedAPI() {
39
39
  console.warn('📚 Please follow the setup guide: https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/getting-started');
40
40
 
41
41
  // Provide fallback implementations
42
- const {
43
- View
44
- } = require('react-native');
42
+ const ReactNative = require('react-native');
43
+ const View = ReactNative?.View || ReactNative?.default?.View;
45
44
  reanimatedAPI = {
46
45
  useSharedValue: value => ({
47
46
  value
@@ -1 +1 @@
1
- {"version":3,"names":["reanimatedAPI","getReanimatedAPI","reanimated","require","makeMutable","Error","useSharedValue","useAnimatedStyle","withTiming","withSpring","withRepeat","withSequence","runOnJS","Easing","Animated","default","isAvailable","error","console","warn","View","value","args","length","fn","inOut","easing","ease","t","checkReanimatedSetup","api","showReanimatedSetupError"],"sourceRoot":"../../../src","sources":["utils/reanimated.helper.ts"],"mappings":";;AAAA;AACA;AACA;AACA;;AAeA,IAAIA,aAA4B;;AAEhC;AACA;AACA;AACA,OAAO,SAASC,gBAAgBA,CAAA,EAAkB;EAChD,IAAID,aAAa,EAAE;IACjB,OAAOA,aAAa;EACtB;EAEA,IAAI;IACF,MAAME,UAAU,GAAGC,OAAO,CAAC,yBAAyB,CAAC;;IAErD;IACA,IAAI,CAACD,UAAU,CAACE,WAAW,EAAE;MAC3B,MAAM,IAAIC,KAAK,CACb,gFACF,CAAC;IACH;IAEAL,aAAa,GAAG;MACdM,cAAc,EAAEJ,UAAU,CAACI,cAAc;MACzCC,gBAAgB,EAAEL,UAAU,CAACK,gBAAgB;MAC7CC,UAAU,EAAEN,UAAU,CAACM,UAAU;MACjCC,UAAU,EAAEP,UAAU,CAACO,UAAU;MACjCC,UAAU,EAAER,UAAU,CAACQ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;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK,CAAC;AACN","ignoreList":[]}
1
+ {"version":3,"names":["reanimatedAPI","getReanimatedAPI","reanimated","require","makeMutable","Error","useSharedValue","useAnimatedStyle","withTiming","withSpring","withRepeat","withSequence","runOnJS","Easing","Animated","default","isAvailable","error","console","warn","ReactNative","View","value","args","length","fn","inOut","easing","ease","t","checkReanimatedSetup","api","showReanimatedSetupError"],"sourceRoot":"../../../src","sources":["utils/reanimated.helper.ts"],"mappings":";;AAAA;AACA;AACA;AACA;;AAeA,IAAIA,aAA4B;;AAEhC;AACA;AACA;AACA,OAAO,SAASC,gBAAgBA,CAAA,EAAkB;EAChD,IAAID,aAAa,EAAE;IACjB,OAAOA,aAAa;EACtB;EAEA,IAAI;IACF,MAAME,UAAU,GAAGC,OAAO,CAAC,yBAAyB,CAAC;;IAErD;IACA,IAAI,CAACD,UAAU,CAACE,WAAW,EAAE;MAC3B,MAAM,IAAIC,KAAK,CACb,gFACF,CAAC;IACH;IAEAL,aAAa,GAAG;MACdM,cAAc,EAAEJ,UAAU,CAACI,cAAc;MACzCC,gBAAgB,EAAEL,UAAU,CAACK,gBAAgB;MAC7CC,UAAU,EAAEN,UAAU,CAACM,UAAU;MACjCC,UAAU,EAAEP,UAAU,CAACO,UAAU;MACjCC,UAAU,EAAER,UAAU,CAACQ,UAAU;MACjCC,YAAY,EAAET,UAAU,CAACS,YAAY;MACrCC,OAAO,EAAEV,UAAU,CAACU,OAAO;MAC3BC,MAAM,EAAEX,UAAU,CAACW,MAAM;MACzBC,QAAQ,EAAEZ,UAAU,CAACa,OAAO;MAC5BC,WAAW,EAAE;IACf,CAAC;IAED,OAAOhB,aAAa;EACtB,CAAC,CAAC,OAAOiB,KAAK,EAAE;IACdC,OAAO,CAACC,IAAI,CACV,qEAAqE,EACrEF,KACF,CAAC;IACDC,OAAO,CAACC,IAAI,CACV,wHACF,CAAC;;IAED;IACA,MAAMC,WAAW,GAAGjB,OAAO,CAAC,cAAc,CAAC;IAC3C,MAAMkB,IAAI,GAAGD,WAAW,EAAEC,IAAI,IAAID,WAAW,EAAEL,OAAO,EAAEM,IAAI;IAE5DrB,aAAa,GAAG;MACdM,cAAc,EAAGgB,KAAU,KAAM;QAAEA;MAAM,CAAC,CAAC;MAC3Cf,gBAAgB,EAAEA,CAAA,MAAO,CAAC,CAAC,CAAC;MAC5BC,UAAU,EAAGc,KAAU,IAAKA,KAAK;MACjCb,UAAU,EAAGa,KAAU,IAAKA,KAAK;MACjCZ,UAAU,EAAGY,KAAU,IAAKA,KAAK;MACjCX,YAAY,EAAEA,CAAC,GAAGY,IAAW,KAAKA,IAAI,CAACA,IAAI,CAACC,MAAM,GAAG,CAAC,CAAC;MACvDZ,OAAO,EAAGa,EAAO,IAAKA,EAAE;MACxBZ,MAAM,EAAE;QACNa,KAAK,EAAGC,MAAW,IAAKA,MAAM;QAC9BC,IAAI,EAAGC,CAAS,IAAKA;MACvB,CAAC;MACDf,QAAQ,EAAEO,IAAI;MACdL,WAAW,EAAE;IACf,CAAC;IAED,OAAOhB,aAAa;EACtB;AACF;;AAEA;AACA;AACA;AACA,OAAO,SAAS8B,oBAAoBA,CAAA,EAAY;EAC9C,MAAMC,GAAG,GAAG9B,gBAAgB,CAAC,CAAC;EAC9B,OAAO8B,GAAG,CAACf,WAAW;AACxB;;AAEA;AACA;AACA;AACA,OAAO,SAASgB,wBAAwBA,CAAA,EAAS;EAC/Cd,OAAO,CAACD,KAAK,CAAC;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK,CAAC;AACN","ignoreList":[]}
@@ -1,4 +1,5 @@
1
- import type { ApiResponse, TokenDetails, UpdateDataRequest } from './types/embed.api.types';
1
+ import type { ApiResponse, TokenDetails } from './types/embed.api.types';
2
+ import type { EventPayload } from '../utils/constant.js';
2
3
  /**
3
4
  * APIService class that ensures proper initialization before API calls
4
5
  */
@@ -33,7 +34,7 @@ export declare class APIService {
33
34
  * @param params Update parameters including userId and data to update
34
35
  * @returns Promise with update response
35
36
  */
36
- updateUserData(params: UpdateDataRequest): Promise<ApiResponse<void>>;
37
+ updateUserData(params: EventPayload): Promise<ApiResponse<void>>;
37
38
  /**
38
39
  * Get token details for a user
39
40
  * @param params Parameters including app_user_id and call_type
@@ -49,7 +50,7 @@ export declare class APIService {
49
50
  }
50
51
  export declare const initializeApi: () => Promise<void>;
51
52
  export declare const registerOnInitialize: () => Promise<ApiResponse<TokenDetails>>;
52
- export declare const updateUserData: (params: UpdateDataRequest) => Promise<ApiResponse<void>>;
53
+ export declare const updateUserData: (params: EventPayload) => Promise<ApiResponse<void>>;
53
54
  export declare const getTokenDetails: (params: {
54
55
  app_user_id: string;
55
56
  call_type: string;
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../../src/api/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EACZ,iBAAiB,EAClB,MAAM,yBAAyB,CAAC;AAIjC;;GAEG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAA2B;IAClD,OAAO,CAAC,UAAU,CAAuB;IACzC,OAAO,CAAC,aAAa,CAAkB;IAEvC,OAAO;IAEP;;OAEG;WACW,WAAW,IAAI,UAAU;IAOvC;;OAEG;IACU,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAexC;;OAEG;YACW,iBAAiB;IAM/B;;OAEG;YACW,UAAU;IAYxB;;;OAGG;IACU,oBAAoB,IAAI,OAAO,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;IAqCvE;;;;OAIG;IACU,cAAc,CACzB,MAAM,EAAE,iBAAiB,GACxB,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAoC7B;;;;OAIG;IACU,eAAe,CAAC,MAAM,EAAE;QACnC,WAAW,EAAE,MAAM,CAAC;QACpB,SAAS,EAAE,MA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;IACU,eAAe,CAAC,MAAM,EAAE;QACnC,WAAW,EAAE,MAAM,CAAC;QACpB,SAAS,EAAE,MAAM,CAAC;KACnB,GAAG,OAAO,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;IAqCzB,mBAAmB,CAAC,MAAM,EAAE;QACvC,WAAW,EAAE,MAAM,CAAC;KACrB,GAAG,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;CAmCjC;AAGD,eAAO,MAAM,aAAa,qBAGzB,CAAC;AAEF,eAAO,MAAM,oBAAoB,0CAGhC,CAAC;AAEF,eAAO,MAAM,cAAc,GAAU,QAAQ,YAAY,+BAGxD,CAAC;AAEF,eAAO,MAAM,eAAe,GAAU,QAAQ;IAC5C,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB,uCAGA,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAU,QAAQ;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,iCAGxE,CAAC"}
@@ -1,6 +1,6 @@
1
1
  export type RegisterRequest = {
2
2
  apiKey: string;
3
- embedUrl: string;
3
+ embedUrl?: string;
4
4
  };
5
5
  export type UpdateDataRequest = {
6
6
  eventKey: string;
@@ -1 +1 @@
1
- {"version":3,"file":"embed.api.types.d.ts","sourceRoot":"","sources":["../../../../../src/api/types/embed.api.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,CAAC,CAAC;IACT,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC"}
1
+ {"version":3,"file":"embed.api.types.d.ts","sourceRoot":"","sources":["../../../../../src/api/types/embed.api.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,CAAC,CAAC;IACT,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC"}
@@ -1,36 +1,16 @@
1
1
  /**
2
- * @file OnwidButton.tsx
3
- * @description A customizable floating action button component for React Native applications.
4
- * This component provides a draggable, expandable button with animation support and gradient styling.
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
- * OnwidButton Component
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
- * <OnwidButton
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;AAgFH;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH;;;;;;GAMG;AAEH,wBAAgB,WAAW,mDAua1B;AAGD,eAAe,WAAW,CAAC"}
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,mDAyG/B,CAAC;AAEF,eAAe,KAAK,CAAC"}
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":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,K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AAa,CAAC"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Agent Event Emitter
3
+ * Handles listening to agent state changes (connection, disconnection, popup visibility)
4
+ * Also sends agent events to the backend API
5
+ */
6
+ import type { EventCallback, AgentEvent } from './embed.types';
7
+ export declare class AgentEventEmitter {
8
+ private agentListeners;
9
+ /**
10
+ * Add an event listener for agent events
11
+ * @param eventKey - The agent event to listen for
12
+ * @param callback - Callback function to execute when event fires
13
+ */
14
+ on(eventKey: AgentEvent, callback: EventCallback): void;
15
+ /**
16
+ * Remove an event listener for agent events
17
+ * @param eventKey - The agent event to stop listening to
18
+ * @param callback - The callback function to remove
19
+ */
20
+ off(eventKey: AgentEvent, callback: EventCallback): void;
21
+ /**
22
+ * Emit an agent event to all registered listeners AND send to backend
23
+ * @param eventKey - The agent event to emit
24
+ * @param data - Data to pass to listeners
25
+ * @internal - Used internally by the library
26
+ */
27
+ emit(eventKey: AgentEvent, data: any): Promise<void>;
28
+ /**
29
+ * Send agent event data to backend API
30
+ * @param eventKey - The agent event type
31
+ * @param data - Event data
32
+ * @private
33
+ */
34
+ private sendToBackend;
35
+ /**
36
+ * Remove all listeners for a specific event
37
+ * @param eventKey - The agent event to clear listeners for
38
+ */
39
+ removeAllListeners(eventKey?: AgentEvent): void;
40
+ }
41
+ //# sourceMappingURL=agent-event-emitter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-event-emitter.d.ts","sourceRoot":"","sources":["../../../../src/events/agent-event-emitter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG/D,qBAAa,iBAAiB;IAC5B,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"}
@@ -1,29 +1,47 @@
1
- import TypedEventEmitter from './eventEmitter';
2
- type EventCallback = (data: any) => void;
3
- export declare enum EventKeys {
4
- USER_DATA = "user_data",
5
- SCREEN_STATE = "screen_state",
6
- OFFER_STATE = "offer_state",
7
- SCREEN_VIEW = "screen_view",
8
- FORM_STATE = "form_state"
9
- }
10
- export declare enum AgentEvent {
11
- AGENT_CONNECTED = "agent_connected",
12
- AGENT_DISCONNECTED = "agent_disconnected",
13
- POPUP_MESSAGE_VISIBLE = "popup_message_visible"
14
- }
1
+ /**
2
+ * Embed Event Manager
3
+ * Main class for managing embed events and agent communication
4
+ */
5
+ import { AgentEventEmitter } from './agent-event-emitter';
6
+ import type { EventCallback, EventKeys } from './embed.types';
15
7
  declare class Embed {
16
8
  private events;
17
- event: TypedEventEmitter<{
18
- agent_connected: any;
19
- agent_disconnected: any;
20
- popup_message_visible: any;
21
- }>;
22
- private userDataInitialized;
9
+ event: AgentEventEmitter;
10
+ constructor();
11
+ /**
12
+ * Automatically adds a default listener if none exists
13
+ * @private
14
+ */
15
+ private ensureDefaultListener;
16
+ /**
17
+ * Enriches event data with user identity
18
+ * @private
19
+ */
20
+ private enrichEventData;
21
+ /**
22
+ * Sends event data to the backend API
23
+ * @private
24
+ */
25
+ private sendEventToAPI;
26
+ /**
27
+ * Triggers local event listeners
28
+ * @private
29
+ */
30
+ private triggerEventListeners;
31
+ /**
32
+ * Send an event to the AI agent
33
+ * @param eventKey - The event type to send
34
+ * @param data - Event data payload
35
+ */
23
36
  Event(eventKey: string, data: any): Promise<void>;
37
+ /**
38
+ * Add listener for data events (legacy support)
39
+ * @deprecated Use event.on() for agent events instead
40
+ */
24
41
  on(eventKey: EventKeys, callback: EventCallback): void;
25
- isUserDataInitialized(): boolean;
26
42
  }
27
43
  declare const embed: Embed;
28
44
  export default embed;
45
+ export { EventKeys, AgentEvent } from './embed.types';
46
+ export type { EventCallback, AgentConnectedData, AgentDisconnectedData, PopupMessageVisibleData, } from './embed.types';
29
47
  //# sourceMappingURL=embed.event.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"embed.event.d.ts","sourceRoot":"","sources":["../../../../src/events/embed.event.ts"],"names":[],"mappings":"AAEA,OAAO,iBAAiB,MAAM,gBAAgB,CAAC;AAE/C,KAAK,aAAa,GAAG,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC;AAGzC,oBAAY,SAAS;IACnB,SAAS,cAAc;IACvB,YAAY,iBAAiB;IAC7B,WAAW,gBAAgB;IAC3B,WAAW,gBAAgB;IAC3B,UAAU,eAAe;CAC1B;AAED,oBAAY,UAAU;IACpB,eAAe,oBAAoB;IACnC,kBAAkB,uBAAuB;IACzC,qBAAqB,0BAA0B;CAChD;AAmBD,cAAM,KAAK;IACT,OAAO,CAAC,MAAM,CAAgD;IAC9D,KAAK;;;;OAAyD;IAC9D,OAAO,CAAC,mBAAmB,CAAkB;IAcvC,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG;IA0DvC,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,aAAa;IAQ/C,qBAAqB,IAAI,OAAO;CAGjC;AAED,QAAA,MAAM,KAAK,OAAc,CAAC;AAC1B,eAAe,KAAK,CAAC"}
1
+ {"version":3,"file":"embed.event.d.ts","sourceRoot":"","sources":["../../../../src/events/embed.event.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,eAAe,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