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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/.npmignore.production +0 -1
  2. package/.npmignore.staging +0 -1
  3. package/README.md +0 -185
  4. package/babel.config.js +3 -16
  5. package/lib/commonjs/ChatbotWebview.js +44 -1
  6. package/lib/commonjs/ChatbotWebview.js.map +1 -1
  7. package/lib/commonjs/Chatbotsdk.js +309 -1
  8. package/lib/commonjs/Chatbotsdk.js.map +1 -1
  9. package/lib/commonjs/FloatingButton.js +60 -1
  10. package/lib/commonjs/FloatingButton.js.map +1 -1
  11. package/lib/commonjs/LoadingIndicator.js +20 -1
  12. package/lib/commonjs/LoadingIndicator.js.map +1 -1
  13. package/lib/commonjs/config.js +10 -1
  14. package/lib/commonjs/config.js.map +1 -1
  15. package/lib/commonjs/constants.js +9 -1
  16. package/lib/commonjs/constants.js.map +1 -1
  17. package/lib/commonjs/global.d.js +7 -1
  18. package/lib/commonjs/global.d.js.map +1 -1
  19. package/lib/commonjs/index.js +20 -1
  20. package/lib/commonjs/index.js.map +1 -1
  21. package/lib/commonjs/openChatbot.js +16 -1
  22. package/lib/commonjs/openChatbot.js.map +1 -1
  23. package/lib/module/ChatbotWebview.js +33 -1
  24. package/lib/module/ChatbotWebview.js.map +1 -1
  25. package/lib/module/Chatbotsdk.js +300 -1
  26. package/lib/module/Chatbotsdk.js.map +1 -1
  27. package/lib/module/FloatingButton.js +53 -1
  28. package/lib/module/FloatingButton.js.map +1 -1
  29. package/lib/module/LoadingIndicator.js +13 -1
  30. package/lib/module/LoadingIndicator.js.map +1 -1
  31. package/lib/module/config.js +4 -1
  32. package/lib/module/config.js.map +1 -1
  33. package/lib/module/constants.js +3 -1
  34. package/lib/module/constants.js.map +1 -1
  35. package/lib/module/global.d.js +6 -1
  36. package/lib/module/global.d.js.map +1 -1
  37. package/lib/module/index.js +2 -1
  38. package/lib/module/index.js.map +1 -1
  39. package/lib/module/openChatbot.js +9 -1
  40. package/package.json +13 -20
  41. package/src/FloatingButton.tsx +6 -6
