react-native-my-uploader-android 1.0.21 → 1.0.23

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.
@@ -1,98 +1,98 @@
1
- import Foundation
2
- import MobileCoreServices
3
- import UIKit
4
- import UniformTypeIdentifiers
5
- import React
6
-
7
- @objc(MyUploader)
8
- class MyUploader: NSObject, UIDocumentPickerDelegate {
9
-
10
- private var resolveCallback: RCTResponseSenderBlock?
11
- private var rejectCallback: RCTResponseSenderBlock?
12
- private var maxFileSize: Int64 = 3 * 1024 * 1024 // 3 MB
13
- private var currentPicker: UIDocumentPickerViewController?
14
-
15
- @objc static func requiresMainQueueSetup() -> Bool {
16
- return true
17
- }
18
-
19
- @objc(openDocument:successCallback:failureCallback:)
20
- func openDocument(_ options: NSDictionary,
21
- successCallback: @escaping RCTResponseSenderBlock,
22
- failureCallback: @escaping RCTResponseSenderBlock) {
23
-
24
- self.resolveCallback = successCallback
25
- self.rejectCallback = failureCallback
26
-
27
- let multipleFiles = options["multipleFiles"] as? Bool ?? false
28
- let fileTypes = options["fileTypes"] as? [String] ?? ["public.data"]
29
-
30
- let supportedTypes: [UTType] = fileTypes.compactMap { mime in
31
- switch mime {
32
- case "application/pdf": return .pdf
33
- case "image/*": return .image
34
- case "application/msword": return UTType(importedAs: "com.microsoft.word.doc")
35
- case "application/vnd.openxmlformats-officedocument.wordprocessingml.document": return UTType(importedAs: "org.openxmlformats.wordprocessingml.document")
36
- case "application/vnd.ms-excel": return UTType(importedAs: "com.microsoft.excel.xls")
37
- case "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": return UTType(importedAs: "org.openxmlformats.spreadsheetml.sheet")
38
- case "application/vnd.ms-powerpoint": return UTType(importedAs: "com.microsoft.powerpoint.ppt")
39
- case "application/vnd.openxmlformats-officedocument.presentationml.presentation": return UTType(importedAs: "org.openxmlformats.presentationml.presentation")
40
- default: return nil
41
- }
42
- }
43
-
44
- let picker = UIDocumentPickerViewController(forOpeningContentTypes: supportedTypes, asCopy: true)
45
- picker.allowsMultipleSelection = multipleFiles
46
- picker.delegate = self
47
-
48
- DispatchQueue.main.async {
49
- if let rootVC = UIApplication.shared.windows.first?.rootViewController {
50
- var topVC = rootVC
51
- while let presented = topVC.presentedViewController {
52
- topVC = presented
53
- }
54
- topVC.present(picker, animated: true, completion: nil)
55
- } else {
56
- failureCallback(["{\"code\":\"NO_ROOT\", \"message\":\"Root view controller bulunamadı.\"}"])
57
- }
58
- }
59
- }
60
-
61
- func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) {
62
- var results: [[String: Any]] = []
63
-
64
- for url in urls {
65
- do {
66
- let fileData = try Data(contentsOf: url)
67
- let fileSize = Int64(fileData.count)
68
-
69
- if fileSize > maxFileSize {
70
- rejectCallback?(["{\"code\":\"TOO_LARGE\", \"message\":\"Seçilen dosya 3 MB'dan büyük olamaz.\"}"])
71
- return
72
- }
73
-
74
- let base64String = fileData.base64EncodedString()
75
- let fileName = url.lastPathComponent
76
- let fileType = url.pathExtension
77
-
78
- let dict: [String: Any] = [
79
- "fileName": fileName,
80
- "fileSize": fileSize,
81
- "fileType": fileType,
82
- "fileUri": url.absoluteString,
83
- "base64": base64String
84
- ]
85
- results.append(dict)
86
- } catch {
87
- rejectCallback?(["{\"code\":\"READ_ERROR\", \"message\":\"Dosya okunamadı: \(error.localizedDescription)\"}"])
88
- return
89
- }
90
- }
91
-
92
- resolveCallback?(results)
93
- }
94
-
95
- func documentPickerWasCancelled(_ controller: UIDocumentPickerViewController) {
96
- rejectCallback?(["{\"code\":\"CANCELLED\", \"message\":\"Kullanıcı iptal etti\"}"])
97
- }
1
+ import Foundation
2
+ import MobileCoreServices
3
+ import UIKit
4
+ import UniformTypeIdentifiers
5
+ import React
6
+
7
+ @objc(MyUploader)
8
+ class MyUploader: NSObject, UIDocumentPickerDelegate {
9
+
10
+ private var resolveCallback: RCTResponseSenderBlock?
11
+ private var rejectCallback: RCTResponseSenderBlock?
12
+ private var maxFileSize: Int64 = 3 * 1024 * 1024 // 3 MB
13
+ private var currentPicker: UIDocumentPickerViewController?
14
+
15
+ @objc static func requiresMainQueueSetup() -> Bool {
16
+ return true
17
+ }
18
+
19
+ @objc(openDocument:successCallback:failureCallback:)
20
+ func openDocument(_ options: NSDictionary,
21
+ successCallback: @escaping RCTResponseSenderBlock,
22
+ failureCallback: @escaping RCTResponseSenderBlock) {
23
+
24
+ self.resolveCallback = successCallback
25
+ self.rejectCallback = failureCallback
26
+
27
+ let multipleFiles = options["multipleFiles"] as? Bool ?? false
28
+ let fileTypes = options["fileTypes"] as? [String] ?? ["public.data"]
29
+
30
+ let supportedTypes: [UTType] = fileTypes.compactMap { mime in
31
+ switch mime {
32
+ case "application/pdf": return .pdf
33
+ case "image/*": return .image
34
+ case "application/msword": return UTType(importedAs: "com.microsoft.word.doc")
35
+ case "application/vnd.openxmlformats-officedocument.wordprocessingml.document": return UTType(importedAs: "org.openxmlformats.wordprocessingml.document")
36
+ case "application/vnd.ms-excel": return UTType(importedAs: "com.microsoft.excel.xls")
37
+ case "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": return UTType(importedAs: "org.openxmlformats.spreadsheetml.sheet")
38
+ case "application/vnd.ms-powerpoint": return UTType(importedAs: "com.microsoft.powerpoint.ppt")
39
+ case "application/vnd.openxmlformats-officedocument.presentationml.presentation": return UTType(importedAs: "org.openxmlformats.presentationml.presentation")
40
+ default: return nil
41
+ }
42
+ }
43
+
44
+ let picker = UIDocumentPickerViewController(forOpeningContentTypes: supportedTypes, asCopy: true)
45
+ picker.allowsMultipleSelection = multipleFiles
46
+ picker.delegate = self
47
+
48
+ DispatchQueue.main.async {
49
+ if let rootVC = UIApplication.shared.windows.first?.rootViewController {
50
+ var topVC = rootVC
51
+ while let presented = topVC.presentedViewController {
52
+ topVC = presented
53
+ }
54
+ topVC.present(picker, animated: true, completion: nil)
55
+ } else {
56
+ failureCallback(["{\"code\":\"NO_ROOT\", \"message\":\"Root view controller bulunamadı.\"}"])
57
+ }
58
+ }
59
+ }
60
+
61
+ func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) {
62
+ var results: [[String: Any]] = []
63
+
64
+ for url in urls {
65
+ do {
66
+ let fileData = try Data(contentsOf: url)
67
+ let fileSize = Int64(fileData.count)
68
+
69
+ if fileSize > maxFileSize {
70
+ rejectCallback?(["{\"code\":\"TOO_LARGE\", \"message\":\"Seçilen dosya 3 MB'dan büyük olamaz.\"}"])
71
+ return
72
+ }
73
+
74
+ let base64String = fileData.base64EncodedString()
75
+ let fileName = url.lastPathComponent
76
+ let fileType = url.pathExtension
77
+
78
+ let dict: [String: Any] = [
79
+ "fileName": fileName,
80
+ "fileSize": fileSize,
81
+ "fileType": fileType,
82
+ "fileUri": url.absoluteString,
83
+ "base64": base64String
84
+ ]
85
+ results.append(dict)
86
+ } catch {
87
+ rejectCallback?(["{\"code\":\"READ_ERROR\", \"message\":\"Dosya okunamadı: \(error.localizedDescription)\"}"])
88
+ return
89
+ }
90
+ }
91
+
92
+ resolveCallback?(results)
93
+ }
94
+
95
+ func documentPickerWasCancelled(_ controller: UIDocumentPickerViewController) {
96
+ rejectCallback?(["{\"code\":\"CANCELLED\", \"message\":\"Kullanıcı iptal etti\"}"])
97
+ }
98
98
  }
