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

55 lines
1.3 KiB
TypeScript
Raw Normal View History

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