1
0
forked from um/web
web/src/shims-fs.d.ts

59 lines
1.3 KiB
TypeScript
Raw Normal View History

2021-05-24 19:06:28 +00:00
export interface FileSystemGetFileOptions {
create?: boolean
}
interface FileSystemCreateWritableOptions {
keepExistingData?: boolean
}
2021-05-24 20:36:32 +00:00
interface FileSystemRemoveOptions {
recursive?: boolean
}
2021-05-24 19:06:28 +00:00
interface FileSystemFileHandle {
getFile(): Promise<File>;
createWritable(options?: FileSystemCreateWritableOptions): Promise<FileSystemWritableFileStream>
}
enum WriteCommandType {
write = "write",
seek = "seek",
truncate = "truncate",
}
interface WriteParams {
type: WriteCommandType
size?: number
position?: number
data: BufferSource | Blob | string
}
type FileSystemWriteChunkType = BufferSource | Blob | string | WriteParams
interface FileSystemWritableFileStream extends WritableStream {
write(data: FileSystemWriteChunkType): Promise<undefined>
seek(position: number): Promise<undefined>
truncate(size: number): Promise<undefined>
close(): Promise<undefined> // should be implemented in WritableStream
}
2021-05-24 20:36:32 +00:00
2021-05-24 19:06:28 +00:00
export declare interface FileSystemDirectoryHandle {
getFileHandle(name: string, options?: FileSystemGetFileOptions): Promise<FileSystemFileHandle>
2021-05-24 20:36:32 +00:00
removeEntry(name: string, options?: FileSystemRemoveOptions): Promise<undefined>
2021-05-24 19:06:28 +00:00
}
declare global {
interface Window {
showDirectoryPicker?(): Promise<FileSystemDirectoryHandle>
}
}