@robylon/react-native-sdk 2.0.31-staging.1 → 2.0.31-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.
@@ -0,0 +1,35 @@
1
+ buildscript {
2
+ repositories {
3
+ google()
4
+ mavenCentral()
5
+ }
6
+ dependencies {
7
+ classpath("com.android.tools.build:gradle:8.3.2")
8
+ }
9
+ }
10
+
11
+ apply plugin: "com.android.library"
12
+
13
+ android {
14
+ namespace "com.robylonreactnativesdk"
15
+ compileSdkVersion 34
16
+
17
+ defaultConfig {
18
+ minSdkVersion 21
19
+ targetSdkVersion 34
20
+ }
21
+
22
+ compileOptions {
23
+ sourceCompatibility JavaVersion.VERSION_17
24
+ targetCompatibility JavaVersion.VERSION_17
25
+ }
26
+ }
27
+
28
+ repositories {
29
+ google()
30
+ mavenCentral()
31
+ }
32
+
33
+ dependencies {
34
+ implementation "com.facebook.react:react-native:+"
35
+ }
@@ -0,0 +1,3 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
+ package="com.robylonreactnativesdk">
3
+ </manifest>
@@ -0,0 +1,83 @@
1
+ package com.robylonreactnativesdk;
2
+
3
+ import android.app.DownloadManager;
4
+ import android.content.Context;
5
+ import android.net.Uri;
6
+ import android.os.Environment;
7
+ import android.webkit.MimeTypeMap;
8
+
9
+ import androidx.annotation.NonNull;
10
+
11
+ import com.facebook.react.bridge.Promise;
12
+ import com.facebook.react.bridge.ReactApplicationContext;
13
+ import com.facebook.react.bridge.ReactContextBaseJavaModule;
14
+ import com.facebook.react.bridge.ReactMethod;
15
+
16
+ public class RobylonDownloadModule extends ReactContextBaseJavaModule {
17
+ private final ReactApplicationContext reactContext;
18
+
19
+ public RobylonDownloadModule(ReactApplicationContext reactContext) {
20
+ super(reactContext);
21
+ this.reactContext = reactContext;
22
+ }
23
+
24
+ @NonNull
25
+ @Override
26
+ public String getName() {
27
+ return "RobylonDownloadModule";
28
+ }
29
+
30
+ @ReactMethod
31
+ public void downloadFile(String url, String filename, Promise promise) {
32
+ try {
33
+ if (url == null || url.trim().isEmpty()) {
34
+ promise.reject("INVALID_URL", "Download URL is missing");
35
+ return;
36
+ }
37
+
38
+ String safeName = getSafeFileName(filename, url);
39
+ DownloadManager manager = (DownloadManager) reactContext.getSystemService(Context.DOWNLOAD_SERVICE);
40
+ if (manager == null) {
41
+ promise.reject("DOWNLOAD_SERVICE_UNAVAILABLE", "Download service unavailable");
42
+ return;
43
+ }
44
+
45
+ DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
46
+ request.setTitle(safeName);
47
+ request.setDescription("Downloading transcript");
48
+ request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
49
+ request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, safeName);
50
+ request.setMimeType(getMimeTypeFromName(safeName));
51
+ request.setAllowedOverMetered(true);
52
+ request.setAllowedOverRoaming(true);
53
+
54
+ long downloadId = manager.enqueue(request);
55
+ promise.resolve(String.valueOf(downloadId));
56
+ } catch (Exception error) {
57
+ promise.reject("DOWNLOAD_FAILED", error);
58
+ }
59
+ }
60
+
61
+ private String getSafeFileName(String filename, String url) {
62
+ if (filename != null && !filename.trim().isEmpty()) {
63
+ return filename.trim().replaceAll("[\\\\/:*?\"<>|]", "_");
64
+ }
65
+ String fromUrl = Uri.parse(url).getLastPathSegment();
66
+ if (fromUrl == null || fromUrl.trim().isEmpty()) {
67
+ return "chat-transcript-" + System.currentTimeMillis() + ".txt";
68
+ }
69
+ return fromUrl.trim().replaceAll("[\\\\/:*?\"<>|]", "_");
70
+ }
71
+
72
+ private String getMimeTypeFromName(String filename) {
73
+ String extension = MimeTypeMap.getFileExtensionFromUrl(filename);
74
+ if (extension == null || extension.isEmpty()) {
75
+ return "application/octet-stream";
76
+ }
77
+ String mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension.toLowerCase());
78
+ if (mimeType == null || mimeType.isEmpty()) {
79
+ return "application/octet-stream";
80
+ }
81
+ return mimeType;
82
+ }
83
+ }
@@ -0,0 +1,24 @@
1
+ package com.robylonreactnativesdk;
2
+
3
+ import com.facebook.react.ReactPackage;
4
+ import com.facebook.react.bridge.NativeModule;
5
+ import com.facebook.react.bridge.ReactApplicationContext;
6
+ import com.facebook.react.uimanager.ViewManager;
7
+
8
+ import java.util.ArrayList;
9
+ import java.util.Collections;
10
+ import java.util.List;
11
+
12
+ public class RobylonReactNativeSdkPackage implements ReactPackage {
13
+ @Override
14
+ public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
15
+ List<NativeModule> modules = new ArrayList<>();
16
+ modules.add(new RobylonDownloadModule(reactContext));
17
+ return modules;
18
+ }
19
+
20
+ @Override
21
+ public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
22
+ return Collections.emptyList();
23
+ }
24
+ }
@@ -1,2 +1,2 @@
1
- var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.handleDownloadRequest=exports.downloadFile=void 0;var _asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));var _reactNative=require("react-native");var _logger=require("./logger");var normalizeUrl=function normalizeUrl(url){return url==null?void 0:url.trim();};var sanitizeFileName=function sanitizeFileName(filename){var fallbackName=`chat-transcript-${Date.now()}.pdf`;var trimmedName=filename==null?void 0:filename.trim();if(!trimmedName)return fallbackName;return trimmedName.replace(/[<>:"/\\|?*\x00-\x1F]/g,"_");};var getBlobUtilModule=function getBlobUtilModule(){try{var _require;return(_require=require("react-native-blob-util"))==null?void 0:_require.default;}catch(error){_logger.logger.warn("react-native-blob-util is unavailable",{error:error instanceof Error?error==null?void 0:error.message:String(error)});return null;}};var isValidHttpUrl=function isValidHttpUrl(url){return /^https?:\/\//i.test(url);};var openUrlWithFallback=function(){var _ref=(0,_asyncToGenerator2.default)(function*(url){try{yield _reactNative.Linking.openURL(url);return;}catch(primaryError){_logger.logger.warn("Primary URL open failed, trying browser fallback",{url:url,primaryError:primaryError instanceof Error?primaryError==null?void 0:primaryError.message:String(primaryError)});}yield _reactNative.Linking.openURL(`https://docs.google.com/viewer?url=${encodeURIComponent(url)}`);});return function openUrlWithFallback(_x){return _ref.apply(this,arguments);};}();var downloadOnAndroid=function(){var _ref2=(0,_asyncToGenerator2.default)(function*(url,filename){var blobUtil=getBlobUtilModule();if(!blobUtil){throw new Error("react-native-blob-util module not available on Android");}var fs=blobUtil.fs,config=blobUtil.config;var downloadPath=`${fs.dirs.DownloadDir}/${filename}`;yield config({fileCache:true,path:downloadPath,addAndroidDownloads:{useDownloadManager:true,notification:true,title:filename,description:"Downloading transcript",mime:"application/pdf",mediaScannable:true,path:downloadPath}}).fetch("GET",url);});return function downloadOnAndroid(_x2,_x3){return _ref2.apply(this,arguments);};}();var downloadOniOS=function(){var _ref3=(0,_asyncToGenerator2.default)(function*(url,filename){var blobUtil=getBlobUtilModule();if(!blobUtil){throw new Error("react-native-blob-util module not available on iOS");}var fs=blobUtil.fs,config=blobUtil.config;var iosPath=`${fs.dirs.DocumentDir}/${filename}`;yield config({fileCache:true,path:iosPath}).fetch("GET",url);yield _reactNative.Share.share({url:`file://${iosPath}`,message:filename,title:filename});});return function downloadOniOS(_x4,_x5){return _ref3.apply(this,arguments);};}();var downloadWithNativeStorage=function(){var _ref4=(0,_asyncToGenerator2.default)(function*(url,filename){var safeName=sanitizeFileName(filename);if(_reactNative.Platform.OS==="android"){yield downloadOnAndroid(url,safeName);return;}yield downloadOniOS(url,safeName);});return function downloadWithNativeStorage(_x6,_x7){return _ref4.apply(this,arguments);};}();var shouldUseInPlaceDownload=function shouldUseInPlaceDownload(downloadRequest){return(downloadRequest==null?void 0:downloadRequest.inPlace)===true;};var downloadFile=exports.downloadFile=function(){var _ref5=(0,_asyncToGenerator2.default)(function*(url,filename,inPlace){try{var normalizedUrl=normalizeUrl(url);_logger.logger.debug("Initiating file download",{url:normalizedUrl,filename:filename});if(!normalizedUrl||typeof normalizedUrl!=="string"){throw new Error("Invalid URL provided for download");}if(!isValidHttpUrl(normalizedUrl)){throw new Error("Download URL must be an http/https URL");}if(inPlace){try{yield downloadWithNativeStorage(normalizedUrl,filename);_logger.logger.debug("File downloaded with native storage flow");}catch(nativeDownloadError){_logger.logger.warn("Native download failed, falling back to URL open",{url:normalizedUrl,nativeDownloadError:nativeDownloadError instanceof Error?nativeDownloadError==null?void 0:nativeDownloadError.message:String(nativeDownloadError)});yield openUrlWithFallback(normalizedUrl);_logger.logger.debug("File download opened with fallback browser flow");}return;}yield openUrlWithFallback(normalizedUrl);_logger.logger.debug("File download opened with legacy URL flow");}catch(error){_logger.logger.error("File download failed",{url:url,filename:filename,error:error instanceof Error?error==null?void 0:error.message:String(error)});throw error;}});return function downloadFile(_x8,_x9,_x10){return _ref5.apply(this,arguments);};}();var handleDownloadRequest=exports.handleDownloadRequest=function(){var _ref6=(0,_asyncToGenerator2.default)(function*(downloadRequest){var url=downloadRequest.url,filename=downloadRequest.filename;if(!url){_logger.logger.error("Download request missing URL");return;}try{yield downloadFile(url,filename,shouldUseInPlaceDownload(downloadRequest));}catch(error){_logger.logger.error("Failed to handle download request",{downloadRequest:downloadRequest,error:error});}});return function handleDownloadRequest(_x11){return _ref6.apply(this,arguments);};}();
1
+ var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.handleDownloadRequest=exports.downloadFile=void 0;var _asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));var _reactNative=require("react-native");var _logger=require("./logger");var normalizeUrl=function normalizeUrl(url){return url==null?void 0:url.trim();};var sanitizeFileName=function sanitizeFileName(filename){var fallbackName=`chat-transcript-${Date.now()}.txt`;var trimmedName=filename==null?void 0:filename.trim();if(!trimmedName)return fallbackName;return trimmedName.replace(/[<>:"/\\|?*\x00-\x1F]/g,"_");};var isValidHttpUrl=function isValidHttpUrl(url){return /^https?:\/\//i.test(url);};var getNativeDownloadModule=function getNativeDownloadModule(){return(_reactNative.NativeModules==null?void 0:_reactNative.NativeModules.RobylonDownloadModule)||null;};var openUrlWithFallback=function(){var _ref=(0,_asyncToGenerator2.default)(function*(url){try{yield _reactNative.Linking.openURL(url);return;}catch(primaryError){_logger.logger.warn("Primary URL open failed, trying browser fallback",{url:url,primaryError:primaryError instanceof Error?primaryError==null?void 0:primaryError.message:String(primaryError)});}yield _reactNative.Linking.openURL(`https://docs.google.com/viewer?url=${encodeURIComponent(url)}`);});return function openUrlWithFallback(_x){return _ref.apply(this,arguments);};}();var downloadOnAndroid=function(){var _ref2=(0,_asyncToGenerator2.default)(function*(url,filename){var module=getNativeDownloadModule();if(!(module!=null&&module.downloadFile)){throw new Error("Robylon native download module is not linked on Android");}yield module.downloadFile(url,filename);});return function downloadOnAndroid(_x2,_x3){return _ref2.apply(this,arguments);};}();var downloadWithNativeStorage=function(){var _ref3=(0,_asyncToGenerator2.default)(function*(url,filename){var safeName=sanitizeFileName(filename);if(_reactNative.Platform.OS==="android"){yield downloadOnAndroid(url,safeName);return;}yield openUrlWithFallback(url);});return function downloadWithNativeStorage(_x4,_x5){return _ref3.apply(this,arguments);};}();var shouldUseInPlaceDownload=function shouldUseInPlaceDownload(downloadRequest){return(downloadRequest==null?void 0:downloadRequest.inPlace)===true;};var downloadFile=exports.downloadFile=function(){var _ref4=(0,_asyncToGenerator2.default)(function*(url,filename,inPlace){try{var normalizedUrl=normalizeUrl(url);_logger.logger.debug("Initiating file download",{url:normalizedUrl,filename:filename});if(!normalizedUrl||typeof normalizedUrl!=="string"){throw new Error("Invalid URL provided for download");}if(!isValidHttpUrl(normalizedUrl)){throw new Error("Download URL must be an http/https URL");}if(inPlace){try{yield downloadWithNativeStorage(normalizedUrl,filename);_logger.logger.debug("File downloaded with native storage flow");}catch(nativeDownloadError){_logger.logger.warn("Native download failed, falling back to URL open",{url:normalizedUrl,nativeDownloadError:nativeDownloadError instanceof Error?nativeDownloadError==null?void 0:nativeDownloadError.message:String(nativeDownloadError)});yield openUrlWithFallback(normalizedUrl);_logger.logger.debug("File download opened with fallback browser flow");}return;}yield openUrlWithFallback(normalizedUrl);_logger.logger.debug("File download opened with legacy URL flow");}catch(error){_logger.logger.error("File download failed",{url:url,filename:filename,error:error instanceof Error?error==null?void 0:error.message:String(error)});throw error;}});return function downloadFile(_x6,_x7,_x8){return _ref4.apply(this,arguments);};}();var handleDownloadRequest=exports.handleDownloadRequest=function(){var _ref5=(0,_asyncToGenerator2.default)(function*(downloadRequest){var url=downloadRequest.url,filename=downloadRequest.filename;if(!url){_logger.logger.error("Download request missing URL");return;}try{yield downloadFile(url,filename,shouldUseInPlaceDownload(downloadRequest));}catch(error){_logger.logger.error("Failed to handle download request",{downloadRequest:downloadRequest,error:error});}});return function handleDownloadRequest(_x9){return _ref5.apply(this,arguments);};}();
2
2
  //# sourceMappingURL=fileDownload.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","_logger","normalizeUrl","url","trim","sanitizeFileName","filename","fallbackName","Date","now","trimmedName","replace","getBlobUtilModule","_require","default","error","logger","warn","Error","message","String","isValidHttpUrl","test","openUrlWithFallback","_ref","_asyncToGenerator2","Linking","openURL","primaryError","encodeURIComponent","_x","apply","arguments","downloadOnAndroid","_ref2","blobUtil","fs","config","downloadPath","dirs","DownloadDir","fileCache","path","addAndroidDownloads","useDownloadManager","notification","title","description","mime","mediaScannable","fetch","_x2","_x3","downloadOniOS","_ref3","iosPath","DocumentDir","Share","share","_x4","_x5","downloadWithNativeStorage","_ref4","safeName","Platform","OS","_x6","_x7","shouldUseInPlaceDownload","downloadRequest","inPlace","downloadFile","exports","_ref5","normalizedUrl","debug","nativeDownloadError","_x8","_x9","_x10","handleDownloadRequest","_ref6","_x11"],"sourceRoot":"../../../src","sources":["utils/fileDownload.ts"],"mappings":"wSAKA,IAAAA,YAAA,CAAAC,OAAA,iBACA,IAAAC,OAAA,CAAAD,OAAA,aAQA,GAAM,CAAAE,YAAY,CA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CACftD,KAAK,CAALA,KACF,CAAC,CAAC,CAEJ,CACF,CAAC,iBAnBY,CAAAiE,qBAAqBA,CAAAE,IAAA,SAAAD,KAAA,CAAAlD,KAAA,MAAAC,SAAA,OAmBjC","ignoreList":[]}
1
+ {"version":3,"names":["_reactNative","require","_logger","normalizeUrl","url","trim","sanitizeFileName","filename","fallbackName","Date","now","trimmedName","replace","isValidHttpUrl","test","getNativeDownloadModule","NativeModules","RobylonDownloadModule","openUrlWithFallback","_ref","_asyncToGenerator2","default","Linking","openURL","primaryError","logger","warn","Error","message","String","encodeURIComponent","_x","apply","arguments","downloadOnAndroid","_ref2","module","downloadFile","_x2","_x3","downloadWithNativeStorage","_ref3","safeName","Platform","OS","_x4","_x5","shouldUseInPlaceDownload","downloadRequest","inPlace","exports","_ref4","normalizedUrl","debug","nativeDownloadError","error","_x6","_x7","_x8","handleDownloadRequest","_ref5","_x9"],"sourceRoot":"../../../src","sources":["utils/fileDownload.ts"],"mappings":"wSAKA,IAAAA,YAAA,CAAAC,OAAA,iBACA,IAAAC,OAAA,CAAAD,OAAA,aAQA,GAAM,CAAAE,YAAY,CAAG,QAAf,CAAAA,YAAYA,CAAIC,GAAW,CAAa,CAC5C,MAAO,CAAAA,GAAG,cAAHA,GAAG,CAAEC,IAAI,CAAC,CAAC,CACpB,CAAC,CAED,GAAM,CAAAC,gBAAgB,CAAG,QAAnB,CAAAA,gBAAgBA,CAAIC,QAAiB,CAAa,CACtD,GAAM,CAAAC,YAAY,CAAG,mBAAmBC,IAAI,CAACC,GAAG,CAAC,CAAC,MAAM,CACxD,GAAM,CAAAC,WAAW,CAAGJ,QAAQ,cAARA,QAAQ,CAAEF,IAAI,CAAC,CAAC,CACpC,GAAI,CAACM,WAAW,CAAE,MAAO,CAAAH,YAAY,CACrC,MAAO,CAAAG,WAAW,CAACC,OAAO,CAAC,wBAAwB,CAAE,GAAG,CAAC,CAC3D,CAAC,CAMD,GAAM,CAAAC,cAAc,CAAG,QAAjB,CAAAA,c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4C,eAAe,CAAjC5C,GAAG,CAAEG,QAAQ,CAAKyC,eAAe,CAA5BzC,QAAQ,CAErB,GAAI,CAACH,GAAG,CAAE,CACRqB,cAAM,CAAC8B,KAAK,CAAC,8BAA8B,CAAC,CAC5C,OACF,CAEA,GAAI,CACF,KAAM,CAAAlB,YAAY,CAACjC,GAAG,CAAEG,QAAQ,CAAEwC,wBAAwB,CAACC,eAAe,CAAC,CAAC,CAC9E,CAAE,MAAOO,KAAK,CAAE,CACd9B,cAAM,CAAC8B,KAAK,CAAC,mCAAmC,CAAE,CAChDP,eAAe,CAAfA,eAAe,CACfO,KAAK,CAALA,KACF,CAAC,CAAC,CAEJ,CACF,CAAC,iBAnBY,CAAAI,qBAAqBA,CAAAE,GAAA,SAAAD,KAAA,CAAA5B,KAAA,MAAAC,SAAA,OAmBjC","ignoreList":[]}
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,"__esModule",{value:true});exports.SDK_VERSION=void 0;var SDK_VERSION=exports.SDK_VERSION='2.0.31-staging.1';
1
+ Object.defineProperty(exports,"__esModule",{value:true});exports.SDK_VERSION=void 0;var SDK_VERSION=exports.SDK_VERSION='2.0.31-staging.3';
2
2
  //# sourceMappingURL=version.staging.js.map
@@ -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.tsx"],"mappings":"","ignoreList":[]}
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,CAAG,GAAGC,2BAAgB,IAAIN,MAAM,CAACO,QAAQ,CAAC,CAAC,EAAE,CACtDC,oBAAO,CAACC,OAAO,CAACJ,GAAG,CAAC,CACtB,CAAC","ignoreList":[]}
@@ -1,2 +1,2 @@
1
- var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.handleDownloadRequest=exports.downloadFile=void 0;var _asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));var _reactNative=require("react-native");var _logger=require("./logger");var normalizeUrl=function normalizeUrl(url){return url==null?void 0:url.trim();};var sanitizeFileName=function sanitizeFileName(filename){var fallbackName=`chat-transcript-${Date.now()}.pdf`;var trimmedName=filename==null?void 0:filename.trim();if(!trimmedName)return fallbackName;return trimmedName.replace(/[<>:"/\\|?*\x00-\x1F]/g,"_");};var getBlobUtilModule=function getBlobUtilModule(){try{var _require;return(_require=require("react-native-blob-util"))==null?void 0:_require.default;}catch(error){_logger.logger.warn("react-native-blob-util is unavailable",{error:error instanceof Error?error==null?void 0:error.message:String(error)});return null;}};var isValidHttpUrl=function isValidHttpUrl(url){return /^https?:\/\//i.test(url);};var openUrlWithFallback=function(){var _ref=(0,_asyncToGenerator2.default)(function*(url){try{yield _reactNative.Linking.openURL(url);return;}catch(primaryError){_logger.logger.warn("Primary URL open failed, trying browser fallback",{url:url,primaryError:primaryError instanceof Error?primaryError==null?void 0:primaryError.message:String(primaryError)});}yield _reactNative.Linking.openURL(`https://docs.google.com/viewer?url=${encodeURIComponent(url)}`);});return function openUrlWithFallback(_x){return _ref.apply(this,arguments);};}();var downloadOnAndroid=function(){var _ref2=(0,_asyncToGenerator2.default)(function*(url,filename){var blobUtil=getBlobUtilModule();if(!blobUtil){throw new Error("react-native-blob-util module not available on Android");}var fs=blobUtil.fs,config=blobUtil.config;var downloadPath=`${fs.dirs.DownloadDir}/${filename}`;yield config({fileCache:true,path:downloadPath,addAndroidDownloads:{useDownloadManager:true,notification:true,title:filename,description:"Downloading transcript",mime:"application/pdf",mediaScannable:true,path:downloadPath}}).fetch("GET",url);});return function downloadOnAndroid(_x2,_x3){return _ref2.apply(this,arguments);};}();var downloadOniOS=function(){var _ref3=(0,_asyncToGenerator2.default)(function*(url,filename){var blobUtil=getBlobUtilModule();if(!blobUtil){throw new Error("react-native-blob-util module not available on iOS");}var fs=blobUtil.fs,config=blobUtil.config;var iosPath=`${fs.dirs.DocumentDir}/${filename}`;yield config({fileCache:true,path:iosPath}).fetch("GET",url);yield _reactNative.Share.share({url:`file://${iosPath}`,message:filename,title:filename});});return function downloadOniOS(_x4,_x5){return _ref3.apply(this,arguments);};}();var downloadWithNativeStorage=function(){var _ref4=(0,_asyncToGenerator2.default)(function*(url,filename){var safeName=sanitizeFileName(filename);if(_reactNative.Platform.OS==="android"){yield downloadOnAndroid(url,safeName);return;}yield downloadOniOS(url,safeName);});return function downloadWithNativeStorage(_x6,_x7){return _ref4.apply(this,arguments);};}();var shouldUseInPlaceDownload=function shouldUseInPlaceDownload(downloadRequest){return(downloadRequest==null?void 0:downloadRequest.inPlace)===true;};var downloadFile=exports.downloadFile=function(){var _ref5=(0,_asyncToGenerator2.default)(function*(url,filename,inPlace){try{var normalizedUrl=normalizeUrl(url);_logger.logger.debug("Initiating file download",{url:normalizedUrl,filename:filename});if(!normalizedUrl||typeof normalizedUrl!=="string"){throw new Error("Invalid URL provided for download");}if(!isValidHttpUrl(normalizedUrl)){throw new Error("Download URL must be an http/https URL");}if(inPlace){try{yield downloadWithNativeStorage(normalizedUrl,filename);_logger.logger.debug("File downloaded with native storage flow");}catch(nativeDownloadError){_logger.logger.warn("Native download failed, falling back to URL open",{url:normalizedUrl,nativeDownloadError:nativeDownloadError instanceof Error?nativeDownloadError==null?void 0:nativeDownloadError.message:String(nativeDownloadError)});yield openUrlWithFallback(normalizedUrl);_logger.logger.debug("File download opened with fallback browser flow");}return;}yield openUrlWithFallback(normalizedUrl);_logger.logger.debug("File download opened with legacy URL flow");}catch(error){_logger.logger.error("File download failed",{url:url,filename:filename,error:error instanceof Error?error==null?void 0:error.message:String(error)});throw error;}});return function downloadFile(_x8,_x9,_x10){return _ref5.apply(this,arguments);};}();var handleDownloadRequest=exports.handleDownloadRequest=function(){var _ref6=(0,_asyncToGenerator2.default)(function*(downloadRequest){var url=downloadRequest.url,filename=downloadRequest.filename;if(!url){_logger.logger.error("Download request missing URL");return;}try{yield downloadFile(url,filename,shouldUseInPlaceDownload(downloadRequest));}catch(error){_logger.logger.error("Failed to handle download request",{downloadRequest:downloadRequest,error:error});}});return function handleDownloadRequest(_x11){return _ref6.apply(this,arguments);};}();
1
+ var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.handleDownloadRequest=exports.downloadFile=void 0;var _asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));var _reactNative=require("react-native");var _logger=require("./logger");var normalizeUrl=function normalizeUrl(url){return url==null?void 0:url.trim();};var sanitizeFileName=function sanitizeFileName(filename){var fallbackName=`chat-transcript-${Date.now()}.txt`;var trimmedName=filename==null?void 0:filename.trim();if(!trimmedName)return fallbackName;return trimmedName.replace(/[<>:"/\\|?*\x00-\x1F]/g,"_");};var isValidHttpUrl=function isValidHttpUrl(url){return /^https?:\/\//i.test(url);};var getNativeDownloadModule=function getNativeDownloadModule(){return(_reactNative.NativeModules==null?void 0:_reactNative.NativeModules.RobylonDownloadModule)||null;};var openUrlWithFallback=function(){var _ref=(0,_asyncToGenerator2.default)(function*(url){try{yield _reactNative.Linking.openURL(url);return;}catch(primaryError){_logger.logger.warn("Primary URL open failed, trying browser fallback",{url:url,primaryError:primaryError instanceof Error?primaryError==null?void 0:primaryError.message:String(primaryError)});}yield _reactNative.Linking.openURL(`https://docs.google.com/viewer?url=${encodeURIComponent(url)}`);});return function openUrlWithFallback(_x){return _ref.apply(this,arguments);};}();var downloadOnAndroid=function(){var _ref2=(0,_asyncToGenerator2.default)(function*(url,filename){var module=getNativeDownloadModule();if(!(module!=null&&module.downloadFile)){throw new Error("Robylon native download module is not linked on Android");}yield module.downloadFile(url,filename);});return function downloadOnAndroid(_x2,_x3){return _ref2.apply(this,arguments);};}();var downloadWithNativeStorage=function(){var _ref3=(0,_asyncToGenerator2.default)(function*(url,filename){var safeName=sanitizeFileName(filename);if(_reactNative.Platform.OS==="android"){yield downloadOnAndroid(url,safeName);return;}yield openUrlWithFallback(url);});return function downloadWithNativeStorage(_x4,_x5){return _ref3.apply(this,arguments);};}();var shouldUseInPlaceDownload=function shouldUseInPlaceDownload(downloadRequest){return(downloadRequest==null?void 0:downloadRequest.inPlace)===true;};var downloadFile=exports.downloadFile=function(){var _ref4=(0,_asyncToGenerator2.default)(function*(url,filename,inPlace){try{var normalizedUrl=normalizeUrl(url);_logger.logger.debug("Initiating file download",{url:normalizedUrl,filename:filename});if(!normalizedUrl||typeof normalizedUrl!=="string"){throw new Error("Invalid URL provided for download");}if(!isValidHttpUrl(normalizedUrl)){throw new Error("Download URL must be an http/https URL");}if(inPlace){try{yield downloadWithNativeStorage(normalizedUrl,filename);_logger.logger.debug("File downloaded with native storage flow");}catch(nativeDownloadError){_logger.logger.warn("Native download failed, falling back to URL open",{url:normalizedUrl,nativeDownloadError:nativeDownloadError instanceof Error?nativeDownloadError==null?void 0:nativeDownloadError.message:String(nativeDownloadError)});yield openUrlWithFallback(normalizedUrl);_logger.logger.debug("File download opened with fallback browser flow");}return;}yield openUrlWithFallback(normalizedUrl);_logger.logger.debug("File download opened with legacy URL flow");}catch(error){_logger.logger.error("File download failed",{url:url,filename:filename,error:error instanceof Error?error==null?void 0:error.message:String(error)});throw error;}});return function downloadFile(_x6,_x7,_x8){return _ref4.apply(this,arguments);};}();var handleDownloadRequest=exports.handleDownloadRequest=function(){var _ref5=(0,_asyncToGenerator2.default)(function*(downloadRequest){var url=downloadRequest.url,filename=downloadRequest.filename;if(!url){_logger.logger.error("Download request missing URL");return;}try{yield downloadFile(url,filename,shouldUseInPlaceDownload(downloadRequest));}catch(error){_logger.logger.error("Failed to handle download request",{downloadRequest:downloadRequest,error:error});}});return function handleDownloadRequest(_x9){return _ref5.apply(this,arguments);};}();
2
2
  //# sourceMappingURL=fileDownload.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","_logger","normalizeUrl","url","trim","sanitizeFileName","filename","fallbackName","Date","now","trimmedName","replace","getBlobUtilModule","_require","default","error","logger","warn","Error","message","String","isValidHttpUrl","test","openUrlWithFallback","_ref","_asyncToGenerator2","Linking","openURL","primaryError","encodeURIComponent","_x","apply","arguments","downloadOnAndroid","_ref2","blobUtil","fs","config","downloadPath","dirs","DownloadDir","fileCache","path","addAndroidDownloads","useDownloadManager","notification","title","description","mime","mediaScannable","fetch","_x2","_x3","downloadOniOS","_ref3","iosPath","DocumentDir","Share","share","_x4","_x5","downloadWithNativeStorage","_ref4","safeName","Platform","OS","_x6","_x7","shouldUseInPlaceDownload","downloadRequest","inPlace","downloadFile","exports","_ref5","normalizedUrl","debug","nativeDownloadError","_x8","_x9","_x10","handleDownloadRequest","_ref6","_x11"],"sourceRoot":"../../../src","sources":["utils/fileDownload.ts"],"mappings":"wSAKA,IAAAA,YAAA,CAAAC,OAAA,iBACA,IAAAC,OAAA,CAAAD,OAAA,aAQA,GAAM,CAAAE,YAAY,CAAG,QAAf,CAAAA,YAAYA,CAAIC,GAAW,CAAa,CAC5C,MAAO,CAAAA,GAAG,cAAHA,GAAG,CAAEC,IAAI,CAAC,CAAC,CACpB,CAAC,CAED,GAAM,CAAAC,gBAAgB,CAAG,QAAnB,CAAAA,gBAAgBA,CAAIC,QAAiB,CAAa,CACtD,GAAM,CAAAC,YAAY,CAAG,mBAAmBC,IAAI,CAACC,GAAG,CAAC,CAAC,MAAM,CACxD,GAAM,CAAAC,WAAW,CAAGJ,QAAQ,cAARA,QAAQ,CAAEF,IAAI,CAAC,CAAC,CACpC,GAAI,CAACM,WAAW,CAAE,MAAO,CAAAH,YAAY,CACrC,MAAO,CAAAG,WAAW,CAACC,OAAO,CAAC,wBAAwB,CAAE,GAAG,CAAC,CAC3D,CAAC,CAED,GAAM,CAAAC,iBAAiB,CAAG,QAApB,CAAAA,iBAAiBA,CAAA,CAAc,CACnC,GAAI,KAAAC,QAAA,CAGF,OAAAA,QAAA,CAAOb,OAAO,CAAC,wBAAwB,CAAC,eAAjCa,QAAA,CAAmCC,OAAO,CACnD,CAAE,MAAOC,KAAK,CAAE,CACdC,cAAM,CAACC,IAAI,CAAC,uCAAuC,CAAE,CACnDF,KAAK,CAAEA,KAAK,WAAY,CAAAG,KAAK,CAAGH,KAAK,cAALA,KAAK,CAAEI,OAAO,CAAGC,MAAM,CAACL,KAAK,CAC/D,CAAC,CAAC,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E,eAAe,CAAjClE,GAAG,CAAEG,QAAQ,CAAK+D,eAAe,CAA5B/D,QAAQ,CAErB,GAAI,CAACH,GAAG,CAAE,CACRa,cAAM,CAACD,KAAK,CAAC,8BAA8B,CAAC,CAC5C,OACF,CAEA,GAAI,CACF,KAAM,CAAAwD,YAAY,CAACpE,GAAG,CAAEG,QAAQ,CAAE8D,wBAAwB,CAACC,eAAe,CAAC,CAAC,CAC9E,CAAE,MAAOtD,KAAK,CAAE,CACdC,cAAM,CAACD,KAAK,CAAC,mCAAmC,CAAE,CAChDsD,eAAe,CAAfA,eAAe,CACftD,KAAK,CAALA,KACF,CAAC,CAAC,CAEJ,CACF,CAAC,iBAnBY,CAAAiE,qBAAqBA,CAAAE,IAAA,SAAAD,KAAA,CAAAlD,KAAA,MAAAC,SAAA,OAmBjC","ignoreList":[]}
1
+ {"version":3,"names":["_reactNative","require","_logger","normalizeUrl","url","trim","sanitizeFileName","filename","fallbackName","Date","now","trimmedName","replace","isValidHttpUrl","test","getNativeDownloadModule","NativeModules","RobylonDownloadModule","openUrlWithFallback","_ref","_asyncToGenerator2","default","Linking","openURL","primaryError","logger","warn","Error","message","String","encodeURIComponent","_x","apply","arguments","downloadOnAndroid","_ref2","module","downloadFile","_x2","_x3","downloadWithNativeStorage","_ref3","safeName","Platform","OS","_x4","_x5","shouldUseInPlaceDownload","downloadRequest","inPlace","exports","_ref4","normalizedUrl","debug","nativeDownloadError","error","_x6","_x7","_x8","handleDownloadRequest","_ref5","_x9"],"sourceRoot":"../../../src","sources":["utils/fileDownload.ts"],"mappings":"wSAKA,IAAAA,YAAA,CAAAC,OAAA,iBACA,IAAAC,OAAA,CAAAD,OAAA,aAQA,GAAM,CAAAE,YAAY,CAAG,QAAf,CAAAA,YAAYA,CAAIC,GAAW,CAAa,CAC5C,MAAO,CAAAA,GAAG,cAAHA,GAAG,CAAEC,IAAI,CAAC,CAAC,CACpB,CAAC,CAED,GAAM,CAAAC,gBAAgB,CAAG,QAAnB,CAAAA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,OAAO,CAAGC,MAAM,CAAC0B,KAAK,CAC/D,CAAC,CAAC,CACF,KAAM,CAAAA,KAAK,CACb,CACF,CAAC,iBA9CY,CAAAlB,YAAYA,CAAAmB,GAAA,CAAAC,GAAA,CAAAC,GAAA,SAAAP,KAAA,CAAAnB,KAAA,MAAAC,SAAA,OA8CxB,CAMM,GAAM,CAAA0B,qBAAqB,CAAAT,OAAA,CAAAS,qBAAA,gBAAAC,KAAA,IAAAxC,kBAAA,CAAAC,OAAA,EAAG,UACnC2B,eAAgC,CACd,CAClB,GAAQ,CAAA5C,GAAG,CAAe4C,eAAe,CAAjC5C,GAAG,CAAEG,QAAQ,CAAKyC,eAAe,CAA5BzC,QAAQ,CAErB,GAAI,CAACH,GAAG,CAAE,CACRqB,cAAM,CAAC8B,KAAK,CAAC,8BAA8B,CAAC,CAC5C,OACF,CAEA,GAAI,CACF,KAAM,CAAAlB,YAAY,CAACjC,GAAG,CAAEG,QAAQ,CAAEwC,wBAAwB,CAACC,eAAe,CAAC,CAAC,CAC9E,CAAE,MAAOO,KAAK,CAAE,CACd9B,cAAM,CAAC8B,KAAK,CAAC,mCAAmC,CAAE,CAChDP,eAAe,CAAfA,eAAe,CACfO,KAAK,CAALA,KACF,CAAC,CAAC,CAEJ,CACF,CAAC,iBAnBY,CAAAI,qBAAqBA,CAAAE,GAAA,SAAAD,KAAA,CAAA5B,KAAA,MAAAC,SAAA,OAmBjC","ignoreList":[]}
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,"__esModule",{value:true});exports.SDK_VERSION=void 0;var SDK_VERSION=exports.SDK_VERSION='2.0.31-staging.1';
1
+ Object.defineProperty(exports,"__esModule",{value:true});exports.SDK_VERSION=void 0;var SDK_VERSION=exports.SDK_VERSION='2.0.31-staging.3';
2
2
  //# sourceMappingURL=version.staging.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fileDownload.d.ts","sourceRoot":"","sources":["../../../src/utils/fileDownload.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAuGD;;;;GAIG;AACH,eAAO,MAAM,YAAY,QAClB,MAAM,aACA,MAAM,YACP,OAAO,KAChB,QAAQ,IAAI,CA0Cd,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,qBAAqB,oBACf,eAAe,KAC/B,QAAQ,IAAI,CAiBd,CAAC"}
1
+ {"version":3,"file":"fileDownload.d.ts","sourceRoot":"","sources":["../../../src/utils/fileDownload.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAkED;;;;GAIG;AACH,eAAO,MAAM,YAAY,QAClB,MAAM,aACA,MAAM,YACP,OAAO,KAChB,QAAQ,IAAI,CA0Cd,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,qBAAqB,oBACf,eAAe,KAC/B,QAAQ,IAAI,CAiBd,CAAC"}
@@ -1,2 +1,2 @@
1
- export declare const SDK_VERSION = "2.0.31-staging.1";
1
+ export declare const SDK_VERSION = "2.0.31-staging.3";
2
2
  //# sourceMappingURL=version.staging.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@robylon/react-native-sdk",
3
- "version": "2.0.31-staging.1",
3
+ "version": "2.0.31-staging.3",
4
4
  "description": "React Native SDK for Robylon",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "module": "lib/module/index.js",
@@ -82,8 +82,5 @@
82
82
  "commit-msg": "sh scripts/validate-branch-name.sh",
83
83
  "post-checkout": "node scripts/prevent-direct-branch.js"
84
84
  }
85
- },
86
- "dependencies": {
87
- "react-native-blob-util": "^0.24.7"
88
85
  }
89
86
  }
@@ -3,7 +3,7 @@
3
3
  * Utility functions for handling file downloads
4
4
  */
5
5
 
6
- import { Linking, Platform, Share } from "react-native";
6
+ import { Linking, NativeModules, Platform } from "react-native";
7
7
  import { logger } from "./logger";
8
8
 
9
9
  export interface DownloadRequest {
@@ -17,29 +17,24 @@ const normalizeUrl = (url: string): string => {
17
17
  };
18
18
 
19
19
  const sanitizeFileName = (filename?: string): string => {
20
- const fallbackName = `chat-transcript-${Date.now()}.pdf`;
20
+ const fallbackName = `chat-transcript-${Date.now()}.txt`;
21
21
  const trimmedName = filename?.trim();
22
22
  if (!trimmedName) return fallbackName;
23
23
  return trimmedName.replace(/[<>:"/\\|?*\x00-\x1F]/g, "_");
24
24
  };
25
25
 
26
- const getBlobUtilModule = (): any => {
27
- try {
28
- // Lazy load so consumers without native linking don't crash at startup.
29
- // eslint-disable-next-line @typescript-eslint/no-var-requires
30
- return require("react-native-blob-util")?.default;
31
- } catch (error) {
32
- logger.warn("react-native-blob-util is unavailable", {
33
- error: error instanceof Error ? error?.message : String(error),
34
- });
35
- return null;
36
- }
26
+ type RobylonDownloadNativeModule = {
27
+ downloadFile: (url: string, filename: string) => Promise<string>;
37
28
  };
38
29
 
39
30
  const isValidHttpUrl = (url: string): boolean => {
40
31
  return /^https?:\/\//i.test(url);
41
32
  };
42
33
 
34
+ const getNativeDownloadModule = (): RobylonDownloadNativeModule | null => {
35
+ return (NativeModules?.RobylonDownloadModule as RobylonDownloadNativeModule) || null;
36
+ };
37
+
43
38
  const openUrlWithFallback = async (url: string): Promise<void> => {
44
39
  try {
45
40
  await Linking.openURL(url);
@@ -58,43 +53,11 @@ const openUrlWithFallback = async (url: string): Promise<void> => {
58
53
  };
59
54
 
60
55
  const downloadOnAndroid = async (url: string, filename: string): Promise<void> => {
61
- const blobUtil = getBlobUtilModule();
62
- if (!blobUtil) {
63
- throw new Error("react-native-blob-util module not available on Android");
64
- }
65
- const { fs, config } = blobUtil;
66
- const downloadPath = `${fs.dirs.DownloadDir}/${filename}`;
67
- await config({
68
- fileCache: true,
69
- path: downloadPath,
70
- addAndroidDownloads: {
71
- useDownloadManager: true,
72
- notification: true,
73
- title: filename,
74
- description: "Downloading transcript",
75
- mime: "application/pdf",
76
- mediaScannable: true,
77
- path: downloadPath,
78
- },
79
- }).fetch("GET", url);
80
- };
81
-
82
- const downloadOniOS = async (url: string, filename: string): Promise<void> => {
83
- const blobUtil = getBlobUtilModule();
84
- if (!blobUtil) {
85
- throw new Error("react-native-blob-util module not available on iOS");
56
+ const module = getNativeDownloadModule();
57
+ if (!module?.downloadFile) {
58
+ throw new Error("Robylon native download module is not linked on Android");
86
59
  }
87
- const { fs, config } = blobUtil;
88
- const iosPath = `${fs.dirs.DocumentDir}/${filename}`;
89
- await config({
90
- fileCache: true,
91
- path: iosPath,
92
- }).fetch("GET", url);
93
- await Share.share({
94
- url: `file://${iosPath}`,
95
- message: filename,
96
- title: filename,
97
- });
60
+ await module.downloadFile(url, filename);
98
61
  };
99
62
 
100
63
  const downloadWithNativeStorage = async (
@@ -106,7 +69,7 @@ const downloadWithNativeStorage = async (
106
69
  await downloadOnAndroid(url, safeName);
107
70
  return;
108
71
  }
109
- await downloadOniOS(url, safeName);
72
+ await openUrlWithFallback(url);
110
73
  };
111
74
 
112
75
  const shouldUseInPlaceDownload = (downloadRequest?: DownloadRequest): boolean => {
@@ -1,2 +1,2 @@
1
1
  // This file is auto-generated. Do not modify it manually.
2
- export const SDK_VERSION = '2.0.31-staging.1';
2
+ export const SDK_VERSION = '2.0.31-staging.3';