@useupup/core 3.3.0
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/LICENSE +21 -0
- package/NOTICE +8 -0
- package/README.md +75 -0
- package/dist/browser-SXR426OQ.cjs +10 -0
- package/dist/browser-WD6T5ABJ.js +1 -0
- package/dist/chunk-2H5ICKFT.cjs +122 -0
- package/dist/chunk-6HF3I2JS.cjs +39 -0
- package/dist/chunk-6S5DQDQH.js +212 -0
- package/dist/chunk-BMQC27OE.cjs +92 -0
- package/dist/chunk-BSGQGINR.cjs +219 -0
- package/dist/chunk-CPKZ2CXD.cjs +179 -0
- package/dist/chunk-DTKDIMKT.cjs +573 -0
- package/dist/chunk-DYE5XJ6Z.cjs +2134 -0
- package/dist/chunk-E3ZCNOXG.cjs +74 -0
- package/dist/chunk-FEQY2WYY.cjs +2377 -0
- package/dist/chunk-FMURBCZ7.js +120 -0
- package/dist/chunk-FYQQRULL.js +37 -0
- package/dist/chunk-GE4LIVXP.js +133 -0
- package/dist/chunk-HFR5HZJZ.js +56 -0
- package/dist/chunk-I7ULPCA2.js +72 -0
- package/dist/chunk-MHYXDLZR.js +569 -0
- package/dist/chunk-N2SLHVAW.cjs +61 -0
- package/dist/chunk-OOPDEOTM.js +169 -0
- package/dist/chunk-PMBR3OUW.js +2359 -0
- package/dist/chunk-QK7HZIVY.cjs +144 -0
- package/dist/chunk-T2AQHY7V.cjs +59 -0
- package/dist/chunk-TRCP5FUR.js +90 -0
- package/dist/chunk-U7KL5M2H.cjs +374 -0
- package/dist/chunk-UXNPM54W.js +2108 -0
- package/dist/chunk-VV6QCQLL.js +365 -0
- package/dist/chunk-ZMS2HXLB.js +56 -0
- package/dist/context-shapes-123dd3b6.d.cts +207 -0
- package/dist/context-shapes-27b24c8f.d.ts +207 -0
- package/dist/contracts-pipeline-cf177270.d.cts +78 -0
- package/dist/contracts-pipeline-cf177270.d.ts +78 -0
- package/dist/contracts-strategies-378a16b7.d.cts +168 -0
- package/dist/contracts-strategies-378a16b7.d.ts +168 -0
- package/dist/contracts.cjs +181 -0
- package/dist/contracts.d.cts +11 -0
- package/dist/contracts.d.ts +11 -0
- package/dist/contracts.js +4 -0
- package/dist/core-141335ac.d.ts +651 -0
- package/dist/core-bea2ceca.d.cts +651 -0
- package/dist/create-worker-provider-AA5SRII6.js +58 -0
- package/dist/create-worker-provider-KJNUSSTW.cjs +60 -0
- package/dist/eligibility-ONLNJ6FB.cjs +10 -0
- package/dist/eligibility-ULFC3E4G.js +8 -0
- package/dist/error-code-map-9c44a425.d.ts +62 -0
- package/dist/error-code-map-dd5becfa.d.cts +62 -0
- package/dist/i18n/index.cjs +90 -0
- package/dist/i18n/index.d.cts +3 -0
- package/dist/i18n/index.d.ts +3 -0
- package/dist/i18n/index.js +1 -0
- package/dist/index.cjs +1770 -0
- package/dist/index.d.cts +280 -0
- package/dist/index.d.ts +280 -0
- package/dist/index.js +1589 -0
- package/dist/internal.cjs +2407 -0
- package/dist/internal.d.cts +595 -0
- package/dist/internal.d.ts +595 -0
- package/dist/internal.js +2275 -0
- package/dist/pipeline/index.cjs +10 -0
- package/dist/pipeline/index.d.cts +11 -0
- package/dist/pipeline/index.d.ts +11 -0
- package/dist/pipeline/index.js +1 -0
- package/dist/pipeline-worker.cjs +199 -0
- package/dist/pipeline-worker.d.cts +2 -0
- package/dist/pipeline-worker.d.ts +2 -0
- package/dist/pipeline-worker.js +197 -0
- package/dist/resolve-locale-81feef21.d.ts +20 -0
- package/dist/resolve-locale-9cb63600.d.cts +20 -0
- package/dist/resolve-theme-01758105.d.ts +53 -0
- package/dist/resolve-theme-66cf8d98.d.cts +53 -0
- package/dist/server-mode-drive-controller-b5f8ee12.d.cts +180 -0
- package/dist/server-mode-drive-controller-b5f8ee12.d.ts +180 -0
- package/dist/steps/compress.cjs +66 -0
- package/dist/steps/compress.d.cts +10 -0
- package/dist/steps/compress.d.ts +10 -0
- package/dist/steps/compress.js +64 -0
- package/dist/steps/exif.cjs +44 -0
- package/dist/steps/exif.d.cts +5 -0
- package/dist/steps/exif.d.ts +5 -0
- package/dist/steps/exif.js +42 -0
- package/dist/steps/hash.cjs +44 -0
- package/dist/steps/hash.d.cts +5 -0
- package/dist/steps/hash.d.ts +5 -0
- package/dist/steps/hash.js +42 -0
- package/dist/steps/heic.cjs +59 -0
- package/dist/steps/heic.d.cts +5 -0
- package/dist/steps/heic.d.ts +5 -0
- package/dist/steps/heic.js +57 -0
- package/dist/steps/thumbnail.cjs +54 -0
- package/dist/steps/thumbnail.d.cts +10 -0
- package/dist/steps/thumbnail.d.ts +10 -0
- package/dist/steps/thumbnail.js +52 -0
- package/dist/strategies/index.cjs +82 -0
- package/dist/strategies/index.d.cts +187 -0
- package/dist/strategies/index.d.ts +187 -0
- package/dist/strategies/index.js +60 -0
- package/dist/strategies/tus-upload.cjs +14 -0
- package/dist/strategies/tus-upload.d.cts +15 -0
- package/dist/strategies/tus-upload.d.ts +15 -0
- package/dist/strategies/tus-upload.js +5 -0
- package/dist/theme/index.cjs +38 -0
- package/dist/theme/index.d.cts +3 -0
- package/dist/theme/index.d.ts +3 -0
- package/dist/theme/index.js +1 -0
- package/dist/theme-store-2e56a674.d.cts +39 -0
- package/dist/theme-store-f13e0315.d.ts +39 -0
- package/dist/token-endpoint-5fdb4a35.d.ts +20 -0
- package/dist/token-endpoint-a7d15ab6.d.cts +20 -0
- package/dist/ui-translations-c5d00392.d.cts +455 -0
- package/dist/ui-translations-c5d00392.d.ts +455 -0
- package/dist/uploader-props-72242002.d.ts +340 -0
- package/dist/uploader-props-7f956e60.d.cts +340 -0
- package/dist/vars-d3421f6c.d.cts +240 -0
- package/dist/vars-d3421f6c.d.ts +240 -0
- package/package.json +182 -0
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { a as UploadFile, c as UploadStatus, F as FileSource } from './contracts-pipeline-cf177270.js';
|
|
2
|
+
import { F as FilesProgressMap, R as ResolvedImageEditorOptions, U as UpupCore, b as CloudDrivesConfig } from './core-141335ac.js';
|
|
3
|
+
import { c as Translations, T as Translator } from './ui-translations-c5d00392.js';
|
|
4
|
+
import { e as UpupThemeMode, d as UpupThemeTokens, I as InternalFlatClassNames, l as DeepPartialSlots, g as UpupResolvedTheme } from './vars-d3421f6c.js';
|
|
5
|
+
|
|
6
|
+
interface UploadProgressInfo {
|
|
7
|
+
loaded: number;
|
|
8
|
+
total: number;
|
|
9
|
+
percentage: number;
|
|
10
|
+
}
|
|
11
|
+
interface OrchestratorState {
|
|
12
|
+
files: Map<string, UploadFile>;
|
|
13
|
+
uploadStatus: UploadStatus;
|
|
14
|
+
uploadError: string;
|
|
15
|
+
/** Machine code from a typed UpupError (e.g. 'SignatureDoesNotMatch', 'bad_signature'), when the failure carried one. */
|
|
16
|
+
uploadErrorCode?: string | undefined;
|
|
17
|
+
totalProgress: number;
|
|
18
|
+
filesProgressMap: FilesProgressMap;
|
|
19
|
+
uploadSpeed: number;
|
|
20
|
+
uploadEta: number;
|
|
21
|
+
uploadedBytes: number;
|
|
22
|
+
totalBytes: number;
|
|
23
|
+
activeSource?: FileSource | undefined;
|
|
24
|
+
editingFile: UploadFile | null;
|
|
25
|
+
editorQueue: UploadFile[];
|
|
26
|
+
isAddingMore: boolean;
|
|
27
|
+
viewMode: 'grid' | 'list';
|
|
28
|
+
isOnline: boolean;
|
|
29
|
+
}
|
|
30
|
+
interface OrchestratorCallbacks {
|
|
31
|
+
onError?: ((message: string) => void) | undefined;
|
|
32
|
+
onWarn?: ((message: string) => void) | undefined;
|
|
33
|
+
onUploadComplete?: ((files: UploadFile[]) => void) | undefined;
|
|
34
|
+
onUploadStart?: (() => void) | undefined;
|
|
35
|
+
onFileUploadStart?: ((file: UploadFile) => void) | undefined;
|
|
36
|
+
onFileUploadProgress?: ((file: UploadFile, progress: UploadProgressInfo) => void) | undefined;
|
|
37
|
+
onFileUploadComplete?: ((file: UploadFile, key: string) => void) | undefined;
|
|
38
|
+
onFilesUploadProgress?: ((completedFiles: number, totalFiles: number) => void) | undefined;
|
|
39
|
+
onFilesUploadComplete?: ((files: UploadFile[]) => void) | undefined;
|
|
40
|
+
onFileRemoved?: ((file: UploadFile) => void) | undefined;
|
|
41
|
+
onFilesSelected?: ((files: UploadFile[]) => void) | undefined;
|
|
42
|
+
onFileDrop?: ((files: File[]) => void) | undefined;
|
|
43
|
+
onDoneClicked?: (() => void) | undefined;
|
|
44
|
+
onPrepareFiles?: ((files: UploadFile[]) => Promise<UploadFile[] | File[]> | UploadFile[] | File[]) | undefined;
|
|
45
|
+
imageEditorOptions?: ResolvedImageEditorOptions | undefined;
|
|
46
|
+
/** When true, triggers upload automatically after files are added. */
|
|
47
|
+
autoUpload?: boolean | undefined;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
declare class UploaderOrchestrator {
|
|
51
|
+
private state;
|
|
52
|
+
private listeners;
|
|
53
|
+
private core;
|
|
54
|
+
private callbacks;
|
|
55
|
+
private unsubs;
|
|
56
|
+
private disposed;
|
|
57
|
+
constructor(core: UpupCore, callbacks: OrchestratorCallbacks);
|
|
58
|
+
/** useSyncExternalStore-compatible subscribe (bound). */
|
|
59
|
+
subscribe: (listener: () => void) => (() => void);
|
|
60
|
+
/** useSyncExternalStore-compatible getSnapshot (bound). */
|
|
61
|
+
getSnapshot: () => OrchestratorState;
|
|
62
|
+
protected setState(partial: Partial<OrchestratorState>): void;
|
|
63
|
+
private notify;
|
|
64
|
+
/** Remove a file by id: revoke its blob URL, then delegate to core. */
|
|
65
|
+
removeFile(fileId: string): void;
|
|
66
|
+
/** Set the active upload source. */
|
|
67
|
+
setActiveSource(source: FileSource | undefined): void;
|
|
68
|
+
/** Toggle between grid and list view. */
|
|
69
|
+
setViewMode(mode: 'grid' | 'list'): void;
|
|
70
|
+
/** Toggle the "adding more files" state. */
|
|
71
|
+
setIsAddingMore(value: boolean): void;
|
|
72
|
+
/** Trigger upload for all current files. Calls onPrepareFiles if provided. */
|
|
73
|
+
startUpload(): Promise<UploadFile[] | undefined>;
|
|
74
|
+
/** Retry upload for a specific file or all failed files. */
|
|
75
|
+
retryUpload(fileId?: string): Promise<UploadFile[] | undefined>;
|
|
76
|
+
/** Cancel in-progress upload, revoke blob URLs, clear all files and progress. */
|
|
77
|
+
handleCancel(): void;
|
|
78
|
+
/** Pause in-progress upload. */
|
|
79
|
+
handlePause(): void;
|
|
80
|
+
/** Resume paused upload. */
|
|
81
|
+
handleResume(): void;
|
|
82
|
+
/** Mark upload as done: invoke callback, emit event, then cancel/clear. */
|
|
83
|
+
handleDone(): void;
|
|
84
|
+
/** Full state reset: clear isAddingMore, emit state-reset, then handleDone. */
|
|
85
|
+
resetState(): void;
|
|
86
|
+
/** Open the image editor for a given file. Invokes onOpen callback and emits event. */
|
|
87
|
+
openImageEditor(file: UploadFile): void;
|
|
88
|
+
/**
|
|
89
|
+
* Close the image editor without saving. Invokes onCancel callback.
|
|
90
|
+
* If the editor queue is non-empty, the next file is automatically opened.
|
|
91
|
+
*/
|
|
92
|
+
closeImageEditor(): void;
|
|
93
|
+
/**
|
|
94
|
+
* Save an edited image. Converts the data URL to a blob, creates a new
|
|
95
|
+
* UploadFile preserving the original's identity, replaces it in state
|
|
96
|
+
* and core, then invokes the onSave callback.
|
|
97
|
+
*/
|
|
98
|
+
saveImageEdit(editedImageData: string, mimeType?: string): void;
|
|
99
|
+
/** Replace a single file in state by id (revokes old blob URL). Also replaces in core. */
|
|
100
|
+
replaceFile(fileId: string, newFile: UploadFile): void;
|
|
101
|
+
/** Enqueue files for auto-opening in the image editor. */
|
|
102
|
+
enqueueForEditor(files: UploadFile[]): void;
|
|
103
|
+
/** Pop the next file from the editor queue and open it. */
|
|
104
|
+
private processEditorQueue;
|
|
105
|
+
private speedSamples;
|
|
106
|
+
/**
|
|
107
|
+
* Project orchestrator state from core — the single source of truth (F-145).
|
|
108
|
+
* `uploadStatus` is derived from the `status` each status-carrying `state-change`
|
|
109
|
+
* event supplies (core sets `_status` before every such emit); the discrete
|
|
110
|
+
* upload-start/upload-all-complete/upload-error listeners no longer write it. `files`
|
|
111
|
+
* is rebuilt from `core.files`, and is a no-op when the file set is unchanged (same
|
|
112
|
+
* size + ordered ids + same UploadFile refs) so the `files` reference stays stable
|
|
113
|
+
* across the many status-only `state-change` events core emits during upload —
|
|
114
|
+
* preserving referential stability for useSyncExternalStore / computed consumers.
|
|
115
|
+
*/
|
|
116
|
+
private projectFromCore;
|
|
117
|
+
private filesProjectionChanged;
|
|
118
|
+
init(): void;
|
|
119
|
+
destroy(): void;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Base context shape types shared across the framework bindings.
|
|
124
|
+
*
|
|
125
|
+
* Each framework package defines its own concrete context types that extend
|
|
126
|
+
* these bases with framework-specific fields (e.g. React refs, Vue refs,
|
|
127
|
+
* Dispatch<SetStateAction<...>> vs plain setters).
|
|
128
|
+
*
|
|
129
|
+
* This file intentionally uses plain function signatures for state setters
|
|
130
|
+
* so both React (Dispatch<SetStateAction<T>>) and Vue ((v: T) => void) are
|
|
131
|
+
* compatible supertypes.
|
|
132
|
+
*/
|
|
133
|
+
|
|
134
|
+
type BaseContextUpload = {
|
|
135
|
+
uploadStatus: UploadStatus;
|
|
136
|
+
uploadError?: string | undefined;
|
|
137
|
+
/** Machine code from a typed UpupError, when the failure carried one. */
|
|
138
|
+
uploadErrorCode?: string | undefined;
|
|
139
|
+
totalProgress: number;
|
|
140
|
+
filesProgressMap: FilesProgressMap;
|
|
141
|
+
startUpload: () => Promise<UploadFile[] | undefined>;
|
|
142
|
+
retryUpload: (fileId?: string) => Promise<UploadFile[] | undefined>;
|
|
143
|
+
uploadSpeed: number;
|
|
144
|
+
uploadEta: number;
|
|
145
|
+
uploadedBytes: number;
|
|
146
|
+
totalBytes: number;
|
|
147
|
+
};
|
|
148
|
+
type BaseContextRuntime = {
|
|
149
|
+
core: UpupCore | null;
|
|
150
|
+
orchestrator: UploaderOrchestrator | null;
|
|
151
|
+
mode: 'client' | 'server';
|
|
152
|
+
serverUrl?: string | undefined;
|
|
153
|
+
openFilePicker: () => void;
|
|
154
|
+
isOnline: boolean;
|
|
155
|
+
};
|
|
156
|
+
type BaseContextSource = {
|
|
157
|
+
activeSource?: FileSource | undefined;
|
|
158
|
+
setActiveSource: (source: FileSource | undefined) => void;
|
|
159
|
+
cloudDrives?: CloudDrivesConfig | undefined;
|
|
160
|
+
};
|
|
161
|
+
type BaseContextI18n = {
|
|
162
|
+
translations: Translations;
|
|
163
|
+
translator?: Translator | undefined;
|
|
164
|
+
lang: string;
|
|
165
|
+
dir: 'ltr' | 'rtl';
|
|
166
|
+
};
|
|
167
|
+
type BaseContextFiles = {
|
|
168
|
+
files: Map<string, UploadFile>;
|
|
169
|
+
setFiles: (newFiles: File[]) => void;
|
|
170
|
+
replaceFiles: (files: File[] | UploadFile[]) => void;
|
|
171
|
+
resetState: () => void;
|
|
172
|
+
uploadFiles: (files: File[] | UploadFile[]) => Promise<UploadFile[] | undefined>;
|
|
173
|
+
handleFileRemove: (fileId: string) => void;
|
|
174
|
+
};
|
|
175
|
+
type BaseContextUploadControls = {
|
|
176
|
+
upload: BaseContextUpload;
|
|
177
|
+
handleDone: () => void;
|
|
178
|
+
handleCancel: () => void;
|
|
179
|
+
handlePause: () => void;
|
|
180
|
+
handleResume: () => void;
|
|
181
|
+
};
|
|
182
|
+
type BaseContextView = {
|
|
183
|
+
isAddingMore: boolean;
|
|
184
|
+
setIsAddingMore: (value: boolean) => void;
|
|
185
|
+
viewMode: 'grid' | 'list';
|
|
186
|
+
setViewMode: (mode: 'grid' | 'list') => void;
|
|
187
|
+
};
|
|
188
|
+
type BaseContextEditor = {
|
|
189
|
+
editingFile: UploadFile | null;
|
|
190
|
+
openImageEditor: (file: UploadFile) => void;
|
|
191
|
+
closeImageEditor: () => void;
|
|
192
|
+
saveImageEdit: (editedImageData: string, mimeType?: string) => void;
|
|
193
|
+
replaceFile: (fileId: string, newFile: UploadFile) => void;
|
|
194
|
+
};
|
|
195
|
+
type BaseResolvedTheme = Omit<UpupResolvedTheme, 'mode'> & {
|
|
196
|
+
mode: Exclude<UpupThemeMode, 'system'>;
|
|
197
|
+
};
|
|
198
|
+
type BaseContextTheme = {
|
|
199
|
+
themeMode: Exclude<UpupThemeMode, 'system'>;
|
|
200
|
+
isDark: boolean;
|
|
201
|
+
tokens: UpupThemeTokens;
|
|
202
|
+
resolved: BaseResolvedTheme;
|
|
203
|
+
slotOverrides: InternalFlatClassNames;
|
|
204
|
+
slots: DeepPartialSlots;
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
export { type BaseContextUpload as B, type OrchestratorCallbacks as O, UploaderOrchestrator as U, type BaseContextRuntime as a, type BaseContextSource as b, type BaseContextI18n as c, type BaseContextFiles as d, type BaseContextUploadControls as e, type BaseContextView as f, type BaseContextEditor as g, type BaseContextTheme as h, type OrchestratorState as i, type UploadProgressInfo as j };
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
declare enum FileSource {
|
|
2
|
+
LOCAL = "local",
|
|
3
|
+
GOOGLE_DRIVE = "googleDrive",
|
|
4
|
+
ONE_DRIVE = "oneDrive",
|
|
5
|
+
DROPBOX = "dropbox",
|
|
6
|
+
BOX = "box",
|
|
7
|
+
URL = "url",
|
|
8
|
+
CAMERA = "camera",
|
|
9
|
+
MICROPHONE = "microphone",
|
|
10
|
+
SCREEN = "screen"
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
declare enum UploadStatus {
|
|
14
|
+
IDLE = "IDLE",
|
|
15
|
+
PROCESSING = "PROCESSING",
|
|
16
|
+
READY = "READY",
|
|
17
|
+
UPLOADING = "UPLOADING",
|
|
18
|
+
PAUSED = "PAUSED",
|
|
19
|
+
SUCCESSFUL = "SUCCESSFUL",
|
|
20
|
+
FAILED = "FAILED"
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
type UploadFileMetadata = {
|
|
24
|
+
width?: number;
|
|
25
|
+
height?: number;
|
|
26
|
+
duration?: number;
|
|
27
|
+
thumbnailUrl?: string;
|
|
28
|
+
checksum?: string;
|
|
29
|
+
originalContentHash?: string;
|
|
30
|
+
originalSize?: number;
|
|
31
|
+
processedSize?: number;
|
|
32
|
+
compressed?: boolean;
|
|
33
|
+
exifStripped?: boolean;
|
|
34
|
+
heicConverted?: boolean;
|
|
35
|
+
};
|
|
36
|
+
type UploadFile = File & {
|
|
37
|
+
id: string;
|
|
38
|
+
source: FileSource;
|
|
39
|
+
status: UploadStatus;
|
|
40
|
+
metadata: UploadFileMetadata;
|
|
41
|
+
url?: string;
|
|
42
|
+
relativePath?: string;
|
|
43
|
+
key?: string;
|
|
44
|
+
etag?: string;
|
|
45
|
+
/** @deprecated Use metadata.originalContentHash instead */
|
|
46
|
+
fileHash?: string;
|
|
47
|
+
/** @deprecated Use metadata.checksum instead */
|
|
48
|
+
checksumSHA256?: string;
|
|
49
|
+
/** @deprecated Use metadata.thumbnailUrl instead */
|
|
50
|
+
thumbnail?: {
|
|
51
|
+
file: File;
|
|
52
|
+
key?: string;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
type UploadFileWithProgress = UploadFile & {
|
|
56
|
+
progress: number;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
interface PipelineStep {
|
|
60
|
+
name: string;
|
|
61
|
+
process(file: UploadFile, context: PipelineContext): Promise<UploadFile>;
|
|
62
|
+
shouldProcess?(file: UploadFile): boolean;
|
|
63
|
+
}
|
|
64
|
+
interface PipelineContext {
|
|
65
|
+
files: ReadonlyMap<string, UploadFile>;
|
|
66
|
+
options: Record<string, unknown>;
|
|
67
|
+
emit(event: string, data?: unknown): void;
|
|
68
|
+
t: (key: string, vars?: Record<string, unknown>) => string;
|
|
69
|
+
worker?: {
|
|
70
|
+
execute<T>(task: {
|
|
71
|
+
type: string;
|
|
72
|
+
data: ArrayBuffer;
|
|
73
|
+
params?: Record<string, unknown>;
|
|
74
|
+
}): Promise<T>;
|
|
75
|
+
} | undefined;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export { FileSource as F, type PipelineStep as P, type UploadFileMetadata as U, type UploadFile as a, type UploadFileWithProgress as b, UploadStatus as c, type PipelineContext as d };
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
declare enum FileSource {
|
|
2
|
+
LOCAL = "local",
|
|
3
|
+
GOOGLE_DRIVE = "googleDrive",
|
|
4
|
+
ONE_DRIVE = "oneDrive",
|
|
5
|
+
DROPBOX = "dropbox",
|
|
6
|
+
BOX = "box",
|
|
7
|
+
URL = "url",
|
|
8
|
+
CAMERA = "camera",
|
|
9
|
+
MICROPHONE = "microphone",
|
|
10
|
+
SCREEN = "screen"
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
declare enum UploadStatus {
|
|
14
|
+
IDLE = "IDLE",
|
|
15
|
+
PROCESSING = "PROCESSING",
|
|
16
|
+
READY = "READY",
|
|
17
|
+
UPLOADING = "UPLOADING",
|
|
18
|
+
PAUSED = "PAUSED",
|
|
19
|
+
SUCCESSFUL = "SUCCESSFUL",
|
|
20
|
+
FAILED = "FAILED"
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
type UploadFileMetadata = {
|
|
24
|
+
width?: number;
|
|
25
|
+
height?: number;
|
|
26
|
+
duration?: number;
|
|
27
|
+
thumbnailUrl?: string;
|
|
28
|
+
checksum?: string;
|
|
29
|
+
originalContentHash?: string;
|
|
30
|
+
originalSize?: number;
|
|
31
|
+
processedSize?: number;
|
|
32
|
+
compressed?: boolean;
|
|
33
|
+
exifStripped?: boolean;
|
|
34
|
+
heicConverted?: boolean;
|
|
35
|
+
};
|
|
36
|
+
type UploadFile = File & {
|
|
37
|
+
id: string;
|
|
38
|
+
source: FileSource;
|
|
39
|
+
status: UploadStatus;
|
|
40
|
+
metadata: UploadFileMetadata;
|
|
41
|
+
url?: string;
|
|
42
|
+
relativePath?: string;
|
|
43
|
+
key?: string;
|
|
44
|
+
etag?: string;
|
|
45
|
+
/** @deprecated Use metadata.originalContentHash instead */
|
|
46
|
+
fileHash?: string;
|
|
47
|
+
/** @deprecated Use metadata.checksum instead */
|
|
48
|
+
checksumSHA256?: string;
|
|
49
|
+
/** @deprecated Use metadata.thumbnailUrl instead */
|
|
50
|
+
thumbnail?: {
|
|
51
|
+
file: File;
|
|
52
|
+
key?: string;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
type UploadFileWithProgress = UploadFile & {
|
|
56
|
+
progress: number;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
interface PipelineStep {
|
|
60
|
+
name: string;
|
|
61
|
+
process(file: UploadFile, context: PipelineContext): Promise<UploadFile>;
|
|
62
|
+
shouldProcess?(file: UploadFile): boolean;
|
|
63
|
+
}
|
|
64
|
+
interface PipelineContext {
|
|
65
|
+
files: ReadonlyMap<string, UploadFile>;
|
|
66
|
+
options: Record<string, unknown>;
|
|
67
|
+
emit(event: string, data?: unknown): void;
|
|
68
|
+
t: (key: string, vars?: Record<string, unknown>) => string;
|
|
69
|
+
worker?: {
|
|
70
|
+
execute<T>(task: {
|
|
71
|
+
type: string;
|
|
72
|
+
data: ArrayBuffer;
|
|
73
|
+
params?: Record<string, unknown>;
|
|
74
|
+
}): Promise<T>;
|
|
75
|
+
} | undefined;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export { FileSource as F, type PipelineStep as P, type UploadFileMetadata as U, type UploadFile as a, type UploadFileWithProgress as b, UploadStatus as c, type PipelineContext as d };
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
type PresignedUrlResponse = {
|
|
2
|
+
key: string;
|
|
3
|
+
publicUrl?: string;
|
|
4
|
+
downloadUrl?: string;
|
|
5
|
+
uploadUrl: string;
|
|
6
|
+
uploadHeaders?: Record<string, string>;
|
|
7
|
+
expiresIn: number;
|
|
8
|
+
};
|
|
9
|
+
type MultipartInitResponse = {
|
|
10
|
+
key: string;
|
|
11
|
+
uploadId: string;
|
|
12
|
+
partSize: number;
|
|
13
|
+
expiresIn: number;
|
|
14
|
+
/** Opaque server-issued token bound to {key, uploadId, size, expiry}. */
|
|
15
|
+
token?: string;
|
|
16
|
+
};
|
|
17
|
+
type MultipartSignPartResponse = {
|
|
18
|
+
uploadUrl: string;
|
|
19
|
+
uploadHeaders?: Record<string, string>;
|
|
20
|
+
expiresIn: number;
|
|
21
|
+
};
|
|
22
|
+
type MultipartPart = {
|
|
23
|
+
partNumber: number;
|
|
24
|
+
eTag: string;
|
|
25
|
+
/** Bytes stored for this part. Populated on resume/list responses; the
|
|
26
|
+
* complete call ignores it. */
|
|
27
|
+
size?: number;
|
|
28
|
+
};
|
|
29
|
+
type MultipartListPartsResponse = {
|
|
30
|
+
parts: MultipartPart[];
|
|
31
|
+
};
|
|
32
|
+
type MultipartResumeResponse = {
|
|
33
|
+
key: string;
|
|
34
|
+
/** Fresh server-issued token replacing the presented (possibly expired)
|
|
35
|
+
* one — same key/uploadId/owner/size-envelope binding, new expiry. */
|
|
36
|
+
token: string;
|
|
37
|
+
/** Parts the storage provider already holds; every entry carries `size`. */
|
|
38
|
+
parts: MultipartPart[];
|
|
39
|
+
};
|
|
40
|
+
type MultipartCompleteResponse = {
|
|
41
|
+
key: string;
|
|
42
|
+
publicUrl?: string;
|
|
43
|
+
downloadUrl?: string;
|
|
44
|
+
etag?: string;
|
|
45
|
+
};
|
|
46
|
+
type MultipartAbortResponse = {
|
|
47
|
+
ok: true;
|
|
48
|
+
};
|
|
49
|
+
type MaxFileSizeObject = {
|
|
50
|
+
size: number;
|
|
51
|
+
unit: 'B' | 'KB' | 'MB' | 'GB' | 'TB' | 'PB' | 'EB' | 'ZB' | 'YB';
|
|
52
|
+
};
|
|
53
|
+
type ResumableUploadOptions = {
|
|
54
|
+
protocol: 'multipart';
|
|
55
|
+
thresholdBytes?: number;
|
|
56
|
+
chunkSizeBytes?: number;
|
|
57
|
+
persist?: boolean;
|
|
58
|
+
/** Delays (ms) before each successive retry of a transiently failed
|
|
59
|
+
* or stalled part. Array length = retry budget; `[]` disables part
|
|
60
|
+
* retries. Default `[0, 1000, 3000, 5000]`. */
|
|
61
|
+
retryDelays?: number[];
|
|
62
|
+
/** Watchdog (ms) for a single part attempt — a request that neither
|
|
63
|
+
* succeeds nor fails within this window is aborted and retried
|
|
64
|
+
* instead of hanging the upload. Default 180000. */
|
|
65
|
+
partTimeoutMs?: number;
|
|
66
|
+
/** Parts of ONE file in flight at once. Default 3. More parts in
|
|
67
|
+
* flight buys throughput on a high-bandwidth link and costs memory
|
|
68
|
+
* and sockets — each in-flight part holds its own chunk. Values
|
|
69
|
+
* below 1 are treated as 1. */
|
|
70
|
+
maxConcurrentParts?: number;
|
|
71
|
+
/** Continue a crash-restored upload automatically instead of waiting
|
|
72
|
+
* for the Resume click. Off by default: closing a tab is as often
|
|
73
|
+
* "cancel" as "oops", so silently resuming is the integrator's
|
|
74
|
+
* call, never the library's. */
|
|
75
|
+
autoResume?: boolean;
|
|
76
|
+
} | {
|
|
77
|
+
protocol: 'tus';
|
|
78
|
+
endpoint: string;
|
|
79
|
+
chunkSizeBytes?: number;
|
|
80
|
+
/** @deprecated Use chunkSizeBytes instead. */
|
|
81
|
+
chunkSize?: number;
|
|
82
|
+
retryDelays?: number[];
|
|
83
|
+
storeFingerprintForResuming?: boolean;
|
|
84
|
+
removeFingerprintOnSuccess?: boolean;
|
|
85
|
+
headers?: Record<string, string>;
|
|
86
|
+
metadata?: Record<string, string>;
|
|
87
|
+
parallelUploads?: number;
|
|
88
|
+
};
|
|
89
|
+
type CrashRecoveryOptions = {
|
|
90
|
+
enabled?: boolean;
|
|
91
|
+
storeName?: string;
|
|
92
|
+
expiry?: number;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
type FileMetadata = {
|
|
96
|
+
name: string;
|
|
97
|
+
size: number;
|
|
98
|
+
type: string;
|
|
99
|
+
metadata?: Record<string, unknown>;
|
|
100
|
+
};
|
|
101
|
+
type UploadCredentials = PresignedUrlResponse;
|
|
102
|
+
type UploadResult = {
|
|
103
|
+
key: string;
|
|
104
|
+
publicUrl?: string | undefined;
|
|
105
|
+
downloadUrl?: string | undefined;
|
|
106
|
+
etag?: string | undefined;
|
|
107
|
+
};
|
|
108
|
+
type ProgressInfo = {
|
|
109
|
+
loaded: number;
|
|
110
|
+
total: number;
|
|
111
|
+
percentage: number;
|
|
112
|
+
};
|
|
113
|
+
type CloudProvider = 'googleDrive' | 'oneDrive' | 'dropbox' | 'box';
|
|
114
|
+
interface CredentialStrategy {
|
|
115
|
+
getPresignedUrl(file: FileMetadata): Promise<PresignedUrlResponse>;
|
|
116
|
+
initMultipartUpload?(file: FileMetadata): Promise<MultipartInitResponse>;
|
|
117
|
+
signPart?(params: {
|
|
118
|
+
token: string;
|
|
119
|
+
partNumber: number;
|
|
120
|
+
}): Promise<MultipartSignPartResponse>;
|
|
121
|
+
completeMultipartUpload?(params: {
|
|
122
|
+
token: string;
|
|
123
|
+
parts: {
|
|
124
|
+
partNumber: number;
|
|
125
|
+
eTag: string;
|
|
126
|
+
}[];
|
|
127
|
+
}): Promise<MultipartCompleteResponse>;
|
|
128
|
+
abortMultipartUpload?(params: {
|
|
129
|
+
token: string;
|
|
130
|
+
}): Promise<void>;
|
|
131
|
+
/** Re-attach to an in-progress multipart upload: verify the presented
|
|
132
|
+
* token server-side, list the parts storage already holds, and issue a
|
|
133
|
+
* fresh token. Powers cross-reload resume. */
|
|
134
|
+
resumeMultipartUpload?(params: {
|
|
135
|
+
token: string;
|
|
136
|
+
}): Promise<MultipartResumeResponse>;
|
|
137
|
+
}
|
|
138
|
+
interface UploadStrategy {
|
|
139
|
+
upload(file: File | Blob, credentials: UploadCredentials, options: {
|
|
140
|
+
onProgress: (loaded: number, total: number) => void;
|
|
141
|
+
signal: AbortSignal;
|
|
142
|
+
}): Promise<UploadResult>;
|
|
143
|
+
}
|
|
144
|
+
interface RuntimeAdapter {
|
|
145
|
+
computeHash(data: ArrayBuffer): Promise<string>;
|
|
146
|
+
createImageBitmap?: ((blob: Blob) => Promise<ImageBitmap>) | undefined;
|
|
147
|
+
createWorker?: (() => Worker | null) | undefined;
|
|
148
|
+
upload(url: string, body: Blob | ArrayBuffer, options: {
|
|
149
|
+
method: string;
|
|
150
|
+
headers: Record<string, string>;
|
|
151
|
+
onProgress: (loaded: number, total: number) => void;
|
|
152
|
+
signal: AbortSignal;
|
|
153
|
+
}): Promise<{
|
|
154
|
+
status: number;
|
|
155
|
+
headers: Record<string, string>;
|
|
156
|
+
body: string;
|
|
157
|
+
}>;
|
|
158
|
+
readAsArrayBuffer(file: File | Blob): Promise<ArrayBuffer>;
|
|
159
|
+
createObjectURL?: ((blob: Blob) => string) | undefined;
|
|
160
|
+
revokeObjectURL?: ((url: string) => void) | undefined;
|
|
161
|
+
storage?: {
|
|
162
|
+
get(key: string): Promise<unknown>;
|
|
163
|
+
set(key: string, value: unknown): Promise<void>;
|
|
164
|
+
delete(key: string): Promise<void>;
|
|
165
|
+
} | undefined;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export type { CrashRecoveryOptions as C, FileMetadata as F, MaxFileSizeObject as M, PresignedUrlResponse as P, ResumableUploadOptions as R, UploadCredentials as U, MultipartInitResponse as a, MultipartSignPartResponse as b, MultipartPart as c, MultipartListPartsResponse as d, MultipartResumeResponse as e, MultipartCompleteResponse as f, MultipartAbortResponse as g, UploadResult as h, ProgressInfo as i, CloudProvider as j, CredentialStrategy as k, UploadStrategy as l, RuntimeAdapter as m };
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
type PresignedUrlResponse = {
|
|
2
|
+
key: string;
|
|
3
|
+
publicUrl?: string;
|
|
4
|
+
downloadUrl?: string;
|
|
5
|
+
uploadUrl: string;
|
|
6
|
+
uploadHeaders?: Record<string, string>;
|
|
7
|
+
expiresIn: number;
|
|
8
|
+
};
|
|
9
|
+
type MultipartInitResponse = {
|
|
10
|
+
key: string;
|
|
11
|
+
uploadId: string;
|
|
12
|
+
partSize: number;
|
|
13
|
+
expiresIn: number;
|
|
14
|
+
/** Opaque server-issued token bound to {key, uploadId, size, expiry}. */
|
|
15
|
+
token?: string;
|
|
16
|
+
};
|
|
17
|
+
type MultipartSignPartResponse = {
|
|
18
|
+
uploadUrl: string;
|
|
19
|
+
uploadHeaders?: Record<string, string>;
|
|
20
|
+
expiresIn: number;
|
|
21
|
+
};
|
|
22
|
+
type MultipartPart = {
|
|
23
|
+
partNumber: number;
|
|
24
|
+
eTag: string;
|
|
25
|
+
/** Bytes stored for this part. Populated on resume/list responses; the
|
|
26
|
+
* complete call ignores it. */
|
|
27
|
+
size?: number;
|
|
28
|
+
};
|
|
29
|
+
type MultipartListPartsResponse = {
|
|
30
|
+
parts: MultipartPart[];
|
|
31
|
+
};
|
|
32
|
+
type MultipartResumeResponse = {
|
|
33
|
+
key: string;
|
|
34
|
+
/** Fresh server-issued token replacing the presented (possibly expired)
|
|
35
|
+
* one — same key/uploadId/owner/size-envelope binding, new expiry. */
|
|
36
|
+
token: string;
|
|
37
|
+
/** Parts the storage provider already holds; every entry carries `size`. */
|
|
38
|
+
parts: MultipartPart[];
|
|
39
|
+
};
|
|
40
|
+
type MultipartCompleteResponse = {
|
|
41
|
+
key: string;
|
|
42
|
+
publicUrl?: string;
|
|
43
|
+
downloadUrl?: string;
|
|
44
|
+
etag?: string;
|
|
45
|
+
};
|
|
46
|
+
type MultipartAbortResponse = {
|
|
47
|
+
ok: true;
|
|
48
|
+
};
|
|
49
|
+
type MaxFileSizeObject = {
|
|
50
|
+
size: number;
|
|
51
|
+
unit: 'B' | 'KB' | 'MB' | 'GB' | 'TB' | 'PB' | 'EB' | 'ZB' | 'YB';
|
|
52
|
+
};
|
|
53
|
+
type ResumableUploadOptions = {
|
|
54
|
+
protocol: 'multipart';
|
|
55
|
+
thresholdBytes?: number;
|
|
56
|
+
chunkSizeBytes?: number;
|
|
57
|
+
persist?: boolean;
|
|
58
|
+
/** Delays (ms) before each successive retry of a transiently failed
|
|
59
|
+
* or stalled part. Array length = retry budget; `[]` disables part
|
|
60
|
+
* retries. Default `[0, 1000, 3000, 5000]`. */
|
|
61
|
+
retryDelays?: number[];
|
|
62
|
+
/** Watchdog (ms) for a single part attempt — a request that neither
|
|
63
|
+
* succeeds nor fails within this window is aborted and retried
|
|
64
|
+
* instead of hanging the upload. Default 180000. */
|
|
65
|
+
partTimeoutMs?: number;
|
|
66
|
+
/** Parts of ONE file in flight at once. Default 3. More parts in
|
|
67
|
+
* flight buys throughput on a high-bandwidth link and costs memory
|
|
68
|
+
* and sockets — each in-flight part holds its own chunk. Values
|
|
69
|
+
* below 1 are treated as 1. */
|
|
70
|
+
maxConcurrentParts?: number;
|
|
71
|
+
/** Continue a crash-restored upload automatically instead of waiting
|
|
72
|
+
* for the Resume click. Off by default: closing a tab is as often
|
|
73
|
+
* "cancel" as "oops", so silently resuming is the integrator's
|
|
74
|
+
* call, never the library's. */
|
|
75
|
+
autoResume?: boolean;
|
|
76
|
+
} | {
|
|
77
|
+
protocol: 'tus';
|
|
78
|
+
endpoint: string;
|
|
79
|
+
chunkSizeBytes?: number;
|
|
80
|
+
/** @deprecated Use chunkSizeBytes instead. */
|
|
81
|
+
chunkSize?: number;
|
|
82
|
+
retryDelays?: number[];
|
|
83
|
+
storeFingerprintForResuming?: boolean;
|
|
84
|
+
removeFingerprintOnSuccess?: boolean;
|
|
85
|
+
headers?: Record<string, string>;
|
|
86
|
+
metadata?: Record<string, string>;
|
|
87
|
+
parallelUploads?: number;
|
|
88
|
+
};
|
|
89
|
+
type CrashRecoveryOptions = {
|
|
90
|
+
enabled?: boolean;
|
|
91
|
+
storeName?: string;
|
|
92
|
+
expiry?: number;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
type FileMetadata = {
|
|
96
|
+
name: string;
|
|
97
|
+
size: number;
|
|
98
|
+
type: string;
|
|
99
|
+
metadata?: Record<string, unknown>;
|
|
100
|
+
};
|
|
101
|
+
type UploadCredentials = PresignedUrlResponse;
|
|
102
|
+
type UploadResult = {
|
|
103
|
+
key: string;
|
|
104
|
+
publicUrl?: string | undefined;
|
|
105
|
+
downloadUrl?: string | undefined;
|
|
106
|
+
etag?: string | undefined;
|
|
107
|
+
};
|
|
108
|
+
type ProgressInfo = {
|
|
109
|
+
loaded: number;
|
|
110
|
+
total: number;
|
|
111
|
+
percentage: number;
|
|
112
|
+
};
|
|
113
|
+
type CloudProvider = 'googleDrive' | 'oneDrive' | 'dropbox' | 'box';
|
|
114
|
+
interface CredentialStrategy {
|
|
115
|
+
getPresignedUrl(file: FileMetadata): Promise<PresignedUrlResponse>;
|
|
116
|
+
initMultipartUpload?(file: FileMetadata): Promise<MultipartInitResponse>;
|
|
117
|
+
signPart?(params: {
|
|
118
|
+
token: string;
|
|
119
|
+
partNumber: number;
|
|
120
|
+
}): Promise<MultipartSignPartResponse>;
|
|
121
|
+
completeMultipartUpload?(params: {
|
|
122
|
+
token: string;
|
|
123
|
+
parts: {
|
|
124
|
+
partNumber: number;
|
|
125
|
+
eTag: string;
|
|
126
|
+
}[];
|
|
127
|
+
}): Promise<MultipartCompleteResponse>;
|
|
128
|
+
abortMultipartUpload?(params: {
|
|
129
|
+
token: string;
|
|
130
|
+
}): Promise<void>;
|
|
131
|
+
/** Re-attach to an in-progress multipart upload: verify the presented
|
|
132
|
+
* token server-side, list the parts storage already holds, and issue a
|
|
133
|
+
* fresh token. Powers cross-reload resume. */
|
|
134
|
+
resumeMultipartUpload?(params: {
|
|
135
|
+
token: string;
|
|
136
|
+
}): Promise<MultipartResumeResponse>;
|
|
137
|
+
}
|
|
138
|
+
interface UploadStrategy {
|
|
139
|
+
upload(file: File | Blob, credentials: UploadCredentials, options: {
|
|
140
|
+
onProgress: (loaded: number, total: number) => void;
|
|
141
|
+
signal: AbortSignal;
|
|
142
|
+
}): Promise<UploadResult>;
|
|
143
|
+
}
|
|
144
|
+
interface RuntimeAdapter {
|
|
145
|
+
computeHash(data: ArrayBuffer): Promise<string>;
|
|
146
|
+
createImageBitmap?: ((blob: Blob) => Promise<ImageBitmap>) | undefined;
|
|
147
|
+
createWorker?: (() => Worker | null) | undefined;
|
|
148
|
+
upload(url: string, body: Blob | ArrayBuffer, options: {
|
|
149
|
+
method: string;
|
|
150
|
+
headers: Record<string, string>;
|
|
151
|
+
onProgress: (loaded: number, total: number) => void;
|
|
152
|
+
signal: AbortSignal;
|
|
153
|
+
}): Promise<{
|
|
154
|
+
status: number;
|
|
155
|
+
headers: Record<string, string>;
|
|
156
|
+
body: string;
|
|
157
|
+
}>;
|
|
158
|
+
readAsArrayBuffer(file: File | Blob): Promise<ArrayBuffer>;
|
|
159
|
+
createObjectURL?: ((blob: Blob) => string) | undefined;
|
|
160
|
+
revokeObjectURL?: ((url: string) => void) | undefined;
|
|
161
|
+
storage?: {
|
|
162
|
+
get(key: string): Promise<unknown>;
|
|
163
|
+
set(key: string, value: unknown): Promise<void>;
|
|
164
|
+
delete(key: string): Promise<void>;
|
|
165
|
+
} | undefined;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export type { CrashRecoveryOptions as C, FileMetadata as F, MaxFileSizeObject as M, PresignedUrlResponse as P, ResumableUploadOptions as R, UploadCredentials as U, MultipartInitResponse as a, MultipartSignPartResponse as b, MultipartPart as c, MultipartListPartsResponse as d, MultipartResumeResponse as e, MultipartCompleteResponse as f, MultipartAbortResponse as g, UploadResult as h, ProgressInfo as i, CloudProvider as j, CredentialStrategy as k, UploadStrategy as l, RuntimeAdapter as m };
|