use new types for browser fs

This commit is contained in:
Benjamin Pasero
2021-04-20 07:46:57 +02:00
parent a09354329b
commit ab27efcc9f
2 changed files with 7 additions and 36 deletions

View File

@@ -1409,37 +1409,8 @@ export function multibyteAwareBtoa(str: string): string {
*/
export namespace WebFileSystemAccess {
// https://wicg.github.io/file-system-access/#dom-window-showdirectorypicker
export interface FileSystemAccess {
showDirectoryPicker: () => Promise<FileSystemDirectoryHandle>;
}
// https://wicg.github.io/file-system-access/#api-filesystemdirectoryhandle
export interface FileSystemDirectoryHandle {
readonly kind: 'directory',
readonly name: string,
getFileHandle: (name: string, options?: { create?: boolean }) => Promise<FileSystemFileHandle>;
getDirectoryHandle: (name: string, options?: { create?: boolean }) => Promise<FileSystemDirectoryHandle>;
}
// https://wicg.github.io/file-system-access/#api-filesystemfilehandle
export interface FileSystemFileHandle {
readonly kind: 'file',
readonly name: string,
createWritable: (options?: { keepExistingData?: boolean }) => Promise<FileSystemWritableFileStream>;
}
// https://wicg.github.io/file-system-access/#api-filesystemwritablefilestream
export interface FileSystemWritableFileStream {
write: (buffer: Uint8Array) => Promise<void>;
close: () => Promise<void>;
}
export function supported(obj: any & Window): obj is FileSystemAccess {
const candidate = obj as FileSystemAccess | undefined;
if (typeof candidate?.showDirectoryPicker === 'function') {
export function supported(obj: any & Window): boolean {
if (typeof obj?.showDirectoryPicker === 'function') {
return true;
}