@@ -1,2 +1,301 @@
1
- var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _reactNativeWebview=require("react-native-webview");var _FloatingButton=_interopRequireDefault(require("./FloatingButton"));var _constants=require("./constants");var _jsxRuntime=require("react/jsx-runtime");var _this=this,_jsxFileName="/Users/jobinabraham/Developer/personal/robylon-react-native-sdk/src/Chatbotsdk.tsx";function _getRequireWildcardCache(e){if("function"!=typeof WeakMap)return null;var r=new WeakMap(),t=new WeakMap();return(_getRequireWildcardCache=function _getRequireWildcardCache(e){return e?t:r;})(e);}function _interopRequireWildcard(e,r){if(!r&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache(r);if(t&&t.has(e))return t.get(e);var n={__proto__:null},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var u in e)if("default"!==u&&{}.hasOwnProperty.call(e,u)){var i=a?Object.getOwnPropertyDescriptor(e,u):null;i&&(i.get||i.set)?Object.defineProperty(n,u,i):n[u]=e[u];}return n.default=e,t&&t.set(e,n),n;}var ChatbotSDK=function ChatbotSDK(_ref){var api_key=_ref.api_key,user_id=_ref.user_id,user_token=_ref.user_token,_ref$additional_param=_ref.additional_params,additional_params=_ref$additional_param===void 0?{}:_ref$additional_param,_ref$show_floating_bu=_ref.show_floating_button,show_floating_button=_ref$show_floating_bu===void 0?true:_ref$show_floating_bu,onMessage=_ref.onMessage,_ref$isFullScreen=_ref.isFullScreen,isFullScreen=_ref$isFullScreen===void 0?true:_ref$isFullScreen,_ref$enableAnimation=_ref.enableAnimation,enableAnimation=_ref$enableAnimation===void 0?true:_ref$enableAnimation,onOpen=_ref.onOpen,onClose=_ref.onClose;var _useState=(0,_react.useState)(false),_useState2=(0,_slicedToArray2.default)(_useState,2),isWebViewVisible=_useState2[0],setIsWebViewVisible=_useState2[1];var _useState3=(0,_react.useState)(null),_useState4=(0,_slicedToArray2.default)(_useState3,2),chatbotConfig=_useState4[0],setChatbotConfig=_useState4[1];var _useState5=(0,_react.useState)(true),_useState6=(0,_slicedToArray2.default)(_useState5,2),loading=_useState6[0],setLoading=_useState6[1];var webViewRef=(0,_react.useRef)(null);var fadeAnim=(0,_react.useRef)(new _reactNative.Animated.Value(0)).current;var isFirstLoadRef=(0,_react.useRef)(true);var webViewUrl=(0,_react.useMemo)(function(){return constructUrl();},[api_key,user_id,additional_params]);var stableAdditionalParams=(0,_react.useMemo)(function(){return additional_params;},[JSON.stringify(additional_params)]);var triggerAppInit=function triggerAppInit(){if(webViewRef.current){webViewRef.current.injectJavaScript("\n // Trigger APP_READY equivalent\n window.ReactNativeWebView.postMessage(JSON.stringify({ type: 'APP_READY' }));\n true;\n ");}};(0,_react.useEffect)(function(){var fetchChatbotConfig=function(){var _ref2=(0,_asyncToGenerator2.default)(function*(){try{var _data$user;var endpointUrl="https://stage-api.robylon.ai/users/auth/copilot/";var payload={client_user_id:user_id,org_id:api_key,token:user_token,extra_info:stableAdditionalParams};var response=yield fetch(endpointUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(payload)});if(!response.ok){throw new Error("Failed to fetch chatbot configuration");}var data=yield response.json();var orgInfo=data==null?void 0:(_data$user=data.user)==null?void 0:_data$user.org_info;if(orgInfo){var _orgInfo$config,_orgInfo$brand_config,_orgInfo$config2;setChatbotConfig({brand_color:(orgInfo==null?void 0:(_orgInfo$config=orgInfo.config)==null?void 0:_orgInfo$config.brand_colour)||"#007AFF",image_url:(orgInfo==null?void 0:(_orgInfo$brand_config=orgInfo.brand_config)==null?void 0:_orgInfo$brand_config.launcher_logo_url)||"",welcome_message:(orgInfo==null?void 0:(_orgInfo$config2=orgInfo.config)==null?void 0:_orgInfo$config2.welcome_message)||""});}}catch(error){console.error("Error fetching chatbot configuration:",error);}finally{setLoading(false);}});return function fetchChatbotConfig(){return _ref2.apply(this,arguments);};}();if(api_key&&user_id){fetchChatbotConfig();}},[api_key,user_id,user_token,stableAdditionalParams]);function constructUrl(){if(!user_id)return"";var params=new URLSearchParams(Object.assign({id:api_key,user_id:user_id},additional_params));return _constants.BASE_CHATBOT_URL+"?"+params.toString();}var openWebView=function openWebView(){setIsWebViewVisible(true);if(enableAnimation){_reactNative.Animated.timing(fadeAnim,{toValue:1,duration:250,useNativeDriver:true}).start(function(){onOpen==null?void 0:onOpen();if(!isFirstLoadRef.current){setTimeout(triggerAppInit,100);}});}else{fadeAnim.setValue(1);requestAnimationFrame(function(){onOpen==null?void 0:onOpen();if(!isFirstLoadRef.current){setTimeout(triggerAppInit,100);}});}};var closeWebView=function closeWebView(){if(webViewRef.current){console.log("closeWebView");webViewRef.current.postMessage(JSON.stringify({name:"closeFrame",domain:"app-domain.com"}));}var complete=function complete(){setIsWebViewVisible(false);onClose==null?void 0:onClose();};if(enableAnimation){_reactNative.Animated.timing(fadeAnim,{toValue:0,duration:200,useNativeDriver:true}).start(complete);}else{fadeAnim.setValue(0);requestAnimationFrame(complete);}};var handleMessage=function handleMessage(event){var data=event.nativeEvent.data;try{var parsedData=JSON.parse(data);if(parsedData.type==="APP_READY"){console.log("APP_READY",webViewRef.current&&isWebViewVisible);if(webViewRef.current&&isWebViewVisible){webViewRef.current.injectJavaScript("\n window.postMessage("+JSON.stringify({name:"openFrame",domain:"app-domain.com"})+", '*');\n window.postMessage("+JSON.stringify({name:"registerUserId",action:"registerUserId",domain:"app-domain.com",data:{userId:""+user_id,token:""+user_token}})+", '*');\n ");}}if(typeof parsedData!=="object"||!parsedData.type){console.warn("Invalid message structure");return;}switch(parsedData.type){case"close_chatbot":closeWebView();break;default:if(onMessage)onMessage(parsedData);}}catch(error){console.error("Failed to parse or process WebView message:",error);}};var getScreenDimensions=function getScreenDimensions(){var windowHeight=_reactNative.Dimensions.get("window").height;var windowWidth=_reactNative.Dimensions.get("window").width;var statusBarHeight=_reactNative.Platform.OS==="ios"?0:_reactNative.StatusBar.currentHeight||0;return{height:windowHeight-statusBarHeight,width:windowWidth};};var screenDimensions=getScreenDimensions();return(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.mainContainer,children:!loading&&(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[show_floating_button&&api_key&&chatbotConfig&&(0,_jsxRuntime.jsx)(_FloatingButton.default,{onPress:openWebView,brandColor:chatbotConfig.brand_color,imageUrl:chatbotConfig.image_url}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.webViewWrapper,{height:isWebViewVisible?"100%":0}],pointerEvents:isWebViewVisible?"auto":"none",children:(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[isFullScreen?styles.fullScreenContainer:styles.inlineContainer,{opacity:fadeAnim}],children:(0,_jsxRuntime.jsx)(_reactNativeWebview.WebView,{ref:webViewRef,source:{uri:webViewUrl},onMessage:handleMessage,style:styles.webview,containerStyle:isFullScreen?{width:screenDimensions.width,height:screenDimensions.height}:undefined,allowsInlineMediaPlayback:true,mediaPlaybackRequiresUserAction:false,allowFileAccess:false,geolocationEnabled:false,javaScriptEnabled:true,domStorageEnabled:true,cacheEnabled:true,scrollEnabled:true,bounces:false,onShouldStartLoadWithRequest:function onShouldStartLoadWithRequest(request){return request.url.startsWith(_constants.BASE_CHATBOT_URL);},startInLoadingState:isFirstLoadRef.current,onLoadEnd:function onLoadEnd(){var _webViewRef$current;(_webViewRef$current=webViewRef.current)==null?void 0:_webViewRef$current.injectJavaScript("\n if (!document.querySelector('meta[name=\"viewport\"]')) {\n var meta = document.createElement('meta');\n meta.name = 'viewport';\n meta.content = 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no';\n document.getElementsByTagName('head')[0].appendChild(meta);\n }\n\n if (!document.querySelector('#injectedStyle')) {\n const style = document.createElement('style');\n style.id = 'injectedStyle';\n style.textContent = `\n html, body, #root, #__next {\n height: 100% !important;\n min-height: 100% !important;\n overflow: hidden !important;\n }\n `;\n document.head.appendChild(style);\n }\n\n window.sendToChatbot = function(message) {\n window.ReactNativeWebView.postMessage(JSON.stringify(message));\n };\n\n var closeButton = document.querySelector('.chatbot-close-button');\n if (closeButton) {\n closeButton.addEventListener('click', () => {\n window.sendToChatbot({ type: 'close_chatbot' });\n });\n }\n \n true;\n");isFirstLoadRef.current=false;},onError:function onError(syntheticEvent){var nativeEvent=syntheticEvent.nativeEvent;console.warn("WebView error:",nativeEvent);}})})})]})});};var styles=_reactNative.StyleSheet.create({mainContainer:{flex:1,position:"relative"},webViewWrapper:{position:"absolute",top:0,left:0,right:0,bottom:0,overflow:"hidden",zIndex:1000},fullScreenContainer:{position:"absolute",top:0,left:0,right:0,bottom:0,backgroundColor:"white",zIndex:1000},inlineContainer:{flex:1,backgroundColor:"white"},webview:{flex:1,backgroundColor:"white"}});var _default=exports.default=ChatbotSDK;
1
+ import React, { useState, useEffect, useRef, useMemo } from "react";
2
+ import { View, StyleSheet, Animated, Dimensions, Platform, StatusBar } from "react-native";
3
+ import { WebView } from "react-native-webview";
4
+ import FloatingButton from "./FloatingButton";
5
+ import { BASE_CHATBOT_URL } from "./constants";
6
+ const ChatbotSDK = ({
7
+ api_key,
8
+ user_id,
9
+ user_token,
10
+ additional_params = {},
11
+ show_floating_button = true,
12
+ onMessage,
13
+ isFullScreen = true,
14
+ enableAnimation = true,
15
+ onOpen,
16
+ onClose
17
+ }) => {
18
+ const [isWebViewVisible, setIsWebViewVisible] = useState(false);
19
+ const [chatbotConfig, setChatbotConfig] = useState(null);
20
+ const [loading, setLoading] = useState(true);
21
+ const webViewRef = useRef(null);
22
+ const fadeAnim = useRef(new Animated.Value(0)).current;
23
+ const isFirstLoadRef = useRef(true);
24
+ const webViewUrl = useMemo(() => constructUrl(), [api_key, user_id, additional_params]);
25
+ const stableAdditionalParams = useMemo(() => additional_params, [JSON.stringify(additional_params)]);
26
+ const triggerAppInit = () => {
27
+ if (webViewRef.current) {
28
+ webViewRef.current.injectJavaScript(`
29
+ // Trigger APP_READY equivalent
30
+ window.ReactNativeWebView.postMessage(JSON.stringify({ type: 'APP_READY' }));
31
+ true;
32
+ `);
33
+ }
34
+ };
35
+ useEffect(() => {
36
+ const fetchChatbotConfig = async () => {
37
+ try {
38
+ var _data$user;
39
+ const endpointUrl = `https://stage-api.robylon.ai/users/auth/copilot/`;
40
+ const payload = {
41
+ client_user_id: user_id,
42
+ org_id: api_key,
43
+ token: user_token,
44
+ extra_info: stableAdditionalParams
45
+ };
46
+ const response = await fetch(endpointUrl, {
47
+ method: "POST",
48
+ headers: {
49
+ "Content-Type": "application/json"
50
+ },
51
+ body: JSON.stringify(payload)
52
+ });
53
+ if (!response.ok) {
54
+ throw new Error("Failed to fetch chatbot configuration");
55
+ }
56
+ const data = await response.json();
57
+ const orgInfo = data === null || data === void 0 || (_data$user = data.user) === null || _data$user === void 0 ? void 0 : _data$user.org_info;
58
+ if (orgInfo) {
59
+ var _orgInfo$config, _orgInfo$brand_config, _orgInfo$config2;
60
+ setChatbotConfig({
61
+ brand_color: (orgInfo === null || orgInfo === void 0 || (_orgInfo$config = orgInfo.config) === null || _orgInfo$config === void 0 ? void 0 : _orgInfo$config.brand_colour) || "#007AFF",
62
+ image_url: (orgInfo === null || orgInfo === void 0 || (_orgInfo$brand_config = orgInfo.brand_config) === null || _orgInfo$brand_config === void 0 ? void 0 : _orgInfo$brand_config.launcher_logo_url) || "",
63
+ welcome_message: (orgInfo === null || orgInfo === void 0 || (_orgInfo$config2 = orgInfo.config) === null || _orgInfo$config2 === void 0 ? void 0 : _orgInfo$config2.welcome_message) || ""
64
+ });
65
+ }
66
+ } catch (error) {
67
+ console.error("Error fetching chatbot configuration:", error);
68
+ } finally {
69
+ setLoading(false);
70
+ }
71
+ };
72
+ if (api_key && user_id) {
73
+ fetchChatbotConfig();
74
+ }
75
+ }, [api_key, user_id, user_token, stableAdditionalParams]);
76
+ function constructUrl() {
77
+ if (!user_id) return "";
78
+ const params = new URLSearchParams({
79
+ id: api_key,
80
+ user_id,
81
+ ...additional_params
82
+ });
83
+ return `${BASE_CHATBOT_URL}?${params.toString()}`;
84
+ }
85
+ const openWebView = () => {
86
+ setIsWebViewVisible(true);
87
+ if (enableAnimation) {
88
+ Animated.timing(fadeAnim, {
89
+ toValue: 1,
90
+ duration: 250,
91
+ useNativeDriver: true
92
+ }).start(() => {
93
+ onOpen === null || onOpen === void 0 || onOpen();
94
+ if (!isFirstLoadRef.current) {
95
+ // If not first load, manually trigger initialization
96
+ setTimeout(triggerAppInit, 100);
97
+ }
98
+ });
99
+ } else {
100
+ fadeAnim.setValue(1);
101
+ requestAnimationFrame(() => {
102
+ onOpen === null || onOpen === void 0 || onOpen();
103
+ if (!isFirstLoadRef.current) {
104
+ setTimeout(triggerAppInit, 100);
105
+ }
106
+ });
107
+ }
108
+ };
109
+ const closeWebView = () => {
110
+ if (webViewRef.current) {
111
+ console.log("closeWebView");
112
+ webViewRef.current.postMessage(JSON.stringify({
113
+ name: "closeFrame",
114
+ domain: "app-domain.com"
115
+ }));
116
+ }
117
+ const complete = () => {
118
+ setIsWebViewVisible(false);
119
+ onClose === null || onClose === void 0 || onClose();
120
+ };
121
+ if (enableAnimation) {
122
+ Animated.timing(fadeAnim, {
123
+ toValue: 0,
124
+ duration: 200,
125
+ useNativeDriver: true
126
+ }).start(complete);
127
+ } else {
128
+ fadeAnim.setValue(0);
129
+ requestAnimationFrame(complete);
130
+ }
131
+ };
132
+ const handleMessage = event => {
133
+ const {
134
+ data
135
+ } = event.nativeEvent;
136
+ try {
137
+ const parsedData = JSON.parse(data);
138
+ if (parsedData.type === "APP_READY") {
139
+ console.log("APP_READY", webViewRef.current && isWebViewVisible);
140
+ if (webViewRef.current && isWebViewVisible) {
141
+ webViewRef.current.injectJavaScript(`
142
+ window.postMessage(${JSON.stringify({
143
+ name: "openFrame",
144
+ domain: "app-domain.com"
145
+ })}, '*');
146
+ window.postMessage(${JSON.stringify({
147
+ name: "registerUserId",
148
+ action: "registerUserId",
149
+ domain: "app-domain.com",
150
+ data: {
151
+ userId: `${user_id}`,
152
+ token: `${user_token}`
153
+ }
154
+ })}, '*');
155
+ `);
156
+ }
157
+ }
158
+ if (typeof parsedData !== "object" || !parsedData.type) {
159
+ console.warn("Invalid message structure");
160
+ return;
161
+ }
162
+ switch (parsedData.type) {
163
+ case "close_chatbot":
164
+ closeWebView();
165
+ break;
166
+ default:
167
+ if (onMessage) onMessage(parsedData);
168
+ }
169
+ } catch (error) {
170
+ console.error("Failed to parse or process WebView message:", error);
171
+ }
172
+ };
173
+ const getScreenDimensions = () => {
174
+ const windowHeight = Dimensions.get("window").height;
175
+ const windowWidth = Dimensions.get("window").width;
176
+ const statusBarHeight = Platform.OS === "ios" ? 0 : StatusBar.currentHeight || 0;
177
+ return {
178
+ height: windowHeight - statusBarHeight,
179
+ width: windowWidth
180
+ };
181
+ };
182
+ const screenDimensions = getScreenDimensions();
183
+ return /*#__PURE__*/React.createElement(View, {
184
+ style: styles.mainContainer
185
+ }, !loading && /*#__PURE__*/React.createElement(React.Fragment, null, show_floating_button && api_key && chatbotConfig && /*#__PURE__*/React.createElement(FloatingButton, {
186
+ onPress: openWebView,
187
+ brandColor: chatbotConfig.brand_color,
188
+ imageUrl: chatbotConfig.image_url
189
+ }), /*#__PURE__*/React.createElement(View, {
190
+ style: [styles.webViewWrapper, {
191
+ height: isWebViewVisible ? "100%" : 0
192
+ }],
193
+ pointerEvents: isWebViewVisible ? "auto" : "none"
194
+ }, /*#__PURE__*/React.createElement(Animated.View, {
195
+ style: [isFullScreen ? styles.fullScreenContainer : styles.inlineContainer, {
196
+ opacity: fadeAnim
197
+ }]
198
+ }, /*#__PURE__*/React.createElement(WebView, {
199
+ ref: webViewRef,
200
+ source: {
201
+ uri: webViewUrl
202
+ },
203
+ onMessage: handleMessage,
204
+ style: styles.webview,
205
+ containerStyle: isFullScreen ? {
206
+ width: screenDimensions.width,
207
+ height: screenDimensions.height
208
+ } : undefined,
209
+ allowsInlineMediaPlayback: true,
210
+ mediaPlaybackRequiresUserAction: false,
211
+ allowFileAccess: false,
212
+ geolocationEnabled: false,
213
+ javaScriptEnabled: true,
214
+ domStorageEnabled: true,
215
+ cacheEnabled: true,
216
+ scrollEnabled: true,
217
+ bounces: false,
218
+ onShouldStartLoadWithRequest: request => {
219
+ return request.url.startsWith(BASE_CHATBOT_URL);
220
+ },
221
+ startInLoadingState: isFirstLoadRef.current,
222
+ onLoadEnd: () => {
223
+ var _webViewRef$current;
224
+ (_webViewRef$current = webViewRef.current) === null || _webViewRef$current === void 0 || _webViewRef$current.injectJavaScript(`
225
+ if (!document.querySelector('meta[name="viewport"]')) {
226
+ var meta = document.createElement('meta');
227
+ meta.name = 'viewport';
228
+ meta.content = 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no';
229
+ document.getElementsByTagName('head')[0].appendChild(meta);
230
+ }
231
+
232
+ if (!document.querySelector('#injectedStyle')) {
233
+ const style = document.createElement('style');
234
+ style.id = 'injectedStyle';
235
+ style.textContent = \`
236
+ html, body, #root, #__next {
237
+ height: 100% !important;
238
+ min-height: 100% !important;
239
+ overflow: hidden !important;
240
+ }
241
+ \`;
242
+ document.head.appendChild(style);
243
+ }
244
+
245
+ window.sendToChatbot = function(message) {
246
+ window.ReactNativeWebView.postMessage(JSON.stringify(message));
247
+ };
248
+
249
+ var closeButton = document.querySelector('.chatbot-close-button');
250
+ if (closeButton) {
251
+ closeButton.addEventListener('click', () => {
252
+ window.sendToChatbot({ type: 'close_chatbot' });
253
+ });
254
+ }
255
+
256
+ true;
257
+ `);
258
+ isFirstLoadRef.current = false;
259
+ },
260
+ onError: syntheticEvent => {
261
+ const {
262
+ nativeEvent
263
+ } = syntheticEvent;
264
+ console.warn("WebView error:", nativeEvent);
265
+ }
266
+ })))));
267
+ };
268
+ const styles = StyleSheet.create({
269
+ mainContainer: {
270
+ flex: 1,
271
+ position: "relative"
272
+ },
273
+ webViewWrapper: {
274
+ position: "absolute",
275
+ top: 0,
276
+ left: 0,
277
+ right: 0,
278
+ bottom: 0,
279
+ overflow: "hidden",
280
+ zIndex: 1000
281
+ },
282
+ fullScreenContainer: {
283
+ position: "absolute",
284
+ top: 0,
285
+ left: 0,
286
+ right: 0,
287
+ bottom: 0,
288
+ backgroundColor: "white",
289
+ zIndex: 1000
290
+ },
291
+ inlineContainer: {
292
+ flex: 1,
293
+ backgroundColor: "white"
294
+ },
295
+ webview: {
296
+ flex: 1,
297
+ backgroundColor: "white"
298
+ }
299
+ });
300
+ export default ChatbotSDK;
2
301
  //# 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","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,gBAA+C,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,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WAAW,CAAK2D,cAAc,CAA9B3D,WAAW,CACnB1B,OAAO,CAACgC,IAAI,CAAC,gBAAgB,CAAEN,WAAW,CAAC,CAC7C,CAAE,CACH,CAAC,CACW,CAAC,CACZ,CAAC,EACP,CACH,CACG,CAAC,CAEX,CAAC,CAED,GAAM,CAAAsB,MAAM,CAAGsC,uBAAU,CAACC,MAAM,CAAC,CAC/BtC,aAAa,CAAE,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,CAAA/L,OAAA,CAEYc,UAAU","ignoreList":[]}
