diff --git a/types/bencode/bencode-tests.ts b/types/bencode/bencode-tests.ts new file mode 100644 index 0000000000..f6ad3c8292 --- /dev/null +++ b/types/bencode/bencode-tests.ts @@ -0,0 +1,6 @@ +import * as bencode from "bencode"; + +bencode.byteLength("abcde"); // $ExpectType number +bencode.encodingLength("abcde"); // $ExpectType number +bencode.encode([1, 2, 3, 4], new Buffer([]), 1); // $ExpectType Buffer +bencode.decode(new Buffer("abcde"), 1, 3); // $ExpectType any diff --git a/types/bencode/index.d.ts b/types/bencode/index.d.ts new file mode 100644 index 0000000000..444513192c --- /dev/null +++ b/types/bencode/index.d.ts @@ -0,0 +1,16 @@ +// Type definitions for bencode 2.0 +// Project: https://github.com/themasch/node-bencode#readme +// Definitions by: Tobenna +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +export function byteLength(value: any): number; +export function encodingLength(value: any): number; +export function encode(data: any, buffer?: Buffer, offset?: number): Buffer; +export function decode( + data: Buffer, + start?: number, + end?: number, + encoding?: string +): any; diff --git a/types/bencode/tsconfig.json b/types/bencode/tsconfig.json new file mode 100644 index 0000000000..47220efa5a --- /dev/null +++ b/types/bencode/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "bencode-tests.ts" + ] +} diff --git a/types/bencode/tslint.json b/types/bencode/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/bencode/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/bigi/bigi-tests.ts b/types/bigi/bigi-tests.ts index 0e4822aeb6..23bffb0477 100644 --- a/types/bigi/bigi-tests.ts +++ b/types/bigi/bigi-tests.ts @@ -14,3 +14,6 @@ const b6 = b4.multiply(b5); console.log(b6); // => BigInteger { '0': 420, '1': 0, t: 1, s: 0 } + +console.log(b1.compareTo(b2)); +// => 70 diff --git a/types/bigi/index.d.ts b/types/bigi/index.d.ts index 7b44ff75e4..de849587ac 100644 --- a/types/bigi/index.d.ts +++ b/types/bigi/index.d.ts @@ -23,7 +23,7 @@ declare class bigi { clamp(): void; clearBit(n: number): bigi; clone(): bigi; - compareTo(a: bigi): bigi; + compareTo(a: bigi): number; copyTo(r: any): void; dAddOffset(n: any, w: any): void; dMultiply(n: number): void; diff --git a/types/chance/chance-tests.ts b/types/chance/chance-tests.ts index 00d8752118..238fd97cf3 100644 --- a/types/chance/chance-tests.ts +++ b/types/chance/chance-tests.ts @@ -71,3 +71,18 @@ euro = chance.euro({opt: 'abc'}); let coin = chance.coin(); coin = chance.coin(); + +// Make sure date works with min and max parameters +let date: string|Date = chance.date(); + +let min = new Date(); +let max = new Date(); +date = chance.date({min, max}); + +min = new Date(); +min.setFullYear(new Date().getFullYear() - 15); +max = new Date(); +max.setFullYear(new Date().getFullYear() + 15); +date = chance.date({min, max}); +date = chance.date({min}); +date = chance.date({max}); diff --git a/types/chance/index.d.ts b/types/chance/index.d.ts index 07418e45be..17708acc5a 100644 --- a/types/chance/index.d.ts +++ b/types/chance/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Chance 1.0.13 +// Type definitions for Chance 1.0.16 // Project: http://chancejs.com // Definitions by: Chris Bowdon // Brice BERNARD @@ -189,6 +189,8 @@ declare namespace Chance { year?: number; month?: number; day?: number; + min?: Date; + max?: Date; } interface Month { diff --git a/types/chrome-apps/index.d.ts b/types/chrome-apps/index.d.ts index 957c409a4f..a1713aa6f9 100644 --- a/types/chrome-apps/index.d.ts +++ b/types/chrome-apps/index.d.ts @@ -1,25 +1,30 @@ // Type definitions for Chrome packaged application development // Project: http://developer.chrome.com/apps/ -// Definitions by: Nikolai Ommundsen , Adam Lay , MIZUNE Pine , MIZUSHIMA Junki , Ingvar Stepanyan , Adam Pyle +// Definitions by: Nikolai Ommundsen , Adam Lay , MIZUNE Pine , MIZUSHIMA Junki , Ingvar Stepanyan , Adam Pyle , Matthew Kimber , otiai10 , couven92 , RReverser , sreimer15 // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.4 -/// +/// -/////////////// -// WebView ref: https://chromium.googlesource.com/chromium/src/+/68.0.3432.1/chrome/common/extensions/api/webview_tag.json -/////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// WebView ref // +// https://chromium.googlesource.com/chromium/src/+/68.0.3432.1/chrome/common/extensions/api/webview_tag.json // +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////// -// Accessibility Features -//////////////////// -/** - * Use the chrome.accessibilityFeatures API to manage Chrome's accessibility features. This API relies on the ChromeSetting prototype of the type API for getting and setting individual accessibility features. In order to get feature states the extension must request accessibilityFeatures.read permission. For modifying feature state, the extension needs accessibilityFeatures.modify permission. Note that accessibilityFeatures.modify does not imply accessibilityFeatures.read permission. - * @since Availability: Since Chrome 37. - * Permissions: "accessibilityFeatures.read" (For read access); "accessibilityFeatures.modify" (For modifications; Note that accessibilityFeatures.modify does not imply accessibilityFeatures.read permission.) - * Important: This API works only on Chrome OS. - */ declare namespace chrome { + //////////////////// + // Accessibility Features + //////////////////// + /** + * Use the chrome.accessibilityFeatures API to manage Chrome's accessibility features. + * This API relies on the ChromeSetting prototype of the type API for getting and setting individual accessibility features. + * In order to get feature states the extension must request accessibilityFeatures.read permission. + * For modifying feature state, the extension needs accessibilityFeatures.modify permission. + * Note that accessibilityFeatures.modify does not imply accessibilityFeatures.read permission. + * Permissions: 'accessibilityFeatures.read' (For read access); 'accessibilityFeatures.modify' (For modifications; Note that accessibilityFeatures.modify does not imply accessibilityFeatures.read permission.) + * Important: This API works only on Chrome OS. + * @since Availability: Since Chrome 37. + */ namespace accessibilityFeatures { interface AccessibilityFeaturesGetArg { /** Optional. Whether to return the value that applies to the incognito session (default false). */ @@ -36,7 +41,7 @@ declare namespace chrome { * • controllable_by_this_extension: can be controlled by this extension * • controlled_by_this_extension: controlled by this extension */ - levelOfControl: string; + levelOfControl: 'not_controllable' | 'controlled_by_other_extensions' | 'controllable_by_this_extension' | 'controlled_by_this_extension'; /** Optional. Whether the effective value is specific to the incognito session. This property will only be present if the incognito property in the details parameter of get() was true. */ incognitoSpecific?: boolean; } @@ -55,7 +60,7 @@ declare namespace chrome { * • incognito_persistent: setting for the incognito profile that survives browser restarts (overrides regular preferences), * • incognito_session_only: setting for the incognito profile that can only be set during an incognito session and is deleted when the incognito session ends (overrides regular and incognito_persistent preferences). */ - scope?: string; + scope?: 'regular' | 'regular_only' | 'incognito_persistent' | 'incognito_session_only'; } interface AccessibilityFeaturesClearArg { @@ -67,7 +72,7 @@ declare namespace chrome { * • incognito_persistent: setting for the incognito profile that survives browser restarts (overrides regular preferences), * • incognito_session_only: setting for the incognito profile that can only be set during an incognito session and is deleted when the incognito session ends (overrides regular and incognito_persistent preferences). */ - scope?: string; + scope?: 'regular' | 'regular_only' | 'incognito_persistent' | 'incognito_session_only'; } interface AccessibilityFeaturesSetting { @@ -96,13 +101,63 @@ declare namespace chrome { clear(details: AccessibilityFeaturesClearArg, callback?: () => void): void; } + /** + * Spoken feedback (text-to-speech). The value indicates whether the feature is enabled or not. get() requires accessibilityFeatures.read permission. set() and clear() require accessibilityFeatures.modify permission. + */ export var spokenFeedback: AccessibilityFeaturesSetting; + /** + * Enlarged cursor. The value indicates whether the feature is enabled or not. get() requires accessibilityFeatures.read permission. set() and clear() require accessibilityFeatures.modify permission. + */ export var largeCursor: AccessibilityFeaturesSetting; + /** + * Sticky modifier keys (like shift or alt). The value indicates whether the feature is enabled or not. get() requires accessibilityFeatures.read permission. set() and clear() require accessibilityFeatures.modify permission. + */ export var stickyKeys: AccessibilityFeaturesSetting; + /** + * High contrast rendering mode. The value indicates whether the feature is enabled or not. get() requires accessibilityFeatures.read permission. set() and clear() require accessibilityFeatures.modify permission. + */ export var highContrast: AccessibilityFeaturesSetting; + /** + * Full screen magnification. The value indicates whether the feature is enabled or not. get() requires accessibilityFeatures.read permission. set() and clear() require accessibilityFeatures.modify permission. + */ export var screenMagnifier: AccessibilityFeaturesSetting; + /** + * Auto mouse click after mouse stops moving. The value indicates whether the feature is enabled or not. get() requires accessibilityFeatures.read permission. set() and clear() require accessibilityFeatures.modify permission. + */ export var autoclick: AccessibilityFeaturesSetting; + /** + * Virtual on-screen keyboard. The value indicates whether the feature is enabled or not. get() requires accessibilityFeatures.read permission. set() and clear() require accessibilityFeatures.modify permission. + */ export var virtualKeyboard: AccessibilityFeaturesSetting; + /** + * Caret highlighting. The value indicates whether the feature is enabled or not. get() requires accessibilityFeatures.read permission. set() and clear() require accessibilityFeatures.modify permission. + * @since Since Chrome 51. + */ + export var caretHighlight: AccessibilityFeaturesSetting; + /** + * Cursor highlighting. The value indicates whether the feature is enabled or not. get() requires accessibilityFeatures.read permission. set() and clear() require accessibilityFeatures.modify permission. + * @since Since Chrome 51. + */ + export var cursorHighlight: AccessibilityFeaturesSetting; + /** + * Focus highlighting. The value indicates whether the feature is enabled or not. get() requires accessibilityFeatures.read permission. set() and clear() require accessibilityFeatures.modify permission. + * @since Since Chrome 51. + */ + export var focusHighlight: AccessibilityFeaturesSetting; + /** + * Select-to-speak. The value indicates whether the feature is enabled or not. get() requires accessibilityFeatures.read permission. set() and clear() require accessibilityFeatures.modify permission. + * @since Since Chrome 51. + */ + export var selectToSpeak: AccessibilityFeaturesSetting; + /** + * Switch access. The value indicates whether the feature is enabled or not. get() requires accessibilityFeatures.read permission. set() and clear() require accessibilityFeatures.modify permission. + * @since Since Chrome 51. + */ + export var switchAccess: AccessibilityFeaturesSetting; + /** + * get() requires accessibilityFeatures.read permission. set() and clear() require accessibilityFeatures.modify permission. + * @since Since Chrome 42. + */ export var animationPolicy: AccessibilityFeaturesSetting; } @@ -111,8 +166,8 @@ declare namespace chrome { //////////////////// /** * Use the chrome.alarms API to schedule code to run periodically or at a specified time in the future. - * Availability: Since Chrome 22. - * Permissions: "alarms" + * Permissions: 'alarms' + * @since Availability: Since Chrome 22. */ namespace alarms { interface AlarmCreateInfo { @@ -137,14 +192,19 @@ declare namespace chrome { /** * Creates an alarm. Near the time(s) specified by alarmInfo, the onAlarm event is fired. If there is another alarm with the same name (or no name if none is specified), it will be cancelled and replaced by this alarm. - * In order to reduce the load on the user's machine, Chrome limits alarms to at most once every 1 minute but may delay them an arbitrary amount more. That is, setting delayInMinutes or periodInMinutes to less than 1 will not be honored and will cause a warning. when can be set to less than 1 minute after "now" without warning but won't actually cause the alarm to fire for at least 1 minute. + * In order to reduce the load on the user's machine, Chrome limits alarms to at most once every 1 minute but may delay them an arbitrary amount more. + * That is, setting delayInMinutes or periodInMinutes to less than 1 will not be honored and will cause a warning. + * `when` can be set to less than 1 minute after 'now' without warning but won't actually cause the alarm to fire for at least 1 minute. * To help you debug your app or extension, when you've loaded it unpacked, there's no limit to how often the alarm can fire. * @param alarmInfo Describes when the alarm should fire. The initial time must be specified by either when or delayInMinutes (but not both). If periodInMinutes is set, the alarm will repeat every periodInMinutes minutes after the initial event. If neither when or delayInMinutes is set for a repeating alarm, periodInMinutes is used as the default for delayInMinutes. */ export function create(alarmInfo: AlarmCreateInfo): void; /** - * Creates an alarm. Near the time(s) specified by alarmInfo, the onAlarm event is fired. If there is another alarm with the same name (or no name if none is specified), it will be cancelled and replaced by this alarm. - * In order to reduce the load on the user's machine, Chrome limits alarms to at most once every 1 minute but may delay them an arbitrary amount more. That is, setting delayInMinutes or periodInMinutes to less than 1 will not be honored and will cause a warning. when can be set to less than 1 minute after "now" without warning but won't actually cause the alarm to fire for at least 1 minute. + * Creates an alarm. Near the time(s) specified by alarmInfo, the onAlarm event is fired. + * If there is another alarm with the same name (or no name if none is specified), it will be cancelled and replaced by this alarm. + * In order to reduce the load on the user's machine, Chrome limits alarms to at most once every 1 minute but may delay them an arbitrary amount more. + * That is, setting delayInMinutes or periodInMinutes to less than 1 will not be honored and will cause a warning. + * `when` can be set to less than 1 minute after 'now' without warning but won't actually cause the alarm to fire for at least 1 minute. * To help you debug your app or extension, when you've loaded it unpacked, there's no limit to how often the alarm can fire. * @param name Optional name to identify this alarm. Defaults to the empty string. * @param alarmInfo Describes when the alarm should fire. The initial time must be specified by either when or delayInMinutes (but not both). If periodInMinutes is set, the alarm will repeat every periodInMinutes minutes after the initial event. If neither when or delayInMinutes is set for a repeating alarm, periodInMinutes is used as the default for delayInMinutes. @@ -153,39 +213,39 @@ declare namespace chrome { /** * Gets an array of all the alarms. * @param callback The callback parameter should be a function that looks like this: - * function(array of Alarm alarms) {...}; + * @example function(array of Alarm alarms) {...}; */ export function getAll(callback: (alarms: Alarm[]) => void): void; /** * Clears all alarms. * @param callback If you specify the callback parameter, it should be a function that looks like this: - * function(boolean wasCleared) {...}; + * @example function(boolean wasCleared) {...}; */ export function clearAll(callback?: (wasCleared: boolean) => void): void; /** * Clears the alarm with the given name. * @param name The name of the alarm to clear. Defaults to the empty string. * @param callback If you specify the callback parameter, it should be a function that looks like this: - * function(boolean wasCleared) {...}; + * @example function(boolean wasCleared) {...}; */ export function clear(name?: string, callback?: (wasCleared: boolean) => void): void; /** * Clears the alarm without a name. * @param callback If you specify the callback parameter, it should be a function that looks like this: - * function(boolean wasCleared) {...}; + * @example function(boolean wasCleared) {...}; */ export function clear(callback: (wasCleared: boolean) => void): void; /** * Retrieves details about the specified alarm. * @param callback The callback parameter should be a function that looks like this: - * function( Alarm alarm) {...}; + * @example function( Alarm alarm) {...}; */ export function get(callback: (alarm: Alarm) => void): void; /** * Retrieves details about the specified alarm. * @param name The name of the alarm to get. Defaults to the empty string. * @param callback The callback parameter should be a function that looks like this: - * function( Alarm alarm) {...}; + * @example function( Alarm alarm) {...}; */ export function get(name: string, callback: (alarm: Alarm) => void): void; @@ -193,54 +253,125 @@ declare namespace chrome { export var onAlarm: AlarmEvent; } - - //////////////////// - // App - //////////////////// - namespace app { - interface AppDetails extends chrome.runtime.Manifest { - id: string; - } - - export function getDetails(): AppDetails; - } - //////////////////// // App Runtime //////////////////// + + /** + * Use the chrome.app.runtime API to manage the app lifecycle. + * The app runtime manages app installation, controls the event page, and can shut down the app at anytime. + * @since Availability: Since Chrome 24. + */ namespace app.runtime { type LaunchSource = 'untracked' | 'app_launcher' | 'new_tab_page' | 'reload' | 'restart' | 'load_and_launch' | 'command_line' | 'file_handler' | 'url_handler' | 'system_tray' | 'about_page' | 'keyboard' | 'extensions_page' | 'management_api' | 'ephemeral_app' | 'background' | 'kiosk' | 'chrome_internal' | 'test' | 'installed_notification' | 'context_menu'; + interface EmbedRequest { + /** + * Optional developer specified data that the app to be embedded can use when making an embedding decision. + */ + data?: any; + /** + * Allows embedderId to embed this app in an element. The url specifies the content to embed. + */ + allow: (url: string) => void; + /** + * Prevents embedderId from embedding this app in an element. + */ + deny: () => void; + } + + type actionType = 'new_note'; + interface LaunchData { + /** + * The ID of the file or URL handler that the app is being invoked with. + * Handler IDs are the top-level keys in the file_handlers and/or url_handlers dictionaries in the manifest. + */ id?: string; + /** + * The file entries for the onLaunched event triggered by a matching file handler in the file_handlers manifest key. + */ items?: LaunchDataItem[]; + /** + * The URL for the onLaunched event triggered by a matching URL handler in the url_handlers manifest key. + */ url?: string; + /** + * The referrer URL for the onLaunched event triggered by a matching URL handler in the url_handlers manifest key. + */ referrerUrl?: string; + /** + * Whether the app is being launched in a Chrome OS kiosk session. + */ isKioskSession?: boolean; + /** + * Whether the app is being launched in a Chrome OS public session. + * @since Since Chrome 47. + */ isPublicSession?: boolean; + /** + * Where the app is launched from. + */ source?: LaunchSource; - actionData?: {}; + /** + * Contains data that specifies the ActionType this app was launched with. This is null if the app was not launched with a specific action intent. + * ______________________________________________________________________________ + * | enum of 'new_note' | actionType | new_note | + * | | | The user wants to quickly take a new note. | + * |____________________|____________|____________________________________________| + * @since Since Chrome 54. + */ + actionData?: actionType; } interface LaunchDataItem { + /** + * Entry for the item + */ entry: FileEntry; - type: string; + /** + * The MIME type of the file. + */ + type?: string; } + interface EmbedRequestedEvent extends chrome.events.Event<(request: EmbedRequest) => void> { } + interface LaunchedEvent extends chrome.events.Event<(launchData: LaunchData) => void> { } interface RestartedEvent extends chrome.events.Event<() => void> { } + /** + * Fired when an embedding app requests to embed this app. This event is only available on dev channel with the flag --enable-app-view. + * @since Since Chrome 38. + */ + export var onEmbedRequest: EmbedRequestedEvent; + /** + * Fired when an app is launched from the launcher. + */ export var onLaunched: LaunchedEvent; + /** + * Fired at Chrome startup to apps that were running when Chrome last shut down, + * or when apps have been requested to restart from their previous state for other reasons + * (e.g. when the user revokes access to an app's retained files the runtime will restart the app). + * In these situations if apps do not have an onRestarted handler they will be sent an onLaunched event instead. + */ export var onRestarted: RestartedEvent; } //////////////////// // App Window //////////////////// + /** + * Use the chrome.app.window API to create windows. + * Windows have an optional frame with title bar and size controls. + * They are not associated with any Chrome browser windows. + * See the Window State Sample for a demonstration of these options. + * @since Availability: Since Chrome 24. + */ namespace app.window { interface ContentBounds { left?: number; @@ -250,114 +381,327 @@ declare namespace chrome { } interface BoundsSpecification { + /** The X coordinate of the content or window. */ left?: number; + /** The Y coordinate of the content or window. */ top?: number; + /** The width of the content or window. */ width?: number; + /** The height of the content or window. */ height?: number; + /** The minimum width of the content or window. */ minWidth?: number; + /** The minimum height of the content or window. */ minHeight?: number; + /** The maximum width of the content or window. */ maxWidth?: number; + /** The maximum height of the content or window. */ maxHeight?: number; } interface Bounds { + /** This property can be used to read or write the current X coordinate of the content or window. */ left: number; + /** This property can be used to read or write the current Y coordinate of the content or window. */ top: number; + /** This property can be used to read or write the current width of the content or window. */ width: number; + /** This property can be used to read or write the current height of the content or window. */ height: number; - minWidth?: number; - minHeight?: number; - maxWidth?: number; - maxHeight?: number; + /** This property can be used to read or write the current minimum width of the content or window. A value of null indicates 'unspecified'. */ + minWidth?: number | null; + /** This property can be used to read or write the current minimum height of the content or window. A value of null indicates 'unspecified'. */ + minHeight?: number | null; + /** This property can be used to read or write the current maximum width of the content or window. A value of null indicates 'unspecified'. */ + maxWidth?: number | null; + /** This property can be used to read or write the current maximum height of the content or window. A value of null indicates 'unspecified'. */ + maxHeight?: number | null; + /** Set the left and top position of the content or window. */ setPosition(left: number, top: number): void; + /** Set the width and height of the content or window. */ setSize(width: number, height: number): void; - setMinimumSize(minWidth: number, minHeight: number): void; - setMaximumSize(maxWidth: number, maxHeight: number): void; + /** Set the minimum size constraints of the content or window. + * The minimum width or height can be set to null to remove the constraint. + * A value of undefined will leave a constraint unchanged. + **/ + setMinimumSize(minWidth: number | null | undefined, minHeight: number | null | undefined): void; + /** + * Set the maximum size constraints of the content or window. + * The maximum width or height can be set to null to remove the constraint. + * A value of undefined will leave a constraint unchanged. + */ + setMaximumSize(maxWidth: number | null | undefined, maxHeight: number | null | undefined): void; } interface FrameOptions { - type?: string; + /** + * Frame type: none or chrome (defaults to chrome). + * + * For none, the -webkit-app-region CSS property can be used to apply draggability to the app's window. + * -webkit-app-region: drag can be used to mark regions draggable. no-drag can be used to disable this style on nested elements. + */ + type: 'none'; + } + interface FrameOptionsChrome { + /** + * Frame type: none or chrome (defaults to chrome). + * + * For none, the -webkit-app-region CSS property can be used to apply draggability to the app's window. + * -webkit-app-region: drag can be used to mark regions draggable. no-drag can be used to disable this style on nested elements. + */ + type?: 'chrome'; + /** + * Allows the frame color to be set. Frame coloring is only available if the frame type is chrome. + * @since Frame coloring is new in Chrome 36. + */ color?: string; + /** + * Allows the frame color of the window when active to be set. Frame coloring is only available if the frame type is chrome. + * Frame coloring is only available if the frame type is chrome. + * @since Frame coloring is new in Chrome 36. + */ activeColor?: string; + /** + * Allows the frame color of the window when inactive to be set differently to the active color. Frame coloring is only available if the frame type is chrome. + * inactiveColor must be used in conjunction with color. + * @since Frame coloring is new in Chrome 36. + */ inactiveColor?: string; } interface CreateWindowOptions { + /** + * Id to identify the window. + * + * This will be used to remember the size and position of the window and restore that geometry when a window with the same id is later opened. + * If a window with a given id is created while another window with the same id already exists, + * the currently opened window will be focused instead of creating a new window. + */ id?: string; + /** + * Used to specify the initial position, initial size and constraints of the window's content (excluding window decorations). + * If an id is also specified and a window with a matching id has been shown before, the remembered bounds will be used instead. + * Note that the padding between the inner and outer bounds is determined by the OS. + * Therefore setting the same bounds property for both the innerBounds and outerBounds will result in an error. + * @since This property is new in Chrome 36. + */ innerBounds?: BoundsSpecification; + /** + * Used to specify the initial position, initial size and constraints of the window (including window decorations such as the title bar and frame). + * If an id is also specified and a window with a matching id has been shown before, the remembered bounds will be used instead. + * Note that the padding between the inner and outer bounds is determined by the OS. + * Therefore setting the same bounds property for both the innerBounds and outerBounds will result in an error. + * @since This property is new in Chrome 36. + */ outerBounds?: BoundsSpecification; + /** + * Minimum width of the window. + * @deprecated Deprecated since Chrome 36. Use innerBounds or outerBounds. + */ minWidth?: number; + /** + * Minimum height of the window. + * @deprecated Deprecated since Chrome 36. Use innerBounds or outerBounds. + */ minHeight?: number; + /** + * Maximum width of the window. + * @deprecated Deprecated since Chrome 36. Use innerBounds or outerBounds. + */ maxWidth?: number; + /** + * Maximum height of the window. + * @deprecated Deprecated since Chrome 36. Use innerBounds or outerBounds. + */ maxHeight?: number; + /** Type of window to create */ + type?: 'shell'; /** - * @description - * @type {(string | FrameOptions)} string ("none", "chrome") or FrameOptions - * @memberof CreateWindowOptions + * If true, the window will have its own shelf icon. + * Otherwise the window will be grouped in the shelf with other windows that are associated with the app. + * Defaults to false. + * If showInShelf is set to true you need to specify an id for the window. + * @since Since Chrome 54. + */ + showInShelf?: boolean; + /** + * URL of the window icon. A window can have its own icon when showInShelf is set to true. The URL should be a global or an extension local URL. + * @since Since Chrome 54. + */ + icon?: string; + /** + * Frame type: none or chrome (defaults to chrome). + * For none, the -webkit-app-region CSS property can be used to apply draggability to the app's window. + * -webkit-app-region: drag can be used to mark regions draggable. no-drag can be used to disable this style on nested elements. + * @since Use of FrameOptions is new in M36. + */ + frame?: 'none' | 'chrome' | FrameOptions | FrameOptionsChrome; + /** + * Size and position of the content in the window (excluding the titlebar). + * If an id is also specified and a window with a matching id has been shown before, + * the remembered bounds of the window will be used instead. + * @deprecated Deprecated since Chrome 36. Use innerBounds or outerBounds. */ - frame?: string | FrameOptions; bounds?: ContentBounds; - alphaEnabled?: boolean; /** - * @description - * @type {string} "normal", "fullscreen", "maximized", "minimized" - * @memberof CreateWindowOptions + * The initial state of the window, allowing it to be created already fullscreen, maximized, or minimized. Defaults to 'normal'. + */ + state?: 'normal' | 'fullscreen' | 'maximized' | 'minimized'; + /** + * If true, the window will be created in a hidden state. Call show() on the window to show it once it has been created. Defaults to false. */ - state?: string; hidden?: boolean; + /** + * If true, the window will be resizable by the user. Defaults to true. + */ resizable?: boolean; + /** + * @deprecated Deprecated since Chrome 34. Multiple windows with the same id is no longer supported. + * By default if you specify an id for the window, + * the window will only be created if another window with the same id doesn't already exist. + * If a window with the same id already exists that window is activated instead. + * If you do want to create multiple windows with the same id, you can set this property to false. + */ singleton?: boolean; + /** + * If true, the window will stay above most other windows. + * If there are multiple windows of this kind, the currently focused window will be in the foreground. + * @requires alwaysOnTopWindows-permission. + * Defaults to false. + * Call setAlwaysOnTop() on the window to change this property after creation. + */ alwaysOnTop?: boolean; + /** If true, the window will be focused when created. Defaults to true. */ focused?: boolean; + /** + * If true, and supported by the platform, the window will be visible on all workspaces. + * @since Since Chrome 39. + */ visibleOnAllWorkspaces?: boolean; } interface AppWindow { + /** Focus the window. */ focus: () => void; + /** + * Fullscreens the window. + * The user will be able to restore the window by pressing ESC. + * An application can prevent the fullscreen state to be left when ESC is pressed by requesting the + * app.window.fullscreen.overrideEsc permission and canceling the event by calling .preventDefault(), + * in the keydown and keyup handlers, like this: + * @example window.onkeydown = window.onkeyup = function(e) { if (e.keyCode == 27 <<--``ESC``) { e.preventDefault(); } + * Note window.fullscreen() will cause the entire window to become fullscreen and does not require a user gesture. + * The HTML5 fullscreen API can also be used to enter fullscreen mode(see Web APIs for more details). + **/ fullscreen: () => void; + /** Is the window fullscreen? This will be true if the window has been created fullscreen or was made fullscreen via the AppWindow or HTML5 fullscreen APIs. */ isFullscreen: () => boolean; + /** Minimize the window. */ minimize: () => void; + /** Is the window minimized? */ isMinimized: () => boolean; + /** Maximize the window. */ maximize: () => void; + /** Is the window maximized? */ isMaximized: () => boolean; + /** Restore the window, exiting a maximized, minimized, or fullscreen state. */ restore: () => void; + /** + * Move the window to the position (|left|, |top|). + * @deprecated Deprecated since Chrome 43. Use outerBounds. + */ moveTo: (left: number, top: number) => void; + /** + * Resize the window to |width|x|height| pixels in size. + * @deprecated Deprecated since Chrome 43. Use outerBounds. + */ resizeTo: (width: number, height: number) => void; + /** Draw attention to the window. */ drawAttention: () => void; + /** Clear attention to the window. */ clearAttention: () => void; + /** Close the window. */ close: () => void; - show: () => void; + /** Show the window. Does nothing if the window is already visible. Focus the window if |focused| is set to true or omitted. */ + show: (focused?: boolean) => void; + /** Hide the window. Does nothing if the window is already hidden. */ hide: () => void; + /** + * @deprecated Deprecated since Chrome 36. Use innerBounds or outerBounds. + * @description Get the window's inner bounds as a ContentBounds object. + */ getBounds: () => ContentBounds; + /** + * Set the window's inner bounds. + * @deprecated Deprecated since Chrome 36. Use innerBounds or outerBounds. + */ setBounds: (bounds: ContentBounds) => void; + /** Is the window always on top? */ isAlwaysOnTop: () => boolean; + /** Set whether the window should stay above most other windows. Requires the alwaysOnTopWindows permission. */ setAlwaysOnTop: (alwaysOnTop: boolean) => void; + /** Set whether the window is visible on all workspaces. (Only for platforms that support this). */ setVisibleOnAllWorkspaces: (alwaysVisible: boolean) => void; + /** The JavaScript 'window' object for the created child. */ contentWindow: Window; + /** The id the window was created with. */ id: string; + /** + * The position, size and constraints of the window's content, which does not include window decorations. + * @since This property is new in Chrome 36. + * */ innerBounds: Bounds; + /** + * The position, size and constraints of the window, which includes window decorations, such as the title bar and frame. + * @since This property is new in Chrome 36. + */ outerBounds: Bounds; + + + /** Fired when the window is resized. */ onBoundsChanged: WindowEvent; + /** + * Fired when the window is closed. + * Note, this should be listened to from a window other than the window being closed, for example from the background page. + * This is because the window being closed will be in the process of being torn down when the event is fired, + * which means not all APIs in the window's script context will be functional. + */ onClosed: WindowEvent; + /** Fired when the window is fullscreened (either via the AppWindow or HTML5 APIs). */ onFullscreened: WindowEvent; + /** Fired when the window is maximized. */ onMaximized: WindowEvent; + /** Fired when the window is minimized. */ onMinimized: WindowEvent; + /** Fired when the window is restored from being minimized or maximized. */ onRestored: WindowEvent; } - - export function create(url: string, options?: CreateWindowOptions, callback?: (created_window: AppWindow) => void): void; - export function current(): AppWindow; - export function get(id: string): AppWindow; - export function getAll(): AppWindow[]; - export function canSetVisibleOnAllWorkspaces(): boolean; - interface WindowEvent extends chrome.events.Event<() => void> { } - - export var onBoundsChanged: WindowEvent; - export var onClosed: WindowEvent; - export var onFullscreened: WindowEvent; - export var onMaximized: WindowEvent; - export var onMinimized: WindowEvent; - export var onRestored: WindowEvent; + /** + * The size and position of a window can be specified in a number of different ways. The most simple option is not specifying anything at all, in which case a default size and platform dependent position will be used. + * To set the position, size and constraints of the window, use the innerBounds or outerBounds properties. Inner bounds do not include window decorations. Outer bounds include the window's title bar and frame. Note that the padding between the inner and outer bounds is determined by the OS. Therefore setting the same property for both inner and outer bounds is considered an error (for example, setting both innerBounds.left and outerBounds.left). + * To automatically remember the positions of windows you can give them ids. If a window has an id, This id is used to remember the size and position of the window whenever it is moved or resized. This size and position is then used instead of the specified bounds on subsequent opening of a window with the same id. If you need to open a window with an id at a location other than the remembered default, you can create it hidden, move it to the desired location, then show it. + * + * @param url + * @param [options] + * @param [callback] Called in the creating window (parent) before the load event is called in the created window (child). The parent can set fields or functions on the child usable from onload. E.g. background.js: function(createdWindow) { createdWindow.contentWindow.foo = function () { }; }; window.js: window.onload = function () { foo(); } If you specify the callback parameter, it should be a function that looks like this: function(AppWindow createdWindow) {...}; + */ + export function create(url: string, options?: CreateWindowOptions, callback?: (created_window: AppWindow) => void): void; + /** + * Returns an AppWindow object for the current script context (ie JavaScript 'window' object). This can also be called on a handle to a script context for another page, for example: otherWindow.chrome.app.window.current(). + */ + export function current(): AppWindow; + /** + * Gets an AppWindow with the given id. If no window with the given id exists null is returned. This method is new in Chrome 33. + */ + export function get(id: string): AppWindow; + /** + * Gets an array of all currently created app windows. This method is new in Chrome 33. + */ + export function getAll(): AppWindow[]; + /** + * Whether the current platform supports windows being visible on all workspaces. + */ + export function canSetVisibleOnAllWorkspaces(): boolean; } @@ -365,8 +709,9 @@ declare namespace chrome { // Audio //////////////////// /** - * The chrome.audio API is provided to allow users to get information about and control the audio devices attached to the system. This API is currently only implemented for ChromeOS. - * @since Chrome 59 + * The chrome.audio API is provided to allow users to get information about and control the audio devices attached to the system. + * This API is currently only implemented for ChromeOS. + * @since Since Chrome 59. */ namespace audio { export type StreamType = 'INPUT' | 'OUTPUT'; @@ -376,8 +721,8 @@ declare namespace chrome { /** Stream type associated with this device. */ streamType: StreamType; /** Type of the device. */ - deviceType: "HEADPHONE" | "MIC" | "USB" | "BLUETOOTH" | "HDMI" | "INTERNAL_SPEAKER" | "INTERNAL_MIC" | "FRONT_MIC" | "REAR_MIC" | "KEYBOARD_MIC" | "HOTWORD" | "LINEOUT" | "POST_MIX_LOOPBACK" | "POST_DSP_LOOPBACK" | "OTHER"; - /** The user-friendly name (e.g. "USB Microphone"). */ + deviceType: 'HEADPHONE' | 'MIC' | 'USB' | 'BLUETOOTH' | 'HDMI' | 'INTERNAL_SPEAKER' | 'INTERNAL_MIC' | 'FRONT_MIC' | 'REAR_MIC' | 'KEYBOARD_MIC' | 'HOTWORD' | 'LINEOUT' | 'POST_MIX_LOOPBACK' | 'POST_DSP_LOOPBACK' | 'OTHER'; + /** The user-friendly name (e.g. 'USB Microphone'). */ displayName: string; /** Device name. */ deviceName: string; @@ -443,15 +788,15 @@ declare namespace chrome { addListener(callback: (devices: AudioDeviceInfo[]) => void): void; } /** - * @description Device properties by which to filter the list of returned audio devices. If the filter is not set or set to {}, returned device list will contain all available audio devices. + * Device properties by which to filter the list of returned audio devices. If the filter is not set or set to {}, returned device list will contain all available audio devices. */ interface Filter { /** - * @description If set, only audio devices whose stream type is included in this list will satisfy the filter. + * If set, only audio devices whose stream type is included in this list will satisfy the filter. */ streamTypes?: StreamType[]; /** - * @description If set, only audio devices whose active state matches this value will satisfy the filter. + * If set, only audio devices whose active state matches this value will satisfy the filter. */ isActive?: boolean; } @@ -490,42 +835,68 @@ declare namespace chrome { //////////////////// /** * Use the chrome.bluetooth API to connect to a Bluetooth device. All functions report failures via chrome.runtime.lastError. - * Manifest: "bluetooth": {...} + * Manifest: 'bluetooth': {...} * @since Chrome 37 */ namespace bluetooth { interface AdapterState { + /** The address of the adapter, in the format 'XX:XX:XX:XX:XX:XX'. */ address: string; + /** The human-readable name of the adapter. */ name: string; + /** Indicates whether or not the adapter has power. */ powered: boolean; + /** Indicates whether or not the adapter is available (i.e. enabled). */ available: boolean; + /** Indicates whether or not the adapter is currently discovering. */ discovering: boolean; } interface Device { + /** The address of the device, in the format 'XX:XX:XX:XX:XX:XX'. */ address: string; + /** The human-readable name of the device. */ name?: string; + /** The class of the device, a bit-field defined by http://www.bluetooth.org/en-us/specification/assigned-numbers/baseband. */ deviceClass?: number; + /** The Device ID record of the device, where available. */ vendorIdSource?: 'bluetooth' | 'usb'; vendorId?: number; productId?: number; deviceId?: number; - type?: "computer" | "phone" | "modem" | "audio" | "carAudio" | "video" | "peripheral" | "joystick" | "gamepad" | "keyboard" | "mouse" | "tablet" | "keyboardMouseCombo"; + /** + * The type of the device, if recognized by Chrome. + * This is obtained from the |deviceClass| field and only represents a small fraction of the possible device types. + * When in doubt you should use the |deviceClass| field directly. + */ + type?: 'computer' | 'phone' | 'modem' | 'audio' | 'carAudio' | 'video' | 'peripheral' | 'joystick' | 'gamepad' | 'keyboard' | 'mouse' | 'tablet' | 'keyboardMouseCombo'; + /** Indicates whether or not the device is paired with the system. */ paired?: boolean; + /** Indicates whether the device is currently connected to the system. */ connected?: boolean; /** + * Indicates whether the device is currently connecting to the system. * @since Chrome 48 */ connecting?: boolean; /** + * Indicates whether the device is connectable. * @since Chrome 48 */ connectable?: boolean; + /** + * UUIDs of protocols, profiles and services advertised by the device. + * For classic Bluetooth devices, this list is obtained from EIR data and SDP tables. + * For Low Energy devices, this list is obtained from AD and GATT primary services. + * For dual mode devices this may be obtained from both. + */ uuids?: string[]; /** + * The received signal strength, in dBm. This field is avaliable and valid only during discovery. Outside of discovery it's value is not specified. * @since Chrome 44 */ inquiryRssi: number; /** + * The transmitted power level. This field is avaliable only for LE devices that include this field in AD. It is avaliable and valid only during discovery. * @since Chrome 44 */ inquiryTxPower: number; @@ -572,25 +943,438 @@ declare namespace chrome { } /** * The chrome.bluetoothLowEnergy API is used to communicate with Bluetooth Smart (Low Energy) devices using the Generic Attribute Profile (GATT). - * Manifest: "bluetooth": {...} + * Manifest: 'bluetooth': {...} * @since Chrome 37 * Important: This API works only on Chrome OS. * Note: With Chrome 56, users can select nearby Bluetooth Low Energy devices to provide to web sites that use the Web Bluetooth API. */ namespace bluetoothLowEnergy { + interface Service { + /** The UUID of the service, e.g. 0000180d-0000-1000-8000-00805f9b34fb. */ + uuid: string; + /** Indicates whether the type of this service is primary or secondary. */ + isPrimary: boolean; + /** + * Returns the identifier assigned to this service. + * Use the instance ID to distinguish between services from a peripheral with the same UUID and to make function calls that take in a service identifier. + * Present, if this instance represents a remote service. + **/ + instanceId?: string; + /** + * The device address of the remote peripheral that the GATT service belongs to. + * Present, if this instance represents a remote service. + */ + deviceAddress?: string; + } + enum CharacteristicProperties { + 'broadcast', + 'read', + 'writeWithoutResponse', + 'write', + 'notify', + 'indicate', + 'authenticatedSignedWrites', + 'extendedProperties', + 'reliableWrite', + 'writableAuxiliaries', + 'encryptRead', + 'encryptWrite', + 'encryptAuthenticatedRead', + 'encryptAuthenticatedWrite' + } + interface Characteristic { + /** The UUID of the characteristic, e.g. 00002a37-0000-1000-8000-00805f9b34fb. */ + uuid: string; + /** The GATT service this characteristic belongs to. */ + service?: Service; + /** The properties of this characteristic. */ + properties: CharacteristicProperties[]; + /** Returns the identifier assigned to this characteristic. Use the instance ID to distinguish between characteristics from a peripheral with the same UUID and to make function calls that take in a characteristic identifier. Present, if this instance represents a remote characteristic. */ + instanceId?: string; + /** The currently cached characteristic value. This value gets updated when the value of the characteristic is read or updated via a notification or indication. */ + value?: ArrayBuffer; + } + enum DescriptorPermissions { + 'read', + 'write', + 'encryptedRead', + 'encryptedWrite', + 'encryptedAuthenticatedRead', + 'encryptedAuthenticatedWrite' + } + interface Descriptor { + /** The UUID of the characteristic descriptor, e.g. 00002902-0000-1000-8000-00805f9b34fb. */ + uuid: string; + /** The GATT characteristic this descriptor belongs to. */ + characteristic?: Characteristic; + /** + * The permissions of this descriptor. + * @since Since Chrome 52. + */ + permissions: DescriptorPermissions[]; + /** Returns the identifier assigned to this descriptor. Use the instance ID to distinguish between descriptors from a peripheral with the same UUID and to make function calls that take in a descriptor identifier. Present, if this instance represents a remote characteristic. */ + instanceId?: string; + /** The currently cached descriptor value. This value gets updated when the value of the descriptor is read. */ + value?: ArrayBuffer; + } + interface RequestDevice { + /** The address of the device, in the format 'XX:XX:XX:XX:XX:XX'. */ + address: string; + /** The human-readable name of the device. */ + name?: string; + /** The class of the device, a bit - field defined by: + * @see [Specs]{@link http://www.bluetooth.org/en-us/specification/assigned-numbers/baseband} + **/ + deviceClass?: number; + } + interface Request { + /** Unique ID for this request. Use this ID when responding to this request. */ + requestId: number; + /** Device that send this request. */ + device: RequestDevice; + /** Value to write (if this is a write request). */ + value?: ArrayBuffer; + } + interface IProperties { + /** + * Flag indicating whether a connection to the device is left open when the event page of the application is unloaded. The default value is false. + * @see [HowToManageAppLifecycle]{@link https://developer.chrome.com/apps/app_lifecycle} + * @default false + */ + persistent: boolean; + } + interface INotification { + /** New value of the characteristic. */ + value: ArrayBuffer; + /** Optional flag for sending an indication instead of a notification. */ + shouldIndicate: boolean; + } + enum AdvertisementType { + 'broadcast', 'peripheral' + } + interface Advertisement { + /** Type of advertisement. */ + type: AdvertisementType; + /** List of UUIDs to include in the 'Service UUIDs' field of the Advertising Data. These UUIDs can be of the 16bit, 32bit or 128 formats. */ + serviceUuids?: string[]; + /** List of manufacturer specific data to be included in 'Manufacturer Specific Data' fields of the advertising data. */ + manufacturerData?: { id: number, data: number[] }; + /** List of UUIDs to include in the 'Solicit UUIDs' field of the Advertising Data. These UUIDs can be of the 16bit, 32bit or 128 formats. */ + solicitUuids?: string[]; + /** List of service data to be included in 'Service Data' fields of the advertising data. */ + serviceData: { uuid: string, data: number[] }; + } + interface IResponse { + /** Id of the request this is a response to. */ + requestId: number; + /** If this is an error response, this should be true. */ + isError: boolean; + /** Response value. Write requests and error responses will ignore this parameter. */ + value?: ArrayBuffer; + } /** - * NOT IMPLEMENTED YET - * @see https://developer.chrome.com/apps/bluetoothLowEnergy - * */ + * Establishes a connection between the application and the device with the given address. A device may be already connected and its GATT services available without calling connect, however, an app that wants to access GATT services of a device should call this function to make sure that a connection to the device is maintained. If the device is not connected, all GATT services of the device will be discovered after a successful call to connect. + * @param deviceAddress The Bluetooth address of the remote device to which a GATT connection should be opened. + * @param callback Called when the connect request has completed. + */ + function connect(deviceAddress: string, callback: () => void): void; + /** + * Establishes a connection between the application and the device with the given address. A device may be already connected and its GATT services available without calling connect, however, an app that wants to access GATT services of a device should call this function to make sure that a connection to the device is maintained. If the device is not connected, all GATT services of the device will be discovered after a successful call to connect. + * @param deviceAddress The Bluetooth address of the remote device to which a GATT connection should be opened. + * @param properties Connection properties (optional). + * @param callback Called when the connect request has completed. + */ + function connect(deviceAddress: string, properties: IProperties, callback: () => void): void; + /** + * Closes the app's connection to the device with the given address. Note that this will not always destroy the physical link itself, since there may be other apps with open connections. + * @param deviceAddress The Bluetooth address of the remote device. + * @param [callback] Called when the disconnect request has completed. + */ + function disconnect(deviceAddress: string, callback?: () => void): void; + /** + * Get the GATT service with the given instance ID. + * @param serviceId The instance ID of the requested GATT service. + * @param callback Called with the requested Service object. + */ + function getService(serviceId: string, callback: (result: Service) => void): void; + /** + * @description Create a locally hosted GATT service. This service can be registered to be available on a local GATT server. This function is only available if the app has both the bluetooth:low_energy and the bluetooth:peripheral permissions set to true. The peripheral permission may not be available to all apps. + * @since Since Chrome 52. + * @param service The service to create. + * @param callback Called with the created services's unique ID. + */ + function createService(service: Service, callback: () => void): void; + /** + * Get all the GATT services that were discovered on the remote device with the given device address. + * Note: If service discovery is not yet complete on the device, this API will return a subset (possibly empty) of services. A work around is to add a time based delay and/or call repeatedly until the expected number of services is returned. + * @param deviceAddress The Bluetooth address of the remote device whose GATT services should be returned. + * @param callback Called with the list of requested Service objects. + */ + function getServices(deviceAddress: string, callback: (result: Service[]) => void): void; + /** + * Get the GATT characteristic with the given instance ID that belongs to the given GATT service, if the characteristic exists. + * @param characteristicId The instance ID of the requested GATT characteristic. + * @param callback Called with the requested Characteristic object. + */ + function getCharacteristic(characteristicId: string, callback: (result: Characteristic) => void): void; + /** + * @description Create a locally hosted GATT characteristic. This characteristic must be hosted under a valid service. If the service ID is not valid, the lastError will be set. This function is only available if the app has both the bluetooth:low_energy and the bluetooth:peripheral permissions set to true. The peripheral permission may not be available to all apps. + * @since Since Chrome 52. + * @param characteristic The characteristic to create. + * @param serviceId ID of the service to create this characteristic for. + * @param callback Called with the created characteristic's unique ID. + */ + function createCharacteristic(characteristic: Characteristic, serviceId: string, callback: (characteristicId: string) => void): void; + /** + * Get a list of all discovered GATT characteristics that belong to the given service. + * @param serviceId The instance ID of the GATT service whose characteristics should be returned. + * @param callback Called with the list of characteristics that belong to the given service. + */ + function getCharacteristics(serviceId: string, callback: (result: Characteristic[]) => void): void; + /** + * Get a list of GATT services that are included by the given service. + * @param serviceId The instance ID of the GATT service whose included services should be returned. + * @param callback Called with the list of GATT services included from the given service. + */ + function getIncludedServices(serviceId: string, callback: (result: Service[]) => void): void; + /** + * Get the GATT characteristic descriptor with the given instance ID. + * @param descriptorId The instance ID of the requested GATT characteristic descriptor. + * @param callback Called with the requested Descriptor object. + */ + function getDescriptor(descriptorId: string, callback: (result: Descriptor) => void): void; + /** + * Create a locally hosted GATT descriptor. This descriptor must be hosted under a valid characteristic. If the characteristic ID is not valid, the lastError will be set. This function is only available if the app has both the bluetooth:low_energy and the bluetooth:peripheral permissions set to true. The peripheral permission may not be available to all apps. + * @since Since Chrome 52. + * @param descriptor The descriptor to create. + * @param characteristicId ID of the characteristic to create this descriptor for. + * @param callback Called with the created desciptor's unique ID. + */ + function createDescriptor(descriptor: Descriptor, characteristicId: string, callback: (descriptorId: string) => void): void; + /** + * Get a list of GATT characteristic descriptors that belong to the given characteristic. + * @param characteristicId The instance ID of the GATT characteristic whose descriptors should be returned. + * @param callback Called with the list of descriptors that belong to the given characteristic. + */ + function getDescriptors(characteristicId: string, callback: (result: Descriptor[]) => void): void; + /** + * Retrieve the value of a specified characteristic from a remote peripheral. + * @param characteristicId The instance ID of the GATT characteristic whose value should be read from the remote device. + * @param callback Called with the Characteristic object whose value was requested. The value field of the returned Characteristic object contains the result of the read request. + */ + function readCharacteristicValue(characteristicId: string, callback: (result: Characteristic) => void): void; + /** + * Write the value of a specified characteristic from a remote peripheral. + * @param characteristicId The instance ID of the GATT characteristic whose value should be written to. + * @param value The value that should be sent to the remote characteristic as part of the write request. + * @param callback Called when the write request has completed. + */ + function writeCharacteristicValue(characteristicId: string, value: ArrayBuffer, callback: () => void): void; + /** + * Enable value notifications/indications from the specified characteristic. Once enabled, an application can listen to notifications using the onCharacteristicValueChanged event. + * @see onCharacteristicValueChanged + * @param characteristicId The instance ID of the GATT characteristic that notifications should be enabled on. + * @param callback Called when the request has completed. + */ + function startCharacteristicNotifications(characteristicId: string, callback: () => void): void; + /** + * Enable value notifications/indications from the specified characteristic. Once enabled, an application can listen to notifications using the onCharacteristicValueChanged event. + * @see onCharacteristicValueChanged + * @param characteristicId The instance ID of the GATT characteristic that notifications should be enabled on. + * @param properties Notification session properties (optional). + * @param callback Called when the request has completed. + */ + function startCharacteristicNotifications(characteristicId: string, properties: IProperties, callback: () => void): void; + /** + * Disable value notifications/indications from the specified characteristic. After a successful call, the application will stop receiving notifications/indications from this characteristic. + * @param characteristicId The instance ID of the GATT characteristic on which this app's notification session should be stopped. + * @param [callback] Called when the request has completed (optional). + */ + function stopCharacteristicNotifications(characteristicId: string, callback?: () => void): void; + /** + * Notify a remote device of a new value for a characteristic. + * If the shouldIndicate flag in the notification object is true, an indication will be sent instead of a notification. + * Note, the characteristic needs to correctly set the 'notify' or 'indicate' property during creation for this call to succeed. + * This function is only available if the app has both the bluetooth:low_energy and the bluetooth:peripheral permissions set to true. + * The peripheral permission may not be available to all apps. + * @since Since Chrome 52. + * @param characteristicId The characteristic to send the notication for. + * @param notification Notification object + * @param callback Callback called once the notification or indication has been sent successfully. + */ + function notifyCharacteristicValueChanged(characteristicId: string, notification: INotification, callback: () => void): void; + /** + * Retrieve the value of a specified characteristic descriptor from a remote peripheral. + * @param descriptorId The instance ID of the GATT characteristic descriptor whose value should be read from the remote device. + * @param callback Called with the Descriptor object whose value was requested. The value field of the returned Descriptor object contains the result of the read request. + */ + function readDescriptorValue(descriptorId: string, callback: (result: Descriptor) => void): void; + /** + * Write the value of a specified characteristic descriptor from a remote peripheral. + * @param descriptorId The instance ID of the GATT characteristic descriptor whose value should be written to. + * @param value The value that should be sent to the remote descriptor as part of the write request. + * @param callback Called when the write request has completed. + */ + function writeDescriptorValue(descriptorId: string, value: ArrayBuffer, callback: () => void): void; + /** + * Register the given service with the local GATT server. + * If the service ID is invalid, the lastError will be set. + * This function is only available if the app has both + * the bluetooth:low_energy and the bluetooth:peripheral permissions set to true. + * The peripheral permission may not be available to all apps. + * @since Since Chrome 52. + * @param serviceId Unique ID of a created service. + * @param callback Callback with the result of the register operation. + */ + function registerService(serviceId: string, callback: () => void): void; + /** + * Unregister the given service with the local GATT server. + * If the service ID is invalid, the lastError will be set. + * This function is only available if the app has both + * the bluetooth:low_energy and the bluetooth:peripheral permissions set to true. + * The peripheral permission may not be available to all apps. + * @since Since Chrome 52. + * @param serviceId Unique ID of a current registered service. + * @param callback Callback with the result of the register operation. + */ + function unregisterService(serviceId: string, callback: () => void): void; + /** + * Remove the specified service, unregistering it if it was registered. + * If the service ID is invalid, the lastError will be set. + * This function is only available if the app has both + * the bluetooth:low_energy and the bluetooth:peripheral permissions set to true. + * The peripheral permission may not be available to all apps. + * @since Since Chrome 52. + * @param serviceId Unique ID of a current registered service. + * @param [callback] Callback called once the service is removed. + */ + function removeService(serviceId: string, callback?: () => void): void; + /** + * Create an advertisement and register it for advertising. + * To call this function, the app must have + * the bluetooth:low_energy and bluetooth:peripheral permissions set to true. + * Additionally this API is only available to auto launched apps in Kiosk Mode + * of by setting the 'enable-ble-advertising-in-apps' flag. + * See https://developer.chrome.com/apps/manifest/bluetooth + * Note: On some hardware, central and peripheral modes at the same time + * is supported but on hardware that doesn't support this, + * making this call will switch the device to peripheral mode. + * In the case of hardware which does not support both central and peripheral mode, + * attempting to use the device in both modes will lead to undefined behavior + * or prevent other central-role applications from behaving correctly + * (including the discovery of Bluetooth Low Energy devices). + * @since Since Chrome 47. + * @param advertisement The advertisement to advertise. + * @param callback Called once the registeration is done and we've started advertising. Returns the id of the created advertisement. + */ + function registerAdvertisement(advertisement: Advertisement, callback: (advertisementId: number) => void): void; + /** + * Unregisters an advertisement and stops its advertising. + * If the advertisement fails to unregister the only way + * to stop advertising might be to restart the device. + * @since Since Chrome 47. + * @param advertisementId Id of the advertisement to unregister. + * @param callback Called once the advertisement is unregistered and is no longer being advertised. + */ + function unregisterAdvertisement(advertisementId: number, callback: () => void): void; + /** + * Resets advertising on the current device. It will unregister and stop all existing advertisements. + * @since Since Chrome 61. + * @param callback Called once the advertisements are reset. + */ + function resetAdvertising(callback: () => void): void; + /** + * Set's the interval betweeen two consecutive advertisements. + * Note: This is a best effort. + * The actual interval may vary non-trivially from the requested intervals. + * On some hardware, there is a minimum interval of 100ms. + * The minimum and maximum values cannot exceed the the range allowed by the Bluetooth 4.2 specification. + * @since Since Chrome 55. + * @param minInterval Minimum interval between advertisments (in milliseconds). This cannot be lower than 20ms (as per the spec). + * @param maxInterval Maximum interval between advertisments (in milliseconds). This cannot be more than 10240ms (as per the spec). + * @param callback Called once the interval has been set. + */ + function setAdvertisingInterval(minInterval: number, maxInterval: number, callback: () => void): void; + /** + * Sends a response for a characteristic or descriptor read/write request. This function is only available if the app has both the bluetooth:low_energy and the bluetooth:peripheral permissions set to true. The peripheral permission may not be available to all apps. + * @since Since Chrome 52. + * @param response The response to the request. + */ + function sendRequestResponse(response: IResponse): void; + /** Fired whan a new GATT service has been discovered on a remote device. */ + var onServiceAdded: chrome.events.Event<(service: Service) => void>; + /** + * Fired when the state of a remote GATT service changes. + * This involves any characteristics and/or descriptors + * that get added or removed from the service, as well as + * "ServiceChanged" notifications from the remote device. + */ + var onServiceChanged: chrome.events.Event<(service: Service) => void>; + /** Fired when a GATT service that was previously discovered on a remote device has been removed. */ + var onServiceRemoved: chrome.events.Event<(service: Service) => void>; + /** + * Fired when the value of a remote GATT characteristic changes, + * either as a result of a read request, + * or a value change notification/indication. + * This event will only be sent if the app has enabled notifications + * by calling startCharacteristicNotifications. + */ + var onCharacteristicValueChanged: chrome.events.Event<(characteristic: Characteristic) => void>; + /** + * Fired when the value of a remote GATT characteristic descriptor changes, + * usually as a result of a read request. + * This event exists mostly for convenience and will always be sent after + * a successful call to readDescriptorValue. + */ + var onDescriptorValueChanged: chrome.events.Event<(descriptor: Descriptor) => void>; + /** + * Fired when a connected central device requests to read the value of + * a characteristic registered on the local GATT server. + * Not responding to this request for a long time may lead to a disconnection. + * This event is only available if the app has both the bluetooth:low_energy + * and the bluetooth:peripheral permissions set to true. + * The peripheral permission may not be available to all apps. + * @since Since Chrome 52. + */ + var onCharacteristicReadRequest: chrome.events.Event<(characteristic: Characteristic) => void>; + /** + * Fired when a connected central device requests to write the value of + * a characteristic registered on the local GATT server. + * Not responding to this request for a long time may lead to a disconnection. + * This event is only available if the app has both the bluetooth:low_energy + * and the bluetooth:peripheral permissions set to true. + * The peripheral permission may not be available to all apps. + * @since Since Chrome 52. + */ + var onCharacteristicWriteRequest: chrome.events.Event<(characteristic: Characteristic) => void>; + /** + * Fired when a connected central device requests to read the value of + * a descriptor registered on the local GATT server. + * Not responding to this request for a long time may lead to a disconnection. + * This event is only available if the app has both the bluetooth:low_energy + * and the bluetooth:peripheral permissions set to true. + * The peripheral permission may not be available to all apps. + * @since Since Chrome 52. + */ + var onDescriptorReadRequest: chrome.events.Event<(descriptor: Descriptor) => void>; + /** + * Fired when a connected central device requests to write the value of + * a descriptor registered on the local GATT server. + * Not responding to this request for a long time may lead to a disconnection. + * This event is only available if the app has both the bluetooth:low_energy + * and the bluetooth:peripheral permissions set to true. + * The peripheral permission may not be available to all apps. + */ + var onDescriptorWriteRequest: chrome.events.Event<(descriptor: Descriptor) => void>; } /** * Use the chrome.bluetoothSocket API to send and receive data to Bluetooth devices using RFCOMM and L2CAP connections. * @since Chrome 37 - * Manifest: "bluetooth": {...} + * Manifest: 'bluetooth': {...} * Important: This API works only on OS X, Windows and Chrome OS. */ namespace bluetoothSocket { - /** NOT IMPLEMENTED YET */ + /* NOT IMPLEMENTED YET */ } //////////////////// @@ -631,7 +1415,7 @@ declare namespace chrome { /** * Use the commands API to add keyboard shortcuts that trigger actions in your extension, for example, an action to open the browser action or send a command to the extension. * Availability: Since Chrome 25. - * Manifest: "commands": {...} + * Manifest: 'commands': {...} */ namespace commands { interface Command { @@ -663,17 +1447,17 @@ declare namespace chrome { /** * Use the chrome.contextMenus API to add items to Google Chrome's context menu. You can choose what types of objects your context menu additions apply to, such as images, hyperlinks, and pages. * Availability: Since Chrome 6. - * Permissions: "contextMenus" + * Permissions: 'contextMenus' */ namespace contextMenus { /** * The different contexts a menu can appear in. Specifying 'all' is equivalent to the combination of all other contexts except for 'launcher'. The 'launcher' context is only supported by apps and is used to add menu items to the context menu that appears when clicking on the app icon in the launcher/taskbar/dock/etc. Different platforms might put limitations on what is actually supported in a launcher context menu. **/ - export type ContextType = "all" | "page" | "frame" | "selection" | "link" | "editable" | "image" | "video" | "audio" | "launcher" | "browser_action" | "page_action"; + export type ContextType = 'all' | 'page' | 'frame' | 'selection' | 'link' | 'editable' | 'image' | 'video' | 'audio' | 'launcher' | 'browser_action' | 'page_action'; /** * The type of menu item. **/ - export type ItemType = "normal" | "checkbox" | "radio" | "separator"; + export type ItemType = 'normal' | 'checkbox' | 'radio' | 'separator'; interface OnClickData { /** @@ -746,7 +1530,7 @@ declare namespace chrome { documentUrlPatterns?: string[]; /** Optional. The initial state of a checkbox or radio item: true for selected and false for unselected. Only one radio item can be selected at a time in a given group of radio items. */ checked?: boolean; - /** Optional. The text to be displayed in the item; this is required unless type is 'separator'. When the context is 'selection', you can use %s within the string to show the selected text. For example, if this parameter's value is "Translate '%s' to Pig Latin" and the user selects the word "cool", the context menu item for the selection is "Translate 'cool' to Pig Latin". */ + /** Optional. The text to be displayed in the item; this is required unless type is 'separator'. When the context is 'selection', you can use %s within the string to show the selected text. For example, if this parameter's value is 'Translate '%s' to Pig Latin' and the user selects the word 'cool', the context menu item for the selection is 'Translate 'cool' to Pig Latin'. */ title?: string; /** Optional. List of contexts this menu item will appear in. Defaults to ['page'] if not specified. */ contexts?: string[]; @@ -873,7 +1657,7 @@ declare namespace chrome { /** * Use the chrome.documentScan API to discover and retrieve images from attached paper document scanners. * Availability: Since Chrome 44. - * Permissions: "documentScan" + * Permissions: 'documentScan' * Important: This API works only on Chrome OS. */ namespace documentScan { @@ -885,7 +1669,7 @@ declare namespace chrome { } interface DocumentScanCallbackArg { - /** The data image URLs in a form that can be passed as the "src" value to an image tag. */ + /** The data image URLs in a form that can be passed as the 'src' value to an image tag. */ dataUrls: string[]; /** The MIME type of dataUrls. */ mimeType: string; @@ -1062,13 +1846,13 @@ declare namespace chrome { */ interface ImageDetails { /** - * @description The format of the resulting image. Default is "jpeg". + * @description The format of the resulting image. Default is 'jpeg'. * @type {ImageFormat} * @memberof ImageDetails */ format?: ImageFormat; /** - * @description When format is "jpeg", controls the quality of the resulting image. This value is ignored for PNG images. As quality is decreased, the resulting image will have more visual artifacts, and the number of bytes needed to store it will decrease. + * @description When format is 'jpeg', controls the quality of the resulting image. This value is ignored for PNG images. As quality is decreased, the resulting image will have more visual artifacts, and the number of bytes needed to store it will decrease. * @type {number} * @memberof ImageDetails */ @@ -1121,13 +1905,13 @@ declare namespace chrome { */ matchAboutBlank?: boolean; /** - * @description The soonest that the JavaScript or CSS will be injected into the tab. Defaults to "document_idle". + * @description The soonest that the JavaScript or CSS will be injected into the tab. Defaults to 'document_idle'. * @type {RunAt} * @memberof InjectDetails */ runAt: RunAt; /** - * @description The origin of the CSS to inject. This may only be specified for CSS, not JavaScript. Defaults to "author". + * @description The origin of the CSS to inject. This may only be specified for CSS, not JavaScript. Defaults to 'author'. * @since Since Chrome 66. * @type {CSSOrigin} * @memberof InjectDetails @@ -1139,32 +1923,118 @@ declare namespace chrome { //////////////////// // FileSystem //////////////////// + /** + * Use the chrome.fileSystem API to create, read, navigate, and write to the user's local file system. + * With this API, Chrome Apps can read and write to a user-selected location. + * For example, a text editor app can use the API to read and write local documents. + * All failures are notified via chrome.runtime.lastError. + */ namespace fileSystem { interface AcceptOptions { + /** + * This is the optional text description for this option. + * If not present, a description will be automatically generated; + * typically containing an expanded list of valid extensions (e.g. 'text/html' may expand to '*.html, *.htm'). + */ description?: string; + /** + * Mime-types to accept, e.g. 'image/jpeg' or 'audio/*'. One of mimeTypes or extensions must contain at least one valid element. + */ mimeTypes?: string[]; + /** + * Extensions to accept, e.g. 'jpg' | 'gif' | 'crx'. + */ extensions?: string[]; } interface ChooseEntryOptions { - type?: string; + /** + * Type of the prompt to show. The default is 'openFile'. + * openFile + * - Prompts the user to open an existing file and returns a FileEntry on success. From Chrome 31 onwards, the FileEntry will be writable if the application has the 'write' permission under 'fileSystem'; otherwise, the FileEntry will be read-only. + * openWritableFile + * - Prompts the user to open an existing file and returns a writable FileEntry on success. Calls using this type will fail with a runtime error if the application doesn't have the 'write' permission under 'fileSystem'. + * saveFile + * - Prompts the user to open an existing file or a new file and returns a writable FileEntry on success. Calls using this type will fail with a runtime error if the application doesn't have the 'write' permission under 'fileSystem'. + * openDirectory + * - Prompts the user to open a directory and returns a DirectoryEntry on success. Calls using this type will fail with a runtime error if the application doesn't have the 'directory' permission under 'fileSystem'. If the application has the 'write' permission under 'fileSystem', the returned DirectoryEntry will be writable; otherwise it will be read-only. New in Chrome 31. + */ + type?: 'openFile' | 'openWritableFile' | 'saveFile' | 'openDirectory'; + /** The suggested file name that will be presented to the user as the default name to read or write. This is optional. */ 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. + * The default is true. If the accepts field is unset or contains no valid entries, this will always be reset to true. + */ acceptsAllTypes?: boolean; + /** + * 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. + */ acceptsMultiple?: boolean; } + type ChildChangeType = 'created' | 'removed' | 'changed'; + + interface Volume { + /** The ID of the requested volume. */ + volumeId: string; + /** Whether the requested file system should be writable. The default is read-only. */ + writable?: boolean; + } + + /** + * 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. + */ export function getDisplayPath(entry: Entry, 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'. + */ export function getWritableEntry(entry: Entry, callback: (entry: Entry) => void): void; + /** Gets whether this Entry is writable or not. */ export function isWritableEntry(entry: Entry, callback: (isWritable: boolean) => void): void; + /** Ask the user to choose a file or directory. */ export function chooseEntry(callback: (entry: Entry) => void): void; + /** Ask the user to choose a file or directory. */ export function chooseEntry(callback: (fileEntries: FileEntry[]) => void): void; + /** Ask the user to choose a file or directory. */ export function chooseEntry(options: ChooseEntryOptions, callback: (entry: Entry) => void): void; + /** Ask the user to choose a file or directory. */ export function chooseEntry(options: ChooseEntryOptions, callback: (fileEntries: FileEntry[]) => void): void; + /** Returns the file entry with the given id if it can be restored. This call will fail with a runtime error otherwise. */ export function restoreEntry(id: string, callback: (entry: Entry) => void): void; + /** Returns whether the app has permission to restore the entry with the given id. */ export function isRestorable(id: string, callback: (isRestorable: boolean) => void): void; + /** + * Returns an id that can be passed to restoreEntry to regain access to a given file entry. + * Only the 500 most recently used entries are retained, where calls to retainEntry and restoreEntry count as use. + * If the app has the 'retainEntries' permission under 'fileSystem', entries are retained indefinitely. + * Otherwise, entries are retained only while the app is running and across restarts. + * */ export function retainEntry(entry: Entry): string; + /** + * Requests access to a file system for a volume represented by options.volumeId. + * If options.writable is set to true, then the file system will be writable. + * Otherwise, it will be read-only. + * The writable option requires the 'fileSystem': {'write'} permission in the manifest. + * Available to kiosk apps running in kiosk session only. + * For manual-launch kiosk mode, a confirmation dialog will be shown on top of the active app window. + * In case of an error, fileSystem will be undefined, and chrome.runtime.lastError will be set. + */ + export function requestFileSystem(options: Volume, callback: (fileSystem: FileSystem) => void): void; + /** + * Returns a list of volumes available for requestFileSystem(). + * The 'fileSystem': {'requestFileSystem'} manifest permission is required. + * Available to kiosk apps running in the kiosk session only. + * In case of an error, volumes will be undefined, and chrome.runtime.lastError will be set. + */ + export function getVolumeList(callback: (volumes: Volume[]) => void): void; + export var onVolumeListChanged: chrome.events.Event<(object: Volume[]) => void>; } @@ -1174,7 +2044,7 @@ declare namespace chrome { /** * Use the chrome.fileSystemProvider API to create file systems, that can be accessible from the file manager on Chrome OS. * Availability: Since Chrome 40. - * Permissions: "fileSystemProvider" + * Permissions: 'fileSystemProvider' * Important: This API works only on Chrome OS. */ namespace fileSystemProvider { @@ -1204,7 +2074,7 @@ declare namespace chrome { /** File size in bytes. */ size: number; /** The last modified time of this entry. */ - modificationTime: Date; + modificationTime: any; /** Optional. Mime type for the entry. */ mimeType?: string; /** Optional. Thumbnail image as a data URI in either PNG, JPEG or WEBP format, at most 32 KB in size. Optional, but can be provided only when explicitly requested by the onGetMetadataRequested event. */ @@ -1460,7 +2330,7 @@ declare namespace chrome { /** * Notifies about changes in the watched directory at observedPath in recursive mode. If the file system is mounted with supportsNofityTag, then tag must be provided, and all changes since the last notification always reported, even if the system was shutdown. The last tag can be obtained with getAll. * To use, the file_system_provider.notify manifest option must be set to true. - * Value of tag can be any string which is unique per call, so it's possible to identify the last registered notification. Eg. if the providing extension starts after a reboot, and the last registered notification's tag is equal to "123", then it should call notify for all changes which happened since the change tagged as "123". It cannot be an empty string. + * Value of tag can be any string which is unique per call, so it's possible to identify the last registered notification. Eg. if the providing extension starts after a reboot, and the last registered notification's tag is equal to '123', then it should call notify for all changes which happened since the change tagged as '123'. It cannot be an empty string. * Not all providers are able to provide a tag, but if the file system has a changelog, then the tag can be eg. a change number, or a revision number. * Note that if a parent directory is removed, then all descendant entries are also removed, and if they are watched, then the API must be notified about the fact. Also, if a directory is renamed, then all descendant entries are in fact removed, as there is no entry under their original paths anymore. * In case of an error, runtime.lastError will be set will a corresponding error code. @@ -1486,7 +2356,7 @@ declare namespace chrome { export var onCreateDirectoryRequested: DirectoryPathRecursiveRequestedEvent; /** Raised when deleting an entry is requested. If recursive is true, and the entry is a directory, then all of the entries inside must be recursively deleted as well. */ export var onDeleteEntryRequested: EntryPathRecursiveRequestedEvent; - /** Raised when creating a file is requested. If the file already exists, then errorCallback must be called with the "EXISTS" error code. */ + /** Raised when creating a file is requested. If the file already exists, then errorCallback must be called with the 'EXISTS' error code. */ export var onCreateFileRequested: FilePathRequestedEvent; /** Raised when copying an entry (recursively if a directory) is requested. If an error occurs, then errorCallback must be called. */ export var onCopyEntryRequested: SourceTargetPathRequestedEvent; @@ -1526,9 +2396,17 @@ declare namespace chrome { /** * Use chrome.gcm to enable apps and extensions to send and receive messages through the Google Cloud Messaging Service. * Availability: Since Chrome 35. - * Permissions: "gcm" + * Permissions: 'gcm' */ namespace gcm { + interface IGCMData { + 'collapse_key'?: never; + 'goog'?: never; + 'goog.'?: never; + 'google'?: never; + 'GOOGLE'?: never; + [key: string]: any; + } interface OutgoingMessage { /** The ID of the server to send the message to as assigned by Google API Console. */ destinationId: string; @@ -1536,13 +2414,15 @@ declare namespace chrome { messageId: string; /** Optional. Time-to-live of the message in seconds. If it is not possible to send the message within that time, an onSendError event will be raised. A time-to-live of 0 indicates that the message should be sent immediately or fail if it's not possible. The maximum and a default value of time-to-live is 86400 seconds (1 day). */ timeToLive?: number; - /** Message data to send to the server. Case-insensitive goog. and google, as well as case-sensitive collapse_key are disallowed as key prefixes. Sum of all key/value pairs should not exceed gcm.MAX_MESSAGE_SIZE. */ - data: Object; + /** + * @description Message data to send to the server. Case-insensitive goog. and google, as well as case-sensitive collapse_key are disallowed as key prefixes. Sum of all key/value pairs should not exceed gcm.MAX_MESSAGE_SIZE. + **/ + data: IGCMData; } interface IncomingMessage { /** The message data. */ - data: Object; + data: IGCMData; /** * Optional. * The sender who issued the message. @@ -1571,7 +2451,7 @@ declare namespace chrome { interface GcmErrorEvent extends chrome.events.Event<(error: GcmError) => void> { } - /** The maximum size (in bytes) of all key/value pairs in a message. */ + /** The maximum size (in bytes) of all key/value pairs in a message. Default: 4096 */ export var MAX_MESSAGE_SIZE: number; /** @@ -1629,9 +2509,11 @@ declare namespace chrome { namespace i18n { /** Holds detected ISO language code and its percentage in the input string */ interface DetectedLanguage { - /** An ISO language code such as 'en' or 'fr'. - * For a complete list of languages supported by this method, see [kLanguageInfoTable]{@link https://src.chromium.org/viewvc/chrome/trunk/src/third_party/cld/languages/internal/languages.cc}. - * For an unknown language, 'und' will be returned, which means that [percentage] of the text is unknown to CLD */ + /** + * @description An ISO language code such as 'en' or 'fr'. + * @description For a complete list of languages supported by this method: + * @see [kLanguageInfoTable]{@link https://src.chromium.org/viewvc/chrome/trunk/src/third_party/cld/languages/internal/languages.cc}. + * @description For an unknown language, 'und' will be returned, which means that [percentage] of the text is unknown to CLD */ language: string; /** The percentage of the detected language */ @@ -1659,7 +2541,7 @@ declare namespace chrome { * @param messageName The name of the message, as specified in the messages.json file. * @param substitutions Optional. Up to 9 substitution strings, if the message requires any. */ - export function getMessage(messageName: string, substitutions?: any): string; + export function getMessage(messageName: string, substitutions?: any): string | undefined; /** * Gets the browser UI language of the browser. This is different from i18n.getAcceptLanguages which returns the preferred user languages. * @since Chrome 35. @@ -1678,7 +2560,7 @@ declare namespace chrome { //////////////////// /** * Use the chrome.identity API to get OAuth2 access tokens. - * Permissions: "identity" + * Permissions: 'identity' * @since Chrome 29. */ namespace identity { @@ -1697,7 +2579,7 @@ declare namespace chrome { /** * Optional. * The account ID whose token should be returned. If not specified, the primary account for the profile will be used. - * account is only supported when the "enable-new-profile-management" flag is set. + * account is only supported when the 'enable-new-profile-management' flag is set. * @since Chrome 37. */ account?: AccountInfo; @@ -1797,14 +2679,14 @@ declare namespace chrome { //////////////////// /** * Use the chrome.idle API to detect when the machine's idle state changes. - * Permissions: "idle" + * Permissions: 'idle' * @since Chrome 6. */ namespace idle { interface IdleStateChangedEvent extends chrome.events.Event<(newState: string) => void> { } /** - * Returns "locked" if the system is locked, "idle" if the user has not generated any input for a specified number of seconds, or "active" otherwise. + * Returns 'locked' if the system is locked, 'idle' if the user has not generated any input for a specified number of seconds, or 'active' otherwise. * @param detectionIntervalInSeconds The system is considered idle if detectionIntervalInSeconds seconds have elapsed since the last user input detected. * Since Chrome 25. * @param callback The callback parameter should be a function that looks like this: @@ -1818,7 +2700,7 @@ declare namespace chrome { */ export function setDetectionInterval(intervalInSeconds: number): void; - /** Fired when the system changes to an active, idle or locked state. The event fires with "locked" if the screen is locked or the screensaver activates, "idle" if the system is unlocked and the user has not generated any input for a specified number of seconds, and "active" when the user generates input on an idle system. */ + /** Fired when the system changes to an active, idle or locked state. The event fires with 'locked' if the screen is locked or the screensaver activates, 'idle' if the system is unlocked and the user has not generated any input for a specified number of seconds, and 'active' when the user generates input on an idle system. */ export var onStateChanged: IdleStateChangedEvent; } @@ -2071,7 +2953,7 @@ declare namespace chrome { //////////////////// /** * Use the chrome.notifications API to create rich notifications using templates and show these notifications to users in the system tray. - * Permissions: "notifications" + * Permissions: 'notifications' * @since Chrome 28. */ namespace notifications { @@ -2307,7 +3189,7 @@ declare namespace chrome { //////////////////// /** * Use the chrome.power API to override the system's power management features. - * Permissions: "power" + * Permissions: 'power' * @since Chrome 27. */ namespace power { @@ -2322,7 +3204,7 @@ declare namespace chrome { //////////////////// /** * The chrome.printerProvider API exposes events used by print manager to query printers controlled by extensions, to query their capabilities and to submit print jobs to these printers. - * Permissions: "printerProvider" + * Permissions: 'printerProvider' * @since Chrome 44. */ namespace printerProvider { @@ -2347,7 +3229,7 @@ declare namespace chrome { title: string; /** Print ticket in CJT format. */ ticket: Object; - /** The document content type. Supported formats are "application/pdf" and "image/pwg-raster". */ + /** The document content type. Supported formats are 'application/pdf' and 'image/pwg-raster'. */ contentType: string; /** Blob containing the document data to print. Format must match |contentType|. */ document: Blob; @@ -2400,7 +3282,7 @@ declare namespace chrome { interface InstalledDetails { /** * The reason that this event is being dispatched. - * One of: "install", "update", "chrome_update", or "shared_module_update" + * One of: 'install', 'update', 'chrome_update', or 'shared_module_update' */ reason: string; /** @@ -2452,17 +3334,17 @@ declare namespace chrome { interface PlatformInfo { /** * The operating system chrome is running on. - * One of: "mac", "win", "android", "cros", "linux", or "openbsd" + * One of: 'mac', 'win', 'android', 'cros', 'linux', or 'openbsd' */ os: string; /** * The machine's processor architecture. - * One of: "arm", "x86-32", or "x86-64" + * One of: 'arm', 'x86-32', or 'x86-64' */ arch: string; /** * The native client architecture. This may be different from arch on some platforms. - * One of: "arm", "x86-32", or "x86-64" + * One of: 'arm', 'x86-32', or 'x86-64' */ nacl_arch: string; } @@ -2629,14 +3511,14 @@ declare namespace chrome { sub_package_path: string; }[]; /** - * Technologies required by the app or extension. Hosting sites such as the Chrome Web Store may use this list to dissuade users from installing apps or extensions that will not work on their computer. Supported requirements currently include "3D" and "plugins"; additional requirements checks may be added in the future. + * Technologies required by the app or extension. Hosting sites such as the Chrome Web Store may use this list to dissuade users from installing apps or extensions that will not work on their computer. Supported requirements currently include '3D' and 'plugins'; additional requirements checks may be added in the future. */ requirements?: { /** - * The "3D" requirement denotes GPU hardware acceleration. The "webgl" requirement refers to the WebGL API. For more information on Chrome 3D graphics support, see the help article on WebGL and 3D graphics. You can list the 3D-related features your app requires, as demonstrated in the following example: - * "requirements": { - * "3D": { - * "features": ["webgl"] + * The '3D' requirement denotes GPU hardware acceleration. The 'webgl' requirement refers to the WebGL API. For more information on Chrome 3D graphics support, see the help article on WebGL and 3D graphics. You can list the 3D-related features your app requires, as demonstrated in the following example: + * 'requirements': { + * '3D': { + * 'features': ['webgl'] * } * } */ @@ -2644,10 +3526,10 @@ declare namespace chrome { features?: Array; }; /** - * The "plugins" requirement indicates if an app or extension requires NPAPI to run. This requirement is enabled by default when the manifest includes the "plugins" field. For apps and extensions that still work when plugins aren't available, you can disable this requirement by setting NPAPI to false. You can also enable this requirement manually, by setting NPAPI to true, as shown in this example: - * "requirements": { - * "plugins": { - * "npapi": true + * The 'plugins' requirement indicates if an app or extension requires NPAPI to run. This requirement is enabled by default when the manifest includes the 'plugins' field. For apps and extensions that still work when plugins aren't available, you can disable this requirement by setting NPAPI to false. You can also enable this requirement manually, by setting NPAPI to true, as shown in this example: + * 'requirements': { + * 'plugins': { + * 'npapi': true * } * } */ @@ -2754,7 +3636,7 @@ declare namespace chrome { * Requests an update check for this app/extension. * @since Chrome 25. * @param callback - * Parameter status: Result of the update check. One of: "throttled", "no_update", or "update_available" + * Parameter status: Result of the update check. One of: 'throttled', 'no_update', or 'update_available' * Optional parameter details: If an update is available, this contains more information about the available update. */ export function requestUpdateCheck(callback: (status: string, details?: UpdateCheckDetails) => void): void; @@ -3029,7 +3911,7 @@ declare namespace chrome { interface SocketProperties { /** * Flag indicating if the socket remains open when the event page of the - * application is unloaded. The default value is "false." When the + * application is unloaded. The default value is 'false.' When the * application is loaded, any sockets previously opened with * persistent=true can be fetched with getSockets. * @@ -3051,7 +3933,7 @@ declare namespace chrome { /** * Flag indicating if the socket remains open when the event page of the * application is unloaded (see SocketProperties.persistent). The - * default value is "false". + * default value is 'false'. */ persistent: boolean; @@ -3061,7 +3943,7 @@ declare namespace chrome { /** * Flag indicating whether connection requests on a listening socket are * dispatched through the onAccept event or queued up in the listen - * queue backlog. See setPaused. The default value is "false" + * queue backlog. See setPaused. The default value is 'false' */ paused: boolean; @@ -3203,7 +4085,7 @@ declare namespace chrome { /** * Use the chrome.sockets.udp API to send and receive data over the network * using UDP connections. This API supersedes the UDP functionality previously - * found in the "socket" API. + * found in the 'socket' API. * * @since Chrome 33 * @see https://developer.chrome.com/apps/sockets_udp @@ -3236,7 +4118,7 @@ declare namespace chrome { interface SocketProperties { /** * Flag indicating if the socket is left open when the event page of the - * application is unloaded. The default value is "false." When the + * application is unloaded. The default value is 'false.' When the * application is loaded, any sockets previously opened with * persistent=true can be fetched with getSockets. * @see http://developer.chrome.com/apps/app_lifecycle.html @@ -3343,9 +4225,9 @@ declare namespace chrome { * @see https://developer.chrome.com/apps/sockets_udp#method-bind * @param socketId The socket ID. * @param address The address of the local machine. DNS name, IPv4 and IPv6 - * formats are supported. Use "0.0.0.0" to accept packets + * formats are supported. Use '0.0.0.0' to accept packets * from all local available network interfaces. - * @param port The port of the local machine. Use "0" to bind to a free + * @param port The port of the local machine. Use '0' to bind to a free * port. * @param callback Called when the bind operation completes. */ @@ -3499,7 +4381,7 @@ declare namespace chrome { //////////////////// /** * Use the chrome.storage API to store, retrieve, and track changes to user data. - * Permissions: "storage" + * Permissions: 'storage' * @since Chrome 20. */ namespace storage { @@ -3526,7 +4408,7 @@ declare namespace chrome { /** * Sets multiple items. * @param items An object which gives each key/value pair to update storage with. Any other key/value pairs in storage will not be affected. - * Primitive values such as numbers will serialize as expected. Values with a typeof "object" and "function" will typically serialize to {}, with the exception of Array (serializes as expected), Date, and Regex (serialize using their String representation). + * Primitive values such as numbers will serialize as expected. Values with a typeof 'object' and 'function' will typically serialize to {}, with the exception of Array (serializes as expected), Date, and Regex (serialize using their String representation). * @param callback Optional. * Callback on success, or on failure (in which case runtime.lastError will be set). */ @@ -3622,7 +4504,7 @@ declare namespace chrome { //////////////////// /** * Use the system.cpu API to query CPU metadata. - * Permissions: "system.cpu" + * Permissions: 'system.cpu' * @since Chrome 32. */ namespace system.cpu { @@ -3651,7 +4533,7 @@ declare namespace chrome { modelName: string; /** * A set of feature codes indicating some of the processor's capabilities. - * The currently supported codes are "mmx", "sse", "sse2", "sse3", "ssse3", "sse4_1", "sse4_2", and "avx". + * The currently supported codes are 'mmx', 'sse', 'sse2', 'sse3', 'ssse3', 'sse4_1', 'sse4_2', and 'avx'. */ features: string[]; /** Information about each logical processor. */ @@ -3667,7 +4549,7 @@ declare namespace chrome { //////////////////// /** * Use the system.display API to query display metadata. - * Permissions: "system.display" + * Permissions: 'system.display' * @since Chrome 30. */ namespace system.display { @@ -3830,7 +4712,7 @@ declare namespace chrome { interface DisplayInfo { /** The unique identifier of the display. */ id: string; - /** The user-friendly name (e.g. "HP LCD monitor"). */ + /** The user-friendly name (e.g. 'HP LCD monitor'). */ name: string; /** Identifier of the display that is being mirrored on the display unit. If mirroring is not in progress, set to an empty string. Currently exposed only on ChromeOS. Will be empty string on other platforms. */ mirroringSourceId: string; @@ -4003,7 +4885,7 @@ declare namespace chrome { //////////////////// /** * The chrome.system.memory API. - * Permissions: "system.memory" + * Permissions: 'system.memory' * @since Chrome 32. */ namespace system.memory { @@ -4036,7 +4918,7 @@ declare namespace chrome { //////////////////// /** * Use the chrome.system.storage API to query storage device information and be notified when a removable storage device is attached and detached. - * Permissions: "system.storage" + * Permissions: 'system.storage' * @since Chrome 30. */ namespace system.storage { @@ -4092,7 +4974,7 @@ declare namespace chrome { //////////////////// /** * Use the chrome.tts API to play synthesized text-to-speech (TTS). See also the related ttsEngine API, which allows an extension to implement a speech engine. - * Permissions: "tts" + * Permissions: 'tts' * @since Chrome 14. */ namespace tts { @@ -4104,7 +4986,7 @@ declare namespace chrome { errorMessage?: string; /** * The type can be 'start' as soon as speech has started, 'word' when a word boundary is reached, 'sentence' when a sentence boundary is reached, 'marker' when an SSML mark element is reached, 'end' when the end of the utterance is reached, 'interrupted' when the utterance is stopped or interrupted before reaching the end, 'cancelled' when it's removed from the queue before ever being synthesized, or 'error' when any other error occurs. When pausing speech, a 'pause' event is fired if a particular utterance is paused in the middle, and 'resume' if an utterance resumes speech. Note that pause and resume events may not fire if speech is paused in-between utterances. - * One of: "start", "end", "word", "sentence", "marker", "interrupted", "cancelled", "error", "pause", or "resume" + * One of: 'start', 'end', 'word', 'sentence', 'marker', 'interrupted', 'cancelled', 'error', 'pause', or 'resume' */ type: string; } @@ -4115,7 +4997,7 @@ declare namespace chrome { lang?: string; /** * Optional. This voice's gender. - * One of: "male", or "female" + * One of: 'male', or 'female' */ gender?: string; /** Optional. The name of the voice. */ @@ -4162,7 +5044,7 @@ declare namespace chrome { extensionId?: string; /** * Optional. Gender of voice for synthesized speech. - * One of: "male", or "female" + * One of: 'male', or 'female' */ gender?: string; /** Optional. The TTS event types the voice must support. */ @@ -4412,7 +5294,7 @@ declare namespace chrome { //////////////////// /** * Use the chrome.vpnProvider API to implement a VPN client. - * Permissions: "vpnProvider" + * Permissions: 'vpnProvider' * Important: This API works only on Chrome OS. * @since Chrome 43. */ @@ -4429,7 +5311,7 @@ declare namespace chrome { */ exclusionList: string[]; /** - * Include network traffic to the list of IP blocks in CIDR notation to the tunnel. This parameter can be used to set up a split tunnel. By default no traffic is directed to the tunnel. Adding the entry "0.0.0.0/0" to this list gets all the user traffic redirected to the tunnel. When many rules match a destination, the rule with the longest matching prefix wins. Entries that correspond to the same CIDR block are treated as duplicates. Such duplicates in the collated (exclusionList + inclusionList) list are eliminated and the exact duplicate entry that will be eliminated is undefined. + * Include network traffic to the list of IP blocks in CIDR notation to the tunnel. This parameter can be used to set up a split tunnel. By default no traffic is directed to the tunnel. Adding the entry '0.0.0.0/0' to this list gets all the user traffic redirected to the tunnel. When many rules match a destination, the rule with the longest matching prefix wins. Entries that correspond to the same CIDR block are treated as duplicates. Such duplicates in the collated (exclusionList + inclusionList) list are eliminated and the exact duplicate entry that will be eliminated is undefined. */ inclusionList: string[]; /** Optional. A list of search domains. (default: no search domain) */ @@ -4462,7 +5344,7 @@ declare namespace chrome { */ export function destroyConfig(id: string, callback?: Function): void; /** - * Sets the parameters for the VPN session. This should be called immediately after "connected" is received from the platform. This will succeed only when the VPN session is owned by the extension. + * Sets the parameters for the VPN session. This should be called immediately after 'connected' is received from the platform. This will succeed only when the VPN session is owned by the extension. * @param parameters The parameters for the VPN session. * @param callback Called when the parameters are set or if there is an error. */ @@ -4499,7 +5381,7 @@ declare namespace chrome { //////////////////// /** * Use the chrome.wallpaper API to change the ChromeOS wallpaper. - * Permissions: "wallpaper" + * Permissions: 'wallpaper' * Important: This API works only on Chrome OS. * @since Chrome 43. */ @@ -4511,7 +5393,7 @@ declare namespace chrome { url?: string; /** * The supported wallpaper layouts. - * One of: "STRETCH", "CENTER", or "CENTER_CROPPED" + * One of: 'STRETCH', 'CENTER', or 'CENTER_CROPPED' */ layout: string; /** The file name of the saved wallpaper. */ @@ -4533,7 +5415,7 @@ declare namespace chrome { // Webview Tag /////////////////// /** - * Use the webview tag to actively load live content from the web over the network and embed it in your Chrome App. Your app can control the appearance of the webview and interact with the web content, initiate navigations in an embedded web page, react to error events that happen within it, and more (see Usage). + * Use the webview tag to actively load live content from the web over the network and embed it in your Chrome App. Your app can control the appearance of the webview and interact with the web content, initiate navigations in an embedded web page, react to error events that happen within it, and more (see Usage). */ namespace webview { /** Options that determine what data should be cleared by `clearData`. */ @@ -4611,7 +5493,7 @@ declare namespace chrome { */ interface InjectDetails { /** - * @description JavaScript or CSS code to inject.

