react-native-my-uploader-android 1.0.29 → 1.0.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/src/main/java/com/myuploaderandroid/MyUploaderModule.kt +147 -78
- package/lib/commonjs/components/DownloadFile.js +4 -2
- package/lib/commonjs/components/DownloadFile.js.map +1 -1
- package/lib/commonjs/components/MyUploader.js +6 -3
- package/lib/commonjs/components/MyUploader.js.map +1 -1
- package/lib/commonjs/index.d.js.map +1 -1
- package/lib/commonjs/index.js +10 -8
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/module/components/DownloadFile.js +4 -2
- package/lib/module/components/DownloadFile.js.map +1 -1
- package/lib/module/components/MyUploader.js +7 -4
- package/lib/module/components/MyUploader.js.map +1 -1
- package/lib/module/index.d.js +4 -0
- package/lib/module/index.d.js.map +1 -1
- package/lib/module/index.js +8 -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 +5 -2
- package/src/components/MyUploader.tsx +5 -4
- package/src/index.d.ts +8 -10
- package/src/index.ts +7 -6
- package/src/types.ts +7 -5
- package/lib/commonjs/NativeModules.js +0 -16
- package/lib/commonjs/NativeModules.js.map +0 -1
- package/lib/module/NativeModules.js +0 -10
- package/lib/module/NativeModules.js.map +0 -1
- package/src/NativeModules.ts +0 -9
|
@@ -8,150 +8,219 @@ import android.util.Base64
|
|
|
8
8
|
import com.facebook.react.bridge.*
|
|
9
9
|
import java.io.ByteArrayOutputStream
|
|
10
10
|
import java.net.URLConnection
|
|
11
|
+
import java.io.FileNotFoundException
|
|
12
|
+
import android.util.Base64OutputStream
|
|
11
13
|
|
|
12
14
|
class MyUploaderModule(private val reactContext: ReactApplicationContext) :
|
|
13
15
|
ReactContextBaseJavaModule(reactContext), ActivityEventListener {
|
|
14
16
|
|
|
15
17
|
private var pickerPromise: Promise? = null
|
|
16
18
|
private var maxSize: Double = 0.0
|
|
17
|
-
private var maxFiles: Int =
|
|
19
|
+
private var maxFiles: Int = 0
|
|
18
20
|
private var excludedUris: List<String> = emptyList()
|
|
19
21
|
|
|
20
22
|
init {
|
|
21
23
|
reactContext.addActivityEventListener(this)
|
|
22
24
|
}
|
|
23
25
|
|
|
24
|
-
override fun getName(): String = "
|
|
26
|
+
override fun getName(): String = "UploadDocumentPicker"
|
|
25
27
|
|
|
26
28
|
companion object {
|
|
27
29
|
private const val REQUEST_CODE = 9900
|
|
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
|
+
private const val E_FAILED_TO_OPEN_DOCUMENT = "E_FAILED_TO_OPEN_DOCUMENT"
|
|
33
|
+
private const val E_FILE_TOO_LARGE = "E_FILE_TOO_LARGE"
|
|
34
|
+
private const val E_MAX_FILES_EXCEEDED = "E_MAX_FILES_EXCEEDED"
|
|
35
|
+
private const val E_INVALID_OPTIONS = "E_INVALID_OPTIONS"
|
|
28
36
|
}
|
|
29
37
|
|
|
30
38
|
@ReactMethod
|
|
31
39
|
fun openDocument(options: ReadableMap, promise: Promise) {
|
|
32
40
|
if (pickerPromise != null) {
|
|
33
|
-
promise.reject(
|
|
41
|
+
promise.reject(E_FAILED_TO_OPEN_DOCUMENT, "Başka bir dosya seçme işlemi zaten devam ediyor.")
|
|
34
42
|
return
|
|
35
43
|
}
|
|
36
44
|
|
|
37
45
|
this.pickerPromise = promise
|
|
38
46
|
|
|
39
|
-
|
|
40
|
-
val
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
// maxFiles mantığı
|
|
48
|
-
this.maxFiles = when {
|
|
49
|
-
multipleFiles && jsMaxFiles == 0 -> 99 // Limit yoksa varsayılan
|
|
50
|
-
!multipleFiles -> 1
|
|
51
|
-
else -> jsMaxFiles
|
|
47
|
+
val multipleFiles = options.takeIf { it.hasKey("multipleFiles") }?.getBoolean("multipleFiles") ?: false
|
|
48
|
+
val jsMaxFiles = options.takeIf { it.hasKey("maxFiles") }?.getInt("maxFiles") ?: 0
|
|
49
|
+
|
|
50
|
+
// KURAL KONTROLÜ (NATIVE): JS tarafındaki kontrolü burada da yaparak güvenliği artır.
|
|
51
|
+
if (!multipleFiles && jsMaxFiles > 1) {
|
|
52
|
+
promise.reject(E_INVALID_OPTIONS, "`maxFiles` değeri, `multipleFiles` false iken 1'den büyük olamaz.")
|
|
53
|
+
return
|
|
52
54
|
}
|
|
53
55
|
|
|
54
|
-
|
|
56
|
+
// KURAL UYGULAMA (NATIVE): `maxFiles` için nihai değeri hesapla.
|
|
57
|
+
val effectiveMaxFiles = when {
|
|
58
|
+
multipleFiles && jsMaxFiles == 0 -> 3 // Varsayılan: 3
|
|
59
|
+
!multipleFiles -> 1 // Tekli seçimde her zaman 1
|
|
60
|
+
else -> jsMaxFiles // Belirtilen değeri kullan
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Değerleri sınıf değişkenlerine ata
|
|
64
|
+
this.maxFiles = effectiveMaxFiles
|
|
65
|
+
this.maxSize = options.takeIf { it.hasKey("maxSize") }?.getDouble("maxSize") ?: 0.0
|
|
66
|
+
this.excludedUris = options.takeIf { it.hasKey("excludedUris") }
|
|
67
|
+
?.getArray("excludedUris")?.toArrayList()?.mapNotNull { it.toString() } ?: emptyList()
|
|
68
|
+
|
|
69
|
+
val currentActivity = reactContext.currentActivity
|
|
55
70
|
if (currentActivity == null) {
|
|
56
|
-
|
|
71
|
+
pickerPromise?.reject(E_ACTIVITY_DOES_NOT_EXIST, "Activity mevcut değil.")
|
|
57
72
|
pickerPromise = null
|
|
58
73
|
return
|
|
59
74
|
}
|
|
60
75
|
|
|
61
|
-
val fileTypes =
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
val mimeTypes = fileTypes.toTypedArray()
|
|
76
|
+
val fileTypes = options.takeIf { it.hasKey("fileTypes") }
|
|
77
|
+
?.getArray("fileTypes")?.toArrayList()?.mapNotNull { it.toString() } ?: listOf("*/*")
|
|
78
|
+
val mimeTypes = if (fileTypes.isEmpty()) arrayOf("*/*") else fileTypes.toTypedArray()
|
|
66
79
|
|
|
67
80
|
try {
|
|
81
|
+
// ANAHTAR: ACTION_GET_CONTENT, güvenilir çoklu seçimi etkinleştirir.
|
|
68
82
|
val intent = Intent(Intent.ACTION_GET_CONTENT).apply {
|
|
69
|
-
type = "*/*"
|
|
83
|
+
type = "*/*"
|
|
70
84
|
addCategory(Intent.CATEGORY_OPENABLE)
|
|
71
85
|
putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes)
|
|
72
|
-
|
|
86
|
+
|
|
87
|
+
if (multipleFiles) {
|
|
88
|
+
putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true)
|
|
89
|
+
}
|
|
73
90
|
}
|
|
74
|
-
currentActivity.startActivityForResult(Intent.createChooser(intent, "Dosya
|
|
91
|
+
currentActivity.startActivityForResult(Intent.createChooser(intent, "Dosya Seçin"), REQUEST_CODE)
|
|
75
92
|
} catch (e: Exception) {
|
|
76
|
-
pickerPromise?.reject(
|
|
93
|
+
pickerPromise?.reject(E_FAILED_TO_OPEN_DOCUMENT, e)
|
|
77
94
|
pickerPromise = null
|
|
78
95
|
}
|
|
79
96
|
}
|
|
80
97
|
|
|
81
98
|
override fun onActivityResult(activity: Activity, requestCode: Int, resultCode: Int, data: Intent?) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
if (resultCode == Activity.RESULT_OK) {
|
|
85
|
-
val uris = mutableListOf<Uri>()
|
|
86
|
-
|
|
87
|
-
if (data?.clipData != null) {
|
|
88
|
-
val clip = data.clipData!!
|
|
89
|
-
for (i in 0 until clip.itemCount) {
|
|
90
|
-
uris.add(clip.getItemAt(i).uri)
|
|
91
|
-
}
|
|
92
|
-
} else if (data?.data != null) {
|
|
93
|
-
uris.add(data.data!!)
|
|
94
|
-
}
|
|
99
|
+
if (requestCode != REQUEST_CODE || pickerPromise == null) { return }
|
|
95
100
|
|
|
96
|
-
|
|
97
|
-
|
|
101
|
+
val currentPromise = pickerPromise
|
|
102
|
+
pickerPromise = null
|
|
98
103
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
104
|
+
if (resultCode == Activity.RESULT_OK && data != null) {
|
|
105
|
+
val allSelectedUris = mutableListOf<Uri>()
|
|
106
|
+
data.clipData?.let { clip ->
|
|
107
|
+
for (i in 0 until clip.itemCount) {
|
|
108
|
+
allSelectedUris.add(clip.getItemAt(i).uri)
|
|
103
109
|
}
|
|
110
|
+
} ?: data.data?.let { uri ->
|
|
111
|
+
allSelectedUris.add(uri)
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
val newSelectedUris = allSelectedUris.filter { uri -> !excludedUris.contains(uri.toString()) }
|
|
115
|
+
|
|
116
|
+
if (this.maxFiles > 0 && newSelectedUris.size > this.maxFiles) {
|
|
117
|
+
currentPromise?.reject(E_MAX_FILES_EXCEEDED, "En fazla ${this.maxFiles} adet yeni dosya seçebilirsiniz.")
|
|
118
|
+
return
|
|
119
|
+
}
|
|
104
120
|
|
|
121
|
+
Thread {
|
|
105
122
|
try {
|
|
106
|
-
val
|
|
107
|
-
|
|
123
|
+
val fileInfoArray = processSelectedFiles(newSelectedUris)
|
|
124
|
+
// Sonucu UI thread'inde Promise'e gönder
|
|
125
|
+
reactContext.runOnUiQueueThread {
|
|
126
|
+
currentPromise?.resolve(fileInfoArray)
|
|
127
|
+
}
|
|
108
128
|
} catch (e: Exception) {
|
|
109
|
-
|
|
129
|
+
// Hataları UI thread'inde Promise'e gönder
|
|
130
|
+
reactContext.runOnUiQueueThread {
|
|
131
|
+
when (e) {
|
|
132
|
+
is FileTooLargeException -> currentPromise?.reject(E_FILE_TOO_LARGE, e.message)
|
|
133
|
+
is FileNotFoundException -> currentPromise?.reject(E_FAILED_TO_OPEN_DOCUMENT, "Dosya bulunamadı veya erişilemedi.")
|
|
134
|
+
else -> currentPromise?.reject(E_FAILED_TO_OPEN_DOCUMENT, e.message)
|
|
135
|
+
}
|
|
136
|
+
}
|
|
110
137
|
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
pickerPromise = null
|
|
138
|
+
}.start()
|
|
139
|
+
} else {
|
|
140
|
+
currentPromise?.reject(E_PICKER_CANCELLED, "Dosya seçimi iptal edildi.")
|
|
115
141
|
}
|
|
142
|
+
}
|
|
116
143
|
|
|
117
|
-
|
|
144
|
+
|
|
145
|
+
override fun onNewIntent(intent: Intent) {}
|
|
118
146
|
|
|
119
147
|
private fun processSelectedFiles(uris: List<Uri>): WritableArray {
|
|
120
|
-
val
|
|
148
|
+
val fileObjects = WritableNativeArray()
|
|
121
149
|
val maxSizeBytes = (maxSize * 1024 * 1024).toLong()
|
|
122
150
|
|
|
123
151
|
for (uri in uris) {
|
|
124
152
|
reactContext.contentResolver.query(uri, null, null, null, null)?.use { cursor ->
|
|
125
153
|
if (cursor.moveToFirst()) {
|
|
126
|
-
val sizeIndex = cursor.getColumnIndex(OpenableColumns.SIZE)
|
|
127
154
|
val nameIndex = cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME)
|
|
128
|
-
|
|
129
|
-
val size = if(sizeIndex >= 0) cursor.getLong(sizeIndex) else 0L
|
|
130
|
-
val name = if(nameIndex >= 0) cursor.getString(nameIndex) else "unknown"
|
|
155
|
+
val sizeIndex = cursor.getColumnIndex(OpenableColumns.SIZE)
|
|
131
156
|
|
|
132
|
-
if (
|
|
133
|
-
|
|
157
|
+
val fileName = if (nameIndex != -1) cursor.getString(nameIndex) else guessFileNameFromUri(uri)
|
|
158
|
+
val fileSize = if (sizeIndex != -1) cursor.getLong(sizeIndex) else -1L
|
|
159
|
+
|
|
160
|
+
var trueSize = -1L
|
|
161
|
+
try {
|
|
162
|
+
reactContext.contentResolver.openAssetFileDescriptor(uri, "r")?.use { afd ->
|
|
163
|
+
trueSize = afd.length
|
|
164
|
+
}
|
|
165
|
+
} catch (e: FileNotFoundException) {
|
|
166
|
+
// Bazı durumlarda bu metod hata verebilir, görmezden gel ve devam et
|
|
134
167
|
}
|
|
168
|
+
|
|
169
|
+
if (trueSize <= 0) trueSize = fileSize
|
|
135
170
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
resultArr.pushMap(map)
|
|
171
|
+
if (maxSizeBytes > 0 && trueSize > 0 && trueSize > maxSizeBytes) {
|
|
172
|
+
throw FileTooLargeException("Seçilen dosya ($fileName) belirtilen ${maxSize}MB boyutundan büyük.")
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
val mimeType = reactContext.contentResolver.getType(uri) ?: URLConnection.guessContentTypeFromName(fileName) ?: "application/octet-stream"
|
|
176
|
+
val base64 = encodeFileToBase64(uri)
|
|
177
|
+
|
|
178
|
+
val fileMap = WritableNativeMap().apply {
|
|
179
|
+
putString("fileName", fileName)
|
|
180
|
+
putDouble("fileSize", if (trueSize > 0) trueSize.toDouble() else fileSize.toDouble())
|
|
181
|
+
putString("fileType", mimeType)
|
|
182
|
+
putString("fileUri", uri.toString())
|
|
183
|
+
putString("base64", base64)
|
|
184
|
+
}
|
|
185
|
+
fileObjects.pushMap(fileMap)
|
|
152
186
|
}
|
|
187
|
+
} ?:throw FileNotFoundException("Content ile dosya bilgisi alınamadı:$uri")
|
|
188
|
+
}
|
|
189
|
+
return fileObjects
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
private fun guessFileNameFromUri (uri:Uri):String{
|
|
193
|
+
return uri.lastPathSegment?.substringBefore("?") ?: "unknown_file"
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// OOM riskini azaltan, streaming tabanlı Base64 çevrimi
|
|
197
|
+
private fun encodeFileToBase64(uri: Uri): String? {
|
|
198
|
+
return try {
|
|
199
|
+
reactContext.contentResolver.openInputStream(uri)?.use { input ->
|
|
200
|
+
val output = ByteArrayOutputStream()
|
|
201
|
+
val encoder = Base64OutputStream(output, Base64.NO_WRAP)
|
|
202
|
+
|
|
203
|
+
// Dosyayı parça parça oku ve anlık olarak Base64'e çevir
|
|
204
|
+
input.copyTo(encoder)
|
|
205
|
+
// .copyTo() encoder'ı otomatik olarak kapatır (flush eder).
|
|
206
|
+
|
|
207
|
+
// DÜZELTME: Doğrudan `output.toString()` değil,
|
|
208
|
+
// `Base64.encodeToString` kullan. Ancak bu gereksiz bir adımdır,
|
|
209
|
+
// çünkü `output` zaten Base64'tür. En basit yol:
|
|
210
|
+
String(output.toByteArray(), Charsets.US_ASCII)
|
|
153
211
|
}
|
|
212
|
+
} catch (e: Exception) {
|
|
213
|
+
null
|
|
154
214
|
}
|
|
155
|
-
return resultArr
|
|
156
215
|
}
|
|
216
|
+
|
|
217
|
+
override fun onCatalystInstanceDestroy() {
|
|
218
|
+
// Bellek sızıntısını önlemek için event listener'ı kaldır.
|
|
219
|
+
reactContext.removeActivityEventListener(this)
|
|
220
|
+
super.onCatalystInstanceDestroy()
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// Özel Exception sınıfınız doğru
|
|
224
|
+
class FileTooLargeException(message: String) : Exception(message)
|
|
225
|
+
|
|
157
226
|
}
|
|
@@ -6,8 +6,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _reactNative = require("react-native");
|
|
9
|
-
var _NativeModules = require("../NativeModules");
|
|
10
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: NativeDownload
|
|
12
|
+
} = _reactNative.NativeModules;
|
|
11
13
|
const DownloadFile = ({
|
|
12
14
|
files,
|
|
13
15
|
multipleDownload = false,
|
|
@@ -33,7 +35,7 @@ const DownloadFile = ({
|
|
|
33
35
|
};
|
|
34
36
|
const targetFiles = multipleDownload ? files : [files[0]];
|
|
35
37
|
try {
|
|
36
|
-
const promises = targetFiles.map(url =>
|
|
38
|
+
const promises = targetFiles.map(url => NativeDownload.downloadFile(url, options));
|
|
37
39
|
const results = await Promise.allSettled(promises);
|
|
38
40
|
const final = {
|
|
39
41
|
successful: [],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","
|
|
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: 'center',\r\n },\r\n text: { color: '#000', fontWeight: 'bold' },\r\n disabled: { backgroundColor: '#AAA' }\r\n});\r\n\r\nexport default DownloadFile;"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAAmG,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,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,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAAAM,GAAA,IAAAP,CAAA,CAAAE,CAAA,EAAAP,CAAA,EAAAM,CAAA,IAAAC,CAAA,CAAAP,CAAA,IAAAD,CAAA,CAAAC,CAAA,WAAAO,CAAA,KAAAR,CAAA,EAAAC,CAAA;A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F,CAAC;AAEvB,CAAC;AAED,MAAMwC,MAAM,GAAGO,uBAAU,CAACC,MAAM,CAAC;EAC/BP,MAAM,EAAE;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":[]}
|
|
@@ -6,12 +6,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.pickFile = exports.default = void 0;
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _reactNative = require("react-native");
|
|
9
|
-
var _NativeModules = require("../NativeModules");
|
|
10
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
|
+
UploadDocumentPicker: NativeUploadPicker
|
|
12
|
+
} = _reactNative.NativeModules;
|
|
13
|
+
|
|
11
14
|
// 1. Standalone pickFile Fonksiyonu
|
|
12
15
|
const pickFile = async (options = {}) => {
|
|
13
16
|
var _options$multipleFile, _options$maxFiles, _options$maxSize, _options$fileTypes, _options$excludedUris;
|
|
14
|
-
if (!
|
|
17
|
+
if (!NativeUploadPicker) throw new Error("DocumentPicker module is not linked.");
|
|
15
18
|
|
|
16
19
|
// Native tarafa gönderilecek options
|
|
17
20
|
const nativeOptions = {
|
|
@@ -21,7 +24,7 @@ const pickFile = async (options = {}) => {
|
|
|
21
24
|
fileTypes: (_options$fileTypes = options.fileTypes) !== null && _options$fileTypes !== void 0 ? _options$fileTypes : ['*/*'],
|
|
22
25
|
excludedUris: (_options$excludedUris = options.excludedUris) !== null && _options$excludedUris !== void 0 ? _options$excludedUris : []
|
|
23
26
|
};
|
|
24
|
-
return await
|
|
27
|
+
return await NativeUploadPicker.openDocument(nativeOptions);
|
|
25
28
|
};
|
|
26
29
|
|
|
27
30
|
// 2. MyUploader Bileşeni
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","
|
|
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","UploadDocumentPicker","NativeUploadPicker","NativeModules","pickFile","options","_options$multipleFile","_options$maxFiles","_options$maxSize","_options$fileTypes","_options$excludedUris","Error","nativeOptions","multipleFiles","maxFiles","maxSize","fileTypes","excludedUris","openDocument","exports","MyUploader","onSelect","onError","buttonPlaceHolder","ButtonStyle","ButtonTextStyle","disabled","isLoading","setIsLoading","useState","handlePress","files","error","console","createElement","TouchableOpacity","style","styles","button","onPress","ActivityIndicator","color","Text","text","StyleSheet","create","backgroundColor","padding","borderRadius","alignItems","justifyContent","fontWeight","fontSize","_default"],"sources":["MyUploader.tsx"],"sourcesContent":["import React, { useState } from 'react';\r\nimport { TouchableOpacity, Text, StyleSheet, ActivityIndicator,NativeModules } from 'react-native';\r\nimport type { MyUploaderProps, DocumentPickerOptions, FileInfo } from '../types';\r\n\r\nconst { UploadDocumentPicker: NativeUploadPicker } = NativeModules;\r\n\r\n// 1. Standalone pickFile Fonksiyonu\r\nexport const pickFile = async (options: DocumentPickerOptions = {}): Promise<FileInfo[]> => {\r\n if (!NativeUploadPicker) throw new Error(\"DocumentPicker module is not linked.\");\r\n \r\n // Native tarafa gönderilecek options\r\n const nativeOptions = {\r\n multipleFiles: options.multipleFiles ?? false,\r\n maxFiles: options.maxFiles ?? 0,\r\n maxSize: options.maxSize ?? 0,\r\n fileTypes: options.fileTypes ?? ['*/*'],\r\n excludedUris: options.excludedUris ?? [],\r\n };\r\n\r\n return await NativeUploadPicker.openDocument(nativeOptions);\r\n};\r\n\r\n// 2. MyUploader Bileşeni\r\nconst MyUploader: React.FC<MyUploaderProps> = ({\r\n onSelect,\r\n onError,\r\n buttonPlaceHolder = \"Dosya Seç\",\r\n ButtonStyle,\r\n ButtonTextStyle,\r\n disabled = false,\r\n multipleFiles = false,\r\n fileTypes = ['*/*'],\r\n maxSize = 0,\r\n maxFiles = 0,\r\n excludedUris = [],\r\n}) => {\r\n const [isLoading, setIsLoading] = useState(false);\r\n\r\n const handlePress = async () => {\r\n if (disabled || isLoading) return;\r\n setIsLoading(true);\r\n\r\n try {\r\n const files = await pickFile({\r\n multipleFiles,\r\n fileTypes,\r\n maxSize,\r\n maxFiles,\r\n excludedUris\r\n });\r\n \r\n onSelect(files);\r\n } catch (error: any) {\r\n if (onError) {\r\n onError(error);\r\n } else {\r\n console.error(\"MyUploader Error:\", error);\r\n }\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 <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: '#6200EE',\r\n padding: 12,\r\n borderRadius: 8,\r\n alignItems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IAC1BC,OAAO,EAAE,EAAE;IACXC,YAAY,EAAE,CAAC;IACfC,UAAU,EAAE,QAAQ;IACpBC,cAAc,EAAE;EAClB,CAAC;EACDP,IAAI,EAAE;IACJF,KAAK,EAAE,MAAM;IACbU,UAAU,EAAE,KAAK;IACjBC,QAAQ,EAAE;EACZ,CAAC;EACD1B,QAAQ,EAAE;IACRoB,eAAe,EAAE;EACnB;AACF,CAAC,CAAC;AAAC,IAAAO,QAAA,GAAAlC,OAAA,CAAA3B,OAAA,GAEY4B,UAAU","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 {
|
|
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\n\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
|
@@ -4,13 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
var _exportNames = {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
MyUploader: true,
|
|
8
|
+
pickFile: true
|
|
9
9
|
};
|
|
10
|
-
Object.defineProperty(exports, "
|
|
10
|
+
Object.defineProperty(exports, "MyUploader", {
|
|
11
11
|
enumerable: true,
|
|
12
12
|
get: function () {
|
|
13
|
-
return
|
|
13
|
+
return _MyUploader.default;
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
16
|
exports.default = void 0;
|
|
@@ -21,7 +21,6 @@ Object.defineProperty(exports, "pickFile", {
|
|
|
21
21
|
}
|
|
22
22
|
});
|
|
23
23
|
var _MyUploader = _interopRequireWildcard(require("./components/MyUploader"));
|
|
24
|
-
var _DownloadFile = _interopRequireDefault(require("./components/DownloadFile"));
|
|
25
24
|
var _types = require("./types");
|
|
26
25
|
Object.keys(_types).forEach(function (key) {
|
|
27
26
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -34,8 +33,11 @@ Object.keys(_types).forEach(function (key) {
|
|
|
34
33
|
}
|
|
35
34
|
});
|
|
36
35
|
});
|
|
37
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
38
36
|
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
|
-
//
|
|
40
|
-
|
|
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
|
+
// Sadece bu paketle ilgili olanları dışa aktar
|
|
41
|
+
// Varsayılan dışa aktarım olarak da ana bileşeni verelim
|
|
42
|
+
var _default = exports.default = _MyUploader.default;
|
|
41
43
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_MyUploader","_interopRequireWildcard","require","
|
|
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\n// import DownloadFile from \"./components/DownloadFile\";\r\n\r\n// 2. Diğerlerini NAMED olarak dışa aktar (import { DownloadFile, pickFile } ... için)\r\n// export { DownloadFile, pickFile };\r\n\r\n\r\n// Sadece bu paketle ilgili olanları dışa aktar\r\nexport { MyUploader, pickFile };\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;AASA,IAAAC,MAAA,GAAAD,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAF,MAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,c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ARxB;AAEA;AACA;AAGA;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 uri: string;\r\n name: string;\r\n type: string;\r\n size: number;\r\n base64?: string
|
|
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 uri: string;\r\n name: string;\r\n type: string;\r\n size: 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,6 +1,8 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
|
-
import { TouchableOpacity, Text, StyleSheet, ActivityIndicator } from 'react-native';
|
|
3
|
-
|
|
2
|
+
import { TouchableOpacity, Text, StyleSheet, ActivityIndicator, NativeModules } from 'react-native';
|
|
3
|
+
const {
|
|
4
|
+
DownloadFile: NativeDownload
|
|
5
|
+
} = NativeModules;
|
|
4
6
|
const DownloadFile = ({
|
|
5
7
|
files,
|
|
6
8
|
multipleDownload = false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useState","TouchableOpacity","Text","StyleSheet","ActivityIndicator","
|
|
1
|
+
{"version":3,"names":["React","useState","TouchableOpacity","Text","StyleSheet","ActivityIndicator","NativeModules","DownloadFile","NativeDownload","files","multipleDownload","disabled","debug","maxSize","fileTypes","buttonPlaceHolder","buttonIcon","ButtonStyle","ButtonTextStyle","onSuccess","onError","isLoading","setIsLoading","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","e","console","error","createElement","style","styles","button","onPress","color","text","create","backgroundColor","padding","borderRadius","alignItems","fontWeight"],"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: 'center',\r\n },\r\n text: { color: '#000', fontWeight: 'bold' },\r\n disabled: { backgroundColor: '#AAA' }\r\n});\r\n\r\nexport default DownloadFile;"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,QAAQ,OAAO;AACvC,SAASC,gBAAgB,EAAEC,IAAI,EAAEC,UAAU,EAAEC,iBAAiB,EAACC,aAAa,QAAQ,cAAc;AAIlG,MAAM;EAAEC,YAAY,EAAEC;AAAe,CAAC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AAO,EAAE,EAAE;IACXC,YAAY,EAAE,CAAC;IACfC,UAAU,EAAE;EACd,CAAC;EACDL,IAAI,EAAE;IAAED,KAAK,EAAE,MAAM;IAAEO,UAAU,EAAE;EAAO,CAAC;EAC3CrD,QAAQ,EAAE;IAAEiD,eAAe,EAAE;EAAO;AACtC,CAAC,CAAC;AAEF,eAAerD,YAAY","ignoreList":[]}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
|
-
import { TouchableOpacity, Text, StyleSheet, ActivityIndicator } from 'react-native';
|
|
3
|
-
|
|
2
|
+
import { TouchableOpacity, Text, StyleSheet, ActivityIndicator, NativeModules } from 'react-native';
|
|
3
|
+
const {
|
|
4
|
+
UploadDocumentPicker: NativeUploadPicker
|
|
5
|
+
} = NativeModules;
|
|
6
|
+
|
|
4
7
|
// 1. Standalone pickFile Fonksiyonu
|
|
5
8
|
export const pickFile = async (options = {}) => {
|
|
6
9
|
var _options$multipleFile, _options$maxFiles, _options$maxSize, _options$fileTypes, _options$excludedUris;
|
|
7
|
-
if (!
|
|
10
|
+
if (!NativeUploadPicker) throw new Error("DocumentPicker module is not linked.");
|
|
8
11
|
|
|
9
12
|
// Native tarafa gönderilecek options
|
|
10
13
|
const nativeOptions = {
|
|
@@ -14,7 +17,7 @@ export const pickFile = async (options = {}) => {
|
|
|
14
17
|
fileTypes: (_options$fileTypes = options.fileTypes) !== null && _options$fileTypes !== void 0 ? _options$fileTypes : ['*/*'],
|
|
15
18
|
excludedUris: (_options$excludedUris = options.excludedUris) !== null && _options$excludedUris !== void 0 ? _options$excludedUris : []
|
|
16
19
|
};
|
|
17
|
-
return await
|
|
20
|
+
return await NativeUploadPicker.openDocument(nativeOptions);
|
|
18
21
|
};
|
|
19
22
|
|
|
20
23
|
// 2. MyUploader Bileşeni
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useState","TouchableOpacity","Text","StyleSheet","ActivityIndicator","
|
|
1
|
+
{"version":3,"names":["React","useState","TouchableOpacity","Text","StyleSheet","ActivityIndicator","NativeModules","UploadDocumentPicker","NativeUploadPicker","pickFile","options","_options$multipleFile","_options$maxFiles","_options$maxSize","_options$fileTypes","_options$excludedUris","Error","nativeOptions","multipleFiles","maxFiles","maxSize","fileTypes","excludedUris","openDocument","MyUploader","onSelect","onError","buttonPlaceHolder","ButtonStyle","ButtonTextStyle","disabled","isLoading","setIsLoading","handlePress","files","error","console","createElement","style","styles","button","onPress","color","text","create","backgroundColor","padding","borderRadius","alignItems","justifyContent","fontWeight","fontSize"],"sources":["MyUploader.tsx"],"sourcesContent":["import React, { useState } from 'react';\r\nimport { TouchableOpacity, Text, StyleSheet, ActivityIndicator,NativeModules } from 'react-native';\r\nimport type { MyUploaderProps, DocumentPickerOptions, FileInfo } from '../types';\r\n\r\nconst { UploadDocumentPicker: NativeUploadPicker } = NativeModules;\r\n\r\n// 1. Standalone pickFile Fonksiyonu\r\nexport const pickFile = async (options: DocumentPickerOptions = {}): Promise<FileInfo[]> => {\r\n if (!NativeUploadPicker) throw new Error(\"DocumentPicker module is not linked.\");\r\n \r\n // Native tarafa gönderilecek options\r\n const nativeOptions = {\r\n multipleFiles: options.multipleFiles ?? false,\r\n maxFiles: options.maxFiles ?? 0,\r\n maxSize: options.maxSize ?? 0,\r\n fileTypes: options.fileTypes ?? ['*/*'],\r\n excludedUris: options.excludedUris ?? [],\r\n };\r\n\r\n return await NativeUploadPicker.openDocument(nativeOptions);\r\n};\r\n\r\n// 2. MyUploader Bileşeni\r\nconst MyUploader: React.FC<MyUploaderProps> = ({\r\n onSelect,\r\n onError,\r\n buttonPlaceHolder = \"Dosya Seç\",\r\n ButtonStyle,\r\n ButtonTextStyle,\r\n disabled = false,\r\n multipleFiles = false,\r\n fileTypes = ['*/*'],\r\n maxSize = 0,\r\n maxFiles = 0,\r\n excludedUris = [],\r\n}) => {\r\n const [isLoading, setIsLoading] = useState(false);\r\n\r\n const handlePress = async () => {\r\n if (disabled || isLoading) return;\r\n setIsLoading(true);\r\n\r\n try {\r\n const files = await pickFile({\r\n multipleFiles,\r\n fileTypes,\r\n maxSize,\r\n maxFiles,\r\n excludedUris\r\n });\r\n \r\n onSelect(files);\r\n } catch (error: any) {\r\n if (onError) {\r\n onError(error);\r\n } else {\r\n console.error(\"MyUploader Error:\", error);\r\n }\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 <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: '#6200EE',\r\n padding: 12,\r\n borderRadius: 8,\r\n alignItems: 'center',\r\n justifyContent: 'center'\r\n },\r\n text: {\r\n color: '#FFF',\r\n fontWeight: '600',\r\n fontSize: 16\r\n },\r\n disabled: {\r\n backgroundColor: '#B0B0B0'\r\n }\r\n});\r\n\r\nexport default MyUploader;"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,QAAQ,OAAO;AACvC,SAASC,gBAAgB,EAAEC,IAAI,EAAEC,UAAU,EAAEC,iBAAiB,EAACC,aAAa,QAAQ,cAAc;AAGlG,MAAM;EAAEC,oBAAoB,EAAEC;AAAmB,CAAC,GAAGF,aAAa;;AAElE;AACA,OAAO,MAAMG,QAAQ,GAAG,MAAAA,CAAOC,OAA8B,GAAG,CAAC,CAAC,KAA0B;EAAA,IAAAC,qBAAA,EAAAC,iBAAA,EAAAC,gBAAA,EAAAC,kBAAA,EAAAC,qBAAA;EAC1F,IAAI,CAACP,kBAAkB,EAAE,MAAM,IAAIQ,KAAK,CAAC,sCAAsC,CAAC;;EAEhF;EACA,MAAMC,aAAa,GAAG;I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AC,CAAC,OAAOC,KAAU,EAAE;MACnB,IAAIT,OAAO,EAAE;QACXA,OAAO,CAACS,KAAK,CAAC;MAChB,CAAC,MAAM;QACLC,OAAO,CAACD,KAAK,CAAC,mBAAmB,EAAEA,KAAK,CAAC;MAC3C;IACF,CAAC,SAAS;MACRH,YAAY,CAAC,KAAK,CAAC;IACrB;EACF,CAAC;EAED,oBACEhC,KAAA,CAAAqC,aAAA,CAACnC,gBAAgB;IACfoC,KAAK,EAAE,CAACC,MAAM,CAACC,MAAM,EAAEZ,WAAW,EAAE,CAACE,QAAQ,IAAIC,SAAS,KAAKQ,MAAM,CAACT,QAAQ,CAAE;IAChFW,OAAO,EAAER,WAAY;IACrBH,QAAQ,EAAEA,QAAQ,IAAIC;EAAU,GAE/BA,SAAS,gBACR/B,KAAA,CAAAqC,aAAA,CAAChC,iBAAiB;IAACqC,KAAK,EAAC;EAAM,CAAE,CAAC,gBAElC1C,KAAA,CAAAqC,aAAA,CAAClC,IAAI;IAACmC,KAAK,EAAE,CAACC,MAAM,CAACI,IAAI,EAAEd,eAAe;EAAE,GAAEF,iBAAwB,CAExD,CAAC;AAEvB,CAAC;AAED,MAAMY,MAAM,GAAGnC,UAAU,CAACwC,MAAM,CAAC;EAC/BJ,MAAM,EAAE;IACNK,eAAe,EAAE,SAAS;IAC1BC,OAAO,EAAE,EAAE;IACXC,YAAY,EAAE,CAAC;IACfC,UAAU,EAAE,QAAQ;IACpBC,cAAc,EAAE;EAClB,CAAC;EACDN,IAAI,EAAE;IACJD,KAAK,EAAE,MAAM;IACbQ,UAAU,EAAE,KAAK;IACjBC,QAAQ,EAAE;EACZ,CAAC;EACDrB,QAAQ,EAAE;IACRe,eAAe,EAAE;EACnB;AACF,CAAC,CAAC;AAEF,eAAerB,UAAU","ignoreList":[]}
|
package/lib/module/index.d.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
+
// import type { DownloadFileProps } from './types';
|
|
2
|
+
|
|
1
3
|
export * from './types';
|
|
2
4
|
|
|
3
5
|
// DownloadFile Component Tanımı (3. Bunu ekledik)
|
|
6
|
+
// export declare const DownloadFile: React.FC<DownloadFileProps>;
|
|
4
7
|
|
|
5
8
|
// pickFile Fonksiyon Tanımı
|
|
6
9
|
|
|
7
10
|
// Varsayılan dışa aktarım (İsteğe bağlı, genellikle ana bileşen verilir)
|
|
11
|
+
export {};
|
|
8
12
|
//# sourceMappingURL=index.d.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.d.ts"],"sourcesContent":["import * as React from 'react';\r\nimport type {
|
|
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\n\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,10 +1,13 @@
|
|
|
1
1
|
import MyUploader, { pickFile } from "./components/MyUploader";
|
|
2
|
-
import DownloadFile from "./components/DownloadFile";
|
|
3
|
-
|
|
4
|
-
// 1. MyUploader'ı DEFAULT olarak dışa aktar (import MyUploader from ... için)
|
|
5
|
-
export default MyUploader;
|
|
2
|
+
// import DownloadFile from "./components/DownloadFile";
|
|
6
3
|
|
|
7
4
|
// 2. Diğerlerini NAMED olarak dışa aktar (import { DownloadFile, pickFile } ... için)
|
|
8
|
-
export { DownloadFile, pickFile };
|
|
5
|
+
// export { DownloadFile, pickFile };
|
|
6
|
+
|
|
7
|
+
// Sadece bu paketle ilgili olanları dışa aktar
|
|
8
|
+
export { MyUploader, pickFile };
|
|
9
9
|
export * from './types';
|
|
10
|
+
|
|
11
|
+
// Varsayılan dışa aktarım olarak da ana bileşeni verelim
|
|
12
|
+
export default MyUploader;
|
|
10
13
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["MyUploader","pickFile"
|
|
1
|
+
{"version":3,"names":["MyUploader","pickFile"],"sources":["index.ts"],"sourcesContent":["import MyUploader,{pickFile} from \"./components/MyUploader\";\r\n// import DownloadFile from \"./components/DownloadFile\";\r\n\r\n// 2. Diğerlerini NAMED olarak dışa aktar (import { DownloadFile, pickFile } ... için)\r\n// export { DownloadFile, pickFile };\r\n\r\n\r\n// Sadece bu paketle ilgili olanları dışa aktar\r\nexport { MyUploader, pickFile };\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;;AAEA;AACA;;AAGA;AACA,SAASD,UAAU,EAAEC,QAAQ;AAC7B,cAAc,SAAS;;AAEvB;AACA,eAAeD,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 uri: string;\r\n name: string;\r\n type: string;\r\n size: number;\r\n base64?: string
|
|
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 uri: string;\r\n name: string;\r\n type: string;\r\n size: 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":[]}
|
package/package.json
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
|
-
import { TouchableOpacity, Text, StyleSheet, ActivityIndicator } from 'react-native';
|
|
3
|
-
import { NativeDownload } from '../NativeModules';
|
|
2
|
+
import { TouchableOpacity, Text, StyleSheet, ActivityIndicator,NativeModules } from 'react-native';
|
|
4
3
|
import type { DownloadFileProps, DownloadResult } from '../types';
|
|
5
4
|
|
|
5
|
+
|
|
6
|
+
const { DownloadFile: NativeDownload } = NativeModules;
|
|
7
|
+
|
|
8
|
+
|
|
6
9
|
const DownloadFile: React.FC<DownloadFileProps> = ({
|
|
7
10
|
files,
|
|
8
11
|
multipleDownload = false,
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
|
-
import { TouchableOpacity, Text, StyleSheet, ActivityIndicator } from 'react-native';
|
|
3
|
-
import { NativePicker } from '../NativeModules';
|
|
2
|
+
import { TouchableOpacity, Text, StyleSheet, ActivityIndicator,NativeModules } from 'react-native';
|
|
4
3
|
import type { MyUploaderProps, DocumentPickerOptions, FileInfo } from '../types';
|
|
5
4
|
|
|
5
|
+
const { UploadDocumentPicker: NativeUploadPicker } = NativeModules;
|
|
6
|
+
|
|
6
7
|
// 1. Standalone pickFile Fonksiyonu
|
|
7
8
|
export const pickFile = async (options: DocumentPickerOptions = {}): Promise<FileInfo[]> => {
|
|
8
|
-
if (!
|
|
9
|
+
if (!NativeUploadPicker) throw new Error("DocumentPicker module is not linked.");
|
|
9
10
|
|
|
10
11
|
// Native tarafa gönderilecek options
|
|
11
12
|
const nativeOptions = {
|
|
@@ -16,7 +17,7 @@ export const pickFile = async (options: DocumentPickerOptions = {}): Promise<Fil
|
|
|
16
17
|
excludedUris: options.excludedUris ?? [],
|
|
17
18
|
};
|
|
18
19
|
|
|
19
|
-
return await
|
|
20
|
+
return await NativeUploadPicker.openDocument(nativeOptions);
|
|
20
21
|
};
|
|
21
22
|
|
|
22
23
|
// 2. MyUploader Bileşeni
|
package/src/index.d.ts
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
MyUploaderProps,
|
|
5
|
-
FileInfo,
|
|
6
|
-
DownloadFileProps } from './types';
|
|
2
|
+
import type { DocumentPickerOptions, MyUploaderProps, FileInfo } from './types';
|
|
3
|
+
// import type { DownloadFileProps } from './types';
|
|
7
4
|
|
|
8
5
|
export * from './types';
|
|
9
6
|
|
|
10
|
-
export declare const MyUploader: React.FC<MyUploaderProps>;
|
|
11
|
-
|
|
12
7
|
// DownloadFile Component Tanımı (3. Bunu ekledik)
|
|
13
|
-
export declare const DownloadFile: React.FC<DownloadFileProps>;
|
|
8
|
+
// export declare const DownloadFile: React.FC<DownloadFileProps>;
|
|
14
9
|
|
|
15
10
|
// pickFile Fonksiyon Tanımı
|
|
16
|
-
export function pickFile(options?: DocumentPickerOptions): Promise<FileInfo[]>;
|
|
11
|
+
export declare function pickFile(options?: DocumentPickerOptions): Promise<FileInfo[]>;
|
|
12
|
+
|
|
13
|
+
export declare const MyUploader: React.FC<MyUploaderProps>;
|
|
17
14
|
|
|
18
15
|
// Varsayılan dışa aktarım (İsteğe bağlı, genellikle ana bileşen verilir)
|
|
19
|
-
|
|
16
|
+
declare const _default: React.FC<MyUploaderProps>;
|
|
17
|
+
export default _default;
|
package/src/index.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import MyUploader,{pickFile} from "./components/MyUploader";
|
|
2
|
-
import DownloadFile from "./components/DownloadFile";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
// 1. MyUploader'ı DEFAULT olarak dışa aktar (import MyUploader from ... için)
|
|
6
|
-
export default MyUploader;
|
|
2
|
+
// import DownloadFile from "./components/DownloadFile";
|
|
7
3
|
|
|
8
4
|
// 2. Diğerlerini NAMED olarak dışa aktar (import { DownloadFile, pickFile } ... için)
|
|
9
|
-
export { DownloadFile, pickFile };
|
|
5
|
+
// export { DownloadFile, pickFile };
|
|
10
6
|
|
|
11
7
|
|
|
8
|
+
// Sadece bu paketle ilgili olanları dışa aktar
|
|
9
|
+
export { MyUploader, pickFile };
|
|
12
10
|
export * from './types';
|
|
13
11
|
|
|
12
|
+
// Varsayılan dışa aktarım olarak da ana bileşeni verelim
|
|
13
|
+
export default MyUploader;
|
|
14
|
+
|
|
14
15
|
|
|
15
16
|
|
package/src/types.ts
CHANGED
|
@@ -76,13 +76,9 @@ export interface FileInfo {
|
|
|
76
76
|
name: string;
|
|
77
77
|
type: string;
|
|
78
78
|
size: number;
|
|
79
|
-
base64?: string;
|
|
79
|
+
base64?: string | null;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
export interface DownloadResult {
|
|
83
|
-
successful: { originalUrl: string; localUri: string | null }[];
|
|
84
|
-
skipped: { originalUrl: string; reason: string }[];
|
|
85
|
-
}
|
|
86
82
|
|
|
87
83
|
// ----- MyUploader & pickFile Props -----
|
|
88
84
|
export interface DocumentPickerOptions {
|
|
@@ -116,4 +112,10 @@ export interface DownloadFileProps {
|
|
|
116
112
|
ButtonTextStyle?: TextStyle;
|
|
117
113
|
onSuccess?: (result: DownloadResult) => void;
|
|
118
114
|
onError?: (error: any) => void;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
export interface DownloadResult {
|
|
119
|
+
successful: { originalUrl: string; localUri: string | null }[];
|
|
120
|
+
skipped: { originalUrl: string; reason: string }[];
|
|
119
121
|
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.NativePicker = exports.NativeDownload = void 0;
|
|
7
|
-
var _reactNative = require("react-native");
|
|
8
|
-
const {
|
|
9
|
-
DownloadFile,
|
|
10
|
-
DocumentPicker
|
|
11
|
-
} = _reactNative.NativeModules;
|
|
12
|
-
if (!DownloadFile) console.warn("MyUploader: DownloadFile native module not found.");
|
|
13
|
-
if (!DocumentPicker) console.warn("MyUploader: DocumentPicker native module not found.");
|
|
14
|
-
const NativeDownload = exports.NativeDownload = DownloadFile;
|
|
15
|
-
const NativePicker = exports.NativePicker = DocumentPicker;
|
|
16
|
-
//# sourceMappingURL=NativeModules.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","DownloadFile","DocumentPicker","NativeModules","console","warn","NativeDownload","exports","NativePicker"],"sources":["NativeModules.ts"],"sourcesContent":["import { NativeModules } from 'react-native';\r\n\r\nconst { DownloadFile, DocumentPicker } = NativeModules;\r\n\r\nif (!DownloadFile) console.warn(\"MyUploader: DownloadFile native module not found.\");\r\nif (!DocumentPicker) console.warn(\"MyUploader: DocumentPicker native module not found.\");\r\n\r\nexport const NativeDownload = DownloadFile;\r\nexport const NativePicker = DocumentPicker;"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEA,MAAM;EAAEC,YAAY;EAAEC;AAAe,CAAC,GAAGC,0BAAa;AAEtD,IAAI,CAACF,YAAY,EAAEG,OAAO,CAACC,IAAI,CAAC,mDAAmD,CAAC;AACpF,IAAI,CAACH,cAAc,EAAEE,OAAO,CAACC,IAAI,CAAC,qDAAqD,CAAC;AAEjF,MAAMC,cAAc,GAAAC,OAAA,CAAAD,cAAA,GAAGL,YAAY;AACnC,MAAMO,YAAY,GAAAD,OAAA,CAAAC,YAAA,GAAGN,cAAc","ignoreList":[]}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { NativeModules } from 'react-native';
|
|
2
|
-
const {
|
|
3
|
-
DownloadFile,
|
|
4
|
-
DocumentPicker
|
|
5
|
-
} = NativeModules;
|
|
6
|
-
if (!DownloadFile) console.warn("MyUploader: DownloadFile native module not found.");
|
|
7
|
-
if (!DocumentPicker) console.warn("MyUploader: DocumentPicker native module not found.");
|
|
8
|
-
export const NativeDownload = DownloadFile;
|
|
9
|
-
export const NativePicker = DocumentPicker;
|
|
10
|
-
//# sourceMappingURL=NativeModules.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["NativeModules","DownloadFile","DocumentPicker","console","warn","NativeDownload","NativePicker"],"sources":["NativeModules.ts"],"sourcesContent":["import { NativeModules } from 'react-native';\r\n\r\nconst { DownloadFile, DocumentPicker } = NativeModules;\r\n\r\nif (!DownloadFile) console.warn(\"MyUploader: DownloadFile native module not found.\");\r\nif (!DocumentPicker) console.warn(\"MyUploader: DocumentPicker native module not found.\");\r\n\r\nexport const NativeDownload = DownloadFile;\r\nexport const NativePicker = DocumentPicker;"],"mappings":"AAAA,SAASA,aAAa,QAAQ,cAAc;AAE5C,MAAM;EAAEC,YAAY;EAAEC;AAAe,CAAC,GAAGF,aAAa;AAEtD,IAAI,CAACC,YAAY,EAAEE,OAAO,CAACC,IAAI,CAAC,mDAAmD,CAAC;AACpF,IAAI,CAACF,cAAc,EAAEC,OAAO,CAACC,IAAI,CAAC,qDAAqD,CAAC;AAExF,OAAO,MAAMC,cAAc,GAAGJ,YAAY;AAC1C,OAAO,MAAMK,YAAY,GAAGJ,cAAc","ignoreList":[]}
|
package/src/NativeModules.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { NativeModules } from 'react-native';
|
|
2
|
-
|
|
3
|
-
const { DownloadFile, DocumentPicker } = NativeModules;
|
|
4
|
-
|
|
5
|
-
if (!DownloadFile) console.warn("MyUploader: DownloadFile native module not found.");
|
|
6
|
-
if (!DocumentPicker) console.warn("MyUploader: DocumentPicker native module not found.");
|
|
7
|
-
|
|
8
|
-
export const NativeDownload = DownloadFile;
|
|
9
|
-
export const NativePicker = DocumentPicker;
|