@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.
- package/android/build.gradle +35 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/java/com/robylonreactnativesdk/RobylonDownloadModule.java +83 -0
- package/android/src/main/java/com/robylonreactnativesdk/RobylonReactNativeSdkPackage.java +24 -0
- package/lib/commonjs/utils/fileDownload.js +1 -1
- package/lib/commonjs/utils/fileDownload.js.map +1 -1
- package/lib/commonjs/versions/version.staging.js +1 -1
- package/lib/module/openChatbot.js +2 -1
- package/lib/module/openChatbot.js.map +1 -1
- package/lib/module/utils/fileDownload.js +1 -1
- package/lib/module/utils/fileDownload.js.map +1 -1
- package/lib/module/versions/version.staging.js +1 -1
- package/lib/typescript/utils/fileDownload.d.ts.map +1 -1
- package/lib/typescript/versions/version.staging.d.ts +1 -1
- package/package.json +1 -4
- package/src/utils/fileDownload.ts +32 -59
- package/src/versions/version.staging.ts +1 -1
|
@@ -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,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
|
|
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","
|
|
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,CAAA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,CAAe0D,eAAe,CAAjC1D,GAAG,CAAEe,QAAQ,CAAK2C,eAAe,CAA5B3C,QAAQ,CAErB,GAAI,CAACf,GAAG,CAAE,CACRmC,cAAM,CAAC8B,KAAK,CAAC,8BAA8B,CAAC,CAC5C,OACF,CAEA,GAAI,CACF,KAAM,CAAAlB,YAAY,CAAC/C,GAAG,CAAEe,QAAQ,CAAE0C,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
|
+
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
|
-
|
|
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":[
|
|
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
|
|
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","
|
|
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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CAAHA,GAAG,CACHe,QAAQ,CAARA,QAAQ,CACRkD,KAAK,CAAEA,KAAK,WAAY,CAAA5B,KAAK,CAAG4B,KAAK,cAALA,KAAK,CAAE3B,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,CAAA1D,GAAG,CAAe0D,eAAe,CAAjC1D,GAAG,CAAEe,QAAQ,CAAK2C,eAAe,CAA5B3C,QAAQ,CAErB,GAAI,CAACf,GAAG,CAAE,CACRmC,cAAM,CAAC8B,KAAK,CAAC,8BAA8B,CAAC,CAC5C,OACF,CAEA,GAAI,CACF,KAAM,CAAAlB,YAAY,CAAC/C,GAAG,CAAEe,QAAQ,CAAE0C,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
|
+
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;
|
|
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.
|
|
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.
|
|
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
|
|
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
|
|
20
|
-
const
|
|
21
|
-
|
|
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
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
|
68
|
-
if (!
|
|
69
|
-
throw new Error("
|
|
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
|
-
|
|
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 =
|
|
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
|
|
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
|
+
export const SDK_VERSION = '2.0.31-staging.4';
|