1
+ {"version":3,"names":["React","useState","useEffect","useRef","useMemo","View","StyleSheet","Animated","Dimensions","Platform","StatusBar","WebView","FloatingButton","BASE_CHATBOT_URL","ChatbotSDK","api_key","user_id","user_token","additional_params","show_floating_button","onMessage","isFullScreen","enableAnimation","onOpen","onClose","isWebViewVisible","setIsWebViewVisible","chatbotConfig","setChatbotConfig","loading","setLoading","webViewRef","fadeAnim","Value","current","isFirstLoadRef","webViewUrl","constructUrl","stableAdditionalParams","JSON","stringify","triggerAppInit","injectJavaScript","fetchChatbotConfig","_data$user","endpointUrl","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","params","URLSearchParams","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","get","height","windowWidth","width","statusBarHeight","OS","currentHeight","screenDimensions","createElement","style","styles","mainContainer","Fragment","onPress","brandColor","imageUrl","webViewWrapper","pointerEvents","fullScreenContainer","inlineContainer","opacity","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","create","flex","position","top","left","right","bottom","overflow","zIndex","backgroundColor"],"sourceRoot":"../../src","sources":["Chatbotsdk.tsx"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,EAAEC,SAAS,EAAEC,MAAM,EAAEC,OAAO,QAAQ,OAAO;AACnE,SACEC,IAAI,EACJC,UAAU,EACVC,QAAQ,EACRC,UAAU,EACVC,QAAQ,EACRC,SAAS,QACJ,cAAc;AACrB,SAASC,OAAO,QAA6B,sBAAsB;AACnE,OAAOC,cAAc,MAAM,kBAAkB;AAC7C,SAASC,gBAAgB,QAAQ,aAAa;AA0B9C,MAAMC,UAAqC,GAAGA,CAAC;EAC7CC,OAAO;EACPC,OAAO;EACPC,UAAU;EACVC,iBAAiB,GAAG,CAAC,CAAC;EACtBC,oBAAoB,GAAG,IAAI;EAC3BC,SAAS;EACTC,YAAY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sB,IAAI,EAAE,CAAC;IACPQ,eAAe,EAAE;EACnB;AACF,CAAC,CAAC;AAEF,eAAejJ,UAAU","ignoreList":[]}
@@ -1,2 +1,54 @@
1
- var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _react=_interopRequireDefault(require("react"));var _reactNative=require("react-native");var _jsxRuntime=require("react/jsx-runtime");var _this=this,_jsxFileName="/Users/jobinabraham/Developer/personal/robylon-react-native-sdk/src/FloatingButton.tsx";var FloatingButton=function FloatingButton(_ref){var onPress=_ref.onPress,_ref$brandColor=_ref.brandColor,brandColor=_ref$brandColor===void 0?"#007AFF":_ref$brandColor,imageUrl=_ref.imageUrl;return(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{style:[styles.button,{backgroundColor:brandColor}],onPress:onPress,children:imageUrl?(0,_jsxRuntime.jsx)(_reactNative.Image,{source:{uri:imageUrl},style:styles.buttonImage}):(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.buttonText,children:"Chat"})});};var styles=_reactNative.StyleSheet.create({button:{position:"absolute",bottom:20,right:20,borderRadius:24,width:48,height:48,justifyContent:"center",alignItems:"center",elevation:5,shadowColor:"#000",shadowOffset:{width:0,height:2},shadowOpacity:0.25,shadowRadius:3.84},buttonText:{color:"white",fontSize:16,fontWeight:"bold"},buttonImage:{width:48,height:48,borderRadius:24}});var _default=exports.default=FloatingButton;
1
+ import React from "react";
2
+ import { TouchableOpacity, StyleSheet, Text, Image } from "react-native";
3
+ const FloatingButton = ({
4
+ onPress,
5
+ brandColor = "#007AFF",
6
+ // Default color
7
+ imageUrl
8
+ }) => {
9
+ return /*#__PURE__*/React.createElement(TouchableOpacity, {
10
+ style: [styles.button, {
11
+ backgroundColor: brandColor
12
+ }],
13
+ onPress: onPress
14
+ }, imageUrl ? /*#__PURE__*/React.createElement(Image, {
15
+ source: {
16
+ uri: imageUrl
17
+ },
18
+ style: styles.buttonImage
19
+ }) : /*#__PURE__*/React.createElement(Text, {
20
+ style: styles.buttonText
21
+ }, "Chat"));
22
+ };
23
+ const styles = StyleSheet.create({
24
+ button: {
25
+ position: "absolute",
26
+ bottom: 20,
27
+ right: 20,
28
+ borderRadius: 30,
29
+ width: 60,
30
+ height: 60,
31
+ justifyContent: "center",
32
+ alignItems: "center",
33
+ elevation: 5,
34
+ shadowColor: "#000",
35
+ shadowOffset: {
36
+ width: 0,
37
+ height: 2
38
+ },
39
+ shadowOpacity: 0.25,
40
+ shadowRadius: 3.84
41
+ },
42
+ buttonText: {
43
+ color: "white",
44
+ fontSize: 16,
45
+ fontWeight: "bold"
46
+ },
47
+ buttonImage: {
48
+ width: 40,
49
+ height: 40,
50
+ borderRadius: 20
51
+ }
52
+ });
53
+ export default FloatingButton;
2
54
  //# sourceMappingURL=FloatingButton.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireDefault","require","_reactNative","_jsxRuntime","_this","_jsxFileName","FloatingButton","_ref","onPress","_ref$brandColor","brandColor","imageUrl","jsx","TouchableOpacity","style","styles","button","backgroundColor","children","Image","source","uri","buttonImage","Text","buttonText","StyleSheet","create","position","bottom","right","borderRadius","width","height","justifyContent","alignItems","elevation","shadowColor","shadowOffset","shadowOpacity","shadowRadius","color","fontSize","fontWeight","_default","exports","default"],"sourceRoot":"../../src","sources":["FloatingButton.tsx"],"mappings":"mKAAA,IAAAA,MAAA,CAAAC,sBAAA,CAAAC,OAAA,WACA,IAAAC,YAAA,CAAAD,OAAA,iBAAyE,IAAAE,WAAA,CAAAF,OAAA,0BAAAG,KAAA,MAAAC,YAAA,0FAQzE,GAAM,CAAAC,cAA6C,CAAG,QAAhD,CAAAA,cAA6CA,CAAAC,IAAA,CAI7C,IAHJ,CAAAC,OAAO,CAAAD,IAAA,CAAPC,OAAO,CAAAC,eAAA,CAAAF,IAAA,CACPG,UAAU,CAAVA,UAAU,CAAAD,eAAA,UAAG,SAAS,CAAAA,eAAA,CACtBE,QAAQ,CAAA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CAAAC,OAAA,CAAAC,OAAA,CAEYvC,cAAc","ignoreList":[]}
1
+ {"version":3,"names":["React","TouchableOpacity","StyleSheet","Text","Image","FloatingButton","onPress","brandColor","imageUrl","createElement","style","styles","button","backgroundColor","source","uri","buttonImage","buttonText","create","position","bottom","right","borderRadius","width","height","justifyContent","alignItems","elevation","shadowColor","shadowOffset","shadowOpacity","shadowRadius","color","fontSize","fontWeight"],"sourceRoot":"../../src","sources":["FloatingButton.tsx"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,gBAAgB,EAAEC,UAAU,EAAEC,IAAI,EAAEC,KAAK,QAAQ,cAAc;AAQxE,MAAMC,cAA6C,GAAGA,CAAC;EACrDC,OAAO;EACPC,UAAU,GAAG,SAAS;EAAE;EACxBC;AACF,CAAC,KAAK;EACJ,oBACER,KAAA,CAAAS,aAAA,CAACR,gBAAgB;IACfS,KAAK,EAAE,CAACC,MAAM,CAACC,MAAM,EAAE;MAAEC,eAAe,EAAEN;IAAW,CAAC,CAAE;IACxDD,OAAO,EAAEA;EAAQ,GAEhBE,QAAQ,gBACPR,KAAA,CAAAS,aAAA,CAACL,KAAK;IAACU,MAAM,EAAE;MAAEC,GAAG,EAAEP;IAAS,CAAE;IAACE,KAAK,EAAEC,MAAM,CAACK;EAAY,CAAE,CAAC,gBAE/DhB,KAAA,CAAAS,aAAA,CAACN,IAAI;IAACO,KAAK,EAAEC,MAAM,CAACM;EAAW,GAAC,MAAU,CAE5B,CAAC;AAEvB,CAAC;AAED,MAAMN,MAAM,GAAGT,UAAU,CAACgB,MAAM,CAAC;EAC/BN,MAAM,EAAE;IACNO,QAAQ,EAAE,UAAU;IACpBC,MAAM,EAAE,EAAE;IACVC,KAAK,EAAE,EAAE;IACTC,YAAY,EAAE,EAAE;IAChBC,KAAK,EAAE,EAAE;IACTC,MAAM,EAAE,EAAE;IACVC,cAAc,EAAE,QAAQ;IACxBC,UAAU,EAAE,QAAQ;IACpBC,SAAS,EAAE,CAAC;IACZC,WAAW,EAAE,MAAM;IACnBC,YAAY,EAAE;MAAEN,KAAK,EAAE,CAAC;MAAEC,MAAM,EAAE;IAAE,CAAC;IACrCM,aAAa,EAAE,IAAI;IACnBC,YAAY,EAAE;EAChB,CAAC;EACDd,UAAU,EAAE;IACVe,KAAK,EAAE,OAAO;IACdC,QAAQ,EAAE,EAAE;IACZC,UAAU,EAAE;EACd,CAAC;EACDlB,WAAW,EAAE;IACXO,KAAK,EAAE,EAAE;IACTC,MAAM,EAAE,EAAE;IACVF,YAAY,EAAE;EAChB;AACF,CAAC,CAAC;AAEF,eAAejB,cAAc","ignoreList":[]}
@@ -1,2 +1,14 @@
1
- var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _react=_interopRequireDefault(require("react"));var _reactNative=require("react-native");var _jsxRuntime=require("react/jsx-runtime");var _this=this,_jsxFileName="/Users/jobinabraham/Developer/personal/robylon-react-native-sdk/src/LoadingIndicator.tsx";var LoadingIndicator=function LoadingIndicator(){return(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flex:1,justifyContent:"center",alignItems:"center"},children:(0,_jsxRuntime.jsx)(_reactNative.ActivityIndicator,{size:"large",color:"#0000ff"})});};var _default=exports.default=LoadingIndicator;
1
+ import React from "react";
2
+ import { View, ActivityIndicator } from "react-native";
3
+ const LoadingIndicator = () => /*#__PURE__*/React.createElement(View, {
4
+ style: {
5
+ flex: 1,
6
+ justifyContent: "center",
7
+ alignItems: "center"
8
+ }
9
+ }, /*#__PURE__*/React.createElement(ActivityIndicator, {
10
+ size: "large",
11
+ color: "#0000ff"
12
+ }));
13
+ export default LoadingIndicator;
2
14
  //# sourceMappingURL=LoadingIndicator.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireDefault","require","_reactNative","_jsxRuntime","_this","_jsxFileName","LoadingIndicator","jsx","View","style","flex","justifyContent","alignItems","children","ActivityIndicator","size","color","_default","exports","default"],"sourceRoot":"../../src","sources":["LoadingIndicator.tsx"],"mappings":"mKAAA,IAAAA,MAAA,CAAAC,sBAAA,CAAAC,OAAA,WACA,IAAAC,YAAA,CAAAD,OAAA,iBAAuD,IAAAE,WAAA,CAAAF,OAAA,0BAAAG,KAAA,MAAAC,YAAA,4FAGvD,GAAM,CAAAC,gBAA0B,CAAG,QAA7B,CAAAA,gBAA0BA,CAAA,QAC9B,GAAAH,WAAA,CAAAI,GAAA,EAACL,YAAA,CAAAM,IAAI,EAACC,KAAK,CAAE,CAAEC,IAAI,CAAE,CAAC,CAAEC,cAAc,CAAE,QAAQ,CAAEC,UAAU,CAAE,QAAS,CAAE,CAAAC,QAAA,CACvE,GAAAV,WAAA,CAAAI,GAAA,EAACL,YAAA,CAAAY,iBAAiB,EAACC,IAAI,CAAC,OAAO,CAACC,KAAK,CAAC,SAAS,CAAE,CAAC,CAC9C,CAAC,EACR,CAAC,IAAAC,QAAA,CAAAC,OAAA,CAAAC,OAAA,CAEab,gBAAgB","ignoreList":[]}
1
+ {"version":3,"names":["React","View","ActivityIndicator","LoadingIndicator","createElement","style","flex","justifyContent","alignItems","size","color"],"sourceRoot":"../../src","sources":["LoadingIndicator.tsx"],"mappings":"AAAA,OAAOA,KAAK,MAA+B,OAAO;AAClD,SAASC,IAAI,EAAEC,iBAAiB,QAAQ,cAAc;AAGtD,MAAMC,gBAA0B,GAAGA,CAAA,kBACjCH,KAAA,CAAAI,aAAA,CAACH,IAAI;EAACI,KAAK,EAAE;IAAEC,IAAI,EAAE,CAAC;IAAEC,cAAc,EAAE,QAAQ;IAAEC,UAAU,EAAE;EAAS;AAAE,gBACvER,KAAA,CAAAI,aAAA,CAACF,iBAAiB;EAACO,IAAI,EAAC,OAAO;EAACC,KAAK,EAAC;AAAS,CAAE,CAC7C,CACP;AAED,eAAeP,gBAAgB","ignoreList":[]}
@@ -1,2 +1,5 @@
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://staging-api.robylon.com"||'https://api.robylon.com',DEBUG:(process&&process.env&&process.env.DEBUG||"true")==='true'};
1
+ export const config = {
2
+ API_URL: process.env.API_URL || 'https://api.robylon.com',
3
+ DEBUG: process.env.DEBUG === 'true'
4
+ };
2
5
  //# 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,qCAAuB,yBAAyB,CACzDI,KAAK,CAAE,CAAAH,OAAA,EAAAA,OAAA,CAAAC,GAAA,EAAAC,WAAA,CAAAC,KAAA,YAAsB,MAC/B,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["config","API_URL","process","env","DEBUG"],"sourceRoot":"../../src","sources":["config.ts"],"mappings":"AAAA,OAAO,MAAMA,MAAM,GAAG;EACpBC,OAAO,EAAEC,OAAO,CAACC,GAAG,CAACF,OAAO,IAAI,yBAAyB;EACzDG,KAAK,EAAEF,OAAO,CAACC,GAAG,CAACC,KAAK,KAAK;AAC/B,CAAC","ignoreList":[]}
@@ -1,2 +1,4 @@
1
- Object.defineProperty(exports,"__esModule",{value:true});exports.BASE_CHATBOT_URL=void 0;var BASE_CHATBOT_DOMAIN=process&&process.env&&process.env.CHATBOT_DOMAIN||"http://172.16.1.79: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;
1
+ const BASE_CHATBOT_DOMAIN = process.env.CHATBOT_DOMAIN || "";
2
+ const CHATBOT_PATH = process.env.CHATBOT_PATH || "";
3
+ export const BASE_CHATBOT_URL = `${BASE_CHATBOT_DOMAIN}/${CHATBOT_PATH}`;
2
4
  //# 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"],"sourceRoot":"../../src","sources":["constants.ts"],"mappings":"yFAAA,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","ignoreList":[]}
1
+ {"version":3,"names":["BASE_CHATBOT_DOMAIN","process","env","CHATBOT_DOMAIN","CHATBOT_PATH","BASE_CHATBOT_URL"],"sourceRoot":"../../src","sources":["constants.ts"],"mappings":"AAAA,MAAMA,mBAAmB,GAAGC,OAAO,CAACC,GAAG,CAACC,cAAc,IAAI,EAAE;AAC5D,MAAMC,YAAY,GAAGH,OAAO,CAACC,GAAG,CAACE,YAAY,IAAI,EAAE;AACnD,OAAO,MAAMC,gBAAgB,GAAG,GAAGL,mBAAmB,IAAII,YAAY,EAAE","ignoreList":[]}
@@ -1,2 +1,7 @@
1
-
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
+ // }
2
7
  //# sourceMappingURL=global.d.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sourceRoot":"../../src","sources":["global.d.ts"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sourceRoot":"../../src","sources":["global.d.ts"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
@@ -1,2 +1,3 @@
1
- var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"ChatbotSDK",{enumerable:true,get:function get(){return _Chatbotsdk.default;}});Object.defineProperty(exports,"openChatbot",{enumerable:true,get:function get(){return _openChatbot.openChatbot;}});var _Chatbotsdk=_interopRequireDefault(require("./Chatbotsdk"));var _openChatbot=require("./openChatbot");
1
+ export { default as ChatbotSDK } from "./Chatbotsdk";
2
+ export { openChatbot } from "./openChatbot";
2
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_Chatbotsdk","_interopRequireDefault","require","_openChatbot"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"8WAAA,IAAAA,WAAA,CAAAC,sBAAA,CAAAC,OAAA,kBACA,IAAAC,YAAA,CAAAD,OAAA","ignoreList":[]}
1
+ {"version":3,"names":["default","ChatbotSDK","openChatbot"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA,SAASA,OAAO,IAAIC,UAAU,QAAQ,cAAc;AACpD,SAASC,WAAW,QAAQ,eAAe","ignoreList":[]}
@@ -1,3 +1,11 @@
1
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);};
2
+ //# sourceMappingURL=openChatbot.js.mapimport { BASE_CHATBOT_URL } from "./constants";
3
+ export const openChatbot = (chatbotId, additionalParams = {}) => {
4
+ const params = new URLSearchParams({
5
+ id: chatbotId,
6
+ ...additionalParams
7
+ });
8
+ const url = `${BASE_CHATBOT_URL}?${params.toString()}`;
9
+ Linking.openURL(url);
10
+ };
3
11
  //# sourceMappingURL=openChatbot.js.map
