@robylon/react-native-sdk 2.0.31-staging.2 → 2.0.31-staging.4

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(){var hasNativeBlobUtil=!!(_reactNative.NativeModules!=null&&_reactNative.NativeModules.ReactNativeBlobUtil);if(!hasNativeBlobUtil){_logger.logger.warn("react-native-blob-util native module is not linked");return null;}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 getUrlPathTail=function getUrlPathTail(url){var _url$split,_cleanedUrl$split,_cleanedUrl$split$pop;var cleanedUrl=(url==null?void 0:(_url$split=url.split("?"))==null?void 0:_url$split[0])||"";return(cleanedUrl==null?void 0:(_cleanedUrl$split=cleanedUrl.split("/"))==null?void 0:(_cleanedUrl$split$pop=_cleanedUrl$split.pop())==null?void 0:_cleanedUrl$split$pop.trim())||"";};var getExtensionFromName=function getExtensionFromName(name){if(!(name!=null&&name.includes(".")))return"";return name.substring(name.lastIndexOf("."));};var resolveDownloadFileName=function resolveDownloadFileName(filename,url){var trimmedName=filename==null?void 0:filename.trim();if(trimmedName){var sanitizedName=trimmedName.replace(/[<>:"/\\|?*\x00-\x1F]/g,"_");var urlExtension=getExtensionFromName(getUrlPathTail(url));if(getExtensionFromName(sanitizedName)||!urlExtension)return sanitizedName;return`${sanitizedName}${urlExtension}`;}var tailName=getUrlPathTail(url);if(tailName)return tailName.replace(/[<>:"/\\|?*\x00-\x1F]/g,"_");return`chat-transcript-${Date.now()}.pdf`;};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=resolveDownloadFileName(filename,url);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","hasNativeBlobUtil","NativeModules","ReactNativeBlobUtil","logger","warn","_require","default","error","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,GAAM,CAAAC,iBAAiB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AG,CAAHA,GAAG,CACHG,QAAQ,CAARA,QAAQ,CACRc,KAAK,CAAEA,KAAK,WAAY,CAAAC,KAAK,CAAGD,KAAK,cAALA,KAAK,CAAEE,OAAO,CAAGC,MAAM,CAACH,KAAK,CAC/D,CAAC,CAAC,CACF,KAAM,CAAAA,KAAK,CACb,CACF,CAAC,iBA9CY,CAAAsD,YAAYA,CAAAM,GAAA,CAAAC,GAAA,CAAAC,IAAA,SAAAN,KAAA,CAAA1C,KAAA,MAAAC,SAAA,OA8CxB,CAMM,GAAM,CAAAgD,qBAAqB,CAAAR,OAAA,CAAAQ,qBAAA,gBAAAC,KAAA,IAAAxD,kBAAA,CAAAT,OAAA,EAAG,UACnCqD,eAAgC,CACd,CAClB,GAAQ,CAAArE,GAAG,CAAeqE,eAAe,CAAjCrE,GAAG,CAAEG,QAAQ,CAAKkE,eAAe,CAA5BlE,QAAQ,CAErB,GAAI,CAACH,GAAG,CAAE,CACRa,cAAM,CAACI,KAAK,CAAC,8BAA8B,CAAC,CAC5C,OACF,CAEA,GAAI,CACF,KAAM,CAAAsD,YAAY,CAACvE,GAAG,CAAEG,QAAQ,CAAEiE,wBAAwB,CAACC,eAAe,CAAC,CAAC,CAC9E,CAAE,MAAOpD,KAAK,CAAE,CACdJ,cAAM,CAACI,KAAK,CAAC,mCAAmC,CAAE,CAChDoD,eAAe,CAAfA,eAAe,CACfpD,KAAK,CAALA,KACF,CAAC,CAAC,CAEJ,CACF,CAAC,iBAnBY,CAAA+D,qBAAqBA,CAAAE,IAAA,SAAAD,KAAA,CAAAlD,KAAA,MAAAC,SAAA,OAmBjC","ignoreList":[]}
1
+ {"version":3,"names":["_reactNative","require","_logger","normalizeUrl","url","trim","getUrlPathTail","_url$split","_cleanedUrl$split","_cleanedUrl$split$pop","cleanedUrl","split","pop","getExtensionFromName","name","includes","substring","lastIndexOf","resolveDownloadFileName","filename","trimmedName","sanitizedName","replace","urlExtension","tailName","Date","now","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,cAAc,CAAG,QAAjB,CAAAA,cAAcA,CAAIF,GAAY,CAAa,KAAAG,UAAA,CAAAC,iBAAA,CAAAC,qBAAA,CAC/C,GAAM,CAAAC,UAAU,CAAG,CAAAN,GAAG,eAAAG,UAAA,CAAHH,GAAG,CAAEO,KAAK,CAAC,GAAG,CAAC,eAAfJ,UAAA,CAAkB,CAAC,CAAC,GAAI,EAAE,CAC7C,MAAO,CAAAG,UAAU,eAAAF,iBAAA,CAAVE,UAAU,CAAEC,KAAK,CAAC,GAAG,CAAC,gBAAAF,qBAAA,CAAtBD,iBAAA,CAAwBI,GAAG,CAAC,CAAC,eAA7BH,qBAAA,CAA+BJ,IAAI,CAAC,CAAC,GAAI,EAAE,CACpD,CAAC,CAED,GAAM,CAAAQ,oBAAoB,CAAG,QAAvB,CAAAA,oBAAoBA,CAAIC,IAAa,CAAa,CACtD,GAAI,EAACA,IAAI,QAAJA,IAAI,CAAEC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAO,EAAE,CACnC,MAAO,CAAAD,IAAI,CAACE,SAAS,CAACF,I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F,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.2';
1
+ Object.defineProperty(exports,"__esModule",{value:true});exports.SDK_VERSION=void 0;var SDK_VERSION=exports.SDK_VERSION='2.0.31-staging.4';
2
2
  //# sourceMappingURL=version.staging.js.map
@@ -1,2 +1,3 @@
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);};
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
3
  //# sourceMappingURL=openChatbot.js.map
@@ -1 +1 @@
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
+ {"version":3,"names":[],"sourceRoot":"../../src","sources":["openChatbot.tsx"],"mappings":"","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(){var hasNativeBlobUtil=!!(_reactNative.NativeModules!=null&&_reactNative.NativeModules.ReactNativeBlobUtil);if(!hasNativeBlobUtil){_logger.logger.warn("react-native-blob-util native module is not linked");return null;}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 getUrlPathTail=function getUrlPathTail(url){var _url$split,_cleanedUrl$split,_cleanedUrl$split$pop;var cleanedUrl=(url==null?void 0:(_url$split=url.split("?"))==null?void 0:_url$split[0])||"";return(cleanedUrl==null?void 0:(_cleanedUrl$split=cleanedUrl.split("/"))==null?void 0:(_cleanedUrl$split$pop=_cleanedUrl$split.pop())==null?void 0:_cleanedUrl$split$pop.trim())||"";};var getExtensionFromName=function getExtensionFromName(name){if(!(name!=null&&name.includes(".")))return"";return name.substring(name.lastIndexOf("."));};var resolveDownloadFileName=function resolveDownloadFileName(filename,url){var trimmedName=filename==null?void 0:filename.trim();if(trimmedName){var sanitizedName=trimmedName.replace(/[<>:"/\\|?*\x00-\x1F]/g,"_");var urlExtension=getExtensionFromName(getUrlPathTail(url));if(getExtensionFromName(sanitizedName)||!urlExtension)return sanitizedName;return`${sanitizedName}${urlExtension}`;}var tailName=getUrlPathTail(url);if(tailName)return tailName.replace(/[<>:"/\\|?*\x00-\x1F]/g,"_");return`chat-transcript-${Date.now()}.pdf`;};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=resolveDownloadFileName(filename,url);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","hasNativeBlobUtil","NativeModules","ReactNativeBlobUtil","logger","warn","_require","default","error","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,GAAM,CAAAC,iBAAiB,CAAG,CAAC,EAACC,0BAAa,Q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,CAARA,QAAQ,CACRc,KAAK,CAAEA,KAAK,WAAY,CAAAC,KAAK,CAAGD,KAAK,cAALA,KAAK,CAAEE,OAAO,CAAGC,MAAM,CAACH,KAAK,CAC/D,CAAC,CAAC,CACF,KAAM,CAAAA,KAAK,CACb,CACF,CAAC,iBA9CY,CAAAsD,YAAYA,CAAAM,GAAA,CAAAC,GAAA,CAAAC,IAAA,SAAAN,KAAA,CAAA1C,KAAA,MAAAC,SAAA,OA8CxB,CAMM,GAAM,CAAAgD,qBAAqB,CAAAR,OAAA,CAAAQ,qBAAA,gBAAAC,KAAA,IAAAxD,kBAAA,CAAAT,OAAA,EAAG,UACnCqD,eAAgC,CACd,CAClB,GAAQ,CAAArE,GAAG,CAAeqE,eAAe,CAAjCrE,GAAG,CAAEG,QAAQ,CAAKkE,eAAe,CAA5BlE,QAAQ,CAErB,GAAI,CAACH,GAAG,CAAE,CACRa,cAAM,CAACI,KAAK,CAAC,8BAA8B,CAAC,CAC5C,OACF,CAEA,GAAI,CACF,KAAM,CAAAsD,YAAY,CAACvE,GAAG,CAAEG,QAAQ,CAAEiE,wBAAwB,CAACC,eAAe,CAAC,CAAC,CAC9E,CAAE,MAAOpD,KAAK,CAAE,CACdJ,cAAM,CAACI,KAAK,CAAC,mCAAmC,CAAE,CAChDoD,eAAe,CAAfA,eAAe,CACfpD,KAAK,CAALA,KACF,CAAC,CAAC,CAEJ,CACF,CAAC,iBAnBY,CAAA+D,qBAAqBA,CAAAE,IAAA,SAAAD,KAAA,CAAAlD,KAAA,MAAAC,SAAA,OAmBjC","ignoreList":[]}
1
+ {"version":3,"names":["_reactNative","require","_logger","normalizeUrl","url","trim","getUrlPathTail","_url$split","_cleanedUrl$split","_cleanedUrl$split$pop","cleanedUrl","split","pop","getExtensionFromName","name","includes","substring","lastIndexOf","resolveDownloadFileName","filename","trimmedName","sanitizedName","replace","urlExtension","tailName","Date","now","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,cAAc,CAAG,QAAjB,CAAAA,cAAcA,CAAIF,GAAY,CAAa,KAAAG,UAAA,CAAAC,iBAAA,CAAAC,qBAAA,CAC/C,GAAM,CAAAC,UAAU,CAAG,CAAAN,GAAG,eAAAG,UAAA,CAAHH,GAAG,CAAEO,KAAK,CAAC,GAAG,CAAC,eAAfJ,UAAA,CAAkB,CAAC,CAAC,GAAI,EAAE,CAC7C,MAAO,CAAAG,UAAU,eAAAF,iBAAA,CAAVE,UAAU,CAAEC,KAAK,CAAC,GAAG,CAAC,gBAAAF,qBAAA,CAAtBD,iBAAA,CAAwBI,GAAG,CAAC,CAAC,eAA7BH,qBAAA,CAA+BJ,IAAI,CAAC,CAAC,GAAI,EAAE,CACpD,CAAC,CAED,GAAM,CAAAQ,oBAAoB,CAAG,QAAvB,CAAAA,oBAAoBA,CAAIC,IAAa,CAAa,CACtD,GAAI,EAACA,IAAI,QAAJA,IAAI,CAAEC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAO,EAAE,CACnC,MAAO,CAAAD,IAAI,CAACE,SAAS,CAACF,IAAI,CAACG,WAAW,CAAC,GAAG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AAC,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.2';
1
+ Object.defineProperty(exports,"__esModule",{value:true});exports.SDK_VERSION=void 0;var SDK_VERSION=exports.SDK_VERSION='2.0.31-staging.4';
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;AA6GD;;;;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;AAkFD;;;;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.2";
1
+ export declare const SDK_VERSION = "2.0.31-staging.4";
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.2",
3
+ "version": "2.0.31-staging.4",
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, NativeModules, 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 {
@@ -16,36 +16,41 @@ const normalizeUrl = (url: string): string => {
16
16
  return url?.trim();
17
17
  };
18
18
 
19
- const sanitizeFileName = (filename?: string): string => {
20
- const fallbackName = `chat-transcript-${Date.now()}.pdf`;
21
- const trimmedName = filename?.trim();
22
- if (!trimmedName) return fallbackName;
23
- return trimmedName.replace(/[<>:"/\\|?*\x00-\x1F]/g, "_");
19
+ const getUrlPathTail = (url?: string): string => {
20
+ const cleanedUrl = url?.split("?")?.[0] || "";
21
+ return cleanedUrl?.split("/")?.pop()?.trim() || "";
24
22
  };
25
23
 
26
- const getBlobUtilModule = (): any => {
27
- const hasNativeBlobUtil = !!NativeModules?.ReactNativeBlobUtil;
28
- if (!hasNativeBlobUtil) {
29
- logger.warn("react-native-blob-util native module is not linked");
30
- return null;
31
- }
24
+ const getExtensionFromName = (name?: string): string => {
25
+ if (!name?.includes(".")) return "";
26
+ return name.substring(name.lastIndexOf("."));
27
+ };
32
28
 
33
- try {
34
- // Lazy load so consumers without native linking don't crash at startup.
35
- // eslint-disable-next-line @typescript-eslint/no-var-requires
36
- return require("react-native-blob-util")?.default;
37
- } catch (error) {
38
- logger.warn("react-native-blob-util is unavailable", {
39
- error: error instanceof Error ? error?.message : String(error),
40
- });
41
- return null;
29
+ const resolveDownloadFileName = (filename?: string, url?: string): string => {
30
+ const trimmedName = filename?.trim();
31
+ if (trimmedName) {
32
+ const sanitizedName = trimmedName.replace(/[<>:"/\\|?*\x00-\x1F]/g, "_");
33
+ const urlExtension = getExtensionFromName(getUrlPathTail(url));
34
+ if (getExtensionFromName(sanitizedName) || !urlExtension) return sanitizedName;
35
+ return `${sanitizedName}${urlExtension}`;
42
36
  }
37
+ const tailName = getUrlPathTail(url);
38
+ if (tailName) return tailName.replace(/[<>:"/\\|?*\x00-\x1F]/g, "_");
39
+ return `chat-transcript-${Date.now()}.pdf`;
40
+ };
41
+
42
+ type RobylonDownloadNativeModule = {
43
+ downloadFile: (url: string, filename: string) => Promise<string>;
43
44
  };
44
45
 
45
46
  const isValidHttpUrl = (url: string): boolean => {
46
47
  return /^https?:\/\//i.test(url);
47
48
  };
48
49
 
50
+ const getNativeDownloadModule = (): RobylonDownloadNativeModule | null => {
51
+ return (NativeModules?.RobylonDownloadModule as RobylonDownloadNativeModule) || null;
52
+ };
53
+
49
54
  const openUrlWithFallback = async (url: string): Promise<void> => {
50
55
  try {
51
56
  await Linking.openURL(url);
@@ -64,55 +69,23 @@ const openUrlWithFallback = async (url: string): Promise<void> => {
64
69
  };
65
70
 
66
71
  const downloadOnAndroid = async (url: string, filename: string): Promise<void> => {
67
- const blobUtil = getBlobUtilModule();
68
- if (!blobUtil) {
69
- throw new Error("react-native-blob-util module not available on Android");
70
- }
71
- const { fs, config } = blobUtil;
72
- const downloadPath = `${fs.dirs.DownloadDir}/${filename}`;
73
- await config({
74
- fileCache: true,
75
- path: downloadPath,
76
- addAndroidDownloads: {
77
- useDownloadManager: true,
78
- notification: true,
79
- title: filename,
80
- description: "Downloading transcript",
81
- mime: "application/pdf",
82
- mediaScannable: true,
83
- path: downloadPath,
84
- },
85
- }).fetch("GET", url);
86
- };
87
-
88
- const downloadOniOS = async (url: string, filename: string): Promise<void> => {
89
- const blobUtil = getBlobUtilModule();
90
- if (!blobUtil) {
91
- throw new Error("react-native-blob-util module not available on iOS");
72
+ const module = getNativeDownloadModule();
73
+ if (!module?.downloadFile) {
74
+ throw new Error("Robylon native download module is not linked on Android");
92
75
  }
93
- const { fs, config } = blobUtil;
94
- const iosPath = `${fs.dirs.DocumentDir}/${filename}`;
95
- await config({
96
- fileCache: true,
97
- path: iosPath,
98
- }).fetch("GET", url);
99
- await Share.share({
100
- url: `file://${iosPath}`,
101
- message: filename,
102
- title: filename,
103
- });
76
+ await module.downloadFile(url, filename);
104
77
  };
105
78
 
106
79
  const downloadWithNativeStorage = async (
107
80
  url: string,
108
81
  filename?: string
109
82
  ): Promise<void> => {
110
- const safeName = sanitizeFileName(filename);
83
+ const safeName = resolveDownloadFileName(filename, url);
111
84
  if (Platform.OS === "android") {
112
85
  await downloadOnAndroid(url, safeName);
113
86
  return;
114
87
  }
115
- await downloadOniOS(url, safeName);
88
+ await openUrlWithFallback(url);
116
89
  };
117
90
 
118
91
  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.2';
2
+ export const SDK_VERSION = '2.0.31-staging.4';