mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 22:30:01 +00:00
Changes written with chrome-test and source code help
This commit is contained in:
4
types/chrome-apps/appview.d.ts
vendored
4
types/chrome-apps/appview.d.ts
vendored
@@ -18,6 +18,8 @@
|
||||
* @see[Documentation]{@link https://developer.chrome.com/apps/tags/appview}
|
||||
*/
|
||||
declare class HTMLAppViewElement extends HTMLElement {
|
||||
/** Create a new AppView tag */
|
||||
constructor ();
|
||||
/**
|
||||
* Requests another app to be embedded.
|
||||
* @param app The extension id of the app to be embedded.
|
||||
@@ -45,3 +47,5 @@ declare namespace AppView {
|
||||
declare interface Document {
|
||||
createElement(element: 'appview'): HTMLAppViewElement;
|
||||
}
|
||||
|
||||
declare const AppView: typeof HTMLAppViewElement;
|
||||
|
||||
20
types/chrome-apps/chrome.test.d.ts
vendored
Normal file
20
types/chrome-apps/chrome.test.d.ts
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
/// <reference path='./index.d.ts' />
|
||||
declare namespace chrome {
|
||||
namespace test {
|
||||
function sendMessage(...msg: any[]): any;
|
||||
function getConfig(callback: (config: any) => any): any;
|
||||
function assertEq(...e: any[]): boolean;
|
||||
function succeed(): any;
|
||||
function fail(reason?: any): any;
|
||||
function notifyPass(): any;
|
||||
function notifyFail(reason: any): any;
|
||||
function assertTrue(...e: any[]): any;
|
||||
function assertFalse(...e: any[]): any;
|
||||
function callbackPass(callback: () => any): any;
|
||||
function callbackPass(callback: (param: any) => any): any;
|
||||
function callbackPass(callback: (...params: any[]) => any): any;
|
||||
function callbackFail(reason: any): any;
|
||||
function listenOnce<F extends Function, E extends chrome.events.Event<F>>(event: E, callback: F): any;
|
||||
function runTests(...tests: any[]): any;
|
||||
}
|
||||
}
|
||||
97
types/chrome-apps/index.d.ts
vendored
97
types/chrome-apps/index.d.ts
vendored
@@ -3200,7 +3200,7 @@ declare namespace chrome {
|
||||
/**
|
||||
* Fired when file system action is executed from ChromeOS file browser.
|
||||
*/
|
||||
const onExecute: chrome.events.Event<(id: FileBrowserHandleExecuteId, details: { entries: Entry[] }) => void>;
|
||||
const onExecute: chrome.events.Event<(id: FileBrowserHandleExecuteId, details: { entries: FileEntry[] }) => void>;
|
||||
}
|
||||
// #endregion
|
||||
|
||||
@@ -3270,36 +3270,62 @@ declare namespace chrome {
|
||||
extensions?: string[];
|
||||
}
|
||||
|
||||
interface ChooseEntryOptions {
|
||||
interface ChooseEntryOptionsBase {
|
||||
/**
|
||||
* Type of the prompt to show.
|
||||
* @default 'openFile'
|
||||
* @see ChooseEntryType
|
||||
*/
|
||||
type?: ToStringLiteral<typeof ChooseEntryType>;
|
||||
// type?: ToStringLiteral<typeof ChooseEntryType>;
|
||||
|
||||
/**
|
||||
* The suggested file name that will be presented to the user as the default name to read or write.
|
||||
*/
|
||||
suggestedName?: string;
|
||||
|
||||
/**
|
||||
* The optional list of accept options for this file opener.
|
||||
* Each option will be presented as a unique group to the end-user.
|
||||
*/
|
||||
accepts?: AcceptOptions[];
|
||||
|
||||
/**
|
||||
* Whether to accept all file types, in addition to the options specified in the accepts argument.
|
||||
* If the accepts field is unset or contains no valid entries, this will always be reset to true.
|
||||
* @default true
|
||||
*/
|
||||
acceptsAllTypes?: boolean;
|
||||
}
|
||||
interface ChooseSaveFileEntryOptions extends ChooseEntryOptionsBase {
|
||||
type: 'saveFile';
|
||||
}
|
||||
interface ChooseFileEntryOptions extends ChooseEntryOptionsBase {
|
||||
type: 'openFile' | 'openWritableFile';
|
||||
/**
|
||||
* Whether to accept multiple files. This is only supported for openFile and openWritableFile.
|
||||
* The callback to chooseEntry will be called with a list of entries if this is set to true.
|
||||
* Otherwise it will be called with a single Entry.
|
||||
* @default false
|
||||
* @since Chrome 30.
|
||||
*/
|
||||
acceptsMultiple?: boolean;
|
||||
acceptsMultiple?: false;
|
||||
}
|
||||
interface ChooseMultipleFilesEntryOptions extends ChooseEntryOptionsBase {
|
||||
type: 'openFile' | 'openWritableFile';
|
||||
|
||||
/**
|
||||
* Whether to accept multiple files. This is only supported for openFile and openWritableFile.
|
||||
* The callback to chooseEntry will be called with a list of entries if this is set to true.
|
||||
* Otherwise it will be called with a single Entry.
|
||||
* @default false
|
||||
* @since Chrome 30.
|
||||
*/
|
||||
acceptsMultiple: true;
|
||||
}
|
||||
interface ChooseDirectoryEntryOptions extends ChooseEntryOptionsBase {
|
||||
type: 'openDirectory';
|
||||
}
|
||||
type ChooseEntryOptions = ChooseFileEntryOptions | ChooseSaveFileEntryOptions | ChooseMultipleFilesEntryOptions | ChooseDirectoryEntryOptions | ChooseEntryOptionsBase;
|
||||
|
||||
/**
|
||||
* @since Chrome 44.
|
||||
@@ -3314,28 +3340,36 @@ declare namespace chrome {
|
||||
writable?: boolean;
|
||||
}
|
||||
|
||||
/** @private */
|
||||
type FileEntryCallback<
|
||||
T extends ChooseEntryOptions,
|
||||
E = T extends ChooseFileEntryOptions ? FileEntry :
|
||||
T extends ChooseMultipleFilesEntryOptions ? FileEntry[] :
|
||||
T extends ChooseDirectoryEntryOptions ? DirectoryEntry :
|
||||
FileEntry> = (selectedEntries: E) => void;
|
||||
|
||||
/**
|
||||
* Get the display path of an Entry object.
|
||||
* The display path is based on the full path of the file or directory on the local file system, but may be made more readable for display purposes.
|
||||
*/
|
||||
function getDisplayPath(entry: Entry, callback: (displayPath: string) => void): void;
|
||||
function getDisplayPath(entry: FileEntry | DirectoryEntry, callback: (displayPath: string) => void): void;
|
||||
/**
|
||||
* Get a writable Entry from another Entry. This call will fail with a runtime error if the application does not have the 'write' permission under 'fileSystem'.
|
||||
* If entry is a DirectoryEntry, this call will fail if the application does not have the 'directory' permission under 'fileSystem'.
|
||||
*/
|
||||
function getWritableEntry(entry: Entry, callback: (entry: Entry) => void): void;
|
||||
function getWritableEntry<T extends FileEntry | DirectoryEntry>(entry: T, callback: (entry: T) => void): void;
|
||||
/** Gets whether this Entry is writable or not. */
|
||||
function isWritableEntry(entry: Entry, callback: (isWritable: boolean) => void): void;
|
||||
function isWritableEntry(entry: FileEntry | DirectoryEntry, callback: (isWritable: boolean) => void): void;
|
||||
/** Ask the user to choose a file or directory. */
|
||||
function chooseEntry(callback: (entry: Entry) => void): void;
|
||||
function chooseEntry(callback: FileEntryCallback<ChooseFileEntryOptions>): void;
|
||||
/** Ask the user to choose a file or directory. */
|
||||
function chooseEntry(callback: (fileEntries: FileEntry[]) => void): void;
|
||||
/** Ask the user to choose a file or directory. */
|
||||
function chooseEntry(options: ChooseEntryOptions, callback: (entry: Entry) => void): void;
|
||||
/** Ask the user to choose a file or directory. */
|
||||
function chooseEntry(options: ChooseEntryOptions, callback: (fileEntries: FileEntry[]) => void): void;
|
||||
function chooseEntry(options: ChooseEntryOptionsBase, callback: FileEntryCallback<ChooseEntryOptionsBase>): void;
|
||||
function chooseEntry(options: ChooseFileEntryOptions, callback: FileEntryCallback<ChooseFileEntryOptions>): void;
|
||||
function chooseEntry(options: ChooseSaveFileEntryOptions, callback: FileEntryCallback<ChooseSaveFileEntryOptions>): void;
|
||||
function chooseEntry(options: ChooseMultipleFilesEntryOptions, callback: FileEntryCallback<ChooseFileEntryOptions>): void;
|
||||
function chooseEntry(options: ChooseDirectoryEntryOptions, callback: FileEntryCallback<ChooseDirectoryEntryOptions>): void;
|
||||
/** Returns the file entry with the given id if it can be restored. This call will fail with a runtime error otherwise. */
|
||||
function restoreEntry(id: string, callback: (entry: Entry) => void): void;
|
||||
function restoreEntry(id: string, callback: (entry: FileEntry) => void): void;
|
||||
/**
|
||||
* Returns whether the app has permission to restore the entry with the given id.
|
||||
* @since Chrome 29.
|
||||
@@ -3348,7 +3382,7 @@ declare namespace chrome {
|
||||
* Otherwise, entries are retained only while the app is running and across restarts.
|
||||
* @since Chrome 29.
|
||||
* */
|
||||
function retainEntry(entry: Entry): string;
|
||||
function retainEntry(entry: FileEntry | DirectoryEntry): string;
|
||||
/**
|
||||
* @requires(Kiosk) Kiosk mode only
|
||||
* @requires Permissions: The writable option requires the 'fileSystem': {'write'} permission in the manifest.
|
||||
@@ -3374,12 +3408,6 @@ declare namespace chrome {
|
||||
* @since Chrome 44.
|
||||
*/
|
||||
const onVolumeListChanged: chrome.events.Event<(object: Volume[]) => void>;
|
||||
/** @todo TODO Document these: */
|
||||
const observeDirectory: Function;
|
||||
const unobserveEntry: Function;
|
||||
const getObservedEntries: Function;
|
||||
const onEntrychanged: chrome.events.Event<any>;
|
||||
const onEntryRemoved: chrome.events.Event<any>;
|
||||
}
|
||||
// #endregion
|
||||
|
||||
@@ -8028,7 +8056,7 @@ declare namespace chrome {
|
||||
* If sending to your extension, the runtime.onMessage event will be fired in each page, or runtime.onMessageExternal, if a different extension.
|
||||
* Note that extensions cannot send messages to content scripts using this method.
|
||||
* @since Chrome 26.
|
||||
* @param responseCallback Optional
|
||||
* @param [responseCallback]
|
||||
* Parameter response: The JSON response object sent by the handler of the message. If an error occurs while connecting to the extension, the callback will be called with no arguments and runtime.lastError will be set to the error message.
|
||||
*/
|
||||
function sendMessage(message: any, responseCallback?: (response: any) => void): void;
|
||||
@@ -8036,28 +8064,19 @@ declare namespace chrome {
|
||||
/**
|
||||
* Sends a single message to event listeners within your app or a different app. Similar to runtime.connect but only sends a single message, with an optional response. If sending to your extension, the runtime.onMessage event will be fired in each page, or runtime.onMessageExternal, if a different extension. Note that extensions cannot send messages to content scripts using this method.
|
||||
* @since Chrome 32.
|
||||
* @param responseCallback Optional
|
||||
* @param [responseCallback]
|
||||
* Parameter response: The JSON response object sent by the handler of the message. If an error occurs while connecting to the extension, the callback will be called with no arguments and runtime.lastError will be set to the error message.
|
||||
*/
|
||||
function sendMessage(message: any, options: MessageOptions, responseCallback?: (response: any) => void): void;
|
||||
|
||||
/**
|
||||
* Sends a single message to event listeners within your app or a different app. Similar to runtime.connect but only sends a single message, with an optional response. If sending to your extension, the runtime.onMessage event will be fired in each page, or runtime.onMessageExternal, if a different extension. Note that extensions cannot send messages to content scripts using this method.
|
||||
* @since Chrome 26.
|
||||
* @param extensionId The ID of the app to send the message to. If omitted, the message will be sent to your own app. Required if sending messages from a web page for web messaging.
|
||||
* @param responseCallback Optional
|
||||
* Parameter response: The JSON response object sent by the handler of the message. If an error occurs while connecting to the extension, the callback will be called with no arguments and runtime.lastError will be set to the error message.
|
||||
*/
|
||||
function sendMessage(extensionId: string, message: any, responseCallback?: (response: any) => void): void;
|
||||
function sendMessage(message: any, options?: MessageOptions | null, responseCallback?: (response: any) => void): void;
|
||||
|
||||
/**
|
||||
* Sends a single message to event listeners within your app or a different app. Similar to runtime.connect but only sends a single message, with an optional response. If sending to your extension, the runtime.onMessage event will be fired in each page, or runtime.onMessageExternal, if a different extension. Note that extensions cannot send messages to content scripts using this method.
|
||||
* @since Chrome 32.
|
||||
* @param extensionId The ID of the app to send the message to. If omitted, the message will be sent to your own app. Required if sending messages from a web page for web messaging.
|
||||
* @param responseCallback Optional
|
||||
* @param [responseCallback]
|
||||
* Parameter response: The JSON response object sent by the handler of the message. If an error occurs while connecting to the extension, the callback will be called with no arguments and runtime.lastError will be set to the error message.
|
||||
*/
|
||||
function sendMessage(extensionId: string, message: any, options: MessageOptions, responseCallback?: (response: any) => void): void;
|
||||
function sendMessage(extensionId: string, message: any, options?: MessageOptions | null, responseCallback?: (response: any) => void): void;
|
||||
|
||||
/**
|
||||
* Send a single message to a native application.
|
||||
@@ -9072,7 +9091,7 @@ declare namespace chrome {
|
||||
|
||||
interface FileStatusInfo {
|
||||
/** One of the Entry's originally given to getFileStatuses. */
|
||||
fileEntry: Entry;
|
||||
fileEntry: FileEntry;
|
||||
/**
|
||||
* Status value
|
||||
* @see FileStatus
|
||||
@@ -9088,7 +9107,7 @@ declare namespace chrome {
|
||||
* On file deletion, fileEntry information will still be
|
||||
* available but file will no longer exist.
|
||||
*/
|
||||
fileEntry: Entry;
|
||||
fileEntry: FileEntry;
|
||||
/**
|
||||
* Resulting file status after onFileStatusChanged event.
|
||||
* @see FileStatus
|
||||
@@ -9150,9 +9169,9 @@ declare namespace chrome {
|
||||
* the service's conflict resolution policy is set to 'manual'.
|
||||
* @see FileStatus
|
||||
* */
|
||||
function getFileStatus(fileEntry: Entry, callback: (status: ToStringLiteral<typeof FileStatus>) => void): void;
|
||||
function getFileStatus(fileEntry: FileEntry, callback: (status: ToStringLiteral<typeof FileStatus>) => void): void;
|
||||
/** Returns each FileStatus for the given fileEntry array. Typically called with the result from dirReader.readEntries(). */
|
||||
function getFileStatuses(fileEntries: Entry[], callback: (status: FileStatusInfo[]) => void): void;
|
||||
function getFileStatuses(fileEntries: FileEntry[], callback: (status: FileStatusInfo[]) => void): void;
|
||||
/**
|
||||
* Returns the current sync backend status.
|
||||
* @since Chrome 31.
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
* @author Nikolai Ommundsen (niikoo {@link https://github.com/niikoo})
|
||||
* @author The Chromium Authors
|
||||
*/
|
||||
/// <reference path="../chrome.test.d.ts" />
|
||||
|
||||
import runtime = chrome.app.runtime;
|
||||
const cwindow = chrome.app.window;
|
||||
@@ -874,7 +875,7 @@ chrome.fileBrowserHandler.onExecute.addListener((id, details) => {
|
||||
// FILE SYSTEM
|
||||
// https://developer.chrome.com/apps/fileSystem
|
||||
|
||||
function test_fileSystem(): void {
|
||||
((): void => {
|
||||
var accepts: chrome.fileSystem.AcceptOptions[] = [
|
||||
{ mimeTypes: ['text/*'], extensions: ['js', 'css', 'txt', 'html', 'xml', 'tsv', 'csv', 'rtf'] }
|
||||
];
|
||||
@@ -885,7 +886,7 @@ function test_fileSystem(): void {
|
||||
acceptsAllTypes: false,
|
||||
acceptsMultiple: false
|
||||
};
|
||||
chrome.fileSystem.chooseEntry(chooseOption, (entry: Entry) => {
|
||||
chrome.fileSystem.chooseEntry(chooseOption, (entry) => {
|
||||
chrome.fileSystem.getDisplayPath(entry, (displayPath: string) => { });
|
||||
|
||||
var retainedId = chrome.fileSystem.retainEntry(entry);
|
||||
@@ -898,7 +899,21 @@ function test_fileSystem(): void {
|
||||
chrome.fileSystem.getWritableEntry(entry, (writableEntry: Entry) => { });
|
||||
chrome.fileSystem.isWritableEntry(entry, (isWritable: boolean) => { });
|
||||
});
|
||||
}
|
||||
})();
|
||||
chrome.app.runtime.onLaunched.addListener(() => {
|
||||
chrome.app.window.create('index.html', { width: 100, height: 100 },
|
||||
win => {
|
||||
var fs = win.contentWindow.chrome.fileSystem;
|
||||
fs.chooseEntry({ type: 'openFile', acceptsAllTypes: false, acceptsMultiple: true }, (entry) => {
|
||||
fs.getWritableEntry(entry, (writableEntry) => {
|
||||
var id = fs.retainEntry(entry);
|
||||
chrome.storage.local.set({ id: id }, () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// #endregion
|
||||
|
||||
// #region chrome.gcm
|
||||
@@ -1269,11 +1284,18 @@ chrome.runtime.onMessageExternal.addListener((request, sender, sendResponse) =>
|
||||
chrome.runtime.sendMessage(
|
||||
chrome.runtime.id,
|
||||
{ myCustomMessage: 'tra laa la' },
|
||||
(response) => {
|
||||
null,
|
||||
(response: any) => {
|
||||
console.log('Response: ' + JSON.stringify(response));
|
||||
}
|
||||
);
|
||||
|
||||
chrome.runtime.getPackageDirectoryEntry((pentry) => {
|
||||
pentry.getFile('manifest.json', undefined, (file) => {
|
||||
return file.name;
|
||||
}, err => console.error(err));
|
||||
});
|
||||
|
||||
chrome.runtime.reload();
|
||||
chrome.runtime.requestUpdateCheck((status, details) => {
|
||||
if (status === chrome.runtime.RequestUpdateCheckStatus.THROTTLED) {
|
||||
@@ -1759,7 +1781,7 @@ chrome.wallpaper.setWallpaper({
|
||||
// #region chrome.webViewRequest & WebView
|
||||
|
||||
let wve = document.createElement('webview');
|
||||
wve = new window.WebView();
|
||||
wve = new WebView() || new window.WebView();
|
||||
wve.name = 'test';
|
||||
wve.src = 'https://github.com/DefinitelyTyped';
|
||||
wve.allowtransparency = true;
|
||||
@@ -1925,10 +1947,13 @@ chrome.app.runtime.onEmbedRequested.addListener((request) => {
|
||||
request.allow('foobar.html');
|
||||
});
|
||||
// Creates an <appview> element.
|
||||
var appview = document.createElement('appview');
|
||||
let appview = document.createElement('appview');
|
||||
appview = new AppView() || new window.AppView();
|
||||
// Appends the element to the document body.
|
||||
document.body.appendChild(appview);
|
||||
// Connects the appview to appToEmbed.
|
||||
appview.connect('id of app');
|
||||
document.appendChild(appview);
|
||||
//#endregion
|
||||
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"chrome.test.d.ts",
|
||||
"test/index.ts"
|
||||
]
|
||||
}
|
||||
|
||||
2
types/chrome-apps/webview.d.ts
vendored
2
types/chrome-apps/webview.d.ts
vendored
@@ -1491,3 +1491,5 @@ declare namespace WebView {
|
||||
declare interface Document {
|
||||
createElement(element: 'webview'): HTMLWebViewElement;
|
||||
}
|
||||
|
||||
declare const WebView: typeof HTMLWebViewElement;
|
||||
|
||||
190
types/filesystem/index.d.ts
vendored
190
types/filesystem/index.d.ts
vendored
@@ -1,21 +1,21 @@
|
||||
// Type definitions for File System API
|
||||
// Project: http://www.w3.org/TR/file-system-api/
|
||||
// Definitions by: Kon <http://phyzkit.net/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// Definitions by: Kon <http://phyzkit.net/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="filewriter" />
|
||||
|
||||
interface LocalFileSystem {
|
||||
|
||||
|
||||
/**
|
||||
* Used for storage with no guarantee of persistence.
|
||||
*/
|
||||
TEMPORARY:number;
|
||||
TEMPORARY: number;
|
||||
|
||||
/**
|
||||
* Used for storage that should not be removed by the user agent without application or user permission.
|
||||
*/
|
||||
PERSISTENT:number;
|
||||
PERSISTENT: number;
|
||||
|
||||
/**
|
||||
* Requests a filesystem in which to store application data.
|
||||
@@ -24,50 +24,50 @@ interface LocalFileSystem {
|
||||
* @param successCallback The callback that is called when the user agent provides a filesystem.
|
||||
* @param errorCallback A callback that is called when errors happen, or when the request to obtain the filesystem is denied.
|
||||
*/
|
||||
requestFileSystem(type:number, size:number, successCallback:FileSystemCallback, errorCallback?:ErrorCallback):void;
|
||||
|
||||
requestFileSystem(type: number, size: number, successCallback: FileSystemCallback, errorCallback?: ErrorCallback): void;
|
||||
|
||||
/**
|
||||
* Allows the user to look up the Entry for a file or directory referred to by a local URL.
|
||||
* @param url A URL referring to a local file in a filesystem accessable via this API.
|
||||
* @param successCallback A callback that is called to report the Entry to which the supplied URL refers.
|
||||
* @param errorCallback A callback that is called when errors happen, or when the request to obtain the Entry is denied.
|
||||
*/
|
||||
resolveLocalFileSystemURL(url:string, successCallback:EntryCallback, errorCallback?:ErrorCallback):void;
|
||||
*/
|
||||
resolveLocalFileSystemURL(url: string, successCallback: EntryCallback, errorCallback?: ErrorCallback): void;
|
||||
|
||||
/**
|
||||
* see requestFileSystem.
|
||||
*/
|
||||
webkitRequestFileSystem(type:number, size:number, successCallback:FileSystemCallback, errorCallback?:ErrorCallback):void;
|
||||
webkitRequestFileSystem(type: number, size: number, successCallback: FileSystemCallback, errorCallback?: ErrorCallback): void;
|
||||
}
|
||||
|
||||
interface LocalFileSystemSync {
|
||||
/**
|
||||
* Used for storage with no guarantee of persistence.
|
||||
*/
|
||||
TEMPORARY:number;
|
||||
TEMPORARY: number;
|
||||
|
||||
/**
|
||||
* Used for storage that should not be removed by the user agent without application or user permission.
|
||||
*/
|
||||
PERSISTENT:number;
|
||||
PERSISTENT: number;
|
||||
|
||||
/**
|
||||
* Requests a filesystem in which to store application data.
|
||||
* @param type Whether the filesystem requested should be persistent, as defined above. Use one of TEMPORARY or PERSISTENT.
|
||||
* @param size This is an indicator of how much storage space, in bytes, the application expects to need.
|
||||
*/
|
||||
requestFileSystemSync(type:number, size:number):FileSystemSync;
|
||||
requestFileSystemSync(type: number, size: number): FileSystemSync;
|
||||
|
||||
/**
|
||||
* Allows the user to look up the Entry for a file or directory referred to by a local URL.
|
||||
* @param url A URL referring to a local file in a filesystem accessable via this API.
|
||||
*/
|
||||
resolveLocalFileSystemSyncURL(url:string):EntrySync;
|
||||
resolveLocalFileSystemSyncURL(url: string): EntrySync;
|
||||
|
||||
/**
|
||||
* see requestFileSystemSync
|
||||
*/
|
||||
webkitRequestFileSystemSync(type:number, size:number):FileSystemSync;
|
||||
webkitRequestFileSystemSync(type: number, size: number): FileSystemSync;
|
||||
}
|
||||
|
||||
interface Metadata {
|
||||
@@ -75,31 +75,31 @@ interface Metadata {
|
||||
* This is the time at which the file or directory was last modified.
|
||||
* @readonly
|
||||
*/
|
||||
modificationTime:Date;
|
||||
modificationTime: Date;
|
||||
|
||||
/**
|
||||
* The size of the file, in bytes. This must return 0 for directories.
|
||||
* @readonly
|
||||
*/
|
||||
size:number;
|
||||
size: number;
|
||||
}
|
||||
|
||||
interface Flags {
|
||||
/**
|
||||
* Used to indicate that the user wants to create a file or directory if it was not previously there.
|
||||
*/
|
||||
create?:boolean;
|
||||
create?: boolean;
|
||||
|
||||
/**
|
||||
* By itself, exclusive must have no effect. Used with create, it must cause getFile and getDirectory to fail if the target path already exists.
|
||||
*/
|
||||
exclusive?:boolean;
|
||||
exclusive?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* This interface represents a file system.
|
||||
*/
|
||||
interface FileSystem{
|
||||
interface FileSystem {
|
||||
/**
|
||||
* This is the name of the file system. The specifics of naming filesystems is unspecified, but a name must be unique across the list of exposed file systems.
|
||||
* @readonly
|
||||
@@ -118,38 +118,38 @@ interface Entry {
|
||||
/**
|
||||
* Entry is a file.
|
||||
*/
|
||||
isFile:boolean;
|
||||
isFile: boolean;
|
||||
|
||||
/**
|
||||
* Entry is a directory.
|
||||
*/
|
||||
isDirectory:boolean;
|
||||
isDirectory: boolean;
|
||||
|
||||
/**
|
||||
* Look up metadata about this entry.
|
||||
* @param successCallback A callback that is called with the time of the last modification.
|
||||
* @param errorCallback ErrorCallback A callback that is called when errors happen.
|
||||
*/
|
||||
getMetadata(successCallback:MetadataCallback, errorCallback?:ErrorCallback):void;
|
||||
|
||||
getMetadata(successCallback: MetadataCallback, errorCallback?: ErrorCallback): void;
|
||||
|
||||
/**
|
||||
* The name of the entry, excluding the path leading to it.
|
||||
*/
|
||||
name:string;
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* The full absolute path from the root to the entry.
|
||||
*/
|
||||
fullPath:string;
|
||||
fullPath: string;
|
||||
|
||||
/**
|
||||
* The file system on which the entry resides.
|
||||
*/
|
||||
filesystem:FileSystem;
|
||||
filesystem: FileSystem;
|
||||
|
||||
/**
|
||||
* Move an entry to a different location on the file system. It is an error to try to:
|
||||
*
|
||||
*
|
||||
* <ui>
|
||||
* <li>move a directory inside itself or to any child at any depth;</li>
|
||||
* <li>move an entry into its parent if a name different from its current one isn't provided;</li>
|
||||
@@ -161,12 +161,12 @@ interface Entry {
|
||||
* A move of a file on top of an existing file must attempt to delete and replace that file.
|
||||
* A move of a directory on top of an existing empty directory must attempt to delete and replace that directory.
|
||||
*/
|
||||
moveTo(parent:DirectoryEntry, newName?:string, successCallback?:EntryCallback, errorCallback?:ErrorCallback):void;
|
||||
|
||||
moveTo(parent: DirectoryEntry, newName?: string, successCallback?: EntryCallback, errorCallback?: ErrorCallback): void;
|
||||
|
||||
/**
|
||||
* Copy an entry to a different location on the file system. It is an error to try to:
|
||||
*
|
||||
* <ul>
|
||||
*
|
||||
* <ul>
|
||||
* <li> copy a directory inside itself or to any child at any depth;</li>
|
||||
* <li> copy an entry into its parent if a name different from its current one isn't provided;</li>
|
||||
* <li> copy a file to a path occupied by a directory;</li>
|
||||
@@ -178,26 +178,26 @@ interface Entry {
|
||||
*
|
||||
* Directory copies are always recursive--that is, they copy all contents of the directory.
|
||||
*/
|
||||
copyTo(parent:DirectoryEntry, newName?:string, successCallback?:EntryCallback, errorCallback?:ErrorCallback):void;
|
||||
|
||||
copyTo(parent: DirectoryEntry, newName?: string, successCallback?: EntryCallback, errorCallback?: ErrorCallback): void;
|
||||
|
||||
/**
|
||||
* Returns a URL that can be used to identify this entry. Unlike the URN defined in [FILE-API-ED], it has no specific expiration; as it describes a location on disk, it should be valid at least as long as that location exists.
|
||||
*/
|
||||
toURL():string;
|
||||
toURL(): string;
|
||||
|
||||
/**
|
||||
* Deletes a file or directory. It is an error to attempt to delete a directory that is not empty. It is an error to attempt to delete the root directory of a filesystem.
|
||||
* @param successCallback A callback that is called on success.
|
||||
* @param errorCallback A callback that is called when errors happen.
|
||||
*/
|
||||
remove(successCallback:VoidCallback, errorCallback?:ErrorCallback):void;
|
||||
|
||||
remove(successCallback: VoidCallback, errorCallback?: ErrorCallback): void;
|
||||
|
||||
/**
|
||||
* Look up the parent DirectoryEntry containing this Entry. If this Entry is the root of its filesystem, its parent is itself.
|
||||
* @param successCallback A callback that is called to return the parent Entry.
|
||||
* @param errorCallback A callback that is called when errors happen.
|
||||
*/
|
||||
getParent(successCallback:DirectoryEntryCallback, errorCallback?:ErrorCallback):void;
|
||||
getParent(successCallback: DirectoryEntryCallback, errorCallback?: ErrorCallback): void;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -207,13 +207,13 @@ interface DirectoryEntry extends Entry {
|
||||
/**
|
||||
* Creates a new DirectoryReader to read Entries from this Directory.
|
||||
*/
|
||||
createReader():DirectoryReader;
|
||||
createReader(): DirectoryReader;
|
||||
|
||||
/**
|
||||
* Creates or looks up a file.
|
||||
* @param path Either an absolute path or a relative path from this DirectoryEntry to the file to be looked up or created. It is an error to attempt to create a file whose immediate parent does not yet exist.
|
||||
* @param options
|
||||
* <ul>
|
||||
* <ul>
|
||||
* <li>If create and exclusive are both true, and the path already exists, getFile must fail.</li>
|
||||
* <li>If create is true, the path doesn't exist, and no other error occurs, getFile must create it as a zero-length file and return a corresponding FileEntry.</li>
|
||||
* <li>If create is not true and the path doesn't exist, getFile must fail.</li>
|
||||
@@ -223,12 +223,12 @@ interface DirectoryEntry extends Entry {
|
||||
* @param successCallback A callback that is called to return the File selected or created.
|
||||
* @param errorCallback A callback that is called when errors happen.
|
||||
*/
|
||||
getFile(path:string, options?:Flags, successCallback?:FileEntryCallback, errorCallback?:ErrorCallback):void;
|
||||
|
||||
getFile(path: string, options?: Flags, successCallback?: FileEntryCallback, errorCallback?: ErrorCallback): void;
|
||||
|
||||
/**
|
||||
* Creates or looks up a directory.
|
||||
* @param path Either an absolute path or a relative path from this DirectoryEntry to the directory to be looked up or created. It is an error to attempt to create a directory whose immediate parent does not yet exist.
|
||||
* @param options
|
||||
* @param options
|
||||
* <ul>
|
||||
* <li>If create and exclusive are both true and the path already exists, getDirectory must fail.</li>
|
||||
* <li>If create is true, the path doesn't exist, and no other error occurs, getDirectory must create and return a corresponding DirectoryEntry.</li>
|
||||
@@ -238,16 +238,16 @@ interface DirectoryEntry extends Entry {
|
||||
* </ul>
|
||||
* @param successCallback A callback that is called to return the DirectoryEntry selected or created.
|
||||
* @param errorCallback A callback that is called when errors happen.
|
||||
*
|
||||
*
|
||||
*/
|
||||
getDirectory(path:string, options?:Flags, successCallback?:DirectoryEntryCallback, errorCallback?:ErrorCallback):void;
|
||||
|
||||
getDirectory(path: string, options?: Flags, successCallback?: DirectoryEntryCallback, errorCallback?: ErrorCallback): void;
|
||||
|
||||
/**
|
||||
* Deletes a directory and all of its contents, if any. In the event of an error [e.g. trying to delete a directory that contains a file that cannot be removed], some of the contents of the directory may be deleted. It is an error to attempt to delete the root directory of a filesystem.
|
||||
* @param successCallback A callback that is called on success.
|
||||
* @param errorCallback A callback that is called when errors happen.
|
||||
*/
|
||||
removeRecursively(successCallback:VoidCallback, errorCallback?:ErrorCallback):void;
|
||||
removeRecursively(successCallback: VoidCallback, errorCallback?: ErrorCallback): void;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -265,7 +265,7 @@ interface DirectoryReader {
|
||||
* @param successCallback Called once per successful call to readEntries to deliver the next previously-unreported set of Entries in the associated Directory. If all Entries have already been returned from previous invocations of readEntries, successCallback must be called with a zero-length array as an argument.
|
||||
* @param errorCallback A callback indicating that there was an error reading from the Directory.
|
||||
*/
|
||||
readEntries(successCallback:EntriesCallback, errorCallback?:ErrorCallback):void;
|
||||
readEntries(successCallback: EntriesCallback, errorCallback?: ErrorCallback): void;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -277,14 +277,14 @@ interface FileEntry extends Entry {
|
||||
* @param successCallback A callback that is called with the new FileWriter.
|
||||
* @param errorCallback A callback that is called when errors happen.
|
||||
*/
|
||||
createWriter(successCallback:FileWriterCallback, errorCallback?:ErrorCallback):void;
|
||||
createWriter(successCallback: FileWriterCallback, errorCallback?: ErrorCallback): void;
|
||||
|
||||
/**
|
||||
* Returns a File that represents the current state of the file that this FileEntry represents.
|
||||
* @param successCallback A callback that is called with the File.
|
||||
* @param errorCallback A callback that is called when errors happen.
|
||||
*/
|
||||
file(successCallback:FileCallback, errorCallback?:ErrorCallback):void;
|
||||
file(successCallback: FileCallback, errorCallback?: ErrorCallback): void;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -294,7 +294,7 @@ interface FileSystemCallback {
|
||||
/**
|
||||
* @param filesystem The file systems to which the app is granted access.
|
||||
*/
|
||||
(filesystem:FileSystem):void;
|
||||
(filesystem: FileSystem): void;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -304,7 +304,7 @@ interface EntryCallback {
|
||||
/**
|
||||
* @param entry
|
||||
*/
|
||||
(entry:Entry):void;
|
||||
(entry: Entry): void;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -314,7 +314,7 @@ interface FileEntryCallback {
|
||||
/**
|
||||
* @param entry
|
||||
*/
|
||||
(entry:FileEntry):void;
|
||||
(entry: FileEntry): void;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -324,102 +324,102 @@ interface DirectoryEntryCallback {
|
||||
/**
|
||||
* @param entry
|
||||
*/
|
||||
(entry:DirectoryEntry):void;
|
||||
(entry: DirectoryEntry): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* When readEntries() succeeds, the following callback is made.
|
||||
*/
|
||||
interface EntriesCallback {
|
||||
(entries:Entry[]):void;
|
||||
(entries: Entry[]): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* This interface is the callback used to look up file and directory metadata.
|
||||
*/
|
||||
interface MetadataCallback {
|
||||
(metadata:Metadata):void;
|
||||
(metadata: Metadata): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* This interface is the callback used to create a FileWriter.
|
||||
*/
|
||||
*/
|
||||
interface FileWriterCallback {
|
||||
(fileWriter:FileWriter):void;
|
||||
(fileWriter: FileWriter): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* This interface is the callback used to obtain a File.
|
||||
*/
|
||||
interface FileCallback {
|
||||
(file:File):void;
|
||||
(file: File): void;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* This interface is the generic callback used to indicate success of an asynchronous method.
|
||||
*/
|
||||
*/
|
||||
interface VoidCallback {
|
||||
():void;
|
||||
(): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* When an error occurs, the following callback is made.
|
||||
*/
|
||||
interface ErrorCallback {
|
||||
(err:DOMError):void;
|
||||
(err: DOMError): void;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
* This interface represents a file system.
|
||||
*/
|
||||
interface FileSystemSync {
|
||||
/**
|
||||
* This is the name of the file system. The specifics of naming filesystems is unspecified, but a name must be unique across the list of exposed file systems.
|
||||
*/
|
||||
name:string;
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* root The root directory of the file system.
|
||||
*/
|
||||
root:DirectoryEntrySync;
|
||||
root: DirectoryEntrySync;
|
||||
}
|
||||
|
||||
/**
|
||||
* An abstract interface representing entries in a file system, each of which may be a FileEntrySync or DirectoryEntrySync.
|
||||
*/
|
||||
interface EntrySync{
|
||||
interface EntrySync {
|
||||
/**
|
||||
* EntrySync is a file.
|
||||
* @readonly
|
||||
*/
|
||||
isFile:boolean;
|
||||
isFile: boolean;
|
||||
|
||||
/**
|
||||
* EntrySync is a directory.
|
||||
* @readonly
|
||||
*/
|
||||
isDirectory:boolean;
|
||||
isDirectory: boolean;
|
||||
|
||||
/**
|
||||
* Look up metadata about this entry.
|
||||
*/
|
||||
getMetadata():Metadata;
|
||||
|
||||
getMetadata(): Metadata;
|
||||
|
||||
/**
|
||||
* The name of the entry, excluding the path leading to it.
|
||||
*/
|
||||
name:string;
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* The full absolute path from the root to the entry.
|
||||
*/
|
||||
fullPath:string;
|
||||
fullPath: string;
|
||||
|
||||
/**
|
||||
* The file system on which the entry resides.
|
||||
*/
|
||||
filesystem:FileSystemSync;
|
||||
filesystem: FileSystemSync;
|
||||
|
||||
/**
|
||||
* Move an entry to a different location on the file system. It is an error to try to:
|
||||
@@ -429,12 +429,12 @@ interface EntrySync{
|
||||
* <li> move a file to a path occupied by a directory;</li>
|
||||
* <li> move a directory to a path occupied by a file;</li>
|
||||
* <li> move any element to a path occupied by a directory which is not empty.</li>
|
||||
* </ui>
|
||||
* </ui>
|
||||
* A move of a file on top of an existing file must attempt to delete and replace that file. A move of a directory on top of an existing empty directory must attempt to delete and replace that directory.
|
||||
* @param parent The directory to which to move the entry.
|
||||
* @param newName The new name of the entry. Defaults to the EntrySync's current name if unspecified.
|
||||
*/
|
||||
moveTo(parent:DirectoryEntrySync, newName?:string):EntrySync;
|
||||
moveTo(parent: DirectoryEntrySync, newName?: string): EntrySync;
|
||||
|
||||
/**
|
||||
* Copy an entry to a different location on the file system. It is an error to try to:
|
||||
@@ -444,27 +444,27 @@ interface EntrySync{
|
||||
* <li> copy a file to a path occupied by a directory;</li>
|
||||
* <li> copy a directory to a path occupied by a file;</li>
|
||||
* <li> copy any element to a path occupied by a directory which is not empty.</li>
|
||||
* </ui>
|
||||
* </ui>
|
||||
* A copy of a file on top of an existing file must attempt to delete and replace that file.
|
||||
* A copy of a directory on top of an existing empty directory must attempt to delete and replace that directory.
|
||||
* Directory copies are always recursive--that is, they copy all contents of the directory.
|
||||
*/
|
||||
copyTo(parent:DirectoryEntrySync, newName?:string):EntrySync;
|
||||
copyTo(parent: DirectoryEntrySync, newName?: string): EntrySync;
|
||||
|
||||
/**
|
||||
* Returns a URL that can be used to identify this entry. Unlike the URN defined in [FILE-API-ED], it has no specific expiration; as it describes a location on disk, it should be valid at least as long as that location exists.
|
||||
*/
|
||||
toURL():string;
|
||||
toURL(): string;
|
||||
|
||||
/**
|
||||
* Deletes a file or directory. It is an error to attempt to delete a directory that is not empty. It is an error to attempt to delete the root directory of a filesystem.
|
||||
*/
|
||||
remove ():void;
|
||||
remove(): void;
|
||||
|
||||
/**
|
||||
* Look up the parent DirectoryEntrySync containing this Entry. If this EntrySync is the root of its filesystem, its parent is itself.
|
||||
*/
|
||||
getParent():DirectoryEntrySync;
|
||||
getParent(): DirectoryEntrySync;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -474,12 +474,12 @@ interface DirectoryEntrySync extends EntrySync {
|
||||
/**
|
||||
* Creates a new DirectoryReaderSync to read EntrySyncs from this DirectorySync.
|
||||
*/
|
||||
createReader():DirectoryReaderSync;
|
||||
createReader(): DirectoryReaderSync;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Creates or looks up a directory.
|
||||
* @param path Either an absolute path or a relative path from this DirectoryEntrySync to the file to be looked up or created. It is an error to attempt to create a file whose immediate parent does not yet exist.
|
||||
* @param options
|
||||
* @param options
|
||||
* <ul>
|
||||
* <li> If create and exclusive are both true and the path already exists, getFile must fail.</li>
|
||||
* <li> If create is true, the path doesn't exist, and no other error occurs, getFile must create it as a zero-length file and return a corresponding FileEntry.</li>
|
||||
@@ -488,12 +488,12 @@ interface DirectoryEntrySync extends EntrySync {
|
||||
* <li> Otherwise, if no other error occurs, getFile must return a FileEntrySync corresponding to path.</li>
|
||||
* </ul>
|
||||
*/
|
||||
getFile(path:string, options?:Flags):FileEntrySync;
|
||||
getFile(path: string, options?: Flags): FileEntrySync;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Creates or looks up a directory.
|
||||
* @param path Either an absolute path or a relative path from this DirectoryEntrySync to the directory to be looked up or created. It is an error to attempt to create a directory whose immediate parent does not yet exist.
|
||||
* @param options
|
||||
* @param options
|
||||
* <ul>
|
||||
* <li> If create and exclusive are both true and the path already exists, getDirectory must fail.</li>
|
||||
* <li> If create is true, the path doesn't exist, and no other error occurs, getDirectory must create and return a corresponding DirectoryEntry.</li>
|
||||
@@ -502,12 +502,12 @@ interface DirectoryEntrySync extends EntrySync {
|
||||
* <li> Otherwise, if no other error occurs, getDirectory must return a DirectoryEntrySync corresponding to path.</li>
|
||||
* </ul>
|
||||
*/
|
||||
getDirectory(path:string, options?:Flags):DirectoryEntrySync;
|
||||
getDirectory(path: string, options?: Flags): DirectoryEntrySync;
|
||||
|
||||
/**
|
||||
* Deletes a directory and all of its contents, if any. In the event of an error [e.g. trying to delete a directory that contains a file that cannot be removed], some of the contents of the directory may be deleted. It is an error to attempt to delete the root directory of a filesystem.
|
||||
*/
|
||||
removeRecursively():void;
|
||||
removeRecursively(): void;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -523,7 +523,7 @@ interface DirectoryReaderSync {
|
||||
/**
|
||||
* Read the next block of entries from this directory.
|
||||
*/
|
||||
readEntries():EntrySync[];
|
||||
readEntries(): EntrySync[];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -533,16 +533,16 @@ interface FileEntrySync extends EntrySync {
|
||||
/**
|
||||
* Creates a new FileWriterSync associated with the file that this FileEntrySync represents.
|
||||
*/
|
||||
createWriter():FileWriterSync;
|
||||
createWriter(): FileWriterSync;
|
||||
|
||||
/**
|
||||
* Returns a File that represents the current state of the file that this FileEntrySync represents.
|
||||
*/
|
||||
file():File;
|
||||
file(): File;
|
||||
}
|
||||
|
||||
interface Window extends LocalFileSystem, LocalFileSystemSync{
|
||||
interface Window extends LocalFileSystem, LocalFileSystemSync {
|
||||
}
|
||||
|
||||
interface WorkerGlobalScope extends LocalFileSystem, LocalFileSystemSync{
|
||||
interface WorkerGlobalScope extends LocalFileSystem, LocalFileSystemSync {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user