package/package.json CHANGED
@@ -1,24 +1,24 @@
1
1
  {
2
2
  "name": "@robylon/react-native-sdk",
3
- "version": "1.10.1-staging.11",
3
+ "version": "1.10.1-staging.3",
4
4
  "description": "React Native SDK for Robylon",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "module": "lib/module/index.js",
7
7
  "types": "lib/typescript/index.d.ts",
8
- "react-native": "lib/commonjs/index.js",
8
+ "react-native": "src/index.tsx",
9
9
  "source": "src/index.tsx",
10
10
  "scripts": {
11
11
  "prepare": "bob build",
12
12
  "build": "bob build",
13
- "clean": "rimraf lib",
13
+ "clean": "del lib",
14
14
  "prebuild:staging": "cp .npmignore.staging .npmignore",
15
15
  "prebuild:production": "cp .npmignore.production .npmignore",
16
16
  "build:staging": "env-cmd -f .env.staging bob build",
17
17
  "build:production": "env-cmd -f .env.production bob build",
18
18
  "version:staging": "npm version prerelease --preid staging",
19
19
  "version:production": "npm version patch",
20
- "publish:staging": "npm run clean && npm run prebuild:staging && npm run version:staging && npm run build:staging && npm publish --tag staging",
21
- "publish:production": "npm run clean && npm run prebuild:production && npm run version:production && npm run build:production && npm publish --tag latest"
20
+ "publish:staging": "npm run prebuild:staging && npm run version:staging && npm run build:staging && npm publish --tag staging",
21
+ "publish:production": "npm run prebuild:production && npm run version:production && npm run build:production && npm publish --tag latest"
22
22
  },
23
23
  "peerDependencies": {
24
24
  "react": "*",
@@ -29,31 +29,19 @@
29
29
  "@types/node": "^22.10.1",
30
30
  "@types/react": "^18.0.0",
31
31
  "@types/react-native": "^0.70.0",
32
- "babel-plugin-inline-dotenv": "^1.7.0",
33
32
  "babel-plugin-transform-inline-environment-variables": "^0.4.4",
34
33
  "env-cmd": "^10.1.0",
35
34
  "react": "^18.0.0",
36
35
  "react-native": "^0.70.0",
37
36
  "react-native-builder-bob": "^0.20.0",
38
- "rimraf": "^6.0.1",
39
37
  "typescript": "^4.5.2"
40
38
  },
41
39
  "react-native-builder-bob": {
42
40
  "source": "src",
43
41
  "output": "lib",
44
42
  "targets": [
45
- [
46
- "commonjs",
47
- {
48
- "configFile": "./babel.config.js"
49
- }
50
- ],
51
- [
52
- "module",
53
- {
54
- "configFile": "./babel.config.js"
55
- }
56
- ],
43
+ "commonjs",
44
+ "module",
57
45
  [
58
46
  "typescript",
59
47
  {
@@ -61,7 +49,12 @@
61
49
  "tsc": "./node_modules/.bin/tsc"
62
50
  }
63
51
  ]
64
- ]
52
+ ],
53
+ "babel": {
54
+ "plugins": [
55
+ "transform-inline-environment-variables"
56
+ ]
57
+ }
65
58
  },
66
59
  "author": "",
67
60
  "license": "ISC"