Skip to content

Commit

Permalink
feat(type): add file system access interface
Browse files Browse the repository at this point in the history
  • Loading branch information
TomokiMiyauci committed Jul 30, 2024
1 parent 7a4eddd commit 9a74e3a
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions src/type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import type { IO, UnderlyingFileSystem } from "@miyauci/file-system";

export interface FilePickerOptions {
types?: FilePickerAcceptType[];
excludeAcceptAllOption?: boolean;

id?: string;

startIn?: StartInDirectory;
}

export interface FilePickerAcceptType {
description?: string;

accept: Record<string, string | string[]>;
}

export interface DirectoryPickerOptions {
id?: string;
startIn?: StartInDirectory;
mode?: FileSystemPermissionMode;
}

export type WellKnownDirectory =
| "desktop"
| "documents"
| "downloads"
| "music"
| "pictures"
| "videos";

export type FileSystemPermissionMode = "read" | "readwrite";

export type StartInDirectory = WellKnownDirectory | FileSystemHandle;

export interface FileSystemPermissionDescriptor extends PermissionDescriptor {
handle: FileSystemHandle;
mode: "read" | "readwrite";
}

export interface OpenFilePickerOptions extends FilePickerOptions {
multiple?: boolean;
}

export interface OpenDirectoryPicker {
(options?: DirectoryPickerOptions): { root: string };
}

export interface OpenFileDialog {
(options?: OpenFilePickerOptions): { root: string; name: string }[];
}

export interface Adaptor {
openFileDialog: OpenFileDialog;
openDirectoryDialog: OpenDirectoryPicker;
fs: UnderlyingFileSystem;
io: IO;
}

0 comments on commit 9a74e3a

Please sign in to comment.