mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-01 07:40:10 +00:00
Merge pull request #2984 from mzsm/chrome-app-filesystem
add chrome.fileSystem
This commit is contained in:
@@ -26,6 +26,35 @@ chrome.app.runtime.onRestarted.addListener(function () { return; });
|
||||
// Get Current Window
|
||||
var currentWindow: cwindow.AppWindow = chrome.app.window.current();
|
||||
|
||||
// FileSystem
|
||||
// https://developer.chrome.com/apps/fileSystem
|
||||
|
||||
function test_fileSystem(): void {
|
||||
var accepts: chrome.fileSystem.AcceptOptions[] = [
|
||||
{mimeTypes: ["text/*"], extensions: ['js', 'css', 'txt', 'html', 'xml', 'tsv', 'csv', 'rtf']}
|
||||
];
|
||||
var chooseOption: chrome.fileSystem.ChooseEntryOptions = {
|
||||
type: "openFile",
|
||||
suggestedName: "foo.txt",
|
||||
accepts: accepts,
|
||||
acceptsAllTypes: false,
|
||||
acceptsMultiple: false
|
||||
};
|
||||
chrome.fileSystem.chooseEntry(chooseOption, (entry: Entry) => {
|
||||
chrome.fileSystem.getDisplayPath(entry, (displayPath: string) => { });
|
||||
|
||||
var retainedId = chrome.fileSystem.retainEntry(entry);
|
||||
chrome.fileSystem.isRestorable(retainedId, (isRestorable: boolean) => {
|
||||
if(isRestorable){
|
||||
chrome.fileSystem.restoreEntry(retainedId, (restoredEntry: Entry) => { });
|
||||
}
|
||||
});
|
||||
|
||||
chrome.fileSystem.getWritableEntry(entry, (writableEntry: Entry) => {});
|
||||
chrome.fileSystem.isWritableEntry(entry, (isWritable: boolean) => {});
|
||||
});
|
||||
}
|
||||
|
||||
// Sockets
|
||||
// https://developer.chrome.com/apps/sockets_tcp
|
||||
function test_socketsTcp(): void {
|
||||
|
||||
52
chrome/chrome-app.d.ts
vendored
52
chrome/chrome-app.d.ts
vendored
@@ -1,8 +1,10 @@
|
||||
// Type definitions for Chrome packaged application development
|
||||
// Project: http://developer.chrome.com/apps/
|
||||
// Definitions by: Adam Lay <https://github.com/AdamLay>, MIZUNE Pine <https://github.com/pine613>
|
||||
// Definitions by: Adam Lay <https://github.com/AdamLay>, MIZUNE Pine <https://github.com/pine613>, MIZUSHIMA Junki <https://github.com/mzsm>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path='../filesystem/filesystem.d.ts'/>
|
||||
|
||||
////////////////////
|
||||
// App Runtime
|
||||
////////////////////
|
||||
@@ -21,11 +23,11 @@ declare module chrome.app.runtime {
|
||||
}
|
||||
|
||||
interface LaunchedEvent {
|
||||
addListener(callback: (launchData: LaunchData) => void);
|
||||
addListener(callback: (launchData: LaunchData) => void): void;
|
||||
}
|
||||
|
||||
interface RestartedEvent {
|
||||
addListener(callback: () => void);
|
||||
addListener(callback: () => void): void;
|
||||
}
|
||||
|
||||
var onLaunched: LaunchedEvent;
|
||||
@@ -94,6 +96,50 @@ declare module chrome.app.window {
|
||||
var onRestored: WindowEvent;
|
||||
}
|
||||
|
||||
////////////////////
|
||||
// fileSystem
|
||||
////////////////////
|
||||
declare module chrome.fileSystem {
|
||||
|
||||
interface ChildChangeInfo {
|
||||
entry: Entry;
|
||||
type: string;
|
||||
}
|
||||
|
||||
interface EntryChangedEvent {
|
||||
target: Entry;
|
||||
childChanges?: ChildChangeInfo[];
|
||||
}
|
||||
|
||||
interface EntryRemovedEvent {
|
||||
target: Entry;
|
||||
}
|
||||
|
||||
interface AcceptOptions {
|
||||
description?: string;
|
||||
mimeTypes?: string[];
|
||||
extensions?: string[];
|
||||
}
|
||||
|
||||
interface ChooseEntryOptions {
|
||||
type?: string;
|
||||
suggestedName?: string;
|
||||
accepts?: AcceptOptions[];
|
||||
acceptsAllTypes?: boolean;
|
||||
acceptsMultiple?: boolean;
|
||||
}
|
||||
|
||||
export function getDisplayPath(entry: Entry, callback: (displayPath: string) => void): void;
|
||||
export function getWritableEntry(entry: Entry, callback: (entry: Entry) => void): void;
|
||||
export function isWritableEntry(entry: Entry, callback: (isWritable: boolean) => void): void;
|
||||
export function chooseEntry(callback: (entry: Entry) => void): void;
|
||||
export function chooseEntry(callback: (fileEntries: FileEntry[]) => void): void;
|
||||
export function chooseEntry(options: ChooseEntryOptions, callback: (entry: Entry) => void): void;
|
||||
export function chooseEntry(options: ChooseEntryOptions, callback: (fileEntries: FileEntry[]) => void): void;
|
||||
export function restoreEntry(id: string, callback: (entry: Entry) => void): void;
|
||||
export function isRestorable(id: string, callback: (isRestorable: boolean) => void): void;
|
||||
export function retainEntry(entry: Entry): string;
|
||||
}
|
||||
|
||||
////////////////////
|
||||
// Sockets
|
||||
|
||||
Reference in New Issue
Block a user