react-native-my-uploader-android 1.0.25 → 1.0.26

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 CHANGED
@@ -18,7 +18,7 @@ import MyUploader,{FileInfo} from 'react-native-my-uploader-android';
18
18
 
19
19
  const [selectedFiles, setSelectedFiles] = useState<FileInfo[]>([]); // response= base64,fileName,fileSize,fileType,FileUri
20
20
 
21
- Usage
21
+ //for "react-native-my-uploader-android": "^1.0.25" version
22
22
  <MyUploader
23
23
  multipleFiles={false}
24
24
  // maxFiles={3}
@@ -37,8 +37,6 @@ Usage
37
37
  }}
38
38
  />
39
39
 
40
- or
41
-
42
40
  <MyUploader
43
41
  multipleFiles={true}
44
42
  maxFiles={3}
@@ -1,2 +1,4 @@
1
1
  <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+ <uses-permission android:name="android.permission.INTERNET" />
3
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="28" />
2
4
  </manifest>
@@ -0,0 +1,144 @@
1
+ package com.myuploader
2
+
3
+ import android.app.DownloadManager
4
+ import android.content.BroadcastReceiver
5
+ import android.content.Context
6
+ import android.content.Intent
7
+ import android.content.IntentFilter
8
+ import android.net.Uri
9
+ import android.os.Build
10
+ import android.os.Environment
11
+ import android.util.Log
12
+ import android.webkit.CookieManager
13
+ import android.webkit.URLUtil
14
+ import com.facebook.react.bridge.*
15
+ import com.myuploader.BuildConfig
16
+ import java.net.HttpURLConnection
17
+ import java.net.URL
18
+
19
+ class DownloadFileModule(private val reactContext: ReactApplicationContext) :
20
+ ReactContextBaseJavaModule(reactContext) {
21
+
22
+ private val TAG = "DownloadFileModule"
23
+ private val downloadPromises = mutableMapOf<Long, Promise>()
24
+
25
+ override fun getName(): String = "DownloadFile"
26
+
27
+ init {
28
+ val receiver = object : BroadcastReceiver() {
29
+ override fun onReceive(context: Context, intent: Intent) {
30
+ val downloadId = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1)
31
+ if (downloadPromises.containsKey(downloadId)) {
32
+ val promise = downloadPromises[downloadId]
33
+ checkDownloadStatus(downloadId, promise)
34
+ downloadPromises.remove(downloadId)
35
+ }
36
+ }
37
+ }
38
+ val intentFilter = IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)
39
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
40
+ reactContext.registerReceiver(receiver, intentFilter, Context.RECEIVER_NOT_EXPORTED)
41
+ } else {
42
+ reactContext.registerReceiver(receiver, intentFilter)
43
+ }
44
+ }
45
+
46
+ @ReactMethod
47
+ fun downloadFile(fileUrl: String, options: ReadableMap, promise: Promise) {
48
+ val isDebug = if (options.hasKey("debug")) options.getBoolean("debug") else false
49
+ val shouldLog = BuildConfig.DEBUG && isDebug
50
+ val maxSizeMB = if (options.hasKey("maxSize")) options.getDouble("maxSize") else 0.0
51
+
52
+ if (shouldLog) Log.d(TAG, "İndirme isteği alındı. URL: $fileUrl")
53
+
54
+ Thread {
55
+ try {
56
+ val url = URL(fileUrl)
57
+ val connection = url.openConnection() as HttpURLConnection
58
+ val cookie = CookieManager.getInstance().getCookie(fileUrl)
59
+ if (cookie != null) connection.setRequestProperty("Cookie", cookie)
60
+ connection.requestMethod = "HEAD"
61
+ connection.connect()
62
+
63
+ val responseCode = connection.responseCode
64
+ if (responseCode !in 200..299) {
65
+ promise.reject("E_HTTP_ERROR", "Sunucu hatası: $responseCode")
66
+ return@Thread
67
+ }
68
+
69
+ val fileSize = connection.contentLengthLong
70
+ val contentType = connection.contentType
71
+ val contentDisposition = connection.getHeaderField("Content-Disposition")
72
+ val cleanContentType = contentType?.split(";")?.get(0)?.trim() ?: "*/*"
73
+ val fileName = URLUtil.guessFileName(fileUrl, contentDisposition, cleanContentType)
74
+
75
+ if (shouldLog) Log.d(TAG, "Dosya: $fileName, Boyut: $fileSize bytes, Tip: $cleanContentType")
76
+
77
+ if (maxSizeMB > 0 && fileSize > maxSizeMB * 1024 * 1024) {
78
+ promise.reject("E_FILE_TOO_LARGE", "Dosya boyutu (${(fileSize / 1024.0 / 1024.0).toInt()}MB) belirtilen limitten (${maxSizeMB}MB) büyük.")
79
+ return@Thread
80
+ }
81
+
82
+ val request = DownloadManager.Request(Uri.parse(fileUrl))
83
+ .setTitle(fileName)
84
+ .setDescription("İndiriliyor...")
85
+ .setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED)
86
+ .setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, fileName)
87
+ .setAllowedOverMetered(true)
88
+
89
+ if (cookie != null) request.addRequestHeader("Cookie", cookie)
90
+ if (cleanContentType != "*/*") request.setMimeType(cleanContentType)
91
+
92
+ val downloadManager = reactContext.getSystemService(Context.DOWNLOAD_SERVICE) as DownloadManager
93
+ val downloadId = downloadManager.enqueue(request)
94
+
95
+ if (BuildConfig.DEBUG) Log.i(TAG, "İndirme sıraya eklendi. ID: #$downloadId")
96
+ downloadPromises[downloadId] = promise
97
+
98
+ } catch (e: Exception) {
99
+ if (BuildConfig.DEBUG) Log.e(TAG, "İndirme başlatılırken hata!", e)
100
+ promise.reject("E_DOWNLOAD_SETUP_FAILED", e.message)
101
+ }
102
+ }.start()
103
+ }
104
+
105
+ private fun checkDownloadStatus(id: Long, promise: Promise?) {
106
+ val downloadManager = reactContext.getSystemService(Context.DOWNLOAD_SERVICE) as DownloadManager
107
+ val query = DownloadManager.Query().setFilterById(id)
108
+ val cursor = downloadManager.query(query)
109
+
110
+ if (cursor.moveToFirst()) {
111
+ val statusIndex = cursor.getColumnIndex(DownloadManager.COLUMN_STATUS)
112
+ val status = cursor.getInt(statusIndex)
113
+
114
+ if (status == DownloadManager.STATUS_SUCCESSFUL) {
115
+ val uriIndex = cursor.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI)
116
+ val localUri = cursor.getString(uriIndex)
117
+ promise?.resolve(localUri)
118
+ } else {
119
+ val reasonIndex = cursor.getColumnIndex(DownloadManager.COLUMN_REASON)
120
+ val reason = cursor.getInt(reasonIndex)
121
+ val reasonText = getDownloadErrorReason(reason)
122
+ promise?.reject("E_DOWNLOAD_FAILED", "İndirme başarısız. Sebep: $reasonText (Kod: $reason)")
123
+ }
124
+ } else {
125
+ promise?.reject("E_DOWNLOAD_NOT_FOUND", "İndirme işlemi bulunamadı.")
126
+ }
127
+ cursor.close()
128
+ }
129
+
130
+ private fun getDownloadErrorReason(reasonCode: Int): String {
131
+ return when (reasonCode) {
132
+ DownloadManager.ERROR_CANNOT_RESUME -> "İndirme devam ettirilemiyor."
133
+ DownloadManager.ERROR_DEVICE_NOT_FOUND -> "Harici depolama bulunamadı."
134
+ DownloadManager.ERROR_FILE_ALREADY_EXISTS -> "Aynı isimde bir dosya zaten var."
135
+ DownloadManager.ERROR_FILE_ERROR -> "Dosya sistemi hatası."
136
+ DownloadManager.ERROR_HTTP_DATA_ERROR -> "Sunucu ile veri alışverişinde hata."
137
+ DownloadManager.ERROR_INSUFFICIENT_SPACE -> "Cihazda yeterli alan yok."
138
+ DownloadManager.ERROR_TOO_MANY_REDIRECTS -> "Çok fazla yönlendirme yapıldı."
139
+ DownloadManager.ERROR_UNHANDLED_HTTP_CODE -> "Sunucudan beklenmeyen HTTP kodu alındı."
140
+ DownloadManager.ERROR_UNKNOWN -> "Bilinmeyen bir hata oluştu."
141
+ else -> "Bilinmeyen hata."
142
+ }
143
+ }
144
+ }
@@ -7,7 +7,10 @@ import com.facebook.react.uimanager.ViewManager
7
7
 
8
8
  class MyUploaderPackage : ReactPackage {
9
9
  override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
10
- return listOf(MyUploaderModule(reactContext))
10
+ return listOf(
11
+ MyUploaderModule(reactContext)
12
+ DownloadFileModule(reactContext)
13
+ )
11
14
  }
12
15
 
