react-native-my-uploader-android 1.0.39 → 1.0.41
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/AndroidManifest.xml +2 -0
- package/android/src/main/java/com/myuploaderandroid/MyUploaderModule.kt +53 -11
- package/lib/commonjs/components/MyUploader.js +15 -3
- package/lib/commonjs/components/MyUploader.js.map +1 -1
- package/lib/commonjs/index.d.js.map +1 -1
- package/lib/commonjs/index.js +7 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/module/components/MyUploader.js +13 -2
- package/lib/module/components/MyUploader.js.map +1 -1
- package/lib/module/index.d.js +0 -2
- package/lib/module/index.d.js.map +1 -1
- package/lib/module/index.js +2 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/package.json +1 -1
- package/src/components/MyUploader.tsx +15 -0
- package/src/index.d.ts +3 -1
- package/src/index.ts +2 -2
- package/src/types.ts +1 -0
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
|
2
2
|
<uses-permission android:name="android.permission.INTERNET" />
|
|
3
3
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="28" />
|
|
4
|
+
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
|
5
|
+
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
|
|
4
6
|
</manifest>
|
|
@@ -13,6 +13,7 @@ import android.util.Base64OutputStream
|
|
|
13
13
|
import android.graphics.Bitmap
|
|
14
14
|
import android.graphics.BitmapFactory
|
|
15
15
|
import android.graphics.Matrix
|
|
16
|
+
import android.provider.MediaStore
|
|
16
17
|
|
|
17
18
|
class MyUploaderModule(private val reactContext: ReactApplicationContext) :
|
|
18
19
|
ReactContextBaseJavaModule(reactContext), ActivityEventListener {
|
|
@@ -46,6 +47,7 @@ class MyUploaderModule(private val reactContext: ReactApplicationContext) :
|
|
|
46
47
|
|
|
47
48
|
this.pickerPromise = promise
|
|
48
49
|
|
|
50
|
+
val isGallery = options.takeIf { it.hasKey("isGallery") }?.getBoolean("isGallery") ?: false
|
|
49
51
|
val multipleFiles = options.takeIf { it.hasKey("multipleFiles") }?.getBoolean("multipleFiles") ?: false
|
|
50
52
|
val jsMaxFiles = options.takeIf { it.hasKey("maxFiles") }?.getInt("maxFiles") ?: 0
|
|
51
53
|
|
|
@@ -75,26 +77,34 @@ class MyUploaderModule(private val reactContext: ReactApplicationContext) :
|
|
|
75
77
|
return
|
|
76
78
|
}
|
|
77
79
|
|
|
78
|
-
val fileTypes = options.takeIf { it.hasKey("fileTypes") }
|
|
79
|
-
?.getArray("fileTypes")?.toArrayList()?.mapNotNull { it.toString() } ?: listOf("*/*")
|
|
80
|
-
val mimeTypes = if (fileTypes.isEmpty()) arrayOf("*/*") else fileTypes.toTypedArray()
|
|
81
|
-
|
|
82
80
|
try {
|
|
83
|
-
|
|
84
|
-
|
|
81
|
+
val intent: Intent
|
|
82
|
+
if (isGallery) {
|
|
83
|
+
// SENARYO A: Sadece Galeri/Fotoğraflar Uygulamasını Açar
|
|
84
|
+
intent = Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI)
|
|
85
|
+
if (multipleFiles) {
|
|
86
|
+
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true)
|
|
87
|
+
}
|
|
88
|
+
} else {
|
|
89
|
+
// SENARYO B: Genel Dosya Seçiciyi Açarlar (Sizin eski kodunuz)
|
|
90
|
+
val fileTypes = options.takeIf { it.hasKey("fileTypes") }
|
|
91
|
+
?.getArray("fileTypes")?.toArrayList()?.mapNotNull { it.toString() } ?: listOf("*/*")
|
|
92
|
+
val mimeTypes = if (fileTypes.isEmpty()) arrayOf("*/*") else fileTypes.toTypedArray()
|
|
93
|
+
|
|
94
|
+
intent = Intent(Intent.ACTION_GET_CONTENT).apply {
|
|
85
95
|
type = "*/*"
|
|
86
96
|
addCategory(Intent.CATEGORY_OPENABLE)
|
|
87
97
|
putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes)
|
|
88
|
-
|
|
89
98
|
if (multipleFiles) {
|
|
90
99
|
putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true)
|
|
91
100
|
}
|
|
92
101
|
}
|
|
93
|
-
currentActivity.startActivityForResult(Intent.createChooser(intent, "Dosya Seçin"), REQUEST_CODE)
|
|
94
|
-
} catch (e: Exception) {
|
|
95
|
-
pickerPromise?.reject(E_FAILED_TO_OPEN_DOCUMENT, e)
|
|
96
|
-
pickerPromise = null
|
|
97
102
|
}
|
|
103
|
+
currentActivity.startActivityForResult(Intent.createChooser(intent, "Seçim Yapın"), REQUEST_CODE)
|
|
104
|
+
} catch (e: Exception) {
|
|
105
|
+
pickerPromise?.reject(E_FAILED_TO_OPEN_DOCUMENT, e)
|
|
106
|
+
pickerPromise = null
|
|
107
|
+
}
|
|
98
108
|
}
|
|
99
109
|
|
|
100
110
|
|
|
@@ -183,7 +193,39 @@ class MyUploaderModule(private val reactContext: ReactApplicationContext) :
|
|
|
183
193
|
}
|
|
184
194
|
}.start()
|
|
185
195
|
}
|
|
196
|
+
|
|
197
|
+
@ReactMethod
|
|
198
|
+
fun getBase64FromUri(cropFileUri: String, promise: Promise) {
|
|
199
|
+
Thread {
|
|
200
|
+
try {
|
|
201
|
+
val uri = Uri.parse(cropFileUri)
|
|
202
|
+
val contentResolver = reactApplicationContext.contentResolver
|
|
203
|
+
|
|
204
|
+
// 1️⃣ MIME TYPE tespiti
|
|
205
|
+
val mimeType = contentResolver.getType(uri)
|
|
206
|
+
?: URLConnection.guessContentTypeFromName(cropFileUri)
|
|
207
|
+
?: "image/jpeg"
|
|
208
|
+
|
|
209
|
+
// 2️⃣ InputStream açma ve Byte okuma
|
|
210
|
+
val inputStream = contentResolver.openInputStream(uri)
|
|
211
|
+
?: throw Exception("Dosya yolu geçersiz veya erişilemedi.")
|
|
212
|
+
|
|
213
|
+
inputStream.use { stream ->
|
|
214
|
+
// NOT: Crop sonrası küçük dosyalar için readBytes performanslıdır.
|
|
215
|
+
val bytes = stream.readBytes()
|
|
216
|
+
|
|
217
|
+
// 3️⃣ Base64 çevrimi
|
|
218
|
+
val base64 = Base64.encodeToString(bytes, Base64.NO_WRAP)
|
|
219
|
+
|
|
220
|
+
// 4️⃣ Sonucu doğrudan döndür (Thread-safe)
|
|
221
|
+
promise.resolve("data:$mimeType;base64,$base64")
|
|
222
|
+
}
|
|
186
223
|
|
|
224
|
+
} catch (e: Exception) {
|
|
225
|
+
promise.reject("E_BASE64_ERROR", e.message)
|
|
226
|
+
}
|
|
227
|
+
}.start()
|
|
228
|
+
}
|
|
187
229
|
|
|
188
230
|
override fun onActivityResult(activity: Activity, requestCode: Int, resultCode: Int, data: Intent?) {
|
|
189
231
|
if (requestCode != REQUEST_CODE || pickerPromise == null) { return }
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.pickFile = exports.default = exports.RotateImage = void 0;
|
|
6
|
+
exports.pickFile = exports.getBase64FromUri = exports.default = exports.RotateImage = void 0;
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _reactNative = require("react-native");
|
|
9
9
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
@@ -13,7 +13,7 @@ const {
|
|
|
13
13
|
|
|
14
14
|
// 1. Standalone pickFile Fonksiyonu
|
|
15
15
|
const pickFile = async (options = {}) => {
|
|
16
|
-
var _options$multipleFile, _options$maxFiles, _options$maxSize, _options$fileTypes, _options$excludedUris;
|
|
16
|
+
var _options$multipleFile, _options$maxFiles, _options$maxSize, _options$fileTypes, _options$excludedUris, _options$isGallery;
|
|
17
17
|
if (!NativeUploadPicker) throw new Error("DocumentPicker module is not linked.");
|
|
18
18
|
|
|
19
19
|
// Native tarafa gönderilecek options
|
|
@@ -22,11 +22,23 @@ const pickFile = async (options = {}) => {
|
|
|
22
22
|
maxFiles: (_options$maxFiles = options.maxFiles) !== null && _options$maxFiles !== void 0 ? _options$maxFiles : 0,
|
|
23
23
|
maxSize: (_options$maxSize = options.maxSize) !== null && _options$maxSize !== void 0 ? _options$maxSize : 0,
|
|
24
24
|
fileTypes: (_options$fileTypes = options.fileTypes) !== null && _options$fileTypes !== void 0 ? _options$fileTypes : ['*/*'],
|
|
25
|
-
excludedUris: (_options$excludedUris = options.excludedUris) !== null && _options$excludedUris !== void 0 ? _options$excludedUris : []
|
|
25
|
+
excludedUris: (_options$excludedUris = options.excludedUris) !== null && _options$excludedUris !== void 0 ? _options$excludedUris : [],
|
|
26
|
+
isGallery: (_options$isGallery = options.isGallery) !== null && _options$isGallery !== void 0 ? _options$isGallery : false
|
|
26
27
|
};
|
|
27
28
|
return await NativeUploadPicker.openDocument(nativeOptions);
|
|
28
29
|
};
|
|
29
30
|
exports.pickFile = pickFile;
|
|
31
|
+
const getBase64FromUri = async cropFileUri => {
|
|
32
|
+
if (!NativeUploadPicker) {
|
|
33
|
+
throw new Error("UploadDocumentPicker modülü linklenmemiş.");
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
return await NativeUploadPicker.getBase64FromUri(cropFileUri);
|
|
37
|
+
} catch (error) {
|
|
38
|
+
throw new Error(`getBase64FromUri Hatası: ${error.message}`);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
exports.getBase64FromUri = getBase64FromUri;
|
|
30
42
|
const RotateImage = async ({
|
|
31
43
|
base64,
|
|
32
44
|
angle
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","UploadDocumentPicker","NativeUploadPicker","NativeModules","pickFile","options","_options$multipleFile","_options$maxFiles","_options$maxSize","_options$fileTypes","_options$excludedUris","Error","nativeOptions","multipleFiles","maxFiles","maxSize","fileTypes","excludedUris","openDocument","exports","
|
|
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","_options$isGallery","Error","nativeOptions","multipleFiles","maxFiles","maxSize","fileTypes","excludedUris","isGallery","openDocument","exports","getBase64FromUri","cropFileUri","error","message","RotateImage","base64","angle","rotatedBase64","rotateImage","MyUploader","onSelect","onError","buttonPlaceHolder","ButtonStyle","ButtonTextStyle","disabled","isLoading","setIsLoading","useState","handlePress","files","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, RotateImageProps } 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 isGallery:options.isGallery ?? false,\r\n };\r\n\r\n return await NativeUploadPicker.openDocument(nativeOptions);\r\n};\r\n\r\nexport const getBase64FromUri = async (cropFileUri: string): Promise<string> => {\r\n if (!NativeUploadPicker) {\r\n throw new Error(\"UploadDocumentPicker modülü linklenmemiş.\");\r\n }\r\n\r\n try {\r\n return await NativeUploadPicker.getBase64FromUri(cropFileUri);\r\n } catch (error: any) {\r\n throw new Error(`getBase64FromUri Hatası: ${error.message}`);\r\n }\r\n};\r\n\r\n\r\n\r\nexport const RotateImage = async ({ base64, angle }: RotateImageProps): Promise<string> => {\r\n if (!NativeUploadPicker) {\r\n throw new Error(\"UploadDocumentPicker modülü linklenmemiş.\");\r\n }\r\n\r\n try {\r\n // Native sadece saf base64 string'i döner\r\n const rotatedBase64: string = await NativeUploadPicker.rotateImage(base64, angle);\r\n\r\n // Uygulama tarafında doğrudan <Image /> içinde kullanılabilmesi için prefix eklenir\r\n return `data:image/jpeg;base64,${rotatedBase64}`;\r\n } catch (error: any) {\r\n // Hata mesajını daha okunaklı fırlatıyoruz\r\n throw new Error(`RotateImage Hatası: ${error.message}`);\r\n }\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,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,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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R5D,MAAA,CAAAc,OAAA,CAAAoD,aAAA,CAAC/D,YAAA,CAAAqE,iBAAiB;IAACC,KAAK,EAAC;EAAM,CAAE,CAAC,gBAElCzE,MAAA,CAAAc,OAAA,CAAAoD,aAAA,CAAC/D,YAAA,CAAAuE,IAAI;IAACN,KAAK,EAAE,CAACC,MAAM,CAACM,IAAI,EAAEjB,eAAe;EAAE,GAAEF,iBAAwB,CAExD,CAAC;AAEvB,CAAC;AAED,MAAMa,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,QAAQ;IACpBC,cAAc,EAAE;EAClB,CAAC;EACDP,IAAI,EAAE;IACJF,KAAK,EAAE,MAAM;IACbU,UAAU,EAAE,KAAK;IACjBC,QAAQ,EAAE;EACZ,CAAC;EACDzB,QAAQ,EAAE;IACRmB,eAAe,EAAE;EACnB;AACF,CAAC,CAAC;AAAC,IAAAO,QAAA,GAAA1C,OAAA,CAAA7B,OAAA,GAEYuC,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 { DocumentPickerOptions, MyUploaderProps, FileInfo, DownloadFileProps ,RotateImageProps } 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
|
|
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 ,RotateImageProps } 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\r\nexport declare function pickFile(options?: DocumentPickerOptions): Promise<FileInfo[]>;\r\nexport declare function RotateImage(props:RotateImageProps):Promise<string>;\r\nexport declare function getBase64FromUri(cropFileUri: string): Promise<string>;\r\n\r\nexport declare const DownloadFile :React.FC<DownloadFileProps>;\r\nexport declare const MyUploader: React.FC<MyUploaderProps>;\r\n\r\n// Varsayılan dışa aktarım (İsteğe bağlı, genellikle ana bileşen verilir)\r\ndeclare const _default: React.FC<MyUploaderProps>;\r\nexport default _default;"],"mappings":";;;;;AAIA,IAAAA,MAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,MAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,MAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,MAAA,CAAAK,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -7,6 +7,7 @@ var _exportNames = {
|
|
|
7
7
|
MyUploader: true,
|
|
8
8
|
pickFile: true,
|
|
9
9
|
RotateImage: true,
|
|
10
|
+
getBase64FromUri: true,
|
|
10
11
|
DownloadFile: true
|
|
11
12
|
};
|
|
12
13
|
Object.defineProperty(exports, "DownloadFile", {
|
|
@@ -28,6 +29,12 @@ Object.defineProperty(exports, "RotateImage", {
|
|
|
28
29
|
}
|
|
29
30
|
});
|
|
30
31
|
exports.default = void 0;
|
|
32
|
+
Object.defineProperty(exports, "getBase64FromUri", {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return _MyUploader.getBase64FromUri;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
31
38
|
Object.defineProperty(exports, "pickFile", {
|
|
32
39
|
enumerable: true,
|
|
33
40
|
get: function () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_MyUploader","_interopRequireWildcard","require","_DownloadFile","_types","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","set","getOwnPropertyDescriptor","_default","MyUploader"],"sources":["index.ts"],"sourcesContent":["import MyUploader,{pickFile,RotateImage} from \"./components/MyUploader\";\r\nimport {DownloadFile} from \"./components/DownloadFile\";\r\n\r\n\r\n// Sadece bu paketle ilgili olanları dışa aktar\r\nexport { MyUploader, pickFile ,DownloadFile ,RotateImage };\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":"
|
|
1
|
+
{"version":3,"names":["_MyUploader","_interopRequireWildcard","require","_DownloadFile","_types","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","set","getOwnPropertyDescriptor","_default","MyUploader"],"sources":["index.ts"],"sourcesContent":["import MyUploader,{pickFile,RotateImage,getBase64FromUri} from \"./components/MyUploader\";\r\nimport {DownloadFile} from \"./components/DownloadFile\";\r\n\r\n\r\n// Sadece bu paketle ilgili olanları dışa aktar\r\nexport { MyUploader, pickFile ,DownloadFile ,RotateImage,getBase64FromUri };\r\nexport * from './types';\r\n\r\n// Varsayılan dışa aktarım olarak da ana bileşeni verelim\r\nexport default MyUploader;\r\n\r\n\r\n\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,WAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,a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CAAA,CAAAR,GAAA,IAAAQ,CAAA,CAAAK,GAAA,IAAAN,CAAA,CAAAE,CAAA,EAAAP,CAAA,EAAAM,CAAA,IAAAC,CAAA,CAAAP,CAAA,IAAAD,CAAA,CAAAC,CAAA,WAAAO,CAAA,KAAAR,CAAA,EAAAC,CAAA;AAFxB;AAIA;AAAA,IAAAa,QAAA,GAAAlB,OAAA,CAAAc,OAAA,GACeK,mBAAU","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["// import type { StyleProp, TextStyle, ViewStyle } from 'react-native';\r\n\r\n// export interface FileInfo {\r\n// fileName: string;\r\n// fileSize: number; \r\n// fileType: string | null;\r\n// fileUri: string;\r\n// base64: string;\r\n// }\r\n\r\n// export interface MyUploaderProps{\r\n// onSelect: (files: FileInfo[]) => void;\r\n// onError?: (error: Error) => void;\r\n// buttonPlaceHolder?: string;\r\n// ButtonStyle?: StyleProp<ViewStyle>;\r\n// ButtonTextStyle?: StyleProp<TextStyle>;\r\n// disabled?: boolean; \r\n// multipleFiles?: boolean;\r\n// fileTypes?: string[];\r\n// maxSize?: number;\r\n// maxFiles?: number;\r\n// excludedUris?: string[];\r\n// }\r\n\r\n// export interface DownloadedFileInfo {\r\n// originalUrl: string;\r\n// localUri: string;\r\n// }\r\n\r\n// export interface SkippedFileInfo {\r\n// originalUrl: string;\r\n// reason: string; \r\n// }\r\n\r\n\r\n\r\n// export interface UploadFileProps {\r\n// files: string[];\r\n// multipleLoad?: boolean;\r\n// disabled?: boolean;\r\n// debug?: boolean; \r\n// maxSize?: number;\r\n// fileTypes?: string[];\r\n// buttonPlaceHolder?: string;\r\n// buttonIcon?: React.ReactNode;\r\n// ButtonStyle?: StyleProp<ViewStyle>;\r\n// ButtonTextStyle?: StyleProp<TextStyle>;\r\n// onSuccess?: (result: DownloadResult) => void;\r\n// onError?: (error: Error) => void;\r\n// }\r\n\r\n// export interface DownloadFileProps {\r\n// files: string[];\r\n// multipleDownload?: boolean;\r\n// disabled?: boolean;\r\n// debug?: boolean;\r\n// maxSize?: number; // MB\r\n// fileTypes?: string[];\r\n// buttonPlaceHolder?: string;\r\n// buttonIcon?: React.ReactNode;\r\n// ButtonStyle?: ViewStyle;\r\n// ButtonTextStyle?: TextStyle;\r\n// onSuccess?: (result: DownloadResult) => void;\r\n// onError?: (error: any) => void;\r\n// }\r\n// export interface DownloadResult {\r\n// successful: { originalUrl: string; localUri: string | null }[];\r\n// skipped: { originalUrl: string; reason: string }[];\r\n// }\r\n\r\n\r\nimport type { ViewStyle, TextStyle } from 'react-native';\r\n\r\nexport interface FileInfo {\r\n fileUri: string;\r\n fileName: string;\r\n fileType: string;\r\n fileSize: number;\r\n base64?: string | null;\r\n}\r\n\r\n\r\n// ----- MyUploader & pickFile Props -----\r\nexport interface DocumentPickerOptions {\r\n multipleFiles?: boolean;\r\n fileTypes?: string[]; // örn: ['image/*', 'application/pdf']\r\n maxSize?: number; // MB cinsinden\r\n maxFiles?: number;\r\n excludedUris?: string[];\r\n}\r\n\r\nexport interface MyUploaderProps extends DocumentPickerOptions {\r\n onSelect: (files: FileInfo[]) => void;\r\n onError?: (error: Error) => void;\r\n buttonPlaceHolder?: string;\r\n ButtonStyle?: ViewStyle;\r\n ButtonTextStyle?: TextStyle;\r\n disabled?: boolean;\r\n}\r\n\r\n// ----- DownloadFile Props -----\r\nexport interface DownloadFileProps {\r\n files: string[];\r\n multipleDownload?: boolean; // multipleFiles yerine multipleDownload (İsim karışmaması için)\r\n disabled?: boolean;\r\n debug?: boolean;\r\n maxSize?: number; // MB\r\n fileTypes?: string[]; // İndirilecek dosyanın Content-Type kontrolü\r\n buttonPlaceHolder?: string;\r\n buttonIcon?: React.ReactNode;\r\n ButtonStyle?: ViewStyle;\r\n ButtonTextStyle?: TextStyle;\r\n onSuccess?: (result: DownloadResult) => void;\r\n onError?: (error: any) => void;\r\n}\r\n\r\n\r\nexport interface DownloadResult {\r\n successful: { originalUrl: string; localUri: string | null }[];\r\n skipped: { originalUrl: string; reason: string }[];\r\n}\r\n\r\n\r\n///rotateImage\r\n\r\nexport interface RotateImageProps{\r\n base64: string, angle: number\r\n}"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["// import type { StyleProp, TextStyle, ViewStyle } from 'react-native';\r\n\r\n// export interface FileInfo {\r\n// fileName: string;\r\n// fileSize: number; \r\n// fileType: string | null;\r\n// fileUri: string;\r\n// base64: string;\r\n// }\r\n\r\n// export interface MyUploaderProps{\r\n// onSelect: (files: FileInfo[]) => void;\r\n// onError?: (error: Error) => void;\r\n// buttonPlaceHolder?: string;\r\n// ButtonStyle?: StyleProp<ViewStyle>;\r\n// ButtonTextStyle?: StyleProp<TextStyle>;\r\n// disabled?: boolean; \r\n// multipleFiles?: boolean;\r\n// fileTypes?: string[];\r\n// maxSize?: number;\r\n// maxFiles?: number;\r\n// excludedUris?: string[];\r\n// }\r\n\r\n// export interface DownloadedFileInfo {\r\n// originalUrl: string;\r\n// localUri: string;\r\n// }\r\n\r\n// export interface SkippedFileInfo {\r\n// originalUrl: string;\r\n// reason: string; \r\n// }\r\n\r\n\r\n\r\n// export interface UploadFileProps {\r\n// files: string[];\r\n// multipleLoad?: boolean;\r\n// disabled?: boolean;\r\n// debug?: boolean; \r\n// maxSize?: number;\r\n// fileTypes?: string[];\r\n// buttonPlaceHolder?: string;\r\n// buttonIcon?: React.ReactNode;\r\n// ButtonStyle?: StyleProp<ViewStyle>;\r\n// ButtonTextStyle?: StyleProp<TextStyle>;\r\n// onSuccess?: (result: DownloadResult) => void;\r\n// onError?: (error: Error) => void;\r\n// }\r\n\r\n// export interface DownloadFileProps {\r\n// files: string[];\r\n// multipleDownload?: boolean;\r\n// disabled?: boolean;\r\n// debug?: boolean;\r\n// maxSize?: number; // MB\r\n// fileTypes?: string[];\r\n// buttonPlaceHolder?: string;\r\n// buttonIcon?: React.ReactNode;\r\n// ButtonStyle?: ViewStyle;\r\n// ButtonTextStyle?: TextStyle;\r\n// onSuccess?: (result: DownloadResult) => void;\r\n// onError?: (error: any) => void;\r\n// }\r\n// export interface DownloadResult {\r\n// successful: { originalUrl: string; localUri: string | null }[];\r\n// skipped: { originalUrl: string; reason: string }[];\r\n// }\r\n\r\n\r\nimport type { ViewStyle, TextStyle } from 'react-native';\r\n\r\nexport interface FileInfo {\r\n fileUri: string;\r\n fileName: string;\r\n fileType: string;\r\n fileSize: number;\r\n base64?: string | null;\r\n}\r\n\r\n\r\n// ----- MyUploader & pickFile Props -----\r\nexport interface DocumentPickerOptions {\r\n multipleFiles?: boolean;\r\n fileTypes?: string[]; // örn: ['image/*', 'application/pdf']\r\n maxSize?: number; // MB cinsinden\r\n maxFiles?: number;\r\n excludedUris?: string[];\r\n isGallery?:boolean;\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}\r\n\r\n\r\n///rotateImage\r\n\r\nexport interface RotateImageProps{\r\n base64: string, angle: number\r\n}"],"mappings":"","ignoreList":[]}
|
|
@@ -6,7 +6,7 @@ const {
|
|
|
6
6
|
|
|
7
7
|
// 1. Standalone pickFile Fonksiyonu
|
|
8
8
|
export const pickFile = async (options = {}) => {
|
|
9
|
-
var _options$multipleFile, _options$maxFiles, _options$maxSize, _options$fileTypes, _options$excludedUris;
|
|
9
|
+
var _options$multipleFile, _options$maxFiles, _options$maxSize, _options$fileTypes, _options$excludedUris, _options$isGallery;
|
|
10
10
|
if (!NativeUploadPicker) throw new Error("DocumentPicker module is not linked.");
|
|
11
11
|
|
|
12
12
|
// Native tarafa gönderilecek options
|
|
@@ -15,10 +15,21 @@ export const pickFile = async (options = {}) => {
|
|
|
15
15
|
maxFiles: (_options$maxFiles = options.maxFiles) !== null && _options$maxFiles !== void 0 ? _options$maxFiles : 0,
|
|
16
16
|
maxSize: (_options$maxSize = options.maxSize) !== null && _options$maxSize !== void 0 ? _options$maxSize : 0,
|
|
17
17
|
fileTypes: (_options$fileTypes = options.fileTypes) !== null && _options$fileTypes !== void 0 ? _options$fileTypes : ['*/*'],
|
|
18
|
-
excludedUris: (_options$excludedUris = options.excludedUris) !== null && _options$excludedUris !== void 0 ? _options$excludedUris : []
|
|
18
|
+
excludedUris: (_options$excludedUris = options.excludedUris) !== null && _options$excludedUris !== void 0 ? _options$excludedUris : [],
|
|
19
|
+
isGallery: (_options$isGallery = options.isGallery) !== null && _options$isGallery !== void 0 ? _options$isGallery : false
|
|
19
20
|
};
|
|
20
21
|
return await NativeUploadPicker.openDocument(nativeOptions);
|
|
21
22
|
};
|
|
23
|
+
export const getBase64FromUri = async cropFileUri => {
|
|
24
|
+
if (!NativeUploadPicker) {
|
|
25
|
+
throw new Error("UploadDocumentPicker modülü linklenmemiş.");
|
|
26
|
+
}
|
|
27
|
+
try {
|
|
28
|
+
return await NativeUploadPicker.getBase64FromUri(cropFileUri);
|
|
29
|
+
} catch (error) {
|
|
30
|
+
throw new Error(`getBase64FromUri Hatası: ${error.message}`);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
22
33
|
export const RotateImage = async ({
|
|
23
34
|
base64,
|
|
24
35
|
angle
|
|
@@ -1 +1 @@
|
|
|
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","
|
|
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","_options$isGallery","Error","nativeOptions","multipleFiles","maxFiles","maxSize","fileTypes","excludedUris","isGallery","openDocument","getBase64FromUri","cropFileUri","error","message","RotateImage","base64","angle","rotatedBase64","rotateImage","MyUploader","onSelect","onError","buttonPlaceHolder","ButtonStyle","ButtonTextStyle","disabled","isLoading","setIsLoading","handlePress","files","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, RotateImageProps } 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 isGallery:options.isGallery ?? false,\r\n };\r\n\r\n return await NativeUploadPicker.openDocument(nativeOptions);\r\n};\r\n\r\nexport const getBase64FromUri = async (cropFileUri: string): Promise<string> => {\r\n if (!NativeUploadPicker) {\r\n throw new Error(\"UploadDocumentPicker modülü linklenmemiş.\");\r\n }\r\n\r\n try {\r\n return await NativeUploadPicker.getBase64FromUri(cropFileUri);\r\n } catch (error: any) {\r\n throw new Error(`getBase64FromUri Hatası: ${error.message}`);\r\n }\r\n};\r\n\r\n\r\n\r\nexport const RotateImage = async ({ base64, angle }: RotateImageProps): Promise<string> => {\r\n if (!NativeUploadPicker) {\r\n throw new Error(\"UploadDocumentPicker modülü linklenmemiş.\");\r\n }\r\n\r\n try {\r\n // Native sadece saf base64 string'i döner\r\n const rotatedBase64: string = await NativeUploadPicker.rotateImage(base64, angle);\r\n\r\n // Uygulama tarafında doğrudan <Image /> içinde kullanılabilmesi için prefix eklenir\r\n return `data:image/jpeg;base64,${rotatedBase64}`;\r\n } catch (error: any) {\r\n // Hata mesajını daha okunaklı fırlatıyoruz\r\n throw new Error(`RotateImage Hatası: ${error.message}`);\r\n }\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,EAAEC,aAAa,QAAQ,cAAc;AAGnG,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,EAAAC,kBAAA;EAC1F,IAAI,CAACR,kBAAkB,EAAE,MAAM,IAAIS,KAAK,CAAC,sCAAsC,CAAC;;EAEhF;EACA,MAAMC,aAAa,GAAG;IACpBC,aAAa,GAAAR,qBAAA,GAAED,OAAO,CAACS,aAAa,cAAAR,qBAAA,cAAAA,qBAAA,GAAI,KAAK;IAC7CS,QAAQ,GAAAR,iBAAA,GAAEF,OAAO,CAACU,QAAQ,cAAAR,iBAAA,cAAAA,iBAAA,GAAI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;IAAC+C,KAAK,EAAC;EAAM,CAAE,CAAC,gBAElCpD,KAAA,CAAA+C,aAAA,CAAC5C,IAAI;IAAC6C,KAAK,EAAE,CAACC,MAAM,CAACI,IAAI,EAAEb,eAAe;EAAE,GAAEF,iBAAwB,CAExD,CAAC;AAEvB,CAAC;AAED,MAAMW,MAAM,GAAG7C,UAAU,CAACkD,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;EACDpB,QAAQ,EAAE;IACRc,eAAe,EAAE;EACnB;AACF,CAAC,CAAC;AAEF,eAAepB,UAAU","ignoreList":[]}
|
package/lib/module/index.d.js
CHANGED
|
@@ -5,8 +5,6 @@ export * from './types';
|
|
|
5
5
|
// DownloadFile Component Tanımı (3. Bunu ekledik)
|
|
6
6
|
// export declare const DownloadFile: React.FC<DownloadFileProps>;
|
|
7
7
|
|
|
8
|
-
// pickFile Fonksiyon Tanımı
|
|
9
|
-
|
|
10
8
|
// Varsayılan dışa aktarım (İsteğe bağlı, genellikle ana bileşen verilir)
|
|
11
9
|
export {};
|
|
12
10
|
//# sourceMappingURL=index.d.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.d.ts"],"sourcesContent":["import * as React from 'react';\r\nimport type { DocumentPickerOptions, MyUploaderProps, FileInfo, DownloadFileProps ,RotateImageProps } 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
|
|
1
|
+
{"version":3,"names":[],"sources":["index.d.ts"],"sourcesContent":["import * as React from 'react';\r\nimport type { DocumentPickerOptions, MyUploaderProps, FileInfo, DownloadFileProps ,RotateImageProps } 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\r\nexport declare function pickFile(options?: DocumentPickerOptions): Promise<FileInfo[]>;\r\nexport declare function RotateImage(props:RotateImageProps):Promise<string>;\r\nexport declare function getBase64FromUri(cropFileUri: string): Promise<string>;\r\n\r\nexport declare const DownloadFile :React.FC<DownloadFileProps>;\r\nexport declare const MyUploader: React.FC<MyUploaderProps>;\r\n\r\n// Varsayılan dışa aktarım (İsteğe bağlı, genellikle ana bileşen verilir)\r\ndeclare const _default: React.FC<MyUploaderProps>;\r\nexport default _default;"],"mappings":"AAEA;;AAEA,cAAc,SAAS;;AAEvB;AACA;;AAUA;AAAA","ignoreList":[]}
|
package/lib/module/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import MyUploader, { pickFile, RotateImage } from "./components/MyUploader";
|
|
1
|
+
import MyUploader, { pickFile, RotateImage, getBase64FromUri } from "./components/MyUploader";
|
|
2
2
|
import { DownloadFile } from "./components/DownloadFile";
|
|
3
3
|
|
|
4
4
|
// Sadece bu paketle ilgili olanları dışa aktar
|
|
5
|
-
export { MyUploader, pickFile, DownloadFile, RotateImage };
|
|
5
|
+
export { MyUploader, pickFile, DownloadFile, RotateImage, getBase64FromUri };
|
|
6
6
|
export * from './types';
|
|
7
7
|
|
|
8
8
|
// Varsayılan dışa aktarım olarak da ana bileşeni verelim
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["MyUploader","pickFile","RotateImage","DownloadFile"],"sources":["index.ts"],"sourcesContent":["import MyUploader,{pickFile,RotateImage} from \"./components/MyUploader\";\r\nimport {DownloadFile} from \"./components/DownloadFile\";\r\n\r\n\r\n// Sadece bu paketle ilgili olanları dışa aktar\r\nexport { MyUploader, pickFile ,DownloadFile ,RotateImage };\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,EAACC,WAAW,QAAO,yBAAyB;
|
|
1
|
+
{"version":3,"names":["MyUploader","pickFile","RotateImage","getBase64FromUri","DownloadFile"],"sources":["index.ts"],"sourcesContent":["import MyUploader,{pickFile,RotateImage,getBase64FromUri} from \"./components/MyUploader\";\r\nimport {DownloadFile} from \"./components/DownloadFile\";\r\n\r\n\r\n// Sadece bu paketle ilgili olanları dışa aktar\r\nexport { MyUploader, pickFile ,DownloadFile ,RotateImage,getBase64FromUri };\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,EAACC,WAAW,EAACC,gBAAgB,QAAO,yBAAyB;AACxF,SAAQC,YAAY,QAAO,2BAA2B;;AAGtD;AACA,SAASJ,UAAU,EAAEC,QAAQ,EAAEG,YAAY,EAAEF,WAAW,EAACC,gBAAgB;AACzE,cAAc,SAAS;;AAEvB;AACA,eAAeH,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 fileUri: string;\r\n fileName: string;\r\n fileType: string;\r\n fileSize: number;\r\n base64?: string | null;\r\n}\r\n\r\n\r\n// ----- MyUploader & pickFile Props -----\r\nexport interface DocumentPickerOptions {\r\n multipleFiles?: boolean;\r\n fileTypes?: string[]; // örn: ['image/*', 'application/pdf']\r\n maxSize?: number; // MB cinsinden\r\n maxFiles?: number;\r\n excludedUris?: string[];\r\n}\r\n\r\nexport interface MyUploaderProps extends DocumentPickerOptions {\r\n onSelect: (files: FileInfo[]) => void;\r\n onError?: (error: Error) => void;\r\n buttonPlaceHolder?: string;\r\n ButtonStyle?: ViewStyle;\r\n ButtonTextStyle?: TextStyle;\r\n disabled?: boolean;\r\n}\r\n\r\n// ----- DownloadFile Props -----\r\nexport interface DownloadFileProps {\r\n files: string[];\r\n multipleDownload?: boolean; // multipleFiles yerine multipleDownload (İsim karışmaması için)\r\n disabled?: boolean;\r\n debug?: boolean;\r\n maxSize?: number; // MB\r\n fileTypes?: string[]; // İndirilecek dosyanın Content-Type kontrolü\r\n buttonPlaceHolder?: string;\r\n buttonIcon?: React.ReactNode;\r\n ButtonStyle?: ViewStyle;\r\n ButtonTextStyle?: TextStyle;\r\n onSuccess?: (result: DownloadResult) => void;\r\n onError?: (error: any) => void;\r\n}\r\n\r\n\r\nexport interface DownloadResult {\r\n successful: { originalUrl: string; localUri: string | null }[];\r\n skipped: { originalUrl: string; reason: string }[];\r\n}\r\n\r\n\r\n///rotateImage\r\n\r\nexport interface RotateImageProps{\r\n base64: string, angle: number\r\n}"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["// import type { StyleProp, TextStyle, ViewStyle } from 'react-native';\r\n\r\n// export interface FileInfo {\r\n// fileName: string;\r\n// fileSize: number; \r\n// fileType: string | null;\r\n// fileUri: string;\r\n// base64: string;\r\n// }\r\n\r\n// export interface MyUploaderProps{\r\n// onSelect: (files: FileInfo[]) => void;\r\n// onError?: (error: Error) => void;\r\n// buttonPlaceHolder?: string;\r\n// ButtonStyle?: StyleProp<ViewStyle>;\r\n// ButtonTextStyle?: StyleProp<TextStyle>;\r\n// disabled?: boolean; \r\n// multipleFiles?: boolean;\r\n// fileTypes?: string[];\r\n// maxSize?: number;\r\n// maxFiles?: number;\r\n// excludedUris?: string[];\r\n// }\r\n\r\n// export interface DownloadedFileInfo {\r\n// originalUrl: string;\r\n// localUri: string;\r\n// }\r\n\r\n// export interface SkippedFileInfo {\r\n// originalUrl: string;\r\n// reason: string; \r\n// }\r\n\r\n\r\n\r\n// export interface UploadFileProps {\r\n// files: string[];\r\n// multipleLoad?: boolean;\r\n// disabled?: boolean;\r\n// debug?: boolean; \r\n// maxSize?: number;\r\n// fileTypes?: string[];\r\n// buttonPlaceHolder?: string;\r\n// buttonIcon?: React.ReactNode;\r\n// ButtonStyle?: StyleProp<ViewStyle>;\r\n// ButtonTextStyle?: StyleProp<TextStyle>;\r\n// onSuccess?: (result: DownloadResult) => void;\r\n// onError?: (error: Error) => void;\r\n// }\r\n\r\n// export interface DownloadFileProps {\r\n// files: string[];\r\n// multipleDownload?: boolean;\r\n// disabled?: boolean;\r\n// debug?: boolean;\r\n// maxSize?: number; // MB\r\n// fileTypes?: string[];\r\n// buttonPlaceHolder?: string;\r\n// buttonIcon?: React.ReactNode;\r\n// ButtonStyle?: ViewStyle;\r\n// ButtonTextStyle?: TextStyle;\r\n// onSuccess?: (result: DownloadResult) => void;\r\n// onError?: (error: any) => void;\r\n// }\r\n// export interface DownloadResult {\r\n// successful: { originalUrl: string; localUri: string | null }[];\r\n// skipped: { originalUrl: string; reason: string }[];\r\n// }\r\n\r\n\r\nimport type { ViewStyle, TextStyle } from 'react-native';\r\n\r\nexport interface FileInfo {\r\n fileUri: string;\r\n fileName: string;\r\n fileType: string;\r\n fileSize: number;\r\n base64?: string | null;\r\n}\r\n\r\n\r\n// ----- MyUploader & pickFile Props -----\r\nexport interface DocumentPickerOptions {\r\n multipleFiles?: boolean;\r\n fileTypes?: string[]; // örn: ['image/*', 'application/pdf']\r\n maxSize?: number; // MB cinsinden\r\n maxFiles?: number;\r\n excludedUris?: string[];\r\n isGallery?:boolean;\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}\r\n\r\n\r\n///rotateImage\r\n\r\nexport interface RotateImageProps{\r\n base64: string, angle: number\r\n}"],"mappings":"","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -15,11 +15,26 @@ export const pickFile = async (options: DocumentPickerOptions = {}): Promise<Fil
|
|
|
15
15
|
maxSize: options.maxSize ?? 0,
|
|
16
16
|
fileTypes: options.fileTypes ?? ['*/*'],
|
|
17
17
|
excludedUris: options.excludedUris ?? [],
|
|
18
|
+
isGallery:options.isGallery ?? false,
|
|
18
19
|
};
|
|
19
20
|
|
|
20
21
|
return await NativeUploadPicker.openDocument(nativeOptions);
|
|
21
22
|
};
|
|
22
23
|
|
|
24
|
+
export const getBase64FromUri = async (cropFileUri: string): Promise<string> => {
|
|
25
|
+
if (!NativeUploadPicker) {
|
|
26
|
+
throw new Error("UploadDocumentPicker modülü linklenmemiş.");
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
try {
|
|
30
|
+
return await NativeUploadPicker.getBase64FromUri(cropFileUri);
|
|
31
|
+
} catch (error: any) {
|
|
32
|
+
throw new Error(`getBase64FromUri Hatası: ${error.message}`);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
23
38
|
export const RotateImage = async ({ base64, angle }: RotateImageProps): Promise<string> => {
|
|
24
39
|
if (!NativeUploadPicker) {
|
|
25
40
|
throw new Error("UploadDocumentPicker modülü linklenmemiş.");
|
package/src/index.d.ts
CHANGED
|
@@ -7,9 +7,11 @@ export * from './types';
|
|
|
7
7
|
// DownloadFile Component Tanımı (3. Bunu ekledik)
|
|
8
8
|
// export declare const DownloadFile: React.FC<DownloadFileProps>;
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
|
|
11
11
|
export declare function pickFile(options?: DocumentPickerOptions): Promise<FileInfo[]>;
|
|
12
12
|
export declare function RotateImage(props:RotateImageProps):Promise<string>;
|
|
13
|
+
export declare function getBase64FromUri(cropFileUri: string): Promise<string>;
|
|
14
|
+
|
|
13
15
|
export declare const DownloadFile :React.FC<DownloadFileProps>;
|
|
14
16
|
export declare const MyUploader: React.FC<MyUploaderProps>;
|
|
15
17
|
|
package/src/index.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import MyUploader,{pickFile,RotateImage} from "./components/MyUploader";
|
|
1
|
+
import MyUploader,{pickFile,RotateImage,getBase64FromUri} from "./components/MyUploader";
|
|
2
2
|
import {DownloadFile} from "./components/DownloadFile";
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
// Sadece bu paketle ilgili olanları dışa aktar
|
|
6
|
-
export { MyUploader, pickFile ,DownloadFile ,RotateImage };
|
|
6
|
+
export { MyUploader, pickFile ,DownloadFile ,RotateImage,getBase64FromUri };
|
|
7
7
|
export * from './types';
|
|
8
8
|
|
|
9
9
|
// Varsayılan dışa aktarım olarak da ana bileşeni verelim
|