@@ -5,8 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _reactNative = require("react-native");
8
- // Native modülün tip tanımı
9
-
10
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';
11
9
  const DocumentPicker = _reactNative.NativeModules.DocumentPicker ? _reactNative.NativeModules.DocumentPicker : new Proxy({}, {
12
10
  get() {
@@ -1 +1 @@
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';\nimport type { FileInfo, DocumentPickerOptions } from './types';\n\n\n// Native modülün tip tanımı\ninterface MyUploaderType {\n openDocument(options: DocumentPickerOptions): Promise<FileInfo[]>;\n}\n\nconst LINKING_ERROR =\n `The package 'react--native-my-uploader' doesn't seem to be linked. Make sure: \\n\\n` +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo Go\\n';\n \n\nconst DocumentPicker = NativeModules.DocumentPicker\n ? (NativeModules.DocumentPicker as MyUploaderType)\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\nexport default DocumentPicker;"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAIA;;AAKA,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
+ {"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 +1 @@
1
- {"version":3,"names":[],"sources":["index.d.ts"],"sourcesContent":["// Dosya: index.d.ts\n\n// ADIM 1: Tipleri DIŞA AKTARARAK (export) doğrudan burada tanımla.\n// (Artık 'import' kullanmıyoruz)\n\n/**\n * Native modülden dönen tek bir dosyanın yapısını tanımlar.\n * Bu tip, paket kullanıcıları tarafından import edilebilir.\n */\nexport interface FileInfo {\n fileName: string;\n fileSize: number; // in bytes\n fileType: string | null;\n fileUri: string;\n base64: string;\n}\n\n/**\n * `pickFile` fonksiyonuna gönderilebilecek tüm opsiyonları tanımlar.\n * Bu tip, paket kullanıcıları tarafından import edilebilir.\n */\nexport interface DocumentPickerOptions {\n /**\n * Birden fazla dosya seçimine izin ver.\n * @default false\n */\n multipleFiles?: boolean;\n\n /**\n * Filtrelenecek dosya tipleri (MIME types).\n * @default ['* / *']\n */\n fileTypes?: string[];\n\n /**\n * MB cinsinden maksimum dosya boyutu.\n * @default 0 (limitsiz)\n */\n maxSize?: number;\n\n /**\n * Seçilebilecek maksimum dosya sayısı. `multipleFiles: true` olmalıdır.\n * Belirtilmezse ve `multipleFiles: true` ise varsayılan olarak 3'tür.\n */\n maxFiles?: number;\n\n /**\n * Zaten seçilmiş olduğu için tekrar seçilmesi engellenecek dosyaların URI listesi.\n */\n excludedUris?: string[];\n}\n\n// ADIM 2: Fonksiyonu da DIŞA AKTARARAK (export) tanımla.\n\n/**\n * Dosya seçiciyi açar ve seçilen dosyaların bilgilerini döndürür.\n * @param options Dosya seçici için yapılandırma ayarları.\n * @returns Seçilen dosya bilgilerini içeren bir Promise<FileInfo[]> döner.\n */\nexport function pickFile(options?: DocumentPickerOptions): Promise<FileInfo[]>;"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["index.d.ts"],"sourcesContent":["import * as React from 'react';\r\nimport type {FileInfo,DocumentPickerOptions, MyUploaderProps} from './types';\r\n\r\ndeclare const MyUploaderAndroid: React.FC<MyUploaderProps>;\r\nexport default MyUploaderAndroid;\r\n\r\n// Fonksiyonu hala export etmek isterseniz\r\nexport function pickFile(options?: DocumentPickerOptions): Promise<FileInfo[]>;"],"mappings":"","ignoreList":[]}
@@ -3,11 +3,11 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.default = void 0;
6
7
  exports.pickFile = pickFile;
8
+ var _react = _interopRequireDefault(require("react"));
7
9
  var _reactNative = require("react-native");
8
- // Gerekli tipleri ve arayüzleri import et
9
-
10
- // Native modülün düzgün bir şekilde bağlanıp bağlanmadığını kontrol eden güvenlik mekanizması
10
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
11
  const LINKING_ERROR = `The package 'react-native-my-uploader' doesn't seem to be linked.`;
12
12
  const DocumentPicker = _reactNative.NativeModules.DocumentPicker ? _reactNative.NativeModules.DocumentPicker : new Proxy({}, {
13
13
  get() {
@@ -15,14 +15,10 @@ const DocumentPicker = _reactNative.NativeModules.DocumentPicker ? _reactNative.
15
15
  }
16
16
  });
17
17
 
18
- /**
19
- * Dosya seçiciyi açar ve seçilen dosyaların bilgilerini döndürür.
20
- * @param options Dosya seçici için yapılandırma ayarları.
21
- * @returns Seçilen dosya bilgilerini içeren bir Promise<FileInfo[]> döner.
22
- */
18
+ // Mevcut pickFile fonksiyonunu dahili (internal) olarak kullanmak üzere saklayalım.
19
+ // İsterseniz bunu dışa aktarmaya devam edebilirsiniz.
23
20
  async function pickFile(options = {}) {
24
21
  var _options$excludedUris, _options$fileTypes, _options$maxSize;
25
- // Gelen opsiyonları varsayılan değerlerle birleştir
26
22
  const {
27
23
  multipleFiles = false,
28
24
  maxFiles = 0,
@@ -31,25 +27,93 @@ async function pickFile(options = {}) {
31
27
  if (!multipleFiles && maxFiles > 1) {
32
28
  throw new Error('`maxFiles` cannot be greater than 1 when `multipleFiles` is false.');
33
29
  }
34
-
35
- // KURAL: `multipleFiles: true` iken `maxFiles` belirtilmemişse, varsayılan olarak 3 ata.
36
30
  let effectiveMaxFiles = maxFiles;
37
31
  if (multipleFiles && maxFiles === 0) {
38
32
  effectiveMaxFiles = 3;
39
33
  }
40
-
41
- // Native koda gönderilecek nihai, temizlenmiş ve varsayılanları atanmış opsiyonları oluştur.
42
34
  const finalOptions = {
43
35
  ...rest,
44
36
  multipleFiles,
45
37
  maxFiles: effectiveMaxFiles,
46
- // Diğer opsiyonlar için de null/undefined kontrolü yap
47
38
  excludedUris: (_options$excludedUris = options.excludedUris) !== null && _options$excludedUris !== void 0 ? _options$excludedUris : [],
48
39
  fileTypes: (_options$fileTypes = options.fileTypes) !== null && _options$fileTypes !== void 0 ? _options$fileTypes : ['*/*'],
49
40
  maxSize: (_options$maxSize = options.maxSize) !== null && _options$maxSize !== void 0 ? _options$maxSize : 0
50
41
  };
51
-
52
- // Nihai opsiyonlarla native modülü çağır
53
42
  return DocumentPicker.openDocument(finalOptions);
54
43
  }
44
+
45
+ // YENİ: MyUploader Component'i
46
+ const MyUploaderAndroid = ({
47
+ // DocumentPickerOptions
48
+ multipleFiles = false,
49
+ maxFiles = 0,
50
+ fileTypes = ['*/*'],
51
+ maxSize = 0,
52
+ excludedUris = [],
53
+ // UI Props with defaults
54
+ buttonPlaceHolder = 'Dosya Seçin...',
55
+ ButtonStyle,
56
+ ButtonTextStyle,
57
+ disabled = false,
58
+ // Callbacks
59
+ onSelect,
60
+ onError = error => console.error('MyUploader Error:', error)
61
+ }) => {
62
+ const handlePress = async () => {
63
+ try {
64
+ const options = {
65
+ multipleFiles,
66
+ maxFiles,
67
+ fileTypes,
68
+ maxSize,
69
+ excludedUris
70
+ };
71
+ const selectedFiles = await pickFile(options);
72
+
73
+ // Eğer kullanıcı seçim yapmadan kapatırsa bazı sistemler boş array dönebilir.
74
+ // Sadece doluysa callback'i tetikleyelim.
75
+ if (selectedFiles && selectedFiles.length > 0) {
76
+ onSelect(selectedFiles);
77
+ }
78
+ } catch (error) {
79
+ // Kullanıcının seçimi iptal etmesi bir "hata" sayılmamalı,
80
+ // bu yüzden sadece konsola yazdırıp onError'ı tetiklemeyebiliriz.
81
+ // Native kodunuz "E_PICKER_CANCELLED" koduyla reject ediyor.
82
+ if (error.code !== 'E_PICKER_CANCELLED') {
83
+ onError(error);
84
+ }
85
+ }
86
+ };
87
+ return /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, {
88
+ style: [styles.button, ButtonStyle, disabled && styles.disabledButton],
89
+ onPress: handlePress,
90
+ disabled: disabled
91
+ }, /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
92
+ style: [styles.buttonText, ButtonTextStyle]
93
+ }, buttonPlaceHolder));
94
+ };
95
+
96
+ // Varsayılan stiller
97
+ const styles = _reactNative.StyleSheet.create({
98
+ button: {
99
+ backgroundColor: '#007AFF',
100
+ paddingHorizontal: 20,
101
+ paddingVertical: 10,
102
+ borderRadius: 8,
103
+ alignItems: 'center',
104
+ justifyContent: 'center'
105
+ },
106
+ buttonText: {
107
+ color: '#FFFFFF',
108
+ fontSize: 16,
109
+ fontWeight: 'bold'
110
+ },
111
+ disabledButton: {
112
+ backgroundColor: '#A9A9A9'
113
+ }
114
+ });
115
+
116
+ // İhtiyaca göre pickFile'ı da export edebilirsiniz.
117
+ // Component'i varsayılan olarak export ediyoruz.
118
+ var _default = exports.default = MyUploaderAndroid;
55
119
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","LINKING_ERROR","DocumentPicker","NativeModules","Proxy","get","Error","pickFile","options","_options$excludedUris","_options$fileTypes","_options$maxSize","multipleFiles","maxFiles","rest","effectiveMaxFiles","finalOptions","excludedUris","fileTypes","maxSize","openDocument"],"sources":["index.tsx"],"sourcesContent":["import { NativeModules } from 'react-native';\n\n// Gerekli tipleri ve arayüzleri import et\nimport type { FileInfo, DocumentPickerOptions } from './types';\n\n// Native modülün düzgün bir şekilde bağlanıp bağlanmadığını kontrol eden güvenlik mekanizması\nconst LINKING_ERROR = `The package 'react-native-my-uploader' doesn't seem to be linked.`;\n\nconst DocumentPicker = NativeModules.DocumentPicker\n ? NativeModules.DocumentPicker\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\n/**\n * Dosya seçiciyi açar ve seçilen dosyaların bilgilerini döndürür.\n * @param options Dosya seçici için yapılandırma ayarları.\n * @returns Seçilen dosya bilgilerini içeren bir Promise<FileInfo[]> döner.\n */\nexport async function pickFile(\n options: DocumentPickerOptions = {}\n): Promise<FileInfo[]> {\n // Gelen opsiyonları varsayılan değerlerle birleştir\n const { multipleFiles = false, maxFiles = 0, ...rest } = options;\n\n if (!multipleFiles && maxFiles > 1) {\n throw new Error(\n '`maxFiles` cannot be greater than 1 when `multipleFiles` is false.'\n );\n }\n\n // KURAL: `multipleFiles: true` iken `maxFiles` belirtilmemişse, varsayılan olarak 3 ata.\n let effectiveMaxFiles = maxFiles;\n if (multipleFiles && maxFiles === 0) {\n effectiveMaxFiles = 3;\n }\n\n // Native koda gönderilecek nihai, temizlenmiş ve varsayılanları atanmış opsiyonları oluştur.\n const finalOptions: DocumentPickerOptions = {\n ...rest,\n multipleFiles,\n maxFiles: effectiveMaxFiles,\n // Diğer opsiyonlar için de null/undefined kontrolü yap\n excludedUris: options.excludedUris ?? [],\n fileTypes: options.fileTypes ?? ['*/*'],\n maxSize: options.maxSize ?? 0,\n };\n\n // Nihai opsiyonlarla native modülü çağır\n return DocumentPicker.openDocument(finalOptions);\n}\n\nexport type { FileInfo, DocumentPickerOptions };"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEA;;AAGA;AACA,MAAMC,aAAa,GAAG,mEAAmE;AAEzF,MAAMC,cAAc,GAAGC,0BAAa,CAACD,cAAc,GAC/CC,0BAAa,CAACD,cAAc,GAC5B,IAAIE,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACL,aAAa,CAAC;EAChC;AACF,CACF,CAAC;;AAEL;AACA;AACA;AACA;AACA;AACO,eAAeM,QAAQA,CAC5BC,OAA8B,GAAG,CAAC,CAAC,EACd;EAAA,IAAAC,qBAAA,EAAAC,kBAAA,EAAAC,gBAAA;EACrB;EACA,MAAM;IAAEC,aAAa,GAAG,KAAK;IAAEC,QAAQ,GAAG,CAAC;IAAE,GAAGC;EAAK,CAAC,GAAGN,OAAO;EAEhE,IAAI,CAACI,aAAa,IAAIC,QAAQ,GAAG,CAAC,EAAE;IAClC,MAAM,IAAIP,KAAK,CACb,oEACF,CAAC;EACH;;EAEA;EACA,IAAIS,iBAAiB,GAAGF,QAAQ;EAChC,IAAID,aAAa,IAAIC,QAAQ,KAAK,CAAC,EAAE;IACnCE,iBAAiB,GAAG,CAAC;EACvB;;EAEA;EACA,MAAMC,YAAmC,GAAG;IAC1C,GAAGF,IAAI;IACPF,aAAa;IACbC,QAAQ,EAAEE,iBAAiB;IAC3B;IACAE,YAAY,GAAAR,qBAAA,GAAED,OAAO,CAACS,YAAY,cAAAR,qBAAA,cAAAA,qBAAA,GAAI,EAAE;IACxCS,SAAS,GAAAR,kBAAA,GAAEF,OAAO,CAACU,SAAS,cAAAR,kBAAA,cAAAA,kBAAA,GAAI,CAAC,KAAK,CAAC;IACvCS,OAAO,GAAAR,gBAAA,GAAEH,OAAO,CAACW,OAAO,cAAAR,gBAAA,cAAAA,gBAAA,GAAI;EAC9B,CAAC;;EAED;EACA,OAAOT,cAAc,CAACkB,YAAY,CAACJ,YAAY,CAAC;AAClD","ignoreList":[]}
1
+ {"version":3,"names":["_react","_interopRequireDefault","require","_reactNative","e","__esModule","default","LINKING_ERROR","DocumentPicker","NativeModules","Proxy","get","Error","pickFile","options","_options$excludedUris","_options$fileTypes","_options$maxSize","multipleFiles","maxFiles","rest","effectiveMaxFiles","finalOptions","excludedUris","fileTypes","maxSize","openDocument","MyUploaderAndroid","buttonPlaceHolder","ButtonStyle","ButtonTextStyle","disabled","onSelect","onError","error","console","handlePress","selectedFiles","length","code","createElement","TouchableOpacity","style","styles","button","disabledButton","onPress","Text","buttonText","StyleSheet","create","backgroundColor","paddingHorizontal","paddingVertical","borderRadius","alignItems","justifyContent","color","fontSize","fontWeight","_default","exports"],"sources":["index.tsx"],"sourcesContent":["import React from 'react';\r\nimport {NativeModules,TouchableOpacity,Text,StyleSheet} from 'react-native';\r\nimport type {FileInfo,DocumentPickerOptions, MyUploaderProps} from './types';\r\n\r\nconst LINKING_ERROR = `The package 'react-native-my-uploader' doesn't seem to be linked.`;\r\n\r\nconst DocumentPicker = NativeModules.DocumentPicker\r\n ? NativeModules.DocumentPicker\r\n : new Proxy(\r\n {},\r\n {\r\n get() {\r\n throw new Error(LINKING_ERROR);\r\n },\r\n }\r\n );\r\n\r\n// Mevcut pickFile fonksiyonunu dahili (internal) olarak kullanmak üzere saklayalım.\r\n// İsterseniz bunu dışa aktarmaya devam edebilirsiniz.\r\nasync function pickFile(\r\n options: DocumentPickerOptions = {}\r\n): Promise<FileInfo[]> {\r\n const { multipleFiles = false, maxFiles = 0, ...rest } = options;\r\n\r\n if (!multipleFiles && maxFiles > 1) {\r\n throw new Error(\r\n '`maxFiles` cannot be greater than 1 when `multipleFiles` is false.'\r\n );\r\n }\r\n let effectiveMaxFiles = maxFiles;\r\n if (multipleFiles && maxFiles === 0) {\r\n effectiveMaxFiles = 3;\r\n }\r\n const finalOptions: DocumentPickerOptions = {\r\n ...rest,\r\n multipleFiles,\r\n maxFiles: effectiveMaxFiles,\r\n excludedUris: options.excludedUris ?? [],\r\n fileTypes: options.fileTypes ?? ['*/*'],\r\n maxSize: options.maxSize ?? 0,\r\n };\r\n return DocumentPicker.openDocument(finalOptions);\r\n}\r\n\r\n// YENİ: MyUploader Component'i\r\nconst MyUploaderAndroid: React.FC<MyUploaderProps> = ({\r\n // DocumentPickerOptions\r\n multipleFiles = false,\r\n maxFiles = 0,\r\n fileTypes = ['*/*'],\r\n maxSize = 0,\r\n excludedUris = [],\r\n // UI Props with defaults\r\n buttonPlaceHolder = 'Dosya Seçin...',\r\n ButtonStyle,\r\n ButtonTextStyle,\r\n disabled = false,\r\n // Callbacks\r\n onSelect,\r\n onError = (error) => console.error('MyUploader Error:', error),\r\n}) => {\r\n const handlePress = async () => {\r\n try {\r\n const options: DocumentPickerOptions = {\r\n multipleFiles,\r\n maxFiles,\r\n fileTypes,\r\n maxSize,\r\n excludedUris,\r\n };\r\n const selectedFiles = await pickFile(options);\r\n \r\n // Eğer kullanıcı seçim yapmadan kapatırsa bazı sistemler boş array dönebilir.\r\n // Sadece doluysa callback'i tetikleyelim.\r\n if (selectedFiles && selectedFiles.length > 0) {\r\n onSelect(selectedFiles);\r\n }\r\n\r\n } catch (error: any) {\r\n // Kullanıcının seçimi iptal etmesi bir \"hata\" sayılmamalı,\r\n // bu yüzden sadece konsola yazdırıp onError'ı tetiklemeyebiliriz.\r\n // Native kodunuz \"E_PICKER_CANCELLED\" koduyla reject ediyor.\r\n if (error.code !== 'E_PICKER_CANCELLED') {\r\n onError(error);\r\n }\r\n }\r\n };\r\n\r\n return (\r\n <TouchableOpacity\r\n style={[styles.button, ButtonStyle, disabled && styles.disabledButton]}\r\n onPress={handlePress}\r\n disabled={disabled}\r\n >\r\n <Text style={[styles.buttonText, ButtonTextStyle]}>\r\n {buttonPlaceHolder}\r\n </Text>\r\n </TouchableOpacity>\r\n );\r\n};\r\n\r\n// Varsayılan stiller\r\nconst styles = StyleSheet.create({\r\n button: {\r\n backgroundColor: '#007AFF',\r\n paddingHorizontal: 20,\r\n paddingVertical: 10,\r\n borderRadius: 8,\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n },\r\n buttonText: {\r\n color: '#FFFFFF',\r\n fontSize: 16,\r\n fontWeight: 'bold',\r\n },\r\n disabledButton: {\r\n backgroundColor: '#A9A9A9',\r\n },\r\n});\r\n\r\n// İhtiyaca göre pickFile'ı da export edebilirsiniz.\r\nexport { pickFile };\r\nexport type { FileInfo, DocumentPickerOptions, MyUploaderProps };\r\n\r\n// Component'i varsayılan olarak export ediyoruz.\r\nexport default MyUploaderAndroid;"],"mappings":"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","ignoreList":[]}
@@ -1,2 +1,6 @@
1
1
  "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
2
6
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["// Dosya: src/types.ts\n\n/**\n * Native modülden dönen tek bir dosyanın yapısını tanımlar.\n */\nexport interface FileInfo {\n fileName: string;\n fileSize: number; // in bytes\n fileType: string | null;\n fileUri: string;\n base64: string;\n}\n\n/**\n * `pickFile` fonksiyonuna gönderilebilecek tüm opsiyonları tanımlar.\n */\nexport interface DocumentPickerOptions {\n /**\n * Birden fazla dosya seçimine izin ver.\n * @default false\n */\n multipleFiles?: boolean;\n\n /**\n * Filtrelenecek dosya tipleri (MIME types).\n * @default ['* / *'] (tüm dosyalar)\n * @example ['image/jpeg', 'application/pdf']\n */\n fileTypes?: string[];\n\n /**\n * MB cinsinden maksimum dosya boyutu.\n * @default 0 (limitsiz)\n */\n maxSize?: number;\n\n /**\n * Seçilebilecek maksimum dosya sayısı. `multipleFiles: true` olmalıdır.\n * Belirtilmezse ve `multipleFiles: true` ise varsayılan olarak 3'tür.\n * @default 0 (limitsiz, ama varsayılan mantığı uygulanır)\n */\n maxFiles?: number;\n\n /**\n * Zaten seçilmiş olduğu için tekrar seçilmesi engellenecek dosyaların URI listesi.\n */\n excludedUris?: string[];\n}"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { StyleProp, TextStyle, ViewStyle } from 'react-native';\r\n\r\nexport interface FileInfo {\r\n fileName: string;\r\n fileSize: number; // in bytes\r\n fileType: string | null;\r\n fileUri: string;\r\n base64: string;\r\n}\r\n\r\nexport interface DocumentPickerOptions {\r\n multipleFiles?: boolean;\r\n fileTypes?: string[];\r\n maxSize?: number;\r\n maxFiles?: number;\r\n excludedUris?: string[];\r\n}\r\nexport interface MyUploaderProps extends DocumentPickerOptions {\r\n // Geri bildirim (callback) fonksiyonları\r\n onSelect: (files: FileInfo[]) => void;\r\n onError?: (error: Error) => void;\r\n buttonPlaceHolder?: string;\r\n ButtonStyle?: StyleProp<ViewStyle>;\r\n ButtonTextStyle?: StyleProp<TextStyle>;\r\n disabled?: boolean;\r\n}"],"mappings":"","ignoreList":[]}
@@ -1,7 +1,4 @@
1
1
  import { NativeModules } from 'react-native';
2
-
3
- // Native modülün tip tanımı
4
-
5
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';
6
3
  const DocumentPicker = NativeModules.DocumentPicker ? NativeModules.DocumentPicker : new Proxy({}, {
7
4
  get() {
@@ -1 +1 @@
1
- {"version":3,"names":["NativeModules","LINKING_ERROR","DocumentPicker","Proxy","get","Error"],"sources":["NativeMyUploader.ts"],"sourcesContent":["import { NativeModules } from 'react-native';\nimport type { FileInfo, DocumentPickerOptions } from './types';\n\n\n// Native modülün tip tanımı\ninterface MyUploaderType {\n openDocument(options: DocumentPickerOptions): Promise<FileInfo[]>;\n}\n\nconst LINKING_ERROR =\n `The package 'react--native-my-uploader' doesn't seem to be linked. Make sure: \\n\\n` +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo Go\\n';\n \n\nconst DocumentPicker = NativeModules.DocumentPicker\n ? (NativeModules.DocumentPicker as MyUploaderType)\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\nexport default DocumentPicker;"],"mappings":"AAAA,SAASA,aAAa,QAAQ,cAAc;;AAI5C;;AAKA,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":[]}
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":[]}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["index.d.ts"],"sourcesContent":["// Dosya: index.d.ts\n\n// ADIM 1: Tipleri DIŞA AKTARARAK (export) doğrudan burada tanımla.\n// (Artık 'import' kullanmıyoruz)\n\n/**\n * Native modülden dönen tek bir dosyanın yapısını tanımlar.\n * Bu tip, paket kullanıcıları tarafından import edilebilir.\n */\nexport interface FileInfo {\n fileName: string;\n fileSize: number; // in bytes\n fileType: string | null;\n fileUri: string;\n base64: string;\n}\n\n/**\n * `pickFile` fonksiyonuna gönderilebilecek tüm opsiyonları tanımlar.\n * Bu tip, paket kullanıcıları tarafından import edilebilir.\n */\nexport interface DocumentPickerOptions {\n /**\n * Birden fazla dosya seçimine izin ver.\n * @default false\n */\n multipleFiles?: boolean;\n\n /**\n * Filtrelenecek dosya tipleri (MIME types).\n * @default ['* / *']\n */\n fileTypes?: string[];\n\n /**\n * MB cinsinden maksimum dosya boyutu.\n * @default 0 (limitsiz)\n */\n maxSize?: number;\n\n /**\n * Seçilebilecek maksimum dosya sayısı. `multipleFiles: true` olmalıdır.\n * Belirtilmezse ve `multipleFiles: true` ise varsayılan olarak 3'tür.\n */\n maxFiles?: number;\n\n /**\n * Zaten seçilmiş olduğu için tekrar seçilmesi engellenecek dosyaların URI listesi.\n */\n excludedUris?: string[];\n}\n\n// ADIM 2: Fonksiyonu da DIŞA AKTARARAK (export) tanımla.\n\n/**\n * Dosya seçiciyi açar ve seçilen dosyaların bilgilerini döndürür.\n * @param options Dosya seçici için yapılandırma ayarları.\n * @returns Seçilen dosya bilgilerini içeren bir Promise<FileInfo[]> döner.\n */\nexport function pickFile(options?: DocumentPickerOptions): Promise<FileInfo[]>;"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["index.d.ts"],"sourcesContent":["import * as React from 'react';\r\nimport type {FileInfo,DocumentPickerOptions, MyUploaderProps} from './types';\r\n\r\ndeclare const MyUploaderAndroid: React.FC<MyUploaderProps>;\r\nexport default MyUploaderAndroid;\r\n\r\n// Fonksiyonu hala export etmek isterseniz\r\nexport function pickFile(options?: DocumentPickerOptions): Promise<FileInfo[]>;"],"mappings":"","ignoreList":[]}
@@ -1,8 +1,5 @@
1
- import { NativeModules } from 'react-native';
2
-
3
- // Gerekli tipleri ve arayüzleri import et
4
-
5
- // Native modülün düzgün bir şekilde bağlanıp bağlanmadığını kontrol eden güvenlik mekanizması
1
+ import React from 'react';
2
+ import { NativeModules, TouchableOpacity, Text, StyleSheet } from 'react-native';
6
3
  const LINKING_ERROR = `The package 'react-native-my-uploader' doesn't seem to be linked.`;
7
4
  const DocumentPicker = NativeModules.DocumentPicker ? NativeModules.DocumentPicker : new Proxy({}, {
8
5
  get() {
@@ -10,14 +7,10 @@ const DocumentPicker = NativeModules.DocumentPicker ? NativeModules.DocumentPick
10
7
  }
11
8
  });
12
9
 
13
- /**
14
- * Dosya seçiciyi açar ve seçilen dosyaların bilgilerini döndürür.
15
- * @param options Dosya seçici için yapılandırma ayarları.
16
- * @returns Seçilen dosya bilgilerini içeren bir Promise<FileInfo[]> döner.
17
- */
18
- export async function pickFile(options = {}) {
10
+ // Mevcut pickFile fonksiyonunu dahili (internal) olarak kullanmak üzere saklayalım.
11
+ // İsterseniz bunu dışa aktarmaya devam edebilirsiniz.
12
+ async function pickFile(options = {}) {
19
13
  var _options$excludedUris, _options$fileTypes, _options$maxSize;
20
- // Gelen opsiyonları varsayılan değerlerle birleştir
21
14
  const {
22
15
  multipleFiles = false,
23
16
  maxFiles = 0,
@@ -26,25 +19,94 @@ export async function pickFile(options = {}) {
26
19
  if (!multipleFiles && maxFiles > 1) {
27
20
  throw new Error('`maxFiles` cannot be greater than 1 when `multipleFiles` is false.');
28
21
  }
29
-
30
- // KURAL: `multipleFiles: true` iken `maxFiles` belirtilmemişse, varsayılan olarak 3 ata.
31
22
  let effectiveMaxFiles = maxFiles;
32
23
  if (multipleFiles && maxFiles === 0) {
33
24
  effectiveMaxFiles = 3;
34
25
  }
35
-
36
- // Native koda gönderilecek nihai, temizlenmiş ve varsayılanları atanmış opsiyonları oluştur.
37
26
  const finalOptions = {
38
27
  ...rest,
39
28
  multipleFiles,
40
29
  maxFiles: effectiveMaxFiles,
41
- // Diğer opsiyonlar için de null/undefined kontrolü yap
42
30
  excludedUris: (_options$excludedUris = options.excludedUris) !== null && _options$excludedUris !== void 0 ? _options$excludedUris : [],
43
31
  fileTypes: (_options$fileTypes = options.fileTypes) !== null && _options$fileTypes !== void 0 ? _options$fileTypes : ['*/*'],
44
32
  maxSize: (_options$maxSize = options.maxSize) !== null && _options$maxSize !== void 0 ? _options$maxSize : 0
45
33
  };
46
-
47
- // Nihai opsiyonlarla native modülü çağır
48
34
  return DocumentPicker.openDocument(finalOptions);
49
35
  }
36
+
37
+ // YENİ: MyUploader Component'i
38
+ const MyUploaderAndroid = ({
39
+ // DocumentPickerOptions
40
+ multipleFiles = false,
41
+ maxFiles = 0,
42
+ fileTypes = ['*/*'],
43
+ maxSize = 0,
44
+ excludedUris = [],
45
+ // UI Props with defaults
46
+ buttonPlaceHolder = 'Dosya Seçin...',
47
+ ButtonStyle,
48
+ ButtonTextStyle,
49
+ disabled = false,
50
+ // Callbacks
51
+ onSelect,
52
+ onError = error => console.error('MyUploader Error:', error)
53
+ }) => {
54
+ const handlePress = async () => {
55
+ try {
56
+ const options = {
57
+ multipleFiles,
58
+ maxFiles,
59
+ fileTypes,
60
+ maxSize,
61
+ excludedUris
62
+ };
63
+ const selectedFiles = await pickFile(options);
64
+
65
+ // Eğer kullanıcı seçim yapmadan kapatırsa bazı sistemler boş array dönebilir.
66
+ // Sadece doluysa callback'i tetikleyelim.
67
+ if (selectedFiles && selectedFiles.length > 0) {
68
+ onSelect(selectedFiles);
69
+ }
70
+ } catch (error) {
71
+ // Kullanıcının seçimi iptal etmesi bir "hata" sayılmamalı,
72
+ // bu yüzden sadece konsola yazdırıp onError'ı tetiklemeyebiliriz.
73
+ // Native kodunuz "E_PICKER_CANCELLED" koduyla reject ediyor.
74
+ if (error.code !== 'E_PICKER_CANCELLED') {
75
+ onError(error);
76
+ }
77
+ }
78
+ };
79
+ return /*#__PURE__*/React.createElement(TouchableOpacity, {
80
+ style: [styles.button, ButtonStyle, disabled && styles.disabledButton],
81
+ onPress: handlePress,
82
+ disabled: disabled
83
+ }, /*#__PURE__*/React.createElement(Text, {
84
+ style: [styles.buttonText, ButtonTextStyle]
85
+ }, buttonPlaceHolder));
86
+ };
87
+
88
+ // Varsayılan stiller
89
+ const styles = StyleSheet.create({
90
+ button: {
91
+ backgroundColor: '#007AFF',
92
+ paddingHorizontal: 20,
93
+ paddingVertical: 10,
94
+ borderRadius: 8,
95
+ alignItems: 'center',
96
+ justifyContent: 'center'
97
+ },
98
+ buttonText: {
99
+ color: '#FFFFFF',
100
+ fontSize: 16,
101
+ fontWeight: 'bold'
102
+ },
103
+ disabledButton: {
104
+ backgroundColor: '#A9A9A9'
105
+ }
106
+ });
107
+
108
+ // İhtiyaca göre pickFile'ı da export edebilirsiniz.
109
+ export { pickFile };
110
+ // Component'i varsayılan olarak export ediyoruz.
111
+ export default MyUploaderAndroid;
50
112
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["NativeModules","LINKING_ERROR","DocumentPicker","Proxy","get","Error","pickFile","options","_options$excludedUris","_options$fileTypes","_options$maxSize","multipleFiles","maxFiles","rest","effectiveMaxFiles","finalOptions","excludedUris","fileTypes","maxSize","openDocument"],"sources":["index.tsx"],"sourcesContent":["import { NativeModules } from 'react-native';\n\n// Gerekli tipleri ve arayüzleri import et\nimport type { FileInfo, DocumentPickerOptions } from './types';\n\n// Native modülün düzgün bir şekilde bağlanıp bağlanmadığını kontrol eden güvenlik mekanizması\nconst LINKING_ERROR = `The package 'react-native-my-uploader' doesn't seem to be linked.`;\n\nconst DocumentPicker = NativeModules.DocumentPicker\n ? NativeModules.DocumentPicker\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\n/**\n * Dosya seçiciyi açar ve seçilen dosyaların bilgilerini döndürür.\n * @param options Dosya seçici için yapılandırma ayarları.\n * @returns Seçilen dosya bilgilerini içeren bir Promise<FileInfo[]> döner.\n */\nexport async function pickFile(\n options: DocumentPickerOptions = {}\n): Promise<FileInfo[]> {\n // Gelen opsiyonları varsayılan değerlerle birleştir\n const { multipleFiles = false, maxFiles = 0, ...rest } = options;\n\n if (!multipleFiles && maxFiles > 1) {\n throw new Error(\n '`maxFiles` cannot be greater than 1 when `multipleFiles` is false.'\n );\n }\n\n // KURAL: `multipleFiles: true` iken `maxFiles` belirtilmemişse, varsayılan olarak 3 ata.\n let effectiveMaxFiles = maxFiles;\n if (multipleFiles && maxFiles === 0) {\n effectiveMaxFiles = 3;\n }\n\n // Native koda gönderilecek nihai, temizlenmiş ve varsayılanları atanmış opsiyonları oluştur.\n const finalOptions: DocumentPickerOptions = {\n ...rest,\n multipleFiles,\n maxFiles: effectiveMaxFiles,\n // Diğer opsiyonlar için de null/undefined kontrolü yap\n excludedUris: options.excludedUris ?? [],\n fileTypes: options.fileTypes ?? ['*/*'],\n maxSize: options.maxSize ?? 0,\n };\n\n // Nihai opsiyonlarla native modülü çağır\n return DocumentPicker.openDocument(finalOptions);\n}\n\nexport type { FileInfo, DocumentPickerOptions };"],"mappings":"AAAA,SAASA,aAAa,QAAQ,cAAc;;AAE5C;;AAGA;AACA,MAAMC,aAAa,GAAG,mEAAmE;AAEzF,MAAMC,cAAc,GAAGF,aAAa,CAACE,cAAc,GAC/CF,aAAa,CAACE,cAAc,GAC5B,IAAIC,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACJ,aAAa,CAAC;EAChC;AACF,CACF,CAAC;;AAEL;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeK,QAAQA,CAC5BC,OAA8B,GAAG,CAAC,CAAC,EACd;EAAA,IAAAC,qBAAA,EAAAC,kBAAA,EAAAC,gBAAA;EACrB;EACA,MAAM;IAAEC,aAAa,GAAG,KAAK;IAAEC,QAAQ,GAAG,CAAC;IAAE,GAAGC;EAAK,CAAC,GAAGN,OAAO;EAEhE,IAAI,CAACI,aAAa,IAAIC,QAAQ,GAAG,CAAC,EAAE;IAClC,MAAM,IAAIP,KAAK,CACb,oEACF,CAAC;EACH;;EAEA;EACA,IAAIS,iBAAiB,GAAGF,QAAQ;EAChC,IAAID,aAAa,IAAIC,QAAQ,KAAK,CAAC,EAAE;IACnCE,iBAAiB,GAAG,CAAC;EACvB;;EAEA;EACA,MAAMC,YAAmC,GAAG;IAC1C,GAAGF,IAAI;IACPF,aAAa;IACbC,QAAQ,EAAEE,iBAAiB;IAC3B;IACAE,YAAY,GAAAR,qBAAA,GAAED,OAAO,CAACS,YAAY,cAAAR,qBAAA,cAAAA,qBAAA,GAAI,EAAE;IACxCS,SAAS,GAAAR,kBAAA,GAAEF,OAAO,CAACU,SAAS,cAAAR,kBAAA,cAAAA,kBAAA,GAAI,CAAC,KAAK,CAAC;IACvCS,OAAO,GAAAR,gBAAA,GAAEH,OAAO,CAACW,OAAO,cAAAR,gBAAA,cAAAA,gBAAA,GAAI;EAC9B,CAAC;;EAED;EACA,OAAOR,cAAc,CAACiB,YAAY,CAACJ,YAAY,CAAC;AAClD","ignoreList":[]}
1
+ {"version":3,"names":["React","NativeModules","TouchableOpacity","Text","StyleSheet","LINKING_ERROR","DocumentPicker","Proxy","get","Error","pickFile","options","_options$excludedUris","_options$fileTypes","_options$maxSize","multipleFiles","maxFiles","rest","effectiveMaxFiles","finalOptions","excludedUris","fileTypes","maxSize","openDocument","MyUploaderAndroid","buttonPlaceHolder","ButtonStyle","ButtonTextStyle","disabled","onSelect","onError","error","console","handlePress","selectedFiles","length","code","createElement","style","styles","button","disabledButton","onPress","buttonText","create","backgroundColor","paddingHorizontal","paddingVertical","borderRadius","alignItems","justifyContent","color","fontSize","fontWeight"],"sources":["index.tsx"],"sourcesContent":["import React from 'react';\r\nimport {NativeModules,TouchableOpacity,Text,StyleSheet} from 'react-native';\r\nimport type {FileInfo,DocumentPickerOptions, MyUploaderProps} from './types';\r\n\r\nconst LINKING_ERROR = `The package 'react-native-my-uploader' doesn't seem to be linked.`;\r\n\r\nconst DocumentPicker = NativeModules.DocumentPicker\r\n ? NativeModules.DocumentPicker\r\n : new Proxy(\r\n {},\r\n {\r\n get() {\r\n throw new Error(LINKING_ERROR);\r\n },\r\n }\r\n );\r\n\r\n// Mevcut pickFile fonksiyonunu dahili (internal) olarak kullanmak üzere saklayalım.\r\n// İsterseniz bunu dışa aktarmaya devam edebilirsiniz.\r\nasync function pickFile(\r\n options: DocumentPickerOptions = {}\r\n): Promise<FileInfo[]> {\r\n const { multipleFiles = false, maxFiles = 0, ...rest } = options;\r\n\r\n if (!multipleFiles && maxFiles > 1) {\r\n throw new Error(\r\n '`maxFiles` cannot be greater than 1 when `multipleFiles` is false.'\r\n );\r\n }\r\n let effectiveMaxFiles = maxFiles;\r\n if (multipleFiles && maxFiles === 0) {\r\n effectiveMaxFiles = 3;\r\n }\r\n const finalOptions: DocumentPickerOptions = {\r\n ...rest,\r\n multipleFiles,\r\n maxFiles: effectiveMaxFiles,\r\n excludedUris: options.excludedUris ?? [],\r\n fileTypes: options.fileTypes ?? ['*/*'],\r\n maxSize: options.maxSize ?? 0,\r\n };\r\n return DocumentPicker.openDocument(finalOptions);\r\n}\r\n\r\n// YENİ: MyUploader Component'i\r\nconst MyUploaderAndroid: React.FC<MyUploaderProps> = ({\r\n // DocumentPickerOptions\r\n multipleFiles = false,\r\n maxFiles = 0,\r\n fileTypes = ['*/*'],\r\n maxSize = 0,\r\n excludedUris = [],\r\n // UI Props with defaults\r\n buttonPlaceHolder = 'Dosya Seçin...',\r\n ButtonStyle,\r\n ButtonTextStyle,\r\n disabled = false,\r\n // Callbacks\r\n onSelect,\r\n onError = (error) => console.error('MyUploader Error:', error),\r\n}) => {\r\n const handlePress = async () => {\r\n try {\r\n const options: DocumentPickerOptions = {\r\n multipleFiles,\r\n maxFiles,\r\n fileTypes,\r\n maxSize,\r\n excludedUris,\r\n };\r\n const selectedFiles = await pickFile(options);\r\n \r\n // Eğer kullanıcı seçim yapmadan kapatırsa bazı sistemler boş array dönebilir.\r\n // Sadece doluysa callback'i tetikleyelim.\r\n if (selectedFiles && selectedFiles.length > 0) {\r\n onSelect(selectedFiles);\r\n }\r\n\r\n } catch (error: any) {\r\n // Kullanıcının seçimi iptal etmesi bir \"hata\" sayılmamalı,\r\n // bu yüzden sadece konsola yazdırıp onError'ı tetiklemeyebiliriz.\r\n // Native kodunuz \"E_PICKER_CANCELLED\" koduyla reject ediyor.\r\n if (error.code !== 'E_PICKER_CANCELLED') {\r\n onError(error);\r\n }\r\n }\r\n };\r\n\r\n return (\r\n <TouchableOpacity\r\n style={[styles.button, ButtonStyle, disabled && styles.disabledButton]}\r\n onPress={handlePress}\r\n disabled={disabled}\r\n >\r\n <Text style={[styles.buttonText, ButtonTextStyle]}>\r\n {buttonPlaceHolder}\r\n </Text>\r\n </TouchableOpacity>\r\n );\r\n};\r\n\r\n// Varsayılan stiller\r\nconst styles = StyleSheet.create({\r\n button: {\r\n backgroundColor: '#007AFF',\r\n paddingHorizontal: 20,\r\n paddingVertical: 10,\r\n borderRadius: 8,\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n },\r\n buttonText: {\r\n color: '#FFFFFF',\r\n fontSize: 16,\r\n fontWeight: 'bold',\r\n },\r\n disabledButton: {\r\n backgroundColor: '#A9A9A9',\r\n },\r\n});\r\n\r\n// İhtiyaca göre pickFile'ı da export edebilirsiniz.\r\nexport { pickFile };\r\nexport type { FileInfo, DocumentPickerOptions, MyUploaderProps };\r\n\r\n// Component'i varsayılan olarak export ediyoruz.\r\nexport default MyUploaderAndroid;"],"mappings":"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","ignoreList":[]}
@@ -1,2 +1,2 @@
1
-
1
+ export {};
2
2
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["// Dosya: src/types.ts\n\n/**\n * Native modülden dönen tek bir dosyanın yapısını tanımlar.\n */\nexport interface FileInfo {\n fileName: string;\n fileSize: number; // in bytes\n fileType: string | null;\n fileUri: string;\n base64: string;\n}\n\n/**\n * `pickFile` fonksiyonuna gönderilebilecek tüm opsiyonları tanımlar.\n */\nexport interface DocumentPickerOptions {\n /**\n * Birden fazla dosya seçimine izin ver.\n * @default false\n */\n multipleFiles?: boolean;\n\n /**\n * Filtrelenecek dosya tipleri (MIME types).\n * @default ['* / *'] (tüm dosyalar)\n * @example ['image/jpeg', 'application/pdf']\n */\n fileTypes?: string[];\n\n /**\n * MB cinsinden maksimum dosya boyutu.\n * @default 0 (limitsiz)\n */\n maxSize?: number;\n\n /**\n * Seçilebilecek maksimum dosya sayısı. `multipleFiles: true` olmalıdır.\n * Belirtilmezse ve `multipleFiles: true` ise varsayılan olarak 3'tür.\n * @default 0 (limitsiz, ama varsayılan mantığı uygulanır)\n */\n maxFiles?: number;\n\n /**\n * Zaten seçilmiş olduğu için tekrar seçilmesi engellenecek dosyaların URI listesi.\n */\n excludedUris?: string[];\n}"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { StyleProp, TextStyle, ViewStyle } from 'react-native';\r\n\r\nexport interface FileInfo {\r\n fileName: string;\r\n fileSize: number; // in bytes\r\n fileType: string | null;\r\n fileUri: string;\r\n base64: string;\r\n}\r\n\r\nexport interface DocumentPickerOptions {\r\n multipleFiles?: boolean;\r\n fileTypes?: string[];\r\n maxSize?: number;\r\n maxFiles?: number;\r\n excludedUris?: string[];\r\n}\r\nexport interface MyUploaderProps extends DocumentPickerOptions {\r\n // Geri bildirim (callback) fonksiyonları\r\n onSelect: (files: FileInfo[]) => void;\r\n onError?: (error: Error) => void;\r\n buttonPlaceHolder?: string;\r\n ButtonStyle?: StyleProp<ViewStyle>;\r\n ButtonTextStyle?: StyleProp<TextStyle>;\r\n disabled?: boolean;\r\n}"],"mappings":"","ignoreList":[]}