@uploadista/react-native-core 0.0.8 → 0.0.10
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/dist/{index.d.ts → index.d.mts} +26 -12
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +5 -5
- package/src/components/GalleryUploadButton.tsx +1 -1
- package/src/components/UploadList.tsx +17 -8
- package/src/hooks/use-flow-upload.ts +18 -3
- package/src/hooks/use-gallery-upload.ts +34 -27
- package/src/hooks/use-multi-upload.ts +120 -123
- package/src/hooks/use-upload.ts +18 -3
- package/src/types/types.ts +10 -2
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +0 -1
|
@@ -20,41 +20,48 @@ export function useGalleryUpload(options?: UseGalleryUploadOptions) {
|
|
|
20
20
|
|
|
21
21
|
// Select and upload media from gallery
|
|
22
22
|
const selectAndUpload = useCallback(async () => {
|
|
23
|
-
|
|
24
|
-
let media: FilePickResult | FilePickResult[];
|
|
23
|
+
let result: FilePickResult;
|
|
25
24
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
// Handle single or multiple files
|
|
43
|
-
const files = Array.isArray(media) ? media : [media];
|
|
25
|
+
// Select appropriate media type
|
|
26
|
+
if (options?.mediaType === "video") {
|
|
27
|
+
result = await fileSystemProvider.pickVideo({
|
|
28
|
+
allowMultiple: options?.allowMultiple ?? true,
|
|
29
|
+
});
|
|
30
|
+
} else if (options?.mediaType === "photo") {
|
|
31
|
+
result = await fileSystemProvider.pickImage({
|
|
32
|
+
allowMultiple: options?.allowMultiple ?? true,
|
|
33
|
+
});
|
|
34
|
+
} else {
|
|
35
|
+
// For 'mixed' or default, use pickImage first (can be extended to support both)
|
|
36
|
+
result = await fileSystemProvider.pickImage({
|
|
37
|
+
allowMultiple: options?.allowMultiple ?? true,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
44
40
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
41
|
+
// Handle cancelled picker
|
|
42
|
+
if (result.status === "cancelled") {
|
|
43
|
+
return [];
|
|
44
|
+
}
|
|
48
45
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
console.error("Gallery selection error:", error);
|
|
52
|
-
|
|
46
|
+
// Handle picker error
|
|
47
|
+
if (result.status === "error") {
|
|
48
|
+
console.error("Gallery selection error:", result.error);
|
|
49
|
+
options?.onError?.(result.error);
|
|
50
|
+
return [];
|
|
53
51
|
}
|
|
52
|
+
|
|
53
|
+
// Success - add file and start upload
|
|
54
|
+
const itemIds = uploadHook.addFiles([result]);
|
|
55
|
+
console.log("starting uploads", itemIds);
|
|
56
|
+
await uploadHook.startUploads(itemIds);
|
|
57
|
+
console.log("uploads started", itemIds);
|
|
58
|
+
|
|
59
|
+
return itemIds;
|
|
54
60
|
}, [
|
|
55
61
|
fileSystemProvider,
|
|
56
62
|
options?.allowMultiple,
|
|
57
63
|
options?.mediaType,
|
|
64
|
+
options?.onError,
|
|
58
65
|
uploadHook,
|
|
59
66
|
]);
|
|
60
67
|
|
|
@@ -5,7 +5,7 @@ import { useUploadistaContext } from "./use-uploadista-context";
|
|
|
5
5
|
|
|
6
6
|
export interface UploadItemState {
|
|
7
7
|
id: string;
|
|
8
|
-
file: FilePickResult
|
|
8
|
+
file: Extract<FilePickResult, { status: "success" }>;
|
|
9
9
|
status: "idle" | "uploading" | "success" | "error" | "aborted";
|
|
10
10
|
progress: number;
|
|
11
11
|
bytesUploaded: number;
|
|
@@ -70,12 +70,14 @@ const initialState: MultiUploadState = {
|
|
|
70
70
|
* ```
|
|
71
71
|
*/
|
|
72
72
|
export function useMultiUpload(options: UseMultiUploadOptions = {}) {
|
|
73
|
-
const { client
|
|
73
|
+
const { client } = useUploadistaContext();
|
|
74
74
|
const [state, setState] = useState<MultiUploadState>(initialState);
|
|
75
75
|
const abortControllersRef = useRef<Map<string, { abort: () => void }>>(
|
|
76
76
|
new Map(),
|
|
77
77
|
);
|
|
78
78
|
const nextIdRef = useRef(0);
|
|
79
|
+
// Use ref to track items synchronously
|
|
80
|
+
const itemsRef = useRef<UploadItemState[]>([]);
|
|
79
81
|
|
|
80
82
|
const generateId = useCallback(() => {
|
|
81
83
|
return `upload-${Date.now()}-${nextIdRef.current++}`;
|
|
@@ -97,6 +99,9 @@ export function useMultiUpload(options: UseMultiUploadOptions = {}) {
|
|
|
97
99
|
).length;
|
|
98
100
|
const failedCount = items.filter((item) => item.status === "error").length;
|
|
99
101
|
|
|
102
|
+
// Update ref synchronously
|
|
103
|
+
itemsRef.current = items;
|
|
104
|
+
|
|
100
105
|
setState((prev) => ({
|
|
101
106
|
...prev,
|
|
102
107
|
items,
|
|
@@ -111,19 +116,28 @@ export function useMultiUpload(options: UseMultiUploadOptions = {}) {
|
|
|
111
116
|
|
|
112
117
|
const addFiles = useCallback(
|
|
113
118
|
(files: FilePickResult[]) => {
|
|
114
|
-
|
|
119
|
+
// Filter out cancelled and error results, only keep successful picks
|
|
120
|
+
const successfulFiles = files.filter(
|
|
121
|
+
(file): file is Extract<FilePickResult, { status: "success" }> =>
|
|
122
|
+
file.status === "success",
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
const newItems: UploadItemState[] = successfulFiles.map((file) => ({
|
|
115
126
|
id: generateId(),
|
|
116
127
|
file,
|
|
117
128
|
status: "idle" as const,
|
|
118
129
|
progress: 0,
|
|
119
130
|
bytesUploaded: 0,
|
|
120
|
-
totalBytes: file.size,
|
|
131
|
+
totalBytes: file.data.size,
|
|
121
132
|
error: null,
|
|
122
133
|
result: null,
|
|
123
134
|
}));
|
|
124
135
|
|
|
136
|
+
// Update ref synchronously
|
|
137
|
+
const updatedItems = [...itemsRef.current, ...newItems];
|
|
138
|
+
itemsRef.current = updatedItems;
|
|
139
|
+
|
|
125
140
|
setState((prev) => {
|
|
126
|
-
const updatedItems = [...prev.items, ...newItems];
|
|
127
141
|
const totalBytes = updatedItems.reduce(
|
|
128
142
|
(sum, item) => sum + item.totalBytes,
|
|
129
143
|
0,
|
|
@@ -143,36 +157,25 @@ export function useMultiUpload(options: UseMultiUploadOptions = {}) {
|
|
|
143
157
|
const uploadSingleItem = useCallback(
|
|
144
158
|
async (item: UploadItemState) => {
|
|
145
159
|
try {
|
|
160
|
+
console.log("Uploading item:", item.file.data.name);
|
|
146
161
|
// Update status to uploading
|
|
147
|
-
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
162
|
+
const updatedItems = itemsRef.current.map((i) =>
|
|
163
|
+
i.id === item.id ? { ...i, status: "uploading" as const } : i,
|
|
164
|
+
);
|
|
165
|
+
updateAggregateStats(updatedItems);
|
|
166
|
+
|
|
167
|
+
// Convert file URI to Blob using fetch (React Native compatible)
|
|
168
|
+
// React Native's Blob doesn't support ArrayBuffer/Uint8Array constructor
|
|
169
|
+
const response = await fetch(item.file.data.uri);
|
|
170
|
+
const blob = await response.blob();
|
|
154
171
|
|
|
155
|
-
//
|
|
156
|
-
const
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
// Convert ArrayBuffer to Uint8Array for better compatibility
|
|
160
|
-
const data =
|
|
161
|
-
fileContent instanceof ArrayBuffer
|
|
162
|
-
? new Uint8Array(fileContent)
|
|
163
|
-
: fileContent;
|
|
164
|
-
// Note: Using any cast here because React Native Blob accepts BufferSource
|
|
165
|
-
// but TypeScript's lib.dom.d.ts Blob type doesn't include it
|
|
166
|
-
// biome-ignore lint/suspicious/noExplicitAny: React Native Blob accepts BufferSource
|
|
167
|
-
const blob = new Blob([data as any], {
|
|
168
|
-
type: item.file.mimeType || "application/octet-stream",
|
|
169
|
-
// biome-ignore lint/suspicious/noExplicitAny: BlobPropertyBag type differs by platform
|
|
170
|
-
} as any);
|
|
171
|
-
|
|
172
|
-
// use the Blob (for React Native)
|
|
173
|
-
const uploadInput = blob;
|
|
172
|
+
// Override blob type if we have mimeType from picker
|
|
173
|
+
const uploadInput = item.file.data.mimeType
|
|
174
|
+
? new Blob([blob], { type: item.file.data.mimeType })
|
|
175
|
+
: blob;
|
|
174
176
|
|
|
175
177
|
// Start upload using the client
|
|
178
|
+
console.log("Uploading input:", uploadInput);
|
|
176
179
|
const uploadPromise = client.upload(uploadInput, {
|
|
177
180
|
metadata: options.metadata,
|
|
178
181
|
|
|
@@ -185,53 +188,44 @@ export function useMultiUpload(options: UseMultiUploadOptions = {}) {
|
|
|
185
188
|
? Math.round((bytesUploaded / totalBytes) * 100)
|
|
186
189
|
: 0;
|
|
187
190
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
updateAggregateStats(updatedItems);
|
|
200
|
-
return prev;
|
|
201
|
-
});
|
|
191
|
+
const updatedItems = itemsRef.current.map((i) =>
|
|
192
|
+
i.id === item.id
|
|
193
|
+
? {
|
|
194
|
+
...i,
|
|
195
|
+
progress,
|
|
196
|
+
bytesUploaded,
|
|
197
|
+
totalBytes: totalBytes || i.totalBytes,
|
|
198
|
+
}
|
|
199
|
+
: i,
|
|
200
|
+
);
|
|
201
|
+
updateAggregateStats(updatedItems);
|
|
202
202
|
},
|
|
203
203
|
|
|
204
204
|
onSuccess: (result: UploadFile) => {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
updateAggregateStats(updatedItems);
|
|
218
|
-
return prev;
|
|
219
|
-
});
|
|
205
|
+
const updatedItems = itemsRef.current.map((i) =>
|
|
206
|
+
i.id === item.id
|
|
207
|
+
? {
|
|
208
|
+
...i,
|
|
209
|
+
status: "success" as const,
|
|
210
|
+
progress: 100,
|
|
211
|
+
result,
|
|
212
|
+
bytesUploaded: result.size || i.totalBytes,
|
|
213
|
+
}
|
|
214
|
+
: i,
|
|
215
|
+
);
|
|
216
|
+
updateAggregateStats(updatedItems);
|
|
220
217
|
|
|
221
218
|
options.onSuccess?.(result);
|
|
222
219
|
abortControllersRef.current.delete(item.id);
|
|
223
220
|
},
|
|
224
221
|
|
|
225
222
|
onError: (error: Error) => {
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
i
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
updateAggregateStats(updatedItems);
|
|
233
|
-
return prev;
|
|
234
|
-
});
|
|
223
|
+
const updatedItems = itemsRef.current.map((i) =>
|
|
224
|
+
i.id === item.id
|
|
225
|
+
? { ...i, status: "error" as const, error }
|
|
226
|
+
: i,
|
|
227
|
+
);
|
|
228
|
+
updateAggregateStats(updatedItems);
|
|
235
229
|
|
|
236
230
|
options.onError?.(error);
|
|
237
231
|
abortControllersRef.current.delete(item.id);
|
|
@@ -242,37 +236,46 @@ export function useMultiUpload(options: UseMultiUploadOptions = {}) {
|
|
|
242
236
|
const controller = await uploadPromise;
|
|
243
237
|
abortControllersRef.current.set(item.id, controller);
|
|
244
238
|
} catch (error) {
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
return prev;
|
|
257
|
-
});
|
|
239
|
+
console.error("Error uploading item:", error);
|
|
240
|
+
const updatedItems = itemsRef.current.map((i) =>
|
|
241
|
+
i.id === item.id
|
|
242
|
+
? {
|
|
243
|
+
...i,
|
|
244
|
+
status: "error" as const,
|
|
245
|
+
error: error as Error,
|
|
246
|
+
}
|
|
247
|
+
: i,
|
|
248
|
+
);
|
|
249
|
+
updateAggregateStats(updatedItems);
|
|
258
250
|
|
|
259
251
|
options.onError?.(error as Error);
|
|
260
252
|
abortControllersRef.current.delete(item.id);
|
|
261
253
|
}
|
|
262
254
|
},
|
|
263
|
-
[client,
|
|
255
|
+
[client, options, updateAggregateStats],
|
|
264
256
|
);
|
|
265
257
|
|
|
266
|
-
const startUploads = useCallback(
|
|
267
|
-
|
|
268
|
-
|
|
258
|
+
const startUploads = useCallback(
|
|
259
|
+
async (itemIds?: string[]) => {
|
|
260
|
+
const maxConcurrent = options.maxConcurrent || 3;
|
|
269
261
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
262
|
+
// Get items from ref (synchronous access to latest items)
|
|
263
|
+
const itemsToUpload = itemIds
|
|
264
|
+
? itemsRef.current.filter(
|
|
265
|
+
(item) => itemIds.includes(item.id) && item.status === "idle",
|
|
266
|
+
)
|
|
267
|
+
: itemsRef.current.filter((item) => item.status === "idle");
|
|
268
|
+
|
|
269
|
+
console.log("Items to upload:", itemsToUpload.length, itemsToUpload);
|
|
270
|
+
|
|
271
|
+
// Process items in batches
|
|
272
|
+
for (let i = 0; i < itemsToUpload.length; i += maxConcurrent) {
|
|
273
|
+
const batch = itemsToUpload.slice(i, i + maxConcurrent);
|
|
274
|
+
await Promise.all(batch.map((item) => uploadSingleItem(item)));
|
|
275
|
+
}
|
|
276
|
+
},
|
|
277
|
+
[options.maxConcurrent, uploadSingleItem],
|
|
278
|
+
);
|
|
276
279
|
|
|
277
280
|
const removeItem = useCallback(
|
|
278
281
|
(id: string) => {
|
|
@@ -282,11 +285,8 @@ export function useMultiUpload(options: UseMultiUploadOptions = {}) {
|
|
|
282
285
|
abortControllersRef.current.delete(id);
|
|
283
286
|
}
|
|
284
287
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
updateAggregateStats(updatedItems);
|
|
288
|
-
return prev;
|
|
289
|
-
});
|
|
288
|
+
const updatedItems = itemsRef.current.filter((item) => item.id !== id);
|
|
289
|
+
updateAggregateStats(updatedItems);
|
|
290
290
|
},
|
|
291
291
|
[updateAggregateStats],
|
|
292
292
|
);
|
|
@@ -299,13 +299,10 @@ export function useMultiUpload(options: UseMultiUploadOptions = {}) {
|
|
|
299
299
|
abortControllersRef.current.delete(id);
|
|
300
300
|
}
|
|
301
301
|
|
|
302
|
-
|
|
303
|
-
const
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
updateAggregateStats(updatedItems);
|
|
307
|
-
return prev;
|
|
308
|
-
});
|
|
302
|
+
const updatedItems = itemsRef.current.map((item) =>
|
|
303
|
+
item.id === id ? { ...item, status: "aborted" as const } : item,
|
|
304
|
+
);
|
|
305
|
+
updateAggregateStats(updatedItems);
|
|
309
306
|
},
|
|
310
307
|
[updateAggregateStats],
|
|
311
308
|
);
|
|
@@ -317,38 +314,38 @@ export function useMultiUpload(options: UseMultiUploadOptions = {}) {
|
|
|
317
314
|
});
|
|
318
315
|
abortControllersRef.current.clear();
|
|
319
316
|
|
|
317
|
+
// Clear ref
|
|
318
|
+
itemsRef.current = [];
|
|
319
|
+
|
|
320
320
|
setState(initialState);
|
|
321
321
|
}, []);
|
|
322
322
|
|
|
323
323
|
const retryItem = useCallback(
|
|
324
324
|
async (id: string) => {
|
|
325
|
-
const item =
|
|
325
|
+
const item = itemsRef.current.find((i) => i.id === id);
|
|
326
326
|
if (item && (item.status === "error" || item.status === "aborted")) {
|
|
327
327
|
// Reset item status to idle
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
updateAggregateStats(updatedItems);
|
|
341
|
-
return prev;
|
|
342
|
-
});
|
|
328
|
+
const updatedItems = itemsRef.current.map((i) =>
|
|
329
|
+
i.id === id
|
|
330
|
+
? {
|
|
331
|
+
...i,
|
|
332
|
+
status: "idle" as const,
|
|
333
|
+
progress: 0,
|
|
334
|
+
bytesUploaded: 0,
|
|
335
|
+
error: null,
|
|
336
|
+
}
|
|
337
|
+
: i,
|
|
338
|
+
);
|
|
339
|
+
updateAggregateStats(updatedItems);
|
|
343
340
|
|
|
344
|
-
// Upload it
|
|
345
|
-
const resetItem =
|
|
341
|
+
// Upload it (get the reset item from the updated items)
|
|
342
|
+
const resetItem = itemsRef.current.find((i) => i.id === id);
|
|
346
343
|
if (resetItem) {
|
|
347
344
|
await uploadSingleItem(resetItem);
|
|
348
345
|
}
|
|
349
346
|
}
|
|
350
347
|
},
|
|
351
|
-
[
|
|
348
|
+
[uploadSingleItem, updateAggregateStats],
|
|
352
349
|
);
|
|
353
350
|
|
|
354
351
|
return {
|
package/src/hooks/use-upload.ts
CHANGED
|
@@ -196,18 +196,33 @@ export function useUpload(options: UseUploadOptions = {}): UseUploadReturn {
|
|
|
196
196
|
|
|
197
197
|
const upload = useCallback(
|
|
198
198
|
async (file: FilePickResult) => {
|
|
199
|
+
// Handle cancelled picker
|
|
200
|
+
if (file.status === "cancelled") {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// Handle picker error
|
|
205
|
+
if (file.status === "error") {
|
|
206
|
+
updateState({
|
|
207
|
+
status: "error",
|
|
208
|
+
error: file.error,
|
|
209
|
+
});
|
|
210
|
+
options.onError?.(file.error);
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
|
|
199
214
|
// Reset any previous state
|
|
200
215
|
setState({
|
|
201
216
|
...initialState,
|
|
202
217
|
status: "uploading",
|
|
203
|
-
totalBytes: file.size,
|
|
218
|
+
totalBytes: file.data.size,
|
|
204
219
|
});
|
|
205
220
|
|
|
206
221
|
lastFileRef.current = file;
|
|
207
222
|
|
|
208
223
|
try {
|
|
209
224
|
// Read file content
|
|
210
|
-
const fileContent = await fileSystemProvider.readFile(file.uri);
|
|
225
|
+
const fileContent = await fileSystemProvider.readFile(file.data.uri);
|
|
211
226
|
|
|
212
227
|
// Create a Blob from the file content
|
|
213
228
|
// Convert ArrayBuffer to Uint8Array for better compatibility
|
|
@@ -219,7 +234,7 @@ export function useUpload(options: UseUploadOptions = {}): UseUploadReturn {
|
|
|
219
234
|
// but TypeScript's lib.dom.d.ts Blob type doesn't include it
|
|
220
235
|
// biome-ignore lint/suspicious/noExplicitAny: React Native Blob accepts BufferSource
|
|
221
236
|
const blob = new Blob([data as any], {
|
|
222
|
-
type: file.mimeType || "application/octet-stream",
|
|
237
|
+
type: file.data.mimeType || "application/octet-stream",
|
|
223
238
|
// biome-ignore lint/suspicious/noExplicitAny: BlobPropertyBag type differs by platform
|
|
224
239
|
} as any);
|
|
225
240
|
|
package/src/types/types.ts
CHANGED
|
@@ -29,9 +29,9 @@ export interface CameraOptions {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
|
-
*
|
|
32
|
+
* Successful file pick result containing file information
|
|
33
33
|
*/
|
|
34
|
-
export interface
|
|
34
|
+
export interface FilePickSuccess {
|
|
35
35
|
/** URI to the file (platform-specific format) */
|
|
36
36
|
uri: string;
|
|
37
37
|
/** File name with extension */
|
|
@@ -44,6 +44,14 @@ export interface FilePickResult {
|
|
|
44
44
|
localPath?: string;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
/**
|
|
48
|
+
* Result from a file pick operation that can be success, cancelled, or error
|
|
49
|
+
*/
|
|
50
|
+
export type FilePickResult =
|
|
51
|
+
| { status: "success"; data: FilePickSuccess }
|
|
52
|
+
| { status: "cancelled" }
|
|
53
|
+
| { status: "error"; error: Error };
|
|
54
|
+
|
|
47
55
|
/**
|
|
48
56
|
* Information about a file
|
|
49
57
|
*/
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/types/types.ts","../src/types/upload-input.ts","../src/components/CameraUploadButton.tsx","../src/components/FileUploadButton.tsx","../src/components/GalleryUploadButton.tsx","../src/components/UploadList.tsx","../src/hooks/use-upload.ts","../src/components/UploadProgress.tsx","../src/client/create-uploadista-client.ts","../src/hooks/use-uploadista-client.ts","../src/hooks/uploadista-context.ts","../src/hooks/use-camera-upload.ts","../src/hooks/use-file-upload.ts","../src/hooks/use-flow-upload.ts","../src/hooks/use-multi-upload.ts","../src/hooks/use-gallery-upload.ts","../src/hooks/use-upload-metrics.ts","../src/hooks/use-uploadista-context.ts","../src/utils/fileHelpers.ts","../src/utils/permissions.ts","../src/utils/uriHelpers.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;UAOiB,aAAA;;;EAAA;EAYA,aAAA,CAAA,EAAa,OAAA;EAcb;EAgBA,OAAA,CAAA,EAAA,MAAQ;AAiBzB;;;;AAasB,UA5DL,aAAA,CA4DK;EAAwB;EAAR,UAAA,CAAA,EAAA,OAAA,GAAA,MAAA;EAOhB;EAAwB,OAAA,CAAA,EAAA,MAAA;EAAR;EAOf,QAAA,CAAA,EAAA,MAAA;EAAwB;EAAR,SAAA,CAAA,EAAA,MAAA;;;;;AAqBX,UAjFX,cAAA,CAiFW;EAAO;EAMlB,GAAA,EAAA,MAAA;EAUL;EAWK,IAAA,EAAA,MAAA;EAgCA;EA8DA,IAAA,EAAA,MAAA;EAcA;EA8BA,QAAA,CAAA,EAAA,MAAA;EAIC;EAEL,SAAA,CAAA,EAAA,MAAA;;;AAgBb;AAwBA;AAsBiB,UA1SA,QAAA,CA0Sa;;;;EC3VlB,IAAA,EAAA,MAAA;;;;ECYK,QAAA,CAAA,EAAA,MAAA;EAEL;EAIC,gBAAA,CAAA,EAAA,MAAA;;;AAeb;;;AAGE,UF8Be,kBAAA,CE9Bf;EACA;;;;;EAIwB,YAAA,CAAA,OAAA,CAAA,EF+BD,aE/BC,CAAA,EF+Be,OE/Bf,CF+BuB,cE/BvB,CAAA;EAAA;;;;AC7B1B;EAEY,S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zB;;;;AC3VA;iBmBqHgB,kBAAA"}
|
package/dist/index.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import e,{createContext as t,useCallback as n,useContext as r,useEffect as i,useRef as a,useState as o}from"react";import{ActivityIndicator as s,FlatList as c,Pressable as l,StyleSheet as u,Text as d,View as f}from"react-native";import{UploadEventType as p}from"@uploadista/core/types";import{jsx as m,jsxs as h}from"react/jsx-runtime";const g=t(void 0);function _(){let e=r(g);if(!e)throw Error(`useUploadistaClient must be used within an UploadistaProvider`);return e}const v={status:`idle`,progress:0,bytesUploaded:0,totalBytes:null,error:null,result:null};function y(e={}){let{client:t,fileSystemProvider:r,subscribeToEvents:s}=_(),[c,l]=o(v),u=a(null),d=a(null),f=a(null),m=n(e=>{l(t=>({...t,...e}))},[]),h=n(()=>{u.current&&=(u.current.abort(),null),l(v),d.current=null,f.current=null},[]),g=n(()=>{u.current&&=(u.current.abort(),null),m({status:`aborted`}),e.onAbort?.()},[e,m]),y=n(async n=>{l({...v,status:`uploading`,totalBytes:n.size}),d.current=n;try{let i=await r.readFile(n.uri),a=i instanceof ArrayBuffer?new Uint8Array(i):i,o=new Blob([a],{type:n.mimeType||`application/octet-stream`});u.current=await t.upload(o,{metadata:e.metadata,uploadLengthDeferred:e.uploadLengthDeferred,uploadSize:e.uploadSize,onStart:({uploadId:e})=>{f.current=e},onProgress:(t,n,r)=>{let i=r?Math.round(n/r*100):0;m({progress:i,bytesUploaded:n,totalBytes:r}),e.onProgress?.(i,n,r)},onChunkComplete:(t,n,r)=>{e.onChunkComplete?.(t,n,r)},onSuccess:t=>{m({status:`success`,result:t,progress:100,bytesUploaded:t.size||0,totalBytes:t.size||null}),e.onSuccess?.(t),u.current=null},onError:t=>{m({status:`error`,error:t}),e.onError?.(t),u.current=null},onShouldRetry:e.onShouldRetry})}catch(t){m({status:`error`,error:t}),e.onError?.(t),u.current=null}},[t,r,e,m]),b=n(()=>{d.current&&(c.status===`error`||c.status===`aborted`)&&y(d.current)},[y,c.status]);return i(()=>s(t=>{let n=t;if(n.type===p.UPLOAD_PROGRESS&&n.data){let{id:t,progress:r,total:i}=n.data;if(t!==f.current)return;let a=i?Math.round(r/i*100):0;l(e=>e.status===`uploading`?{...e,progress:a,bytesUploaded:r,totalBytes:i}:e),e.onProgress?.(a,r,i)}}),[s,e]),{state:c,upload:y,abort:g,reset:h,retry:b,isUploading:c.status===`uploading`,canRetry:(c.status===`error`||c.status===`aborted`)&&d.current!==null}}function b(e){let{fileSystemProvider:t}=_(),r=y({metadata:e?.metadata,onSuccess:e?.onSuccess,onError:e?.onError,onProgress:e?.onProgress}),i=n(async()=>{try{let n=await t.pickCamera(e?.cameraOptions);await r.upload(n)}catch(e){console.error(`Camera capture error:`,e)}},[t,e?.cameraOptions,r]);return{...r,captureAndUpload:i}}function x(e){let{fileSystemProvider:t}=_(),r=y({metadata:e?.metadata,onSuccess:e?.onSuccess,onError:e?.onError,onProgress:e?.onProgress}),i=n(async()=>{try{let n=await t.pickDocument({allowedTypes:e?.allowedTypes});await r.upload(n)}catch(e){throw console.error(`File selection error:`,e),e}},[t,e?.allowedTypes,r]);return{...r,pickAndUpload:i}}const S={status:`idle`,progress:0,bytesUploaded:0,totalBytes:null,jobId:null,error:null,result:null};function ee(e){let{client:t,fileSystemProvider:r}=_(),[i,s]=o(S),c=a(null),l=a(null),u=n(e=>{s(t=>({...t,...e}))},[]),d=n(()=>{c.current&&=(c.current.abort(),null),s(S),l.current=null},[]),f=n(()=>{c.current&&=(c.current.abort(),null),u({status:`aborted`})},[u]),p=n(async n=>{s({...S,status:`uploading`,totalBytes:n.size}),l.current=n;try{let i=await r.readFile(n.uri),a=i instanceof ArrayBuffer?new Uint8Array(i):i,o=new Blob([a],{type:n.mimeType||`application/octet-stream`});c.current=await t.uploadWithFlow(o,{flowId:e.flowId,storageId:e.storageId,outputNodeId:e.outputNodeId,metadata:e.metadata},{onJobStart:()=>{u({status:`processing`})},onProgress:(t,n,r)=>{let i=r?Math.round(n/r*100):0;u({progress:i,bytesUploaded:n,totalBytes:r}),e.onProgress?.(i,n,r)},onChunkComplete:(t,n,r)=>{e.onChunkComplete?.(t,n,r)},onSuccess:t=>{u({status:`success`,result:t,progress:100,bytesUploaded:t.size||0,totalBytes:t.size||null}),e.onSuccess?.(t),c.current=null},onError:t=>{u({status:`error`,error:t}),e.onError?.(t),c.current=null}})}catch(t){u({status:`error`,error:t}),e.onError?.(t),c.current=null}},[t,r,e,u]);return{state:i,upload:p,abort:f,reset:d,retry:n(()=>{l.current&&(i.status===`error`||i.status===`aborted`)&&p(l.current)},[p,i.status]),isActive:i.status===`uploading`||i.status===`processing`,canRetry:(i.status===`error`||i.status===`aborted`)&&l.current!==null}}const C={items:[],totalProgress:0,totalUploaded:0,totalBytes:0,activeCount:0,completedCount:0,failedCount:0};function w(e={}){let{client:t,fileSystemProvider:r}=_(),[i,s]=o(C),c=a(new Map),l=a(0),u=n(()=>`upload-${Date.now()}-${l.current++}`,[]),d=n(e=>{let t=e.reduce((e,t)=>e+t.totalBytes,0),n=e.reduce((e,t)=>e+t.bytesUploaded,0),r=t>0?Math.round(n/t*100):0,i=e.filter(e=>e.status===`uploading`).length,a=e.filter(e=>e.status===`success`).length,o=e.filter(e=>e.status===`error`).length;s(s=>({...s,items:e,totalProgress:r,totalUploaded:n,totalBytes:t,activeCount:i,completedCount:a,failedCount:o}))},[]),f=n(e=>{let t=e.map(e=>({id:u(),file:e,status:`idle`,progress:0,bytesUploaded:0,totalBytes:e.size,error:null,result:null}));return s(e=>{let n=[...e.items,...t],r=n.reduce((e,t)=>e+t.totalBytes,0);return{...e,items:n,totalBytes:r}}),t.map(e=>e.id)},[u]),p=n(async n=>{try{s(e=>(d(e.items.map(e=>e.id===n.id?{...e,status:`uploading`}:e)),e));let i=await r.readFile(n.file.uri),a=i instanceof ArrayBuffer?new Uint8Array(i):i,o=new Blob([a],{type:n.file.mimeType||`application/octet-stream`}),l=await t.upload(o,{metadata:e.metadata,onProgress:(e,t,r)=>{let i=r?Math.round(t/r*100):0;s(e=>(d(e.items.map(e=>e.id===n.id?{...e,progress:i,bytesUploaded:t,totalBytes:r||e.totalBytes}:e)),e))},onSuccess:t=>{s(e=>(d(e.items.map(e=>e.id===n.id?{...e,status:`success`,progress:100,result:t,bytesUploaded:t.size||e.totalBytes}:e)),e)),e.onSuccess?.(t),c.current.delete(n.id)},onError:t=>{s(e=>(d(e.items.map(e=>e.id===n.id?{...e,status:`error`,error:t}:e)),e)),e.onError?.(t),c.current.delete(n.id)}});c.current.set(n.id,l)}catch(t){s(e=>(d(e.items.map(e=>e.id===n.id?{...e,status:`error`,error:t}:e)),e)),e.onError?.(t),c.current.delete(n.id)}},[t,r,e,d]),m=n(async()=>{let t=e.maxConcurrent||3,n=i.items.filter(e=>e.status===`idle`);for(let e=0;e<n.length;e+=t){let r=n.slice(e,e+t);await Promise.all(r.map(e=>p(e)))}},[i.items,e.maxConcurrent,p]),h=n(e=>{let t=c.current.get(e);t&&(t.abort(),c.current.delete(e)),s(t=>(d(t.items.filter(t=>t.id!==e)),t))},[d]),g=n(e=>{let t=c.current.get(e);t&&(t.abort(),c.current.delete(e)),s(t=>(d(t.items.map(t=>t.id===e?{...t,status:`aborted`}:t)),t))},[d]),v=n(()=>{c.current.forEach(e=>{e.abort()}),c.current.clear(),s(C)},[]);return{state:i,addFiles:f,startUploads:m,removeItem:h,abortItem:g,retryItem:n(async e=>{let t=i.items.find(t=>t.id===e);if(t&&(t.status===`error`||t.status===`aborted`)){s(t=>(d(t.items.map(t=>t.id===e?{...t,status:`idle`,progress:0,bytesUploaded:0,error:null}:t)),t));let t=i.items.find(t=>t.id===e);t&&await p(t)}},[i.items,p,d]),clear:v}}function T(e){let{fileSystemProvider:t}=_(),r=w({maxConcurrent:3,metadata:e?.metadata,onSuccess:e?.onSuccess,onError:e?.onError}),i=n(async()=>{try{let n;n=e?.mediaType===`video`?await t.pickVideo({allowMultiple:e?.allowMultiple??!0}):(e?.mediaType,await t.pickImage({allowMultiple:e?.allowMultiple??!0}));let i=Array.isArray(n)?n:[n],a=r.addFiles(i);return await r.startUploads(),a}catch(e){throw console.error(`Gallery selection error:`,e),e}},[t,e?.allowMultiple,e?.mediaType,r]);return{...r,selectAndUpload:i}}function te(){let e=a(null),t=a(0),r=a(0),[i,s]=o({totalBytes:0,durationMs:0,avgSpeed:0,peakSpeed:0,retries:0});return{metrics:i,start:n(()=>{e.current=Date.now(),t.current=0,r.current=0},[]),update:n((t,n,i=0)=>{if(!e.current)return;let a=Date.now()-e.current,o=a>0?t/a*1e3:0;o>r.current&&(r.current=o),s({totalBytes:t,durationMs:a,avgSpeed:a>0?t/a*1e3:0,peakSpeed:r.current,retries:i})},[]),end:n(()=>{let t=i;return e.current=null,t},[i]),reset:n(()=>{e.current=null,t.current=0,r.current=0,s({totalBytes:0,durationMs:0,avgSpeed:0,peakSpeed:0,retries:0})},[])}}function E(e){if(e===0)return`0 Bytes`;let t=1024,n=[`Bytes`,`KB`,`MB`,`GB`],r=Math.floor(Math.log(e)/Math.log(t));return`${Math.round(e/t**r*100)/100} ${n[r]}`}function D(e){return{".jpg":`image/jpeg`,".jpeg":`image/jpeg`,".png":`image/png`,".gif":`image/gif`,".bmp":`image/bmp`,".webp":`image/webp`,".svg":`image/svg+xml`,".mp4":`video/mp4`,".avi":`video/x-msvideo`,".mov":`video/quicktime`,".wmv":`video/x-ms-wmv`,".flv":`video/x-flv`,".mkv":`video/x-matroska`,".webm":`video/webm`,".mp3":`audio/mpeg`,".wav":`audio/wav`,".aac":`audio/aac`,".flac":`audio/flac`,".m4a":`audio/mp4`,".pdf":`application/pdf`,".doc":`application/msword`,".docx":`application/vnd.openxmlformats-officedocument.wordprocessingml.document`,".xls":`application/vnd.ms-excel`,".xlsx":`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,".ppt":`application/vnd.ms-powerpoint`,".pptx":`application/vnd.openxmlformats-officedocument.presentationml.presentation`,".txt":`text/plain`,".csv":`text/csv`,".json":`application/json`,".xml":`application/xml`,".zip":`application/zip`}[e.toLowerCase().slice(e.lastIndexOf(`.`))]||`application/octet-stream`}function ne(e,t){if(!t||t.length===0)return!0;let n=D(e);return t.some(e=>{if(e.endsWith(`/*`)){let[t]=e.split(`/`);return n.startsWith(`${t}/`)}return e===n})}function re(e,t,n){return!(t!==void 0&&e>t||n!==void 0&&e<n)}function ie(e){let t=e.lastIndexOf(`.`);return t===-1?``:e.slice(t+1).toLowerCase()}function ae(e){let t=e.lastIndexOf(`.`);return t===-1?e:e.slice(0,t)}function oe(e){let t=[`.jpg`,`.jpeg`,`.png`,`.gif`,`.bmp`,`.webp`,`.svg`],n=e.toLowerCase().slice(e.lastIndexOf(`.`));return t.includes(n)}function O(e){let t=[`.mp4`,`.avi`,`.mov`,`.wmv`,`.flv`,`.mkv`,`.webm`],n=e.toLowerCase().slice(e.lastIndexOf(`.`));return t.includes(n)}function k(e){let t=[`.pdf`,`.doc`,`.docx`,`.xls`,`.xlsx`,`.ppt`,`.pptx`,`.txt`,`.csv`],n=e.toLowerCase().slice(e.lastIndexOf(`.`));return t.includes(n)}let A=function(e){return e.CAMERA=`CAMERA`,e.PHOTO_LIBRARY=`PHOTO_LIBRARY`,e.WRITE_STORAGE=`WRITE_STORAGE`,e.READ_STORAGE=`READ_STORAGE`,e}({}),j=function(e){return e.GRANTED=`granted`,e.DENIED=`denied`,e.NOT_DETERMINED=`not_determined`,e.RESTRICTED=`restricted`,e}({});async function M(){try{return console.log(`Camera permission requested (handled by file system provider)`),!0}catch(e){return console.error(`Failed to request camera permission:`,e),!1}}async function N(){try{return console.log(`Photo library permission requested (handled by file system provider)`),!0}catch(e){return console.error(`Failed to request photo library permission:`,e),!1}}async function P(){try{return console.log(`Storage read permission requested (handled by file system provider)`),!0}catch(e){return console.error(`Failed to request storage read permission:`,e),!1}}async function F(){try{return console.log(`Storage write permission requested (handled by file system provider)`),!0}catch(e){return console.error(`Failed to request storage write permission:`,e),!1}}async function I(e){try{return(await Promise.all(e.map(async e=>{switch(e){case A.CAMERA:return M();case A.PHOTO_LIBRARY:return N();case A.READ_STORAGE:return P();case A.WRITE_STORAGE:return F();default:return!1}}))).every(e=>e)}catch(e){return console.error(`Failed to request permissions:`,e),!1}}async function L(e){try{return!0}catch(e){return console.error(`Failed to check permissions:`,e),!1}}async function R(e){try{return j.GRANTED}catch(e){return console.error(`Failed to get permission status:`,e),j.DENIED}}function z(){try{console.log(`Opening app settings (requires react-native-app-settings or platform implementation)`)}catch(e){console.error(`Failed to open app settings:`,e)}}function B(e){try{if(e.startsWith(`file://`))return e.replace(`file://`,``).split(`/`).pop()||`file`;if(e.startsWith(`content://`)){let t=e.split(`/`);return t[t.length-1]||`file`}let t=e.split(`/`);return t[t.length-1]||`file`}catch{return`file`}}function V(e){return e.startsWith(`file://`)||e.startsWith(`content://`)?e:`file://${e}`}function H(e){return e.startsWith(`file://`)?e.replace(`file://`,``):(e.startsWith(`content://`),e)}function U(e){try{let t=H(e).split(`/`);return t.pop(),t.join(`/`)}catch{return``}}function W(e){return e.startsWith(`content://`)}function G(e){return e.startsWith(`file://`)}function K(e){return e.replace(/([^:]\/)\/+/g,`$1`)}function se(e){let t=B(e);return{".jpg":`image/jpeg`,".jpeg":`image/jpeg`,".png":`image/png`,".gif":`image/gif`,".bmp":`image/bmp`,".webp":`image/webp`,".mp4":`video/mp4`,".mov":`video/quicktime`,".avi":`video/x-msvideo`,".mp3":`audio/mpeg`,".wav":`audio/wav`,".aac":`audio/aac`,".pdf":`application/pdf`,".txt":`text/plain`,".json":`application/json`}[t.toLowerCase().slice(t.lastIndexOf(`.`))]||`application/octet-stream`}function q({state:e,label:t}){let n=()=>{switch(e.status){case`uploading`:return`#007AFF`;case`success`:return`#34C759`;case`error`:case`aborted`:return`#FF3B30`;default:return`#999999`}};return h(f,{style:[J.wrapper,{borderLeftColor:n()}],children:[e.status===`uploading`&&m(s,{size:`small`,color:n(),style:J.spinner}),(()=>{switch(e.status){case`idle`:return m(f,{style:J.container,children:m(d,{style:J.label,children:t||`Ready to upload`})});case`uploading`:return h(f,{style:J.container,children:[h(f,{style:J.headerRow,children:[m(d,{style:J.label,children:t||`Uploading`}),h(d,{style:J.percentage,children:[e.progress,`%`]})]}),m(f,{style:J.progressBarContainer,children:m(f,{style:[J.progressBar,{width:`${e.progress}%`,backgroundColor:n()}]})}),m(f,{style:J.detailsRow,children:h(d,{style:J.detail,children:[E(e.bytesUploaded),` /`,` `,E(e.totalBytes||0)]})})]});case`success`:return h(f,{style:J.container,children:[h(f,{style:J.headerRow,children:[m(d,{style:[J.label,{color:n()}],children:t||`Upload complete`}),m(d,{style:[J.percentage,{color:n()}],children:`✓`})]}),m(d,{style:[J.detail,{color:n()}],children:E(e.totalBytes||0)})]});case`error`:return h(f,{style:J.container,children:[h(f,{style:J.headerRow,children:[m(d,{style:[J.label,{color:n()}],children:t||`Upload failed`}),m(d,{style:[J.percentage,{color:n()}],children:`✕`})]}),e.error&&m(d,{style:[J.detail,{color:n()}],children:e.error.message})]});case`aborted`:return m(f,{style:J.container,children:m(d,{style:[J.label,{color:n()}],children:t||`Upload cancelled`})});default:return null}})()]})}const J=u.create({wrapper:{flexDirection:`row`,alignItems:`flex-start`,paddingVertical:8,paddingHorizontal:12,borderLeftWidth:4,backgroundColor:`#f5f5f5`,borderRadius:4,gap:8},spinner:{marginTop:4},container:{flex:1,gap:4},headerRow:{flexDirection:`row`,justifyContent:`space-between`,alignItems:`center`},label:{fontSize:14,fontWeight:`600`,color:`#333333`,flex:1},percentage:{fontSize:14,fontWeight:`600`,color:`#007AFF`,minWidth:36,textAlign:`right`},progressBarContainer:{height:4,backgroundColor:`#e0e0e0`,borderRadius:2,overflow:`hidden`},progressBar:{height:`100%`,borderRadius:2},detailsRow:{flexDirection:`row`,justifyContent:`space-between`,alignItems:`center`},detail:{fontSize:12,color:`#666666`}});function ce({options:e,label:t=`Take Photo`,children:n,onSuccess:r,onError:a,onCancel:o,showProgress:c=!0}){let{state:u,captureAndUpload:p}=b(e),g=async()=>{try{await p()}catch(e){e instanceof Error&&(e.message.includes(`cancelled`)||e.message.includes(`aborted`)?o?.():a?.(e))}},_=u.status===`uploading`,v=_||u.status===`aborted`;return i(()=>{u.status===`success`&&u.result&&r?.(u.result)},[u.status,u.result,r]),i(()=>{u.status===`error`&&u.error&&a?.(u.error)},[u.status,u.error,a]),h(f,{style:Y.container,children:[h(l,{style:[Y.button,v&&Y.buttonDisabled],onPress:g,disabled:v,children:[_&&m(s,{size:`small`,color:`#FFFFFF`,style:Y.spinner}),m(d,{style:Y.buttonText,children:n||t})]}),c&&u.status!==`idle`&&m(f,{style:Y.progressContainer,children:m(q,{state:u,label:`Camera upload`})})]})}const Y=u.create({container:{gap:8},button:{flexDirection:`row`,alignItems:`center`,justifyContent:`center`,paddingVertical:12,paddingHorizontal:16,backgroundColor:`#007AFF`,borderRadius:8,gap:8},buttonDisabled:{opacity:.6},buttonText:{fontSize:16,fontWeight:`600`,color:`#FFFFFF`},spinner:{marginRight:4},progressContainer:{marginTop:4}});function X({options:e,label:t=`Choose File`,children:n,onSuccess:r,onError:a,onCancel:o,showProgress:c=!0}){let{state:u,pickAndUpload:p}=x(e),g=async()=>{try{await p()}catch(e){e instanceof Error&&(e.message.includes(`cancelled`)||e.message.includes(`aborted`)?o?.():a?.(e))}},_=u.status===`uploading`,v=_||u.status===`aborted`;return i(()=>{u.status===`success`&&u.result&&r?.(u.result)},[u.status,u.result,r]),i(()=>{u.status===`error`&&u.error&&a?.(u.error)},[u.status,u.error,a]),h(f,{style:Z.container,children:[h(l,{style:[Z.button,v&&Z.buttonDisabled],onPress:g,disabled:v,children:[_&&m(s,{size:`small`,color:`#FFFFFF`,style:Z.spinner}),m(d,{style:Z.buttonText,children:n||t})]}),c&&u.status!==`idle`&&m(f,{style:Z.progressContainer,children:m(q,{state:u,label:`File upload`})})]})}const Z=u.create({container:{gap:8},button:{flexDirection:`row`,alignItems:`center`,justifyContent:`center`,paddingVertical:12,paddingHorizontal:16,backgroundColor:`#FF9500`,borderRadius:8,gap:8},buttonDisabled:{opacity:.6},buttonText:{fontSize:16,fontWeight:`600`,color:`#FFFFFF`},spinner:{marginRight:4},progressContainer:{marginTop:4}});function le({options:t,label:n=`Select from Gallery`,children:r,onSuccess:i,onError:a,onCancel:o,showProgress:u=!0}){let{state:p,selectAndUpload:g}=T(t),_=async()=>{try{await g()}catch(e){e instanceof Error&&(e.message.includes(`cancelled`)||e.message.includes(`aborted`)?o?.():a?.(e))}},v=p.items.some(e=>e.status===`uploading`),y=p.items.length>0,b=y&&p.items.every(e=>e.status!==`uploading`&&e.status!==`idle`);return e.useEffect(()=>{if(b){let e=p.items.filter(e=>e.status===`success`).map(e=>e.result);e.length>0&&i?.(e)}},[b,p.items,i]),e.useEffect(()=>{let e=p.items.filter(e=>e.status===`error`)[0]?.error;e&&a?.(e)},[p.items,a]),h(f,{style:Q.container,children:[h(l,{style:[Q.button,v&&Q.buttonDisabled],onPress:_,disabled:v,children:[v&&m(s,{size:`small`,color:`#FFFFFF`,style:Q.spinner}),h(d,{style:Q.buttonText,children:[r||n,y&&` (${p.items.length})`]})]}),y&&h(f,{style:Q.statsContainer,children:[h(d,{style:Q.statsText,children:[`Progress: `,p.items.filter(e=>e.status===`success`).length,`/`,p.items.length,` uploaded`]}),h(d,{style:Q.statsText,children:[`Overall: `,p.totalProgress,`%`]})]}),u&&y&&m(c,{scrollEnabled:!1,data:p.items,renderItem:({item:e})=>m(f,{style:Q.itemContainer,children:m(q,{state:{status:e.status,progress:e.progress,bytesUploaded:e.bytesUploaded,totalBytes:e.totalBytes,error:e.error,result:e.result},label:e.file.name})},e.id),keyExtractor:e=>e.id,style:Q.listContainer,contentContainerStyle:Q.listContent,ItemSeparatorComponent:()=>m(f,{style:Q.separator})})]})}const Q=u.create({container:{gap:8},button:{flexDirection:`row`,alignItems:`center`,justifyContent:`center`,paddingVertical:12,paddingHorizontal:16,backgroundColor:`#34C759`,borderRadius:8,gap:8},buttonDisabled:{opacity:.6},buttonText:{fontSize:16,fontWeight:`600`,color:`#FFFFFF`},spinner:{marginRight:4},statsContainer:{paddingVertical:8,paddingHorizontal:12,backgroundColor:`#f5f5f5`,borderRadius:4,gap:4},statsText:{fontSize:12,color:`#666666`},listContainer:{maxHeight:400},listContent:{gap:8},itemContainer:{paddingHorizontal:0},separator:{height:4}});function ue({items:e,onRemove:t,onItemPress:n,showRemoveButton:r=!0}){return e.length===0?m(f,{style:$.emptyContainer,children:m(d,{style:$.emptyText,children:`No uploads`})}):h(f,{style:$.container,children:[h(f,{style:$.headerRow,children:[h(d,{style:$.headerText,children:[`Uploads (`,e.length,`)`]}),h(d,{style:$.headerSubtext,children:[e.filter(e=>e.progress.state===`success`).length,` complete`]})]}),m(c,{scrollEnabled:!1,data:e,renderItem:({item:e})=>h(l,{style:[$.itemContainer,{borderLeftColor:de(e.progress.state)}],onPress:()=>n?.(e),children:[h(f,{style:$.itemContent,children:[h(f,{style:$.itemHeader,children:[m(d,{style:$.fileName,numberOfLines:1,children:e.file.name}),m(d,{style:$.fileSize,children:fe(e.file.size)})]}),m(f,{style:$.progressWrapper,children:m(q,{state:{status:e.progress.state===`pending`?`idle`:e.progress.state===`cancelled`?`aborted`:e.progress.state,progress:e.progress.progress,bytesUploaded:e.progress.uploadedBytes,totalBytes:e.progress.totalBytes,error:e.progress.error||null,result:e.result||null}})})]}),r&&e.progress.state!==`uploading`&&e.progress.state!==`pending`&&m(l,{style:$.removeButton,onPress:()=>t?.(e.id),hitSlop:{top:8,right:8,bottom:8,left:8},children:m(d,{style:$.removeButtonText,children:`✕`})})]}),keyExtractor:e=>e.id,ItemSeparatorComponent:()=>m(f,{style:$.separator}),contentContainerStyle:$.listContent})]})}function de(e){switch(e){case`success`:return`#34C759`;case`error`:case`cancelled`:return`#FF3B30`;case`uploading`:case`pending`:return`#007AFF`;default:return`#999999`}}function fe(e){if(e===0)return`0 B`;let t=1024,n=[`B`,`KB`,`MB`,`GB`],r=Math.floor(Math.log(e)/Math.log(t));return`${Math.round(e/t**r*10)/10} ${n[r]}`}const $=u.create({container:{gap:8},headerRow:{flexDirection:`row`,justifyContent:`space-between`,alignItems:`center`,paddingHorizontal:12,paddingVertical:8,backgroundColor:`#f9f9f9`,borderRadius:4},headerText:{fontSize:16,fontWeight:`600`,color:`#333333`},headerSubtext:{fontSize:14,color:`#666666`},listContent:{gap:8},itemContainer:{flexDirection:`row`,alignItems:`center`,paddingVertical:8,paddingHorizontal:12,borderLeftWidth:4,backgroundColor:`#f5f5f5`,borderRadius:4,gap:8},itemContent:{flex:1,gap:6},itemHeader:{flexDirection:`row`,justifyContent:`space-between`,alignItems:`center`},fileName:{fontSize:14,fontWeight:`500`,color:`#333333`,flex:1},fileSize:{fontSize:12,color:`#999999`,marginLeft:8},progressWrapper:{marginTop:2},removeButton:{width:32,height:32,justifyContent:`center`,alignItems:`center`,borderRadius:16,backgroundColor:`#FFE5E5`},removeButtonText:{fontSize:16,fontWeight:`600`,color:`#FF3B30`},separator:{height:4},emptyContainer:{paddingVertical:24,paddingHorizontal:12,backgroundColor:`#f5f5f5`,borderRadius:4,alignItems:`center`,justifyContent:`center`},emptyText:{fontSize:14,color:`#999999`,fontStyle:`italic`}});export{ce as CameraUploadButton,X as FileUploadButton,le as GalleryUploadButton,j as PermissionStatus,A as PermissionType,ue as UploadList,q as UploadProgress,g as UploadistaContext,E as formatFileSize,U as getDirectoryFromUri,ie as getFileExtension,B as getFileNameFromUri,ae as getFileNameWithoutExtension,D as getMimeTypeFromFileName,se as getMimeTypeFromUri,R as getPermissionStatus,L as hasPermissions,W as isContentUri,k as isDocumentFile,re as isFileSizeValid,ne as isFileTypeAllowed,G as isFileUri,oe as isImageFile,O as isVideoFile,K as normalizeUri,z as openAppSettings,V as pathToUri,M as requestCameraPermission,I as requestPermissions,N as requestPhotoLibraryPermission,P as requestStorageReadPermission,F as requestStorageWritePermission,H as uriToPath,b as useCameraUpload,x as useFileUpload,ee as useFlowUpload,T as useGalleryUpload,w as useMultiUpload,te as useUploadMetrics,_ as useUploadistaContext};
|
|
2
|
-
//# sourceMappingURL=index.js.map
|