Warning:
Be careful using the code parameter. Incorrect use of it may open your app to cross site scripting attacks. + * @description JavaScript or CSS code to inject.

Warning:
Be careful using the code parameter. Incorrect use of it may open your app to cross site scripting attacks. * @type {string} * @memberof InjectDetails */ @@ -4624,38 +5506,501 @@ declare namespace chrome { file?: string } - interface WebViewElementEventMap { - 'close': Event, - 'consolemessage': IConsolemessage, - 'contentload': Event, - 'dialog': IDialog, - 'exit': IExit, - 'findupdate': IFindupdate, - 'loadabort': ILoadabort, - 'loadcommit': ILoadcommit, - 'loadredirect': ILoadredirect, - 'loadstart': ILoadstart, - 'loadstop': Event, - 'newwindow': INewwindow, - 'permissionrequest': IPermissionrequest, - 'responsive': IResponsive, - 'sizechanged': ISizechanged, - 'unresponsive': IUnresponsive, - 'zoomchange': IZoomchange, - } - - /** - * @description - * @export - * @interface HTMLWebViewElement - * @extends {Element} + * @description WebView element from html */ interface HTMLWebViewElement extends Element { - executeScript?: (details: InjectDetails, callback?: (result: any) => void) => void; + /** + * This sets the guest content's window.name object. + */ + name: string; + /** + * Returns the visible URL. Mirrors the logic in the browser's omnibox: either returning a pending new navigation if initiated by the embedder page, or the last committed navigation. Writing to this attribute initiates top-level navigation. + * Assigning src its own value will reload the current page. + * The src attribute cannot be cleared or removed once it has been set, unless the webview is removed from the DOM. + * The src attribute can also accept data URLs, such as 'data:text/plain,Hello, world!'. + */ src: string; - contentWindow: Window; - addEventListener(type: K, listener: (this: HTMLWebViewElement, ev: WebViewElementEventMap[K]) => any, useCapture?: boolean): void; + /** + * Storage partition ID used by the webview tag. If the storage partition ID starts with persist: (partition='persist:googlepluswidgets'), the webview will use a persistent storage partition available to all guests in the app with the same storage partition ID. If the ID is unset or if there is no 'persist': prefix, the webview will use an in-memory storage partition. This value can only be modified before the first navigation, since the storage partition of an active renderer process cannot change. Subsequent attempts to modify the value will fail with a DOM exception. By assigning the same partition ID, multiple webviews can share the same storage partition. + */ + partition?: string; + /** + * If present, portions of the embedder could be visible through the webview, where the contents are transparent. Without allowtransparency enabled, no part of the embedder will be shown through the webview, even if elements exist that are specified as transparent. + * This does not affect transparency within the contents of the webview itself. + */ + allowtransparency?: boolean; + /** + * If 'on', the webview container will automatically resize within the bounds specified by the attributes minwidth, minheight, maxwidth, and maxheight. + * These constraints do not impact the webview UNLESS autosize is enabled. + * When autosize is enabled, the webview container size cannot be less than the minimum values or greater than the maximum. + */ + autosize?: 'on'; + /** + * Object reference which can be used to post messages into the guest page. + */ + contentWindow: ContentWindow; + /** Interface which provides access to webRequest events on the guest page. */ + request: WebRequestEventInterface; + /** Similar to chrome's ContextMenus API, but applies to webview instead of browser. Use the webview.contextMenus API to add items to webview's context menu. You can choose what types of objects your context menu additions apply to, such as images, hyperlinks, and pages. */ + contextMenus: webview.ContextMenus; + /** + * Fired when the guest window attempts to close itself. + * The following example code navigates the webview to about:blank when the guest attempts to close itself. + */ + addEventListener(type: 'close', listener: (this: HTMLWebViewElement) => void, useCapture?: boolean): void; + /** + * Fired when the guest window logs a console message. + * The following example code forwards all log messages to the embedder's console without regard for log level or other properties. + */ + addEventListener(type: 'consolemessage', listener: (this: HTMLWebViewElement, ev: IConsoleMessage) => void, useCapture?: boolean): void; + /** + * Fired when the guest window fires a load event, i.e., when a new document is loaded. This does not include page navigation within the current document or asynchronous resource loads. + * The following example code modifies the default font size of the guest's body element after the page loads: + * @example + * webview.addEventListener('contentload', function() { + * webview.executeScript({ code: 'document.body.style.fontSize = '42px'' }) + * }); + */ + addEventListener(type: 'contentload', listener: (this: HTMLWebViewElement) => void, useCapture?: boolean): void; + /** + * Fired when the guest window attempts to open a modal dialog via window.alert, window.confirm, or window.prompt. + * Handling this event will block the guest process until each event listener returns or the dialog object becomes unreachable (if preventDefault() was called.) + * The default behavior is to cancel the dialog. + */ + addEventListener(type: 'dialog', listener: (this: HTMLWebViewElement, ev: IDialog) => void, useCapture?: boolean): void; + /** + * Fired when the process rendering the guest web content has exited. + */ + addEventListener(type: 'exit', listener: (this: HTMLWebViewElement, ev: IExit) => void, useCapture?: boolean): void; + /** + * Fired when new find results are available for an active find request. This might happen multiple times for a single find request as matches are found. + */ + addEventListener(type: 'findupdate', listener: (this: HTMLWebViewElement, ev: IFindupdate) => void, useCapture?: boolean): void; + /** + * Fired when a top-level load has aborted without committing. An error message will be printed to the console unless the event is default-prevented. + * Note: When a resource load is aborted, a loadabort event will eventually be followed by a loadstop event, even if all committed loads since the last loadstop event (if any) were aborted. + * Note: When the load of either an about URL or a JavaScript URL is aborted, loadabort will be fired and then the webview will be navigated to 'about:blank'. + */ + addEventListener(type: 'loadabort', listener: (this: HTMLWebViewElement, ev: ILoadabort) => void, useCapture?: boolean): void; + /** + * Fired when a load has committed. This includes navigation within the current document as well as subframe document-level loads, but does not include asynchronous resource loads. + */ + addEventListener(type: 'loadcommit', listener: (this: HTMLWebViewElement, ev: ILoadcommit) => void, useCapture?: boolean): void; + /** + * Fired when a top-level load request has redirected to a different URL. + */ + addEventListener(type: 'loadredirect', listener: (this: HTMLWebViewElement, ev: ILoadredirect) => void, useCapture?: boolean): void; + /** + * Fired when a load has begun. + */ + addEventListener(type: 'loadstart', listener: (this: HTMLWebViewElement, ev: ILoadstart) => void, useCapture?: boolean): void; + /** + * Fired when all frame-level loads in a guest page (including all its subframes) have completed. + * This includes navigation within the current document as well as subframe document-level loads, but does not include asynchronous resource loads. + * This event fires every time the number of document-level loads transitions from one (or more) to zero. For example, if a page that has already finished loading (i.e., loadstop already fired once) creates a new iframe which loads a page, then a second loadstop will fire when the iframe page load completes. + * This pattern is commonly observed on pages that load ads. + * Note: When a committed load is aborted, a loadstop event will eventually follow a loadabort event, even if all committed loads since the last loadstop event (if any) were aborted. + */ + addEventListener(type: 'loadstop', listener: (this: HTMLWebViewElement) => void, useCapture?: boolean): void; + /** + * Fired when the guest page attempts to open a new browser window. + * The following example code will create and navigate a new webview in the embedder for each requested new window: + * @example + * webview.addEventListener('newwindow', function(e) { + * var newWebview = document.createElement('webview'); + * document.body.appendChild(newWebview); + * e.window.attach(newWebview); + * }); + */ + addEventListener(type: 'newwindow', listener: (this: HTMLWebViewElement, ev: INewwindow) => void, useCapture?: boolean): void; + /** + * Fired when the guest page needs to request special permission from the embedder. + * The following example code will grant the guest page access to the webkitGetUserMedia API. + * Note that an app using this example code must itself specify audioCapture and/or videoCapture manifest permissions: + * @example + * webview.addEventListener('permissionrequest', function(e) { + * if (e.permission === 'media') { + * e.request.allow(); + * } + * }); + */ + addEventListener(type: 'permissionrequest', listener: (this: HTMLWebViewElement, ev: IPermissionrequest) => void, useCapture?: boolean): void; + /** Fired when the process rendering the guest web content has become responsive again after being unresponsive. */ + addEventListener(type: 'response', listener: (this: HTMLWebViewElement, ev: IResponsive) => void, useCapture?: boolean): void; + /** Fired when the embedded web content has been resized via autosize. Only fires if autosize is enabled. */ + addEventListener(type: 'sizechanged', listener: (this: HTMLWebViewElement, ev: ISizechanged) => void, useCapture?: boolean): void; + /** Fired when the process rendering the guest web content has become unresponsive. This event will be generated once with a matching responsive event if the guest begins to respond again. */ + addEventListener(type: 'unresponsive', listener: (this: HTMLWebViewElement, ev: IUnresponsive) => void, useCapture?: boolean): void; + /** Fired when the page's zoom changes. */ + addEventListener(type: 'zoomchange', listener: (this: HTMLWebViewElement, ev: IZoomchange) => void, useCapture?: boolean): void; + /** + * @description Queries audio state. + */ + getAudioState(callback: (audible: boolean) => void): void; + + /** + * @description Sets audio mute state of the webview. + * @param {boolean} mute Mute audio value + */ + setAudioMuted(mute: boolean): void; + + /** + * @description Queries whether audio is muted. + */ + isAudioMuted(callback: (muted: boolean) => void): void; + + /** + * @description Captures the visible region of the webview. + * @param {(dataUrl: string) => void} callback A data URL which encodes an image of the visible area of the captured tab. May be assigned to the 'src' property of an HTML Image element for display. + */ + captureVisibleRegion(callback: (dataUrl: string) => void): void; + /** + * @description Captures the visible region of the webview. + * @param {*} options + * @param {(dataUrl: string) => void} callback + */ + captureVisibleRegion(options: chrome.extensionTypes.ImageDetails, callback: (dataUrl: string) => void): void; + + /** + * Adds content script injection rules to the webview. + * When the webview navigates to a page matching one or more rules, the associated scripts will be injected. + * You can programmatically add rules or update existing rules. + * The following example adds two rules to the webview: 'myRule' and 'anotherRule'. + * webview.addContentScripts([ + * { + * name: 'myRule', + * matches: ['http://www.foo.com/*'], + * css: { files: ['mystyles.css'] }, + * js: { files: ['jquery.js', 'myscript.js'] }, + * run_at: 'document_start' + * }, + * { + * name: 'anotherRule', + * matches: ['http://www.bar.com/*'], + * js: { code: 'document.body.style.backgroundColor = 'red';' }, + * run_at: 'document_end' + * }]); + * ... + * + * // Navigates webview. + * webview.src = 'http://www.foo.com'; + * You can defer addContentScripts call until you needs to inject scripts. + * The following example shows how to overwrite an existing rule. + * + * webview.addContentScripts([{ + * name: 'rule', + * matches: ['http://www.foo.com/*'], + * js: { files: ['scriptA.js'] }, + * run_at: 'document_start'}]); + * + * // Do something. + * webview.src = 'http://www.foo.com/*'; + * ... + * // Overwrite 'rule' defined before. + * webview.addContentScripts([{ + * name: 'rule', + * matches: ['http://www.bar.com/*'], + * js: { files: ['scriptB.js'] }, + * run_at: 'document_end'}]); + * If webview has been naviagted to the origin (e.g., foo.com) and calls webview.addContentScripts to add 'myRule', + * you need to wait for next navigation to make the scripts injected. + * If you want immediate injection, executeScript will do the right thing. + * Rules are preserved even if the guest process crashes or is killed or even if the webview is reparented. + * Refer to the /extensions/content_scripts documentation for more details. + * @param {ContentScriptDetails[]} contentScriptList Details of the content scripts to add. + */ + addContentScripts(contentScriptList: ContentScriptDetails[]): void; + + /** + * @description Navigates backward one history entry if possible. Equivalent to go(-1). + * @param {(success: boolean) => void} [callback] Called after the navigation has either failed or completed successfully. Success parameter indicates whether the navigation was successful. + */ + back(callback?: (success: boolean) => void): void; + + /** + * @description Indicates whether or not it is possible to navigate backward through history. The state of this function is cached, and updated before each loadcommit, so the best place to call it is on loadcommit. + */ + canGoBack(): void; + + /** + * @description Indicates whether or not it is possible to navigate forward through history. The state of this function is cached, and updated before each loadcommit, so the best place to call it is on loadcommit. + */ + canGoForward(): void; + + /** + * @description

Clears browsing data for the webview partition.

+ * @param options Options determining which data to clear. + * @param types The types of data to be cleared. + * @param callback + */ + clearData(options: ClearDataOptions, types: ClearDataTypeSet, callback?: () => void): void; + + /** + * @description

Injects JavaScript code into the guest page.

The following sample code uses script injection to set the guest page's background color to red:

webview.executeScript({ code: 'document.body.style.backgroundColor = 'red'' });
+ * @param details Details of the script to run. + * @param callback + */ + executeScript(details: InjectDetails, callback?: (result?: any[]) => void): void; + + /** + * @description Initiates a find-in-page request. + * @param {string} searchText The string to find in the page. + * @param options Options for the find request. + * @param callback + */ + find(searchText: string, options?: FindOptions, callback?: (results?: any) => void): void; + + /** + * @description Navigates forward one history entry if possible. Equivalent to go(1). + * @param callback + */ + forward(callback?: (success: boolean) => void): void; + + /** + * @description Returns Chrome's internal process ID for the guest web page's current process, allowing embedders to know how many guests would be affected by terminating the process. Two guests will share a process only if they belong to the same app and have the same storage partition ID. The call is synchronous and returns the embedder's cached notion of the current process ID. The process ID isn't the same as the operating system's process ID. + */ + getProcessId(): void; + + /** + * @description Returns the user agent string used by the webview for guest page requests. + */ + getUserAgent(): void; + + /** + * @description Gets the current zoom factor. + * @param callback + */ + getZoom(callback: (zoomFactor: number) => void): void; + + /** + * @description Gets the current zoom mode. + * @param callback + */ + getZoomMode(callback: (ZoomMode: any) => void): void; + + /** + * @description Navigates to a history entry using a history index relative to the current navigation. If the requested navigation is impossible, this method has no effect. + * @param {number} relativeIndex Relative history index to which the webview should be navigated. For example, a value of 2 will navigate forward 2 history entries if possible; a value of -3 will navigate backward 3 entries. + * @param callback + */ + go(relativeIndex: number, callback?: (success: boolean) => void): void; + + /** + * @description Injects CSS into the guest page. + * @param details Details of the CSS to insert. + * @param callback + */ + insertCSS(details: InjectDetails, callback?: () => void): void; + + /** + * @description Indicates whether or not the webview's user agent string has been overridden by $(ref:webviewTag.setUserAgentOverride). + */ + isUserAgentOverridden(): void; + + /** + * @description Prints the contents of the webview. This is equivalent to calling scripted print function from the webview itself. + */ + print(): void; + + /** + * @description Reloads the current top-level page. + */ + reload(): void; + + /** + * @description Removes content scripts from a webview. + * @description The following example removes 'myRule' which was added before. + * @example webview.removeContentScripts(['myRule']); + * @description You can remove all the rules by calling: + * @example webview.removeContentScripts(); + * @param {any[]} scriptNameList A list of names of content scripts that will be removed. If the list is empty, all the content scripts added to the webview will be removed. + */ + removeContentScripts(scriptNameList?: any[]): void; + + /** + * @description Override the user agent string used by the webview for guest page requests. + * @param {string} userAgent The user agent string to use. + */ + setUserAgentOverride(userAgent: string): void; + + /** + * @description Changes the zoom factor of the page. The scope and persistence of this change are determined by the webview's current zoom mode (see $(ref:webviewTag.ZoomMode)). + * @param {number} zoomFactor The new zoom factor. + * @param callback + */ + setZoom(zoomFactor: number, callback?: () => void): void; + + /** + * @description Sets the zoom mode of the webview. + * @param ZoomMode Defines how zooming is handled in the webview. + * @param callback + */ + setZoomMode(ZoomMode: ZoomMode, callback?: () => void): void; + + /** + * @description Stops loading the current webview navigation if in progress. + */ + stop(): void; + + /** + * @description Ends the current find session (clearing all highlighting) and cancels all find requests in progress. + * @param {string} action Determines what to do with the active match after the find session has ended. clear will clear the highlighting over the active match; keep will keep the active match highlighted; activate will keep the active match highlighted and simulate a user click on that match. The default action is keep. + */ + stopFinding(action?: string): void; + + /** + * @description Loads a data URL with a specified base URL used for relative links. Optionally, a virtual URL can be provided to be shown to the user instead of the data URL. + * @param {string} dataUrl The data URL to load. + * @param {string} baseUrl The base URL that will be used for relative links. + * @param {string} virtualUrl The URL that will be displayed to the user (in the address bar). + */ + loadDataWithBaseUrl(dataUrl: string, baseUrl: string, virtualUrl?: string): void; + + /** + * @description Forcibly kills the guest web page's renderer process. This may affect multiple webview tags in the current app if they share the same process, but it will not affect webview tags in other apps. + */ + terminate(): void; + + /** + * @description Fired when the guest window attempts to close itself.

The following example code navigates the webview to about:blank when the guest attempts to close itself.

webview.addEventListener('close', function() {
+              webview.src = 'about:blank';
+            });
+ */ + + close(event: chrome.events.Event): void; + + /** + * @description Fired when the guest window logs a console message.

The following example code forwards all log messages to the embedder's console without regard for log level or other properties.

webview.addEventListener('consolemessage', function(e) {
+              console.log('Guest page logged a message: ', e.message);
+            });
+ * @param callback + */ + + consolemessage: chrome.events.Event; + + /** + * @description Fired when the guest window fires a load event, i.e., when a new document is loaded. This does not include page navigation within the current document or asynchronous resource loads.

The following example code modifies the default font size of the guest's body element after the page loads:

webview.addEventListener('contentload', function() {
+              webview.executeScript({ code: 'document.body.style.fontSize = '42px'' });
+            });
+ */ + + contentload: (event: chrome.events.Event) => void; + + /** + * @description Fired when the guest window attempts to open a modal dialog via window.alert, window.confirm, or window.prompt.

Handling this event will block the guest process until each event listener returns or the dialog object becomes unreachable (if preventDefault() was called.)

The default behavior is to cancel the dialog.

+ * @param callback + */ + + dialog: chrome.events.Event; + + /** + * @description Fired when the process rendering the guest web content has exited.

The following example code will show a farewell message whenever the guest page crashes:

webview.addEventListener('exit', function(e) {
+              if (e.reason === 'crash') {
+                webview.src = 'data:text/plain,Goodbye, world!';
+              }
+            });
+ * @param callback + */ + + exit: chrome.events.Event; + + /** + * @description Fired when new find results are available for an active find request. This might happen multiple times for a single find request as matches are found. + * @param callback + */ + + findupdate: chrome.events.Event; + + /** + * @description Fired when a top-level load has aborted without committing. An error message will be printed to the console unless the event is default-prevented.

Note: When a resource load is aborted, a loadabort event will eventually be followed by a loadstop event, even if all committed loads since the last loadstop event (if any) were aborted.

Note: When the load of either an about URL or a JavaScript URL is aborted, loadabort will be fired and then the webview will be navigated to 'about:blank'.

+ * @param callback + */ + + loadabort: chrome.events.Event; + + /** + * @description Fired when a load has committed. This includes navigation within the current document as well as subframe document-level loads, but does not include asynchronous resource loads. + * @param callback + */ + + loadcommit: chrome.events.Event; + + /** + * @description Fired when a top-level load request has redirected to a different URL. + * @param callback + */ + + loadredirect: chrome.events.Event; + + /** + * @description Fired when a load has begun. + * @param callback + */ + + loadstart: chrome.events.Event; + + /** + * @description Fired when all frame-level loads in a guest page (including all its subframes) have completed. This includes navigation within the current document as well as subframe document-level loads, but does not include asynchronous resource loads. This event fires every time the number of document-level loads transitions from one (or more) to zero. For example, if a page that has already finished loading (i.e., loadstop already fired once) creates a new iframe which loads a page, then a second loadstop will fire when the iframe page load completes. This pattern is commonly observed on pages that load ads.

Note: When a committed load is aborted, a loadstop event will eventually follow a loadabort event, even if all committed loads since the last loadstop event (if any) were aborted.

+ */ + + loadstop(event: chrome.events.Event): void; + + /** + * @description Fired when the guest page attempts to open a new browser window.

The following example code will create and navigate a new webview in the embedder for each requested new window:

webview.addEventListener('newwindow', function(e) {
+              var newWebview = document.createElement('webview');
+              document.body.appendChild(newWebview);
+              e.window.attach(newWebview);
+            });
+ * @param callback + */ + + newwindow: chrome.events.Event; + + /** + * @description Fired when the guest page needs to request special permission from the embedder.

The following example code will grant the guest page access to the webkitGetUserMedia API. Note that an app using this example code must itself specify audioCapture and/or videoCapture manifest permissions:

webview.addEventListener('permissionrequest', function(e) {
+              if (e.permission === 'media') {
+                e.request.allow();
+              }
+            });
+ * @param callback + */ + + permissionrequest: chrome.events.Event; + + /** + * @description Fired when the process rendering the guest web content has become responsive again after being unresponsive.

The following example code will fade the webview element in or out as it becomes responsive or unresponsive:

webview.style.webkitTransition = 'opacity 250ms';
+            webview.addEventListener('unresponsive', function() {
+              webview.style.opacity = '0.5';
+            });
+            webview.addEventListener('responsive', function() {
+              webview.style.opacity = '1';
+            });
+ * @param callback + */ + + responsive: chrome.events.Event; + + /** + * @description Fired when the embedded web content has been resized via autosize. Only fires if autosize is enabled. + * @param callback + */ + + sizechanged: chrome.events.Event; + + /** + * @description Fired when the process rendering the guest web content has become unresponsive. This event will be generated once with a matching responsive event if the guest begins to respond again. + * @param callback + */ + + unresponsive: chrome.events.Event; + + /** + * @description Fired when the page's zoom changes. + * @param callback + */ + + zoomchange: chrome.events.Event; } /**Options that determine what data should be cleared by clearData. */ @@ -4717,21 +6062,21 @@ declare namespace chrome { /** * The different contexts a menu can appear in. Specifying 'all' is equivalent to the combination of all other contexts. * Enum values: - * "all" - * "page" - * "frame" - * "selection" - * "link" - * "editable" - * "image" - * "video" - * "audio" */ - export type ContextType = "all" | "page" | "frame" | "selection" | "link" | "editable" | "image" | "video" | "audio"; + * 'all' + * 'page' + * 'frame' + * 'selection' + * 'link' + * 'editable' + * 'image' + * 'video' + * 'audio' */ + export type ContextType = 'all' | 'page' | 'frame' | 'selection' | 'link' | 'editable' | 'image' | 'video' | 'audio'; /**Details of the script or CSS to inject. Either the code or the file property must be set, but both may not be set at the same time. */ interface InjectDetails { /** - * @description JavaScript or CSS code to inject. Warning: Be careful using the code parameter. Incorrect use of it may open your app to cross site scripting attacks. + * @description JavaScript or CSS code to inject. Warning: Be careful using the code parameter. Incorrect use of it may open your app to cross site scripting attacks. */ code?: string @@ -4787,7 +6132,7 @@ declare namespace chrome { js?: InjectionItems /** - * @description The soonest that the JavaScript or CSS will be injected into the tab. Defaults to "document_idle". + * @description The soonest that the JavaScript or CSS will be injected into the tab. Defaults to 'document_idle'. */ run_at?: chrome.extensionTypes.RunAt; @@ -4820,7 +6165,7 @@ declare namespace chrome { id?: string /** - * @description The text to be displayed in the item; this is required unless type is 'separator'. When the context is 'selection', you can use %s within the string to show the selected text. For example, if this parameter's value is "Translate '%s' to Pig Latin" and the user selects the word "cool", the context menu item for the selection is "Translate 'cool' to Pig Latin". + * @description The text to be displayed in the item; this is required unless type is 'separator'. When the context is 'selection', you can use %s within the string to show the selected text. For example, if this parameter's value is 'Translate '%s' to Pig Latin' and the user selects the word 'cool', the context menu item for the selection is 'Translate 'cool' to Pig Latin'. */ title?: string @@ -4836,7 +6181,7 @@ declare namespace chrome { /** * @description A function that will be called back when the menu item is clicked. - * @param {any} [object Object] + * @param callback */ onclick?: (info: any) => void @@ -4885,7 +6230,7 @@ declare namespace chrome { /** * @description A function that will be called back when the menu item is clicked. - * @param {any} [object Object] + * @param callback */ onclick?: (info: any) => void @@ -4914,28 +6259,28 @@ declare namespace chrome { /** * @description Creates a new context menu item. Note that if an error occurs during creation, you may not find out until the creation callback fires (the details will be in chrome.runtime.lastError). * @param {object} createProperties The properties used to create the item - * @param {any} [object Object] + * @param callback */ create(createProperties: object, callback?: () => void): void; /** * @description Updates a previously created context menu item. - * @param {any} id The ID of the item to update. + * @param id The ID of the item to update. * @param {object} updateProperties The properties to update. Accepts the same values as the create function. - * @param {any} [object Object] + * @param callback */ update(id: number | string, updateProperties: object, callback?: () => void): void; /** * @description Removes a context menu item. - * @param {any} menuItemId The ID of the context menu item to remove. - * @param {any} [object Object] + * @param menuItemId The ID of the context menu item to remove. + * @param callback */ remove(menuItemId: number | string, callback?: () => void): void; /** * @description Removes all context menu items added to this webview. - * @param {any} [object Object] + * @param callback */ removeAll(callback?: () => void): void; @@ -4956,8 +6301,8 @@ declare namespace chrome { interface ContentWindow { /** - * @description

Posts a message to the embedded web content as long as the embedded content is displaying a page from the target origin. This method is available once the page has completed loading. Listen for the contentload event and then call the method.

The guest will be able to send replies to the embedder by posting message to event.source on the message event it receives.

This API is identical to the HTML5 postMessage API for communication between web pages. The embedder may listen for replies by adding a message event listener to its own frame.

- * @param {any} message Message object to send to the guest. + * @description

Posts a message to the embedded web content as long as the embedded content is displaying a page from the target origin. This method is available once the page has completed loading. Listen for the contentload event and then call the method.

The guest will be able to send replies to the embedder by posting message to event.source on the message event it receives.

This API is identical to the HTML5 postMessage API for communication between web pages. The embedder may listen for replies by adding a message event listener to its own frame.

+ * @param message Message object to send to the guest. * @param {string} targetOrigin Specifies what the origin of the guest window must be for the event to be dispatched. */ postMessage(message: any, targetOrigin: string): void; @@ -5118,7 +6463,11 @@ declare namespace chrome { deny(): void; } - /**

Describes a rectangle in screen coordinates.

The containment semantics are array-like; that is, the coordinate (left, top) is considered to be contained by the rectangle, but the coordinate (left + width, top) is not.

*/ + /** + * Fescribes a rectangle in screen coordinates. + * The containment semantics are array-like; that is, the coordinate (left, top) is considered to be contained by the rectangle, + * but the coordinate (left + width, top) is not. + **/ interface SelectionRect { /** @@ -5141,388 +6490,39 @@ declare namespace chrome { */ height: number } - /**Interface which provides access to webRequest events on the guest page. See the chrome.webRequest extensions API for details on webRequest life cycle and related concepts.

To illustrate how usage differs from the extensions webRequest API, consider the following example code which blocks any guest requests for URLs which match *://www.evil.com/*:

webview.request.onBeforeRequest.addListener(
-          function(details) { return {cancel: true}; },
-          {urls: ["*://www.evil.com/*"]},
-          ["blocking"]);

Additionally, this interface supports declarative webRequest rules through onRequest and onMessage events. See declarativeWebRequest for API details.

Note that conditions and actions for declarative webview webRequests should be instantiated from their chrome.webViewRequest.* counterparts. The following example code declaratively blocks all requests to "example.com" on the webview myWebview:

var rule = {
-          conditions: [
-            new chrome.webViewRequest.RequestMatcher({ url: { hostSuffix: 'example.com' } })
-          ],
-          actions: [ new chrome.webViewRequest.CancelRequest() ]
-        };
-        myWebview.request.onRequest.addRules([rule]);
*/ + /** + * @description Interface which provides access to webRequest events on the guest page. See the chrome.webRequest extensions API for details on webRequest life cycle and related concepts.

To illustrate how usage differs from the extensions webRequest API, consider the following example code which blocks any guest requests for URLs which match *://www.evil.com/*:

webview.request.onBeforeRequest.addListener(
+         * @example function(details) { return {cancel: true}; }, {urls: ['*://www.evil.com/*']}, ['blocking']);
+         * @description Additionally, this interface supports declarative webRequest rules through onRequest and onMessage events.
+         * @see http://developer.chrome.com/extensions/declarativeWebRequest.htmldeclarativeWebRequest
+         * @description Note that conditions and actions for declarative webview webRequests should be instantiated from their chrome.webViewRequest.* counterparts. The following example code declaratively blocks all requests to 'example.com' on the webview myWebview:
+         * @example var rule = { conditions: [ new chrome.webViewRequest.RequestMatcher({ url: { hostSuffix: 'example.com' } }) ], actions: [ new chrome.webViewRequest.CancelRequest() ] }; myWebview.request.onRequest.addRules([rule]);
+         **/
         interface WebRequestEventInterface {
         }
         /**
         * Defines the how zooming is handled in the webview.
         * Enum values:
-        * "per-origin"
+        * 'per-origin'
         * * Zoom changes will persist in the zoomed page's origin, i.e. all other webviews in the same partition that are navigated to that same origin will be zoomed as well. Moreover, per-origin zoom changes are saved with the origin, meaning that when navigating to other pages in the same origin, they will all be zoomed to the same zoom factor.
-        * "per-view"
+        * 'per-view'
         * * Zoom changes only take effect in this webview, and zoom changes in other webviews will not affect the zooming of this webview. Also, per-view zoom changes are reset on navigation; navigating a webview will always load pages with their per-origin zoom factors (within the scope of the partition).
-        * "disabled"
+        * 'disabled'
         * * Disables all zooming in the webview. The content will revert to the default zoom level, and all attempted zoom changes will be ignored. */
-        export type ZoomMode = "per-origin" | "per-view" | "disabled";
-
-        /**
-        * @description Queries audio state.
-        * @param {any} [object Object]
-         */
-        export function getAudioState(callback: (audible: boolean) => void): void;
-
-        /**
-        * @description Sets audio mute state of the webview.
-        * @param {boolean} mute Mute audio value
-         */
-        export function setAudioMuted(mute: boolean): void;
-
-        /**
-        * @description Queries whether audio is muted.
-        * @param {any} [object Object]
-         */
-        export function isAudioMuted(callback: (muted: boolean) => void): void;
-
-        /**
-         * @description Captures the visible region of the webview.
-         * @param {(dataUrl: string) => void} callback A data URL which encodes an image of the visible area of the captured tab. May be assigned to the 'src' property of an HTML Image element for display.
-         */
-        export function captureVisibleRegion(callback: (dataUrl: string) => void): void;
-        /**
-         * @description Captures the visible region of the webview.
-         * @param {*} options
-         * @param {(dataUrl: string) => void} callback
-         */
-        export function captureVisibleRegion(options: chrome.extensionTypes.ImageDetails, callback: (dataUrl: string) => void): void;
-
-        /**
-        * @description 

Adds content script injection rules to the webview. When the webview navigates to a page matching one or more rules, the associated scripts will be injected. You can programmatically add rules or update existing rules.

The following example adds two rules to the webview: 'myRule' and 'anotherRule'.

webview.addContentScripts([
-          {
-            name: 'myRule',
-            matches: ['http://www.foo.com/*'],
-            css: { files: ['mystyles.css'] },
-            js: { files: ['jquery.js', 'myscript.js'] },
-            run_at: 'document_start'
-          },
-          {
-            name: 'anotherRule',
-            matches: ['http://www.bar.com/*'],
-            js: { code: "document.body.style.backgroundColor = 'red';" },
-            run_at: 'document_end'
-          }]);
-         ...
-
-        // Navigates webview.
-        webview.src = 'http://www.foo.com';

You can defer addContentScripts call until you needs to inject scripts.

The following example shows how to overwrite an existing rule.

webview.addContentScripts([{
-            name: 'rule',
-            matches: ['http://www.foo.com/*'],
-            js: { files: ['scriptA.js'] },
-            run_at: 'document_start'}]);
-
-        // Do something.
-        webview.src = 'http://www.foo.com/*';
-         ...
-        // Overwrite 'rule' defined before.
-        webview.addContentScripts([{
-            name: 'rule',
-            matches: ['http://www.bar.com/*'],
-            js: { files: ['scriptB.js'] },
-            run_at: 'document_end'}]);

If webview has been naviagted to the origin (e.g., foo.com) and calls webview.addContentScripts to add 'myRule', you need to wait for next navigation to make the scripts injected. If you want immediate injection, executeScript will do the right thing.

Rules are preserved even if the guest process crashes or is killed or even if the webview is reparented.

Refer to the content scripts documentation for more details.

- * @param {ContentScriptDetails[]} contentScriptList Details of the content scripts to add. - */ - export function addContentScripts(contentScriptList: ContentScriptDetails[]): void; - - /** - * @description Navigates backward one history entry if possible. Equivalent to go(-1). - * @param {(success: boolean) => void} [callback] Called after the navigation has either failed or completed successfully. Success parameter indicates whether the navigation was successful. - */ - export function back(callback?: (success: boolean) => void): void; - - /** - * @description Indicates whether or not it is possible to navigate backward through history. The state of this function is cached, and updated before each loadcommit, so the best place to call it is on loadcommit. - */ - export function canGoBack(): void; - - /** - * @description Indicates whether or not it is possible to navigate forward through history. The state of this function is cached, and updated before each loadcommit, so the best place to call it is on loadcommit. - */ - export function canGoForward(): void; - - /** - * @description

Clears browsing data for the webview partition.

- * @param {any} options Options determining which data to clear. - * @param {any} types The types of data to be cleared. - * @param {any} [object Object] - */ - export function clearData(options: ClearDataOptions, types: ClearDataTypeSet, callback?: () => void): void; - - /** - * @description

Injects JavaScript code into the guest page.

The following sample code uses script injection to set the guest page's background color to red:

webview.executeScript({ code: "document.body.style.backgroundColor = 'red'" });
- * @param {any} details Details of the script to run. - * @param {any} [object Object] - */ - export function executeScript(details: InjectDetails, callback?: (result?: any[]) => void): void; - - /** - * @description Initiates a find-in-page request. - * @param {string} searchText The string to find in the page. - * @param {any} options Options for the find request. - * @param {any} [object Object] - */ - export function find(searchText: string, options?: FindOptions, callback?: (results?: any) => void): void; - - /** - * @description Navigates forward one history entry if possible. Equivalent to go(1). - * @param {any} [object Object] - */ - export function forward(callback?: (success: boolean) => void): void; - - /** - * @description Returns Chrome's internal process ID for the guest web page's current process, allowing embedders to know how many guests would be affected by terminating the process. Two guests will share a process only if they belong to the same app and have the same storage partition ID. The call is synchronous and returns the embedder's cached notion of the current process ID. The process ID isn't the same as the operating system's process ID. - */ - export function getProcessId(): void; - - /** - * @description Returns the user agent string used by the webview for guest page requests. - */ - export function getUserAgent(): void; - - /** - * @description Gets the current zoom factor. - * @param {any} [object Object] - */ - export function getZoom(callback: (zoomFactor: number) => void): void; - - /** - * @description Gets the current zoom mode. - * @param {any} [object Object] - */ - export function getZoomMode(callback: (ZoomMode: any) => void): void; - - /** - * @description Navigates to a history entry using a history index relative to the current navigation. If the requested navigation is impossible, this method has no effect. - * @param {number} relativeIndex Relative history index to which the webview should be navigated. For example, a value of 2 will navigate forward 2 history entries if possible; a value of -3 will navigate backward 3 entries. - * @param {any} [object Object] - */ - export function go(relativeIndex: number, callback?: (success: boolean) => void): void; - - /** - * @description Injects CSS into the guest page. - * @param {any} details Details of the CSS to insert. - * @param {any} [object Object] - */ - export function insertCSS(details: InjectDetails, callback?: () => void): void; - - /** - * @description Indicates whether or not the webview's user agent string has been overridden by $(ref:webviewTag.setUserAgentOverride). - */ - export function isUserAgentOverridden(): void; - - /** - * @description Prints the contents of the webview. This is equivalent to calling scripted print function from the webview itself. - */ - export function print(): void; - - /** - * @description Reloads the current top-level page. - */ - export function reload(): void; - - /** - * @description

Removes content scripts from a webview.

The following example removes "myRule" which was added before.

webview.removeContentScripts(['myRule']);

You can remove all the rules by calling:

webview.removeContentScripts();
- * @param {any[]} scriptNameList A list of names of content scripts that will be removed. If the list is empty, all the content scripts added to the webview will be removed. - */ - export function removeContentScripts(scriptNameList?: any[]): void; - - /** - * @description Override the user agent string used by the webview for guest page requests. - * @param {string} userAgent The user agent string to use. - */ - export function setUserAgentOverride(userAgent: string): void; - - /** - * @description Changes the zoom factor of the page. The scope and persistence of this change are determined by the webview's current zoom mode (see $(ref:webviewTag.ZoomMode)). - * @param {number} zoomFactor The new zoom factor. - * @param {any} [object Object] - */ - export function setZoom(zoomFactor: number, callback?: () => void): void; - - /** - * @description Sets the zoom mode of the webview. - * @param {any} ZoomMode Defines how zooming is handled in the webview. - * @param {any} [object Object] - */ - export function setZoomMode(ZoomMode: ZoomMode, callback?: () => void): void; - - /** - * @description Stops loading the current webview navigation if in progress. - */ - export function stop(): void; - - /** - * @description Ends the current find session (clearing all highlighting) and cancels all find requests in progress. - * @param {string} action Determines what to do with the active match after the find session has ended. clear will clear the highlighting over the active match; keep will keep the active match highlighted; activate will keep the active match highlighted and simulate a user click on that match. The default action is keep. - */ - export function stopFinding(action?: string): void; - - /** - * @description Loads a data URL with a specified base URL used for relative links. Optionally, a virtual URL can be provided to be shown to the user instead of the data URL. - * @param {string} dataUrl The data URL to load. - * @param {string} baseUrl The base URL that will be used for relative links. - * @param {string} virtualUrl The URL that will be displayed to the user (in the address bar). - */ - export function loadDataWithBaseUrl(dataUrl: string, baseUrl: string, virtualUrl?: string): void; - - /** - * @description Forcibly kills the guest web page's renderer process. This may affect multiple webview tags in the current app if they share the same process, but it will not affect webview tags in other apps. - */ - export function terminate(): void; - - /** - * @description Fired when the guest window attempts to close itself.

The following example code navigates the webview to about:blank when the guest attempts to close itself.

webview.addEventListener('close', function() {
-          webview.src = 'about:blank';
-        });
- */ - - export function close(event: chrome.events.Event): void; - - /** - * @description Fired when the guest window logs a console message.

The following example code forwards all log messages to the embedder's console without regard for log level or other properties.

webview.addEventListener('consolemessage', function(e) {
-          console.log('Guest page logged a message: ', e.message);
-        });
- * @param {any} [object Object] - */ - - export var consolemessage: chrome.events.Event; - - /** - * @description Fired when the guest window fires a load event, i.e., when a new document is loaded. This does not include page navigation within the current document or asynchronous resource loads.

The following example code modifies the default font size of the guest's body element after the page loads:

webview.addEventListener('contentload', function() {
-          webview.executeScript({ code: 'document.body.style.fontSize = "42px"' });
-        });
- */ - - export var contentload: (event: chrome.events.Event) => void; - - /** - * @description Fired when the guest window attempts to open a modal dialog via window.alert, window.confirm, or window.prompt.

Handling this event will block the guest process until each event listener returns or the dialog object becomes unreachable (if preventDefault() was called.)

The default behavior is to cancel the dialog.

- * @param {any} [object Object] - */ - - export var dialog: chrome.events.Event; - - /** - * @description Fired when the process rendering the guest web content has exited.

The following example code will show a farewell message whenever the guest page crashes:

webview.addEventListener('exit', function(e) {
-          if (e.reason === 'crash') {
-            webview.src = 'data:text/plain,Goodbye, world!';
-          }
-        });
- * @param {any} [object Object] - */ - - export var exit: chrome.events.Event; - - /** - * @description Fired when new find results are available for an active find request. This might happen multiple times for a single find request as matches are found. - * @param {any} [object Object] - */ - - export var findupdate: chrome.events.Event; - - /** - * @description Fired when a top-level load has aborted without committing. An error message will be printed to the console unless the event is default-prevented.

Note: When a resource load is aborted, a loadabort event will eventually be followed by a loadstop event, even if all committed loads since the last loadstop event (if any) were aborted.

Note: When the load of either an about URL or a JavaScript URL is aborted, loadabort will be fired and then the webview will be navigated to 'about:blank'.

- * @param {any} [object Object] - */ - - export var loadabort: chrome.events.Event; - - /** - * @description Fired when a load has committed. This includes navigation within the current document as well as subframe document-level loads, but does not include asynchronous resource loads. - * @param {any} [object Object] - */ - - export var loadcommit: chrome.events.Event; - - /** - * @description Fired when a top-level load request has redirected to a different URL. - * @param {any} [object Object] - */ - - export var loadredirect: chrome.events.Event; - - /** - * @description Fired when a load has begun. - * @param {any} [object Object] - */ - - export var loadstart: chrome.events.Event; - - /** - * @description Fired when all frame-level loads in a guest page (including all its subframes) have completed. This includes navigation within the current document as well as subframe document-level loads, but does not include asynchronous resource loads. This event fires every time the number of document-level loads transitions from one (or more) to zero. For example, if a page that has already finished loading (i.e., loadstop already fired once) creates a new iframe which loads a page, then a second loadstop will fire when the iframe page load completes. This pattern is commonly observed on pages that load ads.

Note: When a committed load is aborted, a loadstop event will eventually follow a loadabort event, even if all committed loads since the last loadstop event (if any) were aborted.

- */ - - export function loadstop(event: chrome.events.Event): void; - - /** - * @description Fired when the guest page attempts to open a new browser window.

The following example code will create and navigate a new webview in the embedder for each requested new window:

webview.addEventListener('newwindow', function(e) {
-          var newWebview = document.createElement('webview');
-          document.body.appendChild(newWebview);
-          e.window.attach(newWebview);
-        });
- * @param {any} [object Object] - */ - - export var newwindow: chrome.events.Event; - - /** - * @description Fired when the guest page needs to request special permission from the embedder.

The following example code will grant the guest page access to the webkitGetUserMedia API. Note that an app using this example code must itself specify audioCapture and/or videoCapture manifest permissions:

webview.addEventListener('permissionrequest', function(e) {
-          if (e.permission === 'media') {
-            e.request.allow();
-          }
-        });
- * @param {any} [object Object] - */ - - export var permissionrequest: chrome.events.Event; - - /** - * @description Fired when the process rendering the guest web content has become responsive again after being unresponsive.

The following example code will fade the webview element in or out as it becomes responsive or unresponsive:

webview.style.webkitTransition = 'opacity 250ms';
-        webview.addEventListener('unresponsive', function() {
-          webview.style.opacity = '0.5';
-        });
-        webview.addEventListener('responsive', function() {
-          webview.style.opacity = '1';
-        });
- * @param {any} [object Object] - */ - - export var responsive: chrome.events.Event; - - /** - * @description Fired when the embedded web content has been resized via autosize. Only fires if autosize is enabled. - * @param {any} [object Object] - */ - - export var sizechanged: chrome.events.Event; - - /** - * @description Fired when the process rendering the guest web content has become unresponsive. This event will be generated once with a matching responsive event if the guest begins to respond again. - * @param {any} [object Object] - */ - - export var unresponsive: chrome.events.Event; - - /** - * @description Fired when the page's zoom changes. - * @param {any} [object Object] - */ - - export var zoomchange: chrome.events.Event; - /**IConsolemessage (Auto generated interface) */ - interface IConsolemessage { + export type ZoomMode = 'per-origin' | 'per-view' | 'disabled'; + + export enum ConsoleMessageLevel { + LOG_VERBOSE = -1, + LOG_INFO = 0, + LOG_WARNING = 1, + LOG_ERROR = 2 + } + interface IConsoleMessage { /** * @description The severity level of the log message. Ranges from -1 to 2. LOG_VERBOSE (console.debug) = -1, LOG_INFO (console.log, console.info) = 0, LOG_WARNING (console.warn) = 1, LOG_ERROR (console.error) = 2. */ - level: number + level: ConsoleMessageLevel; /** * @description The logged message contents. @@ -5539,7 +6539,6 @@ declare namespace chrome { */ sourceId: string } - /**IDialog (Auto generated interface) */ interface IDialog { /** @@ -5557,7 +6556,6 @@ declare namespace chrome { */ dialog: DialogController } - /**IExit (Auto generated interface) */ interface IExit { /** @@ -5570,7 +6568,6 @@ declare namespace chrome { */ reason: 'normal' | 'abnormal' | 'crash' | 'kill' } - /**IFindupdate (Auto generated interface) */ interface IFindupdate { /** @@ -5603,7 +6600,6 @@ declare namespace chrome { */ finalUpdate: string } - /**ILoadabort (Auto generated interface) */ interface ILoadabort { /** @@ -5626,7 +6622,6 @@ declare namespace chrome { */ reason: 'ERR_ABORTED' | 'ERR_INVALID_URL' | 'ERR_DISALLOWED_URL_SCHEME' | 'ERR_BLOCKED_BY_CLIENT' | 'ERR_ADDRESS_UNREACHABLE' | 'ERR_EMPTY_RESPONSE' | 'ERR_FILE_NOT_FOUND' | 'ERR_UNKNOWN_URL_SCHEME' } - /**ILoadcommit (Auto generated interface) */ interface ILoadcommit { /** @@ -5703,7 +6698,6 @@ declare namespace chrome { */ windowOpenDisposition: 'ignore' | 'save_to_disk' | 'current_tab' | 'new_background_tab' | 'new_foreground_tab' | 'new_window' | 'new_popup' } - /**IPermissionrequest (Auto generated interface) */ interface IPermissionrequest { /** @@ -5714,8 +6708,9 @@ declare namespace chrome { /** * @description An object which holds details of the requested permission. Depending on the type of permission requested, this may be a $(ref:webviewTag.MediaPermissionRequest), $(ref:webviewTag.GeolocationPermissionRequest), $(ref:webviewTag.PointerLockPermissionRequest), $(ref:webviewTag.DownloadPermissionRequest), $(ref:webviewTag.LoadPluginPermissionRequest), or $(ref:webviewTag.FullscreenPermissionRequest). */ - request: object + request: GeolocationPermissionRequest | PointerLockPermissionRequest | DownloadPermissionRequest | LoadPluginPermissionRequest | FullscreenPermissionRequest; } + /**IResponsive (Auto generated interface) */ interface IResponsive { diff --git a/types/chrome-apps/test/index.ts b/types/chrome-apps/test/index.ts index f976fc57b4..c0dc6402a6 100644 --- a/types/chrome-apps/test/index.ts +++ b/types/chrome-apps/test/index.ts @@ -1,7 +1,7 @@ import runtime = chrome.app.runtime; import cwindow = chrome.app.window; -var createOptions: cwindow.CreateWindowOptions = { +const createOptions: cwindow.CreateWindowOptions = { id: "My Window", bounds: { left: 0, @@ -324,5 +324,40 @@ function testSystemNetwork() { }); } -import webview = chrome.webview; -let element: webview.HTMLWebViewElement; +const gcmMessage = {}; +gcmMessage.data = { + /*goog: 'any', should not be allowed, and it is not :) */ + test: true +}; + +let wve: chrome.webview.HTMLWebViewElement = (document.getElementById('webview')); +wve.name = 'test'; +wve.src = 'https://github.com/DefinitelyTyped'; +wve.allowtransparency = true; +wve.autosize = 'on'; +wve.partition = 'persist:githubwebview'; +wve.addEventListener('close', () => { + return; +}); +wve.addEventListener('consolemessage', (ev) => { + if (ev.level === chrome.webview.ConsoleMessageLevel.LOG_ERROR) { + const msg = ev.message; + } +}); +wve.addEventListener('dialog', (ev) => { + ev.dialog.ok('Hello World!'); +}); +wve.addEventListener('loadstart', (ev) => { + if (ev.isTopLevel) { + return ev.url; + } + return; +}); +wve.addEventListener('zoomchange', (ev) => { + return ev.newZoomFactor || ev.oldZoomFactor; +}); +wve.addEventListener('loadredirect', (ev) => { + return ev.newUrl || ev.oldUrl; +}); + +chrome.bluetoothLowEnergy.connect('1111111', () => { }); diff --git a/types/com.wikitude.phonegap.wikitudeplugin/com.wikitude.phonegap.wikitudeplugin-tests.ts b/types/com.wikitude.phonegap.wikitudeplugin/com.wikitude.phonegap.wikitudeplugin-tests.ts new file mode 100644 index 0000000000..c46d48d563 --- /dev/null +++ b/types/com.wikitude.phonegap.wikitudeplugin/com.wikitude.phonegap.wikitudeplugin-tests.ts @@ -0,0 +1,33 @@ +const startupConfiguration: any = { camera_position: 'back' }; + +// Some code samples from the wikitude ionic starter +WikitudePlugin.loadARchitectWorld( + success => { + console.log('ARchitect World loaded successfully.'); + }, + fail => { + console.log('Failed to load ARchitect World!'); + }, + 'www/assets/07_3dModels_6_3dModelAtGeoLocation/index.html', + ['geo'], + startupConfiguration +); + +WikitudePlugin.setOnUrlInvokeCallback(url => { + if (url.indexOf('captureScreen') > -1) { + WikitudePlugin.captureScreen( + absoluteFilePath => { + WikitudePlugin.callJavaScript( + `World.testFunction('Screenshot saved at: ${absoluteFilePath}');` + ); + }, + errorMessage => { + console.log(errorMessage); + }, + true, + null + ); + } else { + alert(url + 'not handled'); + } +}); diff --git a/types/com.wikitude.phonegap.wikitudeplugin/index.d.ts b/types/com.wikitude.phonegap.wikitudeplugin/index.d.ts new file mode 100644 index 0000000000..50307d57c8 --- /dev/null +++ b/types/com.wikitude.phonegap.wikitudeplugin/index.d.ts @@ -0,0 +1,82 @@ +// Type definitions for com.wikitude.phonegap.wikitudeplugin 7.2 +// Project: https://github.com/Wikitude/wikitude-cordova-plugin +// Definitions by: zbarbuto +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +// The following types are taken directly (unmodified) from the wikitude-ionic-3-starter-app +// https://github.com/pbreuss/wikitude-ionic-3-starter-app +// Latest commit at time of writing was 647cd546f6d1805765c4cee725566e246ca6259d + +/** + * Wrapper for the Wikitude SDK Phonegap Plugin - to use with IONIC2 + * (c) 2016 Schneeweis.Technology + */ +interface WikitudePlugin { + isDeviceSupported( + successCallback: (success: string) => void, + errorCallback: (message: string) => void, + requiredFeatures: [string] + ): void; + + loadARchitectWorld( + successCallback: (success: string) => void, + errorCallback: (message: string) => void, + architectWorldPath: string, + requiredFeatures: [string], + startupConfiguration: JSON | object + ): void; + + close(): void; + + hide(): void; + + show(): void; + + // test type ok? + callJavaScript(js: any): void; + + setOnUrlInvokeCallback(onUrlInvokeCallback: (success: string) => void): void; + + setLocation(latitude: any, longitude: any, altitude: any, accuracy: any): void; + + captureScreen( + successCallback: (success: string) => void, + errorCallback: (message: string) => void, + includeWebView: boolean, + imagePathInBundleOrNullForPhotoLibrary: string | null + ): void; + + setErrorHandler(errorHandler: (message: string) => void): void; + + setDeviceSensorsNeedCalibrationHandler( + startCalibrationHandler: (message: string) => void + ): void; + + setDeviceSensorsFinishedCalibrationHandler( + finishedCalibrationHandler: (message: string) => void + ): void; + + setBackButtonCallback(onBackButtonCallback: (message: string) => void): void; + + /* Lifecycle updates */ + + onResume(): void; + onBackButton(): void; + onPause(): void; + + onWikitudeOK(): void; + onWikitudeError(): void; + + _sdkKey: string; + FeatureGeo: string; + Feature2DTracking: string; + CameraPositionUndefined: number; + CameraPositionFront: number; + CameraPositionBack: number; + CameraFocusRangeNone: number; + CameraFocusRangeNear: number; + CameraFocusRangeFar: number; +} + +declare var WikitudePlugin: WikitudePlugin; diff --git a/types/com.wikitude.phonegap.wikitudeplugin/tsconfig.json b/types/com.wikitude.phonegap.wikitudeplugin/tsconfig.json new file mode 100644 index 0000000000..ed0ce7783e --- /dev/null +++ b/types/com.wikitude.phonegap.wikitudeplugin/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "com.wikitude.phonegap.wikitudeplugin-tests.ts" + ] +} diff --git a/types/com.wikitude.phonegap.wikitudeplugin/tslint.json b/types/com.wikitude.phonegap.wikitudeplugin/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/com.wikitude.phonegap.wikitudeplugin/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/csso/csso-tests.ts b/types/csso/csso-tests.ts new file mode 100644 index 0000000000..74e0b51dd9 --- /dev/null +++ b/types/csso/csso-tests.ts @@ -0,0 +1,40 @@ +import csso = require('csso'); + +csso.minify('.test { color: #ff0000; }').css; +csso.minify('.test { color: #ff0000; }').map; +csso.minify('.test { color: #ff0000; }', { + sourceMap: true, + filename: '', + debug: true, + beforeCompress: () => {}, + afterCompress: () => {}, + restructure: false, + forceMediaMerge: true, + clone: false, + comments: '', + logger: () => {} +}); + +csso.minifyBlock('color: rgba(255, 0, 0, 1); color: #ff0000').css; +csso.minifyBlock('color: rgba(255, 0, 0, 1); color: #ff0000').map; +csso.minifyBlock('color: rgba(255, 0, 0, 1); color: #ff0000', { + sourceMap: true, + filename: '', + debug: true, + beforeCompress: () => {}, + afterCompress: () => {}, + restructure: false, + forceMediaMerge: true, + clone: false, + comments: '', + logger: () => {} +}); + +csso.compress({}).ast; +csso.compress({}, { + restructure: false, + forceMediaMerge: true, + clone: false, + comments: '', + logger: () => {} +}).ast; diff --git a/types/csso/index.d.ts b/types/csso/index.d.ts new file mode 100644 index 0000000000..f89f395129 --- /dev/null +++ b/types/csso/index.d.ts @@ -0,0 +1,107 @@ +// Type definitions for csso 3.5 +// Project: https://github.com/css/csso +// Definitions by: Christian Rackerseder +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.6 + +declare namespace csso { + interface Result { + /** + * Resulting CSS. + */ + css: string; + /** + * Instance of SourceMapGenerator or null. + */ + map: object | null; + } + + interface CompressOptions { + /** + * Disable or enable a structure optimisations. + * @default true + */ + restructure?: boolean; + /** + * Enables merging of @media rules with the same media query by splitted by other rules. + * The optimisation is unsafe in general, but should work fine in most cases. Use it on your own risk. + * @default false + */ + forceMediaMerge?: boolean; + /** + * Transform a copy of input AST if true. Useful in case of AST reuse. + * @default false + */ + clone?: boolean; + /** + * Specify what comments to leave: + * - 'exclamation' or true – leave all exclamation comments + * - 'first-exclamation' – remove every comment except first one + * - false – remove all comments + * @default true + */ + comments?: string | boolean; + /** + * Usage data for advanced optimisations. + */ + usage?: object; + /** + * Function to track every step of transformation. + */ + logger?: () => void; + } + + interface MinifyOptions { + /** + * Generate a source map when true. + * @default false + */ + sourceMap?: boolean; + /** + * Filename of input CSS, uses for source map generation. + * @default '' + */ + filename?: string; + /** + * Output debug information to stderr. + * @default false + */ + debug?: boolean; + /** + * Called right after parse is run. + */ + beforeCompress?: BeforeCompressFn | BeforeCompressFn[]; + /** + * Called right after compress() is run. + */ + afterCompress?: AfterCompressFn | AfterCompressFn[]; + restructure?: boolean; + } + + type BeforeCompressFn = (ast: object, options: CompressOptions) => void; + type AfterCompressFn = (compressResult: string, options: CompressOptions) => void; +} + +interface Csso { + /** + * Minify source CSS passed as String + * @param source + * @param options + */ + minify(source: string, options?: csso.MinifyOptions & csso.CompressOptions): csso.Result; + + /** + * The same as minify() but for list of declarations. Usually it's a style attribute value. + * @param source + * @param options + */ + minifyBlock(source: string, options?: csso.MinifyOptions & csso.CompressOptions): csso.Result; + + /** + * Does the main task – compress an AST. + */ + compress(ast: object, options?: csso.CompressOptions): { ast: object }; +} + +declare const csso: Csso; +export = csso; diff --git a/types/csso/tsconfig.json b/types/csso/tsconfig.json new file mode 100644 index 0000000000..9ed6695bc9 --- /dev/null +++ b/types/csso/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "csso-tests.ts" + ] +} diff --git a/types/csso/tslint.json b/types/csso/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/csso/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/dat.gui/index.d.ts b/types/dat.gui/index.d.ts index 967b5ae13b..5c20fd51fe 100644 --- a/types/dat.gui/index.d.ts +++ b/types/dat.gui/index.d.ts @@ -51,8 +51,7 @@ export class GUI { __folders: GUI[]; domElement: HTMLElement; - add(target: Object, propName:string): GUIController; - add(target: Object, propName:string, min: number, max: number): GUIController; + add(target: Object, propName:string, min?: number, max?: number, step?: number): GUIController; add(target: Object, propName:string, status: boolean): GUIController; add(target: Object, propName:string, items:string[]): GUIController; add(target: Object, propName:string, items:number[]): GUIController; @@ -64,6 +63,7 @@ export class GUI { destroy(): void; addFolder(propName:string): GUI; + removeFolder(subFolder:GUI):void; open(): void; close(): void; diff --git a/types/emoji-regex/emoji-regex-tests.ts b/types/emoji-regex/emoji-regex-tests.ts new file mode 100644 index 0000000000..6d6b0d25d9 --- /dev/null +++ b/types/emoji-regex/emoji-regex-tests.ts @@ -0,0 +1,3 @@ +import emojiRegex from "emoji-regex"; + +emojiRegex(); // $ExpectType RegExp diff --git a/types/emoji-regex/index.d.ts b/types/emoji-regex/index.d.ts new file mode 100644 index 0000000000..edff690dc7 --- /dev/null +++ b/types/emoji-regex/index.d.ts @@ -0,0 +1,7 @@ +// Type definitions for emoji-regex 7.0 +// Project: https://github.com/mathiasbynens/emoji-regex +// Definitions by: iKBAHT +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare function createRegExp(): RegExp; +export = createRegExp; diff --git a/types/emoji-regex/tsconfig.json b/types/emoji-regex/tsconfig.json new file mode 100644 index 0000000000..1dfdf53dac --- /dev/null +++ b/types/emoji-regex/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "allowSyntheticDefaultImports": true, + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "emoji-regex-tests.ts" + ] +} diff --git a/types/emoji-regex/tslint.json b/types/emoji-regex/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/emoji-regex/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/highcharts/index.d.ts b/types/highcharts/index.d.ts index 1434999411..6ef4ef4e2a 100644 --- a/types/highcharts/index.d.ts +++ b/types/highcharts/index.d.ts @@ -2354,7 +2354,7 @@ declare namespace Highcharts { * can be customized by defining a new array of items and assigning null to unwanted positions. * @since 2.0 */ - menuItems?: MenuItem[]; + menuItems?: string[] | MenuItem[]; /** * A click handler callback to use on the button directly instead of the popup menu. * @since 2.0 @@ -2661,6 +2661,12 @@ declare namespace Highcharts { * @default ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] */ shortMonths?: string[]; + /** + * Short week days, starting Sunday. If not specified, Highcharts uses the first three letters of the lang.weekdays option. + * @default undefined + * @since 4.2.4 + */ + shortWeekdays?: string[]; /** * The default thousands separator used in the Highcharts.numberFormat method unless otherwise specified in the * function arguments. Since Highcharts 4.1 it defaults to a single space character, which is compatible with ISO diff --git a/types/highcharts/modules/drilldown.d.ts b/types/highcharts/modules/drilldown.d.ts new file mode 100644 index 0000000000..adf9bae6f8 --- /dev/null +++ b/types/highcharts/modules/drilldown.d.ts @@ -0,0 +1,10 @@ +// Type definitions for Highcharts Drilldown 4.2.7 +// Project: http://www.highcharts.com/ +// Definitions by: Konstantin Rohde +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import { Static } from "highcharts"; + +declare function HighchartsDrilldown(H: Static): Static; +export = HighchartsDrilldown; +export as namespace HighchartsDrilldown; diff --git a/types/highcharts/test/drilldown.ts b/types/highcharts/test/drilldown.ts new file mode 100644 index 0000000000..f4aa33ca4a --- /dev/null +++ b/types/highcharts/test/drilldown.ts @@ -0,0 +1 @@ +HighchartsDrilldown(Highcharts); diff --git a/types/highcharts/tsconfig.json b/types/highcharts/tsconfig.json index 24b0cf2dd7..e69f0eeb57 100644 --- a/types/highcharts/tsconfig.json +++ b/types/highcharts/tsconfig.json @@ -21,6 +21,7 @@ "index.d.ts", "modules/map/index.d.ts", "modules/boost.d.ts", + "modules/drilldown.d.ts", "modules/exporting.d.ts", "modules/no-data-to-display.d.ts", "modules/offline-exporting.d.ts", @@ -28,6 +29,7 @@ "highstock.d.ts", "js/highcharts/index.d.ts", "test/boost.ts", + "test/drilldown.ts", "test/exporting.ts", "test/highstock.ts", "test/index.ts", diff --git a/types/http-graceful-shutdown/http-graceful-shutdown-tests.ts b/types/http-graceful-shutdown/http-graceful-shutdown-tests.ts new file mode 100644 index 0000000000..17bc81ce1d --- /dev/null +++ b/types/http-graceful-shutdown/http-graceful-shutdown-tests.ts @@ -0,0 +1,21 @@ +import GracefulShutdown = require('http-graceful-shutdown'); +import * as http from "http"; + +const opts: GracefulShutdown.Options = { + signals: "SIGINT SIGTERM", + timeout: 1337, + development: false, + onShutdown: () => { + console.log('fake shutdown handler'); + return Promise.resolve(); + }, + finally: () => { + console.log('fake finally handler'); + } +}; + +const server = http.createServer((req, res) => { + res.end(); +}); + +GracefulShutdown(server, opts); diff --git a/types/http-graceful-shutdown/index.d.ts b/types/http-graceful-shutdown/index.d.ts new file mode 100644 index 0000000000..f8269adea7 --- /dev/null +++ b/types/http-graceful-shutdown/index.d.ts @@ -0,0 +1,22 @@ +// Type definitions for http-graceful-shutdown 2.1 +// Project: https://github.com/sebhildebrandt/http-graceful-shutdown +// Definitions by: Dave Lee +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +import { Server } from "http"; + +declare function GracefulShutdown(server: Server, options?: GracefulShutdown.Options): void; + +declare namespace GracefulShutdown { + interface Options { + signals?: string; + timeout?: number; + development?: boolean; + onShutdown?: () => Promise; + finally?: () => void; + } +} + +export = GracefulShutdown; diff --git a/types/http-graceful-shutdown/tsconfig.json b/types/http-graceful-shutdown/tsconfig.json new file mode 100644 index 0000000000..a738609778 --- /dev/null +++ b/types/http-graceful-shutdown/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "http-graceful-shutdown-tests.ts" + ] +} diff --git a/types/http-graceful-shutdown/tslint.json b/types/http-graceful-shutdown/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/http-graceful-shutdown/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/luxon/index.d.ts b/types/luxon/index.d.ts index 94623c5abb..75491e24f6 100644 --- a/types/luxon/index.d.ts +++ b/types/luxon/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for luxon 0.5 +// Type definitions for luxon 1.2 // Project: https://github.com/moment/luxon#readme // Definitions by: Colby DeHart // Hyeonseok Yang @@ -180,14 +180,14 @@ declare module 'luxon' { zoneName: string; diff( other: DateTime, - unit?: string | string[], + unit?: DurationUnit | DurationUnit[], options?: DiffOptions ): Duration; - diffNow(unit?: string | string[], options?: DiffOptions): Duration; - endOf(unit: string): DateTime; + diffNow(unit?: DurationUnit | DurationUnit[], options?: DiffOptions): Duration; + endOf(unit: DurationUnit): DateTime; equals(other: DateTime): boolean; - get(unit: string): number; - hasSame(other: DateTime, unit: string): boolean; + get(unit: keyof DateTime): number; + hasSame(other: DateTime, unit: DurationUnit): boolean; minus(duration: Duration | number | DurationObject): DateTime; plus(duration: Duration | number | DurationObject): DateTime; reconfigure(properties: LocaleOptions): DateTime; @@ -195,7 +195,8 @@ declare module 'luxon' { set(values: DateObjectUnits): DateTime; setLocale(locale: any): DateTime; setZone(zone: string | Zone, options?: ZoneOptions): DateTime; - startOf(unit: string): DateTime; + startOf(unit: DurationUnit): DateTime; + toBSON(): Date; toFormat(format: string, options?: ToFormatOptions): string; toHTTP(): string; toISO(options?: ISOTimeOptions): string; @@ -207,6 +208,7 @@ declare module 'luxon' { toLocal(): DateTime; toLocaleParts(options?: DateTimeFormatOptions): any[]; toLocaleString(options?: DateTimeFormatOptions): string; + toMillis(): number; toObject(options?: { includeConfig?: boolean }): DateObject; toMillis(): number; toRFC2822(): string; @@ -238,6 +240,9 @@ declare module 'luxon' { type DurationObject = DurationObjectUnits & DurationOptions; + type DurationUnit = 'year' | 'years' | 'quarter' | 'quarters' | 'month' | 'months' | 'week' | 'weeks' | 'day' | 'days' + | 'hour' | 'hours' | 'minute' | 'minutes' | 'second' | 'seconds' | 'millisecond' | 'milliseconds'; + class Duration { static fromISO(text: string, options?: DurationOptions): Duration; static fromMillis( @@ -261,16 +266,16 @@ declare module 'luxon' { seconds: number; weeks: number; years: number; - as(unit: string): number; + as(unit: DurationUnit): number; equals(other: Duration): boolean; - get(unit: string): number; + get(unit: DurationUnit): number; minus(duration: Duration | number | DurationObject): Duration; negate(): Duration; normalize(): Duration; plus(duration: Duration | number | DurationObject): Duration; reconfigure(objectPattern: DurationOptions): Duration; set(values: DurationObjectUnits): Duration; - shiftTo(...units: string[]): Duration; + shiftTo(...units: DurationUnit[]): Duration; toFormat(format: string, options?: ToFormatOptions): string; toISO(): string; toJSON(): string; @@ -278,6 +283,7 @@ declare module 'luxon' { includeConfig?: boolean; }): DurationObject; toString(): string; + valueOf(): number; } type EraLength = 'short' | 'long'; @@ -341,23 +347,23 @@ declare module 'luxon' { abutsEnd(other: Interval): boolean; abutsStart(other: Interval): boolean; contains(dateTime: DateTime): boolean; - count(unit?: string): number; + count(unit?: DurationUnit): number; difference(...intervals: Interval[]): Interval[]; divideEqually(numberOfParts?: number): Interval[]; engulfs(other: Interval): boolean; equals(other: Interval): boolean; - hasSame(unit: string): boolean; + hasSame(unit: DurationUnit): boolean; intersection(other: Interval): Interval; isAfter(dateTime: DateTime): boolean; isBefore(dateTime: DateTime): boolean; isEmpty(): boolean; - length(unit?: string): number; + length(unit?: DurationUnit): number; overlaps(other: Interval): boolean; set(values: IntervalObject): Interval; splitAt(...dateTimes: DateTime[]): Interval[]; splitBy(duration: Duration | DurationObject | number): Interval[]; toDuration( - unit: string | string[], + unit: DurationUnit | DurationUnit[], options?: DiffOptions ): Duration; toFormat( diff --git a/types/mustache/index.d.ts b/types/mustache/index.d.ts index 26a00fc796..2b0ab91cd0 100644 --- a/types/mustache/index.d.ts +++ b/types/mustache/index.d.ts @@ -1,53 +1,247 @@ -// Type definitions for Mustache 0.8.2 +// Type definitions for Mustache 0.8.3 // Project: https://github.com/janl/mustache.js -// Definitions by: Mark Ashley Bell +// Definitions by: Mark Ashley Bell , Manuel Thalmann // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +/** + * Provides the functionality to render templates with `{{mustaches}}`. + */ +interface MustacheStatic { + /** + * The name of the module. + */ + name: string; -interface MustacheScanner { + /** + * The version of the module. + */ + version: string; + + /** + * The opening and closing tags to parse. + */ + tags: string; + + /** + * A simple string scanner that is used by the template parser to find tokens in template strings. + */ + Scanner: typeof MustacheScanner + + /** + * Represents a rendering context by wrapping a view object and maintaining a reference to the parent context. + */ + Context: typeof MustacheContext; + + /** + * A Writer knows how to take a stream of tokens and render them to a `string`, given a context. + * + * It also maintains a cache of templates to avoid the need to parse the same template twice. + */ + Writer: typeof MustacheWriter; + + /** + * Escapes HTML-characters. + * + * @param value + * The string to escape. + */ + escape: (value: string) => string; + + /** + * Clears all cached templates in this writer. + */ + clearCache(): void; + + /** + * Parses and caches the given template in the default writer and returns the array of tokens it contains. + * + * Doing this ahead of time avoids the need to parse templates on the fly as they are rendered. + * + * @param template + * The template to parse. + * + * @param tags + * The tags to use. + */ + parse(template: string, tags?: string[]): any; + + /** + * Renders the `template` with the given `view` and `partials` using the default writer. + * + * @param template + * The template to render. + * + * @param view + * The view to render the template with. + * + * @param partials + * Either an object that contains the names and templates of partials that are used in a template + * + * -- or -- + * + * A function that is used to load partial template on the fly that takes a single argument: the name of the partial. + */ + render(template: string, view: any | MustacheContext, partials?: any): string; + + /** + * Renders the `template` with the given `view` and `partials` using the default writer. + * + * @param template + * The template to render. + * + * @param view + * The view to render the template with. + * + * @param partials + * Either an object that contains the names and templates of partials that are used in a template + * + * -- or -- + * + * A function that is used to load partial template on the fly that takes a single argument: the name of the partial. + */ + to_html(template: string, view: any | MustacheContext, partials?: any, send?: any): any; +} + +/** + * A simple string scanner that is used by the template parser to find tokens in template strings. + */ +declare class MustacheScanner { string: string; tail: string; pos: number; + /** + * Initializes a new instance of the `MustacheScanner` class. + */ + constructor(string: string); + + /** + * Returns `true` if the tail is empty (end of string). + */ eos(): boolean; + + /** + * Tries to match the given regular expression at the current position. + * + * @param re + * The regex-pattern to match. + * + * @returns + * The matched text if it can match, the empty string otherwise. + */ scan(re: RegExp): string; + + /** + * Skips all text until the given regular expression can be matched. + * + * @param re + * The regex-pattern to match. + * + * @returns + * Returns the skipped string, which is the entire tail if no match can be made. + */ scanUntil(re: RegExp): string; } -interface MustacheContext { +/** + * Represents a rendering context by wrapping a view object and maintaining a reference to the parent context. + */ +declare class MustacheContext { view: any; parentContext: MustacheContext; + /** + * Initializes a new instance of the `MustacheContenxt` class. + */ + constructor(view: any, parentContext: MustacheContext); + + /** + * Initializes a new instance of the `MustacheContenxt` class. + */ + constructor(view: any); + + /** + * Creates a new context using the given view with this context as the parent. + * + * @param view + * The view to create the new context with. + */ push(view: any): MustacheContext; + + /** + * Returns the value of the given name in this context, traversing up the context hierarchy if the value is absent in this context's view. + * + * @param name + * The name to look up. + */ lookup(name: string): any; } -interface MustacheWriter { - (view: any): string; +/** + * A Writer knows how to take a stream of tokens and render them to a `string`, given a context. + * + * It also maintains a cache of templates to avoid the need to parse the same template twice. + */ +declare class MustacheWriter { + /** + * Initializes a new instance of the `MustacheWriter` class. + */ + constructor(); + /** + * Clears all cached templates in this writer. + */ clearCache(): void; + + /** + * Parses and caches the given `template` and returns the array of tokens that is generated from the parse. + * + * @param template + * The template to parse. + */ parse(template: string, tags?: any): any; - render(template: string, view: any, partials: any): string; + + /** + * High-level method that is used to render the given `template` with the given `view`. + * + * @param template + * The template to render. + * + * @param view + * The view to render the template with. + * + * @param partials + * Either an object that contains the names and templates of partials that are used in a template + * + * -- or -- + * + * A function that is used to load partial template on the fly that takes a single argument: the name of the partial. + */ + render(template: string, view: any | MustacheContext, partials: any): string; + + /** + * Low-level method that renders the given array of `tokens` using the given `context` and `partials`. + * + * @param tokens + * The tokens to render. + * + * @param context + * The context to use for rendering the tokens. + * + * @param partials + * The partials to use for rendering the tokens. + * + * @param originalTemplate + * An object used to extract the portion of the original template that was contained in a higher-order section. + * + * If the template doesn't use higher-order sections, this argument may be omitted. + */ renderTokens(tokens: string[], context: MustacheContext, partials: any, originalTemplate: any): string; } -interface MustacheStatic { - name: string; - version: string; - tags: string; - Scanner: MustacheScanner; - Context: MustacheContext; - Writer: MustacheWriter; - escape: any; - - clearCache(): MustacheWriter; - parse(template: string, tags?: any): any; - render(template: string, view: any, partials?: any): string; - to_html(template: string, view: any, partials?: any, send?: any): any; -} - +/** + * Provides the functionality to render templates with `{{mustaches}}`. + */ declare var Mustache: MustacheStatic; - -declare module 'mustache' { - export = Mustache; -} +export = Mustache; +export as namespace Mustache; diff --git a/types/mustache/mustache-tests.ts b/types/mustache/mustache-tests.ts index ad9c410d76..30c920a30a 100644 --- a/types/mustache/mustache-tests.ts +++ b/types/mustache/mustache-tests.ts @@ -12,3 +12,18 @@ var output2 = Mustache.render(template2, view2); var view3 = { firstName: "John", lastName: "Smith", blogURL: "http://testblog.com" }; var template3 = "

{{firstName}} {{lastName}}

Blog: {{blogURL}}"; var html = Mustache.to_html(template3, view3); + +var view4 = new class extends Mustache.Context +{ + constructor() + { + super({}); + } + + public lookup(name: string) + { + return name.toUpperCase(); + } +}; +var template4 = "Hello, {{firstName}} {{lastName}}"; +var html4 = Mustache.render(template4, view4); \ No newline at end of file diff --git a/types/node-vault/index.d.ts b/types/node-vault/index.d.ts index 835e364ae7..f21d625822 100644 --- a/types/node-vault/index.d.ts +++ b/types/node-vault/index.d.ts @@ -111,7 +111,7 @@ declare namespace NodeVault { debug?(...args: any[]): any; tv4?(...args: any[]): any; commands?: Array<{ method: string, path: string, scheme: any }>; - mustache?: MustacheStatic; + mustache?: typeof mustache; "request-promise"?: any; Promise?: PromiseConstructor; diff --git a/types/office-js/index.d.ts b/types/office-js/index.d.ts index c800ea2842..346fef880b 100644 --- a/types/office-js/index.d.ts +++ b/types/office-js/index.d.ts @@ -13835,7 +13835,23 @@ declare namespace OfficeExtension { declare namespace OfficeExtension { /** - * Specifies which properties of an object should be loaded. + * Specifies which properties of an object should be loaded. This load happens when the sync() method is executed. This synchronizes the states between Office objects and corresponding JavaScript proxy objects. + * + * @remarks + * + * For Word, the preferred method for specifying the properties and paging information is by using a string literal. The first two examples show the preferred way to request the text and font size properties for paragraphs in a paragraph collection: + * + * `context.load(paragraphs, 'text, font/size');` + * + * `paragraphs.load('text, font/size');` + * + * Here is a similar example using object notation (includes paging): + * + * `context.load(paragraphs, {select: 'text, font/size', expand: 'font', top: 50, skip: 0});` + * + * `paragraphs.load({select: 'text, font/size', expand: 'font', top: 50, skip: 0});` + * + * Note that if we don't specify the specific properties on the font object in the select statement, the expand statement by itself would indicate that all of the font properties are loaded. */ interface LoadOption { /** diff --git a/types/p-timeout/index.d.ts b/types/p-timeout/index.d.ts index 882cc7adc8..40e1dc6410 100644 --- a/types/p-timeout/index.d.ts +++ b/types/p-timeout/index.d.ts @@ -5,8 +5,8 @@ export = pTimeout; -declare function pTimeout(input: Promise, ms: number, message?: string | pTimeout.TimeoutError): Promise; -declare function pTimeout(input: Promise, ms: number, fallback: () => R | Promise): Promise; +declare function pTimeout(input: PromiseLike, ms: number, message?: string | pTimeout.TimeoutError): Promise; +declare function pTimeout(input: PromiseLike, ms: number, fallback: () => R | Promise): Promise; declare namespace pTimeout { class TimeoutError extends Error { diff --git a/types/pngjs/index.d.ts b/types/pngjs/index.d.ts index d5476e9e1f..f5ac2e6d2a 100644 --- a/types/pngjs/index.d.ts +++ b/types/pngjs/index.d.ts @@ -85,7 +85,7 @@ export interface PackerOptions { export type PNGOptions = BaseOptions & ParserOptions & PackerOptions; -export type ColorType = 0 | 1 | 2 | 4; +export type ColorType = 0 | 2 | 4 | 6; export interface Metadata { width: number; diff --git a/types/pouchdb-find/index.d.ts b/types/pouchdb-find/index.d.ts index 7f5f925f8c..1ccd3d4c14 100644 --- a/types/pouchdb-find/index.d.ts +++ b/types/pouchdb-find/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for pouchdb-find 6.3 // Project: https://pouchdb.com/ // Definitions by: Jakub Navratil +// Sebastian Ramirez // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -100,7 +101,7 @@ declare namespace PouchDB { } interface FindResponse { - docs: Array>; + docs: Array>; } interface CreateIndexOptions { diff --git a/types/react-autocomplete/index.d.ts b/types/react-autocomplete/index.d.ts index 58339d3b31..0de7cd7eac 100644 --- a/types/react-autocomplete/index.d.ts +++ b/types/react-autocomplete/index.d.ts @@ -143,8 +143,27 @@ declare namespace Autocomplete { open?: boolean; debug?: boolean; } + + interface State { + /** + * True when the menu is visible. Provided to `onMenuVisibilityChange`. + */ + isOpen: boolean; + + /** + * Index of the highlighted item, `null` if none currently is. + */ + highlightedIndex: number | null; + + /** + * These three `menu___` values are used in CSS to layout the menu. + */ + menuLeft?: number; + menuTop?: number; + menuWidth?: number; + } } -declare class Autocomplete extends Component { +declare class Autocomplete extends Component { /** * Autocomplete exposes a subset of `HTMLInputElement` properties to the parent component. * They can be accessed through Autocomplete's `ref` prop. diff --git a/types/sax/index.d.ts b/types/sax/index.d.ts index 4c556d8aab..40d17caa4d 100644 --- a/types/sax/index.d.ts +++ b/types/sax/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for sax-js 1.x // Project: https://github.com/isaacs/sax-js // Definitions by: Asana +// Evert Pot // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// @@ -44,7 +45,7 @@ export interface Tag extends BaseTag { export declare function parser(strict: boolean, opt: SAXOptions): SAXParser; export declare class SAXParser { - constructor(strict: boolean, opt: SAXOptions); + constructor(strict: boolean, opt?: SAXOptions); // Methods end(): void; diff --git a/types/styled-system/index.d.ts b/types/styled-system/index.d.ts new file mode 100644 index 0000000000..ea6fdc03db --- /dev/null +++ b/types/styled-system/index.d.ts @@ -0,0 +1,603 @@ +// Type definitions for styled-system 2.3 +// Project: https://github.com/jxnblk/styled-system#readme +// Definitions by: Marshall Bowers +// Ben McCormick +// Justin Bennett +// Christopher Pappas +// Eloy Durán +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.6 + +/** + * Core + */ + +export type GlobalStyleValues = "inherit" | "initial" | "unset"; + +export interface BaseTheme { + breakpoints?: number[]; + space?: number[]; + fontSizes?: number[]; + colors?: { + [name: string]: string; + }; +} + +/** + * Space + */ + +export type ResponsiveValue = T | Array; + +export type SpaceValue = number | string; +export type ResponsiveSpaceValue = ResponsiveValue; + +export interface SpaceProps { + m?: ResponsiveSpaceValue; + mt?: ResponsiveSpaceValue; + mr?: ResponsiveSpaceValue; + mb?: ResponsiveSpaceValue; + ml?: ResponsiveSpaceValue; + mx?: ResponsiveSpaceValue; + my?: ResponsiveSpaceValue; + p?: ResponsiveSpaceValue; + pt?: ResponsiveSpaceValue; + pr?: ResponsiveSpaceValue; + pb?: ResponsiveSpaceValue; + pl?: ResponsiveSpaceValue; + px?: ResponsiveSpaceValue; + py?: ResponsiveSpaceValue; +} + +export function space(...args: any[]): any; + +/** + * Width + */ + +export type WidthValue = number | string; +export type ResponsiveWidthValue = ResponsiveValue; + +export interface WidthProps { + width?: ResponsiveWidthValue; +} + +export interface MinWidthProps { + minWidth?: ResponsiveWidthValue; +} + +export interface MaxWidthProps { + maxWidth?: ResponsiveWidthValue; +} + +export function width(...args: any[]): any; +export function minWidth(...args: any[]): any; +export function maxWidth(...args: any[]): any; + +/** + * Height + */ + +export type HeightValue = number | string; +export type ResponsiveHeightValue = ResponsiveValue; + +export interface HeightProps { + height?: ResponsiveHeightValue; +} + +export interface MinHeightProps { + minHeight?: ResponsiveHeightValue; +} + +export interface MaxHeightProps { + maxHeight?: ResponsiveHeightValue; +} + +export function height(...args: any[]): any; +export function minHeight(...args: any[]): any; +export function maxHeight(...args: any[]): any; + +/** + * Font Size + */ + +export type FontSizeValue = number | string; +export type ResponsiveFontSizeValue = ResponsiveValue; + +export interface FontSizeProps { + fontSize?: ResponsiveFontSizeValue; +} + +export function fontSize(...args: any[]): any; + +/** + * Color + */ +export type ColorValue = string; +export type ResponsiveColorValue = ResponsiveValue; + +export interface ColorProps { + color?: ResponsiveColorValue; +} + +export function color(...args: any[]): any; + +/** + * Typography + */ +export interface FontFamilyProps { + fontFamily?: string; +} +export function fontFamily(...args: any[]): any; + +export type TextAlignValue = + | "left" + | "right" + | "center" + | "justify" + | "justify-all" + | "start" + | "end" + | "match-parent"; +export type ResponsiveTextAlignValue = ResponsiveValue; + +export interface TextAlignProps { + textAlign?: ResponsiveTextAlignValue; +} + +export function textAlign(...args: any[]): any; + +export type LineHeightValue = number | string; +export type ResponsiveLineHeightValue = ResponsiveValue; +export interface LineHeightProps { + lineHeight?: ResponsiveLineHeightValue; +} +export function lineHeight(...args: any[]): any; + +export type FontWeightValue = + | GlobalStyleValues + | "normal" + | "bold" + | "lighter" + | "bolder" + | number; + +export interface FontWeightProps { + fontWeight?: FontWeightValue; +} + +export function fontWeight(...args: any[]): any; + +export type LetterSpacingValue = number | string; +export type ResponsiveLetterSpacingValue = ResponsiveValue; +export interface LetterSpacingProps { + letterSpacing?: ResponsiveLetterSpacingValue; +} +export function letterSpacing(...args: any[]): any; + +/** + * Layout + */ + +export type DisplayValue = + | "inline" + | "block" + | "contents" + | "flex" + | "grid" + | "inline-block"; +export type ResponsiveDisplayValue = ResponsiveValue; +export interface DisplayProps { + display?: ResponsiveDisplayValue; +} + +export function display(...args: any[]): any; + +export interface SizeProps { + size?: ResponsiveWidthValue | ResponsiveHeightValue; +} + +export function size(...args: any[]): any; + +export type RatioValue = SpaceValue; + +export interface RatioProps { + ratio?: RatioValue; +} + +export function ratio(...args: any[]): any; + +/** + * Flexbox + */ + +export type AlignItemsValue = + | "normal" + | "stretch" + | "center" + | "start" + | "end" + | "flex-start" + | "flex-end" + | "self-start" + | "self-end" + | "left" + | "right" + | "baseline" + | "first baseline" + | "last baseline" + | "safe center" + | "unsafe center"; +export type ResponsiveAlignItemsValue = ResponsiveValue; + +export interface AlignItemsProps { + align?: ResponsiveAlignItemsValue; + alignItems?: ResponsiveAlignItemsValue; +} + +export function alignItems(...args: any[]): any; + +export type JustifyContentValue = + | "center" + | "start" + | "end" + | "flex-start" + | "flex-end" + | "left" + | "right" + | "baseline" + | "first baseline" + | "last baseline" + | "space-between" + | "space-around" + | "space-evenly" + | "stretch" + | "safe center" + | "unsafe center"; +export type ResponsiveJustifyContentValue = ResponsiveValue< + JustifyContentValue +>; + +export interface JustifyContentProps { + justify?: ResponsiveJustifyContentValue; + justifyContent?: ResponsiveJustifyContentValue; +} + +export function justifyContent(...args: any[]): any; + +export type FlexWrapValue = true | "nowrap" | "wrap" | "wrap-reverse"; + +export interface FlexWrapProps { + flexWrap?: FlexWrapValue; +} + +export function flexWrap(...args: any[]): any; + +export type FlexDirectionValue = + | GlobalStyleValues + | "row" + | "row-reverse" + | "column" + | "column-reverse"; + +export type ResponsiveFlexDirectionValue = ResponsiveValue; + +export interface FlexDirectionProps { + flexDirection?: ResponsiveFlexDirectionValue; +} + +export function flexDirection(...args: any[]): any; + +export type FlexValue = number | string; +export type ResponsiveFlexValue = ResponsiveValue; + +export interface FlexProps { + flex?: ResponsiveFlexValue; +} + +export function flex(...args: any[]): any; + +export type AlignContentValue = + | GlobalStyleValues + | "center" + | "start" + | "end" + | "flex-start" + | "flex-end" + | "normal" + | "baseline" + | "first baseline" + | "last baseline" + | "space-between" + | "space-around" + | "space-evenly" + | "stretch" + | "safe center" + | "unsafe center"; +export type ResponsiveAlignContentValue = ResponsiveValue; + +export interface AlignContentProps { + alignContent?: ResponsiveAlignItemsValue; +} + +export function alignContent(...args: any[]): any; + +export type JustifySelfValue = + | GlobalStyleValues + | "auto" + | "normal" + | "stretch" + | "center" + | "start" + | "end" + | "flex-start" + | "flex-end" + | "self-start" + | "self-end" + | "left" + | "right" + | "baseline" + | "first baseline" + | "last baseline" + | "safe center" + | "unsafe center"; + +export type ResponsiveJustifySelfValue = ResponsiveValue; + +export interface JustifySelfProps { + justifySelf?: ResponsiveJustifySelfValue; +} + +export function justifySelf(...args: any[]): any; + +export type AlignSelfValue = + | "auto" + | "normal" + | "center" + | "start" + | "end" + | "self-start" + | "self-end" + | "flex-start" + | "flex-end" + | "left" + | "right" + | "baseline" + | "first baseline" + | "last baseline" + | "stretch" + | "safe center" + | "unsafe center"; +export type ResponsiveAlignSelfValue = ResponsiveValue; + +export interface AlignSelfProps { + alignSelf?: ResponsiveAlignSelfValue; +} + +export function alignSelf(...args: any[]): any; + +export type OrderValue = GlobalStyleValues | number; +export type ResponsiveOrderValue = ResponsiveValue; + +export interface OrderProps { + order?: ResponsiveOrderValue; +} + +export function order(...args: any[]): any; + +export type FlexBasisValue = + | GlobalStyleValues + | "auto" + | "fill" + | "max-content" + | "min-content" + | "fit-content" + | "content"; + +export interface FlexBasisProps { + // TODO: The FlexBasisValue currently really only exists for documentation + // purposes, because flex-basis also accepts `Nem` and `Npx` strings. + // Not sure there’s a way to still have the union values show up as + // auto-completion results. + flexBasis?: FlexBasisValue | string; +} + +export function flexBasis(...args: any[]): any; + +/** + * Grid Layout + */ + +// TODO: Add grid values + +/** + * Background + */ + +export type BackgroundValue = string; +export interface BackgroundProps { + background?: BackgroundValue; + bg?: BackgroundValue; +} + +export function background(...args: any[]): any; + +export type BackgroundImageValue = string; +export interface BackgroundImageProps { + /** + * Value will be wrapped in url() + */ + backgroundImage?: BackgroundImageValue; +} + +export function backgroundImage(...args: any[]): any; + +export type BackgroundSizeValue = string; +export interface BackgroundSizeProps { + backgroundSize?: BackgroundSizeValue; +} + +export function backgroundSize(...args: any[]): any; + +export type BackgroundPositionValue = string; +export interface BackgroundPositionProps { + backgroundPosition?: BackgroundPositionValue; +} + +export function backgroundPosition(...args: any[]): any; + +export type BackgroundRepeatValue = string; +export interface BackgroundRepeatProps { + backgroundRepeat?: BackgroundRepeatValue; +} + +export function backgroundRepeat(...args: any[]): any; + +/** + * Misc + */ + +export type BorderRadiusValue = string | number; +export interface BorderRadiusProps { + borderRadius?: BorderRadiusValue; +} +export function borderRadius(...args: any[]): any; + +export type BorderColorValue = string; +export interface BorderColorProps { + borderColor?: BorderColorValue; +} +export function borderColor(...args: any[]): any; + +export type BorderValue = string | number; +export type ResponsiveBorderValue = ResponsiveValue; +export interface BorderProps { + border?: ResponsiveBorderValue; + borderTop?: ResponsiveBorderValue; + borderRight?: ResponsiveBorderValue; + borderBottom?: ResponsiveBorderValue; + borderLeft?: ResponsiveBorderValue; +} +export function borders(...args: any[]): any; + +export type BoxShadowValue = string | number; +export interface BoxShadowProps { + boxShadow?: BoxShadowValue; +} +export function boxShadow(...arg: any[]): any; + +/** + * Position + */ + +export type PositionValue = + | "static" + | "relative" + | "absolute" + | "sticky" + | "fixed"; +export type ResponsivePositionValue = ResponsiveValue; +export interface PositionProps { + position?: ResponsivePositionValue; +} +export function position(...args: any[]): any; + +export type ZIndexValue = GlobalStyleValues | "auto" | number; + +export interface ZIndexProps { + zIndex?: ZIndexValue; +} +export function zIndex(...args: any[]): any; + +export type TopValue = string | number; +export type ResponsiveTopValue = ResponsiveValue; +export interface TopProps { + top?: ResponsiveTopValue; +} +export function top(...args: any[]): any; + +export type RightValue = string | number; +export type ResponsiveRightValue = ResponsiveValue; +export interface RightProps { + right?: ResponsiveRightValue; +} +export function right(...args: any[]): any; + +export type BottomValue = string | number; +export type ResponsiveBottomValue = ResponsiveValue; +export interface BottomProps { + bottom?: ResponsiveBottomValue; +} +export function bottom(...args: any[]): any; + +export type LeftValue = string | number; +export type ResponsiveLeftValue = ResponsiveValue; +export interface LeftProps { + left?: ResponsiveLeftValue; +} +export function left(...args: any[]): any; + +/** + * Pseudo-classes + */ + +export interface PseudoStyleValue { + color?: ColorValue; + backgroundColor?: ColorValue; + borderColor?: BorderColorValue; + boxShadow?: BoxShadowValue; + textDecoration?: string; +} +export type HoverValue = PseudoStyleValue; +export interface HoverProps { + hover?: HoverValue; +} +export function hover(...args: any[]): any; + +export type FocusValue = PseudoStyleValue; +export interface FocusProps { + focus?: FocusValue; +} +export function focus(...args: any[]): any; + +export type ActiveValue = PseudoStyleValue; +export interface ActiveProps { + active?: ActiveValue; +} +export function active(...args: any[]): any; + +export type DisabledValue = PseudoStyleValue; +export interface DisabledProps { + disabledStyle?: DisabledValue; +} +export function disabled(...args: any[]): any; + +/** + * Utilities + */ + +export function theme(keys: string): any; +export function themeGet(keys: string, fallback?: string): any; + +export function cleanElement(component: any): any; + +export function removeProps(props: any): any; + +/** + * Low-level style export functions + */ + +export interface LowLevelStylefunctionArguments { + prop: string; + cssProperty?: string; + key?: string; + numberToPx?: boolean; + alias?: string; + getter?: () => any; +} + +export function style(args: LowLevelStylefunctionArguments): any; + +export function responsiveStyle(args: LowLevelStylefunctionArguments): any; + +export function pseudoStyle(args: LowLevelStylefunctionArguments): any; diff --git a/types/styled-system/package.json b/types/styled-system/package.json new file mode 100644 index 0000000000..da1a3181d0 --- /dev/null +++ b/types/styled-system/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "dependencies": { + "styled-components": "^3.3.2" + } +} diff --git a/types/styled-system/styled-system-tests.tsx b/types/styled-system/styled-system-tests.tsx new file mode 100644 index 0000000000..78340eb3d8 --- /dev/null +++ b/types/styled-system/styled-system-tests.tsx @@ -0,0 +1,351 @@ +// Example uses styled-components, but styled-system works with most other css-in-js libraries as well +import * as React from "react"; +import styled from "styled-components"; +import { + themeGet, + space, + width, + fontSize, + color, + fontFamily, + display, + SpaceProps, + WidthProps, + ColorProps, + DisplayProps, + FontSizeProps, + FontFamilyProps, + textAlign, + TextAlignProps, + background, + BackgroundProps, + maxWidth, + MaxWidthProps, + lineHeight, + LineHeightProps, + FontWeightProps, + fontWeight, + letterSpacing, + LetterSpacingProps, + minWidth, + MinWidthProps, + HeightProps, + height, + MaxHeightProps, + maxHeight, + minHeight, + MinHeightProps, + size, + SizeProps, + RatioProps, + ratio, + alignItems, + AlignItemsProps, + AlignContentProps, + alignContent, + justifyContent, + JustifyContentProps, + FlexWrapProps, + flexWrap, + flexBasis, + FlexBasisProps, + borderColor, + BorderColorProps, + flexDirection, + FlexDirectionProps, + flex, + FlexProps, + justifySelf, + JustifySelfProps, + alignSelf, + AlignSelfProps, + borders, + BorderProps, + borderRadius, + BorderRadiusProps, + position, + PositionProps, + zIndex, + ZIndexProps, + top, + bottom, + left, + right, + TopProps, + BottomProps, + LeftProps, + RightProps, + boxShadow, + BoxShadowProps, + backgroundImage, + backgroundPosition, + backgroundRepeat, + backgroundSize, + BackgroundImageProps, + BackgroundPositionProps, + BackgroundRepeatProps, + BackgroundSizeProps, + hover, + HoverProps, + focus, + FocusProps, + active, + ActiveProps, + disabled, + DisabledProps +} from "styled-system"; + +interface BoxProps + extends SpaceProps, + WidthProps, + FontSizeProps, + ColorProps, + DisplayProps, + BackgroundProps, + MaxWidthProps, + MinWidthProps, + HeightProps, + MaxHeightProps, + MinHeightProps, + SizeProps, + RatioProps, + BorderColorProps, + FlexProps, + JustifySelfProps, + AlignSelfProps, + BorderProps, + BorderRadiusProps, + PositionProps, + ZIndexProps, + TopProps, + BottomProps, + LeftProps, + RightProps, + BoxShadowProps, + BackgroundImageProps, + BackgroundPositionProps, + BackgroundRepeatProps, + BackgroundSizeProps, + HoverProps, + FocusProps, + ActiveProps, + DisabledProps {} +const Box = styled.div.attrs({})` + +border-radius: ${themeGet("radii.small", "4px")}; + ${space} + ${width} + ${fontSize} + ${color} + ${display} + ${background} + ${maxWidth} + ${minWidth} + ${height} + ${maxHeight} + ${minHeight} + ${size} + ${ratio} + ${borderColor} + ${flex} + ${justifySelf} + ${alignSelf} + ${borders} + ${borderRadius} + ${position} + ${zIndex} + ${top} + ${bottom} + ${left} + ${right} + ${boxShadow} + ${backgroundImage} + ${backgroundPosition} + ${backgroundRepeat} + ${backgroundSize} + ${hover} + ${focus} + ${active} + ${disabled} +`; + +interface TextProps + extends FontSizeProps, + FontFamilyProps, + TextAlignProps, + LineHeightProps, + FontWeightProps, + LetterSpacingProps {} +const Text = styled.div.attrs({})` + ${fontSize}; + ${fontFamily}; + ${textAlign}; + ${lineHeight}; + ${fontWeight}; + ${letterSpacing}; +`; + +interface FlexComponentProps + extends AlignItemsProps, + AlignContentProps, + JustifyContentProps, + FlexWrapProps, + FlexBasisProps, + FlexDirectionProps {} +const Flex = styled.div.attrs({})` + ${alignItems}; + ${alignContent}; + ${justifyContent}; + ${flexWrap}; + ${flexBasis}; + ${flexDirection}; +`; + +const test = () => ( +
+ // width: 50% + + // font-size: 20px (theme.fontSizes[4]) + + // margin: 16px (theme.space[2]) + + // padding: 32px (theme.space[3]) + + // color + + // color: #333 (theme.colors.gray[0]) + + // background color + + // responsive width + + // responsive font-size + + // responsive margin + + // responsive padding + + // examples (margin prop) // sets margin value of `theme.space[2]` + + // sets margin value of `-1 * theme.space[2]` + + // sets a margin value of `16px` since it's greater than + `theme.space.length` + + // sets margin `'auto'` + + // sets margin `8px` on all viewports and `16px` from the smallest + breakpoint and up + + // examples // width `50%` + + // width `256px` + + // width `'2em'` + + // width `100%` on all viewports and `50%` from the smallest breakpoint + and up + + // examples // font-size of `theme.fontSizes[3]` + + // font-size `32px` + + // font-size `'2em'` + + // font-size `10px` on all viewports and `12px` from the smallest + breakpoint and up + + // examples // picks the value defined in `theme.colors['blue']` + + // picks up a nested color value using dot notation // + `theme.colors['gray'][0]` + + // raw CSS color value + + // fontFamily + + // textAlign (responsive) + + + // lineHeight + + // fontWeight + + // letterSpacing + + // display (responsive) + + + // maxWidth (responsive) + + + // minWidth (responsive) + + + // height (responsive) + + + // maxHeight (responsive) + + + // minHeight (responsive) + + + // size (responsive, width & height) + + + // ratio (height: 0 & paddingBottom) + + // alignItems (responsive) + + // alignContent (responsive) + + // justifyContent (responsive) + + // flexWrap (responsive) + + // flexBasis (responsive) + + // flexDirection (responsive) + + // flex (responsive) + + // justifySelf (responsive) + + // alignSelf (responsive) + + + + + + + // borderColor + + // borderRadius + + // position (responsive) + + // zIndex + + // top, right, bottom, left (responsive) + + // boxShadow + + // backgroundImage, backgroundSize, backgroundPosition, backgroundRepeat + + + + + +
+); diff --git a/types/styled-system/tsconfig.json b/types/styled-system/tsconfig.json new file mode 100644 index 0000000000..2cc754217f --- /dev/null +++ b/types/styled-system/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "jsx": "react", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": ["index.d.ts", "styled-system-tests.tsx"] +} diff --git a/types/styled-system/tslint.json b/types/styled-system/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/styled-system/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/three/index.d.ts b/types/three/index.d.ts index cc26a82225..88cd09c70a 100644 --- a/types/three/index.d.ts +++ b/types/three/index.d.ts @@ -33,6 +33,7 @@ export * from "./three-effectcomposer"; export * from "./three-examples"; export * from "./three-fbxloader"; export * from "./three-FirstPersonControls"; +export * from "./three-gltfexporter"; export * from "./three-maskpass"; export * from "./three-mtlloader"; export * from "./three-objloader"; diff --git a/types/three/three-gltfexporter.d.ts b/types/three/three-gltfexporter.d.ts new file mode 100644 index 0000000000..2bdba480a7 --- /dev/null +++ b/types/three/three-gltfexporter.d.ts @@ -0,0 +1,9 @@ +import { Object3D } from "three"; + +export class GLTFExporter { + constructor(); + + parse(input: Object3D, onCompleted: (gltf: object) => void, options: object): null; + +} + diff --git a/types/twit/index.d.ts b/types/twit/index.d.ts index 89d28766b3..f4a7be74b4 100644 --- a/types/twit/index.d.ts +++ b/types/twit/index.d.ts @@ -24,7 +24,7 @@ declare module 'twit' { */ export interface Contributors { id: number, - id_str: number, + id_str: string, screen_name: string, } @@ -169,7 +169,7 @@ declare module 'twit' { created_at: string, current_user_retweet?: { id: number, - id_str: number, + id_str: string, }, entities: Entities, favorite_count?: number, @@ -257,7 +257,7 @@ declare module 'twit' { id?: string, slug?: string, status?: string, - user_id?: number, + user_id?: number | string, lat?: number, long?: number, follow?: boolean, diff --git a/types/w3c-web-usb/index.d.ts b/types/w3c-web-usb/index.d.ts index d481245e14..d596351a5b 100644 --- a/types/w3c-web-usb/index.d.ts +++ b/types/w3c-web-usb/index.d.ts @@ -62,7 +62,7 @@ declare class USBAlternateInterface { readonly interfaceClass: number; readonly interfaceSubclass: number; readonly interfaceProtocol: number; - readonly alternatinterfaceName?: string; + readonly interfaceName?: string; readonly endpoints: USBEndpoint[]; } @@ -146,6 +146,7 @@ declare class USBDevice { transferOut(endpointNumber: number, data: BufferSource): Promise; isochronousTransferIn(endpointNumber: number, packetLengths: number[]): Promise; isochronousTransferOut(endpointNumber: number, data: BufferSource, packetLengths: number[]): Promise; + reset(): Promise; } interface Navigator { diff --git a/types/w3c-web-usb/w3c-web-usb-tests.ts b/types/w3c-web-usb/w3c-web-usb-tests.ts index fe29480479..49efebcdbc 100644 --- a/types/w3c-web-usb/w3c-web-usb-tests.ts +++ b/types/w3c-web-usb/w3c-web-usb-tests.ts @@ -43,6 +43,7 @@ navigator.usb.addEventListener('disconnect', evt => { }); async function handleConnectedDevice(device: USBDevice) { + await device.reset(); connectedDevices.push(device); await device.open(); diff --git a/types/webpack-serve/index.d.ts b/types/webpack-serve/index.d.ts index 5a1a302af0..f0426c5ad7 100644 --- a/types/webpack-serve/index.d.ts +++ b/types/webpack-serve/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for webpack-serve 1.0 // Project: https://github.com/webpack-contrib/webpack-serve // Definitions by: Ryan Clark +// Jokcy // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -21,7 +22,7 @@ declare module 'webpack' { } declare function WebpackServe( - { config }: { config: webpack.Configuration } + options: WebpackServe.Options ): Promise; declare namespace WebpackServe { diff --git a/types/webpack-serve/webpack-serve-tests.ts b/types/webpack-serve/webpack-serve-tests.ts index 2a29cec317..d22c1adfea 100644 --- a/types/webpack-serve/webpack-serve-tests.ts +++ b/types/webpack-serve/webpack-serve-tests.ts @@ -1,19 +1,25 @@ import webpack = require('webpack'); import serve = require('webpack-serve'); -const compiler = webpack(); +const config: webpack.Configuration = { + mode: 'development', + entry: ['index.js'], // when use compiler entry must be array or object +}; + +const serveConfig = { + http2: true, + dev: { + publicPath: '/', + logLevel: 'info' + }, + host: 'localhost' +}; + +const compiler = webpack(config); const server = serve({ - config: { - serve: { - http2: true, - dev: { - publicPath: '/', - logLevel: 'info' - }, - host: 'localhost' - }, - }, + compiler, + ...serveConfig }); server @@ -22,3 +28,25 @@ server server.close(); }); }); + +const config2: webpack.Configuration = { + ...config, + serve: { + ...serveConfig, + port: 8888, + hot: { + port: 8889 + } + }, +}; + +const server2 = serve({ + config: config2 +}); + +server2 + .then((server) => { + server.on('listening', () => { + server.close(); + }); + }); diff --git a/types/webpack/index.d.ts b/types/webpack/index.d.ts index 55d7dbd801..d482955d2c 100644 --- a/types/webpack/index.d.ts +++ b/types/webpack/index.d.ts @@ -61,24 +61,22 @@ declare namespace webpack { /** Like resolve but for loaders. */ resolveLoader?: ResolveLoader; /** - * Specify dependencies that shouldn’t be resolved by webpack, but should become dependencies of the resulting bundle. - * The kind of the dependency depends on output.libraryTarget. + * Specify dependencies that shouldn’t be resolved by webpack, but should become dependencies of the resulting bundle. + * The kind of the dependency depends on output.libraryTarget. */ externals?: ExternalsElement | ExternalsElement[]; /** - *
    - *
  • "web" Compile for usage in a browser-like environment (default)
  • - *
  • "webworker" Compile as WebWorker
  • - *
  • "node" Compile for usage in a node.js-like environment (use require to load chunks)
  • - *
  • "async-node" Compile for usage in a node.js-like environment (use fs and vm to load chunks async)
  • - *
  • "node-webkit" Compile for usage in webkit, uses jsonp chunk loading but also supports builtin node.js modules plus require(“nw.gui”) (experimental)
  • - *
  • "atom" Compile for usage in electron (formerly known as atom-shell), supports require for modules necessary to run Electron.
  • - *
  • "electron-renderer" Compile for Electron for renderer process, providing a target using JsonpTemplatePlugin, FunctionModulePlugin - * for browser environments and NodeTargetPlugin and ExternalsPlugin for CommonJS and Electron built-in modules.
  • - *
  • "electron-main" Compile for Electron for main process.
  • - *
  • "atom" Alias for electron-main
  • - *
  • "electron" Alias for electron-main
  • - *
      + * - "web" Compile for usage in a browser-like environment (default). + * - "webworker" Compile as WebWorker. + * - "node" Compile for usage in a node.js-like environment (use require to load chunks). + * - "async-node" Compile for usage in a node.js-like environment (use fs and vm to load chunks async). + * - "node-webkit" Compile for usage in webkit, uses jsonp chunk loading but also supports builtin node.js modules plus require(“nw.gui”) (experimental) + * - "atom" Compile for usage in electron (formerly known as atom-shell), supports require for modules necessary to run Electron. + * - "electron-renderer" Compile for Electron for renderer process, providing a target using JsonpTemplatePlugin, FunctionModulePlugin for browser + * environments and NodeTargetPlugin and ExternalsPlugin for CommonJS and Electron built-in modules. + * - "electron-main" Compile for Electron for main process. + * - "atom" Alias for electron-main. + * - "electron" Alias for electron-main. */ target?: 'web' | 'webworker' | 'node' | 'async-node' | 'node-webkit' | 'atom' | 'electron' | 'electron-renderer' | 'electron-main' | ((compiler?: any) => void); /** Report the first error as a hard error instead of tolerating it. */ @@ -171,17 +169,15 @@ declare namespace webpack { library?: string | string[]; /** * Which format to export the library: - *
        - *
      • "var" - Export by setting a variable: var Library = xxx (default)
      • - *
      • "this" - Export by setting a property of this: this["Library"] = xxx
      • - *
      • "commonjs" - Export by setting a property of exports: exports["Library"] = xxx
      • - *
      • "commonjs2" - Export by setting module.exports: module.exports = xxx
      • - *
      • "amd" - Export to AMD (optionally named)
      • - *
      • "umd" - Export to AMD, CommonJS2 or as property in root
      • - *
      • "window" - Assign to window
      • - *
      • "assign" - Assign to a global variable
      • - *
      • "jsonp" - Generate Webpack JSONP module
      • - *
      + * - "var" - Export by setting a variable: var Library = xxx (default) + * - "this" - Export by setting a property of this: this["Library"] = xxx + * - "commonjs" - Export by setting a property of exports: exports["Library"] = xxx + * - "commonjs2" - Export by setting module.exports: module.exports = xxx + * - "amd" - Export to AMD (optionally named) + * - "umd" - Export to AMD, CommonJS2 or as property in root + * - "window" - Assign to window + * - "assign" - Assign to a global variable + * - "jsonp" - Generate Webpack JSONP module */ libraryTarget?: 'var' | 'this' | 'commonjs' | 'commonjs2' | 'amd' | 'umd' | 'window' | 'assign' | 'jsonp'; /** Configure which module or modules will be exposed via the `libraryTarget` */ @@ -955,42 +951,9 @@ declare namespace webpack { usedModuleIds: any; getStats(): Stats; addModule(module: CompilationModule, cacheGroup: any): any; - // getModule(module) - // findModule(identifier) - // waitForBuildingFinished(module, callback) - // buildModule(module, optional, origin, dependencies, thisCallback) - // processModuleDependencies(module, callback) - // addModuleDependencies(module, dependencies, bail, cacheGroup, recursive, callback) // tslint:disable-next-line:ban-types addEntry(context: any, entry: any, name: any, callback: Function): void; - // prefetch(context, dependency, callback) - // rebuildModule(module, thisCallback) - // finish() - // unseal() - // seal(callback) - // sortModules(modules) - // reportDependencyErrorsAndWarnings(module, blocks) - // addChunkInGroup(name, module, loc, request) - // addChunk(name) - // assignIndex(module) - // assignDepth(module) - // processDependenciesBlocksForChunkGroups(inputChunkGroups) - // removeReasonsOfDependencyBlock(module, block) - // patchChunksAfterReasonRemoval(module, chunk) - // removeChunkFromDependencies(block, chunk) - // applyModuleIds() - // applyChunkIds() - // sortItemsWithModuleIds() - // sortItemsWithChunkIds() - // summarizeDependencies() - // createHash() - // modifyHash(update) - // createModuleAssets() - // createChunkAssets() getPath(filename: string, data: {hash?: any, chunk?: any, filename?: string, basename?: string, query?: any}): string; - // createChildCompiler(name, outputOptions, plugins) - // checkConstraints() - /** * @deprecated Compilation.applyPlugins is deprecated. Use new API on `.hooks` instead */ @@ -1131,10 +1094,14 @@ declare namespace webpack { | 'verbose'; interface ToJsonOptionsObject { + /** fallback value for stats options when an option is not defined (has precedence over local webpack defaults) */ + all?: boolean; /** Add asset Information */ assets?: boolean; /** Sort assets by a field */ assetsSort?: string; + /** Add built at time information */ + builtAt?: boolean; /** Add information about cached (not built) modules */ cached?: boolean; /** Show cached assets (setting this to `false` only shows emitted files) */ diff --git a/types/webpack/webpack-tests.ts b/types/webpack/webpack-tests.ts index b7b9ca8913..913eea0b19 100644 --- a/types/webpack/webpack-tests.ts +++ b/types/webpack/webpack-tests.ts @@ -383,6 +383,7 @@ webpack({ const jsonStatsWithAllOptions = stats.toJson({ assets: true, assetsSort: "field", + builtAt: true, cached: true, children: true, chunks: true,