feat(files): upload files with drag and drop

This commit is contained in:
Bohdan Triapitsyn
2026-08-18 21:24:53 +03:00
parent 215749a65f
commit 423f5b9652
20 changed files with 657 additions and 4 deletions
@@ -25,4 +25,9 @@ describe('FilesystemError', () => {
expect(parseFilesystemErrorReason('made-up')).toBe('unknown');
expect(parseFilesystemErrorReason(undefined)).toBe('unknown');
});
test('recognizes filesystem errors created across runtime boundaries', () => {
expect(isFilesystemError({ reason: 'already-exists' })).toBe(true);
expect(isFilesystemError({ reason: 409 })).toBe(false);
});
});
+2
View File
@@ -1,5 +1,6 @@
export type FilesystemErrorReason =
| 'os-permission'
| 'already-exists'
| 'not-found'
| 'not-directory'
| 'invalid-response'
@@ -30,6 +31,7 @@ export const isFilesystemError = (error: unknown): error is FilesystemError => (
export const parseFilesystemErrorReason = (value: unknown): FilesystemErrorReason => {
switch (value) {
case 'os-permission':
case 'already-exists':
case 'not-found':
case 'not-directory':
case 'invalid-response':
+1
View File
@@ -606,6 +606,7 @@ export interface FilesAPI {
readFile?(path: string, options?: FileReadOptions): Promise<{ content: string; path: string }>;
readFileBinary?(path: string, options?: FileReadOptions): Promise<{ dataUrl: string; path: string }>;
writeFile?(path: string, content: string): Promise<{ success: boolean; path: string }>;
uploadFile?(path: string, file: Blob, options?: { overwrite?: boolean; directory?: string }): Promise<{ success: boolean; path: string }>;
delete?(path: string): Promise<{ success: boolean }>;
rename?(oldPath: string, newPath: string): Promise<{ success: boolean; path: string }>;
revealPath?(path: string): Promise<{ success: boolean }>;