diff --git a/src/type.ts b/src/type.ts new file mode 100644 index 0000000..97cf9a7 --- /dev/null +++ b/src/type.ts @@ -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; +} + +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; +}