@idealyst/files 1.2.96
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/package.json +94 -0
- package/src/components/DropZone.native.tsx +96 -0
- package/src/components/DropZone.styles.tsx +99 -0
- package/src/components/DropZone.web.tsx +178 -0
- package/src/components/FilePickerButton.native.tsx +82 -0
- package/src/components/FilePickerButton.styles.tsx +112 -0
- package/src/components/FilePickerButton.web.tsx +84 -0
- package/src/components/UploadProgress.native.tsx +203 -0
- package/src/components/UploadProgress.styles.tsx +90 -0
- package/src/components/UploadProgress.web.tsx +201 -0
- package/src/components/index.native.ts +8 -0
- package/src/components/index.ts +6 -0
- package/src/components/index.web.ts +8 -0
- package/src/constants.ts +336 -0
- package/src/examples/index.ts +181 -0
- package/src/hooks/createUseFilePickerHook.ts +169 -0
- package/src/hooks/createUseFileUploadHook.ts +173 -0
- package/src/hooks/index.native.ts +12 -0
- package/src/hooks/index.ts +12 -0
- package/src/hooks/index.web.ts +12 -0
- package/src/index.native.ts +142 -0
- package/src/index.ts +139 -0
- package/src/index.web.ts +142 -0
- package/src/permissions/index.native.ts +8 -0
- package/src/permissions/index.ts +8 -0
- package/src/permissions/index.web.ts +8 -0
- package/src/permissions/permissions.native.ts +177 -0
- package/src/permissions/permissions.web.ts +96 -0
- package/src/picker/FilePicker.native.ts +407 -0
- package/src/picker/FilePicker.web.ts +366 -0
- package/src/picker/index.native.ts +2 -0
- package/src/picker/index.ts +2 -0
- package/src/picker/index.web.ts +2 -0
- package/src/types.ts +990 -0
- package/src/uploader/ChunkedUploader.ts +312 -0
- package/src/uploader/FileUploader.native.ts +435 -0
- package/src/uploader/FileUploader.web.ts +350 -0
- package/src/uploader/UploadQueue.ts +519 -0
- package/src/uploader/index.native.ts +4 -0
- package/src/uploader/index.ts +4 -0
- package/src/uploader/index.web.ts +4 -0
- package/src/utils.ts +586 -0
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { useState, useCallback, useEffect, useRef } from 'react';
|
|
2
|
+
import type {
|
|
3
|
+
UseFileUploadOptions,
|
|
4
|
+
UseFileUploadResult,
|
|
5
|
+
QueueStatus,
|
|
6
|
+
UploadProgressInfo,
|
|
7
|
+
PickedFile,
|
|
8
|
+
UploadConfig,
|
|
9
|
+
IFileUploader,
|
|
10
|
+
CreateFileUploaderFactory,
|
|
11
|
+
} from '../types';
|
|
12
|
+
import { INITIAL_QUEUE_STATUS, DEFAULT_UPLOAD_CONFIG } from '../constants';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Create a useFileUpload hook with the given file uploader factory.
|
|
16
|
+
*/
|
|
17
|
+
export function createUseFileUploadHook(createFileUploader: CreateFileUploaderFactory) {
|
|
18
|
+
return function useFileUpload(options: UseFileUploadOptions = {}): UseFileUploadResult {
|
|
19
|
+
const { config = {}, autoStart = true, concurrency = 3 } = options;
|
|
20
|
+
|
|
21
|
+
const uploaderRef = useRef<IFileUploader | null>(null);
|
|
22
|
+
const configRef = useRef<Partial<Omit<UploadConfig, 'url'>>>(config);
|
|
23
|
+
|
|
24
|
+
const [queueStatus, setQueueStatus] = useState<QueueStatus>(INITIAL_QUEUE_STATUS);
|
|
25
|
+
const [uploads, setUploads] = useState<UploadProgressInfo[]>([]);
|
|
26
|
+
|
|
27
|
+
// Update config ref when it changes
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
configRef.current = config;
|
|
30
|
+
}, [config]);
|
|
31
|
+
|
|
32
|
+
// Initialize uploader
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
const uploader = createFileUploader({ concurrency });
|
|
35
|
+
uploaderRef.current = uploader;
|
|
36
|
+
|
|
37
|
+
// Subscribe to queue changes
|
|
38
|
+
const unsubscribeQueue = uploader.onQueueChange((status) => {
|
|
39
|
+
setQueueStatus(status);
|
|
40
|
+
setUploads(Array.from(uploader.uploads.values()));
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// Subscribe to completion for final update
|
|
44
|
+
const unsubscribeComplete = uploader.onComplete(() => {
|
|
45
|
+
setUploads(Array.from(uploader.uploads.values()));
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
return () => {
|
|
49
|
+
unsubscribeQueue();
|
|
50
|
+
unsubscribeComplete();
|
|
51
|
+
uploader.dispose();
|
|
52
|
+
uploaderRef.current = null;
|
|
53
|
+
};
|
|
54
|
+
}, [concurrency]);
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Add files to upload queue.
|
|
58
|
+
*/
|
|
59
|
+
const addFiles = useCallback((
|
|
60
|
+
files: PickedFile | PickedFile[],
|
|
61
|
+
uploadConfig: UploadConfig
|
|
62
|
+
): string[] => {
|
|
63
|
+
if (!uploaderRef.current) return [];
|
|
64
|
+
|
|
65
|
+
const finalConfig: UploadConfig = {
|
|
66
|
+
...DEFAULT_UPLOAD_CONFIG,
|
|
67
|
+
...configRef.current,
|
|
68
|
+
...uploadConfig,
|
|
69
|
+
} as UploadConfig;
|
|
70
|
+
|
|
71
|
+
const ids = uploaderRef.current.add(files, finalConfig);
|
|
72
|
+
|
|
73
|
+
if (autoStart) {
|
|
74
|
+
uploaderRef.current.start();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Update uploads state
|
|
78
|
+
setUploads(Array.from(uploaderRef.current.uploads.values()));
|
|
79
|
+
|
|
80
|
+
return ids;
|
|
81
|
+
}, [autoStart]);
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Start processing queue.
|
|
85
|
+
*/
|
|
86
|
+
const start = useCallback(() => {
|
|
87
|
+
uploaderRef.current?.start();
|
|
88
|
+
}, []);
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Pause all uploads.
|
|
92
|
+
*/
|
|
93
|
+
const pause = useCallback(() => {
|
|
94
|
+
uploaderRef.current?.pause();
|
|
95
|
+
}, []);
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Resume paused uploads.
|
|
99
|
+
*/
|
|
100
|
+
const resume = useCallback(() => {
|
|
101
|
+
uploaderRef.current?.resume();
|
|
102
|
+
}, []);
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Cancel specific upload.
|
|
106
|
+
*/
|
|
107
|
+
const cancel = useCallback((uploadId: string) => {
|
|
108
|
+
uploaderRef.current?.cancel(uploadId);
|
|
109
|
+
}, []);
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Cancel all uploads.
|
|
113
|
+
*/
|
|
114
|
+
const cancelAll = useCallback(() => {
|
|
115
|
+
uploaderRef.current?.cancelAll();
|
|
116
|
+
}, []);
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Retry failed upload.
|
|
120
|
+
*/
|
|
121
|
+
const retry = useCallback((uploadId: string) => {
|
|
122
|
+
uploaderRef.current?.retry(uploadId);
|
|
123
|
+
}, []);
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Retry all failed uploads.
|
|
127
|
+
*/
|
|
128
|
+
const retryAll = useCallback(() => {
|
|
129
|
+
uploaderRef.current?.retryAll();
|
|
130
|
+
}, []);
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Remove upload from queue.
|
|
134
|
+
*/
|
|
135
|
+
const remove = useCallback((uploadId: string) => {
|
|
136
|
+
uploaderRef.current?.remove(uploadId);
|
|
137
|
+
}, []);
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Clear completed uploads.
|
|
141
|
+
*/
|
|
142
|
+
const clearCompleted = useCallback(() => {
|
|
143
|
+
uploaderRef.current?.clearCompleted();
|
|
144
|
+
}, []);
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Get specific upload.
|
|
148
|
+
*/
|
|
149
|
+
const getUpload = useCallback((uploadId: string): UploadProgressInfo | undefined => {
|
|
150
|
+
return uploaderRef.current?.getUpload(uploadId);
|
|
151
|
+
}, []);
|
|
152
|
+
|
|
153
|
+
return {
|
|
154
|
+
queueStatus,
|
|
155
|
+
uploads,
|
|
156
|
+
isUploading: queueStatus.isProcessing,
|
|
157
|
+
isPaused: queueStatus.isPaused,
|
|
158
|
+
hasFailedUploads: queueStatus.failed > 0,
|
|
159
|
+
addFiles,
|
|
160
|
+
start,
|
|
161
|
+
pause,
|
|
162
|
+
resume,
|
|
163
|
+
cancel,
|
|
164
|
+
cancelAll,
|
|
165
|
+
retry,
|
|
166
|
+
retryAll,
|
|
167
|
+
remove,
|
|
168
|
+
clearCompleted,
|
|
169
|
+
getUpload,
|
|
170
|
+
uploaderRef,
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createUseFilePickerHook } from './createUseFilePickerHook';
|
|
2
|
+
import { createUseFileUploadHook } from './createUseFileUploadHook';
|
|
3
|
+
import { createFilePicker } from '../picker/FilePicker.native';
|
|
4
|
+
import { createFileUploader } from '../uploader/FileUploader.native';
|
|
5
|
+
|
|
6
|
+
// Export hook factories
|
|
7
|
+
export { createUseFilePickerHook } from './createUseFilePickerHook';
|
|
8
|
+
export { createUseFileUploadHook } from './createUseFileUploadHook';
|
|
9
|
+
|
|
10
|
+
// Create and export hooks with native-specific factories
|
|
11
|
+
export const useFilePicker = createUseFilePickerHook(createFilePicker);
|
|
12
|
+
export const useFileUpload = createUseFileUploadHook(createFileUploader);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createUseFilePickerHook } from './createUseFilePickerHook';
|
|
2
|
+
import { createUseFileUploadHook } from './createUseFileUploadHook';
|
|
3
|
+
import { createFilePicker } from '../picker';
|
|
4
|
+
import { createFileUploader } from '../uploader';
|
|
5
|
+
|
|
6
|
+
// Export hook factories
|
|
7
|
+
export { createUseFilePickerHook } from './createUseFilePickerHook';
|
|
8
|
+
export { createUseFileUploadHook } from './createUseFileUploadHook';
|
|
9
|
+
|
|
10
|
+
// Create and export hooks with platform-specific factories
|
|
11
|
+
export const useFilePicker = createUseFilePickerHook(createFilePicker);
|
|
12
|
+
export const useFileUpload = createUseFileUploadHook(createFileUploader);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createUseFilePickerHook } from './createUseFilePickerHook';
|
|
2
|
+
import { createUseFileUploadHook } from './createUseFileUploadHook';
|
|
3
|
+
import { createFilePicker } from '../picker/FilePicker.web';
|
|
4
|
+
import { createFileUploader } from '../uploader/FileUploader.web';
|
|
5
|
+
|
|
6
|
+
// Export hook factories
|
|
7
|
+
export { createUseFilePickerHook } from './createUseFilePickerHook';
|
|
8
|
+
export { createUseFileUploadHook } from './createUseFileUploadHook';
|
|
9
|
+
|
|
10
|
+
// Create and export hooks with web-specific factories
|
|
11
|
+
export const useFilePicker = createUseFilePickerHook(createFilePicker);
|
|
12
|
+
export const useFileUpload = createUseFileUploadHook(createFileUploader);
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
// Types - re-export everything from main types
|
|
2
|
+
export type {
|
|
3
|
+
// File types
|
|
4
|
+
FileType,
|
|
5
|
+
PickedFile,
|
|
6
|
+
FilePickerConfig,
|
|
7
|
+
FilePickerResult,
|
|
8
|
+
ValidationResult,
|
|
9
|
+
RejectedFile,
|
|
10
|
+
RejectionReason,
|
|
11
|
+
|
|
12
|
+
// Camera types
|
|
13
|
+
CameraMediaType,
|
|
14
|
+
CameraOptions,
|
|
15
|
+
|
|
16
|
+
// Picker types
|
|
17
|
+
FilePickerState,
|
|
18
|
+
FilePickerStatus,
|
|
19
|
+
IFilePicker,
|
|
20
|
+
|
|
21
|
+
// Upload types
|
|
22
|
+
UploadMethod,
|
|
23
|
+
RetryDelayStrategy,
|
|
24
|
+
UploadConfig,
|
|
25
|
+
UploadState,
|
|
26
|
+
UploadProgressInfo,
|
|
27
|
+
UploadResult,
|
|
28
|
+
QueueStatus,
|
|
29
|
+
IFileUploader,
|
|
30
|
+
|
|
31
|
+
// Error types
|
|
32
|
+
FilePickerErrorCode,
|
|
33
|
+
FilePickerError,
|
|
34
|
+
UploadErrorCode,
|
|
35
|
+
UploadError,
|
|
36
|
+
|
|
37
|
+
// Permission types
|
|
38
|
+
PermissionStatus,
|
|
39
|
+
PermissionResult,
|
|
40
|
+
|
|
41
|
+
// Hook types
|
|
42
|
+
UseFilePickerOptions,
|
|
43
|
+
UseFilePickerResult,
|
|
44
|
+
UseFileUploadOptions,
|
|
45
|
+
UseFileUploadResult,
|
|
46
|
+
|
|
47
|
+
// Component types
|
|
48
|
+
ButtonVariant,
|
|
49
|
+
Size,
|
|
50
|
+
Intent,
|
|
51
|
+
FilePickerButtonProps,
|
|
52
|
+
DropZoneState,
|
|
53
|
+
DropZoneProps,
|
|
54
|
+
ProgressVariant,
|
|
55
|
+
UploadProgressProps,
|
|
56
|
+
|
|
57
|
+
// Preset types
|
|
58
|
+
FilePickerPresets,
|
|
59
|
+
UploadPresets,
|
|
60
|
+
|
|
61
|
+
// Factory types
|
|
62
|
+
CreateFilePickerFactory,
|
|
63
|
+
CreateFileUploaderFactory,
|
|
64
|
+
CreateFileUploaderOptions,
|
|
65
|
+
|
|
66
|
+
// Chunked upload types
|
|
67
|
+
ChunkProgress,
|
|
68
|
+
ChunkUploadConfig,
|
|
69
|
+
ChunkUploadResponse,
|
|
70
|
+
} from './types';
|
|
71
|
+
|
|
72
|
+
// Constants
|
|
73
|
+
export {
|
|
74
|
+
FILE_TYPE_MIME_TYPES,
|
|
75
|
+
FILE_TYPE_EXTENSIONS,
|
|
76
|
+
DOCUMENT_PICKER_TYPES,
|
|
77
|
+
DEFAULT_FILE_PICKER_CONFIG,
|
|
78
|
+
DEFAULT_UPLOAD_CONFIG,
|
|
79
|
+
INITIAL_FILE_PICKER_STATUS,
|
|
80
|
+
INITIAL_QUEUE_STATUS,
|
|
81
|
+
FILE_PICKER_PRESETS,
|
|
82
|
+
UPLOAD_PRESETS,
|
|
83
|
+
SIZE_LIMITS,
|
|
84
|
+
TIMING,
|
|
85
|
+
FILE_PICKER_ERROR_MESSAGES,
|
|
86
|
+
UPLOAD_ERROR_MESSAGES,
|
|
87
|
+
} from './constants';
|
|
88
|
+
|
|
89
|
+
// Utilities
|
|
90
|
+
export {
|
|
91
|
+
generateId,
|
|
92
|
+
formatBytes,
|
|
93
|
+
parseSize,
|
|
94
|
+
formatDuration,
|
|
95
|
+
getMimeTypes,
|
|
96
|
+
getExtensions,
|
|
97
|
+
buildAcceptString,
|
|
98
|
+
getFileExtension,
|
|
99
|
+
getFileTypeFromMime,
|
|
100
|
+
isMimeTypeAllowed,
|
|
101
|
+
validateFiles,
|
|
102
|
+
createPickedFileFromFile,
|
|
103
|
+
revokeFileUri,
|
|
104
|
+
revokeFileUris,
|
|
105
|
+
createFilePickerError,
|
|
106
|
+
createUploadError,
|
|
107
|
+
mergeFilePickerConfig,
|
|
108
|
+
mergeUploadConfig,
|
|
109
|
+
SpeedCalculator,
|
|
110
|
+
calculateETA,
|
|
111
|
+
calculateRetryDelay,
|
|
112
|
+
isRetryableError,
|
|
113
|
+
calculateChunkCount,
|
|
114
|
+
getChunkBoundaries,
|
|
115
|
+
shouldUseChunkedUpload,
|
|
116
|
+
EventEmitter,
|
|
117
|
+
} from './utils';
|
|
118
|
+
|
|
119
|
+
// Permissions (native-specific)
|
|
120
|
+
export {
|
|
121
|
+
checkPhotoLibraryPermission,
|
|
122
|
+
requestPhotoLibraryPermission,
|
|
123
|
+
checkCameraPermission,
|
|
124
|
+
requestCameraPermission,
|
|
125
|
+
checkPermissions,
|
|
126
|
+
requestPermissions,
|
|
127
|
+
} from './permissions/index.native';
|
|
128
|
+
|
|
129
|
+
// Picker (native-specific)
|
|
130
|
+
export { createFilePicker, NativeFilePicker } from './picker/index.native';
|
|
131
|
+
|
|
132
|
+
// Uploader (native-specific)
|
|
133
|
+
export { UploadQueue, ChunkedUploader, createChunkedUploader, createFileUploader, NativeFileUploader } from './uploader/index.native';
|
|
134
|
+
|
|
135
|
+
// Hooks (native-specific)
|
|
136
|
+
export { useFilePicker, useFileUpload, createUseFilePickerHook, createUseFileUploadHook } from './hooks/index.native';
|
|
137
|
+
|
|
138
|
+
// Components (native-specific)
|
|
139
|
+
export { FilePickerButton, DropZone, UploadProgress } from './components/index.native';
|
|
140
|
+
|
|
141
|
+
// Styles
|
|
142
|
+
export { filePickerButtonStyles, dropZoneStyles, uploadProgressStyles } from './components/index.native';
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
// Types
|
|
2
|
+
export type {
|
|
3
|
+
// File types
|
|
4
|
+
FileType,
|
|
5
|
+
PickedFile,
|
|
6
|
+
FilePickerConfig,
|
|
7
|
+
FilePickerResult,
|
|
8
|
+
ValidationResult,
|
|
9
|
+
RejectedFile,
|
|
10
|
+
RejectionReason,
|
|
11
|
+
|
|
12
|
+
// Camera types
|
|
13
|
+
CameraMediaType,
|
|
14
|
+
CameraOptions,
|
|
15
|
+
|
|
16
|
+
// Picker types
|
|
17
|
+
FilePickerState,
|
|
18
|
+
FilePickerStatus,
|
|
19
|
+
IFilePicker,
|
|
20
|
+
|
|
21
|
+
// Upload types
|
|
22
|
+
UploadMethod,
|
|
23
|
+
RetryDelayStrategy,
|
|
24
|
+
UploadConfig,
|
|
25
|
+
UploadState,
|
|
26
|
+
UploadProgressInfo,
|
|
27
|
+
UploadResult,
|
|
28
|
+
QueueStatus,
|
|
29
|
+
IFileUploader,
|
|
30
|
+
|
|
31
|
+
// Error types
|
|
32
|
+
FilePickerErrorCode,
|
|
33
|
+
FilePickerError,
|
|
34
|
+
UploadErrorCode,
|
|
35
|
+
UploadError,
|
|
36
|
+
|
|
37
|
+
// Permission types
|
|
38
|
+
PermissionStatus,
|
|
39
|
+
PermissionResult,
|
|
40
|
+
|
|
41
|
+
// Hook types
|
|
42
|
+
UseFilePickerOptions,
|
|
43
|
+
UseFilePickerResult,
|
|
44
|
+
UseFileUploadOptions,
|
|
45
|
+
UseFileUploadResult,
|
|
46
|
+
|
|
47
|
+
// Component types
|
|
48
|
+
ButtonVariant,
|
|
49
|
+
Size,
|
|
50
|
+
Intent,
|
|
51
|
+
FilePickerButtonProps,
|
|
52
|
+
DropZoneState,
|
|
53
|
+
DropZoneProps,
|
|
54
|
+
ProgressVariant,
|
|
55
|
+
UploadProgressProps,
|
|
56
|
+
|
|
57
|
+
// Preset types
|
|
58
|
+
FilePickerPresets,
|
|
59
|
+
UploadPresets,
|
|
60
|
+
|
|
61
|
+
// Factory types
|
|
62
|
+
CreateFilePickerFactory,
|
|
63
|
+
CreateFileUploaderFactory,
|
|
64
|
+
CreateFileUploaderOptions,
|
|
65
|
+
|
|
66
|
+
// Chunked upload types
|
|
67
|
+
ChunkProgress,
|
|
68
|
+
ChunkUploadConfig,
|
|
69
|
+
ChunkUploadResponse,
|
|
70
|
+
} from './types';
|
|
71
|
+
|
|
72
|
+
// Constants
|
|
73
|
+
export {
|
|
74
|
+
FILE_TYPE_MIME_TYPES,
|
|
75
|
+
FILE_TYPE_EXTENSIONS,
|
|
76
|
+
DOCUMENT_PICKER_TYPES,
|
|
77
|
+
DEFAULT_FILE_PICKER_CONFIG,
|
|
78
|
+
DEFAULT_UPLOAD_CONFIG,
|
|
79
|
+
INITIAL_FILE_PICKER_STATUS,
|
|
80
|
+
INITIAL_QUEUE_STATUS,
|
|
81
|
+
FILE_PICKER_PRESETS,
|
|
82
|
+
UPLOAD_PRESETS,
|
|
83
|
+
SIZE_LIMITS,
|
|
84
|
+
TIMING,
|
|
85
|
+
FILE_PICKER_ERROR_MESSAGES,
|
|
86
|
+
UPLOAD_ERROR_MESSAGES,
|
|
87
|
+
} from './constants';
|
|
88
|
+
|
|
89
|
+
// Utilities
|
|
90
|
+
export {
|
|
91
|
+
generateId,
|
|
92
|
+
formatBytes,
|
|
93
|
+
parseSize,
|
|
94
|
+
formatDuration,
|
|
95
|
+
getMimeTypes,
|
|
96
|
+
getExtensions,
|
|
97
|
+
buildAcceptString,
|
|
98
|
+
getFileExtension,
|
|
99
|
+
getFileTypeFromMime,
|
|
100
|
+
isMimeTypeAllowed,
|
|
101
|
+
validateFiles,
|
|
102
|
+
createPickedFileFromFile,
|
|
103
|
+
revokeFileUri,
|
|
104
|
+
revokeFileUris,
|
|
105
|
+
createFilePickerError,
|
|
106
|
+
createUploadError,
|
|
107
|
+
mergeFilePickerConfig,
|
|
108
|
+
mergeUploadConfig,
|
|
109
|
+
SpeedCalculator,
|
|
110
|
+
calculateETA,
|
|
111
|
+
calculateRetryDelay,
|
|
112
|
+
isRetryableError,
|
|
113
|
+
calculateChunkCount,
|
|
114
|
+
getChunkBoundaries,
|
|
115
|
+
shouldUseChunkedUpload,
|
|
116
|
+
EventEmitter,
|
|
117
|
+
} from './utils';
|
|
118
|
+
|
|
119
|
+
// Permissions
|
|
120
|
+
export {
|
|
121
|
+
checkPhotoLibraryPermission,
|
|
122
|
+
requestPhotoLibraryPermission,
|
|
123
|
+
checkCameraPermission,
|
|
124
|
+
requestCameraPermission,
|
|
125
|
+
checkPermissions,
|
|
126
|
+
requestPermissions,
|
|
127
|
+
} from './permissions';
|
|
128
|
+
|
|
129
|
+
// Picker
|
|
130
|
+
export { createFilePicker } from './picker';
|
|
131
|
+
|
|
132
|
+
// Uploader
|
|
133
|
+
export { UploadQueue, ChunkedUploader, createChunkedUploader, createFileUploader } from './uploader';
|
|
134
|
+
|
|
135
|
+
// Hooks
|
|
136
|
+
export { useFilePicker, useFileUpload, createUseFilePickerHook, createUseFileUploadHook } from './hooks';
|
|
137
|
+
|
|
138
|
+
// Styles (components are platform-specific, exported from index.web.ts and index.native.ts)
|
|
139
|
+
export { filePickerButtonStyles, dropZoneStyles, uploadProgressStyles } from './components';
|
package/src/index.web.ts
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
// Types - re-export everything from main types
|
|
2
|
+
export type {
|
|
3
|
+
// File types
|
|
4
|
+
FileType,
|
|
5
|
+
PickedFile,
|
|
6
|
+
FilePickerConfig,
|
|
7
|
+
FilePickerResult,
|
|
8
|
+
ValidationResult,
|
|
9
|
+
RejectedFile,
|
|
10
|
+
RejectionReason,
|
|
11
|
+
|
|
12
|
+
// Camera types
|
|
13
|
+
CameraMediaType,
|
|
14
|
+
CameraOptions,
|
|
15
|
+
|
|
16
|
+
// Picker types
|
|
17
|
+
FilePickerState,
|
|
18
|
+
FilePickerStatus,
|
|
19
|
+
IFilePicker,
|
|
20
|
+
|
|
21
|
+
// Upload types
|
|
22
|
+
UploadMethod,
|
|
23
|
+
RetryDelayStrategy,
|
|
24
|
+
UploadConfig,
|
|
25
|
+
UploadState,
|
|
26
|
+
UploadProgressInfo,
|
|
27
|
+
UploadResult,
|
|
28
|
+
QueueStatus,
|
|
29
|
+
IFileUploader,
|
|
30
|
+
|
|
31
|
+
// Error types
|
|
32
|
+
FilePickerErrorCode,
|
|
33
|
+
FilePickerError,
|
|
34
|
+
UploadErrorCode,
|
|
35
|
+
UploadError,
|
|
36
|
+
|
|
37
|
+
// Permission types
|
|
38
|
+
PermissionStatus,
|
|
39
|
+
PermissionResult,
|
|
40
|
+
|
|
41
|
+
// Hook types
|
|
42
|
+
UseFilePickerOptions,
|
|
43
|
+
UseFilePickerResult,
|
|
44
|
+
UseFileUploadOptions,
|
|
45
|
+
UseFileUploadResult,
|
|
46
|
+
|
|
47
|
+
// Component types
|
|
48
|
+
ButtonVariant,
|
|
49
|
+
Size,
|
|
50
|
+
Intent,
|
|
51
|
+
FilePickerButtonProps,
|
|
52
|
+
DropZoneState,
|
|
53
|
+
DropZoneProps,
|
|
54
|
+
ProgressVariant,
|
|
55
|
+
UploadProgressProps,
|
|
56
|
+
|
|
57
|
+
// Preset types
|
|
58
|
+
FilePickerPresets,
|
|
59
|
+
UploadPresets,
|
|
60
|
+
|
|
61
|
+
// Factory types
|
|
62
|
+
CreateFilePickerFactory,
|
|
63
|
+
CreateFileUploaderFactory,
|
|
64
|
+
CreateFileUploaderOptions,
|
|
65
|
+
|
|
66
|
+
// Chunked upload types
|
|
67
|
+
ChunkProgress,
|
|
68
|
+
ChunkUploadConfig,
|
|
69
|
+
ChunkUploadResponse,
|
|
70
|
+
} from './types';
|
|
71
|
+
|
|
72
|
+
// Constants
|
|
73
|
+
export {
|
|
74
|
+
FILE_TYPE_MIME_TYPES,
|
|
75
|
+
FILE_TYPE_EXTENSIONS,
|
|
76
|
+
DOCUMENT_PICKER_TYPES,
|
|
77
|
+
DEFAULT_FILE_PICKER_CONFIG,
|
|
78
|
+
DEFAULT_UPLOAD_CONFIG,
|
|
79
|
+
INITIAL_FILE_PICKER_STATUS,
|
|
80
|
+
INITIAL_QUEUE_STATUS,
|
|
81
|
+
FILE_PICKER_PRESETS,
|
|
82
|
+
UPLOAD_PRESETS,
|
|
83
|
+
SIZE_LIMITS,
|
|
84
|
+
TIMING,
|
|
85
|
+
FILE_PICKER_ERROR_MESSAGES,
|
|
86
|
+
UPLOAD_ERROR_MESSAGES,
|
|
87
|
+
} from './constants';
|
|
88
|
+
|
|
89
|
+
// Utilities
|
|
90
|
+
export {
|
|
91
|
+
generateId,
|
|
92
|
+
formatBytes,
|
|
93
|
+
parseSize,
|
|
94
|
+
formatDuration,
|
|
95
|
+
getMimeTypes,
|
|
96
|
+
getExtensions,
|
|
97
|
+
buildAcceptString,
|
|
98
|
+
getFileExtension,
|
|
99
|
+
getFileTypeFromMime,
|
|
100
|
+
isMimeTypeAllowed,
|
|
101
|
+
validateFiles,
|
|
102
|
+
createPickedFileFromFile,
|
|
103
|
+
revokeFileUri,
|
|
104
|
+
revokeFileUris,
|
|
105
|
+
createFilePickerError,
|
|
106
|
+
createUploadError,
|
|
107
|
+
mergeFilePickerConfig,
|
|
108
|
+
mergeUploadConfig,
|
|
109
|
+
SpeedCalculator,
|
|
110
|
+
calculateETA,
|
|
111
|
+
calculateRetryDelay,
|
|
112
|
+
isRetryableError,
|
|
113
|
+
calculateChunkCount,
|
|
114
|
+
getChunkBoundaries,
|
|
115
|
+
shouldUseChunkedUpload,
|
|
116
|
+
EventEmitter,
|
|
117
|
+
} from './utils';
|
|
118
|
+
|
|
119
|
+
// Permissions (web-specific)
|
|
120
|
+
export {
|
|
121
|
+
checkPhotoLibraryPermission,
|
|
122
|
+
requestPhotoLibraryPermission,
|
|
123
|
+
checkCameraPermission,
|
|
124
|
+
requestCameraPermission,
|
|
125
|
+
checkPermissions,
|
|
126
|
+
requestPermissions,
|
|
127
|
+
} from './permissions/index.web';
|
|
128
|
+
|
|
129
|
+
// Picker (web-specific)
|
|
130
|
+
export { createFilePicker, WebFilePicker } from './picker/index.web';
|
|
131
|
+
|
|
132
|
+
// Uploader (web-specific)
|
|
133
|
+
export { UploadQueue, ChunkedUploader, createChunkedUploader, createFileUploader, WebFileUploader } from './uploader/index.web';
|
|
134
|
+
|
|
135
|
+
// Hooks (web-specific)
|
|
136
|
+
export { useFilePicker, useFileUpload, createUseFilePickerHook, createUseFileUploadHook } from './hooks/index.web';
|
|
137
|
+
|
|
138
|
+
// Components (web-specific)
|
|
139
|
+
export { FilePickerButton, DropZone, UploadProgress } from './components/index.web';
|
|
140
|
+
|
|
141
|
+
// Styles
|
|
142
|
+
export { filePickerButtonStyles, dropZoneStyles, uploadProgressStyles } from './components/index.web';
|