13
16
  override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _reactNative = require("react-native");
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
+ const {
11
+ DownloadFile: DownloadFileModule
12
+ } = _reactNative.NativeModules;
13
+ const DownloadFile = ({
14
+ files,
15
+ multipleLoad = false,
16
+ disabled = false,
17
+ debug = false,
18
+ maxSize = 0,
19
+ fileTypes = ['*/*'],
20
+ buttonPlaceHolder = 'Dosyaları İndir',
21
+ buttonIcon,
22
+ ButtonStyle,
23
+ ButtonTextStyle,
24
+ onSuccess = () => {},
25
+ onError = error => console.error('DownloadFile Error:', error)
26
+ }) => {
27
+ const [isLoading, setIsLoading] = (0, _react.useState)(false);
28
+ const handlePress = async () => {
29
+ if (!DownloadFileModule) {
30
+ onError(new Error("DownloadFile native module is not available."));
31
+ return;
32
+ }
33
+ setIsLoading(true);
34
+ const downloadOptions = {
35
+ maxSize,
36
+ fileTypes,
37
+ debug
38
+ };
39
+ try {
40
+ const filesToProcess = multipleLoad ? files : files.slice(0, 1);
41
+ const downloadPromises = filesToProcess.map(url => DownloadFileModule.downloadFile(url, downloadOptions));
42
+ const settledResults = await Promise.allSettled(downloadPromises);
43
+ const finalResult = {
44
+ successful: [],
45
+ skipped: []
46
+ };
47
+ settledResults.forEach((result, index) => {
48
+ // DÜZELTME: `filesToProcess[index]` ifadesinin sonuna `!` ekleyerek
49
+ // TypeScript'e bu değerin asla undefined olmayacağını bildiriyoruz.
50
+ const originalUrl = filesToProcess[index];
51
+ if (result.status === 'fulfilled') {
52
+ finalResult.successful.push({
53
+ originalUrl,
54
+ // Artık hata vermeyecek
55
+ localUri: result.value
56
+ });
57
+ } else {
58
+ finalResult.skipped.push({
59
+ originalUrl,
60
+ // Artık hata vermeyecek
61
+ reason: result.reason.message
62
+ });
63
+ }
64
+ });
65
+ onSuccess(finalResult);
66
+ } catch (error) {
67
+ onError(error);
68
+ } finally {
69
+ setIsLoading(false);
70
+ }
71
+ };
72
+ const content = isLoading ? /*#__PURE__*/_react.default.createElement(_reactNative.ActivityIndicator, {
73
+ color: "#FFFFFF"
74
+ }) : buttonIcon || /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
75
+ style: [styles.buttonText, ButtonTextStyle]
76
+ }, buttonPlaceHolder);
77
+ return /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, {
78
+ style: [styles.button, ButtonStyle, (disabled || isLoading) && styles.disabledButton],
79
+ onPress: handlePress,
80
+ disabled: disabled || isLoading
81
+ }, content);
82
+ };
83
+ const styles = _reactNative.StyleSheet.create({
84
+ button: {
85
+ backgroundColor: '#008CBA',
86
+ paddingHorizontal: 20,
87
+ paddingVertical: 10,
88
+ borderRadius: 8,
89
+ alignItems: 'center',
90
+ justifyContent: 'center',
91
+ flexDirection: 'row'
92
+ },
93
+ buttonText: {
94
+ color: '#FFFFFF',
95
+ fontSize: 16,
96
+ fontWeight: 'bold'
97
+ },
98
+ disabledButton: {
99
+ backgroundColor: '#A9A9A9'
100
+ }
101
+ });
102
+ var _default = exports.default = DownloadFile;
103
+ //# sourceMappingURL=DownloadFile.js.map
@@ -0,0 +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","DownloadFileModule","NativeModules","files","multipleLoad","disabled","debug","maxSize","fileTypes","buttonPlaceHolder","buttonIcon","ButtonStyle","ButtonTextStyle","onSuccess","onError","error","console","isLoading","setIsLoading","useState","handlePress","Error","downloadOptions","filesToProcess","slice","downloadPromises","map","url","downloadFile","settledResults","Promise","allSettled","finalResult","successful","skipped","forEach","result","index","originalUrl","status","push","localUri","value","reason","message","content","createElement","ActivityIndicator","color","Text","style","styles","buttonText","TouchableOpacity","button","disabledButton","onPress","StyleSheet","create","backgroundColor","paddingHorizontal","paddingVertical","borderRadius","alignItems","justifyContent","flexDirection","fontSize","fontWeight","_default","exports"],"sources":["DownloadFile.tsx"],"sourcesContent":["import React, { useState } from 'react';\r\nimport { NativeModules, TouchableOpacity, Text, StyleSheet, ActivityIndicator } from 'react-native';\r\nimport type { DownloadFileProps, DownloadResult } from '../types';\r\n\r\nconst { DownloadFile: DownloadFileModule } = NativeModules;\r\n\r\nconst DownloadFile: React.FC<DownloadFileProps> = ({\r\n files,\r\n multipleLoad = 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 = (error) => console.error('DownloadFile Error:', error),\r\n}) => {\r\n const [isLoading, setIsLoading] = useState(false);\r\n\r\n const handlePress = async () => {\r\n if (!DownloadFileModule) {\r\n onError(new Error(\"DownloadFile native module is not available.\"));\r\n return;\r\n }\r\n\r\n setIsLoading(true);\r\n const downloadOptions = { maxSize, fileTypes, debug };\r\n\r\n try {\r\n const filesToProcess = multipleLoad ? files : files.slice(0, 1);\r\n const downloadPromises = filesToProcess.map(url => \r\n DownloadFileModule.downloadFile(url, downloadOptions)\r\n );\r\n\r\n const settledResults = await Promise.allSettled(downloadPromises);\r\n\r\n const finalResult: DownloadResult = { successful: [], skipped: [] };\r\n\r\n settledResults.forEach((result, index) => {\r\n // DÜZELTME: `filesToProcess[index]` ifadesinin sonuna `!` ekleyerek\r\n // TypeScript'e bu değerin asla undefined olmayacağını bildiriyoruz.\r\n const originalUrl = filesToProcess[index]!;\r\n\r\n if (result.status === 'fulfilled') {\r\n finalResult.successful.push({\r\n originalUrl, // Artık hata vermeyecek\r\n localUri: result.value,\r\n });\r\n } else {\r\n finalResult.skipped.push({\r\n originalUrl, // Artık hata vermeyecek\r\n reason: result.reason.message,\r\n });\r\n }\r\n });\r\n \r\n onSuccess(finalResult);\r\n\r\n } catch (error: any) {\r\n onError(error);\r\n } finally {\r\n setIsLoading(false);\r\n }\r\n };\r\n\r\n const content = isLoading ? (\r\n <ActivityIndicator color=\"#FFFFFF\" />\r\n ) : (\r\n buttonIcon || <Text style={[styles.buttonText, ButtonTextStyle]}>{buttonPlaceHolder}</Text>\r\n );\r\n\r\n return (\r\n <TouchableOpacity\r\n style={[styles.button, ButtonStyle, (disabled || isLoading) && styles.disabledButton]}\r\n onPress={handlePress}\r\n disabled={disabled || isLoading}\r\n >\r\n {content}\r\n </TouchableOpacity>\r\n );\r\n};\r\n\r\nconst styles = StyleSheet.create({\r\n button: {\r\n backgroundColor: '#008CBA',\r\n paddingHorizontal: 20,\r\n paddingVertical: 10,\r\n borderRadius: 8,\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n flexDirection: 'row',\r\n },\r\n buttonText: {\r\n color: '#FFFFFF',\r\n fontSize: 16,\r\n fontWeight: 'bold',\r\n },\r\n disabledButton: {\r\n backgroundColor: '#A9A9A9',\r\n },\r\n});\r\n\r\nexport default DownloadFile;"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAAoG,SAAAD,wBAAAG,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAL,uBAAA,YAAAA,CAAAG,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,C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+1,119 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ exports.pickFile = pickFile;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _reactNative = require("react-native");
10
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
+ const LINKING_ERROR = `The package 'react-native-my-uploader' doesn't seem to be linked.`;
12
+ const DocumentPicker = _reactNative.NativeModules.DocumentPicker ? _reactNative.NativeModules.DocumentPicker : new Proxy({}, {
13
+ get() {
14
+ throw new Error(LINKING_ERROR);
15
+ }
16
+ });
17
+
18
+ // Mevcut pickFile fonksiyonunu dahili (internal) olarak kullanmak üzere saklayalım.
19
+ // İsterseniz bunu dışa aktarmaya devam edebilirsiniz.
20
+ async function pickFile(options = {}) {
21
+ var _options$excludedUris, _options$fileTypes, _options$maxSize;
22
+ const {
23
+ multipleFiles = false,
24
+ maxFiles = 0,
25
+ ...rest
26
+ } = options;
27
+ if (!multipleFiles && maxFiles > 1) {
28
+ throw new Error('`maxFiles` cannot be greater than 1 when `multipleFiles` is false.');
29
+ }
30
+ let effectiveMaxFiles = maxFiles;
31
+ if (multipleFiles && maxFiles === 0) {
32
+ effectiveMaxFiles = 3;
33
+ }
34
+ const finalOptions = {
35
+ ...rest,
36
+ multipleFiles,
37
+ maxFiles: effectiveMaxFiles,
38
+ excludedUris: (_options$excludedUris = options.excludedUris) !== null && _options$excludedUris !== void 0 ? _options$excludedUris : [],
39
+ fileTypes: (_options$fileTypes = options.fileTypes) !== null && _options$fileTypes !== void 0 ? _options$fileTypes : ['*/*'],
40
+ maxSize: (_options$maxSize = options.maxSize) !== null && _options$maxSize !== void 0 ? _options$maxSize : 0
41
+ };
42
+ return DocumentPicker.openDocument(finalOptions);
43
+ }
44
+
45
+ // YENİ: MyUploader Component'i
46
+ const MyUploaderAndroid = ({
47
+ // DocumentPickerOptions
48
+ multipleFiles = false,
49
+ maxFiles = 0,
50
+ fileTypes = ['*/*'],
51
+ maxSize = 0,
52
+ excludedUris = [],
53
+ // UI Props with defaults
54
+ buttonPlaceHolder = 'Dosya Seçin...',
55
+ ButtonStyle,
56
+ ButtonTextStyle,
57
+ disabled = false,
58
+ // Callbacks
59
+ onSelect,
60
+ onError = error => console.error('MyUploader Error:', error)
61
+ }) => {
62
+ const handlePress = async () => {
63
+ try {
64
+ const options = {
65
+ multipleFiles,
66
+ maxFiles,
67
+ fileTypes,
68
+ maxSize,
69
+ excludedUris
70
+ };
71
+ const selectedFiles = await pickFile(options);
72
+
73
+ // Eğer kullanıcı seçim yapmadan kapatırsa bazı sistemler boş array dönebilir.
74
+ // Sadece doluysa callback'i tetikleyelim.
75
+ if (selectedFiles && selectedFiles.length > 0) {
76
+ onSelect(selectedFiles);
77
+ }
78
+ } catch (error) {
79
+ // Kullanıcının seçimi iptal etmesi bir "hata" sayılmamalı,
80
+ // bu yüzden sadece konsola yazdırıp onError'ı tetiklemeyebiliriz.
81
+ // Native kodunuz "E_PICKER_CANCELLED" koduyla reject ediyor.
82
+ if (error.code !== 'E_PICKER_CANCELLED') {
83
+ onError(error);
84
+ }
85
+ }
86
+ };
87
+ return /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, {
88
+ style: [styles.button, ButtonStyle, disabled && styles.disabledButton],
89
+ onPress: handlePress,
90
+ disabled: disabled
91
+ }, /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
92
+ style: [styles.buttonText, ButtonTextStyle]
93
+ }, buttonPlaceHolder));
94
+ };
95
+
96
+ // Varsayılan stiller
97
+ const styles = _reactNative.StyleSheet.create({
98
+ button: {
99
+ backgroundColor: '#007AFF',
100
+ paddingHorizontal: 20,
101
+ paddingVertical: 10,
102
+ borderRadius: 8,
103
+ alignItems: 'center',
104
+ justifyContent: 'center'
105
+ },
106
+ buttonText: {
107
+ color: '#FFFFFF',
108
+ fontSize: 16,
109
+ fontWeight: 'bold'
110
+ },
111
+ disabledButton: {
112
+ backgroundColor: '#A9A9A9'
113
+ }
114
+ });
115
+
116
+ // İhtiyaca göre pickFile'ı da export edebilirsiniz.
117
+ // Component'i varsayılan olarak export ediyoruz.
118
+ var _default = exports.default = MyUploaderAndroid;
119
+ //# sourceMappingURL=MyUploader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","_interopRequireDefault","require","_reactNative","e","__esModule","default","LINKING_ERROR","DocumentPicker","NativeModules","Proxy","get","Error","pickFile","options","_options$excludedUris","_options$fileTypes","_options$maxSize","multipleFiles","maxFiles","rest","effectiveMaxFiles","finalOptions","excludedUris","fileTypes","maxSize","openDocument","MyUploaderAndroid","buttonPlaceHolder","ButtonStyle","ButtonTextStyle","disabled","onSelect","onError","error","console","handlePress","selectedFiles","length","code","createElement","TouchableOpacity","style","styles","button","disabledButton","onPress","Text","buttonText","StyleSheet","create","backgroundColor","paddingHorizontal","paddingVertical","borderRadius","alignItems","justifyContent","color","fontSize","fontWeight","_default","exports"],"sources":["MyUploader.tsx"],"sourcesContent":["import React from 'react';\r\nimport {NativeModules,TouchableOpacity,Text,StyleSheet} from 'react-native';\r\nimport type {FileInfo,DocumentPickerOptions, MyUploaderProps} from '../types';\r\n\r\nconst LINKING_ERROR = `The package 'react-native-my-uploader' doesn't seem to be linked.`;\r\n\r\nconst DocumentPicker = NativeModules.DocumentPicker\r\n ? NativeModules.DocumentPicker\r\n : new Proxy(\r\n {},\r\n {\r\n get() {\r\n throw new Error(LINKING_ERROR);\r\n },\r\n }\r\n );\r\n\r\n// Mevcut pickFile fonksiyonunu dahili (internal) olarak kullanmak üzere saklayalım.\r\n// İsterseniz bunu dışa aktarmaya devam edebilirsiniz.\r\nasync function pickFile(\r\n options: DocumentPickerOptions = {}\r\n): Promise<FileInfo[]> {\r\n const { multipleFiles = false, maxFiles = 0, ...rest } = options;\r\n\r\n if (!multipleFiles && maxFiles > 1) {\r\n throw new Error(\r\n '`maxFiles` cannot be greater than 1 when `multipleFiles` is false.'\r\n );\r\n }\r\n let effectiveMaxFiles = maxFiles;\r\n if (multipleFiles && maxFiles === 0) {\r\n effectiveMaxFiles = 3;\r\n }\r\n const finalOptions: DocumentPickerOptions = {\r\n ...rest,\r\n multipleFiles,\r\n maxFiles: effectiveMaxFiles,\r\n excludedUris: options.excludedUris ?? [],\r\n fileTypes: options.fileTypes ?? ['*/*'],\r\n maxSize: options.maxSize ?? 0,\r\n };\r\n return DocumentPicker.openDocument(finalOptions);\r\n}\r\n\r\n// YENİ: MyUploader Component'i\r\nconst MyUploaderAndroid: React.FC<MyUploaderProps> = ({\r\n // DocumentPickerOptions\r\n multipleFiles = false,\r\n maxFiles = 0,\r\n fileTypes = ['*/*'],\r\n maxSize = 0,\r\n excludedUris = [],\r\n // UI Props with defaults\r\n buttonPlaceHolder = 'Dosya Seçin...',\r\n ButtonStyle,\r\n ButtonTextStyle,\r\n disabled = false,\r\n // Callbacks\r\n onSelect,\r\n onError = (error) => console.error('MyUploader Error:', error),\r\n}) => {\r\n const handlePress = async () => {\r\n try {\r\n const options: DocumentPickerOptions = {\r\n multipleFiles,\r\n maxFiles,\r\n fileTypes,\r\n maxSize,\r\n excludedUris,\r\n };\r\n const selectedFiles = await pickFile(options);\r\n \r\n // Eğer kullanıcı seçim yapmadan kapatırsa bazı sistemler boş array dönebilir.\r\n // Sadece doluysa callback'i tetikleyelim.\r\n if (selectedFiles && selectedFiles.length > 0) {\r\n onSelect(selectedFiles);\r\n }\r\n\r\n } catch (error: any) {\r\n // Kullanıcının seçimi iptal etmesi bir \"hata\" sayılmamalı,\r\n // bu yüzden sadece konsola yazdırıp onError'ı tetiklemeyebiliriz.\r\n // Native kodunuz \"E_PICKER_CANCELLED\" koduyla reject ediyor.\r\n if (error.code !== 'E_PICKER_CANCELLED') {\r\n onError(error);\r\n }\r\n }\r\n };\r\n\r\n return (\r\n <TouchableOpacity\r\n style={[styles.button, ButtonStyle, disabled && styles.disabledButton]}\r\n onPress={handlePress}\r\n disabled={disabled}\r\n >\r\n <Text style={[styles.buttonText, ButtonTextStyle]}>\r\n {buttonPlaceHolder}\r\n </Text>\r\n </TouchableOpacity>\r\n );\r\n};\r\n\r\n// Varsayılan stiller\r\nconst styles = StyleSheet.create({\r\n button: {\r\n backgroundColor: '#007AFF',\r\n paddingHorizontal: 20,\r\n paddingVertical: 10,\r\n borderRadius: 8,\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n },\r\n buttonText: {\r\n color: '#FFFFFF',\r\n fontSize: 16,\r\n fontWeight: 'bold',\r\n },\r\n disabledButton: {\r\n backgroundColor: '#A9A9A9',\r\n },\r\n});\r\n\r\n// İhtiyaca göre pickFile'ı da export edebilirsiniz.\r\nexport { pickFile };\r\nexport type { FileInfo, DocumentPickerOptions, MyUploaderProps } from \"../types\";\r\n\r\n// Component'i varsayılan olarak export ediyoruz.\r\nexport default MyUploaderAndroid;"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAA4E,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAG5E,MAAMG,aAAa,GAAG,mEAAmE;AAEzF,MAAMC,cAAc,GAAGC,0BAAa,CAACD,cAAc,GAC/CC,0BAAa,CAACD,cAAc,GAC5B,IAAIE,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACL,aAAa,CAAC;EAChC;AACF,CACF,CAAC;;AAEL;AACA;AACA,eAAeM,QAAQA,CACrBC,OAA8B,GAAG,CAAC,CAAC,EACd;EAAA,IAAAC,qBAAA,EAAAC,kBAAA,EAAAC,gBAAA;EACrB,MAAM;IAAEC,aAAa,GAAG,KAAK;IAAEC,QAAQ,GAAG,CAAC;IAAE,GAAGC;EAAK,CAAC,GAAGN,OAAO;EAEhE,IAAI,CAACI,aAAa,IAAIC,QAAQ,GAAG,CAAC,EA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,aAAa,IAAIA,aAAa,CAACC,MAAM,GAAG,CAAC,EAAE;QAC7CN,QAAQ,CAACK,aAAa,CAAC;MACzB;IAEF,CAAC,CAAC,OAAOH,KAAU,EAAE;MACnB;MACA;MACA;MACA,IAAIA,KAAK,CAACK,IAAI,KAAK,oBAAoB,EAAE;QACvCN,OAAO,CAACC,KAAK,CAAC;MAChB;IACF;EACF,CAAC;EAED,oBACElC,MAAA,CAAAM,OAAA,CAAAkC,aAAA,CAACrC,YAAA,CAAAsC,gBAAgB;IACfC,KAAK,EAAE,CAACC,MAAM,CAACC,MAAM,EAAEf,WAAW,EAAEE,QAAQ,IAAIY,MAAM,CAACE,cAAc,CAAE;IACvEC,OAAO,EAAEV,WAAY;IACrBL,QAAQ,EAAEA;EAAS,gBAEnB/B,MAAA,CAAAM,OAAA,CAAAkC,aAAA,CAACrC,YAAA,CAAA4C,IAAI;IAACL,KAAK,EAAE,CAACC,MAAM,CAACK,UAAU,EAAElB,eAAe;EAAE,GAC/CF,iBACG,CACU,CAAC;AAEvB,CAAC;;AAED;AACA,MAAMe,MAAM,GAAGM,uBAAU,CAACC,MAAM,CAAC;EAC/BN,MAAM,EAAE;IACNO,eAAe,EAAE,SAAS;IAC1BC,iBAAiB,EAAE,EAAE;IACrBC,eAAe,EAAE,EAAE;IACnBC,YAAY,EAAE,CAAC;IACfC,UAAU,EAAE,QAAQ;IACpBC,cAAc,EAAE;EAClB,CAAC;EACDR,UAAU,EAAE;IACVS,KAAK,EAAE,SAAS;IAChBC,QAAQ,EAAE,EAAE;IACZC,UAAU,EAAE;EACd,CAAC;EACDd,cAAc,EAAE;IACdM,eAAe,EAAE;EACnB;AACF,CAAC,CAAC;;AAEF;AAIA;AAAA,IAAAS,QAAA,GAAAC,OAAA,CAAAvD,OAAA,GACeqB,iBAAiB","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\r\nexport * from './types';\r\n\r\ndeclare const MyUploader: React.FC<MyUploaderProps>;\r\n\r\nexport default MyUploader;\r\n\r\nexport function pickFile(options?: DocumentPickerOptions): Promise<FileInfo[]>;"],"mappings":";;;;;AAGA,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":[]}
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\r\nexport * from './types';\r\n\r\ndeclare const MyUploader: React.FC<MyUploaderProps>;\r\nexport default MyUploader;\r\n\r\nexport declare const DownloadFile: React.FC<DownloadFileProps>;\r\nexport function pickFile(options?: DocumentPickerOptions): Promise<FileInfo[]>;"],"mappings":";;;;;AAGA,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":[]}
@@ -3,117 +3,39 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
7
- exports.pickFile = pickFile;
8
- var _react = _interopRequireDefault(require("react"));
9
- var _reactNative = require("react-native");
10
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
- const LINKING_ERROR = `The package 'react-native-my-uploader' doesn't seem to be linked.`;
12
- const DocumentPicker = _reactNative.NativeModules.DocumentPicker ? _reactNative.NativeModules.DocumentPicker : new Proxy({}, {
13
- get() {
14
- throw new Error(LINKING_ERROR);
6
+ var _exportNames = {
7
+ pickFile: true,
8
+ DownloadFileAndroid: true
9
+ };
10
+ Object.defineProperty(exports, "DownloadFileAndroid", {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _DownloadFile.default;
15
14
  }
16
15
  });
17
-
18
- // Mevcut pickFile fonksiyonunu dahili (internal) olarak kullanmak üzere saklayalım.
19
- // İsterseniz bunu dışa aktarmaya devam edebilirsiniz.
20
- async function pickFile(options = {}) {
21
- var _options$excludedUris, _options$fileTypes, _options$maxSize;
22
- const {
23
- multipleFiles = false,
24
- maxFiles = 0,
25
- ...rest
26
- } = options;
27
- if (!multipleFiles && maxFiles > 1) {
28
- throw new Error('`maxFiles` cannot be greater than 1 when `multipleFiles` is false.');
29
- }
30
- let effectiveMaxFiles = maxFiles;
31
- if (multipleFiles && maxFiles === 0) {
32
- effectiveMaxFiles = 3;
16
+ exports.default = void 0;
17
+ Object.defineProperty(exports, "pickFile", {
18
+ enumerable: true,
19
+ get: function () {
20
+ return _MyUploader.pickFile;
33
21
  }
34
- const finalOptions = {
35
- ...rest,
36
- multipleFiles,
37
- maxFiles: effectiveMaxFiles,
38
- excludedUris: (_options$excludedUris = options.excludedUris) !== null && _options$excludedUris !== void 0 ? _options$excludedUris : [],
39
- fileTypes: (_options$fileTypes = options.fileTypes) !== null && _options$fileTypes !== void 0 ? _options$fileTypes : ['*/*'],
40
- maxSize: (_options$maxSize = options.maxSize) !== null && _options$maxSize !== void 0 ? _options$maxSize : 0
41
- };
42
- return DocumentPicker.openDocument(finalOptions);
43
- }
44
-
45
- // YENİ: MyUploader Component'i
46
- const MyUploaderAndroid = ({
47
- // DocumentPickerOptions
48
- multipleFiles = false,
49
- maxFiles = 0,
50
- fileTypes = ['*/*'],
51
- maxSize = 0,
52
- excludedUris = [],
53
- // UI Props with defaults
54
- buttonPlaceHolder = 'Dosya Seçin...',
55
- ButtonStyle,
56
- ButtonTextStyle,
57
- disabled = false,
58
- // Callbacks
59
- onSelect,
60
- onError = error => console.error('MyUploader Error:', error)
61
- }) => {
62
- const handlePress = async () => {
63
- try {
64
- const options = {
65
- multipleFiles,
66
- maxFiles,
67
- fileTypes,
68
- maxSize,
69
- excludedUris
70
- };
71
- const selectedFiles = await pickFile(options);
72
-
73
- // Eğer kullanıcı seçim yapmadan kapatırsa bazı sistemler boş array dönebilir.
74
- // Sadece doluysa callback'i tetikleyelim.
75
- if (selectedFiles && selectedFiles.length > 0) {
76
- onSelect(selectedFiles);
77
- }
78
- } catch (error) {
79
- // Kullanıcının seçimi iptal etmesi bir "hata" sayılmamalı,
80
- // bu yüzden sadece konsola yazdırıp onError'ı tetiklemeyebiliriz.
81
- // Native kodunuz "E_PICKER_CANCELLED" koduyla reject ediyor.
82
- if (error.code !== 'E_PICKER_CANCELLED') {
83
- onError(error);
84
- }
22
+ });
23
+ var _MyUploader = _interopRequireWildcard(require("./components/MyUploader"));
24
+ var _DownloadFile = _interopRequireDefault(require("./components/DownloadFile"));
25
+ var _types = require("./types");
26
+ Object.keys(_types).forEach(function (key) {
27
+ if (key === "default" || key === "__esModule") return;
28
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
29
+ if (key in exports && exports[key] === _types[key]) return;
30
+ Object.defineProperty(exports, key, {
31
+ enumerable: true,
32
+ get: function () {
33
+ return _types[key];
85
34
  }
86
- };
87
- return /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, {
88
- style: [styles.button, ButtonStyle, disabled && styles.disabledButton],
89
- onPress: handlePress,
90
- disabled: disabled
91
- }, /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
92
- style: [styles.buttonText, ButtonTextStyle]
93
- }, buttonPlaceHolder));
94
- };
95
-
96
- // Varsayılan stiller
97
- const styles = _reactNative.StyleSheet.create({
98
- button: {
99
- backgroundColor: '#007AFF',
100
- paddingHorizontal: 20,
101
- paddingVertical: 10,
102
- borderRadius: 8,
103
- alignItems: 'center',
104
- justifyContent: 'center'
105
- },
106
- buttonText: {
107
- color: '#FFFFFF',
108
- fontSize: 16,
109
- fontWeight: 'bold'
110
- },
111
- disabledButton: {
112
- backgroundColor: '#A9A9A9'
113
- }
35
+ });
114
36
  });
115
-
116
- // İhtiyaca göre pickFile'ı da export edebilirsiniz.
117
- // Component'i varsayılan olarak export ediyoruz.
118
- var _default = exports.default = MyUploaderAndroid;
37
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
38
+ 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); }
39
+ // Component'leri ve fonksiyonları dışa aktar
40
+ var _default = exports.default = _MyUploader.default;
119
41
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireDefault","require","_reactNative","e","__esModule","default","LINKING_ERROR","DocumentPicker","NativeModules","Proxy","get","Error","pickFile","options","_options$excludedUris","_options$fileTypes","_options$maxSize","multipleFiles","maxFiles","rest","effectiveMaxFiles","finalOptions","excludedUris","fileTypes","maxSize","openDocument","MyUploaderAndroid","buttonPlaceHolder","ButtonStyle","ButtonTextStyle","disabled","onSelect","onError","error","console","handlePress","selectedFiles","length","code","createElement","TouchableOpacity","style","styles","button","disabledButton","onPress","Text","buttonText","StyleSheet","create","backgroundColor","paddingHorizontal","paddingVertical","borderRadius","alignItems","justifyContent","color","fontSize","fontWeight","_default","exports"],"sources":["index.tsx"],"sourcesContent":["import React from 'react';\r\nimport {NativeModules,TouchableOpacity,Text,StyleSheet} from 'react-native';\r\nimport type {FileInfo,DocumentPickerOptions, MyUploaderProps} from './types';\r\n\r\nconst LINKING_ERROR = `The package 'react-native-my-uploader' doesn't seem to be linked.`;\r\n\r\nconst DocumentPicker = NativeModules.DocumentPicker\r\n ? NativeModules.DocumentPicker\r\n : new Proxy(\r\n {},\r\n {\r\n get() {\r\n throw new Error(LINKING_ERROR);\r\n },\r\n }\r\n );\r\n\r\n// Mevcut pickFile fonksiyonunu dahili (internal) olarak kullanmak üzere saklayalım.\r\n// İsterseniz bunu dışa aktarmaya devam edebilirsiniz.\r\nasync function pickFile(\r\n options: DocumentPickerOptions = {}\r\n): Promise<FileInfo[]> {\r\n const { multipleFiles = false, maxFiles = 0, ...rest } = options;\r\n\r\n if (!multipleFiles && maxFiles > 1) {\r\n throw new Error(\r\n '`maxFiles` cannot be greater than 1 when `multipleFiles` is false.'\r\n );\r\n }\r\n let effectiveMaxFiles = maxFiles;\r\n if (multipleFiles && maxFiles === 0) {\r\n effectiveMaxFiles = 3;\r\n }\r\n const finalOptions: DocumentPickerOptions = {\r\n ...rest,\r\n multipleFiles,\r\n maxFiles: effectiveMaxFiles,\r\n excludedUris: options.excludedUris ?? [],\r\n fileTypes: options.fileTypes ?? ['*/*'],\r\n maxSize: options.maxSize ?? 0,\r\n };\r\n return DocumentPicker.openDocument(finalOptions);\r\n}\r\n\r\n// YENİ: MyUploader Component'i\r\nconst MyUploaderAndroid: React.FC<MyUploaderProps> = ({\r\n // DocumentPickerOptions\r\n multipleFiles = false,\r\n maxFiles = 0,\r\n fileTypes = ['*/*'],\r\n maxSize = 0,\r\n excludedUris = [],\r\n // UI Props with defaults\r\n buttonPlaceHolder = 'Dosya Seçin...',\r\n ButtonStyle,\r\n ButtonTextStyle,\r\n disabled = false,\r\n // Callbacks\r\n onSelect,\r\n onError = (error) => console.error('MyUploader Error:', error),\r\n}) => {\r\n const handlePress = async () => {\r\n try {\r\n const options: DocumentPickerOptions = {\r\n multipleFiles,\r\n maxFiles,\r\n fileTypes,\r\n maxSize,\r\n excludedUris,\r\n };\r\n const selectedFiles = await pickFile(options);\r\n \r\n // Eğer kullanıcı seçim yapmadan kapatırsa bazı sistemler boş array dönebilir.\r\n // Sadece doluysa callback'i tetikleyelim.\r\n if (selectedFiles && selectedFiles.length > 0) {\r\n onSelect(selectedFiles);\r\n }\r\n\r\n } catch (error: any) {\r\n // Kullanıcının seçimi iptal etmesi bir \"hata\" sayılmamalı,\r\n // bu yüzden sadece konsola yazdırıp onError'ı tetiklemeyebiliriz.\r\n // Native kodunuz \"E_PICKER_CANCELLED\" koduyla reject ediyor.\r\n if (error.code !== 'E_PICKER_CANCELLED') {\r\n onError(error);\r\n }\r\n }\r\n };\r\n\r\n return (\r\n <TouchableOpacity\r\n style={[styles.button, ButtonStyle, disabled && styles.disabledButton]}\r\n onPress={handlePress}\r\n disabled={disabled}\r\n >\r\n <Text style={[styles.buttonText, ButtonTextStyle]}>\r\n {buttonPlaceHolder}\r\n </Text>\r\n </TouchableOpacity>\r\n );\r\n};\r\n\r\n// Varsayılan stiller\r\nconst styles = StyleSheet.create({\r\n button: {\r\n backgroundColor: '#007AFF',\r\n paddingHorizontal: 20,\r\n paddingVertical: 10,\r\n borderRadius: 8,\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n },\r\n buttonText: {\r\n color: '#FFFFFF',\r\n fontSize: 16,\r\n fontWeight: 'bold',\r\n },\r\n disabledButton: {\r\n backgroundColor: '#A9A9A9',\r\n },\r\n});\r\n\r\n// İhtiyaca göre pickFile'ı da export edebilirsiniz.\r\nexport { pickFile };\r\nexport type { FileInfo, DocumentPickerOptions, MyUploaderProps } from './types';\r\n\r\n// Component'i varsayılan olarak export ediyoruz.\r\nexport default MyUploaderAndroid;"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAA4E,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAG5E,MAAMG,aAAa,GAAG,mEAAmE;AAEzF,MAAMC,cAAc,GAAGC,0BAAa,CAACD,cAAc,GAC/CC,0BAAa,CAACD,cAAc,GAC5B,IAAIE,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACL,aAAa,CAAC;EAChC;AACF,CACF,CAAC;;AAEL;AACA;AACA,eAAeM,QAAQA,CACrBC,OAA8B,GAAG,CAAC,CAAC,EACd;EAAA,IAAAC,qBAAA,EAAAC,kBAAA,EAAAC,gBAAA;EACrB,MAAM;IAAEC,aAAa,GAAG,KAAK;IAAEC,QAAQ,GAAG,CAAC;IAAE,GAAGC;EAAK,CAAC,GAAGN,OAAO;EAEhE,IAAI,CAACI,aAAa,IAAIC,QAAQ,GAAG,CAAC,EAAE;IAClC,MAAM,IAAIP,KAAK,CACb,oEACF,CAAC;EACH;EACA,IAAIS,iBAAiB,GAAGF,QAAQ;EAChC,IAAID,aAAa,IAAIC,QAAQ,KAAK,CAAC,EAAE;IACnCE,iBAAiB,GAAG,CAAC;EACvB;EACA,MAAMC,YAAmC,GAAG;IAC1C,GAAGF,IAAI;IACPF,aAAa;IACbC,QAAQ,EAAEE,iBAAiB;IAC3BE,YAAY,GAAAR,qBAAA,GAAED,OAAO,CAACS,YAAY,cAAAR,qBAAA,c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fC,KAAK,EAAE,CAACC,MAAM,CAACC,MAAM,EAAEf,WAAW,EAAEE,QAAQ,IAAIY,MAAM,CAACE,cAAc,CAAE;IACvEC,OAAO,EAAEV,WAAY;IACrBL,QAAQ,EAAEA;EAAS,gBAEnB/B,MAAA,CAAAM,OAAA,CAAAkC,aAAA,CAACrC,YAAA,CAAA4C,IAAI;IAACL,KAAK,EAAE,CAACC,MAAM,CAACK,UAAU,EAAElB,eAAe;EAAE,GAC/CF,iBACG,CACU,CAAC;AAEvB,CAAC;;AAED;AACA,MAAMe,MAAM,GAAGM,uBAAU,CAACC,MAAM,CAAC;EAC/BN,MAAM,EAAE;IACNO,eAAe,EAAE,SAAS;IAC1BC,iBAAiB,EAAE,EAAE;IACrBC,eAAe,EAAE,EAAE;IACnBC,YAAY,EAAE,CAAC;IACfC,UAAU,EAAE,QAAQ;IACpBC,cAAc,EAAE;EAClB,CAAC;EACDR,UAAU,EAAE;IACVS,KAAK,EAAE,SAAS;IAChBC,QAAQ,EAAE,EAAE;IACZC,UAAU,EAAE;EACd,CAAC;EACDd,cAAc,EAAE;IACdM,eAAe,EAAE;EACnB;AACF,CAAC,CAAC;;AAEF;AAIA;AAAA,IAAAS,QAAA,GAAAC,OAAA,CAAAvD,OAAA,GACeqB,iBAAiB","ignoreList":[]}
1
+ {"version":3,"names":["_MyUploader","_interopRequireWildcard","require","_DownloadFile","_interopRequireDefault","_types","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","set","getOwnPropertyDescriptor","_default","MyUploaderAndroid"],"sources":["index.ts"],"sourcesContent":["import MyUploaderAndroid from \"./components/MyUploader\";\r\nimport DownloadFileAndroid from \"./components/DownloadFile\";\r\nimport { pickFile } from './components/MyUploader';\r\n\r\n// Component'leri ve fonksiyonları dışa aktar\r\nexport { DownloadFileAndroid, pickFile };\r\nexport * from './types';\r\nexport default MyUploaderAndroid;\r\n\r\n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S,CAAA,gBAAAN,CAAA,IAAAH,CAAA,gBAAAG,CAAA,OAAAV,cAAA,CAAAC,IAAA,CAAAM,CAAA,EAAAG,CAAA,OAAAK,CAAA,IAAAD,CAAA,GAAAnB,MAAA,CAAAS,cAAA,KAAAT,MAAA,CAAAyB,wBAAA,CAAAb,CAAA,EAAAG,CAAA,OAAAK,CAAA,CAAAT,GAAA,IAAAS,CAAA,CAAAI,GAAA,IAAAL,CAAA,CAAAE,CAAA,EAAAN,CAAA,EAAAK,CAAA,IAAAC,CAAA,CAAAN,CAAA,IAAAH,CAAA,CAAAG,CAAA,WAAAM,CAAA,KAAAT,CAAA,EAAAG,CAAA;AAFxB;AAAA,IAAAW,QAAA,GAAAlB,OAAA,CAAAM,OAAA,GAGea,mBAAiB","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { StyleProp, TextStyle, ViewStyle } from 'react-native';\r\n\r\nexport interface FileInfo {\r\n fileName: string;\r\n fileSize: number; // in bytes\r\n fileType: string | null;\r\n fileUri: string;\r\n base64: string;\r\n}\r\n\r\nexport interface DocumentPickerOptions {\r\n multipleFiles?: boolean;\r\n fileTypes?: string[];\r\n maxSize?: number;\r\n maxFiles?: number;\r\n excludedUris?: string[];\r\n}\r\nexport interface MyUploaderProps extends DocumentPickerOptions {\r\n // Geri bildirim (callback) fonksiyonları\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}"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { StyleProp, TextStyle, ViewStyle } from 'react-native';\r\n\r\nexport interface FileInfo {\r\n fileName: string;\r\n fileSize: number; // in bytes\r\n fileType: string | null;\r\n fileUri: string;\r\n base64: string;\r\n}\r\n\r\nexport interface DocumentPickerOptions {\r\n multipleFiles?: boolean;\r\n fileTypes?: string[];\r\n maxSize?: number;\r\n maxFiles?: number;\r\n excludedUris?: string[];\r\n}\r\nexport interface MyUploaderProps extends DocumentPickerOptions {\r\n // Geri bildirim (callback) fonksiyonları\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}\r\n\r\n//download File Module Props\r\nexport interface DownloadedFileInfo {\r\n originalUrl: string;\r\n localUri: string; // Cihazdaki dosyanın URI'si\r\n}\r\n\r\n// YENİ: Atlanan dosyalar hakkında bilgi vermek için arayüz\r\nexport interface SkippedFileInfo {\r\n originalUrl: string;\r\n reason: string; // Neden atlandığı (örn: \"Dosya çok büyük\")\r\n}\r\n\r\n// YENİ: onSUCCESS callback'inin döndüreceği sonuç nesnesi\r\nexport interface DownloadResult {\r\n successful: DownloadedFileInfo[];\r\n skipped: SkippedFileInfo[];\r\n}\r\n\r\n// GÜNCELLENDİ: DownloadFileProps arayüzü\r\nexport interface DownloadFileProps {\r\n files: string[];\r\n // YENİ PROPLAR\r\n multipleLoad?: boolean;\r\n disabled?: boolean;\r\n debug?: boolean; // Mevcut debug prop'u\r\n\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 \r\n // GÜNCELLENDİ: Callback daha zengin bir nesne döndürecek\r\n onSuccess?: (result: DownloadResult) => void;\r\n onError?: (error: Error) => void;\r\n}"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,96 @@
1
+ import React, { useState } from 'react';
2
+ import { NativeModules, TouchableOpacity, Text, StyleSheet, ActivityIndicator } from 'react-native';
3
+ const {
4
+ DownloadFile: DownloadFileModule
5
+ } = NativeModules;
6
+ const DownloadFile = ({
7
+ files,
8
+ multipleLoad = false,
9
+ disabled = false,
10
+ debug = false,
11
+ maxSize = 0,
12
+ fileTypes = ['*/*'],
13
+ buttonPlaceHolder = 'Dosyaları İndir',
14
+ buttonIcon,
15
+ ButtonStyle,
16
+ ButtonTextStyle,
17
+ onSuccess = () => {},
18
+ onError = error => console.error('DownloadFile Error:', error)
19
+ }) => {
20
+ const [isLoading, setIsLoading] = useState(false);
21
+ const handlePress = async () => {
22
+ if (!DownloadFileModule) {
23
+ onError(new Error("DownloadFile native module is not available."));
24
+ return;
25
+ }
26
+ setIsLoading(true);
27
+ const downloadOptions = {
28
+ maxSize,
29
+ fileTypes,
30
+ debug
31
+ };
32
+ try {
33
+ const filesToProcess = multipleLoad ? files : files.slice(0, 1);
34
+ const downloadPromises = filesToProcess.map(url => DownloadFileModule.downloadFile(url, downloadOptions));
35
+ const settledResults = await Promise.allSettled(downloadPromises);
36
+ const finalResult = {
37
+ successful: [],
38
+ skipped: []
39
+ };
40
+ settledResults.forEach((result, index) => {
41
+ // DÜZELTME: `filesToProcess[index]` ifadesinin sonuna `!` ekleyerek
42
+ // TypeScript'e bu değerin asla undefined olmayacağını bildiriyoruz.
43
+ const originalUrl = filesToProcess[index];
44
+ if (result.status === 'fulfilled') {
45
+ finalResult.successful.push({
46
+ originalUrl,
47
+ // Artık hata vermeyecek
48
+ localUri: result.value
49
+ });
50
+ } else {
51
+ finalResult.skipped.push({
52
+ originalUrl,
53
+ // Artık hata vermeyecek
54
+ reason: result.reason.message
55
+ });
56
+ }
57
+ });
58
+ onSuccess(finalResult);
59
+ } catch (error) {
60
+ onError(error);
61
+ } finally {
62
+ setIsLoading(false);
63
+ }
64
+ };
65
+ const content = isLoading ? /*#__PURE__*/React.createElement(ActivityIndicator, {
66
+ color: "#FFFFFF"
67
+ }) : buttonIcon || /*#__PURE__*/React.createElement(Text, {
68
+ style: [styles.buttonText, ButtonTextStyle]
69
+ }, buttonPlaceHolder);
70
+ return /*#__PURE__*/React.createElement(TouchableOpacity, {
71
+ style: [styles.button, ButtonStyle, (disabled || isLoading) && styles.disabledButton],
72
+ onPress: handlePress,
73
+ disabled: disabled || isLoading
74
+ }, content);
75
+ };
76
+ const styles = StyleSheet.create({
77
+ button: {
78
+ backgroundColor: '#008CBA',
79
+ paddingHorizontal: 20,
80
+ paddingVertical: 10,
81
+ borderRadius: 8,
82
+ alignItems: 'center',
83
+ justifyContent: 'center',
84
+ flexDirection: 'row'
85
+ },
86
+ buttonText: {
87
+ color: '#FFFFFF',
88
+ fontSize: 16,
89
+ fontWeight: 'bold'
90
+ },
91
+ disabledButton: {
92
+ backgroundColor: '#A9A9A9'
93
+ }
94
+ });
95
+ export default DownloadFile;
96
+ //# sourceMappingURL=DownloadFile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","useState","NativeModules","TouchableOpacity","Text","StyleSheet","ActivityIndicator","DownloadFile","DownloadFileModule","files","multipleLoad","disabled","debug","maxSize","fileTypes","buttonPlaceHolder","buttonIcon","ButtonStyle","ButtonTextStyle","onSuccess","onError","error","console","isLoading","setIsLoading","handlePress","Error","downloadOptions","filesToProcess","slice","downloadPromises","map","url","downloadFile","settledResults","Promise","allSettled","finalResult","successful","skipped","forEach","result","index","originalUrl","status","push","localUri","value","reason","message","content","createElement","color","style","styles","buttonText","button","disabledButton","onPress","create","backgroundColor","paddingHorizontal","paddingVertical","borderRadius","alignItems","justifyContent","flexDirection","fontSize","fontWeight"],"sources":["DownloadFile.tsx"],"sourcesContent":["import React, { useState } from 'react';\r\nimport { NativeModules, TouchableOpacity, Text, StyleSheet, ActivityIndicator } from 'react-native';\r\nimport type { DownloadFileProps, DownloadResult } from '../types';\r\n\r\nconst { DownloadFile: DownloadFileModule } = NativeModules;\r\n\r\nconst DownloadFile: React.FC<DownloadFileProps> = ({\r\n files,\r\n multipleLoad = 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 = (error) => console.error('DownloadFile Error:', error),\r\n}) => {\r\n const [isLoading, setIsLoading] = useState(false);\r\n\r\n const handlePress = async () => {\r\n if (!DownloadFileModule) {\r\n onError(new Error(\"DownloadFile native module is not available.\"));\r\n return;\r\n }\r\n\r\n setIsLoading(true);\r\n const downloadOptions = { maxSize, fileTypes, debug };\r\n\r\n try {\r\n const filesToProcess = multipleLoad ? files : files.slice(0, 1);\r\n const downloadPromises = filesToProcess.map(url => \r\n DownloadFileModule.downloadFile(url, downloadOptions)\r\n );\r\n\r\n const settledResults = await Promise.allSettled(downloadPromises);\r\n\r\n const finalResult: DownloadResult = { successful: [], skipped: [] };\r\n\r\n settledResults.forEach((result, index) => {\r\n // DÜZELTME: `filesToProcess[index]` ifadesinin sonuna `!` ekleyerek\r\n // TypeScript'e bu değerin asla undefined olmayacağını bildiriyoruz.\r\n const originalUrl = filesToProcess[index]!;\r\n\r\n if (result.status === 'fulfilled') {\r\n finalResult.successful.push({\r\n originalUrl, // Artık hata vermeyecek\r\n localUri: result.value,\r\n });\r\n } else {\r\n finalResult.skipped.push({\r\n originalUrl, // Artık hata vermeyecek\r\n reason: result.reason.message,\r\n });\r\n }\r\n });\r\n \r\n onSuccess(finalResult);\r\n\r\n } catch (error: any) {\r\n onError(error);\r\n } finally {\r\n setIsLoading(false);\r\n }\r\n };\r\n\r\n const content = isLoading ? (\r\n <ActivityIndicator color=\"#FFFFFF\" />\r\n ) : (\r\n buttonIcon || <Text style={[styles.buttonText, ButtonTextStyle]}>{buttonPlaceHolder}</Text>\r\n );\r\n\r\n return (\r\n <TouchableOpacity\r\n style={[styles.button, ButtonStyle, (disabled || isLoading) && styles.disabledButton]}\r\n onPress={handlePress}\r\n disabled={disabled || isLoading}\r\n >\r\n {content}\r\n </TouchableOpacity>\r\n );\r\n};\r\n\r\nconst styles = StyleSheet.create({\r\n button: {\r\n backgroundColor: '#008CBA',\r\n paddingHorizontal: 20,\r\n paddingVertical: 10,\r\n borderRadius: 8,\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n flexDirection: 'row',\r\n },\r\n buttonText: {\r\n color: '#FFFFFF',\r\n fontSize: 16,\r\n fontWeight: 'bold',\r\n },\r\n disabledButton: {\r\n backgroundColor: '#A9A9A9',\r\n },\r\n});\r\n\r\nexport default DownloadFile;"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,QAAQ,OAAO;AACvC,SAASC,aAAa,EAAEC,gBAAgB,EAAEC,IAAI,EAAEC,UAAU,EAAEC,iBAAiB,QAAQ,cAAc;AAGnG,MAAM;EAAEC,YAAY,EAAEC;AAAmB,CAAC,GAAGN,aAAa;AAE1D,MAAMK,YAAyC,GAAGA,CAAC;EACjDE,KAAK;EACLC,YAAY,GAAG,KAAK;EACpBC,QAAQ,GAAG,KAAK;EAChBC,KAAK,GAAG,KAAK;EACbC,OAAO,GAAG,CAAC;EACXC,SAAS,GAAG,CAAC,KAAK,CAAC;EACnBC,iBAAiB,GAAG,iBAAiB;EACrCC,UAAU;EACVC,WAAW;EACXC,eAAe;EACfC,SAAS,GAAGA,CAAA,KAAM,CAAC,CAAC;EACpBC,OAAO,GAAIC,KAAK,IAAKC,OAAO,CAACD,KAAK,CAAC,qBAAqB,EAAEA,KAAK;AACjE,CAAC,KAAK;EACJ,MAAM,CAACE,SAAS,EAAEC,YAAY,CAAC,GAAGvB,QAAQ,CAAC,KAAK,CAAC;EAEjD,MAAMwB,WAAW,GAAG,MAAAA,CAAA,KAAY;IAC9B,IAAI,CAACjB,kBAAkB,EAAE;MACvBY,OAAO,CAAC,IAAIM,KAAK,CAAC,8CAA8C,CAAC,CAAC;MAClE;IACF;IAEAF,YAAY,CAAC,IAAI,CAAC;IAClB,MAAMG,eAAe,GAAG;MAAEd,OAAO;MAAEC,SAAS;MAAEF;IAAM,CAAC;IAErD,IAAI;MACF,MAAMgB,cAAc,GAAG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AAwB,CAC3F;EAED,oBACEf,KAAA,CAAAmD,aAAA,CAAChD,gBAAgB;IACfkD,KAAK,EAAE,CAACC,MAAM,CAACE,MAAM,EAAEvC,WAAW,EAAE,CAACN,QAAQ,IAAIY,SAAS,KAAK+B,MAAM,CAACG,cAAc,CAAE;IACtFC,OAAO,EAAEjC,WAAY;IACrBd,QAAQ,EAAEA,QAAQ,IAAIY;EAAU,GAE/B2B,OACe,CAAC;AAEvB,CAAC;AAED,MAAMI,MAAM,GAAGjD,UAAU,CAACsD,MAAM,CAAC;EAC7BH,MAAM,EAAE;IACNI,eAAe,EAAE,SAAS;IAC1BC,iBAAiB,EAAE,EAAE;IACrBC,eAAe,EAAE,EAAE;IACnBC,YAAY,EAAE,CAAC;IACfC,UAAU,EAAE,QAAQ;IACpBC,cAAc,EAAE,QAAQ;IACxBC,aAAa,EAAE;EACjB,CAAC;EACDX,UAAU,EAAE;IACVH,KAAK,EAAE,SAAS;IAChBe,QAAQ,EAAE,EAAE;IACZC,UAAU,EAAE;EACd,CAAC;EACDX,cAAc,EAAE;IACdG,eAAe,EAAE;EACnB;AACJ,CAAC,CAAC;AAEF,eAAerD,YAAY","ignoreList":[]}
@@ -0,0 +1,112 @@
1
+ import React from 'react';
2
+ import { NativeModules, TouchableOpacity, Text, StyleSheet } from 'react-native';
3
+ const LINKING_ERROR = `The package 'react-native-my-uploader' doesn't seem to be linked.`;
4
+ const DocumentPicker = NativeModules.DocumentPicker ? NativeModules.DocumentPicker : new Proxy({}, {
5
+ get() {
6
+ throw new Error(LINKING_ERROR);
7
+ }
8
+ });
9
+
10
+ // Mevcut pickFile fonksiyonunu dahili (internal) olarak kullanmak üzere saklayalım.
11
+ // İsterseniz bunu dışa aktarmaya devam edebilirsiniz.
12
+ async function pickFile(options = {}) {
13
+ var _options$excludedUris, _options$fileTypes, _options$maxSize;
14
+ const {
15
+ multipleFiles = false,
16
+ maxFiles = 0,
17
+ ...rest
18
+ } = options;
19
+ if (!multipleFiles && maxFiles > 1) {
20
+ throw new Error('`maxFiles` cannot be greater than 1 when `multipleFiles` is false.');
21
+ }
22
+ let effectiveMaxFiles = maxFiles;
23
+ if (multipleFiles && maxFiles === 0) {
24
+ effectiveMaxFiles = 3;
25
+ }
26
+ const finalOptions = {
27
+ ...rest,
28
+ multipleFiles,
29
+ maxFiles: effectiveMaxFiles,
30
+ excludedUris: (_options$excludedUris = options.excludedUris) !== null && _options$excludedUris !== void 0 ? _options$excludedUris : [],
31
+ fileTypes: (_options$fileTypes = options.fileTypes) !== null && _options$fileTypes !== void 0 ? _options$fileTypes : ['*/*'],
32
+ maxSize: (_options$maxSize = options.maxSize) !== null && _options$maxSize !== void 0 ? _options$maxSize : 0
33
+ };
34
+ return DocumentPicker.openDocument(finalOptions);
35
+ }
36
+
37
+ // YENİ: MyUploader Component'i
38
+ const MyUploaderAndroid = ({
39
+ // DocumentPickerOptions
40
+ multipleFiles = false,
41
+ maxFiles = 0,
42
+ fileTypes = ['*/*'],
43
+ maxSize = 0,
44
+ excludedUris = [],
45
+ // UI Props with defaults
46
+ buttonPlaceHolder = 'Dosya Seçin...',
47
+ ButtonStyle,
48
+ ButtonTextStyle,
49
+ disabled = false,
50
+ // Callbacks
51
+ onSelect,
52
+ onError = error => console.error('MyUploader Error:', error)
53
+ }) => {
54
+ const handlePress = async () => {
55
+ try {
56
+ const options = {
57
+ multipleFiles,
58
+ maxFiles,
59
+ fileTypes,
60
+ maxSize,
61
+ excludedUris
62
+ };
63
+ const selectedFiles = await pickFile(options);
64
+
65
+ // Eğer kullanıcı seçim yapmadan kapatırsa bazı sistemler boş array dönebilir.
66
+ // Sadece doluysa callback'i tetikleyelim.
67
+ if (selectedFiles && selectedFiles.length > 0) {
68
+ onSelect(selectedFiles);
69
+ }
70
+ } catch (error) {
71
+ // Kullanıcının seçimi iptal etmesi bir "hata" sayılmamalı,
72
+ // bu yüzden sadece konsola yazdırıp onError'ı tetiklemeyebiliriz.
73
+ // Native kodunuz "E_PICKER_CANCELLED" koduyla reject ediyor.
74
+ if (error.code !== 'E_PICKER_CANCELLED') {
75
+ onError(error);
76
+ }
77
+ }
78
+ };
79
+ return /*#__PURE__*/React.createElement(TouchableOpacity, {
80
+ style: [styles.button, ButtonStyle, disabled && styles.disabledButton],
81
+ onPress: handlePress,
82
+ disabled: disabled
83
+ }, /*#__PURE__*/React.createElement(Text, {
84
+ style: [styles.buttonText, ButtonTextStyle]
85
+ }, buttonPlaceHolder));
86
+ };
87
+
88
+ // Varsayılan stiller
89
+ const styles = StyleSheet.create({
90
+ button: {
91
+ backgroundColor: '#007AFF',
92
+ paddingHorizontal: 20,
93
+ paddingVertical: 10,
94
+ borderRadius: 8,
95
+ alignItems: 'center',
96
+ justifyContent: 'center'
97
+ },
98
+ buttonText: {
99
+ color: '#FFFFFF',
100
+ fontSize: 16,
101
+ fontWeight: 'bold'
102
+ },
103
+ disabledButton: {
104
+ backgroundColor: '#A9A9A9'
105
+ }
106
+ });
107
+
108
+ // İhtiyaca göre pickFile'ı da export edebilirsiniz.
109
+ export { pickFile };
110
+ // Component'i varsayılan olarak export ediyoruz.
111
+ export default MyUploaderAndroid;
112
+ //# sourceMappingURL=MyUploader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","NativeModules","TouchableOpacity","Text","StyleSheet","LINKING_ERROR","DocumentPicker","Proxy","get","Error","pickFile","options","_options$excludedUris","_options$fileTypes","_options$maxSize","multipleFiles","maxFiles","rest","effectiveMaxFiles","finalOptions","excludedUris","fileTypes","maxSize","openDocument","MyUploaderAndroid","buttonPlaceHolder","ButtonStyle","ButtonTextStyle","disabled","onSelect","onError","error","console","handlePress","selectedFiles","length","code","createElement","style","styles","button","disabledButton","onPress","buttonText","create","backgroundColor","paddingHorizontal","paddingVertical","borderRadius","alignItems","justifyContent","color","fontSize","fontWeight"],"sources":["MyUploader.tsx"],"sourcesContent":["import React from 'react';\r\nimport {NativeModules,TouchableOpacity,Text,StyleSheet} from 'react-native';\r\nimport type {FileInfo,DocumentPickerOptions, MyUploaderProps} from '../types';\r\n\r\nconst LINKING_ERROR = `The package 'react-native-my-uploader' doesn't seem to be linked.`;\r\n\r\nconst DocumentPicker = NativeModules.DocumentPicker\r\n ? NativeModules.DocumentPicker\r\n : new Proxy(\r\n {},\r\n {\r\n get() {\r\n throw new Error(LINKING_ERROR);\r\n },\r\n }\r\n );\r\n\r\n// Mevcut pickFile fonksiyonunu dahili (internal) olarak kullanmak üzere saklayalım.\r\n// İsterseniz bunu dışa aktarmaya devam edebilirsiniz.\r\nasync function pickFile(\r\n options: DocumentPickerOptions = {}\r\n): Promise<FileInfo[]> {\r\n const { multipleFiles = false, maxFiles = 0, ...rest } = options;\r\n\r\n if (!multipleFiles && maxFiles > 1) {\r\n throw new Error(\r\n '`maxFiles` cannot be greater than 1 when `multipleFiles` is false.'\r\n );\r\n }\r\n let effectiveMaxFiles = maxFiles;\r\n if (multipleFiles && maxFiles === 0) {\r\n effectiveMaxFiles = 3;\r\n }\r\n const finalOptions: DocumentPickerOptions = {\r\n ...rest,\r\n multipleFiles,\r\n maxFiles: effectiveMaxFiles,\r\n excludedUris: options.excludedUris ?? [],\r\n fileTypes: options.fileTypes ?? ['*/*'],\r\n maxSize: options.maxSize ?? 0,\r\n };\r\n return DocumentPicker.openDocument(finalOptions);\r\n}\r\n\r\n// YENİ: MyUploader Component'i\r\nconst MyUploaderAndroid: React.FC<MyUploaderProps> = ({\r\n // DocumentPickerOptions\r\n multipleFiles = false,\r\n maxFiles = 0,\r\n fileTypes = ['*/*'],\r\n maxSize = 0,\r\n excludedUris = [],\r\n // UI Props with defaults\r\n buttonPlaceHolder = 'Dosya Seçin...',\r\n ButtonStyle,\r\n ButtonTextStyle,\r\n disabled = false,\r\n // Callbacks\r\n onSelect,\r\n onError = (error) => console.error('MyUploader Error:', error),\r\n}) => {\r\n const handlePress = async () => {\r\n try {\r\n const options: DocumentPickerOptions = {\r\n multipleFiles,\r\n maxFiles,\r\n fileTypes,\r\n maxSize,\r\n excludedUris,\r\n };\r\n const selectedFiles = await pickFile(options);\r\n \r\n // Eğer kullanıcı seçim yapmadan kapatırsa bazı sistemler boş array dönebilir.\r\n // Sadece doluysa callback'i tetikleyelim.\r\n if (selectedFiles && selectedFiles.length > 0) {\r\n onSelect(selectedFiles);\r\n }\r\n\r\n } catch (error: any) {\r\n // Kullanıcının seçimi iptal etmesi bir \"hata\" sayılmamalı,\r\n // bu yüzden sadece konsola yazdırıp onError'ı tetiklemeyebiliriz.\r\n // Native kodunuz \"E_PICKER_CANCELLED\" koduyla reject ediyor.\r\n if (error.code !== 'E_PICKER_CANCELLED') {\r\n onError(error);\r\n }\r\n }\r\n };\r\n\r\n return (\r\n <TouchableOpacity\r\n style={[styles.button, ButtonStyle, disabled && styles.disabledButton]}\r\n onPress={handlePress}\r\n disabled={disabled}\r\n >\r\n <Text style={[styles.buttonText, ButtonTextStyle]}>\r\n {buttonPlaceHolder}\r\n </Text>\r\n </TouchableOpacity>\r\n );\r\n};\r\n\r\n// Varsayılan stiller\r\nconst styles = StyleSheet.create({\r\n button: {\r\n backgroundColor: '#007AFF',\r\n paddingHorizontal: 20,\r\n paddingVertical: 10,\r\n borderRadius: 8,\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n },\r\n buttonText: {\r\n color: '#FFFFFF',\r\n fontSize: 16,\r\n fontWeight: 'bold',\r\n },\r\n disabledButton: {\r\n backgroundColor: '#A9A9A9',\r\n },\r\n});\r\n\r\n// İhtiyaca göre pickFile'ı da export edebilirsiniz.\r\nexport { pickFile };\r\nexport type { FileInfo, DocumentPickerOptions, MyUploaderProps } from \"../types\";\r\n\r\n// Component'i varsayılan olarak export ediyoruz.\r\nexport default MyUploaderAndroid;"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAAQC,aAAa,EAACC,gBAAgB,EAACC,IAAI,EAACC,UAAU,QAAO,cAAc;AAG3E,MAAMC,aAAa,GAAG,mEAAmE;AAEzF,MAAMC,cAAc,GAAGL,aAAa,CAACK,cAAc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E,QAAQ;IACpBC,cAAc,EAAE;EAClB,CAAC;EACDP,UAAU,EAAE;IACVQ,KAAK,EAAE,SAAS;IAChBC,QAAQ,EAAE,EAAE;IACZC,UAAU,EAAE;EACd,CAAC;EACDZ,cAAc,EAAE;IACdI,eAAe,EAAE;EACnB;AACF,CAAC,CAAC;;AAEF;AACA,SAASnC,QAAQ;AAGjB;AACA,eAAec,iBAAiB","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\r\nexport * from './types';\r\n\r\ndeclare const MyUploader: React.FC<MyUploaderProps>;\r\n\r\nexport default MyUploader;\r\n\r\nexport function pickFile(options?: DocumentPickerOptions): Promise<FileInfo[]>;"],"mappings":"AAGA,cAAc,SAAS","ignoreList":[]}
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\r\nexport * from './types';\r\n\r\ndeclare const MyUploader: React.FC<MyUploaderProps>;\r\nexport default MyUploader;\r\n\r\nexport declare const DownloadFile: React.FC<DownloadFileProps>;\r\nexport function pickFile(options?: DocumentPickerOptions): Promise<FileInfo[]>;"],"mappings":"AAGA,cAAc,SAAS","ignoreList":[]}
@@ -1,112 +1,9 @@
1
- import React from 'react';
2
- import { NativeModules, TouchableOpacity, Text, StyleSheet } from 'react-native';
3
- const LINKING_ERROR = `The package 'react-native-my-uploader' doesn't seem to be linked.`;
4
- const DocumentPicker = NativeModules.DocumentPicker ? NativeModules.DocumentPicker : new Proxy({}, {
5
- get() {
6
- throw new Error(LINKING_ERROR);
7
- }
8
- });
1
+ import MyUploaderAndroid from "./components/MyUploader";
2
+ import DownloadFileAndroid from "./components/DownloadFile";
3
+ import { pickFile } from './components/MyUploader';
9
4
 
10
- // Mevcut pickFile fonksiyonunu dahili (internal) olarak kullanmak üzere saklayalım.
11
- // İsterseniz bunu dışa aktarmaya devam edebilirsiniz.
12
- async function pickFile(options = {}) {
13
- var _options$excludedUris, _options$fileTypes, _options$maxSize;
14
- const {
15
- multipleFiles = false,
16
- maxFiles = 0,
17
- ...rest
18
- } = options;
19
- if (!multipleFiles && maxFiles > 1) {
20
- throw new Error('`maxFiles` cannot be greater than 1 when `multipleFiles` is false.');
21
- }
22
- let effectiveMaxFiles = maxFiles;
23
- if (multipleFiles && maxFiles === 0) {
24
- effectiveMaxFiles = 3;
25
- }
26
- const finalOptions = {
27
- ...rest,
28
- multipleFiles,
29
- maxFiles: effectiveMaxFiles,
30
- excludedUris: (_options$excludedUris = options.excludedUris) !== null && _options$excludedUris !== void 0 ? _options$excludedUris : [],
31
- fileTypes: (_options$fileTypes = options.fileTypes) !== null && _options$fileTypes !== void 0 ? _options$fileTypes : ['*/*'],
32
- maxSize: (_options$maxSize = options.maxSize) !== null && _options$maxSize !== void 0 ? _options$maxSize : 0
33
- };
34
- return DocumentPicker.openDocument(finalOptions);
35
- }
36
-
37
- // YENİ: MyUploader Component'i
38
- const MyUploaderAndroid = ({
39
- // DocumentPickerOptions
40
- multipleFiles = false,
41
- maxFiles = 0,
42
- fileTypes = ['*/*'],
43
- maxSize = 0,
44
- excludedUris = [],
45
- // UI Props with defaults
46
- buttonPlaceHolder = 'Dosya Seçin...',
47
- ButtonStyle,
48
- ButtonTextStyle,
49
- disabled = false,
50
- // Callbacks
51
- onSelect,
52
- onError = error => console.error('MyUploader Error:', error)
53
- }) => {
54
- const handlePress = async () => {
55
- try {
56
- const options = {
57
- multipleFiles,
58
- maxFiles,
59
- fileTypes,
60
- maxSize,
61
- excludedUris
62
- };
63
- const selectedFiles = await pickFile(options);
64
-
65
- // Eğer kullanıcı seçim yapmadan kapatırsa bazı sistemler boş array dönebilir.
66
- // Sadece doluysa callback'i tetikleyelim.
67
- if (selectedFiles && selectedFiles.length > 0) {
68
- onSelect(selectedFiles);
69
- }
70
- } catch (error) {
71
- // Kullanıcının seçimi iptal etmesi bir "hata" sayılmamalı,
72
- // bu yüzden sadece konsola yazdırıp onError'ı tetiklemeyebiliriz.
73
- // Native kodunuz "E_PICKER_CANCELLED" koduyla reject ediyor.
74
- if (error.code !== 'E_PICKER_CANCELLED') {
75
- onError(error);
76
- }
77
- }
78
- };
79
- return /*#__PURE__*/React.createElement(TouchableOpacity, {
80
- style: [styles.button, ButtonStyle, disabled && styles.disabledButton],
81
- onPress: handlePress,
82
- disabled: disabled
83
- }, /*#__PURE__*/React.createElement(Text, {
84
- style: [styles.buttonText, ButtonTextStyle]
85
- }, buttonPlaceHolder));
86
- };
87
-
88
- // Varsayılan stiller
89
- const styles = StyleSheet.create({
90
- button: {
91
- backgroundColor: '#007AFF',
92
- paddingHorizontal: 20,
93
- paddingVertical: 10,
94
- borderRadius: 8,
95
- alignItems: 'center',
96
- justifyContent: 'center'
97
- },
98
- buttonText: {
99
- color: '#FFFFFF',
100
- fontSize: 16,
101
- fontWeight: 'bold'
102
- },
103
- disabledButton: {
104
- backgroundColor: '#A9A9A9'
105
- }
106
- });
107
-
108
- // İhtiyaca göre pickFile'ı da export edebilirsiniz.
109
- export { pickFile };
110
- // Component'i varsayılan olarak export ediyoruz.
5
+ // Component'leri ve fonksiyonları dışa aktar
6
+ export { DownloadFileAndroid, pickFile };
7
+ export * from './types';
111
8
  export default MyUploaderAndroid;
112
9
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["React","NativeModules","TouchableOpacity","Text","StyleSheet","LINKING_ERROR","DocumentPicker","Proxy","get","Error","pickFile","options","_options$excludedUris","_options$fileTypes","_options$maxSize","multipleFiles","maxFiles","rest","effectiveMaxFiles","finalOptions","excludedUris","fileTypes","maxSize","openDocument","MyUploaderAndroid","buttonPlaceHolder","ButtonStyle","ButtonTextStyle","disabled","onSelect","onError","error","console","handlePress","selectedFiles","length","code","createElement","style","styles","button","disabledButton","onPress","buttonText","create","backgroundColor","paddingHorizontal","paddingVertical","borderRadius","alignItems","justifyContent","color","fontSize","fontWeight"],"sources":["index.tsx"],"sourcesContent":["import React from 'react';\r\nimport {NativeModules,TouchableOpacity,Text,StyleSheet} from 'react-native';\r\nimport type {FileInfo,DocumentPickerOptions, MyUploaderProps} from './types';\r\n\r\nconst LINKING_ERROR = `The package 'react-native-my-uploader' doesn't seem to be linked.`;\r\n\r\nconst DocumentPicker = NativeModules.DocumentPicker\r\n ? NativeModules.DocumentPicker\r\n : new Proxy(\r\n {},\r\n {\r\n get() {\r\n throw new Error(LINKING_ERROR);\r\n },\r\n }\r\n );\r\n\r\n// Mevcut pickFile fonksiyonunu dahili (internal) olarak kullanmak üzere saklayalım.\r\n// İsterseniz bunu dışa aktarmaya devam edebilirsiniz.\r\nasync function pickFile(\r\n options: DocumentPickerOptions = {}\r\n): Promise<FileInfo[]> {\r\n const { multipleFiles = false, maxFiles = 0, ...rest } = options;\r\n\r\n if (!multipleFiles && maxFiles > 1) {\r\n throw new Error(\r\n '`maxFiles` cannot be greater than 1 when `multipleFiles` is false.'\r\n );\r\n }\r\n let effectiveMaxFiles = maxFiles;\r\n if (multipleFiles && maxFiles === 0) {\r\n effectiveMaxFiles = 3;\r\n }\r\n const finalOptions: DocumentPickerOptions = {\r\n ...rest,\r\n multipleFiles,\r\n maxFiles: effectiveMaxFiles,\r\n excludedUris: options.excludedUris ?? [],\r\n fileTypes: options.fileTypes ?? ['*/*'],\r\n maxSize: options.maxSize ?? 0,\r\n };\r\n return DocumentPicker.openDocument(finalOptions);\r\n}\r\n\r\n// YENİ: MyUploader Component'i\r\nconst MyUploaderAndroid: React.FC<MyUploaderProps> = ({\r\n // DocumentPickerOptions\r\n multipleFiles = false,\r\n maxFiles = 0,\r\n fileTypes = ['*/*'],\r\n maxSize = 0,\r\n excludedUris = [],\r\n // UI Props with defaults\r\n buttonPlaceHolder = 'Dosya Seçin...',\r\n ButtonStyle,\r\n ButtonTextStyle,\r\n disabled = false,\r\n // Callbacks\r\n onSelect,\r\n onError = (error) => console.error('MyUploader Error:', error),\r\n}) => {\r\n const handlePress = async () => {\r\n try {\r\n const options: DocumentPickerOptions = {\r\n multipleFiles,\r\n maxFiles,\r\n fileTypes,\r\n maxSize,\r\n excludedUris,\r\n };\r\n const selectedFiles = await pickFile(options);\r\n \r\n // Eğer kullanıcı seçim yapmadan kapatırsa bazı sistemler boş array dönebilir.\r\n // Sadece doluysa callback'i tetikleyelim.\r\n if (selectedFiles && selectedFiles.length > 0) {\r\n onSelect(selectedFiles);\r\n }\r\n\r\n } catch (error: any) {\r\n // Kullanıcının seçimi iptal etmesi bir \"hata\" sayılmamalı,\r\n // bu yüzden sadece konsola yazdırıp onError'ı tetiklemeyebiliriz.\r\n // Native kodunuz \"E_PICKER_CANCELLED\" koduyla reject ediyor.\r\n if (error.code !== 'E_PICKER_CANCELLED') {\r\n onError(error);\r\n }\r\n }\r\n };\r\n\r\n return (\r\n <TouchableOpacity\r\n style={[styles.button, ButtonStyle, disabled && styles.disabledButton]}\r\n onPress={handlePress}\r\n disabled={disabled}\r\n >\r\n <Text style={[styles.buttonText, ButtonTextStyle]}>\r\n {buttonPlaceHolder}\r\n </Text>\r\n </TouchableOpacity>\r\n );\r\n};\r\n\r\n// Varsayılan stiller\r\nconst styles = StyleSheet.create({\r\n button: {\r\n backgroundColor: '#007AFF',\r\n paddingHorizontal: 20,\r\n paddingVertical: 10,\r\n borderRadius: 8,\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n },\r\n buttonText: {\r\n color: '#FFFFFF',\r\n fontSize: 16,\r\n fontWeight: 'bold',\r\n },\r\n disabledButton: {\r\n backgroundColor: '#A9A9A9',\r\n },\r\n});\r\n\r\n// İhtiyaca göre pickFile'ı da export edebilirsiniz.\r\nexport { pickFile };\r\nexport type { FileInfo, DocumentPickerOptions, MyUploaderProps } from './types';\r\n\r\n// Component'i varsayılan olarak export ediyoruz.\r\nexport default MyUploaderAndroid;"],"mappings":"AAAA,OAAOA,KAAK,MAAM,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C,MAAM,CAAC;EAC/BJ,MAAM,EAAE;IACNK,eAAe,EAAE,SAAS;IAC1BC,iBAAiB,EAAE,EAAE;IACrBC,eAAe,EAAE,EAAE;IACnBC,YAAY,EAAE,CAAC;IACfC,UAAU,EAAE,QAAQ;IACpBC,cAAc,EAAE;EAClB,CAAC;EACDP,UAAU,EAAE;IACVQ,KAAK,EAAE,SAAS;IAChBC,QAAQ,EAAE,EAAE;IACZC,UAAU,EAAE;EACd,CAAC;EACDZ,cAAc,EAAE;IACdI,eAAe,EAAE;EACnB;AACF,CAAC,CAAC;;AAEF;AACA,SAASnC,QAAQ;AAGjB;AACA,eAAec,iBAAiB","ignoreList":[]}
1
+ {"version":3,"names":["MyUploaderAndroid","DownloadFileAndroid","pickFile"],"sources":["index.ts"],"sourcesContent":["import MyUploaderAndroid from \"./components/MyUploader\";\r\nimport DownloadFileAndroid from \"./components/DownloadFile\";\r\nimport { pickFile } from './components/MyUploader';\r\n\r\n// Component'leri ve fonksiyonları dışa aktar\r\nexport { DownloadFileAndroid, pickFile };\r\nexport * from './types';\r\nexport default MyUploaderAndroid;\r\n\r\n\r\n"],"mappings":"AAAA,OAAOA,iBAAiB,MAAM,yBAAyB;AACvD,OAAOC,mBAAmB,MAAM,2BAA2B;AAC3D,SAASC,QAAQ,QAAQ,yBAAyB;;AAElD;AACA,SAASD,mBAAmB,EAAEC,QAAQ;AACtC,cAAc,SAAS;AACvB,eAAeF,iBAAiB","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { StyleProp, TextStyle, ViewStyle } from 'react-native';\r\n\r\nexport interface FileInfo {\r\n fileName: string;\r\n fileSize: number; // in bytes\r\n fileType: string | null;\r\n fileUri: string;\r\n base64: string;\r\n}\r\n\r\nexport interface DocumentPickerOptions {\r\n multipleFiles?: boolean;\r\n fileTypes?: string[];\r\n maxSize?: number;\r\n maxFiles?: number;\r\n excludedUris?: string[];\r\n}\r\nexport interface MyUploaderProps extends DocumentPickerOptions {\r\n // Geri bildirim (callback) fonksiyonları\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}"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { StyleProp, TextStyle, ViewStyle } from 'react-native';\r\n\r\nexport interface FileInfo {\r\n fileName: string;\r\n fileSize: number; // in bytes\r\n fileType: string | null;\r\n fileUri: string;\r\n base64: string;\r\n}\r\n\r\nexport interface DocumentPickerOptions {\r\n multipleFiles?: boolean;\r\n fileTypes?: string[];\r\n maxSize?: number;\r\n maxFiles?: number;\r\n excludedUris?: string[];\r\n}\r\nexport interface MyUploaderProps extends DocumentPickerOptions {\r\n // Geri bildirim (callback) fonksiyonları\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}\r\n\r\n//download File Module Props\r\nexport interface DownloadedFileInfo {\r\n originalUrl: string;\r\n localUri: string; // Cihazdaki dosyanın URI'si\r\n}\r\n\r\n// YENİ: Atlanan dosyalar hakkında bilgi vermek için arayüz\r\nexport interface SkippedFileInfo {\r\n originalUrl: string;\r\n reason: string; // Neden atlandığı (örn: \"Dosya çok büyük\")\r\n}\r\n\r\n// YENİ: onSUCCESS callback'inin döndüreceği sonuç nesnesi\r\nexport interface DownloadResult {\r\n successful: DownloadedFileInfo[];\r\n skipped: SkippedFileInfo[];\r\n}\r\n\r\n// GÜNCELLENDİ: DownloadFileProps arayüzü\r\nexport interface DownloadFileProps {\r\n files: string[];\r\n // YENİ PROPLAR\r\n multipleLoad?: boolean;\r\n disabled?: boolean;\r\n debug?: boolean; // Mevcut debug prop'u\r\n\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 \r\n // GÜNCELLENDİ: Callback daha zengin bir nesne döndürecek\r\n onSuccess?: (result: DownloadResult) => void;\r\n onError?: (error: Error) => void;\r\n}"],"mappings":"","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-my-uploader-android",
3
- "version": "1.0.25",
3
+ "version": "1.0.26",
4
4
  "description": "file uploader for android",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./src/index.d.ts",
@@ -0,0 +1,106 @@
1
+ import React, { useState } from 'react';
2
+ import { NativeModules, TouchableOpacity, Text, StyleSheet, ActivityIndicator } from 'react-native';
3
+ import type { DownloadFileProps, DownloadResult } from '../types';
4
+
5
+ const { DownloadFile: DownloadFileModule } = NativeModules;
6
+
7
+ const DownloadFile: React.FC<DownloadFileProps> = ({
8
+ files,
9
+ multipleLoad = false,
10
+ disabled = false,
11
+ debug = false,
12
+ maxSize = 0,
13
+ fileTypes = ['*/*'],
14
+ buttonPlaceHolder = 'Dosyaları İndir',
15
+ buttonIcon,
16
+ ButtonStyle,
17
+ ButtonTextStyle,
18
+ onSuccess = () => {},
19
+ onError = (error) => console.error('DownloadFile Error:', error),
20
+ }) => {
21
+ const [isLoading, setIsLoading] = useState(false);
22
+
23
+ const handlePress = async () => {
24
+ if (!DownloadFileModule) {
25
+ onError(new Error("DownloadFile native module is not available."));
26
+ return;
27
+ }
28
+
29
+ setIsLoading(true);
30
+ const downloadOptions = { maxSize, fileTypes, debug };
31
+
32
+ try {
33
+ const filesToProcess = multipleLoad ? files : files.slice(0, 1);
34
+ const downloadPromises = filesToProcess.map(url =>
35
+ DownloadFileModule.downloadFile(url, downloadOptions)
36
+ );
37
+
38
+ const settledResults = await Promise.allSettled(downloadPromises);
39
+
40
+ const finalResult: DownloadResult = { successful: [], skipped: [] };
41
+
42
+ settledResults.forEach((result, index) => {
43
+ // DÜZELTME: `filesToProcess[index]` ifadesinin sonuna `!` ekleyerek
44
+ // TypeScript'e bu değerin asla undefined olmayacağını bildiriyoruz.
45
+ const originalUrl = filesToProcess[index]!;
46
+
47
+ if (result.status === 'fulfilled') {
48
+ finalResult.successful.push({
49
+ originalUrl, // Artık hata vermeyecek
50
+ localUri: result.value,
51
+ });
52
+ } else {
53
+ finalResult.skipped.push({
54
+ originalUrl, // Artık hata vermeyecek
55
+ reason: result.reason.message,
56
+ });
57
+ }
58
+ });
59
+
60
+ onSuccess(finalResult);
61
+
62
+ } catch (error: any) {
63
+ onError(error);
64
+ } finally {
65
+ setIsLoading(false);
66
+ }
67
+ };
68
+
69
+ const content = isLoading ? (
70
+ <ActivityIndicator color="#FFFFFF" />
71
+ ) : (
72
+ buttonIcon || <Text style={[styles.buttonText, ButtonTextStyle]}>{buttonPlaceHolder}</Text>
73
+ );
74
+
75
+ return (
76
+ <TouchableOpacity
77
+ style={[styles.button, ButtonStyle, (disabled || isLoading) && styles.disabledButton]}
78
+ onPress={handlePress}
79
+ disabled={disabled || isLoading}
80
+ >
81
+ {content}
82
+ </TouchableOpacity>
83
+ );
84
+ };
85
+
86
+ const styles = StyleSheet.create({
87
+ button: {
88
+ backgroundColor: '#008CBA',
89
+ paddingHorizontal: 20,
90
+ paddingVertical: 10,
91
+ borderRadius: 8,
92
+ alignItems: 'center',
93
+ justifyContent: 'center',
94
+ flexDirection: 'row',
95
+ },
96
+ buttonText: {
97
+ color: '#FFFFFF',
98
+ fontSize: 16,
99
+ fontWeight: 'bold',
100
+ },
101
+ disabledButton: {
102
+ backgroundColor: '#A9A9A9',
103
+ },
104
+ });
105
+
106
+ export default DownloadFile;
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import {NativeModules,TouchableOpacity,Text,StyleSheet} from 'react-native';
3
- import type {FileInfo,DocumentPickerOptions, MyUploaderProps} from './types';
3
+ import type {FileInfo,DocumentPickerOptions, MyUploaderProps} from '../types';
4
4
 
5
5
  const LINKING_ERROR = `The package 'react-native-my-uploader' doesn't seem to be linked.`;
6
6
 
@@ -121,7 +121,7 @@ const styles = StyleSheet.create({
121
121
 
122
122
  // İhtiyaca göre pickFile'ı da export edebilirsiniz.
123
123
  export { pickFile };
124
- export type { FileInfo, DocumentPickerOptions, MyUploaderProps } from './types';
124
+ export type { FileInfo, DocumentPickerOptions, MyUploaderProps } from "../types";
125
125
 
126
126
  // Component'i varsayılan olarak export ediyoruz.
127
127
  export default MyUploaderAndroid;
package/src/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import * as React from 'react';
2
- import type { DocumentPickerOptions, MyUploaderProps,FileInfo } from './types';
2
+ import type { DocumentPickerOptions, MyUploaderProps,FileInfo,DownloadFileProps } from './types';
3
3
 
4
4
  export * from './types';
5
5
 
6
6
  declare const MyUploader: React.FC<MyUploaderProps>;
7
-
8
7
  export default MyUploader;
9
8
 
9
+ export declare const DownloadFile: React.FC<DownloadFileProps>;
10
10
  export function pickFile(options?: DocumentPickerOptions): Promise<FileInfo[]>;
package/src/index.ts ADDED
@@ -0,0 +1,10 @@
1
+ import MyUploaderAndroid from "./components/MyUploader";
2
+ import DownloadFileAndroid from "./components/DownloadFile";
3
+ import { pickFile } from './components/MyUploader';
4
+
5
+ // Component'leri ve fonksiyonları dışa aktar
6
+ export { DownloadFileAndroid, pickFile };
7
+ export * from './types';
8
+ export default MyUploaderAndroid;
9
+
10
+
package/src/types.ts CHANGED
@@ -23,4 +23,42 @@ export interface MyUploaderProps extends DocumentPickerOptions {
23
23
  ButtonStyle?: StyleProp<ViewStyle>;
24
24
  ButtonTextStyle?: StyleProp<TextStyle>;
25
25
  disabled?: boolean;
26
+ }
27
+
28
+ //download File Module Props
29
+ export interface DownloadedFileInfo {
30
+ originalUrl: string;
31
+ localUri: string; // Cihazdaki dosyanın URI'si
32
+ }
33
+
34
+ // YENİ: Atlanan dosyalar hakkında bilgi vermek için arayüz
35
+ export interface SkippedFileInfo {
36
+ originalUrl: string;
37
+ reason: string; // Neden atlandığı (örn: "Dosya çok büyük")
38
+ }
39
+
40
+ // YENİ: onSUCCESS callback'inin döndüreceği sonuç nesnesi
41
+ export interface DownloadResult {
42
+ successful: DownloadedFileInfo[];
43
+ skipped: SkippedFileInfo[];
44
+ }
45
+
46
+ // GÜNCELLENDİ: DownloadFileProps arayüzü
47
+ export interface DownloadFileProps {
48
+ files: string[];
49
+ // YENİ PROPLAR
50
+ multipleLoad?: boolean;
51
+ disabled?: boolean;
52
+ debug?: boolean; // Mevcut debug prop'u
53
+
54
+ maxSize?: number;
55
+ fileTypes?: string[];
56
+ buttonPlaceHolder?: string;
57
+ buttonIcon?: React.ReactNode;
58
+ ButtonStyle?: StyleProp<ViewStyle>;
59
+ ButtonTextStyle?: StyleProp<TextStyle>;
60
+
61
+ // GÜNCELLENDİ: Callback daha zengin bir nesne döndürecek
62
+ onSuccess?: (result: DownloadResult) => void;
63
+ onError?: (error: Error) => void;
26
64
  }