@useupup/vanilla 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/README.md +70 -0
- package/dist/chunk-KDBNQMVZ.js +4416 -0
- package/dist/chunk-ZIGB2IKB.cjs +4418 -0
- package/dist/element.cjs +74 -0
- package/dist/element.d.cts +20 -0
- package/dist/element.d.ts +20 -0
- package/dist/element.js +72 -0
- package/dist/index.cjs +23 -0
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +2 -0
- package/dist/styles.d.ts +4 -0
- package/dist/tailwind-prefixed.css +2464 -0
- package/dist/types-412b3393.d.cts +336 -0
- package/dist/types-412b3393.d.ts +336 -0
- package/package.json +102 -0
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
import { FileSource, UpupCore, UploadFile, UploadStatus, CoreOptions, UpupThemeConfig, UploadSource, LocaleBundle, PartialMessages, Translations, Translator, CloudDrivesConfig, ExtensionMethods, MaxFileSizeObject, ResolvedImageEditorOptions } from '@useupup/core';
|
|
2
|
+
import { UploaderOrchestrator, ThemeStore, TransientUiSnapshot, MotionMode, DragDropController, DriveBrowserController } from '@useupup/core/internal';
|
|
3
|
+
|
|
4
|
+
type RecordingState$1 = 'idle' | 'recording' | 'recorded';
|
|
5
|
+
interface ScreenDeps {
|
|
6
|
+
setFiles: (files: File[]) => Promise<void>;
|
|
7
|
+
setActiveSource: (a: FileSource | undefined) => void;
|
|
8
|
+
invalidate: () => void;
|
|
9
|
+
}
|
|
10
|
+
interface ScreenSnapshot {
|
|
11
|
+
recordingState: RecordingState$1;
|
|
12
|
+
duration: number;
|
|
13
|
+
videoUrl: string | null;
|
|
14
|
+
error: string | null;
|
|
15
|
+
}
|
|
16
|
+
declare class ScreenCaptureController implements SourceController<ScreenSnapshot> {
|
|
17
|
+
private deps;
|
|
18
|
+
private recordingState;
|
|
19
|
+
private duration;
|
|
20
|
+
private videoUrl;
|
|
21
|
+
private error;
|
|
22
|
+
private mediaRecorder;
|
|
23
|
+
private chunks;
|
|
24
|
+
private timerHandle;
|
|
25
|
+
private streamRef;
|
|
26
|
+
private previewEl;
|
|
27
|
+
private destroyed;
|
|
28
|
+
constructor(deps: ScreenDeps);
|
|
29
|
+
/** STABLE ref (one identity per controller life) so lit-html only invokes it on real <video>
|
|
30
|
+
* mount/unmount. An inline-arrow ref re-fires every render; the recording timer invalidates
|
|
31
|
+
* each second, so an inline ref would re-bind srcObject + re-call play() every frame. */
|
|
32
|
+
readonly previewRef: (el: Element | undefined) => void;
|
|
33
|
+
activate(): void;
|
|
34
|
+
deactivate(): void;
|
|
35
|
+
setPreviewEl(el: HTMLVideoElement | null): void;
|
|
36
|
+
startRecording(): Promise<void>;
|
|
37
|
+
stopRecording(): void;
|
|
38
|
+
discardRecording(): void;
|
|
39
|
+
addRecording(): void;
|
|
40
|
+
retryRecording(): void;
|
|
41
|
+
formatTime(s: number): string;
|
|
42
|
+
getSnapshot(): ScreenSnapshot;
|
|
43
|
+
destroy(): void;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
type RecordingState = 'idle' | 'recording' | 'recorded';
|
|
47
|
+
interface AudioDeps {
|
|
48
|
+
setFiles: (files: File[]) => Promise<void>;
|
|
49
|
+
setActiveSource: (a: FileSource | undefined) => void;
|
|
50
|
+
invalidate: () => void;
|
|
51
|
+
}
|
|
52
|
+
interface AudioSnapshot {
|
|
53
|
+
recordingState: RecordingState;
|
|
54
|
+
duration: number;
|
|
55
|
+
audioUrl: string | null;
|
|
56
|
+
error: string | null;
|
|
57
|
+
/** Live mic stream while recording — feeds the AudioWaveform visual (mirrors
|
|
58
|
+
* React AudioUploader's streamRef). Null when idle/recorded/torn down. */
|
|
59
|
+
stream: MediaStream | null;
|
|
60
|
+
}
|
|
61
|
+
declare class AudioRecorderController implements SourceController<AudioSnapshot> {
|
|
62
|
+
private deps;
|
|
63
|
+
private recordingState;
|
|
64
|
+
private duration;
|
|
65
|
+
private audioUrl;
|
|
66
|
+
private error;
|
|
67
|
+
private mediaRecorder;
|
|
68
|
+
private chunks;
|
|
69
|
+
private timerHandle;
|
|
70
|
+
private streamRef;
|
|
71
|
+
private destroyed;
|
|
72
|
+
constructor(deps: AudioDeps);
|
|
73
|
+
activate(): void;
|
|
74
|
+
deactivate(): void;
|
|
75
|
+
startRecording(): Promise<void>;
|
|
76
|
+
stopRecording(): void;
|
|
77
|
+
discardRecording(): void;
|
|
78
|
+
addRecording(): void;
|
|
79
|
+
formatTime(s: number): string;
|
|
80
|
+
getSnapshot(): AudioSnapshot;
|
|
81
|
+
destroy(): void;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
declare enum FacingMode {
|
|
85
|
+
Environment = "environment",
|
|
86
|
+
User = "user"
|
|
87
|
+
}
|
|
88
|
+
interface CameraDeps {
|
|
89
|
+
core: UpupCore;
|
|
90
|
+
setFiles: (files: File[]) => Promise<void>;
|
|
91
|
+
setActiveSource: (a: FileSource | undefined) => void;
|
|
92
|
+
invalidate: () => void;
|
|
93
|
+
}
|
|
94
|
+
interface CameraSnapshot {
|
|
95
|
+
capturedUrl: string;
|
|
96
|
+
facingMode: FacingMode;
|
|
97
|
+
newCameraSide: 'front' | 'back';
|
|
98
|
+
}
|
|
99
|
+
declare class CameraController implements SourceController<CameraSnapshot> {
|
|
100
|
+
private deps;
|
|
101
|
+
private capturedUrl;
|
|
102
|
+
private facingMode;
|
|
103
|
+
private stream;
|
|
104
|
+
private videoEl;
|
|
105
|
+
private destroyed;
|
|
106
|
+
constructor(deps: CameraDeps);
|
|
107
|
+
/** STABLE ref callback (one identity for the controller's life) so lit-html only invokes it
|
|
108
|
+
* on real <video> mount/unmount. An inline-arrow ref re-fires every render; since startCamera()
|
|
109
|
+
* calls invalidate() on success, that would loop getUserMedia and restart the camera endlessly. */
|
|
110
|
+
readonly videoRef: (el: Element | undefined) => void;
|
|
111
|
+
setVideoEl(el: HTMLVideoElement | null): void;
|
|
112
|
+
activate(): void;
|
|
113
|
+
deactivate(): void;
|
|
114
|
+
startCamera(): Promise<void>;
|
|
115
|
+
stopCamera(): void;
|
|
116
|
+
capture(): void;
|
|
117
|
+
clearUrl(): void;
|
|
118
|
+
handleFetchImage(): Promise<void>;
|
|
119
|
+
handleCameraSwitch(): void;
|
|
120
|
+
getSnapshot(): CameraSnapshot;
|
|
121
|
+
destroy(): void;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
interface FileInputDeps {
|
|
125
|
+
getFileInput: () => HTMLInputElement | null;
|
|
126
|
+
setFiles: (files: File[]) => Promise<void>;
|
|
127
|
+
invalidate: () => void;
|
|
128
|
+
}
|
|
129
|
+
type FileInputSnapshot = Record<string, never>;
|
|
130
|
+
declare class FileInputController implements UploaderController<FileInputSnapshot> {
|
|
131
|
+
private deps;
|
|
132
|
+
constructor(deps: FileInputDeps);
|
|
133
|
+
open(): void;
|
|
134
|
+
openFolder(): void;
|
|
135
|
+
getSnapshot(): FileInputSnapshot;
|
|
136
|
+
destroy(): void;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** Flat, framework-free snapshot the render loop reads and subscribe() emits. */
|
|
140
|
+
interface UploaderSnapshot {
|
|
141
|
+
files: UploadFile[];
|
|
142
|
+
status: UploadStatus;
|
|
143
|
+
progress: {
|
|
144
|
+
totalFiles: number;
|
|
145
|
+
completedFiles: number;
|
|
146
|
+
percentage: number;
|
|
147
|
+
};
|
|
148
|
+
error: Error | null;
|
|
149
|
+
activeSource: FileSource | undefined;
|
|
150
|
+
viewMode: 'grid' | 'list';
|
|
151
|
+
}
|
|
152
|
+
/** Cloud-drive config shape accepted by createUploader (mirrors svelte UploaderProps.cloudDrives). */
|
|
153
|
+
interface VanillaCloudDrives {
|
|
154
|
+
googleDrive?: {
|
|
155
|
+
clientId: string;
|
|
156
|
+
apiKey: string;
|
|
157
|
+
appId: string;
|
|
158
|
+
};
|
|
159
|
+
oneDrive?: {
|
|
160
|
+
clientId: string;
|
|
161
|
+
redirectUri?: string;
|
|
162
|
+
};
|
|
163
|
+
dropbox?: {
|
|
164
|
+
clientId: string;
|
|
165
|
+
redirectUri?: string;
|
|
166
|
+
};
|
|
167
|
+
box?: {
|
|
168
|
+
clientId: string;
|
|
169
|
+
redirectUri?: string;
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
/** Options accepted by createUploader: the CoreOptions surface + UI + convenience callbacks. */
|
|
173
|
+
interface CreateUploaderOptions extends Omit<CoreOptions, 'cloudDrives'> {
|
|
174
|
+
/** Initial theme; true => dark. Maps to ThemeStore('dark'|'light'). */
|
|
175
|
+
dark?: boolean;
|
|
176
|
+
/** svelte UploaderProps.theme passthrough when present (takes precedence over `dark`). */
|
|
177
|
+
theme?: UpupThemeConfig;
|
|
178
|
+
sources?: UploadSource[];
|
|
179
|
+
/** Mirrors svelte UploaderProps.maxFiles — max number of files. Resolution: maxFiles ?? 10. */
|
|
180
|
+
maxFiles?: number;
|
|
181
|
+
className?: string;
|
|
182
|
+
showBranding?: boolean;
|
|
183
|
+
disableDragDrop?: boolean;
|
|
184
|
+
mini?: boolean;
|
|
185
|
+
/** Motion master switch. `false` disables every upup-fx animation (writes
|
|
186
|
+
* data-motion="off"); the OS reduced-motion preference also forces off.
|
|
187
|
+
* Default true. Not part of CoreOptions — resolved by normalizeUploaderOptions. */
|
|
188
|
+
animations?: boolean;
|
|
189
|
+
/** Quiet-completion mode: a successful run shows ONLY the checkmark overlay
|
|
190
|
+
* (no Done/add-more/CTA); the host takes over via the completion callbacks.
|
|
191
|
+
* Default false. */
|
|
192
|
+
quietCompletion?: boolean;
|
|
193
|
+
isProcessing?: boolean;
|
|
194
|
+
allowPreview?: boolean;
|
|
195
|
+
folderUpload?: {
|
|
196
|
+
allowDrop?: boolean;
|
|
197
|
+
showSelectFolderButton?: boolean;
|
|
198
|
+
};
|
|
199
|
+
cloudDrives?: VanillaCloudDrives;
|
|
200
|
+
i18n?: {
|
|
201
|
+
bundle?: LocaleBundle;
|
|
202
|
+
locale?: LocaleBundle | string;
|
|
203
|
+
fallbackLocale?: LocaleBundle | string;
|
|
204
|
+
overrides?: PartialMessages;
|
|
205
|
+
};
|
|
206
|
+
onFileAdded?: (files: UploadFile[]) => void;
|
|
207
|
+
onFileRemoved?: (file: UploadFile) => void;
|
|
208
|
+
onUploadProgress?: (p: {
|
|
209
|
+
fileId: string;
|
|
210
|
+
loaded: number;
|
|
211
|
+
total: number;
|
|
212
|
+
}) => void;
|
|
213
|
+
onUploadComplete?: (files: UploadFile[]) => void;
|
|
214
|
+
/** Called when the user clicks Done (before files are cleared) — mirrors svelte's onDoneClicked prop. */
|
|
215
|
+
onDoneClicked?: () => void;
|
|
216
|
+
/** Called when a source tile is clicked (before the source-click emit) — mirrors svelte's onIntegrationClick prop. */
|
|
217
|
+
onIntegrationClick?: (sourceId: string) => void;
|
|
218
|
+
onFilesDragOver?: (files: File[]) => void;
|
|
219
|
+
onFilesDragLeave?: (files: File[]) => void;
|
|
220
|
+
onFilesDrop?: (files: File[]) => void;
|
|
221
|
+
onWarn?: (message: string) => void;
|
|
222
|
+
enablePaste?: boolean;
|
|
223
|
+
}
|
|
224
|
+
/** Base controller contract. invalidate() is injected at construction by the render loop. */
|
|
225
|
+
interface UploaderController<S = unknown> {
|
|
226
|
+
getSnapshot(): S;
|
|
227
|
+
destroy(): void;
|
|
228
|
+
}
|
|
229
|
+
/** Controllers that own a source view also implement activate/deactivate. */
|
|
230
|
+
interface SourceController<S = unknown> extends UploaderController<S> {
|
|
231
|
+
activate(): void;
|
|
232
|
+
deactivate(): void;
|
|
233
|
+
}
|
|
234
|
+
/** Lazily-instantiated controllers, keyed; the render loop destroys inactive ones on source switch. */
|
|
235
|
+
interface ControllerRegistry {
|
|
236
|
+
fileInput: FileInputController;
|
|
237
|
+
dragDrop: DragDropController;
|
|
238
|
+
/** active per-source controller cache (camera/audio/screen/drive); see context.ts getController(). */
|
|
239
|
+
getCamera(): CameraController;
|
|
240
|
+
getAudio(): AudioRecorderController;
|
|
241
|
+
getScreen(): ScreenCaptureController;
|
|
242
|
+
/** drive browser controllers are core DriveBrowserController instances, cached by FileSource. */
|
|
243
|
+
getDrive(source: FileSource): DriveBrowserController;
|
|
244
|
+
/** destroy every cached per-source controller (called on source switch + destroy). */
|
|
245
|
+
destroyActive(): void;
|
|
246
|
+
/** destroy everything including fileInput + dragDrop (called on destroy). */
|
|
247
|
+
destroyAll(): void;
|
|
248
|
+
}
|
|
249
|
+
/** Resolved props (plain values, mirroring svelte ContextProps). */
|
|
250
|
+
interface UploaderContextProps {
|
|
251
|
+
mini: boolean;
|
|
252
|
+
sources: FileSource[];
|
|
253
|
+
allowedFileTypes: string;
|
|
254
|
+
limit: number;
|
|
255
|
+
maxFileSize: MaxFileSizeObject | undefined;
|
|
256
|
+
multiple: boolean;
|
|
257
|
+
isProcessing: boolean;
|
|
258
|
+
allowPreview: boolean;
|
|
259
|
+
showBranding: boolean;
|
|
260
|
+
disableDragDrop: boolean;
|
|
261
|
+
className: string;
|
|
262
|
+
folderUploadAllowDrop: boolean;
|
|
263
|
+
folderPickerButtonVisible: boolean;
|
|
264
|
+
imageEditor: ResolvedImageEditorOptions;
|
|
265
|
+
quietCompletion: boolean;
|
|
266
|
+
onIntegrationClick: (sourceId: string) => void;
|
|
267
|
+
resumable: CoreOptions['resumable'];
|
|
268
|
+
}
|
|
269
|
+
/** The flat root context every template fn receives. Replicates svelte createUploaderController data without core extraction. */
|
|
270
|
+
interface UploaderContext {
|
|
271
|
+
core: UpupCore;
|
|
272
|
+
orchestrator: UploaderOrchestrator;
|
|
273
|
+
theme: ThemeStore;
|
|
274
|
+
mode: 'client' | 'server';
|
|
275
|
+
serverUrl: string | undefined;
|
|
276
|
+
translations: Translations;
|
|
277
|
+
translator: Translator;
|
|
278
|
+
lang: string;
|
|
279
|
+
dir: 'ltr' | 'rtl';
|
|
280
|
+
props: UploaderContextProps;
|
|
281
|
+
cloudDrives?: CloudDrivesConfig | undefined;
|
|
282
|
+
registerFileInput(el: HTMLInputElement | null): void;
|
|
283
|
+
getFileInput(): HTMLInputElement | null;
|
|
284
|
+
openFilePicker(): void;
|
|
285
|
+
setActiveSource(a: FileSource | undefined): void;
|
|
286
|
+
setIsAddingMore(v: boolean): void;
|
|
287
|
+
setViewMode(m: 'grid' | 'list'): void;
|
|
288
|
+
/** Current transient-UI snapshot (deferred removal / add-more overlay / drop
|
|
289
|
+
* toast). Read in render; the render loop re-subscribes via controller.subscribe. */
|
|
290
|
+
getTransientUi(): TransientUiSnapshot;
|
|
291
|
+
/** Current motion-gate resolution ('on' | 'off'); the panel writes it as
|
|
292
|
+
* data-motion so the shared CSS gates every upup-fx-* rule. */
|
|
293
|
+
getMotionMode(): MotionMode;
|
|
294
|
+
/** Add-more source overlay commands (core transient-UI store; idempotent). */
|
|
295
|
+
openSourceOverlay(): void;
|
|
296
|
+
closeSourceOverlay(): void;
|
|
297
|
+
/** Raise the drive drop-rejection toast for `source` (resolves the human
|
|
298
|
+
* provider label, then core owns the 3s auto-clear). */
|
|
299
|
+
flagDriveDropRejected(source: FileSource): void;
|
|
300
|
+
setFiles(files: File[]): Promise<void>;
|
|
301
|
+
handleFileRemove(fileId: string): void;
|
|
302
|
+
handleRemoveAll(): void;
|
|
303
|
+
startUpload(): Promise<UploadFile[] | undefined>;
|
|
304
|
+
retryUpload(fileId?: string): Promise<UploadFile[] | undefined>;
|
|
305
|
+
handleDone(): void;
|
|
306
|
+
handleCancel(): void;
|
|
307
|
+
handlePause(): void;
|
|
308
|
+
handleResume(): void;
|
|
309
|
+
controllers: ControllerRegistry;
|
|
310
|
+
/** request a re-render (microtask-coalesced by the render loop). */
|
|
311
|
+
invalidate(): void;
|
|
312
|
+
/** Report a user-facing error message (routed to options.onError). Used by URL fetch + other views. */
|
|
313
|
+
onError?: (message: string) => void;
|
|
314
|
+
}
|
|
315
|
+
/** The public instance returned by createUploader. Mirrors svelte UseUpupUploadReturn + lifecycle. */
|
|
316
|
+
interface UpupInstance {
|
|
317
|
+
getState(): UploaderSnapshot;
|
|
318
|
+
subscribe(cb: (s: UploaderSnapshot) => void): () => void;
|
|
319
|
+
addFiles(files: File[]): Promise<void>;
|
|
320
|
+
removeFile(id: string): void;
|
|
321
|
+
removeAll(): void;
|
|
322
|
+
setFiles(files: File[]): Promise<void>;
|
|
323
|
+
reorderFiles(ids: string[]): void;
|
|
324
|
+
upload(): Promise<UploadFile[]>;
|
|
325
|
+
pause(): void;
|
|
326
|
+
resume(): void;
|
|
327
|
+
cancel(): void;
|
|
328
|
+
retry(fileId?: string): Promise<UploadFile[]>;
|
|
329
|
+
on(event: string, h: (...a: unknown[]) => void): () => void;
|
|
330
|
+
ext: Record<string, ExtensionMethods>;
|
|
331
|
+
core: UpupCore;
|
|
332
|
+
el: HTMLElement;
|
|
333
|
+
destroy(): void;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
export type { CreateUploaderOptions as C, UpupInstance as U, UploaderSnapshot as a, UploaderContext as b };
|
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
import { FileSource, UpupCore, UploadFile, UploadStatus, CoreOptions, UpupThemeConfig, UploadSource, LocaleBundle, PartialMessages, Translations, Translator, CloudDrivesConfig, ExtensionMethods, MaxFileSizeObject, ResolvedImageEditorOptions } from '@useupup/core';
|
|
2
|
+
import { UploaderOrchestrator, ThemeStore, TransientUiSnapshot, MotionMode, DragDropController, DriveBrowserController } from '@useupup/core/internal';
|
|
3
|
+
|
|
4
|
+
type RecordingState$1 = 'idle' | 'recording' | 'recorded';
|
|
5
|
+
interface ScreenDeps {
|
|
6
|
+
setFiles: (files: File[]) => Promise<void>;
|
|
7
|
+
setActiveSource: (a: FileSource | undefined) => void;
|
|
8
|
+
invalidate: () => void;
|
|
9
|
+
}
|
|
10
|
+
interface ScreenSnapshot {
|
|
11
|
+
recordingState: RecordingState$1;
|
|
12
|
+
duration: number;
|
|
13
|
+
videoUrl: string | null;
|
|
14
|
+
error: string | null;
|
|
15
|
+
}
|
|
16
|
+
declare class ScreenCaptureController implements SourceController<ScreenSnapshot> {
|
|
17
|
+
private deps;
|
|
18
|
+
private recordingState;
|
|
19
|
+
private duration;
|
|
20
|
+
private videoUrl;
|
|
21
|
+
private error;
|
|
22
|
+
private mediaRecorder;
|
|
23
|
+
private chunks;
|
|
24
|
+
private timerHandle;
|
|
25
|
+
private streamRef;
|
|
26
|
+
private previewEl;
|
|
27
|
+
private destroyed;
|
|
28
|
+
constructor(deps: ScreenDeps);
|
|
29
|
+
/** STABLE ref (one identity per controller life) so lit-html only invokes it on real <video>
|
|
30
|
+
* mount/unmount. An inline-arrow ref re-fires every render; the recording timer invalidates
|
|
31
|
+
* each second, so an inline ref would re-bind srcObject + re-call play() every frame. */
|
|
32
|
+
readonly previewRef: (el: Element | undefined) => void;
|
|
33
|
+
activate(): void;
|
|
34
|
+
deactivate(): void;
|
|
35
|
+
setPreviewEl(el: HTMLVideoElement | null): void;
|
|
36
|
+
startRecording(): Promise<void>;
|
|
37
|
+
stopRecording(): void;
|
|
38
|
+
discardRecording(): void;
|
|
39
|
+
addRecording(): void;
|
|
40
|
+
retryRecording(): void;
|
|
41
|
+
formatTime(s: number): string;
|
|
42
|
+
getSnapshot(): ScreenSnapshot;
|
|
43
|
+
destroy(): void;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
type RecordingState = 'idle' | 'recording' | 'recorded';
|
|
47
|
+
interface AudioDeps {
|
|
48
|
+
setFiles: (files: File[]) => Promise<void>;
|
|
49
|
+
setActiveSource: (a: FileSource | undefined) => void;
|
|
50
|
+
invalidate: () => void;
|
|
51
|
+
}
|
|
52
|
+
interface AudioSnapshot {
|
|
53
|
+
recordingState: RecordingState;
|
|
54
|
+
duration: number;
|
|
55
|
+
audioUrl: string | null;
|
|
56
|
+
error: string | null;
|
|
57
|
+
/** Live mic stream while recording — feeds the AudioWaveform visual (mirrors
|
|
58
|
+
* React AudioUploader's streamRef). Null when idle/recorded/torn down. */
|
|
59
|
+
stream: MediaStream | null;
|
|
60
|
+
}
|
|
61
|
+
declare class AudioRecorderController implements SourceController<AudioSnapshot> {
|
|
62
|
+
private deps;
|
|
63
|
+
private recordingState;
|
|
64
|
+
private duration;
|
|
65
|
+
private audioUrl;
|
|
66
|
+
private error;
|
|
67
|
+
private mediaRecorder;
|
|
68
|
+
private chunks;
|
|
69
|
+
private timerHandle;
|
|
70
|
+
private streamRef;
|
|
71
|
+
private destroyed;
|
|
72
|
+
constructor(deps: AudioDeps);
|
|
73
|
+
activate(): void;
|
|
74
|
+
deactivate(): void;
|
|
75
|
+
startRecording(): Promise<void>;
|
|
76
|
+
stopRecording(): void;
|
|
77
|
+
discardRecording(): void;
|
|
78
|
+
addRecording(): void;
|
|
79
|
+
formatTime(s: number): string;
|
|
80
|
+
getSnapshot(): AudioSnapshot;
|
|
81
|
+
destroy(): void;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
declare enum FacingMode {
|
|
85
|
+
Environment = "environment",
|
|
86
|
+
User = "user"
|
|
87
|
+
}
|
|
88
|
+
interface CameraDeps {
|
|
89
|
+
core: UpupCore;
|
|
90
|
+
setFiles: (files: File[]) => Promise<void>;
|
|
91
|
+
setActiveSource: (a: FileSource | undefined) => void;
|
|
92
|
+
invalidate: () => void;
|
|
93
|
+
}
|
|
94
|
+
interface CameraSnapshot {
|
|
95
|
+
capturedUrl: string;
|
|
96
|
+
facingMode: FacingMode;
|
|
97
|
+
newCameraSide: 'front' | 'back';
|
|
98
|
+
}
|
|
99
|
+
declare class CameraController implements SourceController<CameraSnapshot> {
|
|
100
|
+
private deps;
|
|
101
|
+
private capturedUrl;
|
|
102
|
+
private facingMode;
|
|
103
|
+
private stream;
|
|
104
|
+
private videoEl;
|
|
105
|
+
private destroyed;
|
|
106
|
+
constructor(deps: CameraDeps);
|
|
107
|
+
/** STABLE ref callback (one identity for the controller's life) so lit-html only invokes it
|
|
108
|
+
* on real <video> mount/unmount. An inline-arrow ref re-fires every render; since startCamera()
|
|
109
|
+
* calls invalidate() on success, that would loop getUserMedia and restart the camera endlessly. */
|
|
110
|
+
readonly videoRef: (el: Element | undefined) => void;
|
|
111
|
+
setVideoEl(el: HTMLVideoElement | null): void;
|
|
112
|
+
activate(): void;
|
|
113
|
+
deactivate(): void;
|
|
114
|
+
startCamera(): Promise<void>;
|
|
115
|
+
stopCamera(): void;
|
|
116
|
+
capture(): void;
|
|
117
|
+
clearUrl(): void;
|
|
118
|
+
handleFetchImage(): Promise<void>;
|
|
119
|
+
handleCameraSwitch(): void;
|
|
120
|
+
getSnapshot(): CameraSnapshot;
|
|
121
|
+
destroy(): void;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
interface FileInputDeps {
|
|
125
|
+
getFileInput: () => HTMLInputElement | null;
|
|
126
|
+
setFiles: (files: File[]) => Promise<void>;
|
|
127
|
+
invalidate: () => void;
|
|
128
|
+
}
|
|
129
|
+
type FileInputSnapshot = Record<string, never>;
|
|
130
|
+
declare class FileInputController implements UploaderController<FileInputSnapshot> {
|
|
131
|
+
private deps;
|
|
132
|
+
constructor(deps: FileInputDeps);
|
|
133
|
+
open(): void;
|
|
134
|
+
openFolder(): void;
|
|
135
|
+
getSnapshot(): FileInputSnapshot;
|
|
136
|
+
destroy(): void;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** Flat, framework-free snapshot the render loop reads and subscribe() emits. */
|
|
140
|
+
interface UploaderSnapshot {
|
|
141
|
+
files: UploadFile[];
|
|
142
|
+
status: UploadStatus;
|
|
143
|
+
progress: {
|
|
144
|
+
totalFiles: number;
|
|
145
|
+
completedFiles: number;
|
|
146
|
+
percentage: number;
|
|
147
|
+
};
|
|
148
|
+
error: Error | null;
|
|
149
|
+
activeSource: FileSource | undefined;
|
|
150
|
+
viewMode: 'grid' | 'list';
|
|
151
|
+
}
|
|
152
|
+
/** Cloud-drive config shape accepted by createUploader (mirrors svelte UploaderProps.cloudDrives). */
|
|
153
|
+
interface VanillaCloudDrives {
|
|
154
|
+
googleDrive?: {
|
|
155
|
+
clientId: string;
|
|
156
|
+
apiKey: string;
|
|
157
|
+
appId: string;
|
|
158
|
+
};
|
|
159
|
+
oneDrive?: {
|
|
160
|
+
clientId: string;
|
|
161
|
+
redirectUri?: string;
|
|
162
|
+
};
|
|
163
|
+
dropbox?: {
|
|
164
|
+
clientId: string;
|
|
165
|
+
redirectUri?: string;
|
|
166
|
+
};
|
|
167
|
+
box?: {
|
|
168
|
+
clientId: string;
|
|
169
|
+
redirectUri?: string;
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
/** Options accepted by createUploader: the CoreOptions surface + UI + convenience callbacks. */
|
|
173
|
+
interface CreateUploaderOptions extends Omit<CoreOptions, 'cloudDrives'> {
|
|
174
|
+
/** Initial theme; true => dark. Maps to ThemeStore('dark'|'light'). */
|
|
175
|
+
dark?: boolean;
|
|
176
|
+
/** svelte UploaderProps.theme passthrough when present (takes precedence over `dark`). */
|
|
177
|
+
theme?: UpupThemeConfig;
|
|
178
|
+
sources?: UploadSource[];
|
|
179
|
+
/** Mirrors svelte UploaderProps.maxFiles — max number of files. Resolution: maxFiles ?? 10. */
|
|
180
|
+
maxFiles?: number;
|
|
181
|
+
className?: string;
|
|
182
|
+
showBranding?: boolean;
|
|
183
|
+
disableDragDrop?: boolean;
|
|
184
|
+
mini?: boolean;
|
|
185
|
+
/** Motion master switch. `false` disables every upup-fx animation (writes
|
|
186
|
+
* data-motion="off"); the OS reduced-motion preference also forces off.
|
|
187
|
+
* Default true. Not part of CoreOptions — resolved by normalizeUploaderOptions. */
|
|
188
|
+
animations?: boolean;
|
|
189
|
+
/** Quiet-completion mode: a successful run shows ONLY the checkmark overlay
|
|
190
|
+
* (no Done/add-more/CTA); the host takes over via the completion callbacks.
|
|
191
|
+
* Default false. */
|
|
192
|
+
quietCompletion?: boolean;
|
|
193
|
+
isProcessing?: boolean;
|
|
194
|
+
allowPreview?: boolean;
|
|
195
|
+
folderUpload?: {
|
|
196
|
+
allowDrop?: boolean;
|
|
197
|
+
showSelectFolderButton?: boolean;
|
|
198
|
+
};
|
|
199
|
+
cloudDrives?: VanillaCloudDrives;
|
|
200
|
+
i18n?: {
|
|
201
|
+
bundle?: LocaleBundle;
|
|
202
|
+
locale?: LocaleBundle | string;
|
|
203
|
+
fallbackLocale?: LocaleBundle | string;
|
|
204
|
+
overrides?: PartialMessages;
|
|
205
|
+
};
|
|
206
|
+
onFileAdded?: (files: UploadFile[]) => void;
|
|
207
|
+
onFileRemoved?: (file: UploadFile) => void;
|
|
208
|
+
onUploadProgress?: (p: {
|
|
209
|
+
fileId: string;
|
|
210
|
+
loaded: number;
|
|
211
|
+
total: number;
|
|
212
|
+
}) => void;
|
|
213
|
+
onUploadComplete?: (files: UploadFile[]) => void;
|
|
214
|
+
/** Called when the user clicks Done (before files are cleared) — mirrors svelte's onDoneClicked prop. */
|
|
215
|
+
onDoneClicked?: () => void;
|
|
216
|
+
/** Called when a source tile is clicked (before the source-click emit) — mirrors svelte's onIntegrationClick prop. */
|
|
217
|
+
onIntegrationClick?: (sourceId: string) => void;
|
|
218
|
+
onFilesDragOver?: (files: File[]) => void;
|
|
219
|
+
onFilesDragLeave?: (files: File[]) => void;
|
|
220
|
+
onFilesDrop?: (files: File[]) => void;
|
|
221
|
+
onWarn?: (message: string) => void;
|
|
222
|
+
enablePaste?: boolean;
|
|
223
|
+
}
|
|
224
|
+
/** Base controller contract. invalidate() is injected at construction by the render loop. */
|
|
225
|
+
interface UploaderController<S = unknown> {
|
|
226
|
+
getSnapshot(): S;
|
|
227
|
+
destroy(): void;
|
|
228
|
+
}
|
|
229
|
+
/** Controllers that own a source view also implement activate/deactivate. */
|
|
230
|
+
interface SourceController<S = unknown> extends UploaderController<S> {
|
|
231
|
+
activate(): void;
|
|
232
|
+
deactivate(): void;
|
|
233
|
+
}
|
|
234
|
+
/** Lazily-instantiated controllers, keyed; the render loop destroys inactive ones on source switch. */
|
|
235
|
+
interface ControllerRegistry {
|
|
236
|
+
fileInput: FileInputController;
|
|
237
|
+
dragDrop: DragDropController;
|
|
238
|
+
/** active per-source controller cache (camera/audio/screen/drive); see context.ts getController(). */
|
|
239
|
+
getCamera(): CameraController;
|
|
240
|
+
getAudio(): AudioRecorderController;
|
|
241
|
+
getScreen(): ScreenCaptureController;
|
|
242
|
+
/** drive browser controllers are core DriveBrowserController instances, cached by FileSource. */
|
|
243
|
+
getDrive(source: FileSource): DriveBrowserController;
|
|
244
|
+
/** destroy every cached per-source controller (called on source switch + destroy). */
|
|
245
|
+
destroyActive(): void;
|
|
246
|
+
/** destroy everything including fileInput + dragDrop (called on destroy). */
|
|
247
|
+
destroyAll(): void;
|
|
248
|
+
}
|
|
249
|
+
/** Resolved props (plain values, mirroring svelte ContextProps). */
|
|
250
|
+
interface UploaderContextProps {
|
|
251
|
+
mini: boolean;
|
|
252
|
+
sources: FileSource[];
|
|
253
|
+
allowedFileTypes: string;
|
|
254
|
+
limit: number;
|
|
255
|
+
maxFileSize: MaxFileSizeObject | undefined;
|
|
256
|
+
multiple: boolean;
|
|
257
|
+
isProcessing: boolean;
|
|
258
|
+
allowPreview: boolean;
|
|
259
|
+
showBranding: boolean;
|
|
260
|
+
disableDragDrop: boolean;
|
|
261
|
+
className: string;
|
|
262
|
+
folderUploadAllowDrop: boolean;
|
|
263
|
+
folderPickerButtonVisible: boolean;
|
|
264
|
+
imageEditor: ResolvedImageEditorOptions;
|
|
265
|
+
quietCompletion: boolean;
|
|
266
|
+
onIntegrationClick: (sourceId: string) => void;
|
|
267
|
+
resumable: CoreOptions['resumable'];
|
|
268
|
+
}
|
|
269
|
+
/** The flat root context every template fn receives. Replicates svelte createUploaderController data without core extraction. */
|
|
270
|
+
interface UploaderContext {
|
|
271
|
+
core: UpupCore;
|
|
272
|
+
orchestrator: UploaderOrchestrator;
|
|
273
|
+
theme: ThemeStore;
|
|
274
|
+
mode: 'client' | 'server';
|
|
275
|
+
serverUrl: string | undefined;
|
|
276
|
+
translations: Translations;
|
|
277
|
+
translator: Translator;
|
|
278
|
+
lang: string;
|
|
279
|
+
dir: 'ltr' | 'rtl';
|
|
280
|
+
props: UploaderContextProps;
|
|
281
|
+
cloudDrives?: CloudDrivesConfig | undefined;
|
|
282
|
+
registerFileInput(el: HTMLInputElement | null): void;
|
|
283
|
+
getFileInput(): HTMLInputElement | null;
|
|
284
|
+
openFilePicker(): void;
|
|
285
|
+
setActiveSource(a: FileSource | undefined): void;
|
|
286
|
+
setIsAddingMore(v: boolean): void;
|
|
287
|
+
setViewMode(m: 'grid' | 'list'): void;
|
|
288
|
+
/** Current transient-UI snapshot (deferred removal / add-more overlay / drop
|
|
289
|
+
* toast). Read in render; the render loop re-subscribes via controller.subscribe. */
|
|
290
|
+
getTransientUi(): TransientUiSnapshot;
|
|
291
|
+
/** Current motion-gate resolution ('on' | 'off'); the panel writes it as
|
|
292
|
+
* data-motion so the shared CSS gates every upup-fx-* rule. */
|
|
293
|
+
getMotionMode(): MotionMode;
|
|
294
|
+
/** Add-more source overlay commands (core transient-UI store; idempotent). */
|
|
295
|
+
openSourceOverlay(): void;
|
|
296
|
+
closeSourceOverlay(): void;
|
|
297
|
+
/** Raise the drive drop-rejection toast for `source` (resolves the human
|
|
298
|
+
* provider label, then core owns the 3s auto-clear). */
|
|
299
|
+
flagDriveDropRejected(source: FileSource): void;
|
|
300
|
+
setFiles(files: File[]): Promise<void>;
|
|
301
|
+
handleFileRemove(fileId: string): void;
|
|
302
|
+
handleRemoveAll(): void;
|
|
303
|
+
startUpload(): Promise<UploadFile[] | undefined>;
|
|
304
|
+
retryUpload(fileId?: string): Promise<UploadFile[] | undefined>;
|
|
305
|
+
handleDone(): void;
|
|
306
|
+
handleCancel(): void;
|
|
307
|
+
handlePause(): void;
|
|
308
|
+
handleResume(): void;
|
|
309
|
+
controllers: ControllerRegistry;
|
|
310
|
+
/** request a re-render (microtask-coalesced by the render loop). */
|
|
311
|
+
invalidate(): void;
|
|
312
|
+
/** Report a user-facing error message (routed to options.onError). Used by URL fetch + other views. */
|
|
313
|
+
onError?: (message: string) => void;
|
|
314
|
+
}
|
|
315
|
+
/** The public instance returned by createUploader. Mirrors svelte UseUpupUploadReturn + lifecycle. */
|
|
316
|
+
interface UpupInstance {
|
|
317
|
+
getState(): UploaderSnapshot;
|
|
318
|
+
subscribe(cb: (s: UploaderSnapshot) => void): () => void;
|
|
319
|
+
addFiles(files: File[]): Promise<void>;
|
|
320
|
+
removeFile(id: string): void;
|
|
321
|
+
removeAll(): void;
|
|
322
|
+
setFiles(files: File[]): Promise<void>;
|
|
323
|
+
reorderFiles(ids: string[]): void;
|
|
324
|
+
upload(): Promise<UploadFile[]>;
|
|
325
|
+
pause(): void;
|
|
326
|
+
resume(): void;
|
|
327
|
+
cancel(): void;
|
|
328
|
+
retry(fileId?: string): Promise<UploadFile[]>;
|
|
329
|
+
on(event: string, h: (...a: unknown[]) => void): () => void;
|
|
330
|
+
ext: Record<string, ExtensionMethods>;
|
|
331
|
+
core: UpupCore;
|
|
332
|
+
el: HTMLElement;
|
|
333
|
+
destroy(): void;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
export type { CreateUploaderOptions as C, UpupInstance as U, UploaderSnapshot as a, UploaderContext as b };
|