@robylon/react-native-sdk 2.0.14 → 2.0.16-staging.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/Chatbotsdk.js +1 -1
- package/lib/commonjs/Chatbotsdk.js.map +1 -1
- package/lib/commonjs/config.js +1 -1
- package/lib/commonjs/config.js.map +1 -1
- package/lib/commonjs/constants.js +1 -1
- package/lib/commonjs/constants.js.map +1 -1
- package/lib/commonjs/openChatbot.js +1 -2
- package/lib/commonjs/openChatbot.js.map +1 -1
- package/lib/module/Chatbotsdk.js +1 -1
- package/lib/module/Chatbotsdk.js.map +1 -1
- package/lib/module/config.js +1 -1
- package/lib/module/config.js.map +1 -1
- package/lib/module/constants.js +1 -1
- package/lib/module/constants.js.map +1 -1
- package/lib/module/openChatbot.js.map +1 -1
- package/lib/typescript/Chatbotsdk.d.ts +5 -0
- package/lib/typescript/Chatbotsdk.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/ChatbotWebview.tsx +44 -0
- package/src/Chatbotsdk.tsx +398 -0
- package/src/FloatingButton.tsx +57 -0
- package/src/LoadingIndicator.tsx +11 -0
- package/src/Toast.tsx +65 -0
- package/src/config.ts +4 -0
- package/src/constants.ts +4 -0
- package/src/global.d.ts +11 -0
- package/src/index.tsx +2 -0
- package/src/openChatbot.ts +11 -0
- package/src/openChatbot.tsx +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
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 _Toast=_interopRequireDefault(require("./Toast"));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 _useState7=(0,_react.useState)(false),_useState8=(0,_slicedToArray2.default)(_useState7,2),toastVisible=_useState8[0],setToastVisible=_useState8[1];var _useState9=(0,_react.useState)(""),_useState10=(0,_slicedToArray2.default)(_useState9,2),toastMessage=_useState10[0],setToastMessage=_useState10[1];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=_constants.API_URL+"/chat/chatbot/get/";var payload={client_user_id:user_id,org_id:api_key,token:user_token,extra_info:stableAdditionalParams};setToastMessage(endpointUrl+" : "+_constants.BASE_CHATBOT_URL);setToastVisible(true);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.jsxs)(_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);}})})})]}),(0,_jsxRuntime.jsx)(_Toast.default,{message:toastMessage,visible:toastVisible,duration:10000})]});};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
|
+
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,user_info=_ref.user_info;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 _useState7=(0,_react.useState)(false),_useState8=(0,_slicedToArray2.default)(_useState7,2),toastVisible=_useState8[0],setToastVisible=_useState8[1];var _useState9=(0,_react.useState)(""),_useState10=(0,_slicedToArray2.default)(_useState9,2),toastMessage=_useState10[0],setToastMessage=_useState10[1];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=_constants.API_URL+"/chat/chatbot/get/";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,user_info:Object.assign({},user_info,{platform:_reactNative.Platform.OS,SDK_VERSION:"${SDK_VERSION}",OS:_reactNative.Platform.OS,browser:_reactNative.Platform.OS})}})+", '*');\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;
|
|
2
2
|
//# sourceMappingURL=Chatbotsdk.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeWebview","_FloatingButton","_interopRequireDefault","_constants","_Toast","_jsxRuntime","_this","_jsxFileName","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","ChatbotSDK","_ref","api_key","user_id","user_token","_ref$additional_param","additional_params","_ref$show_floating_bu","show_floating_button","onMessage","_ref$isFullScreen","isFullScreen","_ref$enableAnimation","enableAnimation","onOpen","onClose","_useState","useState","_useState2","_slicedToArray2","isWebViewVisible","setIsWebViewVisible","_useState3","_useState4","chatbotConfig","setChatbotConfig","_useState5","_useState6","loading","setLoading","webViewRef","useRef","fadeAnim","Animated","Value","current","isFirstLoadRef","_useState7","_useState8","toastVisible","setToastVisible","_useState9","_useState10","toastMessage","setToastMessage","webViewUrl","useMemo","constructUrl","stableAdditionalParams","JSON","stringify","triggerAppInit","injectJavaScript","useEffect","fetchChatbotConfig","_ref2","_asyncToGenerator2","_data$user","endpointUrl","API_URL","payload","client_user_id","org_id","token","extra_info","BASE_CHATBOT_URL","response","fetch","method","headers","body","ok","Error","data","json","orgInfo","user","org_info","_orgInfo$config","_orgInfo$brand_config","_orgInfo$config2","brand_color","config","brand_colour","image_url","brand_config","launcher_logo_url","welcome_message","error","console","apply","arguments","params","URLSearchParams","assign","id","toString","openWebView","timing","toValue","duration","useNativeDriver","start","setTimeout","setValue","requestAnimationFrame","closeWebView","log","postMessage","name","domain","complete","handleMessage","event","nativeEvent","parsedData","parse","type","action","userId","warn","getScreenDimensions","windowHeight","Dimensions","height","windowWidth","width","statusBarHeight","Platform","OS","StatusBar","currentHeight","screenDimensions","jsxs","View","style","styles","mainContainer","children","Fragment","jsx","onPress","brandColor","imageUrl","webViewWrapper","pointerEvents","fullScreenContainer","inlineContainer","opacity","WebView","ref","source","uri","webview","containerStyle","undefined","allowsInlineMediaPlayback","mediaPlaybackRequiresUserAction","allowFileAccess","geolocationEnabled","javaScriptEnabled","domStorageEnabled","cacheEnabled","scrollEnabled","bounces","onShouldStartLoadWithRequest","request","url","startsWith","startInLoadingState","onLoadEnd","_webViewRef$current","onError","syntheticEvent","message","visible","StyleSheet","create","flex","position","top","left","right","bottom","overflow","zIndex","backgroundColor","_default","exports"],"sourceRoot":"../../src","sources":["Chatbotsdk.tsx"],"mappings":"iWAAA,IAAAA,MAAA,CAAAC,uBAAA,CAAAC,OAAA,WACA,IAAAC,YAAA,CAAAD,OAAA,iBAQA,IAAAE,mBAAA,CAAAF,OAAA,yBACA,IAAAG,eAAA,CAAAC,sBAAA,CAAAJ,OAAA,sBACA,IAAAK,UAAA,CAAAL,OAAA,gBACA,IAAAM,MAAA,CAAAF,sBAAA,CAAAJ,OAAA,aAA4B,IAAAO,WAAA,CAAAP,OAAA,0BAAAQ,KAAA,MAAAC,YAAA,+FAAAC,yBAAAC,CAAA,wBAAAC,OAAA,iBAAAC,CAAA,KAAAD,OAAA,GAAAE,CAAA,KAAAF,OAAA,UAAAF,wBAAA,UAAAA,yBAAAC,CAAA,SAAAA,CAAA,CAAAG,CAAA,CAAAD,CAAA,IAAAF,CAAA,YAAAZ,wBAAAY,CAAA,CAAAE,CAAA,MAAAA,CAAA,EAAAF,CAAA,EAAAA,CAAA,CAAAI,UAAA,QAAAJ,CAAA,WAAAA,CAAA,mBAAAA,CAAA,qBAAAA,CAAA,QAAAK,OAAA,CAAAL,CAAA,MAAAG,CAAA,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eAAe,CAAE,CACf+B,IAAI,CAAE,CAAC,CACPQ,eAAe,CAAE,OACnB,CAAC,CACDjC,OAAO,CAAE,CACPyB,IAAI,CAAE,CAAC,CACPQ,eAAe,CAAE,OACnB,CACF,CAAC,CAAC,CAAC,IAAAC,QAAA,CAAAC,OAAA,CAAA1M,OAAA,CAEYc,UAAU","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeWebview","_FloatingButton","_interopRequireDefault","_constants","_jsxRuntime","_this","_jsxFileName","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","ChatbotSDK","_ref","api_key","user_id","user_token","_ref$additional_param","additional_params","_ref$show_floating_bu","show_floating_button","onMessage","_ref$isFullScreen","isFullScreen","_ref$enableAnimation","enableAnimation","onOpen","onClose","user_info","_useState","useState","_useState2","_slicedToArray2","isWebViewVisible","setIsWebViewVisible","_useState3","_useState4","chatbotConfig","setChatbotConfig","_useState5","_useState6","loading","setLoading","webViewRef","useRef","fadeAnim","Animated","Value","current","isFirstLoadRef","_useState7","_useState8","toastVisible","setToastVisible","_useState9","_useState10","toastMessage","setToastMessage","webViewUrl","useMemo","constructUrl","stableAdditionalParams","JSON","stringify","triggerAppInit","injectJavaScript","useEffect","fetchChatbotConfig","_ref2","_asyncToGenerator2","_data$user","endpointUrl","API_URL","payload","client_user_id","org_id","token","extra_info","response","fetch","method","headers","body","ok","Error","data","json","orgInfo","user","org_info","_orgInfo$config","_orgInfo$brand_config","_orgInfo$config2","brand_color","config","brand_colour","image_url","brand_config","launcher_logo_url","welcome_message","error","console","apply","arguments","params","URLSearchParams","assign","id","BASE_CHATBOT_URL","toString","openWebView","timing","toValue","duration","useNativeDriver","start","setTimeout","setValue","requestAnimationFrame","closeWebView","log","postMessage","name","domain","complete","handleMessage","event","nativeEvent","parsedData","parse","type","action","userId","platform","Platform","OS","SDK_VERSION","browser","warn","getScreenDimensions","windowHeight","Dimensions","height","windowWidth","width","statusBarHeight","StatusBar","currentHeight","screenDimensions","jsx","View","style","styles","mainContainer","children","jsxs","Fragment","onPress","brandColor","imageUrl","webViewWrapper","pointerEvents","fullScreenContainer","inlineContainer","opacity","WebView","ref","source","uri","webview","containerStyle","undefined","allowsInlineMediaPlayback","mediaPlaybackRequiresUserAction","allowFileAccess","geolocationEnabled","javaScriptEnabled","domStorageEnabled","cacheEnabled","scrollEnabled","bounces","onShouldStartLoadWithRequest","request","url","startsWith","startInLoadingState","onLoadEnd","_webViewRef$current","onError","syntheticEvent","StyleSheet","create","flex","position","top","left","right","bottom","overflow","zIndex","backgroundColor","_default","exports"],"sourceRoot":"../../src","sources":["Chatbotsdk.tsx"],"mappings":"iWAAA,IAAAA,MAAA,CAAAC,uBAAA,CAAAC,OAAA,WACA,IAAAC,YAAA,CAAAD,OAAA,iBAQA,IAAAE,mBAAA,CAAAF,OAAA,yBACA,IAAAG,eAAA,CAAAC,sBAAA,CAAAJ,OAAA,sBACA,IAAAK,UAAA,CAAAL,OAAA,gBAAwD,IAAAM,WAAA,CAAAN,OAAA,0BAAAO,KAAA,MAAAC,YAAA,+FAAAC,yBAAAC,CAAA,wBAAAC,OAAA,iBAAAC,CAAA,KAAAD,OAAA,GAAAE,CAAA,KAAAF,OAAA,UAAAF,wBAAA,UAAAA,yBAAAC,CAAA,SAAAA,CAAA,CAAAG,CAAA,CAAAD,CAAA,IAAAF,CAAA,YAAAX,wBAAAW,CAAA,CAAAE,CAAA,MAAAA,CAAA,EAAAF,CAAA,EAAAA,CAAA,CAAAI,UAAA,QAAAJ,CAAA,WAAAA,CAAA,mBAAAA,CAAA,qBAAAA,CAAA,QAAAK,OAAA,CAAAL,CAAA,MAAAG,CAAA,CAAAJ,wBAAA,CAAAG,CAAA,KAAAC,CAAA,EAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,SAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,MA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e,CAAE,OACnB,CACF,CAAC,CAAC,CAAC,IAAAC,QAAA,CAAAC,OAAA,CAAA5M,OAAA,CAEYc,UAAU","ignoreList":[]}
|
package/lib/commonjs/config.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,"__esModule",{value:true});exports.config=void 0;var config=exports.config={API_URL:process&&process.env&&process.env.API_URL||"https://api.robylon.ai"||'https://api.robylon.com',DEBUG:(process&&process.env&&process.env.DEBUG||"
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:true});exports.config=void 0;var config=exports.config={API_URL:process&&process.env&&process.env.API_URL||"https://stage-api.robylon.ai"||'https://api.robylon.com',DEBUG:(process&&process.env&&process.env.DEBUG||"true")==='true'};
|
|
2
2
|
//# sourceMappingURL=config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["config","exports","API_URL","process","env","process.env","DEBUG"],"sourceRoot":"../../src","sources":["config.ts"],"mappings":"+EAAO,GAAM,CAAAA,MAAM,CAAAC,OAAA,CAAAD,MAAA,CAAG,CACpBE,OAAO,CAAEC,OAAA,EAAAA,OAAA,CAAAC,GAAA,EAAAC,WAAA,CAAAH,OAAA,
|
|
1
|
+
{"version":3,"names":["config","exports","API_URL","process","env","process.env","DEBUG"],"sourceRoot":"../../src","sources":["config.ts"],"mappings":"+EAAO,GAAM,CAAAA,MAAM,CAAAC,OAAA,CAAAD,MAAA,CAAG,CACpBE,OAAO,CAAEC,OAAA,EAAAA,OAAA,CAAAC,GAAA,EAAAC,WAAA,CAAAH,OAAA,kCAAuB,yBAAyB,CACzDI,KAAK,CAAE,CAAAH,OAAA,EAAAA,OAAA,CAAAC,GAAA,EAAAC,WAAA,CAAAC,KAAA,YAAsB,MAC/B,CAAC","ignoreList":[]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,"__esModule",{value:true});exports.BASE_CHATBOT_URL=exports.API_URL=void 0;var BASE_CHATBOT_DOMAIN=process&&process.env&&process.env.CHATBOT_DOMAIN||"
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:true});exports.BASE_CHATBOT_URL=exports.API_URL=void 0;var BASE_CHATBOT_DOMAIN=process&&process.env&&process.env.CHATBOT_DOMAIN||"http://192.168.1.6:5174"||"";var CHATBOT_PATH=process&&process.env&&process.env.CHATBOT_PATH||"chatbot-plugin"||"";var BASE_CHATBOT_URL=exports.BASE_CHATBOT_URL=BASE_CHATBOT_DOMAIN+"/"+CHATBOT_PATH;var API_URL=exports.API_URL=process&&process.env&&process.env.API_URL||"https://stage-api.robylon.ai";
|
|
2
2
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["BASE_CHATBOT_DOMAIN","process","env","process.env","CHATBOT_DOMAIN","CHATBOT_PATH","BASE_CHATBOT_URL","exports","API_URL"],"sourceRoot":"../../src","sources":["constants.ts"],"mappings":"yGAAA,GAAM,CAAAA,mBAAmB,CAAGC,OAAA,EAAAA,OAAA,CAAAC,GAAA,EAAAC,WAAA,CAAAC,cAAA,
|
|
1
|
+
{"version":3,"names":["BASE_CHATBOT_DOMAIN","process","env","process.env","CHATBOT_DOMAIN","CHATBOT_PATH","BASE_CHATBOT_URL","exports","API_URL"],"sourceRoot":"../../src","sources":["constants.ts"],"mappings":"yGAAA,GAAM,CAAAA,mBAAmB,CAAGC,OAAA,EAAAA,OAAA,CAAAC,GAAA,EAAAC,WAAA,CAAAC,cAAA,6BAA8B,EAAE,CAC5D,GAAM,CAAAC,YAAY,CAAGJ,OAAA,EAAAA,OAAA,CAAAC,GAAA,EAAAC,WAAA,CAAAE,YAAA,oBAA4B,EAAE,CAC5C,GAAM,CAAAC,gBAAgB,CAAAC,OAAA,CAAAD,gBAAA,CAAMN,mBAAmB,KAAIK,YAAc,CACjE,GAAM,CAAAG,OAAO,CAAAD,OAAA,CAAAC,OAAA,CAAAP,OAAA,EAAAA,OAAA,CAAAC,GAAA,EAAAC,WAAA,CAAAK,OAAA,gCAAsB","ignoreList":[]}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
//# sourceMappingURL=openChatbot.js.mape",{value:true});exports.openChatbot=void 0;var _reactNative=require("react-native");var _constants=require("./constants");var openChatbot=exports.openChatbot=function openChatbot(chatbotId){var additionalParams=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var params=new URLSearchParams(Object.assign({id:chatbotId},additionalParams));var url=_constants.BASE_CHATBOT_URL+"?"+params.toString();_reactNative.Linking.openURL(url);};
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:true});exports.openChatbot=void 0;var _reactNative=require("react-native");var _constants=require("./constants");var openChatbot=exports.openChatbot=function openChatbot(chatbotId){var additionalParams=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var params=new URLSearchParams(Object.assign({id:chatbotId},additionalParams));var url=_constants.BASE_CHATBOT_URL+"?"+params.toString();_reactNative.Linking.openURL(url);};
|
|
3
2
|
//# sourceMappingURL=openChatbot.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../src","sources":["openChatbot.
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_constants","openChatbot","exports","chatbotId","additionalParams","arguments","length","undefined","params","URLSearchParams","Object","assign","id","url","BASE_CHATBOT_URL","toString","Linking","openURL"],"sourceRoot":"../../src","sources":["openChatbot.ts"],"mappings":"oFAAA,IAAAA,YAAA,CAAAC,OAAA,iBACA,IAAAC,UAAA,CAAAD,OAAA,gBAEO,GAAM,CAAAE,WAAW,CAAAC,OAAA,CAAAD,WAAA,CAAG,QAAd,CAAAA,WAAWA,CACtBE,SAAiB,CAER,IADT,CAAAC,gBAAwC,CAAAC,SAAA,CAAAC,MAAA,IAAAD,SAAA,MAAAE,SAAA,CAAAF,SAAA,IAAG,CAAC,CAAC,CAE7C,GAAM,CAAAG,MAAM,CAAG,GAAI,CAAAC,eAAe,CAAAC,MAAA,CAAAC,MAAA,EAAGC,EAAE,CAAET,SAAS,EAAKC,gBAAgB,CAAE,CAAC,CAC1E,GAAM,CAAAS,GAAG,CAAMC,2BAAgB,KAAIN,MAAM,CAACO,QAAQ,CAAC,CAAG,CACtDC,oBAAO,CAACC,OAAO,CAACJ,GAAG,CAAC,CACtB,CAAC","ignoreList":[]}
|
package/lib/module/Chatbotsdk.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
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 _Toast=_interopRequireDefault(require("./Toast"));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 _useState7=(0,_react.useState)(false),_useState8=(0,_slicedToArray2.default)(_useState7,2),toastVisible=_useState8[0],setToastVisible=_useState8[1];var _useState9=(0,_react.useState)(""),_useState10=(0,_slicedToArray2.default)(_useState9,2),toastMessage=_useState10[0],setToastMessage=_useState10[1];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=_constants.API_URL+"/chat/chatbot/get/";var payload={client_user_id:user_id,org_id:api_key,token:user_token,extra_info:stableAdditionalParams};setToastMessage(endpointUrl+" : "+_constants.BASE_CHATBOT_URL);setToastVisible(true);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.jsxs)(_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);}})})})]}),(0,_jsxRuntime.jsx)(_Toast.default,{message:toastMessage,visible:toastVisible,duration:10000})]});};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
|
+
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,user_info=_ref.user_info;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 _useState7=(0,_react.useState)(false),_useState8=(0,_slicedToArray2.default)(_useState7,2),toastVisible=_useState8[0],setToastVisible=_useState8[1];var _useState9=(0,_react.useState)(""),_useState10=(0,_slicedToArray2.default)(_useState9,2),toastMessage=_useState10[0],setToastMessage=_useState10[1];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=_constants.API_URL+"/chat/chatbot/get/";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,user_info:Object.assign({},user_info,{platform:_reactNative.Platform.OS,SDK_VERSION:"${SDK_VERSION}",OS:_reactNative.Platform.OS,browser:_reactNative.Platform.OS})}})+", '*');\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;
|
|
2
2
|
//# sourceMappingURL=Chatbotsdk.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeWebview","_FloatingButton","_interopRequireDefault","_constants","_Toast","_jsxRuntime","_this","_jsxFileName","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","ChatbotSDK","_ref","api_key","user_id","user_token","_ref$additional_param","additional_params","_ref$show_floating_bu","show_floating_button","onMessage","_ref$isFullScreen","isFullScreen","_ref$enableAnimation","enableAnimation","onOpen","onClose","_useState","useState","_useState2","_slicedToArray2","isWebViewVisible","setIsWebViewVisible","_useState3","_useState4","chatbotConfig","setChatbotConfig","_useState5","_useState6","loading","setLoading","webViewRef","useRef","fadeAnim","Animated","Value","current","isFirstLoadRef","_useState7","_useState8","toastVisible","setToastVisible","_useState9","_useState10","toastMessage","setToastMessage","webViewUrl","useMemo","constructUrl","stableAdditionalParams","JSON","stringify","triggerAppInit","injectJavaScript","useEffect","fetchChatbotConfig","_ref2","_asyncToGenerator2","_data$user","endpointUrl","API_URL","payload","client_user_id","org_id","token","extra_info","BASE_CHATBOT_URL","response","fetch","method","headers","body","ok","Error","data","json","orgInfo","user","org_info","_orgInfo$config","_orgInfo$brand_config","_orgInfo$config2","brand_color","config","brand_colour","image_url","brand_config","launcher_logo_url","welcome_message","error","console","apply","arguments","params","URLSearchParams","assign","id","toString","openWebView","timing","toValue","duration","useNativeDriver","start","setTimeout","setValue","requestAnimationFrame","closeWebView","log","postMessage","name","domain","complete","handleMessage","event","nativeEvent","parsedData","parse","type","action","userId","warn","getScreenDimensions","windowHeight","Dimensions","height","windowWidth","width","statusBarHeight","Platform","OS","StatusBar","currentHeight","screenDimensions","jsxs","View","style","styles","mainContainer","children","Fragment","jsx","onPress","brandColor","imageUrl","webViewWrapper","pointerEvents","fullScreenContainer","inlineContainer","opacity","WebView","ref","source","uri","webview","containerStyle","undefined","allowsInlineMediaPlayback","mediaPlaybackRequiresUserAction","allowFileAccess","geolocationEnabled","javaScriptEnabled","domStorageEnabled","cacheEnabled","scrollEnabled","bounces","onShouldStartLoadWithRequest","request","url","startsWith","startInLoadingState","onLoadEnd","_webViewRef$current","onError","syntheticEvent","message","visible","StyleSheet","create","flex","position","top","left","right","bottom","overflow","zIndex","backgroundColor","_default","exports"],"sourceRoot":"../../src","sources":["Chatbotsdk.tsx"],"mappings":"iWAAA,IAAAA,MAAA,CAAAC,uBAAA,CAAAC,OAAA,WACA,IAAAC,YAAA,CAAAD,OAAA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CAAE,KAAM,CAAE,CAAC,EACpE,CAAC,CAEX,CAAC,CAED,GAAM,CAAAoC,MAAM,CAAGwC,uBAAU,CAACC,MAAM,CAAC,CAC/BxC,aAAa,CAAE,CACbyC,IAAI,CAAE,CAAC,CACPC,QAAQ,CAAE,UACZ,CAAC,CACDnC,cAAc,CAAE,CACdmC,QAAQ,CAAE,UAAU,CACpBC,GAAG,CAAE,CAAC,CACNC,IAAI,CAAE,CAAC,CACPC,KAAK,CAAE,CAAC,CACRC,MAAM,CAAE,CAAC,CACTC,QAAQ,CAAE,QAAQ,CAClBC,MAAM,CAAE,IACV,CAAC,CACDvC,mBAAmB,CAAE,CACnBiC,QAAQ,CAAE,UAAU,CACpBC,GAAG,CAAE,CAAC,CACNC,IAAI,CAAE,CAAC,CACPC,KAAK,CAAE,CAAC,CACRC,MAAM,CAAE,CAAC,CACTG,eAAe,CAAE,OAAO,CACxBD,MAAM,CAAE,IACV,CAAC,CACDtC,eAAe,CAAE,CACf+B,IAAI,CAAE,CAAC,CACPQ,eAAe,CAAE,OACnB,CAAC,CACDjC,OAAO,CAAE,CACPyB,IAAI,CAAE,CAAC,CACPQ,eAAe,CAAE,OACnB,CACF,CAAC,CAAC,CAAC,IAAAC,QAAA,CAAAC,OAAA,CAAA1M,OAAA,CAEYc,UAAU","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeWebview","_FloatingButton","_interopRequireDefault","_constants","_jsxRuntime","_this","_jsxFileName","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","ChatbotSDK","_ref","api_key","user_id","user_token","_ref$additional_param","additional_params","_ref$show_floating_bu","show_floating_button","onMessage","_ref$isFullScreen","isFullScreen","_ref$enableAnimation","enableAnimation","onOpen","onClose","user_info","_useState","useState","_useState2","_slicedToArray2","isWebViewVisible","setIsWebViewVisible","_useState3","_useState4","chatbotConfig","setChatbotConfig","_useState5","_useState6","loading","setLoading","webViewRef","useRef","fadeAnim","Animated","Value","current","isFirstLoadRef","_useState7","_useState8","toastVisible","setToastVisible","_useState9","_useState10","toastMessage","setToastMessage","webViewUrl","useMemo","constructUrl","stableAdditionalParams","JSON","stringify","triggerAppInit","injectJavaScript","useEffect","fetchChatbotConfig","_ref2","_asyncToGenerator2","_data$user","endpointUrl","API_URL","payload","client_user_id","org_id","token","extra_info","response","fetch","method","headers","body","ok","Error","data","json","orgInfo","user","org_info","_orgInfo$config","_orgInfo$brand_config","_orgInfo$config2","brand_color","config","brand_colour","image_url","brand_config","launcher_logo_url","welcome_message","error","console","apply","arguments","params","URLSearchParams","assign","id","BASE_CHATBOT_URL","toString","openWebView","timing","toValue","duration","useNativeDriver","start","setTimeout","setValue","requestAnimationFrame","closeWebView","log","postMessage","name","domain","complete","handleMessage","event","nativeEvent","parsedData","parse","type","action","userId","platform","Platform","OS","SDK_VERSION","browser","warn","getScreenDimensions","windowHeight","Dimensions","height","windowWidth","width","statusBarHeight","StatusBar","currentHeight","screenDimensions","jsx","View","style","styles","mainContainer","children","jsxs","Fragment","onPress","brandColor","imageUrl","webViewWrapper","pointerEvents","fullScreenContainer","inlineContainer","opacity","WebView","ref","source","uri","webview","containerStyle","undefined","allowsInlineMediaPlayback","mediaPlaybackRequiresUserAction","allowFileAccess","geolocationEnabled","javaScriptEnabled","domStorageEnabled","cacheEnabled","scrollEnabled","bounces","onShouldStartLoadWithRequest","request","url","startsWith","startInLoadingState","onLoadEnd","_webViewRef$current","onError","syntheticEvent","StyleSheet","create","flex","position","top","left","right","bottom","overflow","zIndex","backgroundColor","_default","exports"],"sourceRoot":"../../src","sources":["Chatbotsdk.tsx"],"mappings":"iWAAA,IAAAA,MAAA,CAAAC,uBAAA,CAAAC,OAAA,WACA,IAAAC,YAAA,CAAAD,OAAA,iBAQA,IAAAE,mBAAA,CAAAF,OAAA,yBACA,IAAAG,eAAA,CAAAC,sBAAA,CAAA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AAE,CACbuC,IAAI,CAAE,CAAC,CACPC,QAAQ,CAAE,UACZ,CAAC,CACDjC,cAAc,CAAE,CACdiC,QAAQ,CAAE,UAAU,CACpBC,GAAG,CAAE,CAAC,CACNC,IAAI,CAAE,CAAC,CACPC,KAAK,CAAE,CAAC,CACRC,MAAM,CAAE,CAAC,CACTC,QAAQ,CAAE,QAAQ,CAClBC,MAAM,CAAE,IACV,CAAC,CACDrC,mBAAmB,CAAE,CACnB+B,QAAQ,CAAE,UAAU,CACpBC,GAAG,CAAE,CAAC,CACNC,IAAI,CAAE,CAAC,CACPC,KAAK,CAAE,CAAC,CACRC,MAAM,CAAE,CAAC,CACTG,eAAe,CAAE,OAAO,CACxBD,MAAM,CAAE,IACV,CAAC,CACDpC,eAAe,CAAE,CACf6B,IAAI,CAAE,CAAC,CACPQ,eAAe,CAAE,OACnB,CAAC,CACD/B,OAAO,CAAE,CACPuB,IAAI,CAAE,CAAC,CACPQ,eAAe,CAAE,OACnB,CACF,CAAC,CAAC,CAAC,IAAAC,QAAA,CAAAC,OAAA,CAAA5M,OAAA,CAEYc,UAAU","ignoreList":[]}
|
package/lib/module/config.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,"__esModule",{value:true});exports.config=void 0;var config=exports.config={API_URL:process&&process.env&&process.env.API_URL||"https://api.robylon.ai"||'https://api.robylon.com',DEBUG:(process&&process.env&&process.env.DEBUG||"
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:true});exports.config=void 0;var config=exports.config={API_URL:process&&process.env&&process.env.API_URL||"https://stage-api.robylon.ai"||'https://api.robylon.com',DEBUG:(process&&process.env&&process.env.DEBUG||"true")==='true'};
|
|
2
2
|
//# sourceMappingURL=config.js.map
|
package/lib/module/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["config","exports","API_URL","process","env","process.env","DEBUG"],"sourceRoot":"../../src","sources":["config.ts"],"mappings":"+EAAO,GAAM,CAAAA,MAAM,CAAAC,OAAA,CAAAD,MAAA,CAAG,CACpBE,OAAO,CAAEC,OAAA,EAAAA,OAAA,CAAAC,GAAA,EAAAC,WAAA,CAAAH,OAAA,
|
|
1
|
+
{"version":3,"names":["config","exports","API_URL","process","env","process.env","DEBUG"],"sourceRoot":"../../src","sources":["config.ts"],"mappings":"+EAAO,GAAM,CAAAA,MAAM,CAAAC,OAAA,CAAAD,MAAA,CAAG,CACpBE,OAAO,CAAEC,OAAA,EAAAA,OAAA,CAAAC,GAAA,EAAAC,WAAA,CAAAH,OAAA,kCAAuB,yBAAyB,CACzDI,KAAK,CAAE,CAAAH,OAAA,EAAAA,OAAA,CAAAC,GAAA,EAAAC,WAAA,CAAAC,KAAA,YAAsB,MAC/B,CAAC","ignoreList":[]}
|
package/lib/module/constants.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,"__esModule",{value:true});exports.BASE_CHATBOT_URL=exports.API_URL=void 0;var BASE_CHATBOT_DOMAIN=process&&process.env&&process.env.CHATBOT_DOMAIN||"
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:true});exports.BASE_CHATBOT_URL=exports.API_URL=void 0;var BASE_CHATBOT_DOMAIN=process&&process.env&&process.env.CHATBOT_DOMAIN||"http://192.168.1.6:5174"||"";var CHATBOT_PATH=process&&process.env&&process.env.CHATBOT_PATH||"chatbot-plugin"||"";var BASE_CHATBOT_URL=exports.BASE_CHATBOT_URL=BASE_CHATBOT_DOMAIN+"/"+CHATBOT_PATH;var API_URL=exports.API_URL=process&&process.env&&process.env.API_URL||"https://stage-api.robylon.ai";
|
|
2
2
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["BASE_CHATBOT_DOMAIN","process","env","process.env","CHATBOT_DOMAIN","CHATBOT_PATH","BASE_CHATBOT_URL","exports","API_URL"],"sourceRoot":"../../src","sources":["constants.ts"],"mappings":"yGAAA,GAAM,CAAAA,mBAAmB,CAAGC,OAAA,EAAAA,OAAA,CAAAC,GAAA,EAAAC,WAAA,CAAAC,cAAA,
|
|
1
|
+
{"version":3,"names":["BASE_CHATBOT_DOMAIN","process","env","process.env","CHATBOT_DOMAIN","CHATBOT_PATH","BASE_CHATBOT_URL","exports","API_URL"],"sourceRoot":"../../src","sources":["constants.ts"],"mappings":"yGAAA,GAAM,CAAAA,mBAAmB,CAAGC,OAAA,EAAAA,OAAA,CAAAC,GAAA,EAAAC,WAAA,CAAAC,cAAA,6BAA8B,EAAE,CAC5D,GAAM,CAAAC,YAAY,CAAGJ,OAAA,EAAAA,OAAA,CAAAC,GAAA,EAAAC,WAAA,CAAAE,YAAA,oBAA4B,EAAE,CAC5C,GAAM,CAAAC,gBAAgB,CAAAC,OAAA,CAAAD,gBAAA,CAAMN,mBAAmB,KAAIK,YAAc,CACjE,GAAM,CAAAG,OAAO,CAAAD,OAAA,CAAAC,OAAA,CAAAP,OAAA,EAAAA,OAAA,CAAAC,GAAA,EAAAC,WAAA,CAAAK,OAAA,gCAAsB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["openChatbot.tsx"],"mappings":"","ignoreList":[]}
|
|
@@ -10,6 +10,11 @@ interface ChatbotSDKProps {
|
|
|
10
10
|
enableAnimation?: boolean;
|
|
11
11
|
onOpen?: () => void;
|
|
12
12
|
onClose?: () => void;
|
|
13
|
+
user_info?: {
|
|
14
|
+
name?: string;
|
|
15
|
+
email?: string;
|
|
16
|
+
mobile?: string;
|
|
17
|
+
};
|
|
13
18
|
}
|
|
14
19
|
declare const ChatbotSDK: React.FC<ChatbotSDKProps>;
|
|
15
20
|
export default ChatbotSDK;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chatbotsdk.d.ts","sourceRoot":"","sources":["../../src/Chatbotsdk.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA+C,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Chatbotsdk.d.ts","sourceRoot":"","sources":["../../src/Chatbotsdk.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA+C,MAAM,OAAO,CAAC;AAapE,UAAU,eAAe;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3C,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,IAAI,CAAC;IACnC,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,SAAS,CAAC,EAAE;QACV,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;CACH;AAaD,QAAA,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAgUzC,CAAC;AAmCF,eAAe,UAAU,CAAC"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// File: src/ChatbotWebview.tsx
|
|
2
|
+
import React, { useEffect, useState } from "react";
|
|
3
|
+
import { View } from "react-native";
|
|
4
|
+
import { WebView } from "react-native-webview";
|
|
5
|
+
import { BASE_CHATBOT_URL } from "./constants";
|
|
6
|
+
import LoadingIndicator from "./LoadingIndicator";
|
|
7
|
+
|
|
8
|
+
interface ChatbotWebviewProps {
|
|
9
|
+
chatbotId: string;
|
|
10
|
+
additionalParams?: Record<string, string>;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const constructUrl = (
|
|
14
|
+
chatbotId: string,
|
|
15
|
+
additionalParams: Record<string, string> = {}
|
|
16
|
+
): string => {
|
|
17
|
+
const params = new URLSearchParams({ id: chatbotId, ...additionalParams });
|
|
18
|
+
return `${BASE_CHATBOT_URL}?${params.toString()}`;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const ChatbotWebview: React.FC<ChatbotWebviewProps> = ({
|
|
22
|
+
chatbotId,
|
|
23
|
+
additionalParams,
|
|
24
|
+
}) => {
|
|
25
|
+
const [url, setUrl] = useState<string>("");
|
|
26
|
+
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
setUrl(constructUrl(chatbotId, additionalParams));
|
|
29
|
+
}, [chatbotId, additionalParams]);
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<View style={{ flex: 1 }}>
|
|
33
|
+
{url ? (
|
|
34
|
+
<WebView
|
|
35
|
+
source={{ uri: url }}
|
|
36
|
+
startInLoadingState={true}
|
|
37
|
+
renderLoading={() => <LoadingIndicator />}
|
|
38
|
+
/>
|
|
39
|
+
) : (
|
|
40
|
+
<LoadingIndicator />
|
|
41
|
+
)}
|
|
42
|
+
</View>
|
|
43
|
+
);
|
|
44
|
+
};
|
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
import React, { useState, useEffect, useRef, useMemo } from "react";
|
|
2
|
+
import {
|
|
3
|
+
View,
|
|
4
|
+
StyleSheet,
|
|
5
|
+
Animated,
|
|
6
|
+
Dimensions,
|
|
7
|
+
Platform,
|
|
8
|
+
StatusBar,
|
|
9
|
+
} from "react-native";
|
|
10
|
+
import { WebView, WebViewMessageEvent } from "react-native-webview";
|
|
11
|
+
import FloatingButton from "./FloatingButton";
|
|
12
|
+
import { API_URL, BASE_CHATBOT_URL } from "./constants";
|
|
13
|
+
|
|
14
|
+
interface ChatbotSDKProps {
|
|
15
|
+
api_key: string;
|
|
16
|
+
user_id?: string;
|
|
17
|
+
user_token?: string;
|
|
18
|
+
additional_params?: Record<string, string>;
|
|
19
|
+
show_floating_button?: boolean;
|
|
20
|
+
onMessage?: (message: any) => void;
|
|
21
|
+
isFullScreen?: boolean;
|
|
22
|
+
enableAnimation?: boolean;
|
|
23
|
+
onOpen?: () => void;
|
|
24
|
+
onClose?: () => void;
|
|
25
|
+
user_info?: {
|
|
26
|
+
name?: string;
|
|
27
|
+
email?: string;
|
|
28
|
+
mobile?: string;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
interface ChatbotMessage {
|
|
33
|
+
type: string;
|
|
34
|
+
data?: any;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
interface ChatbotConfig {
|
|
38
|
+
brand_color: string;
|
|
39
|
+
image_url: string;
|
|
40
|
+
welcome_message: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const ChatbotSDK: React.FC<ChatbotSDKProps> = ({
|
|
44
|
+
api_key,
|
|
45
|
+
user_id,
|
|
46
|
+
user_token,
|
|
47
|
+
additional_params = {},
|
|
48
|
+
show_floating_button = true,
|
|
49
|
+
onMessage,
|
|
50
|
+
isFullScreen = true,
|
|
51
|
+
enableAnimation = true,
|
|
52
|
+
onOpen,
|
|
53
|
+
onClose,
|
|
54
|
+
user_info,
|
|
55
|
+
}) => {
|
|
56
|
+
const [isWebViewVisible, setIsWebViewVisible] = useState(false);
|
|
57
|
+
const [chatbotConfig, setChatbotConfig] = useState<ChatbotConfig | null>(
|
|
58
|
+
null
|
|
59
|
+
);
|
|
60
|
+
const [loading, setLoading] = useState(true);
|
|
61
|
+
const webViewRef = useRef<WebView>(null);
|
|
62
|
+
const fadeAnim = useRef(new Animated.Value(0)).current;
|
|
63
|
+
const isFirstLoadRef = useRef(true);
|
|
64
|
+
const [toastVisible, setToastVisible] = useState(false);
|
|
65
|
+
const [toastMessage, setToastMessage] = useState("");
|
|
66
|
+
const webViewUrl = useMemo(
|
|
67
|
+
() => constructUrl(),
|
|
68
|
+
[api_key, user_id, additional_params]
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
const stableAdditionalParams = useMemo(
|
|
72
|
+
() => additional_params,
|
|
73
|
+
[JSON.stringify(additional_params)]
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
const triggerAppInit = () => {
|
|
77
|
+
if (webViewRef.current) {
|
|
78
|
+
webViewRef.current.injectJavaScript(`
|
|
79
|
+
// Trigger APP_READY equivalent
|
|
80
|
+
window.ReactNativeWebView.postMessage(JSON.stringify({ type: 'APP_READY' }));
|
|
81
|
+
true;
|
|
82
|
+
`);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
useEffect(() => {
|
|
87
|
+
const fetchChatbotConfig = async () => {
|
|
88
|
+
try {
|
|
89
|
+
const endpointUrl = `${API_URL}/chat/chatbot/get/`;
|
|
90
|
+
const payload = {
|
|
91
|
+
client_user_id: user_id,
|
|
92
|
+
org_id: api_key,
|
|
93
|
+
token: user_token,
|
|
94
|
+
extra_info: stableAdditionalParams,
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
// setToastMessage(endpointUrl + " : " + BASE_CHATBOT_URL);
|
|
98
|
+
// setToastVisible(true);
|
|
99
|
+
|
|
100
|
+
const response = await fetch(endpointUrl, {
|
|
101
|
+
method: "POST",
|
|
102
|
+
headers: {
|
|
103
|
+
"Content-Type": "application/json",
|
|
104
|
+
},
|
|
105
|
+
body: JSON.stringify(payload),
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
if (!response.ok) {
|
|
109
|
+
throw new Error("Failed to fetch chatbot configuration");
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const data = await response.json();
|
|
113
|
+
const orgInfo = data?.user?.org_info;
|
|
114
|
+
|
|
115
|
+
if (orgInfo) {
|
|
116
|
+
setChatbotConfig({
|
|
117
|
+
brand_color: orgInfo?.config?.brand_colour || "#007AFF",
|
|
118
|
+
image_url: orgInfo?.brand_config?.launcher_logo_url || "",
|
|
119
|
+
welcome_message: orgInfo?.config?.welcome_message || "",
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
} catch (error) {
|
|
123
|
+
console.error("Error fetching chatbot configuration:", error);
|
|
124
|
+
} finally {
|
|
125
|
+
setLoading(false);
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
if (api_key && user_id) {
|
|
130
|
+
fetchChatbotConfig();
|
|
131
|
+
}
|
|
132
|
+
}, [api_key, user_id, user_token, stableAdditionalParams]);
|
|
133
|
+
|
|
134
|
+
function constructUrl(): string {
|
|
135
|
+
if (!user_id) return "";
|
|
136
|
+
const params = new URLSearchParams({
|
|
137
|
+
id: api_key,
|
|
138
|
+
user_id,
|
|
139
|
+
...additional_params,
|
|
140
|
+
});
|
|
141
|
+
return `${BASE_CHATBOT_URL}?${params.toString()}`;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const openWebView = () => {
|
|
145
|
+
setIsWebViewVisible(true);
|
|
146
|
+
if (enableAnimation) {
|
|
147
|
+
Animated.timing(fadeAnim, {
|
|
148
|
+
toValue: 1,
|
|
149
|
+
duration: 250,
|
|
150
|
+
useNativeDriver: true,
|
|
151
|
+
}).start(() => {
|
|
152
|
+
onOpen?.();
|
|
153
|
+
if (!isFirstLoadRef.current) {
|
|
154
|
+
// If not first load, manually trigger initialization
|
|
155
|
+
setTimeout(triggerAppInit, 100);
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
} else {
|
|
159
|
+
fadeAnim.setValue(1);
|
|
160
|
+
requestAnimationFrame(() => {
|
|
161
|
+
onOpen?.();
|
|
162
|
+
if (!isFirstLoadRef.current) {
|
|
163
|
+
setTimeout(triggerAppInit, 100);
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
const closeWebView = () => {
|
|
170
|
+
if (webViewRef.current) {
|
|
171
|
+
console.log("closeWebView");
|
|
172
|
+
webViewRef.current.postMessage(
|
|
173
|
+
JSON.stringify({
|
|
174
|
+
name: "closeFrame",
|
|
175
|
+
domain: "app-domain.com",
|
|
176
|
+
})
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
const complete = () => {
|
|
181
|
+
setIsWebViewVisible(false);
|
|
182
|
+
onClose?.();
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
if (enableAnimation) {
|
|
186
|
+
Animated.timing(fadeAnim, {
|
|
187
|
+
toValue: 0,
|
|
188
|
+
duration: 200,
|
|
189
|
+
useNativeDriver: true,
|
|
190
|
+
}).start(complete);
|
|
191
|
+
} else {
|
|
192
|
+
fadeAnim.setValue(0);
|
|
193
|
+
requestAnimationFrame(complete);
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
const handleMessage = (event: WebViewMessageEvent) => {
|
|
198
|
+
const { data } = event.nativeEvent;
|
|
199
|
+
|
|
200
|
+
try {
|
|
201
|
+
const parsedData: ChatbotMessage = JSON.parse(data);
|
|
202
|
+
|
|
203
|
+
if (parsedData.type === "APP_READY") {
|
|
204
|
+
console.log("APP_READY", webViewRef.current && isWebViewVisible);
|
|
205
|
+
if (webViewRef.current && isWebViewVisible) {
|
|
206
|
+
webViewRef.current.injectJavaScript(`
|
|
207
|
+
window.postMessage(${JSON.stringify({
|
|
208
|
+
name: "openFrame",
|
|
209
|
+
domain: "app-domain.com",
|
|
210
|
+
})}, '*');
|
|
211
|
+
window.postMessage(${JSON.stringify({
|
|
212
|
+
name: "registerUserId",
|
|
213
|
+
action: "registerUserId",
|
|
214
|
+
domain: "app-domain.com",
|
|
215
|
+
data: {
|
|
216
|
+
userId: `${user_id}`,
|
|
217
|
+
token: `${user_token}`,
|
|
218
|
+
user_info: {
|
|
219
|
+
...user_info,
|
|
220
|
+
platform: Platform.OS,
|
|
221
|
+
SDK_VERSION: "${SDK_VERSION}",
|
|
222
|
+
OS: Platform.OS,
|
|
223
|
+
browser: Platform.OS,
|
|
224
|
+
},
|
|
225
|
+
},
|
|
226
|
+
})}, '*');
|
|
227
|
+
`);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
if (typeof parsedData !== "object" || !parsedData.type) {
|
|
232
|
+
console.warn("Invalid message structure");
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
switch (parsedData.type) {
|
|
237
|
+
case "close_chatbot":
|
|
238
|
+
closeWebView();
|
|
239
|
+
break;
|
|
240
|
+
default:
|
|
241
|
+
if (onMessage) onMessage(parsedData);
|
|
242
|
+
}
|
|
243
|
+
} catch (error) {
|
|
244
|
+
console.error("Failed to parse or process WebView message:", error);
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
const getScreenDimensions = () => {
|
|
249
|
+
const windowHeight = Dimensions.get("window").height;
|
|
250
|
+
const windowWidth = Dimensions.get("window").width;
|
|
251
|
+
const statusBarHeight =
|
|
252
|
+
Platform.OS === "ios" ? 0 : StatusBar.currentHeight || 0;
|
|
253
|
+
|
|
254
|
+
return {
|
|
255
|
+
height: windowHeight - statusBarHeight,
|
|
256
|
+
width: windowWidth,
|
|
257
|
+
};
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
const screenDimensions = getScreenDimensions();
|
|
261
|
+
|
|
262
|
+
return (
|
|
263
|
+
<View style={styles.mainContainer}>
|
|
264
|
+
{!loading && (
|
|
265
|
+
<>
|
|
266
|
+
{show_floating_button && api_key && chatbotConfig && (
|
|
267
|
+
<FloatingButton
|
|
268
|
+
onPress={openWebView}
|
|
269
|
+
brandColor={chatbotConfig.brand_color}
|
|
270
|
+
imageUrl={chatbotConfig.image_url}
|
|
271
|
+
/>
|
|
272
|
+
)}
|
|
273
|
+
<View
|
|
274
|
+
style={[
|
|
275
|
+
styles.webViewWrapper,
|
|
276
|
+
{ height: isWebViewVisible ? "100%" : 0 },
|
|
277
|
+
]}
|
|
278
|
+
pointerEvents={isWebViewVisible ? "auto" : "none"}
|
|
279
|
+
>
|
|
280
|
+
<Animated.View
|
|
281
|
+
style={[
|
|
282
|
+
isFullScreen
|
|
283
|
+
? styles.fullScreenContainer
|
|
284
|
+
: styles.inlineContainer,
|
|
285
|
+
{ opacity: fadeAnim },
|
|
286
|
+
]}
|
|
287
|
+
>
|
|
288
|
+
<WebView
|
|
289
|
+
ref={webViewRef}
|
|
290
|
+
source={{ uri: webViewUrl }}
|
|
291
|
+
onMessage={handleMessage}
|
|
292
|
+
style={styles.webview}
|
|
293
|
+
containerStyle={
|
|
294
|
+
isFullScreen
|
|
295
|
+
? {
|
|
296
|
+
width: screenDimensions.width,
|
|
297
|
+
height: screenDimensions.height,
|
|
298
|
+
}
|
|
299
|
+
: undefined
|
|
300
|
+
}
|
|
301
|
+
allowsInlineMediaPlayback={true}
|
|
302
|
+
mediaPlaybackRequiresUserAction={false}
|
|
303
|
+
allowFileAccess={false}
|
|
304
|
+
geolocationEnabled={false}
|
|
305
|
+
javaScriptEnabled={true}
|
|
306
|
+
domStorageEnabled={true}
|
|
307
|
+
cacheEnabled={true}
|
|
308
|
+
scrollEnabled={true}
|
|
309
|
+
bounces={false}
|
|
310
|
+
onShouldStartLoadWithRequest={(request) => {
|
|
311
|
+
return request.url.startsWith(BASE_CHATBOT_URL);
|
|
312
|
+
}}
|
|
313
|
+
startInLoadingState={isFirstLoadRef.current}
|
|
314
|
+
onLoadEnd={() => {
|
|
315
|
+
webViewRef.current?.injectJavaScript(`
|
|
316
|
+
if (!document.querySelector('meta[name="viewport"]')) {
|
|
317
|
+
var meta = document.createElement('meta');
|
|
318
|
+
meta.name = 'viewport';
|
|
319
|
+
meta.content = 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no';
|
|
320
|
+
document.getElementsByTagName('head')[0].appendChild(meta);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
if (!document.querySelector('#injectedStyle')) {
|
|
324
|
+
const style = document.createElement('style');
|
|
325
|
+
style.id = 'injectedStyle';
|
|
326
|
+
style.textContent = \`
|
|
327
|
+
html, body, #root, #__next {
|
|
328
|
+
height: 100% !important;
|
|
329
|
+
min-height: 100% !important;
|
|
330
|
+
overflow: hidden !important;
|
|
331
|
+
}
|
|
332
|
+
\`;
|
|
333
|
+
document.head.appendChild(style);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
window.sendToChatbot = function(message) {
|
|
337
|
+
window.ReactNativeWebView.postMessage(JSON.stringify(message));
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
var closeButton = document.querySelector('.chatbot-close-button');
|
|
341
|
+
if (closeButton) {
|
|
342
|
+
closeButton.addEventListener('click', () => {
|
|
343
|
+
window.sendToChatbot({ type: 'close_chatbot' });
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
true;
|
|
348
|
+
`);
|
|
349
|
+
isFirstLoadRef.current = false;
|
|
350
|
+
}}
|
|
351
|
+
onError={(syntheticEvent) => {
|
|
352
|
+
const { nativeEvent } = syntheticEvent;
|
|
353
|
+
console.warn("WebView error:", nativeEvent);
|
|
354
|
+
}}
|
|
355
|
+
/>
|
|
356
|
+
</Animated.View>
|
|
357
|
+
</View>
|
|
358
|
+
</>
|
|
359
|
+
)}
|
|
360
|
+
{/* <Toast message={toastMessage} visible={toastVisible} duration={10000} /> */}
|
|
361
|
+
</View>
|
|
362
|
+
);
|
|
363
|
+
};
|
|
364
|
+
|
|
365
|
+
const styles = StyleSheet.create({
|
|
366
|
+
mainContainer: {
|
|
367
|
+
flex: 1,
|
|
368
|
+
position: "relative",
|
|
369
|
+
},
|
|
370
|
+
webViewWrapper: {
|
|
371
|
+
position: "absolute",
|
|
372
|
+
top: 0,
|
|
373
|
+
left: 0,
|
|
374
|
+
right: 0,
|
|
375
|
+
bottom: 0,
|
|
376
|
+
overflow: "hidden",
|
|
377
|
+
zIndex: 1000,
|
|
378
|
+
},
|
|
379
|
+
fullScreenContainer: {
|
|
380
|
+
position: "absolute",
|
|
381
|
+
top: 0,
|
|
382
|
+
left: 0,
|
|
383
|
+
right: 0,
|
|
384
|
+
bottom: 0,
|
|
385
|
+
backgroundColor: "white",
|
|
386
|
+
zIndex: 1000,
|
|
387
|
+
},
|
|
388
|
+
inlineContainer: {
|
|
389
|
+
flex: 1,
|
|
390
|
+
backgroundColor: "white",
|
|
391
|
+
},
|
|
392
|
+
webview: {
|
|
393
|
+
flex: 1,
|
|
394
|
+
backgroundColor: "white",
|
|
395
|
+
},
|
|
396
|
+
});
|
|
397
|
+
|
|
398
|
+
export default ChatbotSDK;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { TouchableOpacity, StyleSheet, Text, Image } from "react-native";
|
|
3
|
+
|
|
4
|
+
interface FloatingButtonProps {
|
|
5
|
+
onPress: () => void;
|
|
6
|
+
brandColor?: string; // For dynamic branding
|
|
7
|
+
imageUrl?: string; // For brand logo or icon
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const FloatingButton: React.FC<FloatingButtonProps> = ({
|
|
11
|
+
onPress,
|
|
12
|
+
brandColor = "#007AFF", // Default color
|
|
13
|
+
imageUrl,
|
|
14
|
+
}) => {
|
|
15
|
+
return (
|
|
16
|
+
<TouchableOpacity
|
|
17
|
+
style={[styles.button, { backgroundColor: brandColor }]}
|
|
18
|
+
onPress={onPress}
|
|
19
|
+
>
|
|
20
|
+
{imageUrl ? (
|
|
21
|
+
<Image source={{ uri: imageUrl }} style={styles.buttonImage} />
|
|
22
|
+
) : (
|
|
23
|
+
<Text style={styles.buttonText}>Chat</Text>
|
|
24
|
+
)}
|
|
25
|
+
</TouchableOpacity>
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const styles = StyleSheet.create({
|
|
30
|
+
button: {
|
|
31
|
+
position: "absolute",
|
|
32
|
+
bottom: 20,
|
|
33
|
+
right: 20,
|
|
34
|
+
borderRadius: 24,
|
|
35
|
+
width: 48,
|
|
36
|
+
height: 48,
|
|
37
|
+
justifyContent: "center",
|
|
38
|
+
alignItems: "center",
|
|
39
|
+
elevation: 5,
|
|
40
|
+
shadowColor: "#000",
|
|
41
|
+
shadowOffset: { width: 0, height: 2 },
|
|
42
|
+
shadowOpacity: 0.25,
|
|
43
|
+
shadowRadius: 3.84,
|
|
44
|
+
},
|
|
45
|
+
buttonText: {
|
|
46
|
+
color: "white",
|
|
47
|
+
fontSize: 16,
|
|
48
|
+
fontWeight: "bold",
|
|
49
|
+
},
|
|
50
|
+
buttonImage: {
|
|
51
|
+
width: 48,
|
|
52
|
+
height: 48,
|
|
53
|
+
borderRadius: 24,
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
export default FloatingButton;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React, { useEffect, useState } from "react";
|
|
2
|
+
import { View, ActivityIndicator } from "react-native";
|
|
3
|
+
import { WebView } from "react-native-webview";
|
|
4
|
+
|
|
5
|
+
const LoadingIndicator: React.FC = () => (
|
|
6
|
+
<View style={{ flex: 1, justifyContent: "center", alignItems: "center" }}>
|
|
7
|
+
<ActivityIndicator size="large" color="#0000ff" />
|
|
8
|
+
</View>
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
export default LoadingIndicator;
|
package/src/Toast.tsx
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import React, { useState, useEffect } from "react";
|
|
2
|
+
import { View, Text, StyleSheet, Animated } from "react-native";
|
|
3
|
+
|
|
4
|
+
const Toast = ({
|
|
5
|
+
message,
|
|
6
|
+
visible,
|
|
7
|
+
duration = 3000,
|
|
8
|
+
}: {
|
|
9
|
+
message: any;
|
|
10
|
+
visible: boolean;
|
|
11
|
+
duration?: number;
|
|
12
|
+
}) => {
|
|
13
|
+
const [fadeAnim] = useState(new Animated.Value(0));
|
|
14
|
+
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
if (visible) {
|
|
17
|
+
// Fade in the toast
|
|
18
|
+
Animated.timing(fadeAnim, {
|
|
19
|
+
toValue: 1,
|
|
20
|
+
duration: 300,
|
|
21
|
+
useNativeDriver: true,
|
|
22
|
+
}).start(() => {
|
|
23
|
+
// Auto-hide after duration
|
|
24
|
+
setTimeout(() => {
|
|
25
|
+
Animated.timing(fadeAnim, {
|
|
26
|
+
toValue: 0,
|
|
27
|
+
duration: 300,
|
|
28
|
+
useNativeDriver: true,
|
|
29
|
+
}).start();
|
|
30
|
+
}, duration);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}, [visible]);
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<Animated.View
|
|
37
|
+
style={[
|
|
38
|
+
styles.toastContainer,
|
|
39
|
+
{ opacity: fadeAnim, display: visible ? "flex" : "none" },
|
|
40
|
+
]}
|
|
41
|
+
>
|
|
42
|
+
<Text style={styles.toastText}>{message}</Text>
|
|
43
|
+
</Animated.View>
|
|
44
|
+
);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const styles = StyleSheet.create({
|
|
48
|
+
toastContainer: {
|
|
49
|
+
position: "absolute",
|
|
50
|
+
bottom: 50,
|
|
51
|
+
left: "10%",
|
|
52
|
+
right: "10%",
|
|
53
|
+
backgroundColor: "rgba(0, 0, 0, 0.8)",
|
|
54
|
+
padding: 10,
|
|
55
|
+
borderRadius: 5,
|
|
56
|
+
alignItems: "center",
|
|
57
|
+
justifyContent: "center",
|
|
58
|
+
},
|
|
59
|
+
toastText: {
|
|
60
|
+
color: "#fff",
|
|
61
|
+
textAlign: "center",
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
export default Toast;
|
package/src/config.ts
ADDED
package/src/constants.ts
ADDED
package/src/global.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// declare module "react-native" {
|
|
2
|
+
// export const View: any;
|
|
3
|
+
// export const ActivityIndicator: any;
|
|
4
|
+
// export const Linking: any;
|
|
5
|
+
// // Add other React Native exports as needed
|
|
6
|
+
// }
|
|
7
|
+
|
|
8
|
+
declare module "*.json" {
|
|
9
|
+
const value: any;
|
|
10
|
+
export default value;
|
|
11
|
+
}
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Linking } from "react-native";
|
|
2
|
+
import { BASE_CHATBOT_URL } from "./constants";
|
|
3
|
+
|
|
4
|
+
export const openChatbot = (
|
|
5
|
+
chatbotId: string,
|
|
6
|
+
additionalParams: Record<string, string> = {}
|
|
7
|
+
): void => {
|
|
8
|
+
const params = new URLSearchParams({ id: chatbotId, ...additionalParams });
|
|
9
|
+
const url = `${BASE_CHATBOT_URL}?${params.toString()}`;
|
|
10
|
+
Linking.openURL(url);
|
|
11
|
+
};
|
|
File without changes
|