@robylon/react-native-sdk 1.10.1-staging.11 → 1.10.1-staging.3

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 (41) hide show
  1. package/.npmignore.production +0 -1
  2. package/.npmignore.staging +0 -1
  3. package/README.md +0 -185
  4. package/babel.config.js +3 -16
  5. package/lib/commonjs/ChatbotWebview.js +44 -1
  6. package/lib/commonjs/ChatbotWebview.js.map +1 -1
  7. package/lib/commonjs/Chatbotsdk.js +309 -1
  8. package/lib/commonjs/Chatbotsdk.js.map +1 -1
  9. package/lib/commonjs/FloatingButton.js +60 -1
  10. package/lib/commonjs/FloatingButton.js.map +1 -1
  11. package/lib/commonjs/LoadingIndicator.js +20 -1
  12. package/lib/commonjs/LoadingIndicator.js.map +1 -1
  13. package/lib/commonjs/config.js +10 -1
  14. package/lib/commonjs/config.js.map +1 -1
  15. package/lib/commonjs/constants.js +9 -1
  16. package/lib/commonjs/constants.js.map +1 -1
  17. package/lib/commonjs/global.d.js +7 -1
  18. package/lib/commonjs/global.d.js.map +1 -1
  19. package/lib/commonjs/index.js +20 -1
  20. package/lib/commonjs/index.js.map +1 -1
  21. package/lib/commonjs/openChatbot.js +16 -1
  22. package/lib/commonjs/openChatbot.js.map +1 -1
  23. package/lib/module/ChatbotWebview.js +33 -1
  24. package/lib/module/ChatbotWebview.js.map +1 -1
  25. package/lib/module/Chatbotsdk.js +300 -1
  26. package/lib/module/Chatbotsdk.js.map +1 -1
  27. package/lib/module/FloatingButton.js +53 -1
  28. package/lib/module/FloatingButton.js.map +1 -1
  29. package/lib/module/LoadingIndicator.js +13 -1
  30. package/lib/module/LoadingIndicator.js.map +1 -1
  31. package/lib/module/config.js +4 -1
  32. package/lib/module/config.js.map +1 -1
  33. package/lib/module/constants.js +3 -1
  34. package/lib/module/constants.js.map +1 -1
  35. package/lib/module/global.d.js +6 -1
  36. package/lib/module/global.d.js.map +1 -1
  37. package/lib/module/index.js +2 -1
  38. package/lib/module/index.js.map +1 -1
  39. package/lib/module/openChatbot.js +9 -1
  40. package/package.json +13 -20
  41. package/src/FloatingButton.tsx +6 -6
@@ -5,4 +5,3 @@ __fixtures__/
5
5
  __mocks__/
6
6
  .env*
7
7
  *.log
