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

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,5 @@
1
+ #import <React/RCTBridgeModule.h>
2
+
3
+ @interface RobylonDownloadModule : NSObject <RCTBridgeModule>
4
+
5
+ @end
@@ -0,0 +1,124 @@
1
+ #import "RobylonDownloadModule.h"
2
+
3
+ #import <React/RCTUtils.h>
4
+ #import <UIKit/UIKit.h>
5
+
6
+ @implementation RobylonDownloadModule
7
+
8
+ RCT_EXPORT_MODULE();
9
+
10
+ - (dispatch_queue_t)methodQueue
11
+ {
12
+ return dispatch_get_main_queue();
13
+ }
14
+
15
+ RCT_REMAP_METHOD(downloadFile,
16
+ downloadFileWithUrl:(NSString *)url
17
+ filename:(NSString *)filename
18
+ resolver:(RCTPromiseResolveBlock)resolve
19
+ rejecter:(RCTPromiseRejectBlock)reject)
20
+ {
21
+ if (url == nil || url.length == 0) {
22
+ reject(@"INVALID_URL", @"Download URL is missing", nil);
23
+ return;
24
+ }
25
+
26
+ NSURL *downloadURL = [NSURL URLWithString:url];
27
+ if (downloadURL == nil) {
28
+ reject(@"INVALID_URL", @"Download URL is invalid", nil);
29
+ return;
30
+ }
31
+
32
+ NSURLSessionDownloadTask *task = [[NSURLSession sharedSession]
33
+ downloadTaskWithURL:downloadURL
34
+ completionHandler:^(NSURL * _Nullable location, NSURLResponse * _Nullable response, NSError * _Nullable error) {
35
+ if (error != nil) {
36
+ reject(@"DOWNLOAD_FAILED", @"Failed to download file", error);
37
+ return;
38
+ }
39
+
40
+ if (location == nil) {
41
+ reject(@"DOWNLOAD_FAILED", @"Downloaded file location is empty", nil);
42
+ return;
43
+ }
44
+
45
+ NSString *resolvedName = [self resolvedFileName:filename response:response url:downloadURL];
46
+ NSString *targetPath = [NSTemporaryDirectory() stringByAppendingPathComponent:resolvedName];
47
+ NSURL *targetURL = [NSURL fileURLWithPath:targetPath];
48
+
49
+ [[NSFileManager defaultManager] removeItemAtURL:targetURL error:nil];
50
+
51
+ NSError *moveError = nil;
52
+ [[NSFileManager defaultManager] moveItemAtURL:location toURL:targetURL error:&moveError];
53
+ if (moveError != nil) {
54
+ reject(@"FILE_MOVE_FAILED", @"Failed to move downloaded file", moveError);
55
+ return;
56
+ }
57
+
58
+ dispatch_async(dispatch_get_main_queue(), ^{
59
+ UIViewController *rootViewController = RCTPresentedViewController();
60
+ if (rootViewController == nil) {
61
+ reject(@"VIEW_CONTROLLER_MISSING", @"Unable to open iOS share sheet", nil);
62
+ return;
63
+ }
64
+
65
+ UIActivityViewController *activityController =
66
+ [[UIActivityViewController alloc] initWithActivityItems:@[ targetURL ] applicationActivities:nil];
67
+
68
+ UIPopoverPresentationController *popover = activityController.popoverPresentationController;
69
+ if (popover != nil) {
70
+ popover.sourceView = rootViewController.view;
71
+ popover.sourceRect = CGRectMake(rootViewController.view.bounds.size.width / 2.0,
72
+ rootViewController.view.bounds.size.height / 2.0,
73
+ 1,
74
+ 1);
75
+ }
76
+
77
+ [rootViewController presentViewController:activityController animated:YES completion:^{
78
+ resolve(resolvedName);
79
+ }];
80
+ });
81
+ }];
82
+
83
+ [task resume];
84
+ }
85
+
86
+ - (NSString *)resolvedFileName:(NSString *)filename response:(NSURLResponse *)response url:(NSURL *)url
87
+ {
88
+ NSString *cleanName = [self sanitizedName:filename];
89
+ if (cleanName.length > 0) {
90
+ NSString *urlExtension = [url.path pathExtension];
91
+ NSString *nameExtension = [cleanName pathExtension];
92
+ if (nameExtension.length == 0 && urlExtension.length > 0) {
93
+ return [cleanName stringByAppendingFormat:@".%@", urlExtension];
94
+ }
95
+ return cleanName;
96
+ }
97
+
98
+ NSString *suggested = [self sanitizedName:response.suggestedFilename];
99
+ if (suggested.length > 0) {
100
+ return suggested;
101
+ }
102
+
103
+ NSString *lastPath = [self sanitizedName:url.lastPathComponent];
104
+ if (lastPath.length > 0) {
105
+ return lastPath;
106
+ }
107
+
108
+ return [NSString stringWithFormat:@"download-%f", [[NSDate date] timeIntervalSince1970]];
109
+ }
110
+
111
+ - (NSString *)sanitizedName:(NSString *)name
112
+ {
113
+ if (name == nil || name.length == 0) {
114
+ return @"";
115
+ }
116
+
117
+ NSCharacterSet *invalidCharacters =
118
+ [NSCharacterSet characterSetWithCharactersInString:@"/\\?%*|\"<>:"];
119
+ NSArray<NSString *> *parts = [name componentsSeparatedByCharactersInSet:invalidCharacters];
120
+ NSString *joined = [parts componentsJoinedByString:@"_"];
121
+ return [joined stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
122
+ }
123
+
124
+ @end
@@ -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 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);};}();
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`download-robylon-${Date.now()}`;};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 downloadOniOS=function(){var _ref3=(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 iOS");}yield module.downloadFile(url,filename);});return function downloadOniOS(_x4,_x5){return _ref3.apply(this,arguments);};}();var downloadWithNativeStorage=function(){var _ref4=(0,_asyncToGenerator2.default)(function*(url,filename){var safeName=resolveDownloadFileName(filename,url);if(_reactNative.Platform.OS==="android"){yield downloadOnAndroid(url,safeName);return;}if(_reactNative.Platform.OS==="ios"){yield downloadOniOS(url,safeName);return;}yield openUrlWithFallback(url);});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);};}();
2
2
  //# sourceMappingURL=fileDownload.js.map
@@ -1 +1 @@
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,E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AAE,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
+ {"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","downloadOniOS","_ref3","_x4","_x5","downloadWithNativeStorage","_ref4","safeName","Platform","OS","_x6","_x7","shouldUseInPlaceDownload","downloadRequest","inPlace","exports","_ref5","normalizedUrl","debug","nativeDownloadError","error","_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,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,GA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perty(exports,"__esModule",{value:true});exports.SDK_VERSION=void 0;var SDK_VERSION=exports.SDK_VERSION='2.0.31-staging.4';
1
+ Object.defineProperty(exports,"__esModule",{value:true});exports.SDK_VERSION=void 0;var SDK_VERSION=exports.SDK_VERSION='2.0.31-staging.5';
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 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);};}();
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`download-robylon-${Date.now()}`;};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 downloadOniOS=function(){var _ref3=(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 iOS");}yield module.downloadFile(url,filename);});return function downloadOniOS(_x4,_x5){return _ref3.apply(this,arguments);};}();var downloadWithNativeStorage=function(){var _ref4=(0,_asyncToGenerator2.default)(function*(url,filename){var safeName=resolveDownloadFileName(filename,url);if(_reactNative.Platform.OS==="android"){yield downloadOnAndroid(url,safeName);return;}if(_reactNative.Platform.OS==="ios"){yield downloadOniOS(url,safeName);return;}yield openUrlWithFallback(url);});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);};}();
2
2
  //# sourceMappingURL=fileDownload.js.map
@@ -1 +1 @@
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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K,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
+ {"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","downloadOniOS","_ref3","_x4","_x5","downloadWithNativeStorage","_ref4","safeName","Platform","OS","_x6","_x7","shouldUseInPlaceDownload","downloadRequest","inPlace","exports","_ref5","normalizedUrl","debug","nativeDownloadError","error","_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,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,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ION=exports.SDK_VERSION='2.0.31-staging.4';
1
+ Object.defineProperty(exports,"__esModule",{value:true});exports.SDK_VERSION=void 0;var SDK_VERSION=exports.SDK_VERSION='2.0.31-staging.5';
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;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
+ {"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;AAyGD;;;;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,CAqBd,CAAC"}
@@ -1,2 +1,2 @@
1
- export declare const SDK_VERSION = "2.0.31-staging.4";
1
+ export declare const SDK_VERSION = "2.0.31-staging.5";
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.4",
3
+ "version": "2.0.31-staging.5",
4
4
  "description": "React Native SDK for Robylon",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "module": "lib/module/index.js",
@@ -0,0 +1,18 @@
1
+ require "json"
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = "robylon-react-native-sdk"
7
+ s.version = package["version"]
8
+ s.summary = package["description"]
9
+ s.license = package["license"]
10
+ s.authors = package["author"]
11
+ s.homepage = "https://github.com/OneWorldNation/robylon-react-native-sdk"
12
+ s.platforms = { :ios => "13.0" }
13
+ s.source = { :git => "https://github.com/OneWorldNation/robylon-react-native-sdk.git", :tag => "#{s.version}" }
14
+
15
+ s.source_files = "ios/**/*.{h,m,mm}"
16
+
17
+ s.dependency "React-Core"
18
+ end
@@ -31,12 +31,13 @@ const resolveDownloadFileName = (filename?: string, url?: string): string => {
31
31
  if (trimmedName) {
32
32
  const sanitizedName = trimmedName.replace(/[<>:"/\\|?*\x00-\x1F]/g, "_");
33
33
  const urlExtension = getExtensionFromName(getUrlPathTail(url));
34
- if (getExtensionFromName(sanitizedName) || !urlExtension) return sanitizedName;
34
+ if (getExtensionFromName(sanitizedName) || !urlExtension)
35
+ return sanitizedName;
35
36
  return `${sanitizedName}${urlExtension}`;
36
37
  }
37
38
  const tailName = getUrlPathTail(url);
38
39
  if (tailName) return tailName.replace(/[<>:"/\\|?*\x00-\x1F]/g, "_");
39
- return `chat-transcript-${Date.now()}.pdf`;
40
+ return `download-robylon-${Date.now()}`;
40
41
  };
41
42
 
42
43
  type RobylonDownloadNativeModule = {
@@ -48,7 +49,10 @@ const isValidHttpUrl = (url: string): boolean => {
48
49
  };
49
50
 
50
51
  const getNativeDownloadModule = (): RobylonDownloadNativeModule | null => {
51
- return (NativeModules?.RobylonDownloadModule as RobylonDownloadNativeModule) || null;
52
+ return (
53
+ (NativeModules?.RobylonDownloadModule as RobylonDownloadNativeModule) ||
54
+ null
55
+ );
52
56
  };
53
57
 
54
58
  const openUrlWithFallback = async (url: string): Promise<void> => {
@@ -65,10 +69,15 @@ const openUrlWithFallback = async (url: string): Promise<void> => {
65
69
  });
66
70
  }
67
71
 
68
- await Linking.openURL(`https://docs.google.com/viewer?url=${encodeURIComponent(url)}`);
72
+ await Linking.openURL(
73
+ `https://docs.google.com/viewer?url=${encodeURIComponent(url)}`,
74
+ );
69
75
  };
70
76
 
71
- const downloadOnAndroid = async (url: string, filename: string): Promise<void> => {
77
+ const downloadOnAndroid = async (
78
+ url: string,
79
+ filename: string,
80
+ ): Promise<void> => {
72
81
  const module = getNativeDownloadModule();
73
82
  if (!module?.downloadFile) {
74
83
  throw new Error("Robylon native download module is not linked on Android");
@@ -76,19 +85,33 @@ const downloadOnAndroid = async (url: string, filename: string): Promise<void> =
76
85
  await module.downloadFile(url, filename);
77
86
  };
78
87
 
88
+ const downloadOniOS = async (url: string, filename: string): Promise<void> => {
89
+ const module = getNativeDownloadModule();
90
+ if (!module?.downloadFile) {
91
+ throw new Error("Robylon native download module is not linked on iOS");
92
+ }
93
+ await module.downloadFile(url, filename);
94
+ };
95
+
79
96
  const downloadWithNativeStorage = async (
80
97
  url: string,
81
- filename?: string
98
+ filename?: string,
82
99
  ): Promise<void> => {
83
100
  const safeName = resolveDownloadFileName(filename, url);
84
101
  if (Platform.OS === "android") {
85
102
  await downloadOnAndroid(url, safeName);
86
103
  return;
87
104
  }
105
+ if (Platform.OS === "ios") {
106
+ await downloadOniOS(url, safeName);
107
+ return;
108
+ }
88
109
  await openUrlWithFallback(url);
89
110
  };
90
111
 
91
- const shouldUseInPlaceDownload = (downloadRequest?: DownloadRequest): boolean => {
112
+ const shouldUseInPlaceDownload = (
113
+ downloadRequest?: DownloadRequest,
114
+ ): boolean => {
92
115
  return downloadRequest?.inPlace === true;
93
116
  };
94
117
 
@@ -100,7 +123,7 @@ const shouldUseInPlaceDownload = (downloadRequest?: DownloadRequest): boolean =>
100
123
  export const downloadFile = async (
101
124
  url: string,
102
125
  filename?: string,
103
- inPlace?: boolean
126
+ inPlace?: boolean,
104
127
  ): Promise<void> => {
105
128
  try {
106
129
  const normalizedUrl = normalizeUrl(url);
@@ -150,7 +173,7 @@ export const downloadFile = async (
150
173
  * @param downloadRequest - The download request object
151
174
  */
152
175
  export const handleDownloadRequest = async (
153
- downloadRequest: DownloadRequest
176
+ downloadRequest: DownloadRequest,
154
177
  ): Promise<void> => {
155
178
  const { url, filename } = downloadRequest;
156
179
 
@@ -160,7 +183,11 @@ export const handleDownloadRequest = async (
160
183
  }
161
184
 
162
185
  try {
163
- await downloadFile(url, filename, shouldUseInPlaceDownload(downloadRequest));
186
+ await downloadFile(
187
+ url,
188
+ filename,
189
+ shouldUseInPlaceDownload(downloadRequest),
190
+ );
164
191
  } catch (error) {
165
192
  logger.error("Failed to handle download request", {
166
193
  downloadRequest,
@@ -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.4';
2
+ export const SDK_VERSION = '2.0.31-staging.5';