react-native-my-uploader-android 1.0.31 → 1.0.37
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/README.md +243 -46
- package/android/src/main/java/com/myuploaderandroid/DownloadFileModule.kt +162 -138
- package/android/src/main/java/com/myuploaderandroid/MyUploaderModule.kt +1 -2
- package/lib/commonjs/components/DownloadFile.js +52 -20
- package/lib/commonjs/components/DownloadFile.js.map +1 -1
- package/lib/commonjs/index.d.js.map +1 -1
- package/lib/commonjs/index.js +9 -4
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/module/components/DownloadFile.js +52 -21
- package/lib/module/components/DownloadFile.js.map +1 -1
- package/lib/module/index.d.js.map +1 -1
- package/lib/module/index.js +2 -5
- package/lib/module/index.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/package.json +1 -1
- package/src/components/DownloadFile.tsx +102 -22
- package/src/index.d.ts +2 -2
- package/src/index.ts +2 -5
- package/src/types.ts +4 -4
|
@@ -28,7 +28,6 @@ class MyUploaderModule(private val reactContext: ReactApplicationContext) :
|
|
|
28
28
|
companion object {
|
|
29
29
|
private const val REQUEST_CODE = 9900
|
|
30
30
|
private const val E_ACTIVITY_DOES_NOT_EXIST = "E_ACTIVITY_DOES_NOT_EXIST"
|
|
31
|
-
private const val E_PICKER_CANCELLED = "E_PICKER_CANCELLED"
|
|
32
31
|
private const val E_FAILED_TO_OPEN_DOCUMENT = "E_FAILED_TO_OPEN_DOCUMENT"
|
|
33
32
|
private const val E_FILE_TOO_LARGE = "E_FILE_TOO_LARGE"
|
|
34
33
|
private const val E_MAX_FILES_EXCEEDED = "E_MAX_FILES_EXCEEDED"
|
|
@@ -137,7 +136,7 @@ class MyUploaderModule(private val reactContext: ReactApplicationContext) :
|
|
|
137
136
|
}
|
|
138
137
|
}.start()
|
|
139
138
|
} else {
|
|
140
|
-
|
|
139
|
+
|
|
141
140
|
}
|
|
142
141
|
}
|
|
143
142
|
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.DownloadFile = void 0;
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _reactNative = require("react-native");
|
|
9
9
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
10
10
|
const {
|
|
11
|
-
|
|
11
|
+
DownloadFileModule
|
|
12
12
|
} = _reactNative.NativeModules;
|
|
13
13
|
const DownloadFile = ({
|
|
14
14
|
files,
|
|
@@ -16,7 +16,7 @@ const DownloadFile = ({
|
|
|
16
16
|
disabled = false,
|
|
17
17
|
debug = false,
|
|
18
18
|
maxSize = 0,
|
|
19
|
-
fileTypes = [
|
|
19
|
+
fileTypes = [],
|
|
20
20
|
buttonPlaceHolder = 'Dosyaları İndir',
|
|
21
21
|
buttonIcon,
|
|
22
22
|
ButtonStyle,
|
|
@@ -25,6 +25,14 @@ const DownloadFile = ({
|
|
|
25
25
|
onError
|
|
26
26
|
}) => {
|
|
27
27
|
const [isLoading, setIsLoading] = (0, _react.useState)(false);
|
|
28
|
+
if (!DownloadFileModule) {
|
|
29
|
+
console.warn("DownloadFileModule bulunamadı. Native tarafın kurulduğundan emin olun.");
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
const NativeDownloadModuleWrapper = (url, options) => {
|
|
33
|
+
// 🔥 Kotlin Promise metoduyla birebir uyumlu
|
|
34
|
+
return DownloadFileModule.downloadFile(url, options);
|
|
35
|
+
};
|
|
28
36
|
const handlePress = async () => {
|
|
29
37
|
if (disabled || isLoading || !files.length) return;
|
|
30
38
|
setIsLoading(true);
|
|
@@ -33,33 +41,57 @@ const DownloadFile = ({
|
|
|
33
41
|
maxSize,
|
|
34
42
|
fileTypes
|
|
35
43
|
};
|
|
36
|
-
|
|
44
|
+
|
|
45
|
+
// ✅ undefined güvenli
|
|
46
|
+
const targetFiles = (multipleDownload ? files : [files[0]]).filter(file => typeof file === 'string' && file.trim().length > 0);
|
|
47
|
+
const sizeErrors = [];
|
|
48
|
+
const typeErrors = [];
|
|
49
|
+
const otherErrors = [];
|
|
50
|
+
const successFiles = [];
|
|
37
51
|
try {
|
|
38
|
-
const promises = targetFiles.map(url =>
|
|
52
|
+
const promises = targetFiles.map(url => NativeDownloadModuleWrapper(url, options));
|
|
39
53
|
const results = await Promise.allSettled(promises);
|
|
40
|
-
const final = {
|
|
41
|
-
successful: [],
|
|
42
|
-
skipped: []
|
|
43
|
-
};
|
|
44
54
|
results.forEach((res, index) => {
|
|
45
|
-
var _targetFiles$index;
|
|
55
|
+
var _targetFiles$index, _originalUrl$split$po;
|
|
46
56
|
const originalUrl = (_targetFiles$index = targetFiles[index]) !== null && _targetFiles$index !== void 0 ? _targetFiles$index : "";
|
|
57
|
+
const fileName = ((_originalUrl$split$po = originalUrl.split('/').pop()) === null || _originalUrl$split$po === void 0 ? void 0 : _originalUrl$split$po.split('?')[0]) || `Dosya ${index + 1}`;
|
|
47
58
|
if (res.status === 'fulfilled') {
|
|
48
|
-
|
|
59
|
+
successFiles.push({
|
|
49
60
|
originalUrl,
|
|
50
61
|
localUri: res.value
|
|
51
62
|
});
|
|
52
63
|
} else {
|
|
53
|
-
var _res$reason;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
64
|
+
var _res$reason, _res$reason2;
|
|
65
|
+
const errorCode = (_res$reason = res.reason) === null || _res$reason === void 0 ? void 0 : _res$reason.code;
|
|
66
|
+
const errorMsg = ((_res$reason2 = res.reason) === null || _res$reason2 === void 0 ? void 0 : _res$reason2.message) || 'Bilinmeyen hata';
|
|
67
|
+
if (errorCode === 'ERR_SIZE_LIMIT') {
|
|
68
|
+
sizeErrors.push(fileName);
|
|
69
|
+
} else if (errorCode === 'ERR_TYPE_MISMATCH') {
|
|
70
|
+
typeErrors.push(fileName);
|
|
71
|
+
} else {
|
|
72
|
+
otherErrors.push(`${fileName}: ${errorMsg}`);
|
|
73
|
+
}
|
|
58
74
|
}
|
|
59
75
|
});
|
|
60
|
-
if (
|
|
76
|
+
if (sizeErrors.length > 0) {
|
|
77
|
+
_reactNative.Alert.alert('Boyut Sınırı Aşıldı', `Aşağıdaki dosyalar ${maxSize}MB sınırını aştığı için indirilemedi:\n\n${sizeErrors.join('\n')}`);
|
|
78
|
+
}
|
|
79
|
+
if (typeErrors.length > 0) {
|
|
80
|
+
_reactNative.Alert.alert('Desteklenmeyen Dosya Tipi', `Sadece şu formatlar izin verilmektedir: [${fileTypes.join(', ')}]\n\nUygun olmayan dosyalar:\n\n${typeErrors.join('\n')}`);
|
|
81
|
+
}
|
|
82
|
+
if (otherErrors.length > 0 && debug) {
|
|
83
|
+
_reactNative.Alert.alert('İndirme Hatası', otherErrors.join('\n'));
|
|
84
|
+
}
|
|
85
|
+
const finalResult = {
|
|
86
|
+
successful: successFiles,
|
|
87
|
+
skipped: [...sizeErrors, ...typeErrors, ...otherErrors].map(name => ({
|
|
88
|
+
originalUrl: name,
|
|
89
|
+
reason: 'Failed'
|
|
90
|
+
}))
|
|
91
|
+
};
|
|
92
|
+
onSuccess === null || onSuccess === void 0 || onSuccess(finalResult);
|
|
61
93
|
} catch (e) {
|
|
62
|
-
|
|
94
|
+
onError === null || onError === void 0 || onError(e);
|
|
63
95
|
} finally {
|
|
64
96
|
setIsLoading(false);
|
|
65
97
|
}
|
|
@@ -70,10 +102,11 @@ const DownloadFile = ({
|
|
|
70
102
|
disabled: disabled || isLoading
|
|
71
103
|
}, isLoading ? /*#__PURE__*/_react.default.createElement(_reactNative.ActivityIndicator, {
|
|
72
104
|
color: "#FFF"
|
|
73
|
-
}) : buttonIcon
|
|
105
|
+
}) : buttonIcon || /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
|
|
74
106
|
style: [styles.text, ButtonTextStyle]
|
|
75
107
|
}, buttonPlaceHolder));
|
|
76
108
|
};
|
|
109
|
+
exports.DownloadFile = DownloadFile;
|
|
77
110
|
const styles = _reactNative.StyleSheet.create({
|
|
78
111
|
button: {
|
|
79
112
|
backgroundColor: '#03DAC6',
|
|
@@ -89,5 +122,4 @@ const styles = _reactNative.StyleSheet.create({
|
|
|
89
122
|
backgroundColor: '#AAA'
|
|
90
123
|
}
|
|
91
124
|
});
|
|
92
|
-
var _default = exports.default = DownloadFile;
|
|
93
125
|
//# sourceMappingURL=DownloadFile.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","DownloadFile","NativeDownload","NativeModules","files","multipleDownload","disabled","debug","maxSize","fileTypes","buttonPlaceHolder","buttonIcon","ButtonStyle","ButtonTextStyle","onSuccess","onError","isLoading","setIsLoading","useState","handlePress","length","options","targetFiles","promises","map","url","downloadFile","results","Promise","allSettled","final","successful","skipped","forEach","res","index","_targetFiles$index","originalUrl","status","push","localUri","value","_res$reason","reason","message","console","error","createElement","TouchableOpacity","style","styles","button","onPress","ActivityIndicator","color","Text","text","StyleSheet","create","backgroundColor","padding","borderRadius","alignItems","fontWeight","_default","exports"],"sources":["DownloadFile.tsx"],"sourcesContent":["import React, { useState } from 'react';\r\nimport { TouchableOpacity, Text, StyleSheet, ActivityIndicator,NativeModules } from 'react-native';\r\nimport type { DownloadFileProps, DownloadResult } from '../types';\r\n\r\n\r\nconst { DownloadFile: NativeDownload } = NativeModules;\r\n\r\n\r\nconst DownloadFile: React.FC<DownloadFileProps> = ({\r\n files,\r\n multipleDownload = false,\r\n disabled = false,\r\n debug = false,\r\n maxSize = 0,\r\n fileTypes = ['*/*'],\r\n buttonPlaceHolder = 'Dosyaları İndir',\r\n buttonIcon,\r\n ButtonStyle,\r\n ButtonTextStyle,\r\n onSuccess,\r\n onError,\r\n}) => {\r\n const [isLoading, setIsLoading] = useState(false);\r\n\r\n const handlePress = async () => {\r\n if (disabled || isLoading || !files.length) return;\r\n setIsLoading(true);\r\n\r\n const options = { debug, maxSize, fileTypes };\r\n const targetFiles = multipleDownload ? files : [files[0]];\r\n\r\n try {\r\n const promises = targetFiles.map(url => NativeDownload.downloadFile(url, options));\r\n const results = await Promise.allSettled(promises);\r\n \r\n const final: DownloadResult = { successful: [], skipped: [] };\r\n\r\n results.forEach((res, index) => {\r\n const originalUrl = targetFiles[index] ?? \"\";\r\n if (res.status === 'fulfilled') {\r\n final.successful.push({ originalUrl, localUri: res.value });\r\n } else {\r\n final.skipped.push({ \r\n originalUrl, \r\n reason: res.reason?.message || \"Bilinmeyen Hata\" \r\n });\r\n }\r\n });\r\n\r\n if (onSuccess) onSuccess(final);\r\n } catch (e) {\r\n if (onError) onError(e);\r\n else console.error(e);\r\n } finally {\r\n setIsLoading(false);\r\n }\r\n };\r\n\r\n return (\r\n <TouchableOpacity\r\n style={[styles.button, ButtonStyle, (disabled || isLoading) && styles.disabled]}\r\n onPress={handlePress}\r\n disabled={disabled || isLoading}\r\n >\r\n {isLoading ? (\r\n <ActivityIndicator color=\"#FFF\" />\r\n ) : (\r\n buttonIcon ? buttonIcon : <Text style={[styles.text, ButtonTextStyle]}>{buttonPlaceHolder}</Text>\r\n )}\r\n </TouchableOpacity>\r\n );\r\n};\r\n\r\nconst styles = StyleSheet.create({\r\n button: {\r\n backgroundColor: '#03DAC6',\r\n padding: 12,\r\n borderRadius: 8,\r\n alignItems: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AE;IACNQ,eAAe,EAAE,SAAS;IAC1BC,OAAO,EAAE,EAAE;IACXC,YAAY,EAAE,CAAC;IACfC,UAAU,EAAE;EACd,CAAC;EACDN,IAAI,EAAE;IAAEF,KAAK,EAAE,MAAM;IAAES,UAAU,EAAE;EAAO,CAAC;EAC3CzD,QAAQ,EAAE;IAAEqD,eAAe,EAAE;EAAO;AACtC,CAAC,CAAC;AAAC,IAAAK,QAAA,GAAAC,OAAA,CAAAzE,OAAA,GAEYS,YAAY","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","DownloadFileModule","NativeModules","DownloadFile","files","multipleDownload","disabled","debug","maxSize","fileTypes","buttonPlaceHolder","buttonIcon","ButtonStyle","ButtonTextStyle","onSuccess","onError","isLoading","setIsLoading","useState","console","warn","NativeDownloadModuleWrapper","url","options","downloadFile","handlePress","length","targetFiles","filter","file","trim","sizeErrors","typeErrors","otherErrors","successFiles","promises","map","results","Promise","allSettled","forEach","res","index","_targetFiles$index","_originalUrl$split$po","originalUrl","fileName","split","pop","status","push","localUri","value","_res$reason","_res$reason2","errorCode","reason","code","errorMsg","message","Alert","alert","join","finalResult","successful","skipped","name","createElement","TouchableOpacity","style","styles","button","onPress","ActivityIndicator","color","Text","text","exports","StyleSheet","create","backgroundColor","padding","borderRadius","alignItems","fontWeight"],"sources":["DownloadFile.tsx"],"sourcesContent":["import React, { useState } from 'react';\r\nimport {\r\n TouchableOpacity,\r\n Text,\r\n StyleSheet,\r\n ActivityIndicator,\r\n NativeModules,\r\n Alert,\r\n} from 'react-native';\r\nimport type { DownloadFileProps, DownloadResult } from '../types';\r\n\r\nconst { DownloadFileModule } = NativeModules;\r\n\r\nexport const DownloadFile: React.FC<DownloadFileProps> = ({\r\n files,\r\n multipleDownload = false,\r\n disabled = false,\r\n debug = false,\r\n maxSize = 0,\r\n fileTypes = [],\r\n buttonPlaceHolder = 'Dosyaları İndir',\r\n buttonIcon,\r\n ButtonStyle,\r\n ButtonTextStyle,\r\n onSuccess,\r\n onError,\r\n}) => {\r\n const [isLoading, setIsLoading] = useState(false);\r\n\r\n if (!DownloadFileModule) {\r\n console.warn(\"DownloadFileModule bulunamadı. Native tarafın kurulduğundan emin olun.\");\r\n return null;\r\n }\r\n\r\n const NativeDownloadModuleWrapper = (\r\n url: string,\r\n options: any\r\n ): Promise<string> => {\r\n // 🔥 Kotlin Promise metoduyla birebir uyumlu\r\n return DownloadFileModule.downloadFile(url, options);\r\n };\r\n\r\n const handlePress = async () => {\r\n if (disabled || isLoading || !files.length) return;\r\n setIsLoading(true);\r\n\r\n const options = { debug, maxSize, fileTypes };\r\n\r\n // ✅ undefined güvenli\r\n const targetFiles: string[] = (\r\n multipleDownload ? files : [files[0]]\r\n ).filter((file): file is string => typeof file === 'string' && file.trim().length > 0);\r\n\r\n const sizeErrors: string[] = [];\r\n const typeErrors: string[] = [];\r\n const otherErrors: string[] = [];\r\n const successFiles: DownloadResult['successful'] = [];\r\n\r\n try {\r\n const promises = targetFiles.map(url =>\r\n NativeDownloadModuleWrapper(url, options)\r\n );\r\n\r\n const results = await Promise.allSettled(promises);\r\n\r\n results.forEach((res, index) => {\r\n const originalUrl = targetFiles[index] ?? \"\";\r\n const fileName =\r\n originalUrl.split('/').pop()?.split('?')[0] ||\r\n `Dosya ${index + 1}`;\r\n\r\n if (res.status === 'fulfilled') {\r\n successFiles.push({\r\n originalUrl,\r\n localUri: res.value,\r\n });\r\n } else {\r\n const errorCode = res.reason?.code;\r\n const errorMsg = res.reason?.message || 'Bilinmeyen hata';\r\n\r\n if (errorCode === 'ERR_SIZE_LIMIT') {\r\n sizeErrors.push(fileName);\r\n } else if (errorCode === 'ERR_TYPE_MISMATCH') {\r\n typeErrors.push(fileName);\r\n } else {\r\n otherErrors.push(`${fileName}: ${errorMsg}`);\r\n }\r\n }\r\n });\r\n\r\n if (sizeErrors.length > 0) {\r\n Alert.alert(\r\n 'Boyut Sınırı Aşıldı',\r\n `Aşağıdaki dosyalar ${maxSize}MB sınırını aştığı için indirilemedi:\\n\\n${sizeErrors.join(\r\n '\\n'\r\n )}`\r\n );\r\n }\r\n\r\n if (typeErrors.length > 0) {\r\n Alert.alert(\r\n 'Desteklenmeyen Dosya Tipi',\r\n `Sadece şu formatlar izin verilmektedir: [${fileTypes.join(\r\n ', '\r\n )}]\\n\\nUygun olmayan dosyalar:\\n\\n${typeErrors.join('\\n')}`\r\n );\r\n }\r\n\r\n if (otherErrors.length > 0 && debug) {\r\n Alert.alert('İndirme Hatası', otherErrors.join('\\n'));\r\n }\r\n\r\n const finalResult: DownloadResult = {\r\n successful: successFiles,\r\n skipped: [...sizeErrors, ...typeErrors, ...otherErrors].map(\r\n name => ({\r\n originalUrl: name,\r\n reason: 'Failed',\r\n })\r\n ),\r\n };\r\n\r\n onSuccess?.(finalResult);\r\n } catch (e) {\r\n onError?.(e);\r\n } finally {\r\n setIsLoading(false);\r\n }\r\n };\r\n\r\n return (\r\n <TouchableOpacity\r\n style={[styles.button, ButtonStyle, (disabled || isLoading) && styles.disabled]}\r\n onPress={handlePress}\r\n disabled={disabled || isLoading}\r\n >\r\n {isLoading ? (\r\n <ActivityIndicator color=\"#FFF\" />\r\n ) : (\r\n buttonIcon || (\r\n <Text style={[styles.text, ButtonTextStyle]}>\r\n {buttonPlaceHolder}\r\n </Text>\r\n )\r\n )}\r\n </TouchableOpacity>\r\n );\r\n};\r\n\r\nconst styles = StyleSheet.create({\r\n button: {\r\n backgroundColor: '#03DAC6',\r\n padding: 12,\r\n borderRadius: 8,\r\n alignItems: 'center',\r\n },\r\n text: {\r\n color: '#000',\r\n fontWeight: 'bold',\r\n },\r\n disabled: {\r\n backgroundColor: '#AAA',\r\n },\r\n});\r\n\r\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA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ACtF,YAAA,CAAA4F,iBAAiB;IAACC,KAAK,EAAC;EAAM,CAAE,CAAC,GAElC/D,UAAU,iBACRjC,MAAA,CAAAc,OAAA,CAAA2E,aAAA,CAACtF,YAAA,CAAA8F,IAAI;IAACN,KAAK,EAAE,CAACC,MAAM,CAACM,IAAI,EAAE/D,eAAe;EAAE,GACzCH,iBACG,CAGM,CAAC;AAEvB,CAAC;AAACmE,OAAA,CAAA1E,YAAA,GAAAA,YAAA;AAEF,MAAMmE,MAAM,GAAGQ,uBAAU,CAACC,MAAM,CAAC;EAC/BR,MAAM,EAAE;IACNS,eAAe,EAAE,SAAS;IAC1BC,OAAO,EAAE,EAAE;IACXC,YAAY,EAAE,CAAC;IACfC,UAAU,EAAE;EACd,CAAC;EACDP,IAAI,EAAE;IACJF,KAAK,EAAE,MAAM;IACbU,UAAU,EAAE;EACd,CAAC;EACD9E,QAAQ,EAAE;IACR0E,eAAe,EAAE;EACnB;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_types","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sources":["index.d.ts"],"sourcesContent":["import * as React from 'react';\r\nimport type { DocumentPickerOptions, MyUploaderProps, FileInfo } from './types';\r\n// import type { DownloadFileProps } from './types';\r\n\r\nexport * from './types';\r\n\r\n// DownloadFile Component Tanımı (3. Bunu ekledik)\r\n// export declare const DownloadFile: React.FC<DownloadFileProps>;\r\n\r\n// pickFile Fonksiyon Tanımı\r\nexport declare function pickFile(options?: DocumentPickerOptions): Promise<FileInfo[]>;\r\
|
|
1
|
+
{"version":3,"names":["_types","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sources":["index.d.ts"],"sourcesContent":["import * as React from 'react';\r\nimport type { DocumentPickerOptions, MyUploaderProps, FileInfo, DownloadFileProps } from './types';\r\n// import type { DownloadFileProps } from './types';\r\n\r\nexport * from './types';\r\n\r\n// DownloadFile Component Tanımı (3. Bunu ekledik)\r\n// export declare const DownloadFile: React.FC<DownloadFileProps>;\r\n\r\n// pickFile Fonksiyon Tanımı\r\nexport declare function pickFile(options?: DocumentPickerOptions): Promise<FileInfo[]>;\r\nexport declare const DownloadFile :React.FC<DownloadFileProps>;\r\nexport declare const MyUploader: React.FC<MyUploaderProps>;\r\n\r\n// Varsayılan dışa aktarım (İsteğe bağlı, genellikle ana bileşen verilir)\r\ndeclare const _default: React.FC<MyUploaderProps>;\r\nexport default _default;"],"mappings":";;;;;AAIA,IAAAA,MAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,MAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,MAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,MAAA,CAAAK,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -5,8 +5,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
var _exportNames = {
|
|
7
7
|
MyUploader: true,
|
|
8
|
-
pickFile: true
|
|
8
|
+
pickFile: true,
|
|
9
|
+
DownloadFile: true
|
|
9
10
|
};
|
|
11
|
+
Object.defineProperty(exports, "DownloadFile", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () {
|
|
14
|
+
return _DownloadFile.DownloadFile;
|
|
15
|
+
}
|
|
16
|
+
});
|
|
10
17
|
Object.defineProperty(exports, "MyUploader", {
|
|
11
18
|
enumerable: true,
|
|
12
19
|
get: function () {
|
|
@@ -21,6 +28,7 @@ Object.defineProperty(exports, "pickFile", {
|
|
|
21
28
|
}
|
|
22
29
|
});
|
|
23
30
|
var _MyUploader = _interopRequireWildcard(require("./components/MyUploader"));
|
|
31
|
+
var _DownloadFile = require("./components/DownloadFile");
|
|
24
32
|
var _types = require("./types");
|
|
25
33
|
Object.keys(_types).forEach(function (key) {
|
|
26
34
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -34,9 +42,6 @@ Object.keys(_types).forEach(function (key) {
|
|
|
34
42
|
});
|
|
35
43
|
});
|
|
36
44
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
37
|
-
// import DownloadFile from "./components/DownloadFile";
|
|
38
|
-
// 2. Diğerlerini NAMED olarak dışa aktar (import { DownloadFile, pickFile } ... için)
|
|
39
|
-
// export { DownloadFile, pickFile };
|
|
40
45
|
// Sadece bu paketle ilgili olanları dışa aktar
|
|
41
46
|
// Varsayılan dışa aktarım olarak da ana bileşeni verelim
|
|
42
47
|
var _default = exports.default = _MyUploader.default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_MyUploader","_interopRequireWildcard","require","_types","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","set","getOwnPropertyDescriptor","_default","MyUploader"],"sources":["index.ts"],"sourcesContent":["import MyUploader,{pickFile} from \"./components/MyUploader\";\r\
|
|
1
|
+
{"version":3,"names":["_MyUploader","_interopRequireWildcard","require","_DownloadFile","_types","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","set","getOwnPropertyDescriptor","_default","MyUploader"],"sources":["index.ts"],"sourcesContent":["import MyUploader,{pickFile} from \"./components/MyUploader\";\r\nimport {DownloadFile} from \"./components/DownloadFile\";\r\n\r\n\r\n// Sadece bu paketle ilgili olanları dışa aktar\r\nexport { MyUploader, pickFile ,DownloadFile };\r\nexport * from './types';\r\n\r\n// Varsayılan dışa aktarım olarak da ana bileşeni verelim\r\nexport default MyUploader;\r\n\r\n\r\n\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,WAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AAKA,IAAAE,MAAA,GAAAF,OAAA;AAAAG,MAAA,CAAAC,IAAA,CAAAF,MAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,MAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,MAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AAAwB,SAAAP,wBAAAgB,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAlB,uBAAA,YAAAA,CAAAgB,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAP,GAAA,CAAAC,CAAA,GAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAR,cAAA,CAAAC,IAAA,CAAAM,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAlB,MAAA,CAAAS,cAAA,KAAAT,MAAA,CAAAyB,wBAAA,CAAAb,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAR,GAAA,IAAAQ,CAAA,CAAAK,GAAA,IAAAN,CAAA,CAAAE,CAAA,EAAAP,CAAA,EAAAM,CAAA,IAAAC,CAAA,CAAAP,CAAA,IAAAD,CAAA,CAAAC,CAAA,WAAAO,CAAA,KAAAR,CAAA,EAAAC,CAAA;AAFxB;AAIA;AAAA,IAAAa,QAAA,GAAAlB,OAAA,CAAAc,OAAA,GACeK,mBAAU","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["// import type { StyleProp, TextStyle, ViewStyle } from 'react-native';\r\n\r\n// export interface FileInfo {\r\n// fileName: string;\r\n// fileSize: number; \r\n// fileType: string | null;\r\n// fileUri: string;\r\n// base64: string;\r\n// }\r\n\r\n// export interface MyUploaderProps{\r\n// onSelect: (files: FileInfo[]) => void;\r\n// onError?: (error: Error) => void;\r\n// buttonPlaceHolder?: string;\r\n// ButtonStyle?: StyleProp<ViewStyle>;\r\n// ButtonTextStyle?: StyleProp<TextStyle>;\r\n// disabled?: boolean; \r\n// multipleFiles?: boolean;\r\n// fileTypes?: string[];\r\n// maxSize?: number;\r\n// maxFiles?: number;\r\n// excludedUris?: string[];\r\n// }\r\n\r\n// export interface DownloadedFileInfo {\r\n// originalUrl: string;\r\n// localUri: string;\r\n// }\r\n\r\n// export interface SkippedFileInfo {\r\n// originalUrl: string;\r\n// reason: string; \r\n// }\r\n\r\n\r\n\r\n// export interface UploadFileProps {\r\n// files: string[];\r\n// multipleLoad?: boolean;\r\n// disabled?: boolean;\r\n// debug?: boolean; \r\n// maxSize?: number;\r\n// fileTypes?: string[];\r\n// buttonPlaceHolder?: string;\r\n// buttonIcon?: React.ReactNode;\r\n// ButtonStyle?: StyleProp<ViewStyle>;\r\n// ButtonTextStyle?: StyleProp<TextStyle>;\r\n// onSuccess?: (result: DownloadResult) => void;\r\n// onError?: (error: Error) => void;\r\n// }\r\n\r\n// export interface DownloadFileProps {\r\n// files: string[];\r\n// multipleDownload?: boolean;\r\n// disabled?: boolean;\r\n// debug?: boolean;\r\n// maxSize?: number; // MB\r\n// fileTypes?: string[];\r\n// buttonPlaceHolder?: string;\r\n// buttonIcon?: React.ReactNode;\r\n// ButtonStyle?: ViewStyle;\r\n// ButtonTextStyle?: TextStyle;\r\n// onSuccess?: (result: DownloadResult) => void;\r\n// onError?: (error: any) => void;\r\n// }\r\n// export interface DownloadResult {\r\n// successful: { originalUrl: string; localUri: string | null }[];\r\n// skipped: { originalUrl: string; reason: string }[];\r\n// }\r\n\r\n\r\nimport type { ViewStyle, TextStyle } from 'react-native';\r\n\r\nexport interface FileInfo {\r\n
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["// import type { StyleProp, TextStyle, ViewStyle } from 'react-native';\r\n\r\n// export interface FileInfo {\r\n// fileName: string;\r\n// fileSize: number; \r\n// fileType: string | null;\r\n// fileUri: string;\r\n// base64: string;\r\n// }\r\n\r\n// export interface MyUploaderProps{\r\n// onSelect: (files: FileInfo[]) => void;\r\n// onError?: (error: Error) => void;\r\n// buttonPlaceHolder?: string;\r\n// ButtonStyle?: StyleProp<ViewStyle>;\r\n// ButtonTextStyle?: StyleProp<TextStyle>;\r\n// disabled?: boolean; \r\n// multipleFiles?: boolean;\r\n// fileTypes?: string[];\r\n// maxSize?: number;\r\n// maxFiles?: number;\r\n// excludedUris?: string[];\r\n// }\r\n\r\n// export interface DownloadedFileInfo {\r\n// originalUrl: string;\r\n// localUri: string;\r\n// }\r\n\r\n// export interface SkippedFileInfo {\r\n// originalUrl: string;\r\n// reason: string; \r\n// }\r\n\r\n\r\n\r\n// export interface UploadFileProps {\r\n// files: string[];\r\n// multipleLoad?: boolean;\r\n// disabled?: boolean;\r\n// debug?: boolean; \r\n// maxSize?: number;\r\n// fileTypes?: string[];\r\n// buttonPlaceHolder?: string;\r\n// buttonIcon?: React.ReactNode;\r\n// ButtonStyle?: StyleProp<ViewStyle>;\r\n// ButtonTextStyle?: StyleProp<TextStyle>;\r\n// onSuccess?: (result: DownloadResult) => void;\r\n// onError?: (error: Error) => void;\r\n// }\r\n\r\n// export interface DownloadFileProps {\r\n// files: string[];\r\n// multipleDownload?: boolean;\r\n// disabled?: boolean;\r\n// debug?: boolean;\r\n// maxSize?: number; // MB\r\n// fileTypes?: string[];\r\n// buttonPlaceHolder?: string;\r\n// buttonIcon?: React.ReactNode;\r\n// ButtonStyle?: ViewStyle;\r\n// ButtonTextStyle?: TextStyle;\r\n// onSuccess?: (result: DownloadResult) => void;\r\n// onError?: (error: any) => void;\r\n// }\r\n// export interface DownloadResult {\r\n// successful: { originalUrl: string; localUri: string | null }[];\r\n// skipped: { originalUrl: string; reason: string }[];\r\n// }\r\n\r\n\r\nimport type { ViewStyle, TextStyle } from 'react-native';\r\n\r\nexport interface FileInfo {\r\n fileUri: string;\r\n fileName: string;\r\n fileType: string;\r\n fileSize: number;\r\n base64?: string | null;\r\n}\r\n\r\n\r\n// ----- MyUploader & pickFile Props -----\r\nexport interface DocumentPickerOptions {\r\n multipleFiles?: boolean;\r\n fileTypes?: string[]; // örn: ['image/*', 'application/pdf']\r\n maxSize?: number; // MB cinsinden\r\n maxFiles?: number;\r\n excludedUris?: string[];\r\n}\r\n\r\nexport interface MyUploaderProps extends DocumentPickerOptions {\r\n onSelect: (files: FileInfo[]) => void;\r\n onError?: (error: Error) => void;\r\n buttonPlaceHolder?: string;\r\n ButtonStyle?: ViewStyle;\r\n ButtonTextStyle?: TextStyle;\r\n disabled?: boolean;\r\n}\r\n\r\n// ----- DownloadFile Props -----\r\nexport interface DownloadFileProps {\r\n files: string[];\r\n multipleDownload?: boolean; // multipleFiles yerine multipleDownload (İsim karışmaması için)\r\n disabled?: boolean;\r\n debug?: boolean;\r\n maxSize?: number; // MB\r\n fileTypes?: string[]; // İndirilecek dosyanın Content-Type kontrolü\r\n buttonPlaceHolder?: string;\r\n buttonIcon?: React.ReactNode;\r\n ButtonStyle?: ViewStyle;\r\n ButtonTextStyle?: TextStyle;\r\n onSuccess?: (result: DownloadResult) => void;\r\n onError?: (error: any) => void;\r\n}\r\n\r\n\r\nexport interface DownloadResult {\r\n successful: { originalUrl: string; localUri: string | null }[];\r\n skipped: { originalUrl: string; reason: string }[];\r\n}"],"mappings":"","ignoreList":[]}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
|
-
import { TouchableOpacity, Text, StyleSheet, ActivityIndicator, NativeModules } from 'react-native';
|
|
2
|
+
import { TouchableOpacity, Text, StyleSheet, ActivityIndicator, NativeModules, Alert } from 'react-native';
|
|
3
3
|
const {
|
|
4
|
-
|
|
4
|
+
DownloadFileModule
|
|
5
5
|
} = NativeModules;
|
|
6
|
-
const DownloadFile = ({
|
|
6
|
+
export const DownloadFile = ({
|
|
7
7
|
files,
|
|
8
8
|
multipleDownload = false,
|
|
9
9
|
disabled = false,
|
|
10
10
|
debug = false,
|
|
11
11
|
maxSize = 0,
|
|
12
|
-
fileTypes = [
|
|
12
|
+
fileTypes = [],
|
|
13
13
|
buttonPlaceHolder = 'Dosyaları İndir',
|
|
14
14
|
buttonIcon,
|
|
15
15
|
ButtonStyle,
|
|
@@ -18,6 +18,14 @@ const DownloadFile = ({
|
|
|
18
18
|
onError
|
|
19
19
|
}) => {
|
|
20
20
|
const [isLoading, setIsLoading] = useState(false);
|
|
21
|
+
if (!DownloadFileModule) {
|
|
22
|
+
console.warn("DownloadFileModule bulunamadı. Native tarafın kurulduğundan emin olun.");
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
const NativeDownloadModuleWrapper = (url, options) => {
|
|
26
|
+
// 🔥 Kotlin Promise metoduyla birebir uyumlu
|
|
27
|
+
return DownloadFileModule.downloadFile(url, options);
|
|
28
|
+
};
|
|
21
29
|
const handlePress = async () => {
|
|
22
30
|
if (disabled || isLoading || !files.length) return;
|
|
23
31
|
setIsLoading(true);
|
|
@@ -26,33 +34,57 @@ const DownloadFile = ({
|
|
|
26
34
|
maxSize,
|
|
27
35
|
fileTypes
|
|
28
36
|
};
|
|
29
|
-
|
|
37
|
+
|
|
38
|
+
// ✅ undefined güvenli
|
|
39
|
+
const targetFiles = (multipleDownload ? files : [files[0]]).filter(file => typeof file === 'string' && file.trim().length > 0);
|
|
40
|
+
const sizeErrors = [];
|
|
41
|
+
const typeErrors = [];
|
|
42
|
+
const otherErrors = [];
|
|
43
|
+
const successFiles = [];
|
|
30
44
|
try {
|
|
31
|
-
const promises = targetFiles.map(url =>
|
|
45
|
+
const promises = targetFiles.map(url => NativeDownloadModuleWrapper(url, options));
|
|
32
46
|
const results = await Promise.allSettled(promises);
|
|
33
|
-
const final = {
|
|
34
|
-
successful: [],
|
|
35
|
-
skipped: []
|
|
36
|
-
};
|
|
37
47
|
results.forEach((res, index) => {
|
|
38
|
-
var _targetFiles$index;
|
|
48
|
+
var _targetFiles$index, _originalUrl$split$po;
|
|
39
49
|
const originalUrl = (_targetFiles$index = targetFiles[index]) !== null && _targetFiles$index !== void 0 ? _targetFiles$index : "";
|
|
50
|
+
const fileName = ((_originalUrl$split$po = originalUrl.split('/').pop()) === null || _originalUrl$split$po === void 0 ? void 0 : _originalUrl$split$po.split('?')[0]) || `Dosya ${index + 1}`;
|
|
40
51
|
if (res.status === 'fulfilled') {
|
|
41
|
-
|
|
52
|
+
successFiles.push({
|
|
42
53
|
originalUrl,
|
|
43
54
|
localUri: res.value
|
|
44
55
|
});
|
|
45
56
|
} else {
|
|
46
|
-
var _res$reason;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
57
|
+
var _res$reason, _res$reason2;
|
|
58
|
+
const errorCode = (_res$reason = res.reason) === null || _res$reason === void 0 ? void 0 : _res$reason.code;
|
|
59
|
+
const errorMsg = ((_res$reason2 = res.reason) === null || _res$reason2 === void 0 ? void 0 : _res$reason2.message) || 'Bilinmeyen hata';
|
|
60
|
+
if (errorCode === 'ERR_SIZE_LIMIT') {
|
|
61
|
+
sizeErrors.push(fileName);
|
|
62
|
+
} else if (errorCode === 'ERR_TYPE_MISMATCH') {
|
|
63
|
+
typeErrors.push(fileName);
|
|
64
|
+
} else {
|
|
65
|
+
otherErrors.push(`${fileName}: ${errorMsg}`);
|
|
66
|
+
}
|
|
51
67
|
}
|
|
52
68
|
});
|
|
53
|
-
if (
|
|
69
|
+
if (sizeErrors.length > 0) {
|
|
70
|
+
Alert.alert('Boyut Sınırı Aşıldı', `Aşağıdaki dosyalar ${maxSize}MB sınırını aştığı için indirilemedi:\n\n${sizeErrors.join('\n')}`);
|
|
71
|
+
}
|
|
72
|
+
if (typeErrors.length > 0) {
|
|
73
|
+
Alert.alert('Desteklenmeyen Dosya Tipi', `Sadece şu formatlar izin verilmektedir: [${fileTypes.join(', ')}]\n\nUygun olmayan dosyalar:\n\n${typeErrors.join('\n')}`);
|
|
74
|
+
}
|
|
75
|
+
if (otherErrors.length > 0 && debug) {
|
|
76
|
+
Alert.alert('İndirme Hatası', otherErrors.join('\n'));
|
|
77
|
+
}
|
|
78
|
+
const finalResult = {
|
|
79
|
+
successful: successFiles,
|
|
80
|
+
skipped: [...sizeErrors, ...typeErrors, ...otherErrors].map(name => ({
|
|
81
|
+
originalUrl: name,
|
|
82
|
+
reason: 'Failed'
|
|
83
|
+
}))
|
|
84
|
+
};
|
|
85
|
+
onSuccess === null || onSuccess === void 0 || onSuccess(finalResult);
|
|
54
86
|
} catch (e) {
|
|
55
|
-
|
|
87
|
+
onError === null || onError === void 0 || onError(e);
|
|
56
88
|
} finally {
|
|
57
89
|
setIsLoading(false);
|
|
58
90
|
}
|
|
@@ -63,7 +95,7 @@ const DownloadFile = ({
|
|
|
63
95
|
disabled: disabled || isLoading
|
|
64
96
|
}, isLoading ? /*#__PURE__*/React.createElement(ActivityIndicator, {
|
|
65
97
|
color: "#FFF"
|
|
66
|
-
}) : buttonIcon
|
|
98
|
+
}) : buttonIcon || /*#__PURE__*/React.createElement(Text, {
|
|
67
99
|
style: [styles.text, ButtonTextStyle]
|
|
68
100
|
}, buttonPlaceHolder));
|
|
69
101
|
};
|
|
@@ -82,5 +114,4 @@ const styles = StyleSheet.create({
|
|
|
82
114
|
backgroundColor: '#AAA'
|
|
83
115
|
}
|
|
84
116
|
});
|
|
85
|
-
export default DownloadFile;
|
|
86
117
|
//# sourceMappingURL=DownloadFile.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useState","TouchableOpacity","Text","StyleSheet","ActivityIndicator","NativeModules","
|
|
1
|
+
{"version":3,"names":["React","useState","TouchableOpacity","Text","StyleSheet","ActivityIndicator","NativeModules","Alert","DownloadFileModule","DownloadFile","files","multipleDownload","disabled","debug","maxSize","fileTypes","buttonPlaceHolder","buttonIcon","ButtonStyle","ButtonTextStyle","onSuccess","onError","isLoading","setIsLoading","console","warn","NativeDownloadModuleWrapper","url","options","downloadFile","handlePress","length","targetFiles","filter","file","trim","sizeErrors","typeErrors","otherErrors","successFiles","promises","map","results","Promise","allSettled","forEach","res","index","_targetFiles$index","_originalUrl$split$po","originalUrl","fileName","split","pop","status","push","localUri","value","_res$reason","_res$reason2","errorCode","reason","code","errorMsg","message","alert","join","finalResult","successful","skipped","name","e","createElement","style","styles","button","onPress","color","text","create","backgroundColor","padding","borderRadius","alignItems","fontWeight"],"sources":["DownloadFile.tsx"],"sourcesContent":["import React, { useState } from 'react';\r\nimport {\r\n TouchableOpacity,\r\n Text,\r\n StyleSheet,\r\n ActivityIndicator,\r\n NativeModules,\r\n Alert,\r\n} from 'react-native';\r\nimport type { DownloadFileProps, DownloadResult } from '../types';\r\n\r\nconst { DownloadFileModule } = NativeModules;\r\n\r\nexport const DownloadFile: React.FC<DownloadFileProps> = ({\r\n files,\r\n multipleDownload = false,\r\n disabled = false,\r\n debug = false,\r\n maxSize = 0,\r\n fileTypes = [],\r\n buttonPlaceHolder = 'Dosyaları İndir',\r\n buttonIcon,\r\n ButtonStyle,\r\n ButtonTextStyle,\r\n onSuccess,\r\n onError,\r\n}) => {\r\n const [isLoading, setIsLoading] = useState(false);\r\n\r\n if (!DownloadFileModule) {\r\n console.warn(\"DownloadFileModule bulunamadı. Native tarafın kurulduğundan emin olun.\");\r\n return null;\r\n }\r\n\r\n const NativeDownloadModuleWrapper = (\r\n url: string,\r\n options: any\r\n ): Promise<string> => {\r\n // 🔥 Kotlin Promise metoduyla birebir uyumlu\r\n return DownloadFileModule.downloadFile(url, options);\r\n };\r\n\r\n const handlePress = async () => {\r\n if (disabled || isLoading || !files.length) return;\r\n setIsLoading(true);\r\n\r\n const options = { debug, maxSize, fileTypes };\r\n\r\n // ✅ undefined güvenli\r\n const targetFiles: string[] = (\r\n multipleDownload ? files : [files[0]]\r\n ).filter((file): file is string => typeof file === 'string' && file.trim().length > 0);\r\n\r\n const sizeErrors: string[] = [];\r\n const typeErrors: string[] = [];\r\n const otherErrors: string[] = [];\r\n const successFiles: DownloadResult['successful'] = [];\r\n\r\n try {\r\n const promises = targetFiles.map(url =>\r\n NativeDownloadModuleWrapper(url, options)\r\n );\r\n\r\n const results = await Promise.allSettled(promises);\r\n\r\n results.forEach((res, index) => {\r\n const originalUrl = targetFiles[index] ?? \"\";\r\n const fileName =\r\n originalUrl.split('/').pop()?.split('?')[0] ||\r\n `Dosya ${index + 1}`;\r\n\r\n if (res.status === 'fulfilled') {\r\n successFiles.push({\r\n originalUrl,\r\n localUri: res.value,\r\n });\r\n } else {\r\n const errorCode = res.reason?.code;\r\n const errorMsg = res.reason?.message || 'Bilinmeyen hata';\r\n\r\n if (errorCode === 'ERR_SIZE_LIMIT') {\r\n sizeErrors.push(fileName);\r\n } else if (errorCode === 'ERR_TYPE_MISMATCH') {\r\n typeErrors.push(fileName);\r\n } else {\r\n otherErrors.push(`${fileName}: ${errorMsg}`);\r\n }\r\n }\r\n });\r\n\r\n if (sizeErrors.length > 0) {\r\n Alert.alert(\r\n 'Boyut Sınırı Aşıldı',\r\n `Aşağıdaki dosyalar ${maxSize}MB sınırını aştığı için indirilemedi:\\n\\n${sizeErrors.join(\r\n '\\n'\r\n )}`\r\n );\r\n }\r\n\r\n if (typeErrors.length > 0) {\r\n Alert.alert(\r\n 'Desteklenmeyen Dosya Tipi',\r\n `Sadece şu formatlar izin verilmektedir: [${fileTypes.join(\r\n ', '\r\n )}]\\n\\nUygun olmayan dosyalar:\\n\\n${typeErrors.join('\\n')}`\r\n );\r\n }\r\n\r\n if (otherErrors.length > 0 && debug) {\r\n Alert.alert('İndirme Hatası', otherErrors.join('\\n'));\r\n }\r\n\r\n const finalResult: DownloadResult = {\r\n successful: successFiles,\r\n skipped: [...sizeErrors, ...typeErrors, ...otherErrors].map(\r\n name => ({\r\n originalUrl: name,\r\n reason: 'Failed',\r\n })\r\n ),\r\n };\r\n\r\n onSuccess?.(finalResult);\r\n } catch (e) {\r\n onError?.(e);\r\n } finally {\r\n setIsLoading(false);\r\n }\r\n };\r\n\r\n return (\r\n <TouchableOpacity\r\n style={[styles.button, ButtonStyle, (disabled || isLoading) && styles.disabled]}\r\n onPress={handlePress}\r\n disabled={disabled || isLoading}\r\n >\r\n {isLoading ? (\r\n <ActivityIndicator color=\"#FFF\" />\r\n ) : (\r\n buttonIcon || (\r\n <Text style={[styles.text, ButtonTextStyle]}>\r\n {buttonPlaceHolder}\r\n </Text>\r\n )\r\n )}\r\n </TouchableOpacity>\r\n );\r\n};\r\n\r\nconst styles = StyleSheet.create({\r\n button: {\r\n backgroundColor: '#03DAC6',\r\n padding: 12,\r\n borderRadius: 8,\r\n alignItems: 'center',\r\n },\r\n text: {\r\n color: '#000',\r\n fontWeight: 'bold',\r\n },\r\n disabled: {\r\n backgroundColor: '#AAA',\r\n },\r\n});\r\n\r\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,QAAQ,OAAO;AACvC,SACEC,gBAAgB,EAChBC,IAAI,EACJC,UAAU,EACVC,iBAAiB,EACjBC,aAAa,EACbC,KAAK,QACA,cAAc;AAGrB,MAAM;EAAEC;AAAmB,CAAC,GAAGF,aAAa;AAE5C,OAAO,MAAMG,YAAyC,GAAGA,CAAC;EACxDC,KAAK;EACLC,gBAAgB,GAAG,KAAK;EACxBC,QAAQ,GAAG,KAAK;EAChBC,KAAK,GAAG,KAAK;EACbC,OAAO,GAAG,CAAC;EACXC,SAAS,GAAG,EAAE;EACdC,iBAAiB,GAAG,iBAAiB;EACrCC,UAAU;EACVC,WAAW;EACXC,eAAe;EACfC,SAAS;EACTC;AACF,CAAC,KAAK;EACJ,MAAM,CAACC,SAAS,EAAEC,YAAY,CAAC,GAAGtB,QAAQ,CAAC,KAAK,CAAC;EAEjD,IAAI,CAACO,kBAAkB,EAAE;IACvBgB,OAAO,CAACC,IAAI,CAAC,wEAAwE,CAAC;IACtF,OAAO,IAAI;EACb;EAEA,MAAMC,2BAA2B,GAAGA,CAClCC,GAAW,EACXC,OAAY,KACQ;IACpB;IACA,OAAOpB,kBAAkB,CAACqB,YAAY,CAACF,GAAG,EAAEC,OAAO,CAAC;EACtD,CAAC;EAED,MAAME,WAAW,GAAG,MAAAA,CAAA,KAAY;IAC9B,IAAIlB,QAAQ,IAAIU,SAAS,IAAI,CAACZ,KAAK,CAACqB,MAAM,EAAE;IAC5CR,YAAY,CAAC,IAAI,CAAC;IAElB,MAAMK,OAAO,GAAG;MAAEf,KAAK;MAAEC,OAAO;MAAEC;IAAU,CAAC;;IAE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pB,WAAW,EAAEoB,IAAI;UACjBT,MAAM,EAAE;QACV,CAAC,CACH;MACF,CAAC;MAEDzC,SAAS,aAATA,SAAS,eAATA,SAAS,CAAG+C,WAAW,CAAC;IAC1B,CAAC,CAAC,OAAOI,CAAC,EAAE;MACVlD,OAAO,aAAPA,OAAO,eAAPA,OAAO,CAAGkD,CAAC,CAAC;IACd,CAAC,SAAS;MACRhD,YAAY,CAAC,KAAK,CAAC;IACrB;EACF,CAAC;EAED,oBACEvB,KAAA,CAAAwE,aAAA,CAACtE,gBAAgB;IACfuE,KAAK,EAAE,CAACC,MAAM,CAACC,MAAM,EAAEzD,WAAW,EAAE,CAACN,QAAQ,IAAIU,SAAS,KAAKoD,MAAM,CAAC9D,QAAQ,CAAE;IAChFgE,OAAO,EAAE9C,WAAY;IACrBlB,QAAQ,EAAEA,QAAQ,IAAIU;EAAU,GAE/BA,SAAS,gBACRtB,KAAA,CAAAwE,aAAA,CAACnE,iBAAiB;IAACwE,KAAK,EAAC;EAAM,CAAE,CAAC,GAElC5D,UAAU,iBACRjB,KAAA,CAAAwE,aAAA,CAACrE,IAAI;IAACsE,KAAK,EAAE,CAACC,MAAM,CAACI,IAAI,EAAE3D,eAAe;EAAE,GACzCH,iBACG,CAGM,CAAC;AAEvB,CAAC;AAED,MAAM0D,MAAM,GAAGtE,UAAU,CAAC2E,MAAM,CAAC;EAC/BJ,MAAM,EAAE;IACNK,eAAe,EAAE,SAAS;IAC1BC,OAAO,EAAE,EAAE;IACXC,YAAY,EAAE,CAAC;IACfC,UAAU,EAAE;EACd,CAAC;EACDL,IAAI,EAAE;IACJD,KAAK,EAAE,MAAM;IACbO,UAAU,EAAE;EACd,CAAC;EACDxE,QAAQ,EAAE;IACRoE,eAAe,EAAE;EACnB;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.d.ts"],"sourcesContent":["import * as React from 'react';\r\nimport type { DocumentPickerOptions, MyUploaderProps, FileInfo } from './types';\r\n// import type { DownloadFileProps } from './types';\r\n\r\nexport * from './types';\r\n\r\n// DownloadFile Component Tanımı (3. Bunu ekledik)\r\n// export declare const DownloadFile: React.FC<DownloadFileProps>;\r\n\r\n// pickFile Fonksiyon Tanımı\r\nexport declare function pickFile(options?: DocumentPickerOptions): Promise<FileInfo[]>;\r\
|
|
1
|
+
{"version":3,"names":[],"sources":["index.d.ts"],"sourcesContent":["import * as React from 'react';\r\nimport type { DocumentPickerOptions, MyUploaderProps, FileInfo, DownloadFileProps } from './types';\r\n// import type { DownloadFileProps } from './types';\r\n\r\nexport * from './types';\r\n\r\n// DownloadFile Component Tanımı (3. Bunu ekledik)\r\n// export declare const DownloadFile: React.FC<DownloadFileProps>;\r\n\r\n// pickFile Fonksiyon Tanımı\r\nexport declare function pickFile(options?: DocumentPickerOptions): Promise<FileInfo[]>;\r\nexport declare const DownloadFile :React.FC<DownloadFileProps>;\r\nexport declare const MyUploader: React.FC<MyUploaderProps>;\r\n\r\n// Varsayılan dışa aktarım (İsteğe bağlı, genellikle ana bileşen verilir)\r\ndeclare const _default: React.FC<MyUploaderProps>;\r\nexport default _default;"],"mappings":"AAEA;;AAEA,cAAc,SAAS;;AAEvB;AACA;;AAEA;;AAKA;AAAA","ignoreList":[]}
|
package/lib/module/index.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import MyUploader, { pickFile } from "./components/MyUploader";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
// 2. Diğerlerini NAMED olarak dışa aktar (import { DownloadFile, pickFile } ... için)
|
|
5
|
-
// export { DownloadFile, pickFile };
|
|
2
|
+
import { DownloadFile } from "./components/DownloadFile";
|
|
6
3
|
|
|
7
4
|
// Sadece bu paketle ilgili olanları dışa aktar
|
|
8
|
-
export { MyUploader, pickFile };
|
|
5
|
+
export { MyUploader, pickFile, DownloadFile };
|
|
9
6
|
export * from './types';
|
|
10
7
|
|
|
11
8
|
// Varsayılan dışa aktarım olarak da ana bileşeni verelim
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["MyUploader","pickFile"],"sources":["index.ts"],"sourcesContent":["import MyUploader,{pickFile} from \"./components/MyUploader\";\r\
|
|
1
|
+
{"version":3,"names":["MyUploader","pickFile","DownloadFile"],"sources":["index.ts"],"sourcesContent":["import MyUploader,{pickFile} from \"./components/MyUploader\";\r\nimport {DownloadFile} from \"./components/DownloadFile\";\r\n\r\n\r\n// Sadece bu paketle ilgili olanları dışa aktar\r\nexport { MyUploader, pickFile ,DownloadFile };\r\nexport * from './types';\r\n\r\n// Varsayılan dışa aktarım olarak da ana bileşeni verelim\r\nexport default MyUploader;\r\n\r\n\r\n\r\n"],"mappings":"AAAA,OAAOA,UAAU,IAAEC,QAAQ,QAAO,yBAAyB;AAC3D,SAAQC,YAAY,QAAO,2BAA2B;;AAGtD;AACA,SAASF,UAAU,EAAEC,QAAQ,EAAEC,YAAY;AAC3C,cAAc,SAAS;;AAEvB;AACA,eAAeF,UAAU","ignoreList":[]}
|
package/lib/module/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["// import type { StyleProp, TextStyle, ViewStyle } from 'react-native';\r\n\r\n// export interface FileInfo {\r\n// fileName: string;\r\n// fileSize: number; \r\n// fileType: string | null;\r\n// fileUri: string;\r\n// base64: string;\r\n// }\r\n\r\n// export interface MyUploaderProps{\r\n// onSelect: (files: FileInfo[]) => void;\r\n// onError?: (error: Error) => void;\r\n// buttonPlaceHolder?: string;\r\n// ButtonStyle?: StyleProp<ViewStyle>;\r\n// ButtonTextStyle?: StyleProp<TextStyle>;\r\n// disabled?: boolean; \r\n// multipleFiles?: boolean;\r\n// fileTypes?: string[];\r\n// maxSize?: number;\r\n// maxFiles?: number;\r\n// excludedUris?: string[];\r\n// }\r\n\r\n// export interface DownloadedFileInfo {\r\n// originalUrl: string;\r\n// localUri: string;\r\n// }\r\n\r\n// export interface SkippedFileInfo {\r\n// originalUrl: string;\r\n// reason: string; \r\n// }\r\n\r\n\r\n\r\n// export interface UploadFileProps {\r\n// files: string[];\r\n// multipleLoad?: boolean;\r\n// disabled?: boolean;\r\n// debug?: boolean; \r\n// maxSize?: number;\r\n// fileTypes?: string[];\r\n// buttonPlaceHolder?: string;\r\n// buttonIcon?: React.ReactNode;\r\n// ButtonStyle?: StyleProp<ViewStyle>;\r\n// ButtonTextStyle?: StyleProp<TextStyle>;\r\n// onSuccess?: (result: DownloadResult) => void;\r\n// onError?: (error: Error) => void;\r\n// }\r\n\r\n// export interface DownloadFileProps {\r\n// files: string[];\r\n// multipleDownload?: boolean;\r\n// disabled?: boolean;\r\n// debug?: boolean;\r\n// maxSize?: number; // MB\r\n// fileTypes?: string[];\r\n// buttonPlaceHolder?: string;\r\n// buttonIcon?: React.ReactNode;\r\n// ButtonStyle?: ViewStyle;\r\n// ButtonTextStyle?: TextStyle;\r\n// onSuccess?: (result: DownloadResult) => void;\r\n// onError?: (error: any) => void;\r\n// }\r\n// export interface DownloadResult {\r\n// successful: { originalUrl: string; localUri: string | null }[];\r\n// skipped: { originalUrl: string; reason: string }[];\r\n// }\r\n\r\n\r\nimport type { ViewStyle, TextStyle } from 'react-native';\r\n\r\nexport interface FileInfo {\r\n
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["// import type { StyleProp, TextStyle, ViewStyle } from 'react-native';\r\n\r\n// export interface FileInfo {\r\n// fileName: string;\r\n// fileSize: number; \r\n// fileType: string | null;\r\n// fileUri: string;\r\n// base64: string;\r\n// }\r\n\r\n// export interface MyUploaderProps{\r\n// onSelect: (files: FileInfo[]) => void;\r\n// onError?: (error: Error) => void;\r\n// buttonPlaceHolder?: string;\r\n// ButtonStyle?: StyleProp<ViewStyle>;\r\n// ButtonTextStyle?: StyleProp<TextStyle>;\r\n// disabled?: boolean; \r\n// multipleFiles?: boolean;\r\n// fileTypes?: string[];\r\n// maxSize?: number;\r\n// maxFiles?: number;\r\n// excludedUris?: string[];\r\n// }\r\n\r\n// export interface DownloadedFileInfo {\r\n// originalUrl: string;\r\n// localUri: string;\r\n// }\r\n\r\n// export interface SkippedFileInfo {\r\n// originalUrl: string;\r\n// reason: string; \r\n// }\r\n\r\n\r\n\r\n// export interface UploadFileProps {\r\n// files: string[];\r\n// multipleLoad?: boolean;\r\n// disabled?: boolean;\r\n// debug?: boolean; \r\n// maxSize?: number;\r\n// fileTypes?: string[];\r\n// buttonPlaceHolder?: string;\r\n// buttonIcon?: React.ReactNode;\r\n// ButtonStyle?: StyleProp<ViewStyle>;\r\n// ButtonTextStyle?: StyleProp<TextStyle>;\r\n// onSuccess?: (result: DownloadResult) => void;\r\n// onError?: (error: Error) => void;\r\n// }\r\n\r\n// export interface DownloadFileProps {\r\n// files: string[];\r\n// multipleDownload?: boolean;\r\n// disabled?: boolean;\r\n// debug?: boolean;\r\n// maxSize?: number; // MB\r\n// fileTypes?: string[];\r\n// buttonPlaceHolder?: string;\r\n// buttonIcon?: React.ReactNode;\r\n// ButtonStyle?: ViewStyle;\r\n// ButtonTextStyle?: TextStyle;\r\n// onSuccess?: (result: DownloadResult) => void;\r\n// onError?: (error: any) => void;\r\n// }\r\n// export interface DownloadResult {\r\n// successful: { originalUrl: string; localUri: string | null }[];\r\n// skipped: { originalUrl: string; reason: string }[];\r\n// }\r\n\r\n\r\nimport type { ViewStyle, TextStyle } from 'react-native';\r\n\r\nexport interface FileInfo {\r\n fileUri: string;\r\n fileName: string;\r\n fileType: string;\r\n fileSize: number;\r\n base64?: string | null;\r\n}\r\n\r\n\r\n// ----- MyUploader & pickFile Props -----\r\nexport interface DocumentPickerOptions {\r\n multipleFiles?: boolean;\r\n fileTypes?: string[]; // örn: ['image/*', 'application/pdf']\r\n maxSize?: number; // MB cinsinden\r\n maxFiles?: number;\r\n excludedUris?: string[];\r\n}\r\n\r\nexport interface MyUploaderProps extends DocumentPickerOptions {\r\n onSelect: (files: FileInfo[]) => void;\r\n onError?: (error: Error) => void;\r\n buttonPlaceHolder?: string;\r\n ButtonStyle?: ViewStyle;\r\n ButtonTextStyle?: TextStyle;\r\n disabled?: boolean;\r\n}\r\n\r\n// ----- DownloadFile Props -----\r\nexport interface DownloadFileProps {\r\n files: string[];\r\n multipleDownload?: boolean; // multipleFiles yerine multipleDownload (İsim karışmaması için)\r\n disabled?: boolean;\r\n debug?: boolean;\r\n maxSize?: number; // MB\r\n fileTypes?: string[]; // İndirilecek dosyanın Content-Type kontrolü\r\n buttonPlaceHolder?: string;\r\n buttonIcon?: React.ReactNode;\r\n ButtonStyle?: ViewStyle;\r\n ButtonTextStyle?: TextStyle;\r\n onSuccess?: (result: DownloadResult) => void;\r\n onError?: (error: any) => void;\r\n}\r\n\r\n\r\nexport interface DownloadResult {\r\n successful: { originalUrl: string; localUri: string | null }[];\r\n skipped: { originalUrl: string; reason: string }[];\r\n}"],"mappings":"","ignoreList":[]}
|