8
- usage/*
@@ -4,4 +4,3 @@ __fixtures__/
4
4
  __mocks__/
5
5
  .env*
6
6
  *.log
7
- usage/*
package/README.md CHANGED
@@ -1,185 +0,0 @@
1
- # Robylon React Native SDK Documentation
2
-
3
- ## Installation
4
-
5
- First, install the package using npm or yarn:
6
-
7
- ```bash
8
- # Using npm
9
- npm install @robylon/react-native-sdk react-native-webview
10
-
11
- # Using yarn
12
- yarn add @robylon/react-native-sdk react-native-webview
13
- ```
14
-
15
- ## Prerequisites
16
-
17
- - React Native project set up for iOS
18
- - `react-native-webview` installed and configured
19
- - Valid Robylon API key
20
-
21
- ## Basic Implementation
22
-
23
- ### 1. Import the SDK
24
-
25
- ```typescript
26
- import { ChatbotSDK } from "@robylon/react-native-sdk";
27
- ```
28
-
29
- ### 2. Basic Usage
30
-
31
- ```typescript
32
- import React from "react";
33
- import { View } from "react-native";
34
- import { ChatbotSDK } from "@robylon/react-native-sdk";
35
-
36
- const App = () => {
37
- return (
38
- <View style={{ flex: 1 }}>
39
- <ChatbotSDK
40
- api_key="YOUR_API_KEY"
41
- user_id="USER_ID"
42
- user_token="USER_TOKEN"
43
- />
44
- </View>
45
- );
46
- };
47
-
48
- export default App;
49
- ```
50
-
51
- ## Props Reference
52
-
53
- ### Required Props
54
-
55
- | Prop | Type | Description |
56
- | --------- | ------ | ------------------------------ |
57
- | `api_key` | string | Your Robylon API key |
58
- | `user_id` | string | Unique identifier for the user |
59
-
60
- ### Optional Props
61
-
62
- | Prop | Type | Default | Description |
63
- | ---------------------- | ---------------------- | --------- | -------------------------------------------- |
64
- | `user_token` | string | undefined | Authentication token for the user |
65
- | `additional_params` | Record<string, string> | {} | Additional parameters to pass to the chatbot |
66
- | `show_floating_button` | boolean | true | Whether to show the floating button |
67
- | `isFullScreen` | boolean | true | Whether to display in fullscreen mode |
68
- | `enableAnimation` | boolean | true | Enable/disable animations |
69
- | `onMessage` | (message: any) => void | undefined | Callback for chatbot messages |
70
- | `onOpen` | () => void | undefined | Callback when chatbot opens |
71
- | `onClose` | () => void | undefined | Callback when chatbot closes |
72
-
73
- ## Advanced Implementation
74
-
75
- ### Custom Configuration Example
76
-
77
- ```typescript
78
- import React from "react";
79
- import { View } from "react-native";
80
- import { ChatbotSDK } from "@robylon/react-native-sdk";
81
-
82
- const App = () => {
83
- const handleMessage = (message) => {
84
- console.log("Received message:", message);
85
- };
86
-
87
- const handleOpen = () => {
88
- console.log("Chatbot opened");
89
- };
90
-
91
- const handleClose = () => {
92
- console.log("Chatbot closed");
93
- };
94
-
95
- return (
96
- <View style={{ flex: 1 }}>
97
- <ChatbotSDK
98
- api_key="YOUR_API_KEY"
99
- user_id="USER_ID"
100
- user_token="USER_TOKEN"
101
- additional_params={{
102
- theme: "light",
103
- language: "en",
104
- }}
105
- show_floating_button={true}
106
- isFullScreen={true}
107
- enableAnimation={true}
108
- onMessage={handleMessage}
109
- onOpen={handleOpen}
110
- onClose={handleClose}
111
- />
112
- </View>
113
- );
114
- };
115
-
116
- export default App;
117
- ```
118
-
119
- <!-- ### Handling Messages
120
-
121
- The `onMessage` callback receives messages in the following format:
122
-
123
- ```typescript
124
- interface ChatbotMessage {
125
- type: string;
126
- data?: any;
127
- }
128
- ```
129
-
130
- Example message handler:
131
-
132
- ```typescript
133
- const handleMessage = (message: ChatbotMessage) => {
134
- switch (message.type) {
135
- case 'user_message':
136
- console.log('User sent:', message.data);
137
- break;
138
- case 'bot_response':
139
- console.log('Bot responded:', message.data);
140
- break;
141
- // Handle other message types
142
- }
143
- };
144
- ``` -->
145
-
146
- ## Styling and Customization
147
-
148
- The SDK automatically fetches and applies your organization's branding configuration, including:
149
-
150
- - Brand color
151
- - Launcher logo
152
- - Welcome message
153
-
154
- <!-- These are fetched using the provided API key and user credentials. -->
155
-
156
- ## Best Practices
157
-
158
- 1. **Error Handling**: Always implement error handling for network requests and message processing.
159
- 2. **User Authentication**: Ensure user_id and user_token are properly managed and updated.
160
- 3. **Performance**: Consider using `useMemo` or `useCallback` for callback functions to optimize performance.
161
- 4. **Testing**: Test the implementation across different iOS devices and orientations.
162
-
163
- ## Troubleshooting
164
-
165
- Common issues and solutions:
166
-
167
- 1. **WebView Not Loading**
168
-
169
- - Verify internet connectivity
170
- - Check if API key is valid
171
- - Ensure WebView permissions are properly configured
172
-
173
- 2. **Authentication Issues**
174
-
175
- - Verify user_token is valid and not expired
176
- - Check if user_id is correctly formatted
177
-
178
- 3. **UI Issues**
179
- - Ensure proper layout hierarchy
180
- - Check for conflicts with other UI elements
181
- - Verify styling properties
182
-
183
- ## Support
184
-
185
- For additional support or to report issues, please contact Robylon support or refer to the official documentation.
package/babel.config.js CHANGED
@@ -1,17 +1,4 @@
1
- module.exports = function (api) {
2
- api.cache(true);
3
- return {
4
- presets: ["module:metro-react-native-babel-preset"],
5
- plugins: [
6
- [
7
- "inline-dotenv",
8
- {
9
- path:
10
- process.env.NODE_ENV === "production"
11
- ? ".env.production"
12
- : ".env.staging",
13
- },
14
- ],
15
- ],
16
- };
1
+ module.exports = {
2
+ presets: ["module:metro-react-native-babel-preset"],
3
+ plugins: ["transform-inline-environment-variables"],
17
4
  };
@@ -1,2 +1,45 @@
1
- var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.ChatbotWebview=void 0;var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _reactNativeWebview=require("react-native-webview");var _constants=require("./constants");var _LoadingIndicator=_interopRequireDefault(require("./LoadingIndicator"));var _jsxRuntime=require("react/jsx-runtime");var _this=this,_jsxFileName="/Users/jobinabraham/Developer/personal/robylon-react-native-sdk/src/ChatbotWebview.tsx";function _getRequireWildcardCache(e){if("function"!=typeof WeakMap)return null;var r=new WeakMap(),t=new WeakMap();return(_getRequireWildcardCache=function _getRequireWildcardCache(e){return e?t:r;})(e);}function _interopRequireWildcard(e,r){if(!r&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache(r);if(t&&t.has(e))return t.get(e);var n={__proto__:null},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var u in e)if("default"!==u&&{}.hasOwnProperty.call(e,u)){var i=a?Object.getOwnPropertyDescriptor(e,u):null;i&&(i.get||i.set)?Object.defineProperty(n,u,i):n[u]=e[u];}return n.default=e,t&&t.set(e,n),n;}var constructUrl=function constructUrl(chatbotId){var additionalParams=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var params=new URLSearchParams(Object.assign({id:chatbotId},additionalParams));return _constants.BASE_CHATBOT_URL+"?"+params.toString();};var ChatbotWebview=exports.ChatbotWebview=function ChatbotWebview(_ref){var chatbotId=_ref.chatbotId,additionalParams=_ref.additionalParams;var _useState=(0,_react.useState)(""),_useState2=(0,_slicedToArray2.default)(_useState,2),url=_useState2[0],setUrl=_useState2[1];(0,_react.useEffect)(function(){setUrl(constructUrl(chatbotId,additionalParams));},[chatbotId,additionalParams]);return(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flex:1},children:url?(0,_jsxRuntime.jsx)(_reactNativeWebview.WebView,{source:{uri:url},startInLoadingState:true,renderLoading:function renderLoading(){return(0,_jsxRuntime.jsx)(_LoadingIndicator.default,{});}}):(0,_jsxRuntime.jsx)(_LoadingIndicator.default,{})});};
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ChatbotWebview = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _reactNative = require("react-native");
9
+ var _reactNativeWebview = require("react-native-webview");
10
+ var _constants = require("./constants");
11
+ var _LoadingIndicator = _interopRequireDefault(require("./LoadingIndicator"));
12
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
14
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
15
+ // File: src/ChatbotWebview.tsx
16
+
17
+ const constructUrl = (chatbotId, additionalParams = {}) => {
18
+ const params = new URLSearchParams({
19
+ id: chatbotId,
20
+ ...additionalParams
21
+ });
22
+ return `${_constants.BASE_CHATBOT_URL}?${params.toString()}`;
23
+ };
24
+ const ChatbotWebview = ({
25
+ chatbotId,
26
+ additionalParams
27
+ }) => {
28
+ const [url, setUrl] = (0, _react.useState)("");
29
+ (0, _react.useEffect)(() => {
30
+ setUrl(constructUrl(chatbotId, additionalParams));
31
+ }, [chatbotId, additionalParams]);
32
+ return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
33
+ style: {
34
+ flex: 1
35
+ }
36
+ }, url ? /*#__PURE__*/_react.default.createElement(_reactNativeWebview.WebView, {
37
+ source: {
38
+ uri: url
39
+ },
40
+ startInLoadingState: true,
41
+ renderLoading: () => /*#__PURE__*/_react.default.createElement(_LoadingIndicator.default, null)
42
+ }) : /*#__PURE__*/_react.default.createElement(_LoadingIndicator.default, null));
43
+ };
44
+ exports.ChatbotWebview = ChatbotWebview;
2
45
  //# sourceMappingURL=ChatbotWebview.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeWebview","_constants","_LoadingIndicator","_interopRequireDefault","_jsxRuntime","_this","_jsxFileName","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","constructUrl","chatbotId","additionalParams","arguments","length","undefined","params","URLSearchParams","assign","id","BASE_CHATBOT_URL","toString","ChatbotWebview","exports","_ref","_useState","useState","_useState2","_slicedToArray2","url","setUrl","useEffect","jsx","View","style","flex","children","WebView","source","uri","startInLoadingState","renderLoading"],"sourceRoot":"../../src","sources":["ChatbotWebview.tsx"],"mappings":"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","ignoreList":[]}
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeWebview","_constants","_LoadingIndicator","_interopRequireDefault","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","constructUrl","chatbotId","additionalParams","params","URLSearchParams","id","BASE_CHATBOT_URL","toString","ChatbotWebview","url","setUrl","useState","useEffect","createElement","View","style","flex","WebView","source","uri","startInLoadingState","renderLoading","exports"],"sourceRoot":"../../src","sources":["ChatbotWebview.tsx"],"mappings":"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","ignoreList":[]}
@@ -1,2 +1,310 @@
1
- var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _reactNativeWebview=require("react-native-webview");var _FloatingButton=_interopRequireDefault(require("./FloatingButton"));var _constants=require("./constants");var _jsxRuntime=require("react/jsx-runtime");var _this=this,_jsxFileName="/Users/jobinabraham/Developer/personal/robylon-react-native-sdk/src/Chatbotsdk.tsx";function _getRequireWildcardCache(e){if("function"!=typeof WeakMap)return null;var r=new WeakMap(),t=new WeakMap();return(_getRequireWildcardCache=function _getRequireWildcardCache(e){return e?t:r;})(e);}function _interopRequireWildcard(e,r){if(!r&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache(r);if(t&&t.has(e))return t.get(e);var n={__proto__:null},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var u in e)if("default"!==u&&{}.hasOwnProperty.call(e,u)){var i=a?Object.getOwnPropertyDescriptor(e,u):null;i&&(i.get||i.set)?Object.defineProperty(n,u,i):n[u]=e[u];}return n.default=e,t&&t.set(e,n),n;}var ChatbotSDK=function ChatbotSDK(_ref){var api_key=_ref.api_key,user_id=_ref.user_id,user_token=_ref.user_token,_ref$additional_param=_ref.additional_params,additional_params=_ref$additional_param===void 0?{}:_ref$additional_param,_ref$show_floating_bu=_ref.show_floating_button,show_floating_button=_ref$show_floating_bu===void 0?true:_ref$show_floating_bu,onMessage=_ref.onMessage,_ref$isFullScreen=_ref.isFullScreen,isFullScreen=_ref$isFullScreen===void 0?true:_ref$isFullScreen,_ref$enableAnimation=_ref.enableAnimation,enableAnimation=_ref$enableAnimation===void 0?true:_ref$enableAnimation,onOpen=_ref.onOpen,onClose=_ref.onClose;var _useState=(0,_react.useState)(false),_useState2=(0,_slicedToArray2.default)(_useState,2),isWebViewVisible=_useState2[0],setIsWebViewVisible=_useState2[1];var _useState3=(0,_react.useState)(null),_useState4=(0,_slicedToArray2.default)(_useState3,2),chatbotConfig=_useState4[0],setChatbotConfig=_useState4[1];var _useState5=(0,_react.useState)(true),_useState6=(0,_slicedToArray2.default)(_useState5,2),loading=_useState6[0],setLoading=_useState6[1];var webViewRef=(0,_react.useRef)(null);var fadeAnim=(0,_react.useRef)(new _reactNative.Animated.Value(0)).current;var isFirstLoadRef=(0,_react.useRef)(true);var webViewUrl=(0,_react.useMemo)(function(){return constructUrl();},[api_key,user_id,additional_params]);var stableAdditionalParams=(0,_react.useMemo)(function(){return additional_params;},[JSON.stringify(additional_params)]);var triggerAppInit=function triggerAppInit(){if(webViewRef.current){webViewRef.current.injectJavaScript("\n // Trigger APP_READY equivalent\n window.ReactNativeWebView.postMessage(JSON.stringify({ type: 'APP_READY' }));\n true;\n ");}};(0,_react.useEffect)(function(){var fetchChatbotConfig=function(){var _ref2=(0,_asyncToGenerator2.default)(function*(){try{var _data$user;var endpointUrl="https://stage-api.robylon.ai/users/auth/copilot/";var payload={client_user_id:user_id,org_id:api_key,token:user_token,extra_info:stableAdditionalParams};var response=yield fetch(endpointUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(payload)});if(!response.ok){throw new Error("Failed to fetch chatbot configuration");}var data=yield response.json();var orgInfo=data==null?void 0:(_data$user=data.user)==null?void 0:_data$user.org_info;if(orgInfo){var _orgInfo$config,_orgInfo$brand_config,_orgInfo$config2;setChatbotConfig({brand_color:(orgInfo==null?void 0:(_orgInfo$config=orgInfo.config)==null?void 0:_orgInfo$config.brand_colour)||"#007AFF",image_url:(orgInfo==null?void 0:(_orgInfo$brand_config=orgInfo.brand_config)==null?void 0:_orgInfo$brand_config.launcher_logo_url)||"",welcome_message:(orgInfo==null?void 0:(_orgInfo$config2=orgInfo.config)==null?void 0:_orgInfo$config2.welcome_message)||""});}}catch(error){console.error("Error fetching chatbot configuration:",error);}finally{setLoading(false);}});return function fetchChatbotConfig(){return _ref2.apply(this,arguments);};}();if(api_key&&user_id){fetchChatbotConfig();}},[api_key,user_id,user_token,stableAdditionalParams]);function constructUrl(){if(!user_id)return"";var params=new URLSearchParams(Object.assign({id:api_key,user_id:user_id},additional_params));return _constants.BASE_CHATBOT_URL+"?"+params.toString();}var openWebView=function openWebView(){setIsWebViewVisible(true);if(enableAnimation){_reactNative.Animated.timing(fadeAnim,{toValue:1,duration:250,useNativeDriver:true}).start(function(){onOpen==null?void 0:onOpen();if(!isFirstLoadRef.current){setTimeout(triggerAppInit,100);}});}else{fadeAnim.setValue(1);requestAnimationFrame(function(){onOpen==null?void 0:onOpen();if(!isFirstLoadRef.current){setTimeout(triggerAppInit,100);}});}};var closeWebView=function closeWebView(){if(webViewRef.current){console.log("closeWebView");webViewRef.current.postMessage(JSON.stringify({name:"closeFrame",domain:"app-domain.com"}));}var complete=function complete(){setIsWebViewVisible(false);onClose==null?void 0:onClose();};if(enableAnimation){_reactNative.Animated.timing(fadeAnim,{toValue:0,duration:200,useNativeDriver:true}).start(complete);}else{fadeAnim.setValue(0);requestAnimationFrame(complete);}};var handleMessage=function handleMessage(event){var data=event.nativeEvent.data;try{var parsedData=JSON.parse(data);if(parsedData.type==="APP_READY"){console.log("APP_READY",webViewRef.current&&isWebViewVisible);if(webViewRef.current&&isWebViewVisible){webViewRef.current.injectJavaScript("\n window.postMessage("+JSON.stringify({name:"openFrame",domain:"app-domain.com"})+", '*');\n window.postMessage("+JSON.stringify({name:"registerUserId",action:"registerUserId",domain:"app-domain.com",data:{userId:""+user_id,token:""+user_token}})+", '*');\n ");}}if(typeof parsedData!=="object"||!parsedData.type){console.warn("Invalid message structure");return;}switch(parsedData.type){case"close_chatbot":closeWebView();break;default:if(onMessage)onMessage(parsedData);}}catch(error){console.error("Failed to parse or process WebView message:",error);}};var getScreenDimensions=function getScreenDimensions(){var windowHeight=_reactNative.Dimensions.get("window").height;var windowWidth=_reactNative.Dimensions.get("window").width;var statusBarHeight=_reactNative.Platform.OS==="ios"?0:_reactNative.StatusBar.currentHeight||0;return{height:windowHeight-statusBarHeight,width:windowWidth};};var screenDimensions=getScreenDimensions();return(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.mainContainer,children:!loading&&(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[show_floating_button&&api_key&&chatbotConfig&&(0,_jsxRuntime.jsx)(_FloatingButton.default,{onPress:openWebView,brandColor:chatbotConfig.brand_color,imageUrl:chatbotConfig.image_url}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.webViewWrapper,{height:isWebViewVisible?"100%":0}],pointerEvents:isWebViewVisible?"auto":"none",children:(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[isFullScreen?styles.fullScreenContainer:styles.inlineContainer,{opacity:fadeAnim}],children:(0,_jsxRuntime.jsx)(_reactNativeWebview.WebView,{ref:webViewRef,source:{uri:webViewUrl},onMessage:handleMessage,style:styles.webview,containerStyle:isFullScreen?{width:screenDimensions.width,height:screenDimensions.height}:undefined,allowsInlineMediaPlayback:true,mediaPlaybackRequiresUserAction:false,allowFileAccess:false,geolocationEnabled:false,javaScriptEnabled:true,domStorageEnabled:true,cacheEnabled:true,scrollEnabled:true,bounces:false,onShouldStartLoadWithRequest:function onShouldStartLoadWithRequest(request){return request.url.startsWith(_constants.BASE_CHATBOT_URL);},startInLoadingState:isFirstLoadRef.current,onLoadEnd:function onLoadEnd(){var _webViewRef$current;(_webViewRef$current=webViewRef.current)==null?void 0:_webViewRef$current.injectJavaScript("\n if (!document.querySelector('meta[name=\"viewport\"]')) {\n var meta = document.createElement('meta');\n meta.name = 'viewport';\n meta.content = 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no';\n document.getElementsByTagName('head')[0].appendChild(meta);\n }\n\n if (!document.querySelector('#injectedStyle')) {\n const style = document.createElement('style');\n style.id = 'injectedStyle';\n style.textContent = `\n html, body, #root, #__next {\n height: 100% !important;\n min-height: 100% !important;\n overflow: hidden !important;\n }\n `;\n document.head.appendChild(style);\n }\n\n window.sendToChatbot = function(message) {\n window.ReactNativeWebView.postMessage(JSON.stringify(message));\n };\n\n var closeButton = document.querySelector('.chatbot-close-button');\n if (closeButton) {\n closeButton.addEventListener('click', () => {\n window.sendToChatbot({ type: 'close_chatbot' });\n });\n }\n \n true;\n");isFirstLoadRef.current=false;},onError:function onError(syntheticEvent){var nativeEvent=syntheticEvent.nativeEvent;console.warn("WebView error:",nativeEvent);}})})})]})});};var styles=_reactNative.StyleSheet.create({mainContainer:{flex:1,position:"relative"},webViewWrapper:{position:"absolute",top:0,left:0,right:0,bottom:0,overflow:"hidden",zIndex:1000},fullScreenContainer:{position:"absolute",top:0,left:0,right:0,bottom:0,backgroundColor:"white",zIndex:1000},inlineContainer:{flex:1,backgroundColor:"white"},webview:{flex:1,backgroundColor:"white"}});var _default=exports.default=ChatbotSDK;
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _reactNative = require("react-native");
9
+ var _reactNativeWebview = require("react-native-webview");
10
+ var _FloatingButton = _interopRequireDefault(require("./FloatingButton"));
11
+ var _constants = require("./constants");
12
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
14
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
15
+ const ChatbotSDK = ({
16
+ api_key,
17
+ user_id,
18
+ user_token,
19
+ additional_params = {},
20
+ show_floating_button = true,
21
+ onMessage,
22
+ isFullScreen = true,
23
+ enableAnimation = true,
24
+ onOpen,
25
+ onClose
26
+ }) => {
27
+ const [isWebViewVisible, setIsWebViewVisible] = (0, _react.useState)(false);
28
+ const [chatbotConfig, setChatbotConfig] = (0, _react.useState)(null);
29
+ const [loading, setLoading] = (0, _react.useState)(true);
30
+ const webViewRef = (0, _react.useRef)(null);
31
+ const fadeAnim = (0, _react.useRef)(new _reactNative.Animated.Value(0)).current;
32
+ const isFirstLoadRef = (0, _react.useRef)(true);
33
+ const webViewUrl = (0, _react.useMemo)(() => constructUrl(), [api_key, user_id, additional_params]);
34
+ const stableAdditionalParams = (0, _react.useMemo)(() => additional_params, [JSON.stringify(additional_params)]);
35
+ const triggerAppInit = () => {
36
+ if (webViewRef.current) {
37
+ webViewRef.current.injectJavaScript(`
38
+ // Trigger APP_READY equivalent
39
+ window.ReactNativeWebView.postMessage(JSON.stringify({ type: 'APP_READY' }));
40
+ true;
41
+ `);
42
+ }
43
+ };
44
+ (0, _react.useEffect)(() => {
45
+ const fetchChatbotConfig = async () => {
46
+ try {
47
+ var _data$user;
48
+ const endpointUrl = `https://stage-api.robylon.ai/users/auth/copilot/`;
49
+ const payload = {
50
+ client_user_id: user_id,
51
+ org_id: api_key,
52
+ token: user_token,
53
+ extra_info: stableAdditionalParams
54
+ };
55
+ const response = await fetch(endpointUrl, {
56
+ method: "POST",
57
+ headers: {
58
+ "Content-Type": "application/json"
59
+ },
60
+ body: JSON.stringify(payload)
61
+ });
62
+ if (!response.ok) {
63
+ throw new Error("Failed to fetch chatbot configuration");
64
+ }
65
+ const data = await response.json();
66
+ const orgInfo = data === null || data === void 0 || (_data$user = data.user) === null || _data$user === void 0 ? void 0 : _data$user.org_info;
67
+ if (orgInfo) {
68
+ var _orgInfo$config, _orgInfo$brand_config, _orgInfo$config2;
69
+ setChatbotConfig({
70
+ brand_color: (orgInfo === null || orgInfo === void 0 || (_orgInfo$config = orgInfo.config) === null || _orgInfo$config === void 0 ? void 0 : _orgInfo$config.brand_colour) || "#007AFF",
71
+ image_url: (orgInfo === null || orgInfo === void 0 || (_orgInfo$brand_config = orgInfo.brand_config) === null || _orgInfo$brand_config === void 0 ? void 0 : _orgInfo$brand_config.launcher_logo_url) || "",
72
+ welcome_message: (orgInfo === null || orgInfo === void 0 || (_orgInfo$config2 = orgInfo.config) === null || _orgInfo$config2 === void 0 ? void 0 : _orgInfo$config2.welcome_message) || ""
73
+ });
74
+ }
75
+ } catch (error) {
76
+ console.error("Error fetching chatbot configuration:", error);
77
+ } finally {
78
+ setLoading(false);
79
+ }
80
+ };
81
+ if (api_key && user_id) {
82
+ fetchChatbotConfig();
83
+ }
84
+ }, [api_key, user_id, user_token, stableAdditionalParams]);
85
+ function constructUrl() {
86
+ if (!user_id) return "";
87
+ const params = new URLSearchParams({
88
+ id: api_key,
89
+ user_id,
90
+ ...additional_params
91
+ });
92
+ return `${_constants.BASE_CHATBOT_URL}?${params.toString()}`;
93
+ }
94
+ const openWebView = () => {
95
+ setIsWebViewVisible(true);
96
+ if (enableAnimation) {
97
+ _reactNative.Animated.timing(fadeAnim, {
98
+ toValue: 1,
99
+ duration: 250,
100
+ useNativeDriver: true
101
+ }).start(() => {
102
+ onOpen === null || onOpen === void 0 || onOpen();
103
+ if (!isFirstLoadRef.current) {
104
+ // If not first load, manually trigger initialization
105
+ setTimeout(triggerAppInit, 100);
106
+ }
107
+ });
108
+ } else {
109
+ fadeAnim.setValue(1);
110
+ requestAnimationFrame(() => {
111
+ onOpen === null || onOpen === void 0 || onOpen();
112
+ if (!isFirstLoadRef.current) {
113
+ setTimeout(triggerAppInit, 100);
114
+ }
115
+ });
116
+ }
117
+ };
118
+ const closeWebView = () => {
119
+ if (webViewRef.current) {
120
+ console.log("closeWebView");
121
+ webViewRef.current.postMessage(JSON.stringify({
122
+ name: "closeFrame",
123
+ domain: "app-domain.com"
124
+ }));
125
+ }
126
+ const complete = () => {
127
+ setIsWebViewVisible(false);
128
+ onClose === null || onClose === void 0 || onClose();
129
+ };
130
+ if (enableAnimation) {
131
+ _reactNative.Animated.timing(fadeAnim, {
132
+ toValue: 0,
133
+ duration: 200,
134
+ useNativeDriver: true
135
+ }).start(complete);
136
+ } else {
137
+ fadeAnim.setValue(0);
138
+ requestAnimationFrame(complete);
139
+ }
140
+ };
141
+ const handleMessage = event => {
142
+ const {
143
+ data
144
+ } = event.nativeEvent;
145
+ try {
146
+ const parsedData = JSON.parse(data);
147
+ if (parsedData.type === "APP_READY") {
148
+ console.log("APP_READY", webViewRef.current && isWebViewVisible);
149
+ if (webViewRef.current && isWebViewVisible) {
150
+ webViewRef.current.injectJavaScript(`
151
+ window.postMessage(${JSON.stringify({
152
+ name: "openFrame",
153
+ domain: "app-domain.com"
154
+ })}, '*');
155
+ window.postMessage(${JSON.stringify({
156
+ name: "registerUserId",
157
+ action: "registerUserId",
158
+ domain: "app-domain.com",
159
+ data: {
160
+ userId: `${user_id}`,
161
+ token: `${user_token}`
162
+ }
163
+ })}, '*');
164
+ `);
165
+ }
166
+ }
167
+ if (typeof parsedData !== "object" || !parsedData.type) {
168
+ console.warn("Invalid message structure");
169
+ return;
170
+ }
171
+ switch (parsedData.type) {
172
+ case "close_chatbot":
173
+ closeWebView();
174
+ break;
175
+ default:
176
+ if (onMessage) onMessage(parsedData);
177
+ }
178
+ } catch (error) {
179
+ console.error("Failed to parse or process WebView message:", error);
180
+ }
181
+ };
182
+ const getScreenDimensions = () => {
183
+ const windowHeight = _reactNative.Dimensions.get("window").height;
184
+ const windowWidth = _reactNative.Dimensions.get("window").width;
185
+ const statusBarHeight = _reactNative.Platform.OS === "ios" ? 0 : _reactNative.StatusBar.currentHeight || 0;
186
+ return {
187
+ height: windowHeight - statusBarHeight,
188
+ width: windowWidth
189
+ };
190
+ };
191
+ const screenDimensions = getScreenDimensions();
192
+ return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
193
+ style: styles.mainContainer
194
+ }, !loading && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, show_floating_button && api_key && chatbotConfig && /*#__PURE__*/_react.default.createElement(_FloatingButton.default, {
195
+ onPress: openWebView,
196
+ brandColor: chatbotConfig.brand_color,
197
+ imageUrl: chatbotConfig.image_url
198
+ }), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
199
+ style: [styles.webViewWrapper, {
200
+ height: isWebViewVisible ? "100%" : 0
201
+ }],
202
+ pointerEvents: isWebViewVisible ? "auto" : "none"
203
+ }, /*#__PURE__*/_react.default.createElement(_reactNative.Animated.View, {
204
+ style: [isFullScreen ? styles.fullScreenContainer : styles.inlineContainer, {
205
+ opacity: fadeAnim
206
+ }]
207
+ }, /*#__PURE__*/_react.default.createElement(_reactNativeWebview.WebView, {
208
+ ref: webViewRef,
209
+ source: {
210
+ uri: webViewUrl
211
+ },
212
+ onMessage: handleMessage,
213
+ style: styles.webview,
214
+ containerStyle: isFullScreen ? {
215
+ width: screenDimensions.width,
216
+ height: screenDimensions.height
217
+ } : undefined,
218
+ allowsInlineMediaPlayback: true,
219
+ mediaPlaybackRequiresUserAction: false,
220
+ allowFileAccess: false,
221
+ geolocationEnabled: false,
222
+ javaScriptEnabled: true,
223
+ domStorageEnabled: true,
224
+ cacheEnabled: true,
225
+ scrollEnabled: true,
226
+ bounces: false,
227
+ onShouldStartLoadWithRequest: request => {
228
+ return request.url.startsWith(_constants.BASE_CHATBOT_URL);
229
+ },
230
+ startInLoadingState: isFirstLoadRef.current,
231
+ onLoadEnd: () => {
232
+ var _webViewRef$current;
233
+ (_webViewRef$current = webViewRef.current) === null || _webViewRef$current === void 0 || _webViewRef$current.injectJavaScript(`
234
+ if (!document.querySelector('meta[name="viewport"]')) {
235
+ var meta = document.createElement('meta');
236
+ meta.name = 'viewport';
237
+ meta.content = 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no';
238
+ document.getElementsByTagName('head')[0].appendChild(meta);
239
+ }
240
+
241
+ if (!document.querySelector('#injectedStyle')) {
242
+ const style = document.createElement('style');
243
+ style.id = 'injectedStyle';
244
+ style.textContent = \`
245
+ html, body, #root, #__next {
246
+ height: 100% !important;
247
+ min-height: 100% !important;
248
+ overflow: hidden !important;
249
+ }
250
+ \`;
251
+ document.head.appendChild(style);
252
+ }
253
+
254
+ window.sendToChatbot = function(message) {
255
+ window.ReactNativeWebView.postMessage(JSON.stringify(message));
256
+ };
257
+
258
+ var closeButton = document.querySelector('.chatbot-close-button');
259
+ if (closeButton) {
260
+ closeButton.addEventListener('click', () => {
261
+ window.sendToChatbot({ type: 'close_chatbot' });
262
+ });
263
+ }
264
+
265
+ true;
266
+ `);
267
+ isFirstLoadRef.current = false;
268
+ },
269
+ onError: syntheticEvent => {
270
+ const {
271
+ nativeEvent
272
+ } = syntheticEvent;
273
+ console.warn("WebView error:", nativeEvent);
274
+ }
275
+ })))));
276
+ };
277
+ const styles = _reactNative.StyleSheet.create({
278
+ mainContainer: {
279
+ flex: 1,
280
+ position: "relative"
281
+ },
282
+ webViewWrapper: {
283
+ position: "absolute",
284
+ top: 0,
285
+ left: 0,
286
+ right: 0,
287
+ bottom: 0,
288
+ overflow: "hidden",
289
+ zIndex: 1000
290
+ },
291
+ fullScreenContainer: {
292
+ position: "absolute",
293
+ top: 0,
294
+ left: 0,
295
+ right: 0,
296
+ bottom: 0,
297
+ backgroundColor: "white",
298
+ zIndex: 1000
299
+ },
300
+ inlineContainer: {
301
+ flex: 1,
302
+ backgroundColor: "white"
303
+ },
304
+ webview: {
305
+ flex: 1,
306
+ backgroundColor: "white"
307
+ }
308
+ });
309
+ var _default = exports.default = ChatbotSDK;
2
310
  //# sourceMappingURL=Chatbotsdk.js.map