;
}
- interface IOnShowEvent {
- /**
- * @description Call this to prevent showing the context menu.
- * @memberof IOnShowEvent
- */
+ interface OnShowEvent {
+ /** Call this to prevent showing the context menu. */
preventDefault: () => void;
}
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 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.
+ * 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 targetOrigin Specifies what the origin of the guest window must be for the event to be dispatched.
*/
postMessage(message: any, targetOrigin: string): void;
-
}
interface DialogController {
-
/**
- * @description Accept the dialog. Equivalent to clicking OK in an alert, confirm, or prompt dialog.
- * @param {string} response The response string to provide to the guest when accepting a prompt dialog.
+ * Accept the dialog. Equivalent to clicking OK in an alert, confirm, or prompt dialog.
+ * @param response The response string to provide to the guest when accepting a prompt dialog.
*/
ok(response?: string): void;
-
- /**
- * @description Reject the dialog. Equivalent to clicking Cancel in a confirm or prompt dialog.
- */
+ /** Reject the dialog. Equivalent to clicking Cancel in a confirm or prompt dialog. */
cancel(): void;
-
}
- /**Contains all of the results of the find request. */
+ /** Contains all of the results of the find request. */
interface FindCallbackResults {
-
- /**
- * @description The number of times searchText was matched on the page.
- */
- numberOfMatches: number
-
- /**
- * @description The ordinal number of the current match.
- */
- activeMatchOrdinal: number
-
- /**
- * @description Describes a rectangle around the active match in screen coordinates.
- */
- selectionRect: SelectionRect
-
- /**
- * @description Indicates whether this find request was canceled.
- */
- canceled: boolean
+ /** The number of times searchText was matched on the page. */
+ numberOfMatches: number;
+ /** The ordinal number of the current match. */
+ activeMatchOrdinal: number;
+ /** Describes a rectangle around the active match in screen coordinates. */
+ selectionRect: SelectionRect;
+ /** Indicates whether this find request was canceled. */
+ canceled: boolean;
}
- /**Options for the find request. */
interface FindOptions {
-
/**
- * @description Flag to find matches in reverse order. The default value is false.
+ * Flag to find matches in reverse order.
+ * @default false
*/
- backward?: boolean
-
+ backward?: boolean;
/**
- * @description Flag to match with case-sensitivity. The default value is false.
+ * Flag to match with case-sensitivity.
+ * @default false
*/
- matchCase?: boolean
+ matchCase?: boolean;
}
interface NewWindow {
-
/**
- * @description Attach the requested target page to an existing webview element.
- * @param {object} webview The webview element to which the target page should be attached.
+ * Attach the requested target page to an existing webview element.
+ * @param webview The webview element to which the target page should be attached.
*/
- attach(webview: object): void;
-
+ attach(webview: HTMLWebViewElement): void;
/**
- * @description Cancel the new window request.
+ * Cancel the new window request.
*/
discard(): void;
-
}
- interface MediaPermissionRequest {
-
- /**
- * @description Allow the permission request.
- */
+ interface PermissionRequestHandler {
+ /** Allow the permission request. */
allow(): void;
-
- /**
- * @description Deny the permission request. This is the default behavior if allow is not called.
- */
+ /** Deny the permission request. This is the default behavior if allow is not called. */
deny(): void;
-
- }
- interface GeolocationPermissionRequest {
-
- /**
- * @description Allow the permission request.
- */
- allow(): void;
-
- /**
- * @description Deny the permission request. This is the default behavior if allow is not called.
- */
- deny(): void;
-
- }
- interface PointerLockPermissionRequest {
-
- /**
- * @description Allow the permission request.
- */
- allow(): void;
-
- /**
- * @description Deny the permission request. This is the default behavior if allow is not called.
- */
- deny(): void;
-
- }
- interface DownloadPermissionRequest {
-
- /**
- * @description Allow the permission request.
- */
- allow(): void;
-
- /**
- * @description Deny the permission request. This is the default behavior if allow is not called.
- */
- deny(): void;
-
- }
- interface FileSystemPermissionRequest {
-
- /**
- * @description Allow the permission request.
- */
- allow(): void;
-
- /**
- * @description Deny the permission request.
- */
- deny(): void;
-
- }
- interface FullscreenPermissionRequest {
-
- /**
- * @description Allow the permission request.
- */
- allow(): void;
-
- /**
- * @description Deny the permission request.
- */
- deny(): void;
-
- }
- interface LoadPluginPermissionRequest {
-
- /**
- * @description Allow the permission request. This is the default behavior if deny is not called..
- */
- allow(): void;
-
- /**
- * @description Deny the permission request.
- */
- deny(): void;
-
}
/**
- * Fescribes a rectangle in screen coordinates.
+ * 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.
**/
interface SelectionRect {
-
- /**
- * @description Distance from the left edge of the screen to the left edge of the rectangle.
- */
- left: number
-
- /**
- * @description Distance from the top edge of the screen to the top edge of the rectangle.
- */
- top: number
-
- /**
- * @description Width of the rectangle.
- */
- width: number
-
- /**
- * @description Height of the rectangle.
- */
- height: number
+ /** Distance from the left edge of the screen to the left edge of the rectangle. */
+ left: number;
+ /** Distance from the top edge of the screen to the top edge of the rectangle. */
+ top: number;
+ /** Width of the rectangle. */
+ width: number;
+ /** Height of the rectangle. */
+ height: number;
}
/**
- * @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 which provides access to webRequest events on the guest page.
+ * @see[chrome.webRequest]{@link http://developer.chrome.com/extensions/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/*:
+ * @example
+ * webview.request.onBeforeRequest.addListener(
+ * function(details) { return {cancel: true}; }, {urls: ['*://www.evil.com/*']}, ['blocking']);
+ * @description
+ * Additionally, this interface supports declarative webRequest rules through onRequest and onMessage events.
+ * @see[Docs]{@link 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 const rule = { conditions: [ new chrome.webViewRequest.RequestMatcher({ url: { hostSuffix: 'example.com' } }) ], actions: [ new chrome.webViewRequest.CancelRequest() ] }; myWebview.request.onRequest.addRules([rule]);
**/
interface WebRequestEventInterface {
+ /** @todo TODO */
}
/**
* Defines the how zooming is handled in the webview.
* Enum values:
* '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.
+ * > 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'
- * * 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).
+ * > 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'
- * * 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';
-
- export enum ConsoleMessageLevel {
- LOG_VERBOSE = -1,
- LOG_INFO = 0,
- LOG_WARNING = 1,
- LOG_ERROR = 2
- }
- interface IConsoleMessage {
-
+ * > Disables all zooming in the webview.
+ * The content will revert to the default zoom level,
+ * and all attempted zoom changes will be ignored.
+ **/
+ type ZoomMode =
+ 'per-origin' |
+ 'per-view' |
+ 'disabled';
+ type ConsoleMessageLevel = -1 | 0 | 1 | 2;
+ type LoadAbortReason =
+ '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';
+ interface ConsoleMessage {
/**
- * @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.
+ * 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: ConsoleMessageLevel;
-
- /**
- * @description The logged message contents.
- */
- message: string
-
- /**
- * @description The line number of the message source.
- */
- line: number
-
- /**
- * @description A string identifying the resource which logged the message.
- */
- sourceId: string
+ /** The logged message contents. */
+ message: string;
+ /** The line number of the message source. */
+ line: number;
+ /** A string identifying the resource which logged the message. */
+ sourceId: string;
}
- interface IDialog {
+ type DialogMessageType =
+ 'alert' |
+ 'confirm' |
+ 'prompt';
+ interface Dialog {
/**
- * @description The type of modal dialog requested by the guest.
+ * The type of modal dialog requested by the guest.
*/
- messageType: 'alert' | 'confirm' | 'prompt'
-
+ messageType: DialogMessageType;
/**
- * @description The text the guest attempted to display in the modal dialog.
+ * The text the guest attempted to display in the modal dialog.
*/
- messageText: string
-
+ messageText: string;
/**
- * @description An interface that can be used to respond to the guest's modal request.
+ * An interface that can be used to respond to the guest's modal request.
*/
- dialog: DialogController
+ dialog: DialogController;
}
- interface IExit {
-
- /**
- * @description Chrome's internal ID of the process that exited.
- */
- processID: number
-
- /**
- * @description String indicating the reason for the exit.
- */
- reason: 'normal' | 'abnormal' | 'crash' | 'kill'
+ type ExitReason =
+ 'normal' |
+ 'abnormal' |
+ 'crash' |
+ 'kill';
+ interface Exit {
+ /** Chrome's internal ID of the process that exited. */
+ processID: number;
+ /** String indicating the reason for the exit. */
+ reason: ExitReason;
}
- interface IFindupdate {
-
+ interface FindUpdate {
/**
- * @description The string that is being searched for in the page.
+ * The string that is being searched for in the page.
*/
- searchText: string
-
+ searchText: string;
/**
- * @description The number of matches found for searchText on the page so far.
+ * The number of matches found for searchText on the page so far.
*/
- numberOfMatches: number
-
+ numberOfMatches: number;
/**
- * @description The ordinal number of the current active match, if it has been found. This will be 0 until then.
+ * The ordinal number of the current active match,
+ * if it has been found. This will be 0 until then.
*/
- activeMatchOrdinal: number
-
+ activeMatchOrdinal: number;
/**
- * @description Describes a rectangle around the active match, if it has been found, in screen coordinates.
+ * Describes a rectangle around the active match,
+ * if it has been found, in screen coordinates.
*/
- selectionRect: SelectionRect
-
+ selectionRect: SelectionRect;
/**
- * @description Indicates whether the find request was canceled.
+ * Indicates whether the find request was canceled.
*/
- canceled: boolean
-
+ canceled: boolean;
/**
- * @description Indicates that all find requests have completed and that no more findupdate events will be fired until more find requests are made.
+ * Indicates that all find requests have completed
+ * and that no more findupdate events will be fired
+ * until more find requests are made.
*/
- finalUpdate: string
+ finalUpdate: string;
}
- interface ILoadabort {
-
+ interface LoadAbort {
+ /** Requested URL. */
+ url: string;
+ /** Whether the load was top-level or in a subframe. */
+ isTopLevel: boolean;
/**
- * @description Requested URL.
+ * Unique integer ID for the type of abort.
+ * Note that this ID is `not` guaranteed to
+ * remain backwards compatible between releases.
+ * You must not act based upon this specific integer.
*/
- url: string
-
+ code: integer;
/**
- * @description Whether the load was top-level or in a subframe.
+ * String indicating what type of abort occurred.
+ * This string is `not` guaranteed to remain
+ * backwards compatible between releases.
+ * You must not parse and act based upon its content.
+ * It is also possible that, in some cases,
+ * an error not listed here could be reported.
*/
- isTopLevel: boolean
-
- /**
- * @description Unique integer ID for the type of abort. Note that this ID is not guaranteed to remain backwards compatible between releases. You must not act based upon this specific integer.
- */
- code: number
-
- /**
- * @description String indicating what type of abort occurred. This string is not guaranteed to remain backwards compatible between releases. You must not parse and act based upon its content. It is also possible that, in some cases, an error not listed here could be reported.
- */
- 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'
+ reason: LoadAbortReason;
}
- interface ILoadcommit {
-
- /**
- * @description The URL that committed.
- */
- url: string
-
- /**
- * @description Whether the load is top-level or in a subframe.
- */
- isTopLevel: boolean
+ interface LoadCommit {
+ /** The URL that committed. */
+ url: string;
+ /** Whether the load is top-level or in a subframe. */
+ isTopLevel: boolean;
}
- /**ILoadredirect (Auto generated interface) */
- interface ILoadredirect {
-
- /**
- * @description The requested URL before the redirect.
- */
- oldUrl: string
-
- /**
- * @description The new URL after the redirect.
- */
- newUrl: string
-
- /**
- * @description Whether or not the redirect happened at top-level or in a subframe.
- */
- isTopLevel: boolean
+ interface LoadRedirect {
+ /** The requested URL before the redirect. */
+ oldUrl: string;
+ /** The new URL after the redirect. */
+ newUrl: string;
+ /** Whether or not the redirect happened at top-level or in a subframe. */
+ isTopLevel: boolean;
}
- /**ILoadstart (Auto generated interface) */
- interface ILoadstart {
-
- /**
- * @description Requested URL.
- */
- url: string
-
- /**
- * @description Whether the load is top-level or in a subframe.
- */
- isTopLevel: boolean
+ interface LoadStart {
+ /** Requested URL. */
+ url: string;
+ /** Whether the load is top-level or in a subframe. */
+ isTopLevel: boolean;
}
- /**INewwindow (Auto generated interface) */
- interface INewwindow {
-
+ type WindowOpenDisposition =
+ 'ignore' |
+ 'save_to_disk' |
+ 'current_tab' |
+ 'new_background_tab' |
+ 'new_foreground_tab' |
+ 'new_window' |
+ 'new_popup';
+ interface NewWindow {
/**
- * @description An interface that can be used to either attach the requested target page to an existing webview element or explicitly discard the request.
- */
- window: NewWindow
+ * An interface that can be used to either attach the requested
+ * target page to an existing webview element or explicitly
+ * discard the request.
+ **/
+ window: NewWindow;
- /**
- * @description The target URL requested for the new window.
- */
- targetUrl: string
+ /** The target URL requested for the new window. */
+ targetUrl: string;
- /**
- * @description The initial width requested for the new window.
- */
- initialWidth: number
+ /** The initial width requested for the new window. */
+ initialWidth: number;
- /**
- * @description The initial height requested for the new window.
- */
- initialHeight: number
+ /** The initial height requested for the new window. */
+ initialHeight: number;
- /**
- * @description The requested name of the new window.
- */
- name: string
+ /** The requested name of the new window. */
+ name: string;
- /**
- * @description The requested disposition of the new window.
- */
- windowOpenDisposition: 'ignore' | 'save_to_disk' | 'current_tab' | 'new_background_tab' | 'new_foreground_tab' | 'new_window' | 'new_popup'
+ /** The requested disposition of the new window. */
+ windowOpenDisposition: WindowOpenDisposition;
}
- interface IPermissionrequest {
-
- /**
- * @description The type of permission being requested.
- */
- permission: 'media' | 'geolocation' | 'pointerLock' | 'download' | 'loadplugin' | 'filesystem' | 'fullscreen'
-
- /**
- * @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: GeolocationPermissionRequest | PointerLockPermissionRequest | DownloadPermissionRequest | LoadPluginPermissionRequest | FullscreenPermissionRequest;
+ type RequestedPermission =
+ 'media' |
+ 'geolocation' |
+ 'pointerLock' |
+ 'download' |
+ 'loadplugin' |
+ 'filesystem' |
+ 'fullscreen';
+ interface PermissionRequest {
+ /** The type of permission being requested. */
+ permission: RequestedPermission;
+ /** An object which holds details of the requested permission.*/
+ request: PermissionRequestHandler;
}
-
- /**IResponsive (Auto generated interface) */
- interface IResponsive {
-
- /**
- * @description Chrome's internal ID of the process that became responsive.
- */
- processID: number
+ interface ProcessResponsive {
+ /** Chrome's internal ID of the process that became responsive. */
+ processID: number;
}
- /**ISizechanged (Auto generated interface) */
- interface ISizechanged {
-
- /**
- * @description Old width of embedded web content.
- */
- oldWidth: number
-
- /**
- * @description Old height of embedded web content.
- */
- oldHeight: number
-
- /**
- * @description New width of embedded web content.
- */
- newWidth: number
-
- /**
- * @description New height of embedded web content.
- */
- newHeight: number
+ interface SizeChanged {
+ /** Old width of embedded web content. */
+ oldWidth: number;
+ /** Old height of embedded web content. */
+ oldHeight: number;
+ /** New width of embedded web content. */
+ newWidth: number;
+ /** New height of embedded web content. */
+ newHeight: number;
}
- /**IUnresponsive (Auto generated interface) */
- interface IUnresponsive {
-
- /**
- * @description Chrome's internal ID of the process that has become unresponsive.
- */
- processID: number
+ interface ProcessUnresponsive {
+ /** Chrome's internal ID of the process that has become unresponsive. */
+ processID: number;
}
- /**IZoomchange (Auto generated interface) */
- interface IZoomchange {
-
- /**
- * @description The page's previous zoom factor.
- */
- oldZoomFactor: number
-
- /**
- * @description The new zoom factor that the page was zoomed to.
- */
- newZoomFactor: number
+ interface ZoomChange {
+ /** The page's previous zoom factor. */
+ oldZoomFactor: number;
+ /** The new zoom factor that the page was zoomed to. */
+ newZoomFactor: number;
}
-
}
+ /////////////
+ // METHODS //
+ /////////////
+
+ /**
+ * Different page speed and load metrics
+ */
+ function csi(): {
+ onloadT: number;
+ pageT: number;
+ startE: number;
+ tran: number;
+ }
+
+ /**
+ * @deprecated Deprecated in Chrome 64.
+ * chrome.loadTimes() is a non-standard API that exposes loading metrics
+ * and network information to developers in order to help them better
+ * understand their site's performance in the real world.
+ * @see[Use this instead]{@link https://www.w3.org/TR/navigation-timing-2/}
+ * @see[Deprecation article]{@link https://developers.google.com/web/updates/2017/12/chrome-loadtimes-deprecated}
+ */
+ function loadTimes(): chrome.deprecatedButUsable;
}
/////////////////////
diff --git a/types/chrome-apps/test/index.ts b/types/chrome-apps/test/index.ts
index c0dc6402a6..3babb0b80e 100644
--- a/types/chrome-apps/test/index.ts
+++ b/types/chrome-apps/test/index.ts
@@ -1,8 +1,8 @@
import runtime = chrome.app.runtime;
-import cwindow = chrome.app.window;
+const cwindow = chrome.app.window;
-const createOptions: cwindow.CreateWindowOptions = {
- id: "My Window",
+const createOptions: chrome.app.CreateWindowOptions = {
+ id: 'My Window',
bounds: {
left: 0,
top: 0,
@@ -14,7 +14,7 @@ const createOptions: cwindow.CreateWindowOptions = {
//Create new window on app launch
chrome.app.runtime.onLaunched.addListener(function (launchData: runtime.LaunchData) {
- chrome.app.window.create('app/url', createOptions, function (created_window: cwindow.AppWindow) {
+ chrome.app.window.create('app/url', createOptions, function (created_window: chrome.app.AppWindow) {
return;
});
});
@@ -22,9 +22,9 @@ chrome.app.runtime.onLaunched.addListener(function (launchData: runtime.LaunchDa
chrome.app.runtime.onRestarted.addListener(function () { return; });
// retrieving windows
-var currentWindow: cwindow.AppWindow = chrome.app.window.current();
-var otherWindow: cwindow.AppWindow = chrome.app.window.get('some-string');
-var allWindows: cwindow.AppWindow[] = chrome.app.window.getAll();
+var currentWindow: chrome.app.AppWindow = chrome.app.window.current();
+var otherWindow: chrome.app.AppWindow = chrome.app.window.get('some-string');
+var allWindows: chrome.app.AppWindow[] = chrome.app.window.getAll();
// listening to window events
currentWindow.onBoundsChanged.addListener(function () { return; });
@@ -42,11 +42,11 @@ var visibleEverywhere: boolean = chrome.app.window.canSetVisibleOnAllWorkspaces(
function test_fileSystem(): void {
var accepts: chrome.fileSystem.AcceptOptions[] = [
- { mimeTypes: ["text/*"], extensions: ['js', 'css', 'txt', 'html', 'xml', 'tsv', 'csv', 'rtf'] }
+ { mimeTypes: ['text/*'], extensions: ['js', 'css', 'txt', 'html', 'xml', 'tsv', 'csv', 'rtf'] }
];
var chooseOption: chrome.fileSystem.ChooseEntryOptions = {
- type: "openFile",
- suggestedName: "foo.txt",
+ type: 'openFile',
+ suggestedName: 'foo.txt',
accepts: accepts,
acceptsAllTypes: false,
acceptsMultiple: false
@@ -98,7 +98,7 @@ function test_socketsTcp(): void {
chrome.sockets.tcp.setNoDelay(socketId, true, (result: number) => { });
// connect
- chrome.sockets.tcp.connect(socketId, "192.168.0.1", 8080, (result: number) => { });
+ chrome.sockets.tcp.connect(socketId, '192.168.0.1', 8080, (result: number) => { });
// disconnect
chrome.sockets.tcp.disconnect(socketId);
@@ -132,7 +132,7 @@ function testSocketsTcpTypes(): void {
properties = {
persistent: true,
- name: "test",
+ name: 'test',
bufferSize: 1024
};
@@ -146,11 +146,11 @@ function testSocketsTcpTypes(): void {
connected: false
};
- socketInfo.name = "test";
+ socketInfo.name = 'test';
socketInfo.bufferSize = 1024;
- socketInfo.localAddress = "192.168.0.2";
+ socketInfo.localAddress = '192.168.0.2';
socketInfo.localPort = 8000;
- socketInfo.peerAddress = "192.168.0.3";
+ socketInfo.peerAddress = '192.168.0.3';
socketInfo.peerPort = 1000;
}
@@ -178,10 +178,10 @@ function test_socketsUdp(): void {
chrome.sockets.udp.setPaused(socketId, true, () => { });
// bind
- chrome.sockets.udp.bind(socketId, "0.0.0.0", 8080, (result: number) => { });
+ chrome.sockets.udp.bind(socketId, '0.0.0.0', 8080, (result: number) => { });
// send
- chrome.sockets.udp.send(socketId, buffer, "172.21.0.1", 10080, (info: chrome.sockets.udp.SendInfo) => { });
+ chrome.sockets.udp.send(socketId, buffer, '172.21.0.1', 10080, (info: chrome.sockets.udp.SendInfo) => { });
// close
chrome.sockets.udp.close(socketId);
@@ -194,10 +194,10 @@ function test_socketsUdp(): void {
chrome.sockets.udp.getSockets((infos: chrome.sockets.udp.SocketInfo[]) => { });
// joinGroup
- chrome.sockets.udp.joinGroup(socketId, "224.0.0.1", (result: number) => { });
+ chrome.sockets.udp.joinGroup(socketId, '224.0.0.1', (result: number) => { });
// leaveGroup
- chrome.sockets.udp.leaveGroup(socketId, "224.0.0.1", (result: number) => { });
+ chrome.sockets.udp.leaveGroup(socketId, '224.0.0.1', (result: number) => { });
// setMulticastTimeToLive
chrome.sockets.udp.setMulticastTimeToLive(socketId, 100, (result: number) => { });
@@ -223,7 +223,7 @@ function testSocketsUdpTypes(): void {
properties = {
persistent: true,
- name: "test",
+ name: 'test',
bufferSize: 1024
};
@@ -236,9 +236,9 @@ function testSocketsUdpTypes(): void {
paused: true
};
- socketInfo.name = "test";
+ socketInfo.name = 'test';
socketInfo.bufferSize = 1024;
- socketInfo.localAddress = "192.168.0.2";
+ socketInfo.localAddress = '192.168.0.2';
socketInfo.localPort = 8000;
}
@@ -266,8 +266,8 @@ function test_socketsTcpServer(): void {
chrome.sockets.tcpServer.setPaused(socketId, true, () => { });
// listen
- chrome.sockets.tcpServer.listen(socketId, "0.0.0.0", 80, (result: number) => { });
- chrome.sockets.tcpServer.listen(socketId, "0.0.0.0", 80, 128, (result: number) => { });
+ chrome.sockets.tcpServer.listen(socketId, '0.0.0.0', 80, (result: number) => { });
+ chrome.sockets.tcpServer.listen(socketId, '0.0.0.0', 80, 128, (result: number) => { });
// disconnect
chrome.sockets.tcp.disconnect(socketId);
@@ -298,7 +298,7 @@ function testSocketsTcpServerTypes(): void {
properties = {
persistent: true,
- name: "test"
+ name: 'test'
};
// SocketInfo
@@ -310,8 +310,8 @@ function testSocketsTcpServerTypes(): void {
paused: true
};
- socketInfo.name = "test";
- socketInfo.localAddress = "192.168.0.2";
+ socketInfo.name = 'test';
+ socketInfo.localAddress = '192.168.0.2';
socketInfo.localPort = 8000;
}
@@ -340,7 +340,7 @@ wve.addEventListener('close', () => {
return;
});
wve.addEventListener('consolemessage', (ev) => {
- if (ev.level === chrome.webview.ConsoleMessageLevel.LOG_ERROR) {
+ if (ev.level === 2) {
const msg = ev.message;
}
});
@@ -360,4 +360,177 @@ wve.addEventListener('loadredirect', (ev) => {
return ev.newUrl || ev.oldUrl;
});
-chrome.bluetoothLowEnergy.connect('1111111', () => { });
+chrome.bluetooth.getAdapterState((adapter) => {
+ console.log('Adapter ' + adapter.address + ': ' + adapter.name);
+});
+
+chrome.bluetooth.getDevices((devices) => {
+ for (const device of devices) {
+ console.log(device.address);
+ }
+});
+
+chrome.bluetooth.onDeviceAdded.addListener((device) => {
+ let uuid = '0000180d-0000-1000-8000-00805f9b34fb';
+ if (!device.uuids || device.uuids.indexOf(uuid) < 0)
+ return;
+
+ // The device has a service with the desired UUID.
+ chrome.bluetoothLowEnergy.connect(device.address, () => {
+ if (chrome.runtime.lastError) {
+ console.log('Failed to connect: ' + chrome.runtime.lastError.message);
+ return;
+ }
+ // Connected! Do stuff...
+ });
+});
+
+const uuid = '1105';
+
+chrome.bluetooth.getDevices((devices) => {
+ chrome.bluetoothSocket.create((createInfo) => {
+ chrome.bluetoothSocket.connect(createInfo.socketId,
+ devices[0].address, uuid, () => {
+ if (chrome.runtime.lastError) {
+ console.log('Connection failed: ' + chrome.runtime.lastError.message);
+ } else {
+ chrome.bluetoothSocket.send(createInfo.socketId, new ArrayBuffer(4096), (bytes_sent) => {
+ if (chrome.runtime.lastError) {
+ console.log('Send failed: ' + chrome.runtime.lastError.message);
+ } else {
+ console.log('Sent ' + bytes_sent + ' bytes')
+ }
+ });
+ }
+ });
+ chrome.bluetoothSocket.onReceive.addListener((receiveInfo) => {
+ if (receiveInfo.socketId != createInfo.socketId)
+ return;
+ // receiveInfo.data is an ArrayBuffer.
+ });
+ });
+});
+
+chrome.hid.getDevices({
+ filters: [
+ { vendorId: 5 }
+ ]
+}, (devices) => {
+ const productId = devices[0].productId;
+ chrome.hid.getUserSelectedDevices((selectedDevices) => {
+ const hmm = selectedDevices.productId == productId ? selectedDevices.vendorId : selectedDevices.maxFeatureReportSize;
+ });
+});
+
+chrome.syncFileSystem.getConflictResolutionPolicy((policy) => {
+ if (policy === 'manual') {
+ chrome.syncFileSystem.requestFileSystem((fs) => {
+ if (fs.root.isFile) {
+ throw new Error('It was a file!');
+ }
+ });
+ }
+})
+chrome.contextMenus.ACTION_MENU_TOP_LEVEL_LIMIT;
+
+chrome.i18n.getMessage('click_here', ['string1', 'string2']);
+
+const TLSFormatExample = {
+ NetworkConfigurations:
+ {
+ GUID: '{00f79111-51e0-e6e0-76b3b55450d80a1b}',
+ Name: 'MyTTLSNetwork',
+ Type: 'WiFi',
+ WiFi: {
+ AutoConnect: false,
+ EAP: {
+ ClientCertPattern: {
+ EnrollmentURI: [
+ 'http://fetch-my-certificate.com'
+ ],
+ IssuerCARef: [
+ '{6ed8dce9-64c8-d568-d225d7e467e37828}'
+ ]
+ },
+ 'ClientCertType': 'Pattern',
+ 'Outer': 'EAP-TLS',
+ 'ServerCARef': '{6ed8dce9-64c8-d568-d225d7e467e37828}',
+ 'UseSystemCAs': true
+ },
+ 'HiddenSSID': false,
+ 'SSID': 'MyTTLSNetwork',
+ 'Security': 'WPA-EAP'
+ }
+ }
+}
+
+let serviceId: any = null;
+
+const runApp = () => {
+ var options = {
+ 'id': 'Bluetooth Sample App',
+ 'bounds': {
+ 'width': 1024,
+ 'height': 768
+ }
+ };
+
+ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
+ if (request.serviceId) {
+ serviceId = request.serviceId;
+ console.log('Received registered service Id: ' + serviceId);
+ }
+ });
+
+ chrome.app.window.create('test.html', options, (theWindow) => {
+ theWindow.onClosed.addListener(() => {
+ if (serviceId) {
+ console.log('Unregistering service: ' + serviceId);
+ chrome.bluetoothLowEnergy.unregisterService(serviceId, (status) => {
+ console.log('Unregister service status = ' + status);
+ });
+ }
+ });
+ });
+}
+
+chrome.app.runtime.onLaunched.addListener(runApp);
+chrome.app.runtime.onRestarted.addListener(runApp);
+
+// networking.onc
+
+chrome.networking.onc.getNetworks({ 'networkType': 'All' }, (networkList) => {
+ console.log('Length of Network list: ' + networkList.length);
+ for (let networkObj of networkList) {
+ console.log('GUID: ' + networkObj.GUID);
+ console.log('Connectable: ' + networkObj.Connectable);
+ if (networkObj.WiFi) {
+ // WiFi active :)
+ console.log('Wifi BSID: ' + networkObj.WiFi.BSSID);
+ }
+ chrome.networking.onc.setProperties(networkObj.GUID || '', {
+ WiFi: {
+ Passphrase: 'Can be set :) but not get?'
+ }
+ })
+ // Test that we can't get passphrase
+ chrome.networking.onc.getProperties(networkObj.GUID || '', (props) => {
+ const WiFiResult = props.WiFi;
+ });
+ }
+});
+
+//// AUDIO
+
+chrome.audio.getDevices({}, (audioDeviceInfoList) => {
+ for (let audioObj of audioDeviceInfoList) {
+ console.log('ID: ' + audioObj.id);
+ console.log('Audio Stream Type: ' + audioObj.streamType);
+ console.log('Audio Device Name: ' + audioObj.deviceName);
+ }
+});
+
+
+chrome.desktopCapture.chooseDesktopMedia(["screen", "window", "tab"], () => { });
+chrome.desktopCapture.chooseDesktopMedia([chrome.desktopCapture.DesktopCaptureSourceType.AUDIO], () => { });
+
diff --git a/types/cleave.js/options/index.d.ts b/types/cleave.js/options/index.d.ts
index 60e2e99e40..65d87d79e1 100644
--- a/types/cleave.js/options/index.d.ts
+++ b/types/cleave.js/options/index.d.ts
@@ -19,6 +19,12 @@ export interface CleaveOptions {
datePattern?: ReadonlyArray;
}
+// Time Options
+export interface CleaveOptions {
+ time?: boolean;
+ timePattern?: ReadonlyArray;
+}
+
// Numeral Options
export type NumeralThousandsGroupStyleType = "lakh" | "thousand" | "wan" | "none";
diff --git a/types/clipboard/clipboard-tests.ts b/types/clipboard/clipboard-tests.ts
index a2ae8f9354..1a9a170087 100644
--- a/types/clipboard/clipboard-tests.ts
+++ b/types/clipboard/clipboard-tests.ts
@@ -14,6 +14,12 @@ const cb5 = new ClipboardJS(".btn", {
action: elem => "copy",
target: elem => null
});
+const cb6 = new ClipboardJS(".btn", {
+ action: elem => "copy",
+ text: trigger => trigger.getAttribute('aria-label'),
+ target: trigger => trigger.nextElementSibling,
+ container: document.getElementById('modal')
+});
cb1.destroy();
ClipboardJS.isSupported();
diff --git a/types/clipboard/index.d.ts b/types/clipboard/index.d.ts
index 2405c0c6f0..ceb15b885b 100644
--- a/types/clipboard/index.d.ts
+++ b/types/clipboard/index.d.ts
@@ -49,6 +49,14 @@ declare namespace ClipboardJS {
* @returns Text to be copied.
*/
text?(elem: Element): string;
+
+ /**
+ * For use in Bootstrap Modals or with any
+ * other library that changes the focus
+ * you'll want to set the focused element
+ * as the container value.
+ */
+ container?: Element;
}
interface Event {
diff --git a/types/connect-mongo/index.d.ts b/types/connect-mongo/index.d.ts
index cf3d5ddb3e..ee110ab6b0 100644
--- a/types/connect-mongo/index.d.ts
+++ b/types/connect-mongo/index.d.ts
@@ -104,11 +104,11 @@ declare namespace connectMongo {
}
export class MongoStore extends session.Store {
- get: (sid: string, callback: (err: any, session: Express.Session) => void) => void;
+ get: (sid: string, callback: (err: any, session: Express.Session | null) => void) => void;
set: (sid: string, session: Express.Session, callback?: (err: any) => void) => void;
destroy: (sid: string, callback?: (err: any) => void) => void;
length: (callback: (err: any, length: number) => void) => void;
- clear: (callback?: (err: any) => void) => void;
+ clear: (callback?: (err?: any) => void) => void;
touch: (sid: string, session: Express.Session, callback?: (err: any) => void) => void;
}
}
diff --git a/types/couchbase/couchbase-tests.ts b/types/couchbase/couchbase-tests.ts
index d04b71c907..e6ea7c12d3 100644
--- a/types/couchbase/couchbase-tests.ts
+++ b/types/couchbase/couchbase-tests.ts
@@ -31,6 +31,11 @@ bucket.manager().createPrimaryIndex(function() {
});
});
+// Ensure bucket.upsert is composable with normal callbacks
+function composable(callback: (err?: Error) => void) {
+ bucket.upsert('key', {value: 1}, callback);
+}
+
// From https://developer.couchbase.com/documentation/server/current/sdk/nodejs/n1ql-queries-with-sdk.html
function n1ql_a() {
const n1qlquery = N1qlQuery.fromString('SELECT name, email FROM users WHERE name=$1');
diff --git a/types/couchbase/index.d.ts b/types/couchbase/index.d.ts
index f55ac6dbe9..813ee8f110 100644
--- a/types/couchbase/index.d.ts
+++ b/types/couchbase/index.d.ts
@@ -2019,10 +2019,10 @@ declare namespace Bucket {
*/
interface OpCallback {
/**
- * @param error The error for the operation. This can either be an Error object or a value which evaluates to false (null, undefined, 0 or false).
+ * @param error The error for the operation. This can either be an Error object or a value which evaluates to false.
* @param result The result of the operation that was executed. This usually contains at least a cas property, and on some operations will contain a value property as well.
*/
- (error: CouchbaseError | number, result: any): void;
+ (error: CouchbaseError | null, result: any): void;
}
/**
diff --git a/types/cqrs-domain/index.d.ts b/types/cqrs-domain/index.d.ts
index f826b45ffd..33db11b857 100644
--- a/types/cqrs-domain/index.d.ts
+++ b/types/cqrs-domain/index.d.ts
@@ -252,7 +252,7 @@ declare namespace Domain {
/**
* @param data is the command data
- * @callback callback is optional, if not defined as function argument you can throw errors or return errors here (sync way)
+ * @param callback is optional, if not defined as function argument you can throw errors or return errors here (sync way)
*/
type preLoadConditionHandler = (data: any, callback?: (err: string | Error) => string | Error) => void | string | Error;
@@ -295,7 +295,7 @@ declare namespace Domain {
/**
* @param data is the command data
* @param aggregate is the aggregate object
- * @callback callback is optional, if not defined as function argument you can throw errors or return errors here (sync way)
+ * @param callback is optional, if not defined as function argument you can throw errors or return errors here (sync way)
*/
type preConditionHandler = (data: any, aggregate: AggregateModel, callback?: (err: string | Error) => string | Error) => void | string | Error;
diff --git a/types/create-react-class/index.d.ts b/types/create-react-class/index.d.ts
index 9a1b0b12b5..9b9d2b2ad5 100644
--- a/types/create-react-class/index.d.ts
+++ b/types/create-react-class/index.d.ts
@@ -2,7 +2,7 @@
// Project: https://facebook.github.io/react/
// Definitions by: John Gozde
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
-// TypeScript Version: 2.6
+// TypeScript Version: 2.8
import { ComponentSpec, ClassicComponentClass } from "react";
diff --git a/types/create-subscription/index.d.ts b/types/create-subscription/index.d.ts
index 79003980ee..8c7d8c1ced 100644
--- a/types/create-subscription/index.d.ts
+++ b/types/create-subscription/index.d.ts
@@ -3,7 +3,7 @@
// Definitions by: Asana
// Vincent Siao
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
-// TypeScript Version: 2.6
+// TypeScript Version: 2.8
import * as React from "react";
diff --git a/types/crypto-random-string/crypto-random-string-tests.ts b/types/crypto-random-string/crypto-random-string-tests.ts
new file mode 100644
index 0000000000..1a66c25981
--- /dev/null
+++ b/types/crypto-random-string/crypto-random-string-tests.ts
@@ -0,0 +1,4 @@
+import generate = require('crypto-random-string');
+
+// $ExpectType string
+generate(10);
diff --git a/types/crypto-random-string/index.d.ts b/types/crypto-random-string/index.d.ts
new file mode 100644
index 0000000000..dc41e18428
--- /dev/null
+++ b/types/crypto-random-string/index.d.ts
@@ -0,0 +1,13 @@
+// Type definitions for crypto-random-string 1.0
+// Project: https://github.com/sindresorhus/crypto-random-string
+// Definitions by: Manuel Warum
+// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
+
+/**
+ * Generate a hexadecimal string of the given length.
+ * @param length the length of the random string.
+ * @return a string of the specified length.
+ */
+declare function cryptoRandomString(length: number): string;
+
+export = cryptoRandomString;
diff --git a/types/crypto-random-string/tsconfig.json b/types/crypto-random-string/tsconfig.json
new file mode 100644
index 0000000000..fd68e9d080
--- /dev/null
+++ b/types/crypto-random-string/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",
+ "crypto-random-string-tests.ts"
+ ]
+}
diff --git a/types/crypto-random-string/tslint.json b/types/crypto-random-string/tslint.json
new file mode 100644
index 0000000000..f93cf8562a
--- /dev/null
+++ b/types/crypto-random-string/tslint.json
@@ -0,0 +1,3 @@
+{
+ "extends": "dtslint/dt.json"
+}
diff --git a/types/cssnano/cssnano-tests.ts b/types/cssnano/cssnano-tests.ts
new file mode 100644
index 0000000000..17828e1b02
--- /dev/null
+++ b/types/cssnano/cssnano-tests.ts
@@ -0,0 +1,17 @@
+import cssnano = require('cssnano');
+import { Transformer } from 'postcss';
+
+const nano1: Transformer = cssnano();
+const nano2: Transformer = cssnano({
+ configFile: '/path/to/config',
+});
+const nano3: Transformer = cssnano({
+ preset: 'default',
+});
+const nano4: Transformer = cssnano({
+ preset: ['default', {
+ discardComments: {
+ removeAll: true,
+ },
+ }],
+});
diff --git a/types/cssnano/index.d.ts b/types/cssnano/index.d.ts
new file mode 100644
index 0000000000..bf298f1854
--- /dev/null
+++ b/types/cssnano/index.d.ts
@@ -0,0 +1,19 @@
+// Type definitions for cssnano 4.0
+// Project: https://github.com/cssnano/cssnano
+// Definitions by: Armando Meziat
+// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
+// TypeScript Version: 2.2
+
+import { Plugin } from 'postcss';
+
+declare namespace cssnano {
+ interface CssNanoOptions {
+ configFile?: string;
+ preset?: [string, object] | string;
+ }
+
+ type CssNano = Plugin;
+}
+
+declare const cssnano: cssnano.CssNano;
+export = cssnano;
diff --git a/types/cssnano/package.json b/types/cssnano/package.json
new file mode 100644
index 0000000000..3c7b1f0f76
--- /dev/null
+++ b/types/cssnano/package.json
@@ -0,0 +1,6 @@
+{
+ "private": true,
+ "dependencies": {
+ "postcss": "5 - 7"
+ }
+}
diff --git a/types/cssnano/tsconfig.json b/types/cssnano/tsconfig.json
new file mode 100644
index 0000000000..5667012b67
--- /dev/null
+++ b/types/cssnano/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",
+ "cssnano-tests.ts"
+ ]
+}
diff --git a/types/cssnano/tslint.json b/types/cssnano/tslint.json
new file mode 100644
index 0000000000..3db14f85ea
--- /dev/null
+++ b/types/cssnano/tslint.json
@@ -0,0 +1 @@
+{ "extends": "dtslint/dt.json" }
diff --git a/types/cytoscape/index.d.ts b/types/cytoscape/index.d.ts
index c38acead19..59482ad507 100644
--- a/types/cytoscape/index.d.ts
+++ b/types/cytoscape/index.d.ts
@@ -2819,13 +2819,13 @@ declare namespace cytoscape {
/**
* The handler returns true when it finds the desired node, and it returns false to cancel the search.
- * i - The index indicating this node is the ith visited node.
- * depth - How many edge hops away this node is from the root nodes.
* v - The current node.
* e - The edge connecting the previous node to the current node.
* u - The previous node.
+ * i - The index indicating this node is the ith visited node.
+ * depth - How many edge hops away this node is from the root nodes.
*/
- type SearchVisitFunction = (i: number, depth: number, v: NodeCollection, e: EdgeCollection, u: NodeCollection) => boolean;
+ type SearchVisitFunction = (v: NodeCollection, e: EdgeCollection, u: NodeCollection, i: number, depth: number) => boolean | void;
interface SearchFirstOptions {
/**
* The root nodes (selector or collection) to start the search from.
diff --git a/types/d3-hierarchy/d3-hierarchy-tests.ts b/types/d3-hierarchy/d3-hierarchy-tests.ts
index 65b1f5c392..b75b9fbbd0 100644
--- a/types/d3-hierarchy/d3-hierarchy-tests.ts
+++ b/types/d3-hierarchy/d3-hierarchy-tests.ts
@@ -189,6 +189,10 @@ stratificatorizer = d3Hierarchy.stratify();
// id(...)
+stratificatorizer = stratificatorizer.id((d) => {
+ return d.name; // d is of type TabularHierarchyDatum
+});
+
stratificatorizer = stratificatorizer.id((d, i, data) => {
console.log('Length of tabular array: ', data.length);
console.log('Name of first entry in tabular array: ', data[0].name); // data of type Array
@@ -199,6 +203,10 @@ idStringAccessor = stratificatorizer.id();
// parentId(...)
+stratificatorizer = stratificatorizer.parentId((d) => {
+ return d.parentId; // d is of type TabularHierarchyDatum
+});
+
stratificatorizer = stratificatorizer.parentId((d, i, data) => {
console.log('Length of tabular array: ', data.length);
console.log('Name of first entry in tabular array: ', data[0].name); // data of type Array
@@ -225,14 +233,12 @@ clusterLayout = d3Hierarchy.cluster();
// size() ----------------------------------------------------------------
-clusterLayout = clusterLayout.size(null);
clusterLayout = clusterLayout.size([200, 200]);
size = clusterLayout.size();
// nodeSize() ------------------------------------------------------------
-clusterLayout = clusterLayout.nodeSize(null);
clusterLayout = clusterLayout.nodeSize([10, 10]);
size = clusterLayout.nodeSize();
@@ -358,14 +364,12 @@ treeLayout = d3Hierarchy.tree();
// size() ----------------------------------------------------------------
-treeLayout = treeLayout.size(null);
treeLayout = treeLayout.size([200, 200]);
size = treeLayout.size();
// nodeSize() ------------------------------------------------------------
-treeLayout = treeLayout.nodeSize(null);
treeLayout = treeLayout.nodeSize([10, 10]);
size = treeLayout.nodeSize();
@@ -416,7 +420,6 @@ tilingFn = treemapLayout.tile();
// size() ----------------------------------------------------------------
-treemapLayout = treemapLayout.size(null);
treemapLayout = treemapLayout.size([400, 200]);
size = treemapLayout.size();
@@ -635,7 +638,6 @@ partitionLayout = d3Hierarchy.partition();
// size() ----------------------------------------------------------------
-partitionLayout = partitionLayout.size(null);
partitionLayout = partitionLayout.size([400, 200]);
size = partitionLayout.size();
@@ -674,7 +676,6 @@ packLayout = d3Hierarchy.pack();
// size() ----------------------------------------------------------------
-packLayout = packLayout.size(null);
packLayout = packLayout.size([400, 400]);
size = packLayout.size();
diff --git a/types/d3-hierarchy/index.d.ts b/types/d3-hierarchy/index.d.ts
index 440a779217..bdb7b652d5 100644
--- a/types/d3-hierarchy/index.d.ts
+++ b/types/d3-hierarchy/index.d.ts
@@ -1,65 +1,208 @@
// Type definitions for D3JS d3-hierarchy module 1.1
// Project: https://github.com/d3/d3-hierarchy/
-// Definitions by: Tom Wanzek , Alex Ford , Boris Yankov
+// Definitions by: Tom Wanzek
+// Alex Ford
+// Boris Yankov
+// denisname
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
-// Last module patch version validated against: 1.1.1
+// Last module patch version validated against: 1.1.6
// -----------------------------------------------------------------------
// Hierarchy
// -----------------------------------------------------------------------
export interface HierarchyLink {
+ /**
+ * The source of the link.
+ */
source: HierarchyNode;
+
+ /**
+ * The target of the link.
+ */
target: HierarchyNode;
}
export interface HierarchyNode {
- data: Datum;
- readonly depth: number;
- readonly height: number;
- parent: HierarchyNode | null;
- children?: Array>;
/**
- * Aggregated numeric value as calculated by sum(value) or count(),
- * if previously invoked.
+ * The associated data, as specified to the constructor.
+ */
+ data: Datum;
+
+ /**
+ * Zero for the root node, and increasing by one for each descendant generation.
+ */
+ readonly depth: number;
+
+ /**
+ * Zero for leaf nodes, and the greatest distance from any descendant leaf for internal nodes.
+ */
+ readonly height: number;
+
+ /**
+ * The parent node, or null for the root node.
+ */
+ parent: this | null;
+
+ /**
+ * An array of child nodes, if any; undefined for leaf nodes.
+ */
+ children?: this[];
+
+ /**
+ * Aggregated numeric value as calculated by `sum(value)` or `count()`, if previously invoked.
*/
readonly value?: number;
+
/**
- * Optional Node Id string set by StratifyOperator, if
- * hierarchical data was created from tabular data using stratify()
+ * Optional node id string set by `StratifyOperator`, if hierarchical data was created from tabular data using stratify().
*/
readonly id?: string;
- ancestors(): Array>;
- descendants(): Array>;
- leaves(): Array>;
- path(target: HierarchyNode): Array>;
+
+ /**
+ * Returns the array of ancestors nodes, starting with this node, then followed by each parent up to the root.
+ */
+ ancestors(): this[];
+
+ /**
+ * Returns the array of descendant nodes, starting with this node, then followed by each child in topological order.
+ */
+ descendants(): this[];
+
+ /**
+ * Returns the array of leaf nodes in traversal order; leaves are nodes with no children.
+ */
+ leaves(): this[];
+
+ /**
+ * Returns the shortest path through the hierarchy from this node to the specified target node.
+ * The path starts at this node, ascends to the least common ancestor of this node and the target node, and then descends to the target node.
+ *
+ * @param target The target node.
+ */
+ path(target: this): this[];
+
+ /**
+ * Returns an array of links for this node, where each link is an object that defines source and target properties.
+ * The source of each link is the parent node, and the target is a child node.
+ */
links(): Array>;
+
+ /**
+ * Evaluates the specified value function for this node and each descendant in post-order traversal, and returns this node.
+ * The `node.value` property of each node is set to the numeric value returned by the specified function plus the combined value of all descendants.
+ *
+ * @param value The value function is passed the node’s data, and must return a non-negative number.
+ */
sum(value: (d: Datum) => number): this;
+
+ /**
+ * Computes the number of leaves under this node and assigns it to `node.value`, and similarly for every descendant of node.
+ * If this node is a leaf, its count is one. Returns this node.
+ */
count(): this;
- sort(compare: (a: HierarchyNode, b: HierarchyNode) => number): this;
- each(func: (node: HierarchyNode) => void): this;
- eachAfter(func: (node: HierarchyNode) => void): this;
- eachBefore(func: (node: HierarchyNode) => void): this;
- copy(): HierarchyNode;
+
+ /**
+ * Sorts the children of this node, if any, and each of this node’s descendants’ children,
+ * in pre-order traversal using the specified compare function, and returns this node.
+ *
+ * @param compare The compare function is passed two nodes a and b to compare.
+ * If a should be before b, the function must return a value less than zero;
+ * if b should be before a, the function must return a value greater than zero;
+ * otherwise, the relative order of a and b are not specified. See `array.sort` for more.
+ */
+ sort(compare: (a: this, b: this) => number): this;
+
+ /**
+ * Invokes the specified function for node and each descendant in breadth-first order,
+ * such that a given node is only visited if all nodes of lesser depth have already been visited,
+ * as well as all preceding nodes of the same depth.
+ *
+ * @param func The specified function is passed the current node.
+ */
+ each(func: (node: this) => void): this;
+
+ /**
+ * Invokes the specified function for node and each descendant in post-order traversal,
+ * such that a given node is only visited after all of its descendants have already been visited.
+ *
+ * @param func The specified function is passed the current node.
+ */
+ eachAfter(func: (node: this) => void): this;
+
+ /**
+ * Invokes the specified function for node and each descendant in pre-order traversal,
+ * such that a given node is only visited after all of its ancestors have already been visited.
+ *
+ * @param func The specified function is passed the current node.
+ */
+ eachBefore(func: (node: this) => void): this;
+
+ /**
+ * Return a deep copy of the subtree starting at this node. The returned deep copy shares the same data, however.
+ * The returned node is the root of a new tree; the returned node’s parent is always null and its depth is always zero.
+ */
+ copy(): this;
}
+/**
+ * Constructs a root node from the specified hierarchical data.
+ *
+ * @param data The root specified data.
+ * @param children The specified children accessor function invoked for each datum, starting with the root data.
+ * Must return an array of data representing the children, and return null or undefined if the current datum has no children.
+ * If children is not specified, it defaults to: `(d) => d.children`.
+ */
export function hierarchy(data: Datum, children?: (d: Datum) => (Datum[] | null)): HierarchyNode;
// -----------------------------------------------------------------------
// Stratify
// -----------------------------------------------------------------------
-// TODO: Review the comment in the API documentation related to 'reserved properties': id, parentId, children. If this is referring to the element on node, it should be 'parent'?
-
export interface StratifyOperator {
+ /**
+ * Generates a new hierarchy from the specified tabular data. Each node in the returned object has a shallow copy of the properties
+ * from the corresponding data object, excluding the following reserved properties: id, parentId, children.
+ *
+ * @param data The root specified data.
+ * @throws Error on missing id, ambiguous id, cycle, multiple roots or no root.
+ */
(data: Datum[]): HierarchyNode;
+
+ /**
+ * Returns the current id accessor, which defaults to: `(d) => d.id`.
+ */
id(): (d: Datum, i: number, data: Datum[]) => (string | null | '' | undefined);
+ /**
+ * Sets the id accessor to the given function.
+ * The id accessor is invoked for each element in the input data passed to the stratify operator.
+ * The returned string is then used to identify the node's relationships in conjunction with the parent id.
+ * For leaf nodes, the id may be undefined, null or the empty string; otherwise, the id must be unique.
+ *
+ * @param id The id accessor.
+ */
id(id: (d: Datum, i?: number, data?: Datum[]) => (string | null | '' | undefined)): this;
+
+ /**
+ * Returns the current parent id accessor, which defaults to: `(d) => d.parentId`.
+ */
parentId(): (d: Datum, i: number, data: Datum[]) => (string | null | '' | undefined);
+ /**
+ * Sets the parent id accessor to the given function.
+ * The parent id accessor is invoked for each element in the input data passed to the stratify operator.
+ * The returned string is then used to identify the node's relationships in conjunction with the id.
+ * For the root node, the parent id should be undefined, null or the empty string.
+ * There must be exactly one root node in the input data, and no circular relationships.
+ *
+ * @param parentId The parent id accessor.
+ */
parentId(parentId: (d: Datum, i?: number, data?: Datum[]) => (string | null | '' | undefined)): this;
}
+/**
+ * Constructs a new stratify operator with the default settings.
+ */
export function stratify