react-native-my-uploader-android 1.0.28 → 1.0.30
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/DownloadFileModule.kt +91 -58
- package/android/src/main/java/com/myuploaderandroid/MyUploaderModule.kt +93 -42
- package/lib/commonjs/components/DownloadFile.js +37 -47
- package/lib/commonjs/components/DownloadFile.js.map +1 -1
- package/lib/commonjs/components/MyUploader.js +57 -80
- package/lib/commonjs/components/MyUploader.js.map +1 -1
- package/lib/commonjs/index.d.js.map +1 -1
- package/lib/commonjs/index.js +9 -7
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/module/components/DownloadFile.js +38 -48
- package/lib/module/components/DownloadFile.js.map +1 -1
- package/lib/module/components/MyUploader.js +55 -79
- package/lib/module/components/MyUploader.js.map +1 -1
- package/lib/module/index.d.js +10 -0
- package/lib/module/index.d.js.map +1 -1
- package/lib/module/index.js +10 -6
- 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 +40 -61
- package/src/components/MyUploader.tsx +59 -89
- package/src/index.d.ts +12 -5
- package/src/index.ts +12 -6
- package/src/types.ts +98 -41
- package/android/src/main/java/com/myuploader/MyUploaderModule.kt +0 -173
- package/android/src/main/java/com/myuploader/MyUploaderPackage.kt +0 -16
- package/lib/commonjs/NativeMyUploader.js +0 -15
- package/lib/commonjs/NativeMyUploader.js.map +0 -1
- package/lib/module/NativeMyUploader.js +0 -9
- package/lib/module/NativeMyUploader.js.map +0 -1
- package/src/NativeMyUploader.ts +0 -25
package/src/index.d.ts
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { DocumentPickerOptions, MyUploaderProps, FileInfo } from './types';
|
|
3
|
+
// import type { DownloadFileProps } from './types';
|
|
3
4
|
|
|
4
5
|
export * from './types';
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
export
|
|
7
|
+
// DownloadFile Component Tanımı (3. Bunu ekledik)
|
|
8
|
+
// export declare const DownloadFile: React.FC<DownloadFileProps>;
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
export function pickFile(options?: DocumentPickerOptions): Promise<FileInfo[]>;
|
|
10
|
+
// pickFile Fonksiyon Tanımı
|
|
11
|
+
export declare function pickFile(options?: DocumentPickerOptions): Promise<FileInfo[]>;
|
|
12
|
+
|
|
13
|
+
export declare const MyUploader: React.FC<MyUploaderProps>;
|
|
14
|
+
|
|
15
|
+
// Varsayılan dışa aktarım (İsteğe bağlı, genellikle ana bileşen verilir)
|
|
16
|
+
declare const _default: React.FC<MyUploaderProps>;
|
|
17
|
+
export default _default;
|
package/src/index.ts
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import { pickFile } from './components/MyUploader';
|
|
1
|
+
import MyUploader,{pickFile} from "./components/MyUploader";
|
|
2
|
+
// import DownloadFile from "./components/DownloadFile";
|
|
4
3
|
|
|
5
|
-
//
|
|
6
|
-
export {
|
|
4
|
+
// 2. Diğerlerini NAMED olarak dışa aktar (import { DownloadFile, pickFile } ... için)
|
|
5
|
+
// export { DownloadFile, pickFile };
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
// Sadece bu paketle ilgili olanları dışa aktar
|
|
9
|
+
export { MyUploader, pickFile };
|
|
7
10
|
export * from './types';
|
|
8
|
-
|
|
11
|
+
|
|
12
|
+
// Varsayılan dışa aktarım olarak da ana bileşeni verelim
|
|
13
|
+
export default MyUploader;
|
|
14
|
+
|
|
9
15
|
|
|
10
16
|
|
package/src/types.ts
CHANGED
|
@@ -1,64 +1,121 @@
|
|
|
1
|
-
import type { StyleProp, TextStyle, ViewStyle } from 'react-native';
|
|
1
|
+
// import type { StyleProp, TextStyle, ViewStyle } from 'react-native';
|
|
2
|
+
|
|
3
|
+
// export interface FileInfo {
|
|
4
|
+
// fileName: string;
|
|
5
|
+
// fileSize: number;
|
|
6
|
+
// fileType: string | null;
|
|
7
|
+
// fileUri: string;
|
|
8
|
+
// base64: string;
|
|
9
|
+
// }
|
|
10
|
+
|
|
11
|
+
// export interface MyUploaderProps{
|
|
12
|
+
// onSelect: (files: FileInfo[]) => void;
|
|
13
|
+
// onError?: (error: Error) => void;
|
|
14
|
+
// buttonPlaceHolder?: string;
|
|
15
|
+
// ButtonStyle?: StyleProp<ViewStyle>;
|
|
16
|
+
// ButtonTextStyle?: StyleProp<TextStyle>;
|
|
17
|
+
// disabled?: boolean;
|
|
18
|
+
// multipleFiles?: boolean;
|
|
19
|
+
// fileTypes?: string[];
|
|
20
|
+
// maxSize?: number;
|
|
21
|
+
// maxFiles?: number;
|
|
22
|
+
// excludedUris?: string[];
|
|
23
|
+
// }
|
|
24
|
+
|
|
25
|
+
// export interface DownloadedFileInfo {
|
|
26
|
+
// originalUrl: string;
|
|
27
|
+
// localUri: string;
|
|
28
|
+
// }
|
|
29
|
+
|
|
30
|
+
// export interface SkippedFileInfo {
|
|
31
|
+
// originalUrl: string;
|
|
32
|
+
// reason: string;
|
|
33
|
+
// }
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
// export interface UploadFileProps {
|
|
38
|
+
// files: string[];
|
|
39
|
+
// multipleLoad?: boolean;
|
|
40
|
+
// disabled?: boolean;
|
|
41
|
+
// debug?: boolean;
|
|
42
|
+
// maxSize?: number;
|
|
43
|
+
// fileTypes?: string[];
|
|
44
|
+
// buttonPlaceHolder?: string;
|
|
45
|
+
// buttonIcon?: React.ReactNode;
|
|
46
|
+
// ButtonStyle?: StyleProp<ViewStyle>;
|
|
47
|
+
// ButtonTextStyle?: StyleProp<TextStyle>;
|
|
48
|
+
// onSuccess?: (result: DownloadResult) => void;
|
|
49
|
+
// onError?: (error: Error) => void;
|
|
50
|
+
// }
|
|
51
|
+
|
|
52
|
+
// export interface DownloadFileProps {
|
|
53
|
+
// files: string[];
|
|
54
|
+
// multipleDownload?: boolean;
|
|
55
|
+
// disabled?: boolean;
|
|
56
|
+
// debug?: boolean;
|
|
57
|
+
// maxSize?: number; // MB
|
|
58
|
+
// fileTypes?: string[];
|
|
59
|
+
// buttonPlaceHolder?: string;
|
|
60
|
+
// buttonIcon?: React.ReactNode;
|
|
61
|
+
// ButtonStyle?: ViewStyle;
|
|
62
|
+
// ButtonTextStyle?: TextStyle;
|
|
63
|
+
// onSuccess?: (result: DownloadResult) => void;
|
|
64
|
+
// onError?: (error: any) => void;
|
|
65
|
+
// }
|
|
66
|
+
// export interface DownloadResult {
|
|
67
|
+
// successful: { originalUrl: string; localUri: string | null }[];
|
|
68
|
+
// skipped: { originalUrl: string; reason: string }[];
|
|
69
|
+
// }
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
import type { ViewStyle, TextStyle } from 'react-native';
|
|
2
73
|
|
|
3
74
|
export interface FileInfo {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
base64
|
|
75
|
+
uri: string;
|
|
76
|
+
name: string;
|
|
77
|
+
type: string;
|
|
78
|
+
size: number;
|
|
79
|
+
base64?: string | null;
|
|
9
80
|
}
|
|
10
81
|
|
|
82
|
+
|
|
83
|
+
// ----- MyUploader & pickFile Props -----
|
|
11
84
|
export interface DocumentPickerOptions {
|
|
12
85
|
multipleFiles?: boolean;
|
|
13
|
-
fileTypes?: string[];
|
|
14
|
-
maxSize?: number;
|
|
86
|
+
fileTypes?: string[]; // örn: ['image/*', 'application/pdf']
|
|
87
|
+
maxSize?: number; // MB cinsinden
|
|
15
88
|
maxFiles?: number;
|
|
16
89
|
excludedUris?: string[];
|
|
17
90
|
}
|
|
91
|
+
|
|
18
92
|
export interface MyUploaderProps extends DocumentPickerOptions {
|
|
19
|
-
// Geri bildirim (callback) fonksiyonları
|
|
20
93
|
onSelect: (files: FileInfo[]) => void;
|
|
21
94
|
onError?: (error: Error) => void;
|
|
22
95
|
buttonPlaceHolder?: string;
|
|
23
|
-
ButtonStyle?:
|
|
24
|
-
ButtonTextStyle?:
|
|
96
|
+
ButtonStyle?: ViewStyle;
|
|
97
|
+
ButtonTextStyle?: TextStyle;
|
|
25
98
|
disabled?: boolean;
|
|
26
99
|
}
|
|
27
100
|
|
|
28
|
-
//
|
|
29
|
-
export interface DownloadedFileInfo {
|
|
30
|
-
originalUrl: string;
|
|
31
|
-
localUri: string; // Cihazdaki dosyanın URI'si
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// YENİ: Atlanan dosyalar hakkında bilgi vermek için arayüz
|
|
35
|
-
export interface SkippedFileInfo {
|
|
36
|
-
originalUrl: string;
|
|
37
|
-
reason: string; // Neden atlandığı (örn: "Dosya çok büyük")
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// YENİ: onSUCCESS callback'inin döndüreceği sonuç nesnesi
|
|
41
|
-
export interface DownloadResult {
|
|
42
|
-
successful: DownloadedFileInfo[];
|
|
43
|
-
skipped: SkippedFileInfo[];
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// GÜNCELLENDİ: DownloadFileProps arayüzü
|
|
101
|
+
// ----- DownloadFile Props -----
|
|
47
102
|
export interface DownloadFileProps {
|
|
48
103
|
files: string[];
|
|
49
|
-
//
|
|
50
|
-
multipleLoad?: boolean;
|
|
104
|
+
multipleDownload?: boolean; // multipleFiles yerine multipleDownload (İsim karışmaması için)
|
|
51
105
|
disabled?: boolean;
|
|
52
|
-
debug?: boolean;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
fileTypes?: string[];
|
|
106
|
+
debug?: boolean;
|
|
107
|
+
maxSize?: number; // MB
|
|
108
|
+
fileTypes?: string[]; // İndirilecek dosyanın Content-Type kontrolü
|
|
56
109
|
buttonPlaceHolder?: string;
|
|
57
110
|
buttonIcon?: React.ReactNode;
|
|
58
|
-
ButtonStyle?:
|
|
59
|
-
ButtonTextStyle?:
|
|
60
|
-
|
|
61
|
-
// GÜNCELLENDİ: Callback daha zengin bir nesne döndürecek
|
|
111
|
+
ButtonStyle?: ViewStyle;
|
|
112
|
+
ButtonTextStyle?: TextStyle;
|
|
62
113
|
onSuccess?: (result: DownloadResult) => void;
|
|
63
|
-
onError?: (error:
|
|
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 }[];
|
|
64
121
|
}
|
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
package com.myuploader
|
|
2
|
-
|
|
3
|
-
import android.app.Activity
|
|
4
|
-
import android.content.Intent
|
|
5
|
-
import android.net.Uri
|
|
6
|
-
import android.provider.OpenableColumns
|
|
7
|
-
import android.util.Base64
|
|
8
|
-
import com.facebook.react.bridge.*
|
|
9
|
-
import java.io.ByteArrayOutputStream
|
|
10
|
-
import java.net.URLConnection
|
|
11
|
-
|
|
12
|
-
class MyUploaderModule(private val reactContext: ReactApplicationContext) :
|
|
13
|
-
ReactContextBaseJavaModule(reactContext), ActivityEventListener {
|
|
14
|
-
|
|
15
|
-
private var pickerPromise: Promise? = null
|
|
16
|
-
private var maxSize: Double = 0.0
|
|
17
|
-
private var maxFiles: Int = 0
|
|
18
|
-
private var excludedUris: List<String> = emptyList()
|
|
19
|
-
|
|
20
|
-
init {
|
|
21
|
-
reactContext.addActivityEventListener(this)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
override fun getName(): String = "DocumentPicker"
|
|
25
|
-
|
|
26
|
-
companion object {
|
|
27
|
-
private const val REQUEST_CODE = 9900
|
|
28
|
-
private const val E_ACTIVITY_DOES_NOT_EXIST = "E_ACTIVITY_DOES_NOT_EXIST"
|
|
29
|
-
private const val E_PICKER_CANCELLED = "E_PICKER_CANCELLED"
|
|
30
|
-
private const val E_FAILED_TO_OPEN_DOCUMENT = "E_FAILED_TO_OPEN_DOCUMENT"
|
|
31
|
-
private const val E_FILE_TOO_LARGE = "E_FILE_TOO_LARGE"
|
|
32
|
-
private const val E_MAX_FILES_EXCEEDED = "E_MAX_FILES_EXCEEDED"
|
|
33
|
-
private const val E_INVALID_OPTIONS = "E_INVALID_OPTIONS"
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
@ReactMethod
|
|
37
|
-
fun openDocument(options: ReadableMap, promise: Promise) {
|
|
38
|
-
if (pickerPromise != null) {
|
|
39
|
-
promise.reject(E_FAILED_TO_OPEN_DOCUMENT, "Başka bir dosya seçme işlemi zaten devam ediyor.")
|
|
40
|
-
return
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
this.pickerPromise = promise
|
|
44
|
-
|
|
45
|
-
val multipleFiles = options.takeIf { it.hasKey("multipleFiles") }?.getBoolean("multipleFiles") ?: false
|
|
46
|
-
val jsMaxFiles = options.takeIf { it.hasKey("maxFiles") }?.getInt("maxFiles") ?: 0
|
|
47
|
-
|
|
48
|
-
// KURAL KONTROLÜ (NATIVE): JS tarafındaki kontrolü burada da yaparak güvenliği artır.
|
|
49
|
-
if (!multipleFiles && jsMaxFiles > 1) {
|
|
50
|
-
promise.reject(E_INVALID_OPTIONS, "`maxFiles` değeri, `multipleFiles` false iken 1'den büyük olamaz.")
|
|
51
|
-
return
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// KURAL UYGULAMA (NATIVE): `maxFiles` için nihai değeri hesapla.
|
|
55
|
-
val effectiveMaxFiles = when {
|
|
56
|
-
multipleFiles && jsMaxFiles == 0 -> 3 // Varsayılan: 3
|
|
57
|
-
!multipleFiles -> 1 // Tekli seçimde her zaman 1
|
|
58
|
-
else -> jsMaxFiles // Belirtilen değeri kullan
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// Değerleri sınıf değişkenlerine ata
|
|
62
|
-
this.maxFiles = effectiveMaxFiles
|
|
63
|
-
this.maxSize = options.takeIf { it.hasKey("maxSize") }?.getDouble("maxSize") ?: 0.0
|
|
64
|
-
this.excludedUris = options.takeIf { it.hasKey("excludedUris") }
|
|
65
|
-
?.getArray("excludedUris")?.toArrayList()?.mapNotNull { it.toString() } ?: emptyList()
|
|
66
|
-
|
|
67
|
-
val currentActivity = reactContext.currentActivity
|
|
68
|
-
if (currentActivity == null) {
|
|
69
|
-
pickerPromise?.reject(E_ACTIVITY_DOES_NOT_EXIST, "Activity mevcut değil.")
|
|
70
|
-
pickerPromise = null
|
|
71
|
-
return
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
val fileTypes = options.takeIf { it.hasKey("fileTypes") }
|
|
75
|
-
?.getArray("fileTypes")?.toArrayList()?.mapNotNull { it.toString() } ?: listOf("*/*")
|
|
76
|
-
val mimeTypes = if (fileTypes.isEmpty()) arrayOf("*/*") else fileTypes.toTypedArray()
|
|
77
|
-
|
|
78
|
-
try {
|
|
79
|
-
// ANAHTAR: ACTION_GET_CONTENT, güvenilir çoklu seçimi etkinleştirir.
|
|
80
|
-
val intent = Intent(Intent.ACTION_GET_CONTENT).apply {
|
|
81
|
-
type = "*/*"
|
|
82
|
-
addCategory(Intent.CATEGORY_OPENABLE)
|
|
83
|
-
putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes)
|
|
84
|
-
|
|
85
|
-
if (multipleFiles) {
|
|
86
|
-
putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true)
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
currentActivity.startActivityForResult(Intent.createChooser(intent, "Dosya Seçin"), REQUEST_CODE)
|
|
90
|
-
} catch (e: Exception) {
|
|
91
|
-
pickerPromise?.reject(E_FAILED_TO_OPEN_DOCUMENT, e)
|
|
92
|
-
pickerPromise = null
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
override fun onActivityResult(activity: Activity, requestCode: Int, resultCode: Int, data: Intent?) {
|
|
97
|
-
if (requestCode != REQUEST_CODE || pickerPromise == null) { return }
|
|
98
|
-
|
|
99
|
-
if (resultCode == Activity.RESULT_OK && data != null) {
|
|
100
|
-
val allSelectedUris = mutableListOf<Uri>()
|
|
101
|
-
data.clipData?.let { clip ->
|
|
102
|
-
for (i in 0 until clip.itemCount) {
|
|
103
|
-
allSelectedUris.add(clip.getItemAt(i).uri)
|
|
104
|
-
}
|
|
105
|
-
} ?: data.data?.let { uri ->
|
|
106
|
-
allSelectedUris.add(uri)
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
val newSelectedUris = allSelectedUris.filter { uri -> !excludedUris.contains(uri.toString()) }
|
|
110
|
-
|
|
111
|
-
if (this.maxFiles > 0 && newSelectedUris.size > this.maxFiles) {
|
|
112
|
-
pickerPromise?.reject(E_MAX_FILES_EXCEEDED, "En fazla ${this.maxFiles} adet yeni dosya seçebilirsiniz.")
|
|
113
|
-
pickerPromise = null
|
|
114
|
-
return
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
try {
|
|
118
|
-
val fileInfoArray = processSelectedFiles(newSelectedUris)
|
|
119
|
-
pickerPromise?.resolve(fileInfoArray)
|
|
120
|
-
} catch (e: Exception) {
|
|
121
|
-
pickerPromise?.reject(E_FILE_TOO_LARGE, e.message)
|
|
122
|
-
}
|
|
123
|
-
} else {
|
|
124
|
-
pickerPromise?.reject(E_PICKER_CANCELLED, "Dosya seçimi iptal edildi.")
|
|
125
|
-
}
|
|
126
|
-
pickerPromise = null
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
override fun onNewIntent(intent: Intent) {}
|
|
130
|
-
|
|
131
|
-
private fun processSelectedFiles(uris: List<Uri>): WritableArray {
|
|
132
|
-
val fileObjects = WritableNativeArray()
|
|
133
|
-
val maxSizeBytes = (maxSize * 1024 * 1024).toLong()
|
|
134
|
-
|
|
135
|
-
for (uri in uris) {
|
|
136
|
-
reactContext.contentResolver.query(uri, null, null, null, null)?.use { cursor ->
|
|
137
|
-
if (cursor.moveToFirst()) {
|
|
138
|
-
val fileNameIndex = cursor.getColumnIndexOrThrow(OpenableColumns.DISPLAY_NAME)
|
|
139
|
-
val fileSizeIndex = cursor.getColumnIndexOrThrow(OpenableColumns.SIZE)
|
|
140
|
-
val fileName = cursor.getString(fileNameIndex)
|
|
141
|
-
val fileSize = cursor.getLong(fileSizeIndex)
|
|
142
|
-
|
|
143
|
-
if (maxSizeBytes > 0 && fileSize > maxSizeBytes) {
|
|
144
|
-
throw Exception("Seçilen dosya ($fileName) belirtilen ${maxSize}MB boyutundan büyük.")
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
val mimeType = getMimeType(fileName)
|
|
148
|
-
val base64 = reactContext.contentResolver.openInputStream(uri)?.use { inputStream ->
|
|
149
|
-
val byteBuffer = ByteArrayOutputStream()
|
|
150
|
-
val buffer = ByteArray(1024)
|
|
151
|
-
var len: Int
|
|
152
|
-
while (inputStream.read(buffer).also { len = it } != -1) {
|
|
153
|
-
byteBuffer.write(buffer, 0, len)
|
|
154
|
-
}
|
|
155
|
-
Base64.encodeToString(byteBuffer.toByteArray(), Base64.NO_WRAP)
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
val fileMap = WritableNativeMap().apply {
|
|
159
|
-
putString("fileName", fileName)
|
|
160
|
-
putDouble("fileSize", fileSize.toDouble())
|
|
161
|
-
putString("fileType", mimeType)
|
|
162
|
-
putString("fileUri", uri.toString())
|
|
163
|
-
putString("base64", base64)
|
|
164
|
-
}
|
|
165
|
-
fileObjects.pushMap(fileMap)
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
return fileObjects
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
private fun getMimeType(fileName: String): String? = URLConnection.guessContentTypeFromName(fileName)
|
|
173
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
package com.myuploader
|
|
2
|
-
|
|
3
|
-
import com.facebook.react.ReactPackage
|
|
4
|
-
import com.facebook.react.bridge.NativeModule
|
|
5
|
-
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
-
import com.facebook.react.uimanager.ViewManager
|
|
7
|
-
|
|
8
|
-
class MyUploaderPackage : ReactPackage {
|
|
9
|
-
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
|
|
10
|
-
return listOf(MyUploaderModule(reactContext))
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
|
|
14
|
-
return emptyList()
|
|
15
|
-
}
|
|
16
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _reactNative = require("react-native");
|
|
8
|
-
const LINKING_ERROR = `The package 'react--native-my-uploader' doesn't seem to be linked. Make sure: \n\n` + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
|
|
9
|
-
const DocumentPicker = _reactNative.NativeModules.DocumentPicker ? _reactNative.NativeModules.DocumentPicker : new Proxy({}, {
|
|
10
|
-
get() {
|
|
11
|
-
throw new Error(LINKING_ERROR);
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
var _default = exports.default = DocumentPicker;
|
|
15
|
-
//# sourceMappingURL=NativeMyUploader.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","LINKING_ERROR","DocumentPicker","NativeModules","Proxy","get","Error","_default","exports","default"],"sources":["NativeMyUploader.ts"],"sourcesContent":["import { NativeModules } from 'react-native';\r\nimport type { FileInfo, DocumentPickerOptions } from './types';\r\n\r\ninterface MyUploaderType {\r\n openDocument(options: DocumentPickerOptions): Promise<FileInfo[]>;\r\n}\r\n\r\nconst LINKING_ERROR =\r\n `The package 'react--native-my-uploader' doesn't seem to be linked. Make sure: \\n\\n` +\r\n '- You rebuilt the app after installing the package\\n' +\r\n '- You are not using Expo Go\\n';\r\n \r\n\r\nconst DocumentPicker = NativeModules.DocumentPicker\r\n ? (NativeModules.DocumentPicker as MyUploaderType)\r\n : new Proxy(\r\n {},\r\n {\r\n get() {\r\n throw new Error(LINKING_ERROR);\r\n },\r\n }\r\n );\r\n\r\nexport default DocumentPicker;"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAOA,MAAMC,aAAa,GACjB,oFAAoF,GACpF,sDAAsD,GACtD,+BAA+B;AAGjC,MAAMC,cAAc,GAAGC,0BAAa,CAACD,cAAc,GAC9CC,0BAAa,CAACD,cAAc,GAC7B,IAAIE,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACL,aAAa,CAAC;EAChC;AACF,CACF,CAAC;AAAC,IAAAM,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAESP,cAAc","ignoreList":[]}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { NativeModules } from 'react-native';
|
|
2
|
-
const LINKING_ERROR = `The package 'react--native-my-uploader' doesn't seem to be linked. Make sure: \n\n` + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
|
|
3
|
-
const DocumentPicker = NativeModules.DocumentPicker ? NativeModules.DocumentPicker : new Proxy({}, {
|
|
4
|
-
get() {
|
|
5
|
-
throw new Error(LINKING_ERROR);
|
|
6
|
-
}
|
|
7
|
-
});
|
|
8
|
-
export default DocumentPicker;
|
|
9
|
-
//# sourceMappingURL=NativeMyUploader.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["NativeModules","LINKING_ERROR","DocumentPicker","Proxy","get","Error"],"sources":["NativeMyUploader.ts"],"sourcesContent":["import { NativeModules } from 'react-native';\r\nimport type { FileInfo, DocumentPickerOptions } from './types';\r\n\r\ninterface MyUploaderType {\r\n openDocument(options: DocumentPickerOptions): Promise<FileInfo[]>;\r\n}\r\n\r\nconst LINKING_ERROR =\r\n `The package 'react--native-my-uploader' doesn't seem to be linked. Make sure: \\n\\n` +\r\n '- You rebuilt the app after installing the package\\n' +\r\n '- You are not using Expo Go\\n';\r\n \r\n\r\nconst DocumentPicker = NativeModules.DocumentPicker\r\n ? (NativeModules.DocumentPicker as MyUploaderType)\r\n : new Proxy(\r\n {},\r\n {\r\n get() {\r\n throw new Error(LINKING_ERROR);\r\n },\r\n }\r\n );\r\n\r\nexport default DocumentPicker;"],"mappings":"AAAA,SAASA,aAAa,QAAQ,cAAc;AAO5C,MAAMC,aAAa,GACjB,oFAAoF,GACpF,sDAAsD,GACtD,+BAA+B;AAGjC,MAAMC,cAAc,GAAGF,aAAa,CAACE,cAAc,GAC9CF,aAAa,CAACE,cAAc,GAC7B,IAAIC,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACJ,aAAa,CAAC;EAChC;AACF,CACF,CAAC;AAEL,eAAeC,cAAc","ignoreList":[]}
|
package/src/NativeMyUploader.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { NativeModules } from 'react-native';
|
|
2
|
-
import type { FileInfo, DocumentPickerOptions } from './types';
|
|
3
|
-
|
|
4
|
-
interface MyUploaderType {
|
|
5
|
-
openDocument(options: DocumentPickerOptions): Promise<FileInfo[]>;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
const LINKING_ERROR =
|
|
9
|
-
`The package 'react--native-my-uploader' doesn't seem to be linked. Make sure: \n\n` +
|
|
10
|
-
'- You rebuilt the app after installing the package\n' +
|
|
11
|
-
'- You are not using Expo Go\n';
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const DocumentPicker = NativeModules.DocumentPicker
|
|
15
|
-
? (NativeModules.DocumentPicker as MyUploaderType)
|
|
16
|
-
: new Proxy(
|
|
17
|
-
{},
|
|
18
|
-
{
|
|
19
|
-
get() {
|
|
20
|
-
throw new Error(LINKING_ERROR);
|
|
21
|
-
},
|
|
22
|
-
}
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
export default DocumentPicker;
|