@robylon/react-native-sdk 2.0.2-staging.0 → 2.0.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.
- package/lib/commonjs/Chatbotsdk.js +1 -1
- package/lib/commonjs/Chatbotsdk.js.map +1 -1
- package/lib/commonjs/openChatbot.js +1 -1
- 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/openChatbot.js +1 -2
- package/lib/module/openChatbot.js.map +1 -1
- package/lib/typescript/Chatbotsdk.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/ChatbotWebview.tsx +0 -44
- package/src/Chatbotsdk.tsx +0 -378
- package/src/FloatingButton.tsx +0 -57
- package/src/LoadingIndicator.tsx +0 -11
- package/src/config.ts +0 -4
- package/src/constants.ts +0 -4
- package/src/global.d.ts +0 -6
- package/src/index.tsx +0 -2
- package/src/openChatbot.ts +0 -11
- 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 _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=_constants.API_URL+"/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
|
+
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=_constants.API_URL+"/users/auth/copilot/";var payload={client_user_id:user_id,org_id:api_key,token:user_token,extra_info:stableAdditionalParams};console.log("endpointUrl",endpointUrl,payload);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;
|
|
2
2
|
//# sourceMappingURL=Chatbotsdk.js.map
|
|
@@ -1 +1 @@
|
|
|
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","_useState","useState","_useState2","_slicedToArray2","isWebViewVisible","setIsWebViewVisible","_useState3","_useState4","chatbotConfig","setChatbotConfig","_useState5","_useState6","loading","setLoading","webViewRef","useRef","fadeAnim","Animated","Value","current","isFirstLoadRef","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","warn","getScreenDimensions","windowHeight","Dimensions","height","windowWidth","width","statusBarHeight","Platform","OS","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,O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view","_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","_useState","useState","_useState2","_slicedToArray2","isWebViewVisible","setIsWebViewVisible","_useState3","_useState4","chatbotConfig","setChatbotConfig","_useState5","_useState6","loading","setLoading","webViewRef","useRef","fadeAnim","Animated","Value","current","isFirstLoadRef","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","console","log","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","apply","arguments","params","URLSearchParams","assign","id","BASE_CHATBOT_URL","toString","openWebView","timing","toValue","duration","useNativeDriver","start","setTimeout","setValue","requestAnimationFrame","closeWebView","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","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,MAAAQ,CAAA,EAAAC,SAAA,OAAAC,CAAA,CAAAC,MAAA,CAAAC,cAAA,EAAAD,MAAA,CAAAE,wBAAA,SAAAC,CAAA,IAAAd,CAAA,gBAAAc,CAAA,KAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,CAAAc,CAAA,OAAAG,CAAA,CAAAP,CAAA,CAAAC,MAAA,CAAAE,wBAAA,CAAAb,CAAA,CAAAc,CAAA,OAAAG,CAAA,GAAAA,CAAA,CAAAV,GAAA,EAAAU,CAAA,CAAAC,GAAA,EAAAP,MAAA,CAAAC,cAAA,CAAA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,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,CAAAhM,OAAA,CAEYc,UAAU","ignoreList":[]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
2
|
//# sourceMappingURL=openChatbot.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["openChatbot.tsx"],"mappings":"","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 _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=_constants.API_URL+"/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
|
+
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=_constants.API_URL+"/users/auth/copilot/";var payload={client_user_id:user_id,org_id:api_key,token:user_token,extra_info:stableAdditionalParams};console.log("endpointUrl",endpointUrl,payload);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;
|
|
2
2
|
//# sourceMappingURL=Chatbotsdk.js.map
|
|
@@ -1 +1 @@
|
|
|
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","_useState","useState","_useState2","_slicedToArray2","isWebViewVisible","setIsWebViewVisible","_useState3","_useState4","chatbotConfig","setChatbotConfig","_useState5","_useState6","loading","setLoading","webViewRef","useRef","fadeAnim","Animated","Value","current","isFirstLoadRef","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","warn","getScreenDimensions","windowHeight","Dimensions","height","windowWidth","width","statusBarHeight","Platform","OS","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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|
+
{"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","_useState","useState","_useState2","_slicedToArray2","isWebViewVisible","setIsWebViewVisible","_useState3","_useState4","chatbotConfig","setChatbotConfig","_useState5","_useState6","loading","setLoading","webViewRef","useRef","fadeAnim","Animated","Value","current","isFirstLoadRef","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","console","log","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","apply","arguments","params","URLSearchParams","assign","id","BASE_CHATBOT_URL","toString","openWebView","timing","toValue","duration","useNativeDriver","start","setTimeout","setValue","requestAnimationFrame","closeWebView","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","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,MAAAQ,CAAA,EAAAC,SAAA,OAAAC,CAAA,CAAAC,MAAA,CAAAC,cAAA,EAAAD,MAAA,CAAAE,wBAAA,SAAAC,CAAA,IAAAd,CAAA,gBAAAc,CAAA,KAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,CAAAc,CAAA,OAAAG,CAAA,CAAAP,CAAA,CAAAC,MAAA,CAAAE,wBAAA,CAAAb,CAAA,CAAAc,CAAA,OAAAG,CAAA,GAAAA,CAAA,CAAAV,GAAA,EAAA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M,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,CAAAhM,OAAA,CAEYc,UAAU","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":[]}
|
|
@@ -1 +1 @@
|
|
|
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;CACtB;AAaD,QAAA,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,
|
|
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;CACtB;AAaD,QAAA,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAkTzC,CAAC;AAmCF,eAAe,UAAU,CAAC"}
|
package/package.json
CHANGED
package/src/ChatbotWebview.tsx
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
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
|
-
};
|
package/src/Chatbotsdk.tsx
DELETED
|
@@ -1,378 +0,0 @@
|
|
|
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
|
-
}
|
|
26
|
-
|
|
27
|
-
interface ChatbotMessage {
|
|
28
|
-
type: string;
|
|
29
|
-
data?: any;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
interface ChatbotConfig {
|
|
33
|
-
brand_color: string;
|
|
34
|
-
image_url: string;
|
|
35
|
-
welcome_message: string;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const ChatbotSDK: React.FC<ChatbotSDKProps> = ({
|
|
39
|
-
api_key,
|
|
40
|
-
user_id,
|
|
41
|
-
user_token,
|
|
42
|
-
additional_params = {},
|
|
43
|
-
show_floating_button = true,
|
|
44
|
-
onMessage,
|
|
45
|
-
isFullScreen = true,
|
|
46
|
-
enableAnimation = true,
|
|
47
|
-
onOpen,
|
|
48
|
-
onClose,
|
|
49
|
-
}) => {
|
|
50
|
-
const [isWebViewVisible, setIsWebViewVisible] = useState(false);
|
|
51
|
-
const [chatbotConfig, setChatbotConfig] = useState<ChatbotConfig | null>(
|
|
52
|
-
null
|
|
53
|
-
);
|
|
54
|
-
const [loading, setLoading] = useState(true);
|
|
55
|
-
const webViewRef = useRef<WebView>(null);
|
|
56
|
-
const fadeAnim = useRef(new Animated.Value(0)).current;
|
|
57
|
-
const isFirstLoadRef = useRef(true);
|
|
58
|
-
const webViewUrl = useMemo(
|
|
59
|
-
() => constructUrl(),
|
|
60
|
-
[api_key, user_id, additional_params]
|
|
61
|
-
);
|
|
62
|
-
|
|
63
|
-
const stableAdditionalParams = useMemo(
|
|
64
|
-
() => additional_params,
|
|
65
|
-
[JSON.stringify(additional_params)]
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
const triggerAppInit = () => {
|
|
69
|
-
if (webViewRef.current) {
|
|
70
|
-
webViewRef.current.injectJavaScript(`
|
|
71
|
-
// Trigger APP_READY equivalent
|
|
72
|
-
window.ReactNativeWebView.postMessage(JSON.stringify({ type: 'APP_READY' }));
|
|
73
|
-
true;
|
|
74
|
-
`);
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
useEffect(() => {
|
|
79
|
-
const fetchChatbotConfig = async () => {
|
|
80
|
-
try {
|
|
81
|
-
const endpointUrl = `${API_URL}/users/auth/copilot/`;
|
|
82
|
-
const payload = {
|
|
83
|
-
client_user_id: user_id,
|
|
84
|
-
org_id: api_key,
|
|
85
|
-
token: user_token,
|
|
86
|
-
extra_info: stableAdditionalParams,
|
|
87
|
-
};
|
|
88
|
-
const response = await fetch(endpointUrl, {
|
|
89
|
-
method: "POST",
|
|
90
|
-
headers: {
|
|
91
|
-
"Content-Type": "application/json",
|
|
92
|
-
},
|
|
93
|
-
body: JSON.stringify(payload),
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
if (!response.ok) {
|
|
97
|
-
throw new Error("Failed to fetch chatbot configuration");
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
const data = await response.json();
|
|
101
|
-
const orgInfo = data?.user?.org_info;
|
|
102
|
-
|
|
103
|
-
if (orgInfo) {
|
|
104
|
-
setChatbotConfig({
|
|
105
|
-
brand_color: orgInfo?.config?.brand_colour || "#007AFF",
|
|
106
|
-
image_url: orgInfo?.brand_config?.launcher_logo_url || "",
|
|
107
|
-
welcome_message: orgInfo?.config?.welcome_message || "",
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
} catch (error) {
|
|
111
|
-
console.error("Error fetching chatbot configuration:", error);
|
|
112
|
-
} finally {
|
|
113
|
-
setLoading(false);
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
if (api_key && user_id) {
|
|
118
|
-
fetchChatbotConfig();
|
|
119
|
-
}
|
|
120
|
-
}, [api_key, user_id, user_token, stableAdditionalParams]);
|
|
121
|
-
|
|
122
|
-
function constructUrl(): string {
|
|
123
|
-
if (!user_id) return "";
|
|
124
|
-
const params = new URLSearchParams({
|
|
125
|
-
id: api_key,
|
|
126
|
-
user_id,
|
|
127
|
-
...additional_params,
|
|
128
|
-
});
|
|
129
|
-
return `${BASE_CHATBOT_URL}?${params.toString()}`;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
const openWebView = () => {
|
|
133
|
-
setIsWebViewVisible(true);
|
|
134
|
-
if (enableAnimation) {
|
|
135
|
-
Animated.timing(fadeAnim, {
|
|
136
|
-
toValue: 1,
|
|
137
|
-
duration: 250,
|
|
138
|
-
useNativeDriver: true,
|
|
139
|
-
}).start(() => {
|
|
140
|
-
onOpen?.();
|
|
141
|
-
if (!isFirstLoadRef.current) {
|
|
142
|
-
// If not first load, manually trigger initialization
|
|
143
|
-
setTimeout(triggerAppInit, 100);
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
} else {
|
|
147
|
-
fadeAnim.setValue(1);
|
|
148
|
-
requestAnimationFrame(() => {
|
|
149
|
-
onOpen?.();
|
|
150
|
-
if (!isFirstLoadRef.current) {
|
|
151
|
-
setTimeout(triggerAppInit, 100);
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
const closeWebView = () => {
|
|
158
|
-
if (webViewRef.current) {
|
|
159
|
-
console.log("closeWebView");
|
|
160
|
-
webViewRef.current.postMessage(
|
|
161
|
-
JSON.stringify({
|
|
162
|
-
name: "closeFrame",
|
|
163
|
-
domain: "app-domain.com",
|
|
164
|
-
})
|
|
165
|
-
);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
const complete = () => {
|
|
169
|
-
setIsWebViewVisible(false);
|
|
170
|
-
onClose?.();
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
if (enableAnimation) {
|
|
174
|
-
Animated.timing(fadeAnim, {
|
|
175
|
-
toValue: 0,
|
|
176
|
-
duration: 200,
|
|
177
|
-
useNativeDriver: true,
|
|
178
|
-
}).start(complete);
|
|
179
|
-
} else {
|
|
180
|
-
fadeAnim.setValue(0);
|
|
181
|
-
requestAnimationFrame(complete);
|
|
182
|
-
}
|
|
183
|
-
};
|
|
184
|
-
|
|
185
|
-
const handleMessage = (event: WebViewMessageEvent) => {
|
|
186
|
-
const { data } = event.nativeEvent;
|
|
187
|
-
|
|
188
|
-
try {
|
|
189
|
-
const parsedData: ChatbotMessage = JSON.parse(data);
|
|
190
|
-
|
|
191
|
-
if (parsedData.type === "APP_READY") {
|
|
192
|
-
console.log("APP_READY", webViewRef.current && isWebViewVisible);
|
|
193
|
-
if (webViewRef.current && isWebViewVisible) {
|
|
194
|
-
webViewRef.current.injectJavaScript(`
|
|
195
|
-
window.postMessage(${JSON.stringify({
|
|
196
|
-
name: "openFrame",
|
|
197
|
-
domain: "app-domain.com",
|
|
198
|
-
})}, '*');
|
|
199
|
-
window.postMessage(${JSON.stringify({
|
|
200
|
-
name: "registerUserId",
|
|
201
|
-
action: "registerUserId",
|
|
202
|
-
domain: "app-domain.com",
|
|
203
|
-
data: {
|
|
204
|
-
userId: `${user_id}`,
|
|
205
|
-
token: `${user_token}`,
|
|
206
|
-
},
|
|
207
|
-
})}, '*');
|
|
208
|
-
`);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
if (typeof parsedData !== "object" || !parsedData.type) {
|
|
213
|
-
console.warn("Invalid message structure");
|
|
214
|
-
return;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
switch (parsedData.type) {
|
|
218
|
-
case "close_chatbot":
|
|
219
|
-
closeWebView();
|
|
220
|
-
break;
|
|
221
|
-
default:
|
|
222
|
-
if (onMessage) onMessage(parsedData);
|
|
223
|
-
}
|
|
224
|
-
} catch (error) {
|
|
225
|
-
console.error("Failed to parse or process WebView message:", error);
|
|
226
|
-
}
|
|
227
|
-
};
|
|
228
|
-
|
|
229
|
-
const getScreenDimensions = () => {
|
|
230
|
-
const windowHeight = Dimensions.get("window").height;
|
|
231
|
-
const windowWidth = Dimensions.get("window").width;
|
|
232
|
-
const statusBarHeight =
|
|
233
|
-
Platform.OS === "ios" ? 0 : StatusBar.currentHeight || 0;
|
|
234
|
-
|
|
235
|
-
return {
|
|
236
|
-
height: windowHeight - statusBarHeight,
|
|
237
|
-
width: windowWidth,
|
|
238
|
-
};
|
|
239
|
-
};
|
|
240
|
-
|
|
241
|
-
const screenDimensions = getScreenDimensions();
|
|
242
|
-
|
|
243
|
-
return (
|
|
244
|
-
<View style={styles.mainContainer}>
|
|
245
|
-
{!loading && (
|
|
246
|
-
<>
|
|
247
|
-
{show_floating_button && api_key && chatbotConfig && (
|
|
248
|
-
<FloatingButton
|
|
249
|
-
onPress={openWebView}
|
|
250
|
-
brandColor={chatbotConfig.brand_color}
|
|
251
|
-
imageUrl={chatbotConfig.image_url}
|
|
252
|
-
/>
|
|
253
|
-
)}
|
|
254
|
-
<View
|
|
255
|
-
style={[
|
|
256
|
-
styles.webViewWrapper,
|
|
257
|
-
{ height: isWebViewVisible ? "100%" : 0 },
|
|
258
|
-
]}
|
|
259
|
-
pointerEvents={isWebViewVisible ? "auto" : "none"}
|
|
260
|
-
>
|
|
261
|
-
<Animated.View
|
|
262
|
-
style={[
|
|
263
|
-
isFullScreen
|
|
264
|
-
? styles.fullScreenContainer
|
|
265
|
-
: styles.inlineContainer,
|
|
266
|
-
{ opacity: fadeAnim },
|
|
267
|
-
]}
|
|
268
|
-
>
|
|
269
|
-
<WebView
|
|
270
|
-
ref={webViewRef}
|
|
271
|
-
source={{ uri: webViewUrl }}
|
|
272
|
-
onMessage={handleMessage}
|
|
273
|
-
style={styles.webview}
|
|
274
|
-
containerStyle={
|
|
275
|
-
isFullScreen
|
|
276
|
-
? {
|
|
277
|
-
width: screenDimensions.width,
|
|
278
|
-
height: screenDimensions.height,
|
|
279
|
-
}
|
|
280
|
-
: undefined
|
|
281
|
-
}
|
|
282
|
-
allowsInlineMediaPlayback={true}
|
|
283
|
-
mediaPlaybackRequiresUserAction={false}
|
|
284
|
-
allowFileAccess={false}
|
|
285
|
-
geolocationEnabled={false}
|
|
286
|
-
javaScriptEnabled={true}
|
|
287
|
-
domStorageEnabled={true}
|
|
288
|
-
cacheEnabled={true}
|
|
289
|
-
scrollEnabled={true}
|
|
290
|
-
bounces={false}
|
|
291
|
-
onShouldStartLoadWithRequest={(request) => {
|
|
292
|
-
return request.url.startsWith(BASE_CHATBOT_URL);
|
|
293
|
-
}}
|
|
294
|
-
startInLoadingState={isFirstLoadRef.current}
|
|
295
|
-
onLoadEnd={() => {
|
|
296
|
-
webViewRef.current?.injectJavaScript(`
|
|
297
|
-
if (!document.querySelector('meta[name="viewport"]')) {
|
|
298
|
-
var meta = document.createElement('meta');
|
|
299
|
-
meta.name = 'viewport';
|
|
300
|
-
meta.content = 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no';
|
|
301
|
-
document.getElementsByTagName('head')[0].appendChild(meta);
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
if (!document.querySelector('#injectedStyle')) {
|
|
305
|
-
const style = document.createElement('style');
|
|
306
|
-
style.id = 'injectedStyle';
|
|
307
|
-
style.textContent = \`
|
|
308
|
-
html, body, #root, #__next {
|
|
309
|
-
height: 100% !important;
|
|
310
|
-
min-height: 100% !important;
|
|
311
|
-
overflow: hidden !important;
|
|
312
|
-
}
|
|
313
|
-
\`;
|
|
314
|
-
document.head.appendChild(style);
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
window.sendToChatbot = function(message) {
|
|
318
|
-
window.ReactNativeWebView.postMessage(JSON.stringify(message));
|
|
319
|
-
};
|
|
320
|
-
|
|
321
|
-
var closeButton = document.querySelector('.chatbot-close-button');
|
|
322
|
-
if (closeButton) {
|
|
323
|
-
closeButton.addEventListener('click', () => {
|
|
324
|
-
window.sendToChatbot({ type: 'close_chatbot' });
|
|
325
|
-
});
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
true;
|
|
329
|
-
`);
|
|
330
|
-
isFirstLoadRef.current = false;
|
|
331
|
-
}}
|
|
332
|
-
onError={(syntheticEvent) => {
|
|
333
|
-
const { nativeEvent } = syntheticEvent;
|
|
334
|
-
console.warn("WebView error:", nativeEvent);
|
|
335
|
-
}}
|
|
336
|
-
/>
|
|
337
|
-
</Animated.View>
|
|
338
|
-
</View>
|
|
339
|
-
</>
|
|
340
|
-
)}
|
|
341
|
-
</View>
|
|
342
|
-
);
|
|
343
|
-
};
|
|
344
|
-
|
|
345
|
-
const styles = StyleSheet.create({
|
|
346
|
-
mainContainer: {
|
|
347
|
-
flex: 1,
|
|
348
|
-
position: "relative",
|
|
349
|
-
},
|
|
350
|
-
webViewWrapper: {
|
|
351
|
-
position: "absolute",
|
|
352
|
-
top: 0,
|
|
353
|
-
left: 0,
|
|
354
|
-
right: 0,
|
|
355
|
-
bottom: 0,
|
|
356
|
-
overflow: "hidden",
|
|
357
|
-
zIndex: 1000,
|
|
358
|
-
},
|
|
359
|
-
fullScreenContainer: {
|
|
360
|
-
position: "absolute",
|
|
361
|
-
top: 0,
|
|
362
|
-
left: 0,
|
|
363
|
-
right: 0,
|
|
364
|
-
bottom: 0,
|
|
365
|
-
backgroundColor: "white",
|
|
366
|
-
zIndex: 1000,
|
|
367
|
-
},
|
|
368
|
-
inlineContainer: {
|
|
369
|
-
flex: 1,
|
|
370
|
-
backgroundColor: "white",
|
|
371
|
-
},
|
|
372
|
-
webview: {
|
|
373
|
-
flex: 1,
|
|
374
|
-
backgroundColor: "white",
|
|
375
|
-
},
|
|
376
|
-
});
|
|
377
|
-
|
|
378
|
-
export default ChatbotSDK;
|
package/src/FloatingButton.tsx
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
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;
|
package/src/LoadingIndicator.tsx
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
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/config.ts
DELETED
package/src/constants.ts
DELETED
package/src/global.d.ts
DELETED
package/src/index.tsx
DELETED
package/src/openChatbot.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
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
|
-
};
|
package/src/openChatbot.tsx
DELETED
|
File without changes
|