Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define entry points for File System API #9128

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/bom.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ declare class StorageManager {
persist: () => Promise<boolean>;
persisted: () => Promise<boolean>;
estimate?: () => Promise<StorageEstimate>;
getDirectory: () => Promise<FileSystemDirectoryHandle>;
}

type StorageManagerRegisteredEndpoint = 'caches' | 'indexedDB' | 'localStorage' | 'serviceWorkerRegistrations' | 'sessionStorage';
Expand Down
68 changes: 68 additions & 0 deletions lib/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ declare class DataTransferItemList {
clear(): void;
};

// https://wicg.github.io/file-system-access/#drag-and-drop
declare class DataTransferItem {
kind: string; // readonly
type: string; // readonly
Expand All @@ -124,6 +125,12 @@ declare class DataTransferItem {
* https://developer.mozilla.org/en-US/docs/Web/API/DataTransferItem/webkitGetAsEntry
*/
webkitGetAsEntry(): void | () => any;
/*
* Not supported in all browsers
* For up to date compatibility information, please visit
* https://developer.mozilla.org/en-US/docs/Web/API/DataTransferItem/getAsFileSystemHandle
*/
getAsFileSystemHandle?: () => Promise<?FileSystemHandle>;
};

/* DOM */
Expand Down Expand Up @@ -4522,6 +4529,67 @@ declare function scrollTo(options: ScrollToOptions): void;
declare function scrollBy(x: number, y: number): void;
declare function scrollBy(options: ScrollToOptions): void;

/* Window file picker */

type WindowFileSystemPickerFileType = {|
description?: string,
/*
* An Object with the keys set to the MIME type
* and the values an Array of file extensions
* Example:
* accept: {
* "image/*": [".png", ".gif", ".jpeg", ".jpg"],
* },
*/
accept: {
[string]: Array<string>,
},
|};

type WindowBaseFilePickerOptions = {|
id?: number,
startIn?:
| FileSystemHandle
| "desktop"
| "documents"
| "downloads"
| "music"
| "pictures"
| "videos",
|};

type WindowFilePickerOptions = WindowBaseFilePickerOptions & {|
excludeAcceptAllOption?: boolean,
types?: Array<WindowFileSystemPickerFileType>,
|};

type WindowOpenFilePickerOptions = WindowFilePickerOptions & {|
multiple?: boolean,
|};

type WindowSaveFilePickerOptions = WindowFilePickerOptions & {|
suggestedName?: string,
|};

type WindowDirectoryFilePickerOptions = WindowBaseFilePickerOptions & {|
mode?: "read" | "readwrite",
|};

// https://wicg.github.io/file-system-access/#api-showopenfilepicker
declare function showOpenFilePicker(
options?: WindowOpenFilePickerOptions
): Promise<Array<FileSystemFileHandle>>;

// https://wicg.github.io/file-system-access/#api-showsavefilepicker
declare function showSaveFilePicker(
options?: WindowSaveFilePickerOptions
): Promise<FileSystemFileHandle>;

// https://wicg.github.io/file-system-access/#api-showdirectorypicker
declare function showDirectoryPicker(
options?: WindowDirectoryFilePickerOptions
): Promise<FileSystemDirectoryHandle>;

/* Notification */
type NotificationPermission = 'default' | 'denied' | 'granted';
type NotificationDirection = 'auto' | 'ltr' | 'rtl';
Expand Down
Loading
Loading