diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md
index 7ebdcc514f..44f0d8e9a0 100644
--- a/CONTRIBUTORS.md
+++ b/CONTRIBUTORS.md
@@ -401,6 +401,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam
* [:link:](egg.js/egg.js.d.ts) [Egg.js](https://github.com/mikeflynn/egg.js) by [Markus Peloso](https://github.com/ToastHawaii)
* [:link:](ejs-locals/ejs-locals.d.ts) [ejs-locals](https://github.com/randometc/ejs-locals) by [jt000](https://github.com/jt000)
* [:link:](ejs/ejs.d.ts) [ejs.js](http://ejs.co) by [Ben Liddicott](https://github.com/benliddicott/DefinitelyTyped)
+* [:link:](elasticsearch/elasticsearch.d.ts) [elasticsearch](https://www.elastic.co) by [Casper Skydt](https://github.com/CasperSkydt/DefinitelyTyped), [Blake Smith](https://github.com/bfsmith/DefinitelyTyped)
* [:link:](jquery.elang/jquery.elang.d.ts) [eLang](https://github.com/sumegizoltan/ELang) by [Zoltan Sumegi](https://github.com/sumegizoltan)
* [:link:](github-electron/github-electron.d.ts) [Electron](http://electron.atom.io) by [jedmao](https://github.com/jedmao), [rhysd](https://rhysd.github.io), [Milan Burda](https://github.com/miniak)
* [:link:](electron-builder/electron-builder.d.ts) [electron-builder](https://github.com/loopline-systems/electron-builder) by [Maxime LUCE](https://github.com/SomaticIT)
diff --git a/amcharts/AmCharts.d.ts b/amcharts/AmCharts.d.ts
index 27998956b8..4f5dbe90f7 100644
--- a/amcharts/AmCharts.d.ts
+++ b/amcharts/AmCharts.d.ts
@@ -27,6 +27,9 @@ declare namespace AmCharts {
/** Clears all the charts on page, removes listeners and intervals. */
function clear();
+ /** Handle ready event */
+ function ready(Function): void;
+
/** Create chart by params. */
function makeChart(selector: string, params: any, delay?: number): AmChart;
@@ -961,6 +964,10 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val
@Default 150
*/
hideBalloonTime: number;
+ /** Allows changing language easily.
+ * Note, you should include the language.js file from amcharts/lang or ammap/lang folder and then use variable name used in this file, like chart.language = "de";
+ * Note, for maps this works differently - you use language only for country names, as there are no other strings in the maps application. */
+ language: string;
/** Legend of a chart. */
legend: AmLegend;
/** Reference to the div of the legend. */
@@ -989,6 +996,8 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val
prefixesOfBigNumbers: any[];
/** Prefixes which are used to make small numbers shorter: 2μ instead of 0.000002, etc. Prefixes are used on value axes and in the legend. To enable prefixes, set usePrefixes property to true. [{number:1e-24, prefix:"y"},{number:1e-21, prefix:"z"},{number:1e-18, prefix:"a"},{number:1e-15, prefix:"f"},{number:1e-12, prefix:"p"},{number:1e-9, prefix:"n"},{number:1e-6, prefix:"μ"},{number:1e-3, prefix:"m"}] */
prefixesOfSmallNumbers: any[];
+ /** A config object for Responsive plugin. */
+ responsive: any;
/** Theme of a chart. Config files of themes can be found in amcharts/themes/ folder. More info about using themes. */
theme: string;
/** Thousands separator.
diff --git a/amplitude-js/v2/amplitude-js-tests.ts b/amplitude-js/v2/amplitude-js-tests.ts
new file mode 100644
index 0000000000..3e69d7c867
--- /dev/null
+++ b/amplitude-js/v2/amplitude-js-tests.ts
@@ -0,0 +1,87 @@
+// Tests for Amplitude SDK TypeScript definitions
+
+///
+
+module Amplitude.Tests {
+ function all() {
+ amplitude.init('YOUR_API_KEY_HERE', null, {
+ // optional configuration options
+ saveEvents: true,
+ includeUtm: true,
+ includeReferrer: true,
+ batchEvents: true,
+ eventUploadThreshold: 50
+ });
+ amplitude.init('YOUR_API_KEY_HERE', 'USER_ID_HERE', null, () => {});
+
+ amplitude.logEvent('EVENT_IDENTIFIER_HERE');
+ amplitude.setUserId('USER_ID_HERE');
+ amplitude.init('YOUR_API_KEY_HERE', 'USER_ID_HERE');
+ amplitude.setUserId(null); // not string 'null'
+ amplitude.setVersionName('VERSION_NAME_HERE');
+
+ amplitude.regenerateDeviceId();
+ amplitude.setDeviceId('CUSTOM_DEVICE_ID');
+
+ amplitude.logEvent('EVENT_IDENTIFIER_HERE', {
+ 'color': 'blue',
+ 'age': 20,
+ 'key': 'value'
+ });
+ amplitude.logEvent("EVENT_IDENTIFIER_HERE", null, (httpCode, response) => { });
+
+ let identify = new amplitude.Identify().set('gender', 'female').set('age', 20);
+ amplitude.identify(identify);
+
+ identify = new amplitude.Identify().setOnce('sign_up_date', '08/24/2015');
+ amplitude.identify(identify);
+
+ identify = new amplitude.Identify().setOnce('sign_up_date', '09/14/2015');
+ amplitude.identify(identify);
+
+ identify = new amplitude.Identify().unset('gender').unset('age');
+ amplitude.identify(identify);
+
+ identify = new amplitude.Identify().add('karma', 1).add('friends', 1);
+ amplitude.identify(identify);
+
+ identify = new amplitude.Identify().append('ab-tests', 'new-user-test').append('some_list', [1, 2, 3, 4, 'values']);
+ amplitude.identify(identify);
+
+ identify = new amplitude.Identify().prepend('ab-tests', 'new-user-test').prepend('some_list', [1, 2, 3, 4, 'values']);
+ amplitude.identify(identify);
+
+ identify = new amplitude.Identify()
+ .set('karma', 10)
+ .add('karma', 1)
+ .unset('karma');
+ amplitude.identify(identify);
+
+ identify = new amplitude.Identify()
+ .set('colors', ['rose', 'gold'])
+ .append('ab-tests', 'campaign_a')
+ .append('existing_list', [4, 5]);
+ amplitude.identify(identify);
+
+ amplitude.setUserProperties({
+ gender: 'female',
+ age: 20
+ });
+
+ amplitude.clearUserProperties();
+
+ amplitude.setOptOut(true);
+ amplitude.setOptOut(false);
+
+ amplitude.setGroup('orgId', '15');
+ amplitude.setGroup('sport', ['soccer', 'tennis']);
+
+ // TODO: Implement those.
+ /*
+ var revenue = new amplitude.Revenue().setProductId('com.company.productId').setPrice(3.99).setQuantity(3);
+ amplitude.logRevenueV2(revenue);
+
+ amplitude.logEventWithGroups('initialize_game', { 'key': 'value' }, { 'sport': 'soccer' });
+ */
+ }
+}
diff --git a/amplitude-js/v2/amplitude-js.d.ts b/amplitude-js/v2/amplitude-js.d.ts
new file mode 100644
index 0000000000..613f5ad5d8
--- /dev/null
+++ b/amplitude-js/v2/amplitude-js.d.ts
@@ -0,0 +1,61 @@
+// Type definitions for Amplitude SDK 2.12.1
+// Project: https://github.com/amplitude/Amplitude-Javascript
+// Definitions by: Arvydas Sidorenko
+// Definitions: https://github.com/Asido/DefinitelyTyped
+
+declare module amplitude {
+ interface Config {
+ batchEvents?: boolean;
+ cookieExpiration?: number;
+ cookieName?: string;
+ deviceId?: string;
+ domain?: string;
+ eventUploadPeriodMillis?: number;
+ eventUploadThreshold?: number;
+ includeReferrer?: boolean;
+ includeUtm?: boolean;
+ language?: string;
+ optOut?: boolean;
+ platform?: string;
+ saveEvents?: boolean;
+ savedMaxCount?: number;
+ sessionTimeout?: number;
+ uploadBatchSize?: number;
+ }
+
+ export class Identify {
+ set(key: string, value: any): Identify;
+ setOnce(key: string, value: any): Identify;
+ add(key: string, value: number): Identify;
+ append(key: string, value: any): Identify;
+ prepend(key: string, value: any): Identify;
+
+ unset(key: string): Identify;
+ }
+
+ export function init(apiKey: string): void;
+ export function init(apiKey: string, userId: string): void;
+ export function init(apiKey: string, userId: string, options: Config): void;
+ export function init(apiKey: string, userId: string, options: Config, callback: () => void): void;
+
+ export function setVersionName(version: string): void;
+ export function setUserId(userId: string): void;
+
+ export function setDeviceId(id: string): void;
+ export function regenerateDeviceId(): void;
+
+ export function identify(identify: Identify): void;
+
+ export function setUserProperties(properties: Object): void;
+ export function clearUserProperties(): void;
+
+ export function setOptOut(optOut: boolean): void;
+
+ export function setGroup(groupType: string, groupName: string | string[]): void;
+
+ export function logEvent(event: string): void;
+ export function logEvent(event: string, data: Object): void;
+ export function logEvent(event: string, data: Object, callback: (httpCode: number, response: any) => void): void;
+
+ export var options: Config;
+}
diff --git a/angular-es/angular-es.d.ts b/angular-es/angular-es.d.ts
index 10979ae15c..0972b42da0 100644
--- a/angular-es/angular-es.d.ts
+++ b/angular-es/angular-es.d.ts
@@ -45,12 +45,12 @@ declare module 'angular-es' {
*
* @returns {ngESDecorator} - decorated class
*/
- var Component: (component: iComponent) => ngESDecorator;
+ function Component(component: iComponent): ngESDecorator;
/**
* Register config block
*/
- var Config: () => ngESDecorator;
+ function Config(): ngESDecorator;
/**
* Register constant
@@ -59,7 +59,7 @@ declare module 'angular-es' {
*
* @returns {ngESDecorator} - decorated class
*/
- var Constant: (name: string) => ngESDecorator;
+ function Constant(name: string): ngESDecorator;
/**
* Register controller
@@ -68,7 +68,7 @@ declare module 'angular-es' {
*
* @returns {ngESDecorator} - decorated class
*/
- var Controller: (name: string) => ngESDecorator;
+ function Controller(name: string): ngESDecorator;
/**
* Register decorator
@@ -77,7 +77,7 @@ declare module 'angular-es' {
*
* @returns {ngESDecorator} - decorated class
*/
- var Decorator: (name: string) => ngESDecorator;
+ function Decorator(name: string): ngESDecorator;
/**
* Register directive
@@ -86,7 +86,7 @@ declare module 'angular-es' {
*
* @returns {ngESDecorator} - decorated class
*/
- var Directive: (name: string) => ngESDecorator;
+ function Directive(name: string): ngESDecorator;
/**
* Register factory
@@ -95,7 +95,7 @@ declare module 'angular-es' {
*
* @returns {ngESDecorator} - decorated class
*/
- var Factory: (name: string) => ngESDecorator;
+ function Factory(name: string): ngESDecorator;
/**
* Register filter
@@ -104,7 +104,7 @@ declare module 'angular-es' {
*
* @returns {ngESDecorator} - decorated class
*/
- var Filter: (name: string) => ngESDecorator;
+ function Filter(name: string): ngESDecorator;
/**
* Add $inject property to target
@@ -113,7 +113,7 @@ declare module 'angular-es' {
*
* @returns {ngESDecorator} - decorated class
*/
- var Inject: (...dependencies: Array) => ngESDecorator;
+ function Inject(...dependencies: Array): ngESDecorator;
/**
* Inject dependencies as properties to target
@@ -122,7 +122,7 @@ declare module 'angular-es' {
*
* @returns {ngESDecorator} - decorated class
*/
- var InjectAsProperty: (...dependencies: Array) => ngESDecorator;
+ function InjectAsProperty(...dependencies: Array): ngESDecorator;
/**
* Attach target to the specified module
@@ -131,7 +131,7 @@ declare module 'angular-es' {
*
* @returns {ngESDecorator} - decorated class
*/
- var Module: (name: string) => ngESDecorator;
+ function Module(name: string): ngESDecorator;
/**
* Register provider
@@ -140,14 +140,14 @@ declare module 'angular-es' {
*
* @returns {ngESDecorator} - decorated class
*/
- var Provider: (name: string) => ngESDecorator;
+ function Provider(name: string): ngESDecorator;
/**
* Register run block
*
* @returns {ngESDecorator} - decorated class
*/
- var Run: () => ngESDecorator;
+ function Run(): ngESDecorator;
/**
* Register service
@@ -156,7 +156,7 @@ declare module 'angular-es' {
*
* @returns {ngESDecorator} - decorated class
*/
- var Service: (name: string) => ngESDecorator;
+ function Service(name: string): ngESDecorator;
/**
* Register value
@@ -165,7 +165,7 @@ declare module 'angular-es' {
*
* @returns {ngESDecorator} - decorated class
*/
- var Value: (name: string) => ngESDecorator;
+ function Value(name: string): ngESDecorator;
export {
Component,
diff --git a/angular-gettext/angular-gettext.d.ts b/angular-gettext/angular-gettext.d.ts
index 48734d4433..84721d8dc0 100644
--- a/angular-gettext/angular-gettext.d.ts
+++ b/angular-gettext/angular-gettext.d.ts
@@ -51,12 +51,12 @@ declare namespace angular.gettext {
/** Get the correct pluralized (but untranslated) string for the value of n. */
getStringForm(string: string, n: number): string;
- /** Translate a string with the given context. Uses Angular.JS interpolation, so something like this will do what you expect:
+ /** Translate a string with the given scope. Uses Angular.JS interpolation, so something like this will do what you expect:
* var hello = gettextCatalog.getString("Hello {{name}}!", { name: "Ruben" });
* // var hello will be "Hallo Ruben!" in Dutch.
- * The context parameter is optional: pass null (or don't pass anything) if you're not using it: this skips interpolation and is a lot faster.
+ * The scope parameter is optional: pass null (or don't pass anything) if you're not using it: this skips interpolation and is a lot faster.
*/
- getString(string: string, context?: any): string;
+ getString(string: string, scope?: any, context?: string): string;
/** Translate a plural string with the given context. */
getPlural(n: number, string: string, stringPlural: string, context?: any): string;
diff --git a/angular-jwt/angular-jwt-tests.ts b/angular-jwt/angular-jwt-tests.ts
index 3a6b7d6bf1..818899e829 100644
--- a/angular-jwt/angular-jwt-tests.ts
+++ b/angular-jwt/angular-jwt-tests.ts
@@ -15,3 +15,18 @@ var $jwtInterceptor: ng.jwt.IJwtInterceptor;
$jwtInterceptor.tokenGetter = () => {
return expToken;
}
+
+
+var authManager: ng.jwt.IAuthManagerServiceProvider;
+
+// Indicate the user is authenticated
+authManager.authenticate();
+
+// Indicate the user is unauthenticated
+authManager.unauthenticate();
+
+// Keep the user authenticated
+authManager.checkAuthOnRefresh();
+
+// Redirect the user on unauthorized requests
+authManager.redirectWhenUnauthenticated();
\ No newline at end of file
diff --git a/angular-jwt/angular-jwt.d.ts b/angular-jwt/angular-jwt.d.ts
index eb02cf24df..d1f9eb085f 100644
--- a/angular-jwt/angular-jwt.d.ts
+++ b/angular-jwt/angular-jwt.d.ts
@@ -27,4 +27,11 @@ declare namespace angular.jwt {
interface IJwtInterceptor {
tokenGetter(...params : any[]): string;
}
+
+ interface IAuthManagerServiceProvider {
+ authenticate(): void;
+ unauthenticate(): void;
+ checkAuthOnRefresh(): void;
+ redirectWhenUnauthenticated(): void;
+ }
}
diff --git a/angular-material/angular-material-tests.ts b/angular-material/angular-material-tests.ts
index 4464c599e3..c3ebcbaf99 100644
--- a/angular-material/angular-material-tests.ts
+++ b/angular-material/angular-material-tests.ts
@@ -127,15 +127,30 @@ myApp.controller('SidenavController', ($scope: ng.IScope, $mdSidenav: ng.materia
instance.isOpen();
instance.isLockedOpen();
});
+
+ $scope['onClose'] = $mdSidenav(componentId).onClose(() => {});
});
myApp.controller('ToastController', ($scope: ng.IScope, $mdToast: ng.material.IToastService) => {
$scope['openToast'] = () => $mdToast.show($mdToast.simple().textContent('Hello!'));
+
+ $scope['customToast'] = () => {
+ var options = {
+ hideDelay: 3000,
+ position: 'top right',
+ controller : 'ToastCtrl',
+ templateUrl : 'toast-template.html',
+ toastClass: 'my-class'
+ };
+
+ $mdToast.show(options);
+ }
});
myApp.controller('PanelController', ($scope: ng.IScope, $mdPanel: ng.material.IPanelService) => {
$scope['createPanel'] = () => {
var config = {
+ id: 'myPanel',
template: 'Hello!
',
hasBackdrop: true,
disableParentScroll: true,
diff --git a/angular-material/angular-material.d.ts b/angular-material/angular-material.d.ts
index 23da7bceb2..66852586da 100644
--- a/angular-material/angular-material.d.ts
+++ b/angular-material/angular-material.d.ts
@@ -22,7 +22,7 @@ declare namespace angular.material {
clickOutsideToClose?: boolean;
disableBackdrop?: boolean;
escapeToClose?: boolean;
- resolve?: {[index: string]: angular.IPromise};
+ resolve?: {[index: string]: () => angular.IPromise};
controllerAs?: string;
parent?: Function|string|Object; // default: root node
disableParentScroll?: boolean; // default: true
@@ -53,7 +53,7 @@ declare namespace angular.material {
controller(controller?: string|Function): T;
locals(locals?: {[index: string]: any}): T;
bindToController(bindToController?: boolean): T; // default: false
- resolve(resolve?: {[index: string]: angular.IPromise}): T;
+ resolve(resolve?: {[index: string]: () => angular.IPromise}): T;
controllerAs(controllerAs?: string): T;
parent(parent?: string|Element|JQuery): T; // default: root node
onComplete(onComplete?: Function): T;
@@ -91,7 +91,7 @@ declare namespace angular.material {
controller?: string|Function;
locals?: {[index: string]: any};
bindToController?: boolean; // default: false
- resolve?: {[index: string]: angular.IPromise}
+ resolve?: {[index: string]: () => angular.IPromise}
controllerAs?: string;
parent?: string|Element|JQuery; // default: root node
onShowing?: Function;
@@ -132,6 +132,7 @@ declare namespace angular.material {
close(): angular.IPromise;
isOpen(): boolean;
isLockedOpen(): boolean;
+ onClose(onClose: Function): void;
}
interface ISidenavService {
@@ -162,10 +163,11 @@ declare namespace angular.material {
preserveScope?: boolean; // default: false
hideDelay?: number; // default (ms): 3000
position?: string; // any combination of 'bottom'/'left'/'top'/'right'/'fit'; default: 'bottom left'
+ toastClass?: string;
controller?: string|Function;
locals?: {[index: string]: any};
bindToController?: boolean; // default: false
- resolve?: {[index: string]: angular.IPromise}
+ resolve?: {[index: string]: () => angular.IPromise}
controllerAs?: string;
parent?: string|Element|JQuery; // default: root node
}
@@ -291,13 +293,14 @@ declare namespace angular.material {
}
interface IPanelConfig {
+ id?: string;
template?: string;
templateUrl?: string;
controller?: string|Function;
controllerAs?: string;
bindToController?: boolean; // default: true
locals?: {[index: string]: any};
- resolve?: {[index: string]: angular.IPromise}
+ resolve?: {[index: string]: () => angular.IPromise}
attachTo?: string|JQuery|Element;
propagateContainerEvents?: boolean;
panelClass?: string;
diff --git a/angular-ui-notification/angular-ui-notification-tests.ts b/angular-ui-notification/angular-ui-notification-tests.ts
new file mode 100644
index 0000000000..3039a74c9e
--- /dev/null
+++ b/angular-ui-notification/angular-ui-notification-tests.ts
@@ -0,0 +1,30 @@
+///
+
+function TestNotifications(NotificationProvider: angular.uiNotification.INotificationProvider, Notification: angular.uiNotification.INotificationService) {
+ NotificationProvider.setOptions({
+ delay: 10000,
+ startTop: 20,
+ startRight: 10,
+ verticalSpacing: 20,
+ horizontalSpacing: 20,
+ positionX: 'left',
+ positionY: 'bottom'
+ });
+
+ Notification.primary('Primary notification');
+ Notification('Primary notification');
+
+ Notification.success('Success notification');
+
+ Notification({message: 'Warning notification'}, 'warning');
+
+ Notification({message: 'Primary notification', title: 'Primary notification'});
+
+ Notification.error({message: 'Error notification 1s', delay: 1000});
+
+ Notification.success({message: 'Success notification
Some other content
This is a link
', title: 'Html content'});
+
+ Notification.error({message: 'Error Bottom Right', positionY: 'bottom', positionX: 'right'});
+
+ Notification.error({message: 'Error notification 1s', replaceMessage: true});
+}
\ No newline at end of file
diff --git a/angular-ui-notification/angular-ui-notification.d.ts b/angular-ui-notification/angular-ui-notification.d.ts
new file mode 100644
index 0000000000..48215e6d42
--- /dev/null
+++ b/angular-ui-notification/angular-ui-notification.d.ts
@@ -0,0 +1,82 @@
+// Type definitions for angular-ui-notification
+// Project: https://github.com/alexcrack/angular-ui-notification
+// Definitions by: Kamil Rojewski
+// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
+
+declare namespace angular.uiNotification {
+ // Taken from angular to avoid dependency
+ interface IPromise {
+ /**
+ * Regardless of when the promise was or will be resolved or rejected, then calls one of the success or error callbacks asynchronously as soon as the result is available. The callbacks are called with a single argument: the result or rejection reason. Additionally, the notify callback may be called zero or more times to provide a progress indication, before the promise is resolved or rejected.
+ * The successCallBack may return IPromise for when a $q.reject() needs to be returned
+ * This method returns a new promise which is resolved or rejected via the return value of the successCallback, errorCallback. It also notifies via the return value of the notifyCallback method. The promise can not be resolved or rejected from the notifyCallback method.
+ */
+ then(successCallback: (promiseValue: T) => IPromise|TResult, errorCallback?: (reason: any) => any, notifyCallback?: (state: any) => any): IPromise;
+
+ /**
+ * Shorthand for promise.then(null, errorCallback)
+ */
+ catch(onRejected: (reason: any) => IPromise|TResult): IPromise;
+
+ /**
+ * Allows you to observe either the fulfillment or rejection of a promise, but to do so without modifying the final value. This is useful to release resources or do some clean-up that needs to be done whether the promise was rejected or resolved. See the full specification for more information.
+ *
+ * Because finally is a reserved word in JavaScript and reserved keywords are not supported as property names by ES3, you'll need to invoke the method like promise['finally'](callback) to make your code IE8 and Android 2.x compatible.
+ */
+ finally(finallyCallback: () => any): IPromise;
+ }
+
+ type XPosition = 'right'|'left'|'center';
+ type YPosition = 'top'|'bottom';
+
+ type MessageType = 'primary'|'info'|'success'|'warning'|'error';
+
+ interface IGlobalMessageOptions {
+ delay?: number;
+ startTop?: number;
+ startRight?: number;
+ verticalSpacing?: number;
+ horizontalSpacing?: number;
+ positionX?: XPosition;
+ positionY?: YPosition;
+ replaceMessage?: boolean;
+ templateUrl?: string;
+ onClose?: (element: any) => any;
+ closeOnClick?: boolean;
+ maxCount?: number;
+ }
+
+ interface IMessageOptions {
+ title?: string;
+ message?: string;
+ templateUrl?: string;
+ delay?: number;
+ type?: MessageType;
+ positionX?: XPosition;
+ positionY?: YPosition;
+ replaceMessage?: boolean;
+ closeOnClick?: boolean;
+ }
+
+ interface INotificationScope {
+ kill(isHard: boolean): void;
+ }
+
+ interface INotificationProvider {
+ setOptions(options: IGlobalMessageOptions): void;
+ }
+
+ type Message = string|IMessageOptions;
+
+ interface INotificationService {
+ primary(message: Message): IPromise;
+ info(message: Message): IPromise;
+ success(message: Message): IPromise;
+ warning(message: Message): IPromise;
+ error(message: Message): IPromise;
+
+ clearAll(): void;
+
+ (message: Message, type?: MessageType): IPromise;
+ }
+}
diff --git a/angular-ui-scroll/angular-ui-scroll.d.ts b/angular-ui-scroll/angular-ui-scroll.d.ts
index 168c6ba271..5f24c8ec38 100644
--- a/angular-ui-scroll/angular-ui-scroll.d.ts
+++ b/angular-ui-scroll/angular-ui-scroll.d.ts
@@ -42,9 +42,10 @@ declare namespace angular.ui {
*/
topVisibleScope: ng.IRepeatScope;
/**
- * calling this method reinitializes and reloads the scroller content.
+ * calling this method reinitializes and reloads the scroller content.
+ * @param startIndex is an integer indicating what item index the scroller will use to start the load process.
*/
- reload(): void;
+ reload(startIndex?: number): void;
/**
* Replaces the item in the buffer at the given index with the new items.
*
diff --git a/angularjs/angular-resource.d.ts b/angularjs/angular-resource.d.ts
index 441a7e1d3d..f7e803c1c8 100644
--- a/angularjs/angular-resource.d.ts
+++ b/angularjs/angular-resource.d.ts
@@ -42,15 +42,20 @@ declare namespace angular.resource {
(url: string, paramDefaults?: any,
/** example: {update: { method: 'PUT' }, delete: deleteDescriptor }
where deleteDescriptor : IActionDescriptor */
- actions?: any, options?: IResourceOptions): IResourceClass>;
+ actions?: IActionHash, options?: IResourceOptions): IResourceClass>;
(url: string, paramDefaults?: any,
/** example: {update: { method: 'PUT' }, delete: deleteDescriptor }
where deleteDescriptor : IActionDescriptor */
- actions?: any, options?: IResourceOptions): U;
+ actions?: IActionHash, options?: IResourceOptions): U;
(url: string, paramDefaults?: any,
/** example: {update: { method: 'PUT' }, delete: deleteDescriptor }
where deleteDescriptor : IActionDescriptor */
- actions?: any, options?: IResourceOptions): IResourceClass;
+ actions?: IActionHash, options?: IResourceOptions): IResourceClass;
+ }
+
+ // Hash of action descriptors allows custom action names
+ interface IActionHash {
+ [action: string]: IActionDescriptor
}
// Just a reference to facilitate describing new actions
@@ -186,6 +191,12 @@ declare namespace angular {
/** creating a resource service factory */
factory(name: string, resourceServiceFactoryFunction: angular.resource.IResourceServiceFactoryFunction): IModule;
}
+
+ namespace auto {
+ interface IInjectorService {
+ get(name: '$resource'): ng.resource.IResourceService;
+ }
+ }
}
interface Array
diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts
index 3c13fd6cf3..1831bc0493 100644
--- a/angularjs/angular.d.ts
+++ b/angularjs/angular.d.ts
@@ -1,6 +1,6 @@
// Type definitions for Angular JS 1.5
// Project: http://angularjs.org
-// Definitions by: Diego Vilar
+// Definitions by: Diego Vilar , Georgii Dolzhykov
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -125,6 +125,7 @@ declare namespace angular {
isFunction(value: any): value is Function;
isNumber(value: any): value is number;
isObject(value: any): value is Object;
+ isObject(value: any): value is T;
isString(value: any): value is string;
isUndefined(value: any): boolean;
lowercase(str: string): string;
@@ -1411,6 +1412,16 @@ declare namespace angular {
* Absolute or relative URL of the resource that is being requested.
*/
url: string;
+ /**
+ * Event listeners to be bound to the XMLHttpRequest object.
+ * To bind events to the XMLHttpRequest upload object, use uploadEventHandlers. The handler will be called in the context of a $apply block.
+ */
+ eventHandlers?: { [type: string]: EventListenerOrEventListenerObject };
+ /**
+ * Event listeners to be bound to the XMLHttpRequest upload object.
+ * To bind events to the XMLHttpRequest object, use eventHandlers. The handler will be called in the context of a $apply block.
+ */
+ uploadEventHandlers?: { [type: string]: EventListenerOrEventListenerObject };
}
interface IHttpHeadersGetter {
@@ -1745,12 +1756,12 @@ declare namespace angular {
*/
$onInit?(): void;
/**
- * Called whenever one-way bindings are updated. The changesObj is a hash whose keys are the names of the bound
- * properties that have changed, and the values are an {@link IChangesObject} object of the form
+ * Called whenever one-way bindings are updated. The onChangesObj is a hash whose keys are the names of the bound
+ * properties that have changed, and the values are an {@link IChangesObject} object of the form
* { currentValue, previousValue, isFirstChange() }. Use this hook to trigger updates within a component such as
* cloning the bound value to prevent accidental mutation of the outer value.
*/
- $onChanges?(changesObj: {[property:string]: IChangesObject}): void;
+ $onChanges?(onChangesObj: IOnChangesObject): void;
/**
* Called on a controller when its containing scope is destroyed. Use this hook for releasing external resources,
* watches and event handlers.
@@ -1766,6 +1777,10 @@ declare namespace angular {
*/
$postLink?(): void;
}
+
+ interface IOnChangesObject {
+ [property: string]: IChangesObject;
+ }
interface IChangesObject {
currentValue: any;
diff --git a/atom/atom.d.ts b/atom/atom.d.ts
index 389d6ef16e..ac899ba5ac 100644
--- a/atom/atom.d.ts
+++ b/atom/atom.d.ts
@@ -946,9 +946,14 @@ declare namespace AtomCore {
registry: any;
repository: Object;
scopeName: string;
+ tokenizeLines: (text: string) => any;
// TBD
}
+
+ interface IGrammars {
+ grammarForScopeName(scope: string): IGrammar;
+ }
interface IPane /* extends Theorist.Model */ {
itemForURI: (uri:string)=>IEditor;
@@ -1302,6 +1307,7 @@ declare namespace AtomCore {
deserializers:IDeserializerManager;
config: IConfig;
commands: ICommandRegistry;
+ grammars: IGrammars;
keymaps: IKeymapManager;
keymap: IKeymapManager;
packages: IPackageManager;
diff --git a/auth0-js/auth0-js-tests.ts b/auth0-js/auth0-js-tests.ts
new file mode 100644
index 0000000000..c92251db91
--- /dev/null
+++ b/auth0-js/auth0-js-tests.ts
@@ -0,0 +1,23 @@
+///
+
+var auth0 = new Auth0({
+ domain: 'mine.auth0.com',
+ clientID: 'dsa7d77dsa7d7',
+ callbackURL: 'http://my-app.com/callback',
+ callbackOnLocationHash: true
+});
+
+auth0.login({
+ connection: 'google-oauth2',
+ popup: true,
+ popupOptions: {
+ width: 450,
+ height: 800
+ }
+}, (err, profile, idToken, accessToken, state) => {
+ if (err) {
+ alert("something went wrong: " + err.message);
+ return;
+ }
+ alert('hello ' + profile.name);
+ });
diff --git a/auth0-js/auth0-js.d.ts b/auth0-js/auth0-js.d.ts
new file mode 100644
index 0000000000..250c7a850e
--- /dev/null
+++ b/auth0-js/auth0-js.d.ts
@@ -0,0 +1,133 @@
+// Type definitions for Auth0.js
+// Project: https://github.com/auth0/auth0.js
+// Definitions by: Robert McLaws
+// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
+
+/** Extensions to the browser Window object. */
+interface Window {
+ /** Allows you to pass the id_token to other APIs, as specified in https://docs.auth0.com/apps-apis */
+ token: string;
+}
+
+/** This is the interface for the main Auth0 client. */
+interface Auth0Static {
+
+ new(options: Auth0ClientOptions): Auth0Static;
+ changePassword(options: any, callback?: Function): void;
+ decodeJwt(jwt: string): any;
+ login(options: any, callback: (error?: Auth0Error, profile?: Auth0UserProfile, id_token?: string, access_token?: string, state?: string) => any): void;
+ loginWithPopup(options: Auth0LoginOptions, callback: (error?: Auth0Error, profile?: Auth0UserProfile, id_token?: string, access_token?: string, state?: string) => any): void;
+ loginWithResourceOwner(options: Auth0LoginOptions, callback: (error?: Auth0Error, profile?: Auth0UserProfile, id_token?: string, access_token?: string, state?: any) => any): void;
+ loginWithUsernamePassword(options: Auth0LoginOptions, callback: (error?: Auth0Error, profile?: Auth0UserProfile, id_token?: string, access_token?: string, state?: string) => any): void;
+ logout(query: string): void;
+ getConnections(callback?: Function): void;
+ refreshToken(refreshToken: string, callback: (error?: Auth0Error, delegationResult?: Auth0DelegationToken) => any): void;
+ getDelegationToken(targetClientId: string, id_token: string, options: any, callback: (error?: Auth0Error, delegationResult?: Auth0DelegationToken) => any): void;
+ getProfile(id_token: string, callback?: Function): Auth0UserProfile;
+ getSSOData(withActiveDirectories: any, callback?: Function): void;
+ parseHash(hash: string): Auth0DecodedHash;
+ signup(options: Auth0SignupOptions, callback: Function): void;
+ validateUser(options: any, callback: (error?: Auth0Error, valid?: any) => any): void;
+}
+
+/** Represents constructor options for the Auth0 client. */
+interface Auth0ClientOptions {
+ clientID: string;
+ callbackURL: string;
+ callbackOnLocationHash?: boolean;
+ domain: string;
+ forceJSONP?: boolean;
+}
+
+/** Represents a normalized UserProfile. */
+interface Auth0UserProfile {
+ email: string;
+ email_verified: boolean;
+ family_name: string;
+ gender: string;
+ given_name: string;
+ locale: string;
+ name: string;
+ nickname: string;
+ picture: string;
+ user_id: string;
+ /** Represents one or more Identities that may be associated with the User. */
+ identities: Auth0Identity[];
+ user_metadata?: any;
+ app_metadata?: any;
+}
+
+/** Represents an Auth0UserProfile that has a Microsoft Account as the primary identity. */
+interface MicrosoftUserProfile extends Auth0UserProfile {
+ emails: string[];
+}
+
+/** Represents an Auth0UserProfile that has an Office365 account as the primary identity. */
+interface Office365UserProfile extends Auth0UserProfile {
+ tenantid: string;
+ upn: string;
+}
+
+/** Represents an Auth0UserProfile that has an Active Directory account as the primary identity. */
+interface AdfsUserProfile extends Auth0UserProfile {
+ issuer: string;
+}
+
+/** Represents multiple identities assigned to a user. */
+interface Auth0Identity {
+ access_token: string;
+ connection: string;
+ isSocial: boolean;
+ provider: string;
+ user_id: string;
+}
+
+interface Auth0DecodedHash {
+ access_token: string;
+ id_token: string;
+ profile: Auth0UserProfile;
+ state: any;
+}
+
+interface Auth0PopupOptions {
+ width: number;
+ height: number;
+}
+
+interface Auth0LoginOptions {
+ auto_login?: boolean;
+ connection?: string;
+ email?: string;
+ username?: string;
+ password?: string;
+ popup?: boolean;
+ popupOptions?: Auth0PopupOptions;
+}
+
+interface Auth0SignupOptions extends Auth0LoginOptions {
+ auto_login: boolean;
+}
+
+interface Auth0Error {
+ code: any;
+ details: any;
+ name: string;
+ message: string;
+ status: any;
+}
+
+/** Represents the response from an API Token Delegation request. */
+interface Auth0DelegationToken {
+ /** The length of time in seconds the token is valid for. */
+ expires_in: string;
+ /** The JWT for delegated access. */
+ id_token: string;
+ /** The type of token being returned. Possible values: "Bearer" */
+ token_type: string;
+}
+
+declare var Auth0: Auth0Static;
+
+declare module "auth0-js" {
+ export = Auth0
+}
diff --git a/auth0.lock/auth0.lock-tests.ts b/auth0.lock/auth0.lock-tests.ts
index 07a7cf8323..d466cf5937 100644
--- a/auth0.lock/auth0.lock-tests.ts
+++ b/auth0.lock/auth0.lock-tests.ts
@@ -1,4 +1,4 @@
-///
+///
///
const CLIENT_ID = "YOUR_AUTH0_APP_CLIENTID";
diff --git a/auth0.lock/auth0.lock.d.ts b/auth0.lock/auth0.lock.d.ts
index 7a459afd97..43d842aecc 100644
--- a/auth0.lock/auth0.lock.d.ts
+++ b/auth0.lock/auth0.lock.d.ts
@@ -3,7 +3,7 @@
// Definitions by: Brian Caruso
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
-///
+///
interface Auth0LockAdditionalSignUpFieldOption {
value: string;
diff --git a/auth0.widget/auth0.widget-tests.ts b/auth0.widget/auth0.widget-tests.ts
index 012e9b9769..f44601986e 100644
--- a/auth0.widget/auth0.widget-tests.ts
+++ b/auth0.widget/auth0.widget-tests.ts
@@ -1,4 +1,4 @@
-///
+///
///
var widget: Auth0WidgetStatic = new Auth0Widget({
diff --git a/auth0.widget/auth0.widget.d.ts b/auth0.widget/auth0.widget.d.ts
index 20694526c3..e36a7f868a 100644
--- a/auth0.widget/auth0.widget.d.ts
+++ b/auth0.widget/auth0.widget.d.ts
@@ -3,7 +3,7 @@
// Definitions by: Robert McLaws
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
-///
+///
interface Auth0WidgetStatic {
diff --git a/auth0/auth0-tests.ts b/auth0/auth0-tests.ts
index 9cd903b306..a1357246f3 100644
--- a/auth0/auth0-tests.ts
+++ b/auth0/auth0-tests.ts
@@ -1,23 +1,51 @@
-///
+///
-var auth0 = new Auth0({
- domain: 'mine.auth0.com',
- clientID: 'dsa7d77dsa7d7',
- callbackURL: 'http://my-app.com/callback',
- callbackOnLocationHash: true
+import * as auth0 from 'auth0';
+
+const management = new auth0.ManagementClient({
+ token: '{YOUR_API_V2_TOKEN}',
+ domain: '{YOUR_ACCOUNT}.auth0.com'
});
-auth0.login({
- connection: 'google-oauth2',
- popup: true,
- popupOptions: {
- width: 450,
- height: 800
- }
-}, (err, profile, idToken, accessToken, state) => {
- if (err) {
- alert("something went wrong: " + err.message);
- return;
- }
- alert('hello ' + profile.name);
- });
+const auth = new auth0.AuthenticationClient({
+ domain: '{YOUR_ACCOUNT}.auth0.com',
+ clientId: '{OPTIONAL_CLIENT_ID}'
+});
+
+// Using a callback.
+management.getUsers((err: Error, users: auth0.User[]) => {
+ if (err) {
+ // Handle error.
+ }
+ console.log(users);
+});
+
+// Using a Promise.
+management
+ .getUsers()
+ .then((users) => {
+ console.log(users);
+ })
+ .catch((err) => {
+ // Handle the error.
+ });
+
+management
+ .createUser({
+ connection: 'My-Connection',
+ email: 'hi@me.co',
+ }).then((user) => {
+ console.log(user);
+ }).catch((err) => {
+ // Handle the error.
+ });
+
+auth
+ .requestChangePasswordEmail({
+ connection: 'My-Connection',
+ email: 'hi@me.co',
+ }).then((response) => {
+ console.log(response);
+ }).catch((err) => {
+ // Handle the error.
+ });
diff --git a/auth0/auth0.d.ts b/auth0/auth0.d.ts
index 5ca8487f85..e367d30411 100644
--- a/auth0/auth0.d.ts
+++ b/auth0/auth0.d.ts
@@ -1,132 +1,95 @@
-// Type definitions for Auth0.js
-// Project: http://auth0.com
-// Definitions by: Robert McLaws
+// Type definitions for auth0 v2.3.1
+// Project: https://github.com/auth0/node-auth0
+// Definitions by: Seth Westphal
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
-/** Extensions to the browser Window object. */
-interface Window {
- /** Allows you to pass the id_token to other APIs, as specified in https://docs.auth0.com/apps-apis */
+///
+
+declare module "auth0" {
+
+ import * as Promise from 'bluebird';
+
+ export interface ManagementClientOptions {
token: string;
-}
+ domain?: string;
+ }
-/** This is the interface for the main Auth0 client. */
-interface Auth0Static {
-
- new(options: Auth0ClientOptions): Auth0Static;
- changePassword(options: any, callback?: Function): void;
- decodeJwt(jwt: string): any;
- login(options: any, callback: (error?: Auth0Error, profile?: Auth0UserProfile, id_token?: string, access_token?: string, state?: string) => any): void;
- loginWithPopup(options: Auth0LoginOptions, callback: (error?: Auth0Error, profile?: Auth0UserProfile, id_token?: string, access_token?: string, state?: string) => any): void;
- loginWithResourceOwner(options: Auth0LoginOptions, callback: (error?: Auth0Error, profile?: Auth0UserProfile, id_token?: string, access_token?: string, state?: any) => any): void;
- loginWithUsernamePassword(options: Auth0LoginOptions, callback: (error?: Auth0Error, profile?: Auth0UserProfile, id_token?: string, access_token?: string, state?: string) => any): void;
- logout(query: string): void;
- getConnections(callback?: Function): void;
- refreshToken(refreshToken: string, callback: (error?: Auth0Error, delegationResult?: Auth0DelegationToken) => any): void;
- getDelegationToken(targetClientId: string, id_token: string, options: any, callback: (error?: Auth0Error, delegationResult?: Auth0DelegationToken) => any): void;
- getProfile(id_token: string, callback?: Function): Auth0UserProfile;
- getSSOData(withActiveDirectories: any, callback?: Function): void;
- parseHash(hash: string): Auth0DecodedHash;
- signup(options: Auth0SignupOptions, callback: Function): void;
- validateUser(options: any, callback: (error?: Auth0Error, valid?: any) => any): void;
-}
-
-/** Represents constructor options for the Auth0 client. */
-interface Auth0ClientOptions {
- clientID: string;
- callbackURL: string;
- callbackOnLocationHash?: boolean;
- domain: string;
- forceJSONP?: boolean;
-}
-
-/** Represents a normalized UserProfile. */
-interface Auth0UserProfile {
- email: string;
- family_name: string;
- gender: string;
- given_name: string;
- locale: string;
- name: string;
- nickname: string;
- picture: string;
- user_id: string;
- /** Represents one or more Identities that may be associated with the User. */
- identities: Auth0Identity[];
- user_metadata?: any;
- app_metadata?: any;
-}
-
-/** Represents an Auth0UserProfile that has a Microsoft Account as the primary identity. */
-interface MicrosoftUserProfile extends Auth0UserProfile {
- emails: string[];
-}
-
-/** Represents an Auth0UserProfile that has an Office365 account as the primary identity. */
-interface Office365UserProfile extends Auth0UserProfile {
- tenantid: string;
- upn: string;
-}
-
-/** Represents an Auth0UserProfile that has an Active Directory account as the primary identity. */
-interface AdfsUserProfile extends Auth0UserProfile {
- issuer: string;
-}
-
-/** Represents multiple identities assigned to a user. */
-interface Auth0Identity {
- access_token: string;
+ export interface UserData {
connection: string;
- isSocial: boolean;
- provider: string;
- user_id: string;
-}
-
-interface Auth0DecodedHash {
- access_token: string;
- id_token: string;
- profile: Auth0UserProfile;
- state: any;
-}
-
-interface Auth0PopupOptions {
- width: number;
- height: number;
-}
-
-interface Auth0LoginOptions {
- auto_login?: boolean;
- connection?: string;
email?: string;
username?: string;
password?: string;
- popup?: boolean;
- popupOptions?: Auth0PopupOptions;
-}
+ phone_number?: string;
+ user_metadata?: {};
+ email_verified?: boolean;
+ app_metadata?: {};
+ }
-interface Auth0SignupOptions extends Auth0LoginOptions {
- auto_login: boolean;
-}
+ export interface GetUsersData {
+ per_page?: number;
+ page?: number;
+ include_totals?: boolean;
+ sort?: string;
+ connection?: string;
+ fields?: string;
+ include_fields?: boolean;
+ q?: string;
+ search_engine?: string;
+ }
-interface Auth0Error {
- code: any;
- details: any;
- name: string;
- message: string;
- status: any;
-}
+ export interface User {
+ email?: string;
+ email_verified?: boolean;
+ username?: string;
+ phone_number?: string;
+ phone_verified?: boolean;
+ user_id?: string;
+ created_at?: string;
+ updated_at?: string;
+ identities?: Identity[];
+ app_metadata?: {};
+ user_metadata?: {};
+ picture?: string;
+ name?: string;
+ nickname?: string;
+ multifactor?: string[];
+ last_ip?: string;
+ last_login?: string;
+ logins_count?: number;
+ blocked?: boolean;
+ }
-/** Represents the response from an API Token Delegation request. */
-interface Auth0DelegationToken {
- /** The length of time in seconds the token is valid for. */
- expires_in: string;
- /** The JWT for delegated access. */
- id_token: string;
- /** The type of token being returned. Possible values: "Bearer" */
- token_type: string;
-}
+ export interface Identity {
+ connection: string;
+ user_id: string;
+ provider: string;
+ isSocial: boolean;
+ }
-declare var Auth0: Auth0Static;
+ export class ManagementClient {
+ constructor(options: ManagementClientOptions);
+
+ getUsers(params?: GetUsersData): Promise;
+ getUsers(params?: GetUsersData, cb?: (err: Error, users: User[]) => void): void;
+ createUser(data: UserData): Promise;
+ createUser(data: UserData, cb: (err: Error, data: User) => void): void;
+ }
+
+ export interface AuthenticationClientOptions {
+ clientId?: string;
+ domain: string;
+ }
+
+ export interface RequestChangePasswordEmailData {
+ connection: string;
+ email: string;
+ }
+
+ export class AuthenticationClient {
+ constructor(options: AuthenticationClientOptions);
+
+ requestChangePasswordEmail(data: RequestChangePasswordEmailData): Promise;
+ requestChangePasswordEmail(data: RequestChangePasswordEmailData, cb: (err: Error, message: string) => void): void;
+ }
-declare module "auth0" {
- export = Auth0
}
diff --git a/autobind-decorator/autobind-decorator-tests.ts b/autobind-decorator/autobind-decorator-tests.ts
new file mode 100644
index 0000000000..e428604802
--- /dev/null
+++ b/autobind-decorator/autobind-decorator-tests.ts
@@ -0,0 +1,43 @@
+///
+
+import autobind = require('autobind-decorator');
+
+class Test {
+ public static what: string = 'static';
+
+ @autobind
+ public static test(): void {
+ console.log(this.what);
+ }
+
+ public constructor(public what: string) {
+ this.what = what;
+ }
+
+ @autobind
+ public test(): void {
+ console.warn(this.what);
+ }
+}
+
+const tester: Test = new Test('bind');
+const { test } = tester;
+tester.test(); // warns 'bind'.
+test(); // warns 'bind'.
+Test.test(); // logs 'static'.
+
+@autobind
+class Component {
+ public constructor(private someMember: string) {
+ this.someMember = someMember;
+ }
+
+ public someMethod(): void {
+ console.error(this.someMember);
+ }
+}
+
+const component: Component = new Component('React vs Angular2');
+const { someMethod } = component;
+component.someMethod(); // errors 'React vs Angular2'
+someMethod(); // errors 'React vs Angular2'
diff --git a/autobind-decorator/autobind-decorator.d.ts b/autobind-decorator/autobind-decorator.d.ts
new file mode 100644
index 0000000000..51ba89c9bf
--- /dev/null
+++ b/autobind-decorator/autobind-decorator.d.ts
@@ -0,0 +1,10 @@
+// Type definitions for autobind-decorator v1.3.3
+// Project: https://github.com/andreypopp/autobind-decorator
+// Definitions by: Ivo Stratev
+// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
+
+declare module 'autobind-decorator' {
+ function autobind(target: TFunction): TFunction | void;
+ function autobind(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor | void;
+ export = autobind;
+}
diff --git a/autobind-decorator/autobind-decorator.ts.tscparams b/autobind-decorator/autobind-decorator.ts.tscparams
new file mode 100644
index 0000000000..1ee3d05cb6
--- /dev/null
+++ b/autobind-decorator/autobind-decorator.ts.tscparams
@@ -0,0 +1 @@
+--experimentalDecorators
diff --git a/aws-lambda/aws-lambda-tests.ts b/aws-lambda/aws-lambda-tests.ts
index fd289dcb7f..f562b59d3d 100644
--- a/aws-lambda/aws-lambda-tests.ts
+++ b/aws-lambda/aws-lambda-tests.ts
@@ -4,46 +4,37 @@ import lambda = require('aws-lambda');
var str: string;
var date: Date;
-var sns: lambda.SNS;
-var kinesis: lambda.Kinesis;
-var recordsList: lambda.Record[];
var anyObj: any;
var num: number;
-
-/* Records */
-var records: lambda.Records;
-
-recordsList = records.Records;
-
-/* Record */
-var record: lambda.Record;
-
-str = record.EventVersion;
-str = record.EventSubscriptionArn;
-str = record.EnventSource;
-sns = record.Sns;
-kinesis = record.kinesis;
-
-/* SNS */
-str = sns.Type;
-str = sns.MessageId;
-str = sns.TopicArn;
-str = sns.Subject;
-str = sns.Message;
-date = sns.Timestamp;
-
-/* Kinesis */
-var kinesis: lambda.Kinesis;
-
-str = kinesis.data;
+var identity: lambda.CognitoIdentity;
+var error: Error;
+var b: boolean;
+var clientCtx: lambda.ClientContext;
/* Context */
var context: lambda.Context;
-context.log(str, anyObj);
-context.fail(str);
-context.succeed(str);
-context.succeed(anyObj);
-context.succeed(str, anyObj);
+b = context.callbackWaitsForEmptyEventLoop;
+str = context.functionName;
+str = context.functionVersion;
+str = context.invokedFunctionArn;
+num = context.memoryLimitInMB;
str = context.awsRequestId;
-num = context.getRemainingTimeInMillis();
\ No newline at end of file
+str = context.logGroupName;
+str = context.logStreamName;
+identity = context.identity;
+clientCtx = context.clientContext;
+
+/* CognitoIdentity */
+var identity: lambda.CognitoIdentity;
+
+str = identity.cognitoIdentityId;
+str = identity.cognitoIdentityPoolId;
+
+/* Callback */
+function callback(cb: lambda.Callback) {
+ cb();
+ cb(null);
+ cb(error);
+ cb(null, anyObj);
+}
\ No newline at end of file
diff --git a/aws-lambda/aws-lambda.d.ts b/aws-lambda/aws-lambda.d.ts
index cdd8e2f506..c9a66a3783 100644
--- a/aws-lambda/aws-lambda.d.ts
+++ b/aws-lambda/aws-lambda.d.ts
@@ -1,43 +1,68 @@
// Type definitions for AWS Lambda
// Project: http://docs.aws.amazon.com/lambda
-// Definitions by: Michael Skarum
+// Definitions by: James Darbyshire , Michael Skarum , Stef Heyenrath
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare module "aws-lambda" {
+ // Context
+ // http://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-context.html
+ interface Context {
+ // Properties
+ callbackWaitsForEmptyEventLoop: boolean;
+ functionName: string;
+ functionVersion: string;
+ invokedFunctionArn: string;
+ memoryLimitInMB: number;
+ awsRequestId: string;
+ logGroupName: string;
+ logStreamName: string;
+ identity?: CognitoIdentity;
+ clientContext?: ClientContext;
+
+ // Functions
+ getRemainingTimeInMillis(): number;
- export interface Records {
- Records: Record[];
- }
- interface Record {
- EventVersion: string;
- EventSubscriptionArn: string;
- EnventSource: string;
- Sns: SNS;
- kinesis: Kinesis;
- }
- interface SNS {
- Type: string;
- MessageId: string;
- TopicArn: string;
- Subject: string;
- Message: string;
- Timestamp: Date;
- }
-
- interface Kinesis {
- data: string;
- }
-
- export interface Context {
+ // Functions for compatibility with earlier Node.js Runtime v0.10.42
log(message: string, object: any): void;
fail(message: string): void;
succeed(message: string): void;
succeed(object: any): void;
- succeed(message: string, object: any): void;
- awsRequestId: string;
- getRemainingTimeInMillis(): number;
+ succeed(message: string, object: any): void;
}
-
-
- export type Callback = (error?: Error, message?: string) => void;
+
+ interface CognitoIdentity {
+ cognitoIdentityId: string;
+ cognitoIdentityPoolId: string;
+ }
+
+ interface ClientContext {
+ client: ClientContextClient;
+ Custom?: any;
+ env: ClientContextEnv;
+ }
+
+ interface ClientContextClient {
+ installationId: string;
+ appTitle: string;
+ appVersionName: string;
+ appVersionCode: string;
+ appPackageName: string;
+ }
+
+ interface ClientContextEnv {
+ platformVersion: string;
+ platform: string;
+ make: string;
+ model: string;
+ locale: string;
+ }
+
+ /**
+ * Optional callback parameter.
+ * http://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-handler.html
+ *
+ * @param error – an optional parameter that you can use to provide results of the failed Lambda function execution.
+ * @param result – an optional parameter that you can use to provide the result of a successful function execution. The result provided must be JSON.stringify compatible.
+ */
+ export type Callback = (error?: Error, result?: any) => void;
}
\ No newline at end of file
diff --git a/aws-sdk/aws-sdk.d.ts b/aws-sdk/aws-sdk.d.ts
index cb35f34e97..09ec2f6267 100644
--- a/aws-sdk/aws-sdk.d.ts
+++ b/aws-sdk/aws-sdk.d.ts
@@ -226,7 +226,7 @@ declare module "aws-sdk" {
constructor(options?: any);
endpoint: Endpoint;
- getObject(params: s3.GetObjectRequest, callback: (err: Error, data: any) => void): void;
+ getObject(params: s3.GetObjectRequest, callback?: (err: Error, data: any) => void): any;
putObject(params: s3.PutObjectRequest, callback: (err: Error, data: any) => void): void;
deleteObject(params: s3.DeleteObjectRequest, callback: (err: Error, data: any) => void): void;
headObject(params: s3.HeadObjectRequest, callback: (err: Error, data: any) => void): void;
@@ -235,6 +235,12 @@ declare module "aws-sdk" {
upload(params?: s3.PutObjectRequest, options?: s3.UploadOptions, callback?: (err: Error, data: any) => void): void;
listObjects(params: s3.ListObjectRequest, callback: (err: Error, data: s3.ListObjectResponse) => void): void;
listObjectsV2(params: s3.ListObjectV2Request, callback: (err: Error, data: s3.ListObjectV2Response) => void): void;
+ waitFor(state: string, params: s3.HeadObjectRequest, callback: (err: Error, data: any) => void): void;
+
+ createMultipartUpload(params: any, callback: (err: Error, data: any) => void): void;
+ uploadPart(params: any, callback: (err: Error, data: any) => void): void;
+ listParts(params: any, callback: (err: Error, data: any) => void): void;
+ completeMultipartUpload(params: any, callback: (err: Error, data: any) => void): void;
}
export class STS {
diff --git a/axe-core/axe-core-tests.ts b/axe-core/axe-core-tests.ts
new file mode 100644
index 0000000000..7decb865c2
--- /dev/null
+++ b/axe-core/axe-core-tests.ts
@@ -0,0 +1,91 @@
+///
+
+var context:any = document
+var $fixture:any = {}
+
+// axe.a11yCheck config
+axe.a11yCheck(context, {}, (results) => {
+ // axe's results object
+ console.log(results.passes.length)
+ console.log(results.violations.length)
+});
+// axe.a11yCheck include/exclude
+axe.a11yCheck({include: [['#id1'], ['#id2']]}, {}, (results) => {
+ console.log(results)
+})
+axe.a11yCheck({exclude: [$fixture[0]]}, {}, (results) => {
+ console.log(results)
+})
+var tagConfigRunOnly: axe.RunOnly = {
+ type: 'tag',
+ values: ['wcag2a']
+}
+var tagConfig = {
+ runOnly: tagConfigRunOnly
+}
+axe.a11yCheck(context, tagConfig, (results) => {
+ console.log(results)
+})
+var includeExcludeTagsRunOnly: axe.RunOnly = {
+ type: 'tags',
+ value: {
+ include: ['wcag2a', 'wcag2aa'],
+ exclude: ['experimental']
+ }
+}
+var includeExcludeTagsConfig = {
+ runOnly: includeExcludeTagsRunOnly
+}
+axe.a11yCheck(context, includeExcludeTagsConfig, (results) => {
+ console.log(results)
+})
+var someRulesConfig = {
+ rules: {
+ "color-contrast": {enabled: 'false'},
+ "heading-order": {enabled: 'true'}
+ }
+}
+axe.a11yCheck(context, someRulesConfig, (results) => {
+ console.log(results)
+})
+
+// axe.configure
+var spec: axe.Spec = {
+ branding: {
+ brand: 'foo',
+ application: 'bar'
+ },
+ reporter: 'v1',
+ checks: [{
+ id: 'custom-check',
+ evaluate: function() {
+ return true
+ }
+ }],
+ rules: [{
+ id: 'custom-rule',
+ any: ['custom-check']
+ }]
+}
+axe.configure(spec)
+
+axe.reset()
+
+axe.getRules(['wcag2aa'])
+typeof axe.getRules() === 'object'
+
+// Plugins
+var pluginSrc: axe.AxePlugin = {
+ id: 'doStuff',
+ run: (data:any, callback:Function) => {
+ callback()
+ },
+ commands: [{
+ id: 'run-doStuff',
+ callback: (data:any, callback:Function) => {
+ axe.plugins['doStuff'].run(data, callback)
+ }
+ }]
+}
+axe.registerPlugin(pluginSrc)
+axe.cleanup()
diff --git a/axe-core/axe-core.d.ts b/axe-core/axe-core.d.ts
new file mode 100644
index 0000000000..98818e75cc
--- /dev/null
+++ b/axe-core/axe-core.d.ts
@@ -0,0 +1,159 @@
+// Type definitions for axe-core 2.0.5
+// Project: https://github.com/dequelabs/axe-core
+// Definitions by: Marcy Sutton
+// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
+
+declare namespace axe {
+
+ export type ImpactValue = "minor" | "moderate" | "serious" | "critical";
+
+ export type TagValue = "wcag2a" | "wcag2aa" | "section508" | "best-practice";
+
+ export type ReporterVersion = "v1" | "v2";
+
+ export type RunOnlyType = "rule" | "rules" | "tag" | "tags";
+
+ export interface ElementContext {
+ node?: Object,
+ selector?: string,
+ include?: any[],
+ exclude?: any[]
+ }
+ export interface RunOnly {
+ type: RunOnlyType,
+ value?: {
+ include?: string[],
+ exclude?: string[]
+ }
+ values?: TagValue[]
+ }
+ export interface AxeResults {
+ url: string,
+ timestamp: string,
+ passes: Pass[],
+ violations: Violation[]
+ }
+ export interface Pass {
+ description: string,
+ help: string,
+ helpUrl: string,
+ id: string,
+ impact: ImpactValue,
+ tags: TagValue[],
+ nodes: NodeResult[]
+ }
+ export interface Violation {
+ description: string,
+ help: string,
+ helpUrl: string,
+ id: string,
+ impact: ImpactValue,
+ tags: TagValue[],
+ nodes: NodeResult[]
+ }
+ export interface NodeResult {
+ html: string,
+ impact: ImpactValue,
+ target: string[],
+ any: CheckResult[],
+ all: CheckResult[],
+ none: CheckResult[]
+ }
+ export interface CheckResult {
+ id: string,
+ impact: string,
+ message: string,
+ data: any,
+ relatedNodes?: RelatedNode[]
+ }
+ export interface RelatedNode {
+ target: string[],
+ html: string
+ }
+ export interface Spec {
+ branding?: {
+ brand: string,
+ application: string
+ },
+ reporter?: ReporterVersion,
+ checks?: Check[],
+ rules?: Rule[]
+ }
+ export interface Check {
+ id: string,
+ evaluate: Function,
+ after?: Function,
+ options?: any,
+ matches?: string,
+ enabled?: boolean
+ }
+ export interface Rule {
+ id: string,
+ selector?: string,
+ excludeHidden?: boolean,
+ enabled?: boolean,
+ pageLevel?: boolean,
+ any?: string[],
+ all?: string[],
+ none?: string[],
+ tags?: string[],
+ matches?: string
+ }
+ export interface AxePlugin {
+ id: string,
+ run(...args:any[]): any,
+ commands: {
+ id: string,
+ callback(...args:any[]): void
+ }[],
+ cleanup?(callback:Function): void
+ }
+
+ export let plugins: any
+
+ /**
+ * Starts analysis on the current document and its subframes
+ *
+ * @param {Object} context The `Context` specification object @see Context
+ * @param {Array} options Options passed into rules or checks, temporarily modifyint them.
+ * @param {Function} callback The function to invoke when analysis is complete.
+ * @returns {Object} results The aXe results object
+ */
+ export function a11yCheck(context: ElementContext, options: {runOnly?: RunOnly, rules?: Object}, callback: (results:AxeResults) => void): AxeResults
+
+ /**
+ * Method for configuring the data format used by aXe. Helpful for adding new
+ * rules, which must be registered with the library to execute.
+ * @param {Spec} Spec Object with valid `branding`, `reporter`, `checks` and `rules` data
+ */
+ export function configure(spec: Spec): void
+
+ /**
+ * Searches and returns rules that contain a tag in the list of tags.
+ * @param {Array} tags Optional array of tags
+ * @return {Array} Array of rules
+ */
+ export function getRules(tags?: string[]): Object[]
+
+ /**
+ * Restores the default axe configuration
+ */
+ export function reset(): void
+
+ /**
+ * Function to register a plugin configuration in document and its subframes
+ * @param {Object} plugin A plugin configuration object
+ */
+ export function registerPlugin(plugin: AxePlugin): void
+
+ /**
+ * Function to clean up plugin configuration in document and its subframes
+ */
+ export function cleanup(): void
+
+}
+
+// axe is also available as a module
+declare module "axe-core" {
+ export = axe;
+}
diff --git a/azure-mobile-apps/azure-mobile-apps-tests.ts b/azure-mobile-apps/azure-mobile-apps-tests.ts
index 093932c2fb..302f732889 100644
--- a/azure-mobile-apps/azure-mobile-apps-tests.ts
+++ b/azure-mobile-apps/azure-mobile-apps-tests.ts
@@ -72,6 +72,13 @@ table.read.use([function () {}, function () {}]);
table.read.use(function () {}, function () {});
table.use(function () {}).use(function () {}).read(function () {}).use(function () {})
+table.access = undefined;
+table.access = 'authenticated';
+table.read.access = 'anonymous';
+table.update.access = 'disabled';
+table.delete.access = 'authenticated';
+table.insert.access = 'authenticated';
+
// Express.Table, instantiated from the static require('azure-mobile-apps').table()
// This is going to be interesting if we ever support more than one provider
var table2 = mobileApps.table();
@@ -84,4 +91,14 @@ mobileApps.logger.debug('a debug message')
// Query
queries.create('table').where({ x: 10 }).select('col1,col2');
-mobileApps.query.create('table');
\ No newline at end of file
+mobileApps.query.create('table');
+
+// custom sql query
+mobileApp.api.add('query', { authorize: true, get: (req, res, next) => {
+ req.azureMobile.data.execute({
+ sql: "SELECT * FROM TODOITEM WHERE COMPLETE = :complete",
+ parameters: [
+ { name: 'complete', value: 1 }
+ ]
+ }).then(x => {});
+}, delete: function () {} });
diff --git a/azure-mobile-apps/azure-mobile-apps.d.ts b/azure-mobile-apps/azure-mobile-apps.d.ts
index 0a42fa9ecf..a17e41e2d6 100644
--- a/azure-mobile-apps/azure-mobile-apps.d.ts
+++ b/azure-mobile-apps/azure-mobile-apps.d.ts
@@ -47,6 +47,7 @@ declare namespace Azure.MobileApps {
interface Table {
authorize?: boolean;
+ access?: AccessType;
autoIncrement?: boolean;
dynamicSchema?: boolean;
name: string;
@@ -66,8 +67,11 @@ declare namespace Azure.MobileApps {
(operationHandler: (context: Context) => void): Table;
use(...middleware: Middleware[]): Table;
use(middleware: Middleware[]): Table;
+ access: AccessType;
}
+ type AccessType = 'anonymous' | 'authenticated' | 'disabled';
+
interface Tables {
configuration: Configuration;
add(name: string, definition?: Table | TableDefinition): void;
@@ -215,7 +219,7 @@ declare namespace Azure.MobileApps {
item: any;
req: Express.Request;
res: Express.Response;
- data: (table: TableDefinition) => Data.Table;
+ data: ContextData;
tables: (tableName: string) => Data.Table;
user: User;
push: typeof nh;
@@ -223,6 +227,21 @@ declare namespace Azure.MobileApps {
execute(): Thenable;
}
+ interface ContextData {
+ (table: TableDefinition): Data.Table;
+ execute(q: SqlQueryDefinition): Thenable;
+ }
+
+ interface SqlQueryDefinition {
+ sql: string;
+ parameters?: SqlParameterDefinition[];
+ }
+
+ interface SqlParameterDefinition {
+ name: string;
+ value: any;
+ }
+
interface TableDefinition {
authorize?: boolean;
autoIncrement?: boolean;
diff --git a/azure-mobile-services-client/AzureMobileServicesClient.d.ts b/azure-mobile-services-client/AzureMobileServicesClient.d.ts
index afd6014598..6fa0f9c475 100644
--- a/azure-mobile-services-client/AzureMobileServicesClient.d.ts
+++ b/azure-mobile-services-client/AzureMobileServicesClient.d.ts
@@ -17,7 +17,7 @@ declare namespace Microsoft.WindowsAzure {
login(provider: string, token: string): asyncPromise;
login(provider: string, callback: (error: any, user: User) => void ): void;
login(provider: string): asyncPromise;
- logout(): void;
+ logout(): asyncPromise;
getTable(tableName: string): MobileServiceTable;
withFilter(serviceFilter: (request: any, next: (request: any, callback: (error: any, response: any) => void) => void, callback: (error: any, response: any) => void) => void): MobileServiceClient;
/**
diff --git a/backlog-js/backlog-js-tests.ts b/backlog-js/backlog-js-tests.ts
new file mode 100644
index 0000000000..979eb57ca4
--- /dev/null
+++ b/backlog-js/backlog-js-tests.ts
@@ -0,0 +1,88 @@
+///
+
+import * as backlogjs from 'backlog-js';
+
+const host = 'example.backlog.jp';
+const apiKey = 'apiKey';
+const clientId = 'clientId';
+const clientSecret = 'clientSecret';
+const redirectUri = 'redirectUri';
+const state = 'state';
+const code = 'code';
+const refreshToken = 'refreshToken';
+const configure = { host, apiKey }
+const credentials = { clientId, clientSecret }
+
+const oauth2 = new backlogjs.OAuth2(credentials);
+oauth2.getAuthorizationURL({ host, redirectUri, state });
+oauth2.getAccessToken({ host, code, redirectUri }).then(data => {}).catch(err => {});
+oauth2.refreshAccessToken({ host, refreshToken }).then(data => {}).catch(err => {});
+
+const backlog = new backlogjs.Backlog(configure);
+backlog.getSpace().then(data => { }).catch(err => { });
+backlog.getSpaceActivities({
+ activityTypeId: [
+ backlogjs.Option.ActivityType.IssueCreated,
+ backlogjs.Option.ActivityType.IssueUpdated
+ ],
+ minId: 1,
+ maxId: 2,
+ count: 3,
+ order: "asc"
+}).then(data => { }).catch(err => { });
+backlog.getSpaceDiskUsage().then(data => { }).catch(err => { });
+backlog.getSpaceIcon().then(data => { }).catch(err => { });
+backlog.postSpaceAttachment(new FormData()).then(data => { }).catch(err => { });
+backlog.getUsers().then(data => { }).catch(err => { });
+backlog.getUser(1).then(data => { }).catch(err => { });
+backlog.postUser({
+ userId: 'string',
+ password: 'string',
+ name: 'string',
+ mailAddress: 'string',
+ roleType: backlogjs.Option.User.RoleType.Admin
+}).then(data => { }).catch(err => { });
+backlog.patchUser(1, {
+ password: 'string',
+ name: 'string',
+ mailAddress: 'string',
+ roleType: backlogjs.Option.User.RoleType.Admin
+}).then(data => { }).catch(err => { });
+backlog.deleteUser(1).then(data => { }).catch(err => { });
+backlog.getMyself().then(data => { }).catch(err => { });
+backlog.getUserActivities(1, {
+ activityTypeId: [
+ backlogjs.Option.ActivityType.IssueCreated,
+ backlogjs.Option.ActivityType.IssueUpdated
+ ],
+ minId: 1,
+ maxId: 2,
+ count: 3,
+ order: "asc"
+}).then(data => { }).catch(err => { });
+backlog.getUserStars(1, {
+ minId: 1,
+ maxId: 2,
+ count: 3,
+ order: "asc"
+}).then(data => { }).catch(err => { });
+backlog.getUserStarsCount(1, {
+ since: 'YYYY-MM-DD',
+ until: 'YYYY-MM-DD'
+}).then(data => { }).catch(err => { });
+backlog.getRecentlyViewedIssues({
+ order: 'asc',
+ offset: 1,
+ count: 2
+}).then(data => { }).catch(err => { });
+backlog.getRecentlyViewedProjects({
+ order: 'asc',
+ offset: 1,
+ count: 2
+}).then(data => { }).catch(err => { });
+backlog.getRecentlyViewedWikis({
+ order: 'asc',
+ offset: 1,
+ count: 2
+}).then(data => { }).catch(err => { });
+backlog.getUserIcon(1).then(data => {}).catch(err => {});
diff --git a/backlog-js/backlog-js.d.ts b/backlog-js/backlog-js.d.ts
new file mode 100644
index 0000000000..353e7e90cd
--- /dev/null
+++ b/backlog-js/backlog-js.d.ts
@@ -0,0 +1,695 @@
+// Type definitions for backlog-js 0.9.0
+// Project: https://github.com/nulab/backlog-js
+// Definitions by: Yuichi Watanabe
+// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
+
+///
+///
+///
+
+declare module 'backlog-js' {
+
+ class Request {
+ private configure;
+ constructor(configure: {
+ host: string;
+ apiKey?: string;
+ accessToken?: string;
+ timeout?: number;
+ });
+ get(path: string, params?: any): Promise;
+ post(path: string, params?: any): Promise;
+ put(path: string, params: any): Promise;
+ patch(path: string, params: any): Promise;
+ delete(path: string, params?: any): Promise;
+ request(options: {
+ method: string;
+ path: string;
+ params?: Params | FormData;
+ }): Promise;
+ checkStatus(response: IResponse): Promise;
+ parseJSON(response: IResponse): Promise;
+ private toFormData(params);
+ private toQueryString(params);
+ webAppBaseURL: string;
+ restBaseURL: string;
+ }
+
+ type Params = {
+ [index: string]: number | string | number[] | string[];
+ };
+
+ export class Backlog extends Request {
+ constructor(configure: {
+ host: string;
+ apiKey?: string;
+ accessToken?: string;
+ timeout?: number;
+ });
+ getSpace(): Promise;
+ getSpaceActivities(params: Option.Space.GetActivitiesParams): Promise;
+ getSpaceNotification(): Promise;
+ putSpaceNotification(params: Option.Space.PutSpaceNotificationParams): Promise;
+ getSpaceDiskUsage(): Promise;
+ getSpaceIcon(): Promise;
+ postSpaceAttachment(form: FormData): Promise;
+ getUsers(): Promise;
+ getUser(userId: number): Promise;
+ postUser(params: Option.User.PostUserParams): Promise;
+ patchUser(userId: number, params: Option.User.PatchUserParams): Promise;
+ deleteUser(userId: number): Promise;
+ getMyself(): Promise;
+ getUserActivities(userId: number, params: Option.User.GetUserActivitiesParams): Promise;
+ getUserStars(userId: number, params: Option.User.GetUserStarsParams): Promise;
+ getUserStarsCount(userId: number, params: Option.User.GetUserStarsCountParams): Promise;
+ getRecentlyViewedIssues(params: Option.User.GetRecentlyViewedParams): Promise;
+ getRecentlyViewedProjects(params: Option.User.GetRecentlyViewedParams): Promise;
+ getRecentlyViewedWikis(params: Option.User.GetRecentlyViewedParams): Promise;
+ getUserIcon(userId: number): Promise;
+ getGroups(params: Option.Group.GetGroupsParams): Promise;
+ postGroups(params: Option.Group.PostGroupsParams): Promise;
+ getGroup(groupId: number): Promise;
+ patchGroup(groupId: number, params: Option.Group.PatchGroupParams): Promise;
+ deleteGroup(groupId: number): Promise;
+ getStatuses(): Promise;
+ getResolutions(): Promise;
+ getPriorities(): Promise;
+ postProject(params: Option.Project.PostProjectParams): Promise;
+ getProjects(params?: Option.Project.GetProjectsParams): Promise;
+ getProject(projectIdOrKey: string): Promise;
+ patchProject(projectIdOrKey: string, params: Option.Project.PatchProjectParams): Promise;
+ deleteProject(projectIdOrKey: string): Promise;
+ getProjectActivities(projectIdOrKey: string, params: Option.Space.GetActivitiesParams): Promise;
+ getProjectUsers(projectIdOrKey: string): Promise;
+ deleteProjectUsers(projectIdOrKey: string, params: Option.Project.DeleteProjectUsersParams): Promise;
+ postProjectAdministrators(projectIdOrKey: string, params: Option.Project.PostProjectAdministrators): Promise;
+ getProjectAdministrators(projectIdOrKey: string): Promise;
+ deleteProjectAdministrators(projectIdOrKey: string, params: Option.Project.DeleteProjectAdministrators): Promise;
+ getIssueTypes(projectIdOrKey: string): Promise;
+ postIssueType(projectIdOrKey: string, params: Option.Project.PostIssueTypeParams): Promise;
+ patchIssueType(projectIdOrKey: string, id: number, params: Option.Project.PatchIssueTypeParams): Promise;
+ deleteIssueType(projectIdOrKey: string, id: number, params: Option.Project.DeleteIssueTypeParams): Promise;
+ getCategories(projectIdOrKey: string): Promise;
+ postCategories(projectIdOrKey: string, params: Option.Project.PostCategoriesParams): Promise;
+ patchCategories(projectIdOrKey: string, id: number, params: Option.Project.PatchCategoriesParams): Promise;
+ deleteCategories(projectIdOrKey: string, id: number): Promise;
+ getVersions(projectIdOrKey: string): Promise;
+ postVersions(projectIdOrKey: string, params: Option.Project.PostVersionsParams): Promise;
+ patchVersions(projectIdOrKey: string, id: number, params: Option.Project.PatchVersionsParams): Promise;
+ deleteVersions(projectIdOrKey: string, id: number): Promise;
+ getCustomFields(projectIdOrKey: string): Promise;
+ postCustomField(projectIdOrKey: string, params: Option.Project.PostCustomFieldParams | Option.Project.PostCustomFieldWithNumericParams | Option.Project.PostCustomFieldWithDateParams | Option.Project.PostCustomFieldWithListParams): Promise;
+ patchCustomField(projectIdOrKey: string, id: number, params: Option.Project.PatchCustomFieldParams | Option.Project.PatchCustomFieldWithNumericParams | Option.Project.PatchCustomFieldWithDateParams | Option.Project.PatchCustomFieldWithListParams): Promise;
+ deleteCustomField(projectIdOrKey: string, id: number): Promise;
+ postCustomFieldItem(projectIdOrKey: string, id: number, params: Option.Project.PostCustomFieldItemParams): Promise;
+ patchCustomFieldItem(projectIdOrKey: string, id: number, itemId: number, params: Option.Project.PatchCustomFieldItemParams): Promise;
+ deleteCustomFieldItem(projectIdOrKey: string, id: number, params: Option.Project.PostCustomFieldItemParams): Promise;
+ getSharedFiles(projectIdOrKey: string, path: string, params: Option.Project.GetSharedFilesParams): Promise;
+ getProjectsDiskUsage(projectIdOrKey: string): Promise;
+ getWebhooks(projectIdOrKey: string): Promise;
+ postWebhook(projectIdOrKey: string, params: Option.Project.PostWebhookParams): Promise;
+ getWebhook(projectIdOrKey: string, webhookId: string): Promise;
+ patchWebhook(projectIdOrKey: string, webhookId: string, params: Option.Project.PatchWebhookParams): Promise;
+ deleteWebhook(projectIdOrKey: string, webhookId: string): Promise;
+ postIssue(params: Option.Issue.PostIssueParams): Promise;
+ patchIssue(issueIdOrKey: string, params: Option.Issue.PatchIssueParams): Promise;
+ getIssues(params?: Option.Issue.GetIssuesParams): Promise;
+ getIssue(issueIdOrKey: string): Promise;
+ getIssuesCount(params?: Option.Issue.GetIssuesParams): Promise;
+ deleteIssuesCount(issueIdOrKey: string): Promise;
+ getIssueComments(issueIdOrKey: string, params: Option.Issue.GetIssueCommentsParams): Promise;
+ postIssueComments(issueIdOrKey: string, params: Option.Issue.PostIssueCommentsParams): Promise;
+ getIssueCommentsCount(issueIdOrKey: string): Promise;
+ getIssueComment(issueIdOrKey: string, commentId: number): Promise;
+ patchIssueComment(issueIdOrKey: string, commentId: number, params: Option.Issue.PatchIssueCommentParams): Promise;
+ getIssueCommentNotifications(issueIdOrKey: string, commentId: number): Promise;
+ postIssueCommentNotifications(issueIdOrKey: string, commentId: number, prams: Option.Issue.IssueCommentNotifications): Promise;
+ getIssueAttachments(issueIdOrKey: string): Promise;
+ deleteIssueAttachment(issueIdOrKey: string, attachmentId: string): Promise;
+ getIssueSharedFiles(issueIdOrKey: string): Promise;
+ linkIssueSharedFiles(issueIdOrKey: string, params: Option.Issue.LinkIssueSharedFilesParams): Promise;
+ unlinkIssueSharedFile(issueIdOrKey: string, id: number): Promise;
+ getWikis(projectIdOrKey: number): Promise;
+ getWikisCount(projectIdOrKey: number): Promise;
+ getWikisTags(projectIdOrKey: number): Promise;
+ postWiki(params: Option.Wiki.PostWikiParams): Promise;
+ getWiki(wikiId: number): Promise;
+ patchWiki(wikiId: number, params: Option.Wiki.PatchWikiParams): Promise;
+ deleteWiki(wikiId: number, mailNotify: boolean): Promise;
+ getWikisAttachments(wikiId: number): Promise;
+ postWikisAttachments(wikiId: number, attachmentId: number[]): Promise;
+ deleteWikisAttachments(wikiId: number, attachmentId: number): Promise;
+ getWikisSharedFiles(wikiId: number): Promise;
+ linkWikisSharedFiles(wikiId: number, fileId: number[]): Promise;
+ unlinkWikisSharedFiles(wikiId: number, id: number): Promise;
+ getWikisHistory(wikiId: number, params: Option.Wiki.GetWikisHistoryParams): Promise;
+ getWikisStars(wikiId: number): Promise;
+ postStar(params: Option.Project.PostStarParams): Promise;
+ getNotifications(params: Option.Notification.GetNotificationsParams): Promise;
+ getNotificationsCount(params: Option.Notification.GetNotificationsCountParams): Promise;
+ resetNotificationsMarkAsRead(): Promise;
+ markAsReadNotification(id: number): Promise;
+ getGitRepositories(projectIdOrKey: string): Promise;
+ getGitRepository(projectIdOrKey: string, repoIdOrName: string): Promise;
+ getPullRequests(projectIdOrKey: string, repoIdOrName: string, params: Option.PullRequest.GetPullRequestsParams): Promise;
+ getPullRequestsCount(projectIdOrKey: string, repoIdOrName: string, params: Option.PullRequest.GetPullRequestsParams): Promise;
+ postPullRequest(projectIdOrKey: string, repoIdOrName: string, params: Option.PullRequest.PostPullRequestParams): Promise;
+ getPullRequest(projectIdOrKey: string, repoIdOrName: string, number: number): Promise;
+ patchPullRequest(projectIdOrKey: string, repoIdOrName: string, number: number, params: Option.PullRequest.PatchPullRequestParams): Promise;
+ getPullRequestComments(projectIdOrKey: string, repoIdOrName: string, number: number, params: Option.PullRequest.GetPullRequestCommentsParams): Promise;
+ postPullRequestComments(projectIdOrKey: string, repoIdOrName: string, number: number, params: Option.PullRequest.PostPullRequestCommentsParams): Promise;
+ getPullRequestCommentsCount(projectIdOrKey: string, repoIdOrName: string, number: number): Promise;
+ patchPullRequestComments(projectIdOrKey: string, repoIdOrName: string, number: number, commentId: number, params: Option.PullRequest.PatchPullRequestCommentsParams): Promise;
+ getPullRequestAttachments(projectIdOrKey: string, repoIdOrName: string, number: number): Promise;
+ deletePullRequestAttachment(projectIdOrKey: string, repoIdOrName: string, number: number, attachmentId: number): Promise;
+ getProjectIcon(projectIdOrKey: string): Promise;
+ getSharedFile(projectIdOrKey: string, sharedFileId: number): Promise;
+ getIssueAttachment(issueIdOrKey: string, attachmentId: number): Promise;
+ getWikiAttachment(wikiId: number, attachmentId: number): Promise;
+ getPullRequestAttachment(projectIdOrKey: string, repoIdOrName: string, number: number, attachmentId: number): Promise;
+ private download(path);
+ private upload(path, params);
+ private parseFileData(response);
+ }
+
+ export class OAuth2 {
+ private credentials;
+ private timeout;
+ constructor(credentials: Option.OAuth2.Credentials, timeout?: number);
+ getAuthorizationURL(options: {
+ host: string;
+ redirectUri?: string;
+ state?: string;
+ }): string;
+ getAccessToken(options: {
+ host: string;
+ code: string;
+ redirectUri?: string;
+ }): Promise;
+ refreshAccessToken(options: {
+ host: string;
+ refreshToken: string;
+ }): Promise;
+ }
+
+ import { PassThrough } from 'stream';
+ export namespace Entity {
+ export namespace File {
+ export type FileData = NodeFileData | BrowserFileData;
+ export interface NodeFileData {
+ body: PassThrough;
+ url: string;
+ filename: string;
+ }
+ export interface BrowserFileData {
+ body: any;
+ url: string;
+ blob?: () => Promise;
+ }
+ }
+ export namespace OAuth2 {
+ export interface AccessToken {
+ access_token: string;
+ token_type: string;
+ expires_in: number;
+ refresh_token: string;
+ }
+ }
+ }
+
+
+ export namespace Option {
+ export type Order = "asc" | "desc";
+ export enum ActivityType {
+ Undefined = -1,
+ IssueCreated = 1,
+ IssueUpdated = 2,
+ IssueCommented = 3,
+ IssueDeleted = 4,
+ WikiCreated = 5,
+ WikiUpdated = 6,
+ WikiDeleted = 7,
+ FileAdded = 8,
+ FileUpdated = 9,
+ FileDeleted = 10,
+ SvnCommitted = 11,
+ GitPushed = 12,
+ GitRepositoryCreated = 13,
+ IssueMultiUpdated = 14,
+ ProjectUserAdded = 15,
+ ProjectUserRemoved = 16,
+ NotifyAdded = 17,
+ PullRequestAdded = 18,
+ PullRequestUpdated = 19,
+ PullRequestCommented = 20,
+ PullRequestMerged = 21,
+ }
+ export namespace Notification {
+ export interface GetNotificationsParams {
+ minId?: number;
+ maxId?: number;
+ count?: number;
+ order?: Order;
+ }
+ export interface GetNotificationsCountParams {
+ alreadyRead: boolean;
+ resourceAlreadyRead: boolean;
+ }
+ }
+ export namespace Space {
+ export interface GetActivitiesParams {
+ activityTypeId?: ActivityType[];
+ minId?: number;
+ maxId?: number;
+ count?: number;
+ order?: Order;
+ }
+ export interface PutSpaceNotificationParams {
+ content: string;
+ }
+ }
+ export namespace User {
+ export interface PostUserParams {
+ userId: string;
+ password: string;
+ name: string;
+ mailAddress: string;
+ roleType: RoleType;
+ }
+ export interface PatchUserParams {
+ password?: string;
+ name?: string;
+ mailAddress?: string;
+ roleType?: RoleType;
+ }
+ export enum RoleType {
+ Admin = 1,
+ User = 2,
+ Reporter = 3,
+ Viewer = 4,
+ GuestReporter = 5,
+ GuestViewer = 6,
+ }
+ export interface GetUserActivitiesParams {
+ activityTypeId?: ActivityType[];
+ minId?: number;
+ maxId?: number;
+ count?: number;
+ order?: Order;
+ }
+ export interface GetUserStarsParams {
+ minId?: number;
+ maxId?: number;
+ count?: number;
+ order?: Order;
+ }
+ export interface GetUserStarsCountParams {
+ since?: string;
+ until?: string;
+ }
+ export interface GetRecentlyViewedParams {
+ order?: Order;
+ offset?: number;
+ count?: number;
+ }
+ }
+ export namespace Group {
+ export interface GetGroupsParams {
+ order?: Order;
+ offset?: number;
+ count?: number;
+ }
+ export interface PostGroupsParams {
+ name: string;
+ members?: string[];
+ }
+ export interface PatchGroupParams {
+ name?: string;
+ members?: string[];
+ }
+ }
+ export namespace Project {
+ export type TextFormattingRule = "backlog" | "markdown";
+ export interface PostProjectParams {
+ name: string;
+ key: string;
+ chartEnabled: boolean;
+ projectLeaderCanEditProjectLeader?: boolean;
+ subtaskingEnabled: boolean;
+ textFormattingRule: TextFormattingRule;
+ }
+ export interface PatchProjectParams {
+ name?: string;
+ key?: string;
+ chartEnabled?: boolean;
+ subtaskingEnabled?: boolean;
+ projectLeaderCanEditProjectLeader?: boolean;
+ textFormattingRule?: TextFormattingRule;
+ archived?: boolean;
+ }
+ export interface GetProjectsParams {
+ archived?: boolean;
+ all?: boolean;
+ }
+ export interface DeleteProjectUsersParams {
+ userId: number;
+ }
+ export interface PostProjectAdministrators {
+ userId: number;
+ }
+ export interface DeleteProjectAdministrators {
+ userId: number;
+ }
+ export type IssueTypeColor = "#e30000" | "#990000" | "#934981" | "#814fbc" | "#2779ca" | "#007e9a" | "#7ea800" | "#ff9200" | "#ff3265" | "#666665";
+ export interface PostIssueTypeParams {
+ name: string;
+ color: IssueTypeColor;
+ }
+ export interface PatchIssueTypeParams {
+ name?: string;
+ color?: IssueTypeColor;
+ }
+ export interface DeleteIssueTypeParams {
+ substituteIssueTypeId: number;
+ }
+ export interface PostCategoriesParams {
+ name: string;
+ }
+ export interface PatchCategoriesParams {
+ name: string;
+ }
+ export interface PostVersionsParams {
+ name: string;
+ description: string;
+ startDate: string;
+ releaseDueDate: string;
+ }
+ export interface PatchVersionsParams {
+ name: string;
+ description?: string;
+ startDate?: string;
+ releaseDueDate?: string;
+ archived?: boolean;
+ }
+ export interface PostCustomFieldParams {
+ typeId: FieldType;
+ name: string;
+ applicableIssueTypes?: number[];
+ description?: string;
+ required?: boolean;
+ }
+ export interface PostCustomFieldWithNumericParams extends PostCustomFieldParams {
+ min?: number;
+ max?: number;
+ initialValue?: number;
+ unit?: string;
+ }
+ export interface PostCustomFieldWithDateParams extends PostCustomFieldParams {
+ min?: string;
+ max?: string;
+ initialValueType?: number;
+ initialDate?: string;
+ initialShift?: number;
+ }
+ export interface PostCustomFieldWithListParams extends PostCustomFieldParams {
+ items?: string[];
+ allowInput?: boolean;
+ allowAddItem?: boolean;
+ }
+ export interface PatchCustomFieldParams {
+ name?: string;
+ applicableIssueTypes?: number[];
+ description?: string;
+ required?: boolean;
+ }
+ export interface PatchCustomFieldWithNumericParams extends PatchCustomFieldParams {
+ min?: number;
+ max?: number;
+ initialValue?: number;
+ unit?: string;
+ }
+ export interface PatchCustomFieldWithDateParams extends PatchCustomFieldParams {
+ min?: string;
+ max?: string;
+ initialValueType?: number;
+ initialDate?: string;
+ initialShift?: number;
+ }
+ export interface PatchCustomFieldWithListParams extends PatchCustomFieldParams {
+ items?: string[];
+ allowInput?: boolean;
+ allowAddItem?: boolean;
+ }
+ export interface PostCustomFieldItemParams {
+ name: string;
+ }
+ export interface PatchCustomFieldItemParams {
+ name: string;
+ }
+ export interface GetSharedFilesParams {
+ order?: Order;
+ offset?: number;
+ count?: number;
+ }
+ export interface PostWebhookParams {
+ name?: string;
+ description?: string;
+ hookUrl?: string;
+ allEvent?: boolean;
+ activityTypeIds?: number[];
+ }
+ export interface PatchWebhookParams {
+ name?: string;
+ description?: string;
+ hookUrl?: string;
+ allEvent?: boolean;
+ activityTypeIds?: number[];
+ }
+ export enum FieldType {
+ Text = 1,
+ TextArea = 2,
+ Numeric = 3,
+ Date = 4,
+ SingleList = 5,
+ MultipleList = 6,
+ CheckBox = 7,
+ Radio = 8,
+ }
+ export interface PostStarParams {
+ issueId?: number;
+ commentId?: number;
+ wikiId?: number;
+ pullRequestId?: number;
+ pullRequestCommentId?: number;
+ }
+ }
+ export namespace Issue {
+ export interface PostIssueParams {
+ projectId: number;
+ summary: string;
+ priorityId: number;
+ issueTypeId: number;
+ parentIssueId?: number;
+ description?: string;
+ startDate?: string;
+ dueDate?: string;
+ estimatedHours?: number;
+ actualHours?: number;
+ categoryId?: number[];
+ versionId?: number[];
+ milestoneId?: number[];
+ assigneeId?: number;
+ notifiedUserId?: number[];
+ attachmentId?: number[];
+ [customField_: string]: any;
+ }
+ export interface PatchIssueParams {
+ summary?: string;
+ parentIssueId?: number;
+ description?: string;
+ statusId?: number;
+ resolutionId?: number;
+ startDate?: string;
+ dueDate?: string;
+ estimatedHours?: number;
+ actualHours?: number;
+ issueTypeId?: number;
+ categoryId?: number[];
+ versionId?: number[];
+ milestoneId?: number[];
+ priorityId?: number;
+ assigneeId?: number;
+ notifiedUserId?: number[];
+ attachmentId?: number[];
+ comment?: string;
+ [customField_: string]: any;
+ }
+ export interface GetIssuesParams {
+ projectId?: number[];
+ issueTypeId?: number[];
+ categoryId?: number[];
+ versionId?: number[];
+ milestoneId?: number[];
+ statusId?: number[];
+ priorityId?: number[];
+ assigneeId?: number[];
+ createdUserId?: number[];
+ resolutionId?: number[];
+ parentChild?: ParentChildType;
+ attachment?: boolean;
+ sharedFile?: boolean;
+ sort?: SortKey;
+ order?: Order;
+ offset?: number;
+ count?: number;
+ createdSince?: string;
+ createdUntil?: string;
+ updatedSince?: string;
+ updatedUntil?: string;
+ startDateSince?: string;
+ startDateUntil?: string;
+ dueDateSince?: string;
+ dueDateUntil?: string;
+ id?: number[];
+ parentIssueId?: number[];
+ keyword: string;
+ [customField_: string]: any;
+ }
+ export enum ParentChildType {
+ All = 0,
+ NotChild = 1,
+ Child = 2,
+ NotChildNotParent = 3,
+ Parent = 4,
+ }
+ export type SortKey = "issueType" | "category" | "version" | "milestone" | "summary" | "status" | "priority" | "attachment" | "sharedFile" | "created" | "createdUser" | "updated" | "updatedUser" | "assignee" | "startDate" | "dueDate" | "estimatedHours" | "actualHours" | "childIssue";
+ export interface GetIssueCommentsParams {
+ minId?: number;
+ maxId?: number;
+ count?: number;
+ order?: Order;
+ }
+ export interface PostIssueCommentsParams {
+ content: string;
+ notifiedUserId?: number[];
+ attachmentId?: number[];
+ }
+ export interface PatchIssueCommentParams {
+ content: string;
+ }
+ export interface IssueCommentNotifications {
+ notifiedUserId: number[];
+ }
+ export interface LinkIssueSharedFilesParams {
+ fileId: number[];
+ }
+ }
+ export namespace PullRequest {
+ export interface GetPullRequestsParams {
+ statusId?: number[];
+ assigneeId?: number[];
+ issueId?: number[];
+ createdUserId?: number[];
+ offset?: number;
+ count?: number;
+ }
+ export interface PostPullRequestParams {
+ summary: string;
+ description: string;
+ base: string;
+ branch: string;
+ issueId?: number;
+ assigneeId?: number;
+ notifiedUserId?: number[];
+ attachmentId?: number[];
+ }
+ export interface PatchPullRequestParams {
+ summary?: string;
+ description?: string;
+ issueId?: number;
+ assigneeId?: number;
+ notifiedUserId?: number[];
+ comment?: string[];
+ }
+ export interface GetPullRequestCommentsParams {
+ minId?: number;
+ maxId?: number;
+ count?: number;
+ order?: Order;
+ }
+ export interface PostPullRequestCommentsParams {
+ content: string;
+ notifiedUserId?: number[];
+ }
+ export interface PatchPullRequestCommentsParams {
+ content: string;
+ }
+ }
+ export namespace Wiki {
+ export interface PostWikiParams {
+ projectId: number;
+ name: string;
+ content: string;
+ mailNotify?: boolean;
+ }
+ export interface PatchWikiParams {
+ name?: string;
+ content?: string;
+ mailNotify?: boolean;
+ }
+ export interface GetWikisHistoryParams {
+ minId?: number;
+ maxId?: number;
+ count?: number;
+ order?: Order;
+ }
+ }
+ export namespace OAuth2 {
+ export interface Credentials {
+ clientId: string;
+ clientSecret: string;
+ }
+ }
+ }
+
+ export namespace Error {
+ export class BacklogError extends global.Error {
+ private _name;
+ private _url;
+ private _status;
+ private _body;
+ private _response;
+ constructor(name: BacklogErrorNameType, response: IResponse, body?: {
+ errors: BacklogErrorMessage[];
+ });
+ name: BacklogErrorNameType;
+ url: string;
+ status: number;
+ body: {
+ errors: BacklogErrorMessage[];
+ };
+ response: IResponse;
+ }
+ export class BacklogApiError extends BacklogError {
+ constructor(response: IResponse, body?: {
+ errors: BacklogErrorMessage[];
+ });
+ }
+ export class BacklogAuthError extends BacklogError {
+ constructor(response: IResponse, body?: {
+ errors: BacklogErrorMessage[];
+ });
+ }
+ export class UnexpectedError extends BacklogError {
+ constructor(response: IResponse);
+ }
+ export interface BacklogErrorMessage {
+ message: string;
+ code: number;
+ errorInfo: string;
+ moreInfo: string;
+ }
+ export type BacklogErrorNameType = 'BacklogApiError' | 'BacklogAuthError' | 'UnexpectedError';
+ }
+
+}
diff --git a/blessed/blessed-tests.ts b/blessed/blessed-tests.ts
new file mode 100644
index 0000000000..4e7f7002e6
--- /dev/null
+++ b/blessed/blessed-tests.ts
@@ -0,0 +1,773 @@
+///
+
+import * as blessed from 'blessed';
+
+let screen: blessed.Widgets.Screen = null;
+
+// https://github.com/chjj/blessed/blob/master/test/widget-autopad.js
+
+screen = blessed.screen({
+ dump: __dirname + '/logs/autopad.log',
+ smartCSR: true,
+ autoPadding: true,
+ warnings: true
+});
+
+var box1 = blessed.box({
+ parent: screen,
+ top: 'center',
+ left: 'center',
+ width: 20,
+ height: 10,
+ border: 'line'
+});
+
+var box2 = blessed.box({
+ parent: box1,
+ top: 0,
+ left: 0,
+ width: 10,
+ height: 5,
+ border: 'line'
+});
+
+screen.key('q', function() {
+ return screen.destroy();
+});
+
+screen.render();
+
+// https://github.com/chjj/blessed/blob/master/test/widget-bigtext.js
+
+screen = blessed.screen({
+ dump: __dirname + '/logs/bigtext.log',
+ smartCSR: true,
+ warnings: true
+});
+
+var box = blessed.bigtext({
+ parent: screen,
+ content: 'Hello',
+ shrink: true,
+ width: '80%',
+ // height: '80%',
+ height: 'shrink',
+ // width: 'shrink',
+ border: 'line',
+ fch: ' ',
+ ch: '\u2592',
+ style: {
+ fg: 'red',
+ bg: 'blue',
+ bold: false
+ }
+});
+
+screen.key('q', function() {
+ return screen.destroy();
+});
+
+screen.render();
+
+// https://github.com/chjj/blessed/blob/master/test/widget-csr.js
+
+screen = blessed.screen({
+ dump: __dirname + '/logs/csr.log',
+ smartCSR: true,
+ warnings: true
+});
+
+var lorem = require('fs').readFileSync(__dirname + '/git.diff', 'utf8');
+
+var cleanSides = screen.cleanSides;
+function expectClean(value: any) {
+ screen.cleanSides = function(el: blessed.widget.Element) {
+ var ret = cleanSides.apply(this, arguments);
+ if (ret !== value) {
+ throw new Error('Failed. Expected '
+ + value + ' from cleanSides. Got '
+ + ret + '.');
+ }
+ return ret;
+ };
+}
+var btext = blessed.box({
+ parent: screen,
+ left: 'center',
+ top: 'center',
+ width: '80%',
+ height: '80%',
+ style: {
+ bg: 'green'
+ },
+ border: 'line',
+ content: 'CSR should still work.'
+});
+let _oscroll = btext.scroll;
+btext.scroll = function(offset, always) {
+ expectClean(true);
+ return _oscroll(offset, always);
+};
+
+var text = blessed.scrollabletext({
+ parent: screen,
+ content: lorem,
+ border: 'line',
+ left: 'center',
+ top: 'center',
+ draggable: true,
+ width: '50%',
+ height: '50%',
+ mouse: true,
+ keys: true,
+ vi: true
+});
+
+_oscroll = text.scroll;
+text.scroll = function(offset, always) {
+ var el = this;
+ var value = true;
+ if (el.left < 0) value = true;
+ if (el.top < 0) value = false;
+ if (el.left + el.width > screen.width) value = true;
+ if (el.top + el.height > screen.height) value = false;
+ expectClean(value);
+ return _oscroll(offset, always);
+};
+
+text.focus();
+
+screen.key('q', function() {
+ return screen.destroy();
+});
+
+screen.render();
+
+// https://github.com/chjj/blessed/blob/master/test/widget-dock-noborder.js
+
+screen = blessed.screen({
+ dump: __dirname + '/logs/dock.log',
+ smartCSR: true,
+ dockBorders: true,
+ warnings: true
+});
+
+blessed.box({
+ parent: screen,
+ left: -1,
+ top: -1,
+ width: '50%+1',
+ height: '50%+1',
+ border: 'line',
+ content: 'Foo'
+});
+
+blessed.box({
+ parent: screen,
+ left: '50%-1',
+ top: -1,
+ width: '50%+3',
+ height: '50%+1',
+ content: 'Bar',
+ border: 'line'
+});
+
+blessed.box({
+ parent: screen,
+ left: -1,
+ top: '50%-1',
+ width: '50%+1',
+ height: '50%+3',
+ border: 'line',
+ content: 'Foo'
+});
+
+blessed.listtable({
+ parent: screen,
+ left: '50%-1',
+ top: '50%-1',
+ width: '50%+3',
+ height: '50%+3',
+ border: 'line',
+ align: 'center',
+ tags: true,
+ keys: true,
+ vi: true,
+ mouse: true,
+ style: {
+ header: {
+ fg: 'blue',
+ bold: true
+ },
+ cell: {
+ fg: 'magenta',
+ selected: {
+ bg: 'blue'
+ }
+ }
+ },
+ data: [
+ [ 'Animals', 'Foods', 'Times', 'Numbers' ],
+ [ 'Elephant', 'Apple', '1:00am', 'One' ],
+ [ 'Bird', 'Orange', '2:15pm', 'Two' ],
+ [ 'T-Rex', 'Taco', '8:45am', 'Three' ],
+ [ 'Mouse', 'Cheese', '9:05am', 'Four' ]
+ ]
+}).focus();
+
+screen.key('q', function() {
+ return screen.destroy();
+});
+
+screen.render();
+
+// https://raw.githubusercontent.com/chjj/blessed/master/example/simple-form.js
+
+var form = blessed.form({
+ parent: screen,
+ keys: true,
+ left: 0,
+ top: 0,
+ width: 30,
+ height: 4,
+ bg: 'green',
+ content: 'Submit or cancel?'
+});
+
+var submit = blessed.button({
+ parent: form,
+ mouse: true,
+ keys: true,
+ padding: {
+ left: 1,
+ right: 1
+ },
+ left: 10,
+ top: 2,
+ shrink: true,
+ name: 'submit',
+ content: 'submit',
+ style: {
+ bg: 'blue',
+ focus: {
+ bg: 'red'
+ },
+ hover: {
+ bg: 'red'
+ }
+ }
+});
+
+var cancel = blessed.button({
+ parent: form,
+ mouse: true,
+ keys: true,
+ padding: {
+ left: 1,
+ right: 1
+ },
+ left: 20,
+ top: 2,
+ shrink: true,
+ name: 'cancel',
+ content: 'cancel',
+ style: {
+ bg: 'blue',
+ focus: {
+ bg: 'red'
+ },
+ hover: {
+ bg: 'red'
+ }
+ }
+});
+
+// https://github.com/chjj/blessed/blob/master/test/widget-layout.js
+
+screen = blessed.screen({
+ dump: __dirname + '/logs/layout.log',
+ smartCSR: true,
+ autoPadding: true,
+ warnings: true
+});
+
+var layout = blessed.layout({
+ parent: screen,
+ top: 'center',
+ left: 'center',
+ width: '50%',
+ height: '50%',
+ border: 'line',
+ layout: process.argv[2] === 'grid' ? 'grid' : 'inline',
+ style: {
+ bg: 'red',
+ border: {
+ fg: 'blue'
+ }
+ }
+});
+
+var box1 = blessed.box({
+ parent: layout,
+ top: 'center',
+ left: 'center',
+ width: 20,
+ height: 10,
+ border: 'line',
+ content: '1'
+});
+
+var box2 = blessed.box({
+ parent: layout,
+ top: 0,
+ left: 0,
+ width: 10,
+ height: 5,
+ border: 'line',
+ content: '2'
+});
+
+var box3 = blessed.box({
+ parent: layout,
+ top: 0,
+ left: 0,
+ width: 10,
+ height: 5,
+ border: 'line',
+ content: '3'
+});
+
+var box4 = blessed.box({
+ parent: layout,
+ top: 0,
+ left: 0,
+ width: 10,
+ height: 5,
+ border: 'line',
+ content: '4'
+});
+
+var box5 = blessed.box({
+ parent: layout,
+ top: 0,
+ left: 0,
+ width: 10,
+ height: 5,
+ border: 'line',
+ content: '5'
+});
+
+var box6 = blessed.box({
+ parent: layout,
+ top: 0,
+ left: 0,
+ width: 10,
+ height: 5,
+ border: 'line',
+ content: '6'
+});
+
+var box7 = blessed.box({
+ parent: layout,
+ top: 0,
+ left: 0,
+ width: 10,
+ height: 5,
+ border: 'line',
+ content: '7'
+});
+
+var box8 = blessed.box({
+ parent: layout,
+ top: 'center',
+ left: 'center',
+ width: 20,
+ height: 10,
+ border: 'line',
+ content: '8'
+});
+
+var box9 = blessed.box({
+ parent: layout,
+ top: 0,
+ left: 0,
+ width: 10,
+ height: 5,
+ border: 'line',
+ content: '9'
+});
+
+var box10 = blessed.box({
+ parent: layout,
+ top: 'center',
+ left: 'center',
+ width: 20,
+ height: 10,
+ border: 'line',
+ content: '10'
+});
+
+var box11 = blessed.box({
+ parent: layout,
+ top: 0,
+ left: 0,
+ width: 10,
+ height: 5,
+ border: 'line',
+ content: '11'
+});
+
+var box12 = blessed.box({
+ parent: layout,
+ top: 'center',
+ left: 'center',
+ width: 20,
+ height: 10,
+ border: 'line',
+ content: '12'
+});
+
+if (process.argv[2] !== 'grid') {
+ for (var i = 0; i < 10; i++) {
+ blessed.box({
+ parent: layout,
+ // width: i % 2 === 0 ? 10 : 20,
+ // height: i % 2 === 0 ? 5 : 10,
+ width: Math.random() > 0.5 ? 10 : 20,
+ height: Math.random() > 0.5 ? 5 : 10,
+ border: 'line',
+ content: (i + 1 + 12) + ''
+ });
+ }
+}
+
+screen.key('q', function() {
+ return screen.destroy();
+});
+
+screen.render();
+
+// https://github.com/chjj/blessed/blob/master/test/widget-form.js
+
+screen = blessed.screen({
+ dump: __dirname + '/logs/form.log',
+ warnings: true
+});
+
+type FormData = {
+ radio1: boolean;
+ radio2: boolean;
+ text: string;
+ check: boolean;
+};
+
+var form2 = blessed.form({
+ parent: screen,
+ mouse: true,
+ keys: true,
+ vi: true,
+ left: 0,
+ top: 0,
+ width: '100%',
+ //height: 12,
+ style: {
+ bg: 'green',
+ border: {
+ inverse: true
+ },
+ scrollbar: {
+ inverse: true
+ }
+ },
+ content: 'foobar',
+ scrollable: true,
+ scrollbar: {
+ ch: ' '
+ }
+ //alwaysScroll: true
+});
+
+form2.on('submit', (data) => {
+ output.setContent(JSON.stringify(data, null, 2));
+ screen.render();
+});
+
+form2.key('d', function() {
+ form2.scroll(1, true);
+ screen.render();
+});
+
+form2.key('u', function() {
+ form2.scroll(-1, true);
+ screen.render();
+});
+
+var set = blessed.radioset({
+ parent: form2,
+ left: 1,
+ top: 1,
+ shrink: true,
+ //padding: 1,
+ //content: 'f',
+ style: {
+ bg: 'magenta'
+ }
+});
+
+var radio1 = blessed.radiobutton({
+ parent: set,
+ mouse: true,
+ keys: true,
+ shrink: true,
+ style: {
+ bg: 'magenta'
+ },
+ height: 1,
+ left: 0,
+ top: 0,
+ name: 'radio1',
+ content: 'radio1'
+});
+
+var radio2 = blessed.radiobutton({
+ parent: set,
+ mouse: true,
+ keys: true,
+ shrink: true,
+ style: {
+ bg: 'magenta'
+ },
+ height: 1,
+ left: 15,
+ top: 0,
+ name: 'radio2',
+ content: 'radio2'
+});
+
+var text2 = blessed.textbox({
+ parent: form2,
+ mouse: true,
+ keys: true,
+ style: {
+ bg: 'blue'
+ },
+ height: 1,
+ width: 20,
+ left: 1,
+ top: 3,
+ name: 'text'
+});
+
+text2.on('focus', function() {
+ text2.readInput();
+});
+
+var check = blessed.checkbox({
+ parent: form2,
+ mouse: true,
+ keys: true,
+ shrink: true,
+ style: {
+ bg: 'magenta'
+ },
+ height: 1,
+ left: 28,
+ top: 1,
+ name: 'check',
+ content: 'check'
+});
+
+var check2 = blessed.checkbox({
+ parent: form2,
+ mouse: true,
+ keys: true,
+ shrink: true,
+ style: {
+ bg: 'magenta'
+ },
+ height: 1,
+ left: 28,
+ top: 14,
+ name: 'foooooooo2',
+ content: 'foooooooo2'
+});
+
+var submit = blessed.button({
+ parent: form2,
+ mouse: true,
+ keys: true,
+ shrink: true,
+ padding: {
+ left: 1,
+ right: 1
+ },
+ left: 29,
+ top: 3,
+ name: 'submit',
+ content: 'submit',
+ style: {
+ bg: 'blue',
+ focus: {
+ bg: 'red'
+ }
+ }
+});
+
+submit.on('press', function() {
+ form2.submit();
+});
+
+var box1 = blessed.box({
+ parent: form2,
+ left: 1,
+ top: 10,
+ height: 10,
+ width: 10,
+ content: 'one',
+ style: {
+ bg: 'cyan'
+ }
+});
+
+var box2 = blessed.box({
+ parent: box1,
+ left: 1,
+ top: 2,
+ height: 8,
+ width: 9,
+ content: 'two',
+ style: {
+ bg: 'magenta'
+ }
+});
+
+var box3 = blessed.box({
+ parent: box2,
+ left: 1,
+ top: 2,
+ height: 6,
+ width: 8,
+ content: 'three',
+ style: {
+ bg: 'yellow'
+ }
+});
+
+var box4 = blessed.box({
+ parent: box3,
+ left: 1,
+ top: 2,
+ height: 4,
+ width: 7,
+ content: 'four',
+ style: {
+ bg: 'blue'
+ }
+});
+
+var output = blessed.scrollabletext({
+ parent: form2,
+ mouse: true,
+ keys: true,
+ left: 0,
+ top: 20,
+ height: 5,
+ right: 0,
+ style: {
+ bg: 'red'
+ },
+ content: 'foobar'
+});
+
+var bottom = blessed.line({
+ parent: form2,
+ type: 'line',
+ orientation: 'horizontal',
+ left: 0,
+ right: 0,
+ top: 50,
+ style: {
+ fg: 'blue'
+ }
+});
+
+screen.key('q', function() {
+ return screen.destroy();
+});
+
+form2.focus();
+
+form2.submit();
+
+screen.render();
+
+// https://github.com/chjj/blessed/blob/master/test/widget-table.js
+
+screen = blessed.screen({
+ dump: __dirname + '/logs/table.log',
+ autoPadding: false,
+ fullUnicode: true,
+ warnings: true
+});
+
+var DU = '杜';
+var JUAN = '鹃';
+
+var table = blessed.table({
+ //parent: screen,
+ top: 'center',
+ left: 'center',
+ data: null,
+ border: 'line',
+ align: 'center',
+ tags: true,
+ //width: '80%',
+ width: 'shrink',
+ style: {
+ border: {
+ fg: 'red'
+ },
+ header: {
+ fg: 'blue',
+ bold: true
+ },
+ cell: {
+ fg: 'magenta'
+ }
+ }
+});
+
+var data1 = [
+ [ 'Animals', 'Foods', 'Times' ],
+ [ 'Elephant', 'Apple', '1:00am' ],
+ [ 'Bird', 'Orange', '2:15pm' ],
+ [ 'T-Rex', 'Taco', '8:45am' ],
+ [ 'Mouse', 'Cheese', '9:05am' ]
+];
+
+data1[1][0] = '{red-fg}' + data1[1][0] + '{/red-fg}';
+data1[2][0] += ' (' + DU + JUAN + ')';
+
+var data2 = [
+ [ 'Animals', 'Foods', 'Times', 'Numbers' ],
+ [ 'Elephant', 'Apple', '1:00am', 'One' ],
+ [ 'Bird', 'Orange', '2:15pm', 'Two' ],
+ [ 'T-Rex', 'Taco', '8:45am', 'Three' ],
+ [ 'Mouse', 'Cheese', '9:05am', 'Four' ]
+];
+
+data2[1][0] = '{red-fg}' + data2[1][0] + '{/red-fg}';
+data2[2][0] += ' (' + DU + JUAN + ')';
+
+screen.key('q', function() {
+ return screen.destroy();
+});
+
+table.setData(data2);
+screen.append(table);
+screen.render();
+
+setTimeout(function() {
+ table.setData(data1);
+ screen.render();
+}, 3000);
diff --git a/blessed/blessed.d.ts b/blessed/blessed.d.ts
index 6746afe5f5..cb9bd393ed 100644
--- a/blessed/blessed.d.ts
+++ b/blessed/blessed.d.ts
@@ -1,1256 +1,155 @@
-// Type definitions for blessed 0.1.5
+// Type definitions for blessed 0.1.81
// Project: https://github.com/chjj/blessed
-// Definitions by: bryn austin bellomy
+// Definitions by: bryn austin bellomy , Diullei Gomes
// Definitions: https://github.com/borisyankov/DefinitelyTyped
-///
+///
-declare module "blessed"
-{
- import events = require('events');
- import buffer = require('buffer');
- import child_process = require('child_process');
+declare module "blessed" {
+ import {EventEmitter} from 'events';
+ import * as stream from "stream"
+ import * as child_process from "child_process";
- module Blessed
- {
- export var colors: Colors;
+ export class BlessedProgram {
+ hideCursor: () => void;
+ move: any;
+ showCursor: any;
+ }
- export interface GenericCallback {
- (...args:any[]): void;
+ export module Widgets {
+
+ export module Types {
+
+ export type TTopLeft = string | number | "center";
+
+ export type TPosition = string | number;
+
+ export type TMouseAction = "mousedown" | "mouseup" | "mousemove";
+
+ export type TStyle = {
+ type?: string;
+ bg?: string;
+ fg?: string;
+ ch?: string;
+ bold?: boolean;
+ underline?: boolean;
+ blink?: boolean;
+ inverse?: boolean;
+ invisible?: boolean;
+ transparent?: boolean;
+ border?: "line" | "bg" | TBorder;
+ hover?: boolean;
+ focus?: boolean;
+ label?: string;
+ track?: {bg?: string; fg?: string;};
+ scrollbar?: {bg?: string; fg?: string;};
+ }
+
+ export type TBorder = {
+ /**
+ * Type of border (line or bg). bg by default.
+ */
+ type?: "line" | "bg";
+ /**
+ * Character to use if bg type, default is space.
+ */
+ ch?: string;
+ /**
+ * Border foreground and background, must be numbers (-1 for default).
+ */
+ bg?: number;
+ fg?: number;
+ /**
+ * Border attributes.
+ */
+ bold?: string;
+ underline?: string;
+ }
+
+ export type TCursor = {
+ /**
+ * Have blessed draw a custom cursor and hide the terminal cursor (experimental).
+ */
+ artificial: boolean;
+ /**
+ * Shape of the cursor. Can be: block, underline, or line.
+ */
+ shape: boolean;
+ /**
+ * Whether the cursor blinks.
+ */
+ blink: boolean;
+ /**
+ * Color of the color. Accepts any valid color value (null is default).
+ */
+ color: string;
+ }
+
+ export type TAlign = "left" | "center" | "right";
+
+ export type ListbarCommand = {
+ key: string;
+ callback: () => void;
+ };
+
+ export type TImage = {
+ /**
+ * Pixel width.
+ */
+ width: number;
+ /**
+ * Pixel height.
+ */
+ height: number;
+ /**
+ * Image bitmap.
+ * */
+ bmp: any;
+ /**
+ * Image cellmap (bitmap scaled down to cell size).
+ */
+ cellmap: any;
+ };
+
+ export type Cursor = {
+ /**
+ * Have blessed draw a custom cursor and hide the terminal cursor (experimental).
+ */
+ artificial: boolean;
+ /**
+ * Shape of the cursor. Can be: block, underline, or line.
+ */
+ shape: boolean;
+ /**
+ * Whether the cursor blinks.
+ */
+ blink: boolean;
+ /**
+ * Color of the color. Accepts any valid color value (null is default).
+ */
+ color: string;
+ }
}
- export interface ColorPair {
- /** background, must be number (-1 for default). */
- bg?: number;
- /** foreground, must be number (-1 for default). */
- fg?: number;
- }
-
- export interface Style extends ColorPair {
- bold?: boolean;
- underline?: boolean;
- border: Border;
- hover: ColorPair;
- }
-
- export interface Border extends ColorPair {
- /** type of border ('line' or 'bg'). */
- type?: string; //'line'|'bg';
- /** character to use if bg type, default is space. */
- ch?: string;
- }
-
- export interface Padding {
- top?:number;
- right?:number;
- bottom?:number;
- left?:number;
- }
-
- export interface Position {
- /** offsets of the element relative to its parent. can be a number, percentage (0-100%), or keyword (center). right and bottom do not accept keywords. */
- top?:number|string;
- /** offsets of the element relative to its parent. can be a number, percentage (0-100%), or keyword (center). right and bottom do not accept keywords. */
- right?:number|string;
- /** offsets of the element relative to its parent. can be a number, percentage (0-100%), or keyword (center). right and bottom do not accept keywords. */
- bottom?:number|string;
- /** offsets of the element relative to its parent. can be a number, percentage (0-100%), or keyword (center). right and bottom do not accept keywords. */
- left?:number|string;
- /** width of the element, can be a number, percentage (0-100%), or keyword (half or shrink). */
- width?:number|string;
- /** height of the element, can be a number, percentage (0-100%), or keyword (half or shrink). */
- height?:number|string;
- }
-
- export interface KeyCode {
- name: string;
- ctrl: boolean;
- meta: boolean;
- shift: boolean;
- sequence: string;
- full: string;
- }
-
- export class Program
- {
- /**
- Wrap the given text in terminal formatting codes corresponding to the given attribute
- name. The `attr` string can be of the form `red fg` or `52 bg` where `52` is a 0-255
- integer color number.
- */
- text (text:string, attr:string): string;
- }
-
- export interface Colors {
- /** Either pass a hex string, an array of 3 numbers, or three separate numbers representing an RGB value. This returns the 0-255 color number for that color. */
- match (r:string|number[]|number, g?:number, b?:number): number;
-
- /** An array of the 255 colors as hex strings. */
- colors: string[];
- }
-
- export interface NodeOptions
- {
- screen?: Screen;
- parent?: Node;
- children?: Node[];
- }
-
- export class Node extends events.EventEmitter
- {
- constructor(options?:NodeOptions);
-
- type : string;
- options : NodeOptions;
- parent : Node;
- screen : Screen;
- children : Node[];
- data : any;
- _ : any;
- $ : any;
- index : number;
-
- // on(event:string, callback:() => void);
- // on(event:'adopt', callback:() => void);
- // on(event:'remove', callback:() => void);
- // on(event:'reparent', callback:() => void);
- // on(event:'attach', callback:() => void);
- // on(event:'detach', callback:() => void);
-
- prepend(node:Node): void;
- append(node:Node): void;
- remove(node:Node): void;
- insert(node:Node, index:number): void;
- insertBefore(node:Node, refNode:Node): void;
- insertAfter(node:Node, refNode:Node): void;
- detach(): void;
- // emitDescendants(): void;
- // get(key:string): any;
- // get(key:string, default:any): any;
- // set(key:string, value:any): void;
- }
-
- export interface ScreenOptions extends NodeOptions
- {
- /** the blessed Program to be associated with. will be automatically instantiated if none is provided. */
- program?: any;
- /** attempt to perform CSR optimization on all possible elements (not just full-width ones, elements with uniform cells to their sides). this is known to cause flickering with elements that are not full-width, however, it is more optimal for terminal rendering. */
- smartCSR?: boolean;
- /** do CSR on any element within 20 cols of the screen edge on either side. faster than smartCSR, but may cause flickering depending on what is on each side of the element. */
- fastCSR?: boolean;
- /** attempt to perform back_color_erase optimizations for terminals that support it. it will also work with terminals that don't support it, but only on lines with the default background color. as it stands with the current implementation, it's uncertain how much terminal performance this adds at the cost of overhead within node. */
- useBCE?: boolean;
- /** amount of time (in ms) to redraw the screen after the terminal is resized (default: 300). */
- resizeTimeout?: number;
- /** the width of tabs within an element's content. */
- tabSize?: number;
- /** automatically position child elements with border and padding in mind. */
- autoPadding?: boolean;
- /** the name of the logfile to use. if specified but the file does not exist, it will be created. see log method. */
- log?: string;
- /** dump all output and input to desired file. can be used together with log option if set as a boolean. */
- dump?: any;
- /** debug mode. enables usage of the `debug` method. also creates a debug console which will display when pressing F12. it will display all log and debug messages. */
- debug?: boolean;
- /** Array of keys in their full format (e.g. C-c) to ignore when keys are locked. Useful for creating a key that will always exit no matter whether the keys are locked. */
- ignoreLocked?: string[];
-
- /** Do not clear the screen, only scroll down enough to make room for the elements on the screen. do not use the alternate screenbuffer. useful for writing a CLI tool or some kind of prompt (experimental - see test/widget-noalt.js) */
- noAlt?: boolean;
-
- /** Options for the cursor. */
- cursor?: CursorOptions;
- }
-
- export interface CursorOptions {
- /** have blessed draw a custom cursor and hide the terminal cursor (experimental). */
- artificial?: boolean;
- /** shape of the artificial cursor. can be: block, underline, or line. */
- shape?: string; //'block'|'underline'|'line';
- /** whether the artificial cursor blinks. */
- blink?: boolean;
- /** color of the artificial cursor. accepts any valid color value (null is default). */
- color?: string;
- }
-
- export interface ScreenEventCallback {
- (character:string, keyCode:KeyCode): void;
- }
-
- export class Screen extends Node
- {
- constructor(options?:ScreenOptions);
-
- /** the blessed Program object. */
- program: any;
- /** the blessed Tput object (only available if you passed tput: true to the Program constructor.) */
- tput: any;
- /** top of the focus history stack. */
- focused: any;
- /** width of the screen (same as program.cols). */
- width: number;
- /** height of the screen (same as program.rows). */
- height: number;
- /** same as screen.width. */
- cols: number;
- /** same as screen.height. */
- rows: number;
-
- /** calculated relative left offset. */
- left: number;
- /** calculated relative right offset. */
- right: number;
- /** calculated relative top offset. */
- top: number;
- /** calculated relative bottom offset. */
- bottom: number;
- /** calculated absolute left offset. */
- aleft: number;
- /** calculated absolute right offset. */
- aright: number;
- /** calculated absolute top offset. */
- atop: number;
- /** calculated absolute bottom offset. */
- abottom: number;
-
-
- /** whether the focused element grabs all keypresses. */
- grabKeys: boolean;
- /** prevent keypresses from being received by any element. */
- lockKeys: boolean;
- /** the currently hovered element. only set if mouse events are bound. */
- hover: Element;
- /** set or get window title. */
- title: string;
-
- /** write string to the log file if one was created. */
- log(...msg:any[]): void;
- /** same as the log method, but only gets called if the debug option was set. */
- debug(...msg:string[]): void;
- /** allocate a new pending screen buffer and a new output screen buffer. */
- alloc(): void;
- /** draw the screen based on the contents of the screen buffer. */
- draw(start:number, end:number): void;
- /** render all child elements, writing all data to the screen buffer and drawing the screen. */
- render(): void;
- /** clear any region on the screen. */
- clearRegion(x1:number, x2:number, y1:number, y2:number): void;
- /** fill any region with a character of a certain attribute. */
- fillRegion(attr:number, ch:string, x1:number, x2:number, y1:number, y2:number): void;
- /** focus element by offset of focusable elements. */
- focusOffset(offset:number): void;
- /** focus previous element in the index. */
- focusPrevious(): void;
- /** focus next element in the index. */
- focusNext(): void;
- /** push element on the focus stack (equivalent to screen.focused = el). */
- focusPush(element:Element): void;
- /** pop element off the focus stack. */
- focusPop(): void;
- /** save the focused element. */
- saveFocus(): void;
- /** restore the saved focused element. */
- restoreFocus(): void;
- /** "rewind" focus to the last visible and attached element. */
- rewindFocus(): void;
- /** bind a keypress listener for a specific key. */
- key(keyEvents:string|string[], callback:ScreenEventCallback): void;
- /** bind a keypress listener for a specific key once. */
- onceKey(keyEvents:string|string[], callback:ScreenEventCallback): void;
- /** remove a keypress listener for a specific key. */
- unkey(name:string, listener:ScreenEventCallback): void;
- /** spawn a process in the foreground, return to blessed app after exit. */
- spawn(file:string, args:string[], options:NodeChildProcessExecOptions): child_process.ChildProcess;
- /** spawn a process in the foreground, return to blessed app after exit. executes callback on error or exit. */
- exec(file:string, args:string[], options:NodeChildProcessExecOptions, callback:GenericCallback): child_process.ChildProcess;
- /** read data from text editor. */
- readEditor(options:{}, callback:GenericCallback): void;
- /** set effects based on two events and attributes. */
- setEffects(el:Element, fel:Element, over:string, out:string, effects:Style, temp?:string): void;
- /** insert a line into the screen (using csr: this bypasses the output buffer). */
- insertLine(n:number, y:number, top:number, bottom:number): void;
- /** delete a line from the screen (using csr: this bypasses the output buffer). */
- deleteLine(n:number, y:number, top:number, bottom:number): void;
- /** insert a line at the bottom of the screen. */
- insertBottom(top:number, bottom:number): void;
- /** insert a line at the top of the screen. */
- insertTop(top:number, bottom:number): void;
- /** delete a line at the bottom of the screen. */
- deleteBottom(top:number, bottom:number): void;
- /** delete a line at the top of the screen. */
- deleteTop(top:number, bottom:number): void;
-
- /** enable mouse events for the screen and optionally an element (automatically called when a form of on('mouse') is bound). */
- enableMouse(el?:Element): void;
- /** enable keypress events for the screen and optionally an element (automatically called when a form of on('keypress') is bound). */
- enableKeys(el?:Element): void;
- /** enable key and mouse events. calls bot enableMouse and enableKeys. */
- enableInput(el?:Element): void;
-
- /** attempt to copy text to clipboard using iTerm2's propriety sequence. returns true if successful. */
- copyToClipboard(text:string): boolean;
- /** attempt to change cursor shape. will not work in all terminals (see artificial cursors for a solution to this). returns true if successful. */
- cursorShape(shape:string, blink:boolean): boolean;
- /** attempt to change cursor color. returns true if successful. */
- cursorColor(color: string): boolean;
- /** attempt to reset cursor. returns true if successful. */
- cursorReset(): boolean;
-
- }
-
- export interface ElementOptions extends NodeOptions
- {
- fg?: string;
- bg?: string;
- scrollbar?: ColorPair;
- focus?: Style;
- hover?: Style;
-
- /** border object, see below. */
- border?: Border;
- /** positioning options. */
- position?: Position;
- /** amount of padding on the inside of the element. can be a number or an object containing the properties: left, right, top, and bottom. */
- padding?: number|Padding;
- /** element's text content. */
- content?: string;
- /** element is clickable. */
- clickable?: boolean;
- /** element is focusable and can receive key input. */
- input?: boolean;
- /** element is focused. */
- focused?: boolean;
- /** whether the element is hidden. */
- hidden?: boolean;
- /** a simple text label for the element. */
- label?: string;
- /** a floating text label for the element which appears on mouseover. */
- hoverText?: string;
- /** text alignment: left, center, or right. */
- align?: string;
- /** vertical text alignment: top, middle, or bottom. */
- valign?: string;
- /** shrink/flex/grow to content and child elements. width/height during render. */
- shrink?: any;
- /** width of the element, can be a number, percentage (0-100%), or keyword (half or shrink). */
- width?: number|string;
- /** height of the element, can be a number, percentage (0-100%), or keyword (half or shrink). */
- height?: number|string;
- /** whether the element is scrollable or not. */
- scrollable?: boolean;
- /** background character (default is whitespace ). */
- ch?: string;
- /** allow the element to be dragged with the mouse. */
- draggable?: boolean;
- }
-
- export class Element extends Node
- {
- constructor(options?:ElementOptions);
-
- /** name of the element. useful for form submission. */
- name: string;
- /** border object. */
- border: Border;
- /** contains attributes (e.g. fg/bg/underline). see above. */
- style: Style;
- /** raw width, height, and offsets. */
- position: Position;
- /** type of border (line or bg). bg by default. */
- type: string; //'line'|'bg';
- /** character to use if bg type, default is space. */
- ch: string;
- /** raw text content. */
- content: string;
- /** whether the element is hidden or not. */
- hidden: boolean;
- /** whether the element is visible or not. */
- visible: boolean;
- /** whether the element is attached to a screen in its ancestry somewhere. */
- detached: boolean;
- /** calculated width. */
- width: number;
- /** calculated height. */
- height: number;
- /** whether the element is draggable. set to true to allow dragging. */
- draggable: boolean;
-
-
-
- /** calculated relative left offset. */
- left: number;
- /** calculated relative right offset. */
- right: number;
- /** calculated relative top offset. */
- top: number;
- /** calculated relative bottom offset. */
- bottom: number;
- /** calculated absolute left offset. */
- aleft: number;
- /** calculated absolute right offset. */
- aright: number;
- /** calculated absolute top offset. */
- atop: number;
- /** calculated absolute bottom offset. */
- abottom: number;
-
-
- /** write content and children to the screen buffer. */
- render(): void;
- /** hide element. */
- hide(): void;
- /** show element. */
- show(): void;
- /** toggle hidden/shown. */
- toggle(): void;
- /** focus element. */
- focus(): void;
- /** bind a keypress listener for a specific key. */
- key(name:string|string[], listener:(character?:any, keyCode?:any) => void): void;
- /** bind a keypress listener for a specific key once. */
- onceKey(name:string, listener:() => void): void;
- /** remove a keypress listener for a specific key. */
- unkey(name:string, listener:() => void): void;
- /** same as el.on('screen', ...) except this will automatically cleanup listeners after the element is detached. */
- onScreenEvent(event:string, listener:(...args:any[]) => void): void;
- /** set the z-index of the element (changes rendering order). */
- setIndex(z:number): void;
- /** put the element in front of its siblings. */
- setFront(): void;
- /** put the element in back of its siblings. */
- setBack(): void;
- /** set the label text for the top-left corner. example options: {text:'foo',side:'left'} */
- setLabel(textOrOptions:string|{}): void;
- /** remove the label completely. */
- removeLabel(): void;
- /** set the hover text for the bottom-right corner. example options: {text:'foo'} */
- setHover(textOrOptions:string|{}): void;
- /** remove the hover label completely. */
- removeHover(): void;
- /** set the content. note: when text is input, it will be stripped of all non-SGR escape codes, tabs will be replaced with 8 spaces, and tags will be replaced with SGR codes (if enabled). */
- setContent(text:string): void;
- /** return content, slightly different from el.content. assume the above formatting. */
- getContent(): void;
- /** similar to setContent, but ignore tags and remove escape codes. */
- setText(text:string): void;
- /** similar to getContent, but return content with tags and escape codes removed. */
- getText(): void;
- /** insert a line into the box's content. */
- insertLine(index:number, lines:string|string[]): void;
- /** delete a line from the box's content. */
- deleteLine(index:number, numLines:number): void;
- /** get a line from the box's content. */
- getLine(index:number): void;
- /** get a line from the box's content from the visible top. */
- getBaseLine(index:number): void;
- /** set a line in the box's content. */
- setLine(index:number, line:string): void;
- /** set a line in the box's content from the visible top. */
- setBaseLine(index:number, line:string): void;
- /** clear a line from the box's content. */
- clearLine(index:number): void;
- /** clear a line from the box's content from the visible top. */
- clearBaseLine(index:number): void;
- /** insert a line at the top of the box. */
- insertTop(lines:string|string[]): void;
- /** insert a line at the bottom of the box. */
- insertBottom(lines:string|string[]): void;
- /** delete a line at the top of the box. */
- deleteTop(): void;
- /** delete a line at the bottom of the box. */
- deleteBottom(): void;
- /** unshift a line onto the top of the content. */
- unshiftLine(lines:string|string[]): void;
- /** shift a line off the top of the content. */
- shiftLine(index:number): void;
- /** push a line onto the bottom of the content. */
- pushLine(lines:string|string[]): void;
- /** pop a line off the bottom of the content. */
- popLine(index:number): void;
- /** an array containing the content lines. */
- getLines(): void;
- /** an array containing the lines as they are displayed on the screen. */
- getScreenLines(): void;
- /** get a string's real length, taking into account tags. */
- textLength(text:string): number;
-
- /** enable dragging of the element. */
- enableDrag(): void;
- /** disable dragging of the element. */
- disableDrag(): void;
- }
-
-
- //
- // Box
- //
-
- export interface BoxOptions extends ElementOptions {
- // intentionally empty
- }
-
- export class Box extends Element {
- constructor(options?:BoxOptions);
- // intentionally empty
- }
-
-
- //
- // ScrollableBox
- //
-
- export interface ScrollableBoxOptions extends BoxOptions {
- /** a limit to the childBase. default is `Infinity`. */
- baseLimit: number;
- /** a option which causes the ignoring of `childOffset`. this in turn causes the childBase to change every time the element is scrolled. */
- alwaysScroll: boolean;
- /** object enabling a scrollbar. */
- scrollbar: ScrollBar;
- }
-
- /** A box with scrollable content. */
- export class ScrollableBox extends Box {
- constructor(options?:ScrollableBoxOptions);
-
- /** the offset of the top of the scroll content. */
- childBase: number;
- /** the offset of the chosen item/line. */
- childOffset: number;
- /** scroll the content by a relative offset. */
- scroll(offset:number): void;
- /** scroll the content to an absolute index. */
- scrollTo(index:number): void;
- /** same as `scrollTo`. */
- setScroll(index:number): void;
- /** set the current scroll index in percentage (0-100). */
- setScrollPerc(perc:number): void;
- /** get the current scroll index in lines. */
- getScroll(): number;
- /** get the actual height of the scrolling area. */
- getScrollHeight(): number;
- /** get the current scroll index in percentage. */
- getScrollPerc(): number;
- /** reset the scroll index to its initial state. */
- resetScroll(): void;
-
- }
-
- export interface ScrollBar {
- /** style of the scrollbar. */
- style: Style;
- /** style of the scrollbar track if present (takes regular style options). */
- track: Style;
- }
-
-
- //
- // ScrollableText
- //
-
- export interface ScrollableTextOptions extends ScrollableBoxOptions {
- /** whether to enable automatic mouse support for this element. */
- mouse: boolean;
- /** use predefined keys for navigating the text. */
- keys: boolean;
- /** use vi keys with the `keys` option. */
- vi: boolean;
- }
-
- /** __DEPRECATED__ - Use Box with the `scrollable` and `alwaysScroll` options instead. A scrollable text box which can display and scroll text, as well as handle pre-existing newlines and escape codes. */
- export class ScrollableText extends ScrollableBox {
- constructor(options?:ScrollableTextOptions);
- }
-
-
-
- //
- // Text
- //
-
- export interface TextOptions extends ElementOptions {
- align?: string; //'left'|'center'|'right';
- }
-
- export class Text extends Element {
- constructor(options?:TextOptions);
- // intentionally empty
- }
-
-
- //
- // Line
- //
-
- export interface LineOptions extends BoxOptions {
- orientation?: string; //'vertical'|'horizontal';
- style?: Style;
- }
-
- export class Line extends Box {
- constructor(options?:LineOptions);
- // intentionally empty
- }
-
-
- //
- // List
- //
-
- export interface ListStyle extends Style {
- selected?: Style;
- item?: Style;
- }
-
- export interface ListOptions extends BoxOptions
- {
- style?: ListStyle;
-
- /** whether to automatically enable mouse support for this list (allows clicking items). */
- mouse?: boolean;
- /** use predefined keys for navigating the list. */
- keys?: any;
- /** use vi keys with the keys option. */
- vi?: boolean;
- /** an array of strings which become the list's items. */
- items?: string[];
- /** a function that is called when vi mode is enabled and the key / is pressed. This function accepts a callback function which should be called with the search string. The search string is then used to jump to an item that is found in items. */
- search?: (callback:(searchString:string) => void) => void;
- /** whether the list is interactive and can have items selected (default: true). */
- interactive?: boolean;
- }
-
- export class List extends Box
- {
- constructor(options?:ListOptions);
-
- /** The text of the currently selected item. */
- value:string;
- /** The items in the list. */
- items:string[];
- /** The items in the list. */
- ritems:string[];
- /** The index of the current selection. */
- selected:number;
-
- /** add an item based on a string. */
- addItem(text:string): void;
- /** returns the item index from the list. child can be an element, index, or string. */
- getItemIndex(child:Element|number|string): void;
- /** returns the item element. child can be an element, index, or string. */
- getItem(child:Element|number|string): void;
- /** removes an item from the list. child can be an element, index, or string. */
- removeItem(child:Element|number|string): void;
- /** clears all items from the list. */
- clearItems(): void;
- /** sets the list items to multiple strings. */
- setItems(items:string[]): void;
- /** Sets the current selection by absolute index. */
- select(index:number): void;
- /** Changes the current selection based on current offset. */
- move(offset:number): void;
- /** select item above selected. */
- up(amount:number): void;
- /** select item below selected. */
- down(amount:number): void;
- /** show/focus list and pick an item. the callback is executed with the result. */
- pick(cwd:string, callback:(err:any, file:string) => void): void;
-
- /** show/focus list and pick an item. the callback is executed with the result. */
- pick(callback:(err:any, file:string) => void): void;
- }
-
- //
- // Input
- //
-
- export interface InputOptions extends BoxOptions {
- // intentionally empty
- }
-
- export class Input extends Box {
- constructor(options?:InputOptions);
- // intentionally empty
- }
-
- export interface InputOptions extends BoxOptions {
- // intentionally empty
- }
-
- //
- // Textarea
- //
-
- export interface TextareaOptions extends InputOptions
- {
- /** use pre-defined keys (`i` or `enter` for insert, `e` for editor, `C-e` for editor while inserting). */
- keys?: boolean;
- /** use pre-defined mouse events (right-click for editor). */
- mouse?: boolean;
- /** call `readInput()` when the element is focused. automatically unfocus. */
- inputOnFocus?: boolean;
- }
-
- /** A box which allows multiline text input. */
- export class Textarea extends Input
- {
- constructor(options?:TextareaOptions);
-
- /** the input text. __read-only__. */
- value: string;
-
- /** submit the textarea (emits `submit`). */
- submit(): void;
- /** cancel the textarea (emits `cancel`). */
- cancel(): void;
- /** grab key events and start reading text from the keyboard. takes a callback which receives the final value. */
- readInput(callback:GenericCallback): void;
- /** open text editor in `$EDITOR`, read the output from the resulting file. takes a callback which receives the final value. */
- readEditor(callback:GenericCallback): void;
- /** the same as `this.value`, for now. */
- getValue(): string;
- /** clear input. */
- clearValue(): void;
- /** set value. */
- setValue(text:string): void;
- }
-
-
- //
- // Textbox
- //
-
- export interface TextboxOptions extends TextareaOptions {
- /** completely hide text. */
- secret?: boolean;
- /** replace text with asterisks (`*`). */
- censor?: boolean;
- }
-
- /** A box which allows text input. */
- export class Textbox extends Textarea {
- constructor(options?:TextboxOptions);
-
- /** completely hide text. */
- secret: boolean;
- /** replace text with asterisks (`*`). */
- censor: boolean;
- }
-
-
- //
- // Button
- //
-
- export interface ButtonOptions extends InputOptions {
- }
-
- /** A button which can be focused and allows key and mouse input. */
- export class Button extends Input {
- constructor(options?:ButtonOptions);
-
- // on(event:string, callback:() => void): void;
- // on(event:'press', callback:() => void);
-
- /** press button. emits 'press'. */
- press(): void;
- }
-
-
- //
- // ProgressBar
- //
-
- export interface ProgressBarOptions extends InputOptions {
- /** can be `horizontal` or `vertical`. */
- orientation: string;
- /** the character to fill the bar with (default is space). */
- pch: string;
- /** the amount filled (0 - 100). */
- filled: number;
- /** same as `filled`. */
- value: number;
- /** enable key support. */
- keys: boolean;
- /** enable mouse support. */
- mouse: boolean;
-
- /** contains the extra key 'bar', which defines the style of the bar contents itself. */
- style: ProgressBarStyle;
- }
-
- export interface ProgressBarStyle extends Style {
- /** style of the bar contents itself. */
- bar: Style;
- }
-
-
- export class ProgressBar extends Input {
- constructor(options?:ProgressBarOptions);
-
- /** progress the bar by a fill amount. */
- progress(amount:number): void;
- /** set progress to specific amount. */
- setProgress(amount:number): void;
- /** reset the bar. */
- reset(): void;
- }
-
- //
- // Checkbox
- //
-
- export interface CheckboxOptions extends InputOptions {
- /** whether the element is checked or not. */
- checked: boolean;
- /** enable mouse support. */
- mouse: boolean;
+ export module Events {
+
+ export interface IMouseEventArg {
+ x: number;
+ y: number;
+ action: Types.TMouseAction;
+ }
+
+ export interface IKeyEventArg {
+ full: string;
+ name: string;
+ shift: boolean;
+ ctrl: boolean;
+ meta: boolean;
+ sequence: string;
+ }
}
-
- /** A checkbox which can be used in a form element. */
- export class Checkbox extends Input
- {
- constructor(options?:CheckboxOptions);
-
- /** the text next to the checkbox (do not use setcontent, use `check.text = ''`). */
- text: string;
- /** whether the element is checked or not. */
- checked: boolean;
- /** same as `checked`. */
- value: boolean;
-
- /** check the element. */
- check(): void;
- /** uncheck the element. */
- uncheck(): void;
- /** toggle checked state. */
- toggle(): void;
- }
-
-
- //
- // RadioSet
- //
-
- export interface RadioSetOptions extends BoxOptions {
- }
-
-
- export class RadioSet extends Box {
- constructor(options?:RadioSetOptions);
- }
-
-
- //
- // RadioButton
- //
-
- export interface RadioButtonOptions extends CheckboxOptions {
- }
-
-
- /** A radio button which can be used in a form element. */
- export class RadioButton extends Checkbox {
- constructor(options?:RadioButtonOptions);
- }
-
-
-
- //
- // Prompt
- //
-
- export interface PromptOptions extends BoxOptions {
- }
-
-
- /** A prompt box containing a text input, okay, and cancel buttons (automatically hidden). */
- export class Prompt extends Box
- {
- constructor(options?:PromptOptions);
-
- /** show the prompt and wait for the result of the textbox. set text and initial value */
- input(text:string, value:any, callback:(val:any) => void): void;
- /** show the prompt and wait for the result of the textbox. set text and initial value */
- setInput(text:string, value:any, callback:(val:any) => void): void;
- /** show the prompt and wait for the result of the textbox. set text and initial value */
- readInput(text:string, value:any, callback:(val:any) => void): void;
- }
-
-
- //
- // Question
- //
-
- export interface QuestionOptions extends BoxOptions {
- }
-
-
- /** A question box containing okay and cancel buttons (automatically hidden). */
- export class Question extends Box
- {
- constructor(options?:QuestionOptions);
-
- /** ask a `question`. `callback` will yield the result. */
- ask(question:string, callback:(result:any) => void): void;
- }
-
-
- //
- // Message
- //
-
- export interface MessageOptions extends BoxOptions {
- }
-
-
- /** A box containing a message to be displayed (automatically hidden). */
- export class Message extends Box
- {
- constructor(options?:MessageOptions);
-
- /** display a message for a time (default is 3 seconds). set time to 0 for a perpetual message that is dismissed on keypress. */
- log(text:string, timeOrCallback:number|MessageCallback, callback?:MessageCallback): void;
- /** display a message for a time (default is 3 seconds). set time to 0 for a perpetual message that is dismissed on keypress. */
- display(text:string, timeOrCallback:number|MessageCallback, callback?:MessageCallback): void;
- /** display an error in the same way. */
- error(text:string, timeOrCallback:number|MessageCallback, callback?:MessageCallback): void;
- }
-
- export interface MessageCallback {
- (): void;
- }
-
-
- //
- // Loading
- //
-
- export interface LoadingOptions extends BoxOptions {
- }
-
- /** A box with a spinning line to denote loading (automatically hidden). */
- export class Loading extends Box
- {
- constructor(options?:LoadingOptions);
-
- /** display the loading box with a message. will lock keys until `stop` is called. */
- load(text:string): void;
- /** hide loading box. unlock keys. */
- stop(): void;
- }
-
-
- //
- // Listbar
- //
-
- export interface ListbarOptions extends BoxOptions
- {
- /** Listbar's `style` object includes sub-styles for `selected` and `item`. */
- style?: ListbarStyle;
-
- /** set buttons using an object with keys as titles of buttons, containing of objects containing keys of `keys` and `callback`. */
- items?: ListbarItemSet;
- /** set buttons using an object with keys as titles of buttons, containing of objects containing keys of `keys` and `callback`. */
- commands?: ListbarItemSet;
- /** automatically bind list buttons to keys 0-9. */
- autoCommandKeys?: boolean;
- }
-
- export interface ListbarItemSet {
- [name: string]: ListbarItem;
- }
-
- export interface ListbarItem {
- keys: string[];
- callback: GenericCallback;
- }
-
- export interface ListbarStyle extends Style
- {
- /** style for a selected item. */
- selected: Style;
- /** style for an unselected item. */
- item: Style;
- }
-
- /** A horizontal list. Useful for a main menu bar. */
- export class Listbar extends Box
- {
- constructor(options?:ListbarOptions);
-
- /** append an item to the bar. */
- add(item:ListbarItem, callback:GenericCallback): void;
- /** append an item to the bar. */
- addItem(item:ListbarItem, callback:GenericCallback): void;
- /** append an item to the bar. */
- appendItem(item:ListbarItem, callback:GenericCallback): void;
-
- /** select button and execute its callback. */
- selectTab(index: number): void;
-
- /** set commands (see `commands` option above). */
- setItems(commands: ListbarItemSet): void;
- /** select an item on the bar. */
- select(offset: number): void;
- /** remove item from the bar. */
- removeItem(child:ListbarItem): void;
- /** move focus relatively across the bar. */
- move(offset: number): void;
- /** move focus left relatively across the bar. */
- moveLeft(offset: number): void;
- /** move focus right relatively across the bar. */
- moveRight(offset: number): void;
- }
-
-
- //
- // Log
- //
-
- export interface LogOptions extends ScrollableTextOptions {
- /** amount of scrollback allowed. default: Infinity. */
- scrollback?: number;
- /** scroll to bottom on input even if the user has scrolled up. default: false. */
- scrollOnInput?: boolean;
- }
-
-
- /** A log permanently scrolled to the bottom. */
- export class Log extends ScrollableText
- {
- constructor(options?:LogOptions);
-
- /** amount of scrollback allowed. default: Infinity. */
- scrollback: number;
- /** scroll to bottom on input even if the user has scrolled up. default: false. */
- scrollOnInput: boolean;
-
- /** add a log line. */
- log(text:string): void;
- /** add a log line. */
- add(text:string): void;
- }
-
-
- //
- // Table
- //
-
- export interface TableOptions extends BoxOptions
- {
- /** array of array of strings representing rows (same as `data`). */
- rows?: string[][];
- /** array of array of strings representing rows (same as `rows`). */
- data?: string[][];
- /** spaces to attempt to pad on the sides of each cell. `2` by default: one space on each side (only useful if the width is shrunken). */
- pad?: number;
- /** do not draw inner cells. */
- noCellBorders?: boolean;
- /** fill cell borders with the adjacent background color. */
- fillCellBorders?: boolean;
-
- /** includes `header` and `cell` substyles. */
- style?: TableStyle;
- }
-
- export interface TableStyle extends Style {
- /** header style. */
- header: Style;
- /** cell style. */
- cell: Style;
- }
-
- /** A stylized table of text elements. */
- export class Table extends Box
- {
- /** includes `header` and `cell` substyles. */
- style: TableStyle;
-
- /** set rows in table. array of arrays of strings. */
- setData(rows: string[][]): void;
- /** set rows in table. array of arrays of strings. */
- setRows(rows: string[][]): void;
- }
-
-
- //
- // ListTable
- //
-
- export interface ListTableOptions extends ListOptions
- {
- /** array of array of strings representing rows (same as `data`). */
- rows?: string[][];
- /** array of array of strings representing rows (same as `rows`). */
- data?: string[][];
- /** spaces to attempt to pad on the sides of each cell. `2` by default: one space on each side (only useful if the width is shrunken). */
- pad?: number;
-
- /** do not draw inner cells. */
- noCellBorders?: boolean;
-
- /** includes `header` and `cell` substyles. */
- style?: TableStyle;
- }
-
- export interface ListTableStyle extends TableStyle {
- }
-
-
- /** A stylized table of text elements with a list. */
- export class ListTable extends List
- {
- constructor(options?:ListTableOptions);
-
- /** set rows in table. array of arrays of strings. */
- setData(rows: string[][]): void;
- /** set rows in table. array of arrays of strings. */
- setRows(rows: string[][]): void;
- }
-
- //
- // Image
- //
-
- export interface ImageOptions extends BoxOptions {
- /** path to image. */
- file: string;
- /** path to w3mimgdisplay. if a proper w3mimgdisplay path is not given, blessed will search the entire disk for the binary. */
- w3m: string;
- }
-
-
- /** Display an image in the terminal (jpeg, png, gif) using w3mimgdisplay. Requires w3m to be installed. X11 required: works in xterm, urxvt, and possibly other terminals. */
- export class Image extends Box
- {
- constructor(options?:ImageOptions);
-
- /** set the image in the box to a new path. */
- setImage (img:string, callback:GenericCallback): void;
- /** clear the current image. */
- clearImage (callback:GenericCallback): void;
- /** get the size of an image file in pixels. */
- imageSize (img:string, callback:GenericCallback): void;
- /** get the size of the terminal in pixels. */
- termSize (callback:GenericCallback): void;
- /** get the pixel to cell ratio for the terminal. */
- getPixelRatio (callback:GenericCallback): void;
- }
-
-
- //
- // Form
- //
-
- export interface FormOptions extends BoxOptions {
- /** allow default keys (tab, vi keys, enter). */
- keys?:boolean;
- /** allow vi keys. */
- vi?:boolean;
- }
-
- export class Form extends Box
- {
- constructor(options?:FormOptions);
-
- /** last submitted data. */
- submission: any;
-
- // on(event:string, callback:() => void): void;
- // on(event:'submit', callback:(data) => void): void;
- // on(event:'cancel', callback:() => void): void;
- // on(event:'reset', callback:() => void): void;
-
- next(): void;
- previous(): void;
-
- resetSelected(): void;
- /** focus first form element. */
- focusFirst(): void;
- /** focus last form element. */
- focusLast(): void;
- /** focus next form element. */
- focusNext(): void;
- /** focus previous form element. */
- focusPrevious(): void;
- /** submit the form. */
- submit(): void;
- /** discard the form. */
- cancel(): void;
- /** clear the form. */
- reset(): void;
- }
-
-
- //
- // FileManager
- //
-
- export interface FileManagerOptions extends ListOptions {
- cwd?: string;
- }
-
- export interface DirectoryEntry {
- name: string;
- text: string;
- dir: boolean;
- symlink: boolean;
- }
-
- export class FileManager extends List
- {
- constructor(options?:FileManagerOptions);
-
- cwd: string;
-
- useFormatter (formatterFn:(entry:DirectoryEntry) => DirectoryEntry): void;
-
- /** refresh the file list (perform a readdir on cwd and update the list items). */
- refresh (cwd?:string, callback?:() => void): void;
-
- /** refresh the file list. */
- refresh (callback?:() => void): void;
-
- /** reset back to original cwd. */
- reset (cwd?:string, callback?:() => void): void;
- }
-
-
- //
- // Terminal
- //
-
- export interface TerminalOptions extends BoxOptions
- {
- /** handler for input data. */
- handler?: (userInput:Buffer) => void;
- /** name of shell. $SHELL by default. */
- shell?:string;
- /** args for shell. */
- args?:any;
- /** can be line, underline, and block. */
- cursor?:string; //'line'|'underline'|'block';
- }
-
- export class Terminal extends Box
- {
- /** reference to the headless term.js terminal. */
- term: any;
- /** reference to the pty.js pseudo terminal. */
- pty: any;
-
- /** write data to the terminal. */
- write(data:string): void;
-
- /** nearly identical to `element.screenshot`, however, the specified region includes the terminal's _entire_ scrollback, rather than just what is visible on the screen. */
- screenshot(xi?:number, xl?:number, yi?:number, yl?:number): string;
- }
-
-
- export interface NodeChildProcessExecOptions
- {
+ export interface NodeChildProcessExecOptions {
cwd?: string;
stdio?: any;
customFds?: any;
@@ -1260,10 +159,2676 @@ declare module "blessed"
maxBuffer?: number;
killSignal?: string;
}
+
+ export interface IDestroyable {
+ destroy(): void;
+ }
+
+ export interface IOptions {
+ }
+
+ export interface IHasOptions {
+ options: T;
+ }
+
+ export interface TputsOptions extends IOptions {
+ terminal?: string;
+ extended?: boolean;
+ debug?: boolean;
+ termcap?: string;
+ terminfoFile?: string;
+ terminfoPrefix?: string;
+ termcapFile?: string;
+ }
+
+ export class Tput implements IHasOptions {
+ constructor(opts: TputsOptions);
+
+ // ** properties ** //
+
+ /**
+ * Original options object.
+ */
+ options: TputsOptions;
+
+ debug: boolean;
+ padding: boolean;
+ extended: boolean;
+ printf: boolean;
+ termcap: string;
+ terminfoPrefix: string;
+ terminfoFile: string;
+ termcapFile: string;
+ error: Error;
+ terminal: string;
+
+ setup(): void;
+ term(is: any): boolean;
+ readTerminfo(term: string): string;
+ parseTerminfo(data: any, file: string): {
+ header: {
+ dataSize: number;
+ headerSize: number;
+ magicNumber: boolean;
+ namesSize: number;
+ boolCount: number;
+ numCount: number;
+ strCount: number;
+ strTableSize: number;
+ extended: {
+ dataSize: number;
+ headerSize: number;
+ boolCount: number;
+ numCount: number;
+ strCount: number;
+ strTableSize: number;
+ lastStrTableOffset: number;
+ }
+ }
+ name: string;
+ names: string[];
+ desc: string;
+ bools: Object;
+ numbers: Object;
+ strings: Object;
+ };
+ }
+
+ export interface IDestroyable {
+ destroy(): void;
+ }
+
+ export interface INodeOptions extends IOptions {
+ name?: string;
+ screen?: Screen;
+ parent?: Node;
+ children?: Node[];
+ focusable?: boolean;
+ }
+
+ export abstract class Node extends EventEmitter implements IHasOptions, IDestroyable {
+ constructor(options: INodeOptions);
+
+ // ** properties ** //
+
+ focusable: boolean;
+
+ /**
+ * Original options object.
+ */
+ options: INodeOptions;
+
+ /**
+ * An object for any miscellanous user data.
+ */
+ data: {[index: string]: any;};
+ /**
+ * An object for any miscellanous user data.
+ */
+ _: {[index: string]: any;};
+ /**
+ * An object for any miscellanous user data.
+ */
+ $: {[index: string]: any;};
+ /**
+ * Type of the node (e.g. box).
+ */
+ type: string;
+ /**
+ * Render index (document order index) of the last render call.
+ */
+ index: number;
+ /**
+ * Parent screen.
+ */
+ screen: Screen;
+ /**
+ * Parent node.
+ */
+ parent: Node;
+ /**
+ * Array of node's children.
+ */
+ children: Node[];
+
+ // ** methods ** //
+
+ /**
+ * Prepend a node to this node's children.
+ */
+ prepend(node: Node): void;
+ /**
+ * Append a node to this node's children.
+ */
+ append(node: Node): void;
+ /**
+ * Remove child node from node.
+ */
+ remove(node: Node): void;
+ /**
+ * Insert a node to this node's children at index i.
+ */
+ insert(node: Node, index: number): void;
+ /**
+ * Insert a node to this node's children before the reference node.
+ */
+ insertBefore(node: Node, refNode: Node): void;
+ /**
+ * Insert a node from node after the reference node.
+ */
+ insertAfter(node: Node, refNode: Node): void;
+ /**
+ * Remove node from its parent.
+ */
+ detach(): void;
+ /**
+ * Remove node from its parent.
+ */
+ free(): void;
+ /**
+ * Remove node from its parent.
+ */
+ forDescendants(iter: Function, s: any): void;
+ /**
+ * Remove node from its parent.
+ */
+ forAncestors(iter: Function, s: any): void;
+ /**
+ * Remove node from its parent.
+ */
+ collectDescendants(s: any): void;
+ /**
+ * Remove node from its parent.
+ */
+ collectAncestors(s: any): void;
+ /**
+ * Remove node from its parent.
+ */
+ emitDescendants(): void;
+ /**
+ * Remove node from its parent.
+ */
+ emitAncestors(): void;
+ /**
+ * Remove node from its parent.
+ */
+ hasDescendant(target: Node): void;
+ /**
+ * Remove node from its parent.
+ */
+ hasAncestor(target: Node): boolean;
+ /**
+ * Remove node from its parent.
+ */
+ destroy(): void;
+ /**
+ * Emit event for element, and recursively emit same event for all descendants.
+ */
+ emitDescendants(type: string, ...args: any[]): void;
+ /**
+ * Get user property with a potential default value.
+ */
+ get(name: string, def: T): T;
+ /**
+ * Set user property to value.
+ */
+ set(name: string, value: T): void;
+
+ // ** events ** //
+
+ on(event: string, listener: Function): this;
+ /**
+ * Received when node is added to a parent.
+ */
+ on(event: "adopt", callback: (arg: Node) => void): this;
+ /**
+ * Received when node is removed from it's current parent.
+ */
+ on(event: "remove", callback: (arg: Node) => void): this;
+ /**
+ * Received when node gains a new parent.
+ */
+ on(event: "reparent", callback: (arg: Node) => void): this;
+ /**
+ * Received when node is attached to the screen directly or somewhere in its ancestry.
+ */
+ on(event: "attach", callback: (arg: Node) => void): this;
+ /**
+ * Received when node is detached from the screen directly or somewhere in its ancestry.
+ */
+ on(event: "detach", callback: (arg: Node) => void): this;
+ }
+
+ export class NodeWithEvents extends Node {
+ // ** methods ** //
+
+ /**
+ * Bind a keypress listener for a specific key.
+ */
+ key(name: string | string[], listener: Function): void;
+ /**
+ * Bind a keypress listener for a specific key once.
+ */
+ onceKey(name: string, listener: Function): void;
+ /**
+ * Remove a keypress listener for a specific key.
+ */
+ unkey(name: string, listener: Function): void;
+ removeKey(name: string, listener: Function): void;
+
+ // ** events ** //
+
+ on(event: string, listener: Function): this;
+ /**
+ * Received on screen resize.
+ */
+ on(event: "resize", callback: () => void): this;
+ /**
+ * Received on mouse events.
+ */
+ on(event: "mouse", callback: (arg: Events.IMouseEventArg) => void): this;
+ on(event: "mouseout", callback: (arg: Events.IMouseEventArg) => void): this;
+ on(event: "mouseover", callback: (arg: Events.IMouseEventArg) => void): this;
+ on(event: "mousedown", callback: (arg: Events.IMouseEventArg) => void): this;
+ on(event: "mouseup", callback: (arg: Events.IMouseEventArg) => void): this;
+ on(event: "mousewheel", callback: (arg: Events.IMouseEventArg) => void): this;
+ on(event: "wheeldown", callback: (arg: Events.IMouseEventArg) => void): this;
+ on(event: "wheelup", callback: (arg: Events.IMouseEventArg) => void): this;
+ on(event: "mousemove", callback: (arg: Events.IMouseEventArg) => void): this;
+ /**
+ * Received on key events.
+ */
+ on(event: "keypress", callback: (ch: string, key: Events.IKeyEventArg) => void): this;
+ /**
+ * Global events received for all elements.
+ */
+ on(event: "element click", callback: (arg: Screen) => void): this;
+ on(event: "element mouseover", callback: (arg: Screen) => void): this;
+ on(event: "element mouseout", callback: (arg: Screen) => void): this;
+ on(event: "element mouseup", callback: (arg: Screen) => void): this;
+ /**
+ * Received on key event for [name].
+ */
+ //on(event: "key", callback: (arg: BlessedScreen) => void): this;
+ /**
+ * Received when the terminal window focuses/blurs. Requires a terminal supporting the
+ * focus protocol and focus needs to be passed to program.enableMouse().
+ */
+ on(event: "focus", callback: (arg: Screen) => void): this;
+ /**
+ * Received when the terminal window focuses/blurs. Requires a terminal supporting the
+ * focus protocol and focus needs to be passed to program.enableMouse().
+ */
+ on(event: "blur", callback: (arg: Screen) => void): this;
+ /**
+ * Received before render.
+ */
+ on(event: "prerender", callback: () => void): this;
+ /**
+ * Received on render.
+ */
+ on(event: "render", callback: () => void): this;
+ /**
+ * Received when blessed notices something untoward (output is not a tty, terminfo not found, etc).
+ */
+ on(event: "warning", callback: (text: string) => void): this;
+ /**
+ * Received when the screen is destroyed (only useful when using multiple screens).
+ */
+ on(event: "destroy", callback: () => void): this;
+ /**
+ * Received when the element is moved.
+ */
+ on(event: "move", callback: () => void): this;
+ /**
+ * Element was clicked (slightly smarter than mouseup).
+ */
+ on(event: "click", callback: (arg: Screen) => void): this;
+ /**
+ * Received when element is shown.
+ */
+ on(event: "show", callback: () => void): this;
+ /**
+ * Received when element becomes hidden.
+ */
+ on(event: "hide", callback: () => void): this;
+
+ on(event: "set content", callback: () => void): this;
+ on(event: "parsed content", callback: () => void): this;
+ }
+
+ export interface IScreenOptions extends INodeOptions {
+ /**
+ * The blessed Program to be associated with. Will be automatically instantiated if none is provided.
+ */
+ program?: BlessedProgram;
+ /**
+ * Attempt to perform CSR optimization on all possible elements (not just full-width ones, elements with
+ * uniform cells to their sides). This is known to cause flickering with elements that are not full-width,
+ * however, it is more optimal for terminal rendering.
+ */
+ smartCSR?: boolean;
+ /**
+ * Do CSR on any element within 20 cols of the screen edge on either side. Faster than smartCSR,
+ * but may cause flickering depending on what is on each side of the element.
+ */
+ fastCSR?: boolean;
+ /**
+ * Attempt to perform back_color_erase optimizations for terminals that support it. It will also work
+ * with terminals that don't support it, but only on lines with the default background color. As it
+ * stands with the current implementation, it's uncertain how much terminal performance this adds at
+ * the cost of overhead within node.
+ */
+ useBCE?: boolean;
+ /**
+ * Amount of time (in ms) to redraw the screen after the terminal is resized (Default: 300).
+ */
+ resizeTimeout?: number;
+ /**
+ * The width of tabs within an element's content.
+ */
+ tabSize?: number;
+ /**
+ * Automatically position child elements with border and padding in mind (NOTE: this is a recommended
+ * option. It may become default in the future).
+ */
+ autoPadding?: boolean;
+
+ cursor?: Types.TCursor;
+
+ /**
+ * Create a log file. See log method.
+ */
+ log?: (...msg: any[]) => void;
+ /**
+ * Dump all output and input to desired file. Can be used together with log option if set as a boolean.
+ */
+ dump?: string;
+ /**
+ * Debug mode. Enables usage of the debug method. Also creates a debug console which will display when
+ * pressing F12. It will display all log and debug messages.
+ */
+ debug?: (...msg: string[]) => void;
+ /**
+ * Array of keys in their full format (e.g. C-c) to ignore when keys are locked or grabbed. Useful
+ * for creating a key that will always exit no matter whether the keys are locked.
+ */
+ ignoreLocked?: boolean;
+ /**
+ * Automatically "dock" borders with other elements instead of overlapping, depending on position
+ * (experimental). For example: These border-overlapped elements:
+ */
+ dockBorders?: boolean;
+ /**
+ * Normally, dockable borders will not dock if the colors or attributes are different. This option
+ * will allow them to dock regardless. It may produce some odd looking multi-colored borders though.
+ */
+ ignoreDockContrast?: boolean;
+ /**
+ * Allow for rendering of East Asian double-width characters, utf-16 surrogate pairs, and unicode
+ * combining characters. This allows you to display text above the basic multilingual plane. This
+ * is behind an option because it may affect performance slightly negatively. Without this option
+ * enabled, all double-width, surrogate pair, and combining characters will be replaced by '??',
+ * '?', '' respectively. (NOTE: iTerm2 cannot display combining characters properly. Blessed simply
+ * removes them from an element's content if iTerm2 is detected).
+ */
+ fullUnicode?: boolean;
+ /**
+ * Send focus events after mouse is enabled.
+ */
+ sendFocus?: boolean;
+ /**
+ * Display warnings (such as the output not being a TTY, similar to ncurses).
+ */
+ warnings?: boolean;
+ /**
+ * Force blessed to use unicode even if it is not detected via terminfo, env variables, or windows code page.
+ * If value is true unicode is forced. If value is false non-unicode is forced (default: null).
+ */
+ forceUnicode?: boolean;
+ /**
+ * Input and output streams. process.stdin/process.stdout by default, however, it could be a
+ * net.Socket if you want to make a program that runs over telnet or something of that nature.
+ * */
+ input?: stream.Writable;
+ /**
+ * Input and output streams. process.stdin/process.stdout by default, however, it could be a
+ * net.Socket if you want to make a program that runs over telnet or something of that nature.
+ * */
+ output?: stream.Readable;
+ /**
+ * The blessed Tput object (only available if you passed tput: true to the Program constructor.)
+ */
+ tput?: Tput;
+ /**
+ * Top of the focus history stack.
+ */
+ focused?: BlessedElement;
+ /**
+ * Width of the screen (same as program.cols).
+ */
+ width?: Types.TPosition;
+ /**
+ * Height of the screen (same as program.rows).
+ */
+ height?: Types.TPosition;
+ /**
+ * Same as screen.width.
+ */
+ cols?: number;
+ /**
+ * Same as screen.height.
+ */
+ rows?: number;
+ /**
+ * Relative top offset, always zero.
+ */
+ top?: Types.TTopLeft;
+ /**
+ * Relative left offset, always zero.
+ */
+ left?: Types.TTopLeft;
+ /**
+ * Relative right offset, always zero.
+ */
+ right?: Types.TPosition;
+ /**
+ * Relative bottom offset, always zero.
+ */
+ bottom?: Types.TPosition;
+ /**
+ * Absolute top offset, always zero.
+ */
+ atop?: Types.TTopLeft;
+ /**
+ * Absolute left offset, always zero.
+ */
+ aleft?: Types.TTopLeft;
+ /**
+ * Absolute right offset, always zero.
+ */
+ aright?: Types.TPosition;
+ /**
+ * Absolute bottom offset, always zero.
+ */
+ abottom?: Types.TPosition;
+ /**
+ * Whether the focused element grabs all keypresses.
+ */
+ grabKeys?: any;
+ /**
+ * Prevent keypresses from being received by any element.
+ */
+ lockKeys?: boolean;
+ /**
+ * The currently hovered element. Only set if mouse events are bound.
+ */
+ hover?: any;
+ /**
+ * Set or get terminal name. Set calls screen.setTerminal() internally.
+ */
+ terminal?: string;
+ /**
+ * Set or get window title.
+ */
+ title?: string;
+ }
+
+ export class Screen extends NodeWithEvents implements IHasOptions {
+ constructor(opts: IScreenOptions);
+
+ // ** properties ** //
+ cleanSides: any;
+
+ /**
+ * Original options object.
+ */
+ options: IScreenOptions;
+
+ /**
+ * The blessed Program to be associated with. Will be automatically instantiated if none is provided.
+ */
+ program: BlessedProgram;
+ /**
+ * Attempt to perform CSR optimization on all possible elements (not just full-width ones, elements with
+ * uniform cells to their sides). This is known to cause flickering with elements that are not full-width,
+ * however, it is more optimal for terminal rendering.
+ */
+ smartCSR: boolean;
+ /**
+ * Do CSR on any element within 20 cols of the screen edge on either side. Faster than smartCSR,
+ * but may cause flickering depending on what is on each side of the element.
+ */
+ fastCSR: boolean;
+ /**
+ * Attempt to perform back_color_erase optimizations for terminals that support it. It will also work
+ * with terminals that don't support it, but only on lines with the default background color. As it
+ * stands with the current implementation, it's uncertain how much terminal performance this adds at
+ * the cost of overhead within node.
+ */
+ useBCE: boolean;
+ /**
+ * Amount of time (in ms) to redraw the screen after the terminal is resized (Default: 300).
+ */
+ resizeTimeout: number;
+ /**
+ * The width of tabs within an element's content.
+ */
+ tabSize: number;
+ /**
+ * Automatically position child elements with border and padding in mind (NOTE: this is a recommended
+ * option. It may become default in the future).
+ */
+ autoPadding: boolean;
+
+ cursor: Types.TCursor;
+
+ /**
+ * Dump all output and input to desired file. Can be used together with log option if set as a boolean.
+ */
+ dump: string;
+ /**
+ * Array of keys in their full format (e.g. C-c) to ignore when keys are locked or grabbed. Useful
+ * for creating a key that will always exit no matter whether the keys are locked.
+ */
+ ignoreLocked: boolean;
+ /**
+ * Automatically "dock" borders with other elements instead of overlapping, depending on position
+ * (experimental). For example: These border-overlapped elements:
+ */
+ dockBorders: boolean;
+ /**
+ * Normally, dockable borders will not dock if the colors or attributes are different. This option
+ * will allow them to dock regardless. It may produce some odd looking multi-colored borders though.
+ */
+ ignoreDockContrast: boolean;
+ /**
+ * Allow for rendering of East Asian double-width characters, utf-16 surrogate pairs, and unicode
+ * combining characters. This allows you to display text above the basic multilingual plane. This
+ * is behind an option because it may affect performance slightly negatively. Without this option
+ * enabled, all double-width, surrogate pair, and combining characters will be replaced by '??',
+ * '?', '' respectively. (NOTE: iTerm2 cannot display combining characters properly. Blessed simply
+ * removes them from an element's content if iTerm2 is detected).
+ */
+ fullUnicode: boolean;
+ /**
+ * Send focus events after mouse is enabled.
+ */
+ sendFocus: boolean;
+ /**
+ * Display warnings (such as the output not being a TTY, similar to ncurses).
+ */
+ warnings: boolean;
+ /**
+ * Force blessed to use unicode even if it is not detected via terminfo, env variables, or windows code page.
+ * If value is true unicode is forced. If value is false non-unicode is forced (default: null).
+ */
+ forceUnicode: boolean;
+ /**
+ * Input and output streams. process.stdin/process.stdout by default, however, it could be a
+ * net.Socket if you want to make a program that runs over telnet or something of that nature.
+ * */
+ input: stream.Writable;
+ /**
+ * Input and output streams. process.stdin/process.stdout by default, however, it could be a
+ * net.Socket if you want to make a program that runs over telnet or something of that nature.
+ * */
+ output: stream.Readable;
+ /**
+ * The blessed Tput object (only available if you passed tput: true to the Program constructor.)
+ */
+ tput: Tput;
+ /**
+ * Top of the focus history stack.
+ */
+ focused: BlessedElement;
+ /**
+ * Width of the screen (same as program.cols).
+ */
+ width: Types.TPosition;
+ /**
+ * Height of the screen (same as program.rows).
+ */
+ height: Types.TPosition;
+ /**
+ * Same as screen.width.
+ */
+ cols: number;
+ /**
+ * Same as screen.height.
+ */
+ rows: number;
+ /**
+ * Relative top offset, always zero.
+ */
+ top: Types.TTopLeft;
+ /**
+ * Relative left offset, always zero.
+ */
+ left: Types.TTopLeft;
+ /**
+ * Relative right offset, always zero.
+ */
+ right: Types.TPosition;
+ /**
+ * Relative bottom offset, always zero.
+ */
+ bottom: Types.TPosition;
+ /**
+ * Absolute top offset, always zero.
+ */
+ atop: Types.TTopLeft;
+ /**
+ * Absolute left offset, always zero.
+ */
+ aleft: Types.TTopLeft;
+ /**
+ * Absolute right offset, always zero.
+ */
+ aright: Types.TPosition;
+ /**
+ * Absolute bottom offset, always zero.
+ */
+ abottom: Types.TPosition;
+ /**
+ * Whether the focused element grabs all keypresses.
+ */
+ grabKeys: any;
+ /**
+ * Prevent keypresses from being received by any element.
+ */
+ lockKeys: boolean;
+ /**
+ * The currently hovered element. Only set if mouse events are bound.
+ */
+ hover: any;
+ /**
+ * Set or get terminal name. Set calls screen.setTerminal() internally.
+ */
+ terminal: string;
+ /**
+ * Set or get window title.
+ */
+ title: string;
+
+ // ** methods ** //
+
+ /**
+ * Write string to the log file if one was created.
+ */
+ log(...msg: any[]): void;
+ /**
+ * Same as the log method, but only gets called if the debug option was set.
+ */
+ debug(...msg: string[]): void;
+ /**
+ * Allocate a new pending screen buffer and a new output screen buffer.
+ */
+ alloc(): void;
+ /**
+ * Reallocate the screen buffers and clear the screen.
+ */
+ realloc(): void;
+ /**
+ * Draw the screen based on the contents of the screen buffer.
+ */
+ draw(start: number, end: number): void;
+ /**
+ * Render all child elements, writing all data to the screen buffer and drawing the screen.
+ */
+ render(): void;
+ /**
+ * Clear any region on the screen.
+ */
+ clearRegion(x1: number, x2: number, y1: number, y2: number): void;
+ /**
+ * Fill any region with a character of a certain attribute.
+ */
+ fillRegion(attr: string, ch: string, x1: number, x2: number, y1: number, y2: number): void;
+ /**
+ * Focus element by offset of focusable elements.
+ */
+ focusOffset(offset: number): any;
+ /**
+ * Focus previous element in the index.
+ */
+ focusPrevious(): void;
+ /**
+ * Focus next element in the index.
+ */
+ focusNext(): void;
+ /**
+ * Push element on the focus stack (equivalent to screen.focused = el).
+ */
+ focusPush(element: BlessedElement): void;
+ /**
+ * Pop element off the focus stack.
+ */
+ focusPop(): BlessedElement;
+ /**
+ * Save the focused element.
+ */
+ saveFocus(): BlessedElement;
+ /**
+ * Restore the saved focused element.
+ */
+ restoreFocus(): BlessedElement;
+ /**
+ * "Rewind" focus to the last visible and attached element.
+ */
+ rewindFocus(): BlessedElement;
+ /**
+ * Spawn a process in the foreground, return to blessed app after exit.
+ */
+ spawn(file: string, args: string[], options: NodeChildProcessExecOptions): child_process.ChildProcess;
+ /**
+ * Spawn a process in the foreground, return to blessed app after exit. Executes callback on error or exit.
+ */
+ exec(file: string, args: string[], options: NodeChildProcessExecOptions, callback: Function): child_process.ChildProcess;
+ /**
+ * Read data from text editor.
+ */
+ readEditor(options: any, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void;
+ readEditor(callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void;
+ /**
+ * Set effects based on two events and attributes.
+ */
+ setEffects(el: BlessedElement, fel: BlessedElement, over: any, out: any, effects: any, temp: any): void;
+ /**
+ * Insert a line into the screen (using csr: this bypasses the output buffer).
+ */
+ insertLine(n: number, y: number, top: number, bottom: number): void;
+ /**
+ * Delete a line from the screen (using csr: this bypasses the output buffer).
+ */
+ deleteLine(n: number, y: number, top: number, bottom: number): void;
+ /**
+ * Insert a line at the bottom of the screen.
+ */
+ insertBottom(top: number, bottom: number): void;
+ /**
+ * Insert a line at the top of the screen.
+ */
+ insertTop(top: number, bottom: number): void;
+ /**
+ * Delete a line at the bottom of the screen.
+ */
+ deleteBottom(top: number, bottom: number): void;
+ /**
+ * Delete a line at the top of the screen.
+ */
+ deleteTop(top: number, bottom: number): void;
+ /**
+ * Enable mouse events for the screen and optionally an element (automatically called when a form of
+ * on('mouse') is bound).
+ */
+ enableMouse(el: BlessedElement): void;
+ enableMouse(): void;
+ /**
+ * Enable keypress events for the screen and optionally an element (automatically called when a form of
+ * on('keypress') is bound).
+ */
+ enableKeys(el: BlessedElement): void;
+ enableKeys(): void;
+ /**
+ * Enable key and mouse events. Calls bot enableMouse and enableKeys.
+ */
+ enableInput(el: BlessedElement): void;
+ enableInput(): void;
+ /**
+ * Attempt to copy text to clipboard using iTerm2's proprietary sequence. Returns true if successful.
+ */
+ copyToClipboard(text: string): void;
+ /**
+ * Attempt to change cursor shape. Will not work in all terminals (see artificial cursors for a solution
+ * to this). Returns true if successful.
+ */
+ cursorShape(shape: boolean, blink: boolean): any;
+ /**
+ * Attempt to change cursor color. Returns true if successful.
+ */
+ cursorColor(color: string): void;
+ /**
+ * Attempt to reset cursor. Returns true if successful.
+ */
+ cursorReset(): void;
+ /**
+ * Take an SGR screenshot of the screen within the region. Returns a string containing only
+ * characters and SGR codes. Can be displayed by simply echoing it in a terminal.
+ */
+ screenshot(xi: number, xl: number, yi: number, yl: number): string;
+ screenshot(): void;
+ /**
+ * Destroy the screen object and remove it from the global list. Also remove all global events relevant
+ * to the screen object. If all screen objects are destroyed, the node process is essentially reset
+ * to its initial state.
+ */
+ destroy(): void;
+ /**
+ * Reset the terminal to term. Reloads terminfo.
+ */
+ setTerminal(term: string): void;
+ }
+
+ export interface Padding {
+ left?: number;
+ right?: number;
+ top?: number;
+ bottom?: number;
+ }
+
+ export class PositionCoords {
+ xi: number;
+ xl: number;
+ yi: number;
+ yl: number;
+ }
+
+ export interface Position {
+ left: number | string;
+ right: number | string;
+ top: number | string;
+ bottom: number | string;
+ }
+
+ export interface Border {
+ /**
+ * Type of border (line or bg). bg by default.
+ */
+ type?: "line" | "bg";
+ /**
+ * Character to use if bg type, default is space.
+ */
+ ch?: string;
+ /**
+ * Border foreground and background, must be numbers (-1 for default).
+ */
+ bg?: number;
+ fg?: number;
+ /**
+ * Border attributes.
+ */
+ bold?: string;
+ underline?: string;
+ }
+
+ export interface ElementOptions extends INodeOptions {
+ tags?: boolean;
+
+ fg?: string;
+ bg?: string;
+ bold?: string;
+ underline?: string;
+
+ style?: any;
+ /**
+ * Border object, see below.
+ */
+ border?: Border | "line" | "bg";
+ /**
+ * Element's text content.
+ */
+ content?: string;
+ /**
+ * Element is clickable.
+ */
+ clickable?: boolean;
+ /**
+ * Element is focusable and can receive key input.
+ */
+ input?: boolean;
+ keyable?: boolean;
+ /**
+ * Element is focused.
+ */
+ focused?: BlessedElement;
+ /**
+ * Whether the element is hidden.
+ */
+ hidden?: boolean;
+ /**
+ * A simple text label for the element.
+ */
+ label?: string;
+ /**
+ * A floating text label for the element which appears on mouseover.
+ */
+ hoverText?: string;
+ /**
+ * Text alignment: left, center, or right.
+ */
+ align?: "left" | "center" | "right";
+ /**
+ * Vertical text alignment: top, middle, or bottom.
+ */
+ valign?: "top" | "middle" | "bottom";
+ /**
+ * Shrink/flex/grow to content and child elements. Width/height during render.
+ */
+ shrink?: boolean;
+ /**
+ * Amount of padding on the inside of the element. Can be a number or an object containing
+ * the properties: left, right, top, and bottom.
+ */
+ padding?: number | Padding;
+
+ top?: Types.TTopLeft;
+ left?: Types.TTopLeft;
+ right?: Types.TPosition;
+ bottom?: Types.TPosition;
+
+ /**
+ * Width/height of the element, can be a number, percentage (0-100%), or keyword (half or shrink).
+ * Percentages can also have offsets (50%+1, 50%-1).
+ */
+ width?: number | string;
+ /**
+ * Offsets of the element relative to its parent. Can be a number, percentage (0-100%), or
+ * keyword (center). right and bottom do not accept keywords. Percentages can also have
+ * offsets (50%+1, 50%-1).
+ */
+ height?: number | string;
+ /**
+ * Can contain the above options.
+ */
+ position?: Position;
+ /**
+ * Whether the element is scrollable or not.
+ */
+ scrollable?: boolean;
+ /**
+ * Background character (default is whitespace ).
+ */
+ ch?: string;
+ /**
+ * Allow the element to be dragged with the mouse.
+ */
+ draggable?: boolean;
+ /**
+ * Draw a translucent offset shadow behind the element.
+ */
+ shadow?: boolean;
+ }
+
+ export interface Coords {
+ xl: number;
+ xi: number;
+ yl: number;
+ yi: number;
+ base: number;
+ _contentEnd: {x: number; y: number;};
+ notop: Types.TTopLeft;
+ noleft: Types.TTopLeft;
+ noright: Types.TPosition;
+ nobot: Types.TPosition;
+ }
+
+ export interface LabelOptions {
+ text: string;
+ side: Types.TAlign;
+ }
+
+ // TODO: scrollable - Note: If the scrollable option is enabled, Element inherits all methods from ScrollableBox.
+ export abstract class BlessedElement extends NodeWithEvents implements IHasOptions {
+ constructor(opts: ElementOptions);
+
+ // ** properties ** //
+
+ /**
+ * Original options object.
+ */
+ options: ElementOptions;
+ /**
+ * Name of the element. Useful for form submission.
+ */
+ name: string;
+ /**
+ * Border object.
+ */
+ border: Border;
+
+ style: any;
+ position: Position;
+ content: string;
+ hidden: boolean;
+ visible: boolean;
+ detached: boolean;
+ /**
+ * Border foreground and background, must be numbers (-1 for default).
+ */
+ bg: number;
+ fg: number;
+ /**
+ * Border attributes.
+ */
+ bold: string;
+ underline: string;
+ /**
+ * Calculated width.
+ */
+ width: number | string;
+ /**
+ * Calculated height.
+ */
+ height: number | string;
+ /**
+ * Calculated relative top offset.*/
+ top: Types.TTopLeft;
+ /**
+ * Calculated relative left offset.
+ */
+ left: Types.TTopLeft;
+ /**
+ * Calculated relative right offset.
+ */
+ right: Types.TPosition;
+ /**
+ * Calculated relative bottom offset.
+ */
+ bottom: Types.TPosition;
+ /**
+ * Calculated absolute top offset.
+ */
+ atop: Types.TTopLeft;
+ /**
+ * Calculated absolute left offset.
+ */
+ aleft: Types.TTopLeft;
+ /**
+ * Calculated absolute right offset.
+ */
+ aright: Types.TPosition;
+ /**
+ * Calculated absolute bottom offset.
+ */
+ abottom: Types.TPosition;
+
+ /**
+ * Whether the element is draggable. Set to true to allow dragging.
+ */
+ draggable: boolean;
+
+ itop: Types.TTopLeft;
+ ileft: Types.TTopLeft;
+ iheight: Types.TPosition;
+ iwidth: Types.TPosition;
+
+ /**
+ * Calculated relative top offset.
+ */
+ rtop: Types.TTopLeft;
+ /**
+ * Calculated relative left offset.
+ */
+ rleft: Types.TTopLeft;
+ /**
+ * Calculated relative right offset.
+ */
+ rright: Types.TPosition;
+ /**
+ * Calculated relative bottom offset.
+ */
+ rbottom: Types.TPosition;
+
+ lpos: PositionCoords;
+
+ // ** methods ** //
+
+ /**
+ * Write content and children to the screen buffer.
+ */
+ render(): Coords;
+ /**
+ * Hide element.*/
+ hide(): void;
+ /**
+ * Show element.
+ */
+ show(): void;
+ /**
+ * Toggle hidden/shown.
+ */
+ toggle(): void;
+ /**
+ * Focus element.
+ */
+ focus(): void;
+ /**
+ * Same asel.on('screen', ...) except this will automatically keep track of which listeners
+ * are bound to the screen object. For use with removeScreenEvent(), free(), and destroy().
+ */
+ onScreenEvent(type: string, handler: Function): void;
+ /**
+ * Same asel.removeListener('screen', ...) except this will automatically keep track of which
+ * listeners are bound to the screen object. For use with onScreenEvent(), free(), and destroy().
+ */
+ removeScreenEvent(type: string, handler: Function): void;
+ /**
+ * Free up the element. Automatically unbind all events that may have been bound to the screen
+ * object. This prevents memory leaks. For use with onScreenEvent(), removeScreenEvent(),
+ * and destroy().
+ */
+ free(): void;
+ /**
+ * Same as the detach() method, except this will automatically call free() and unbind any screen
+ * events to prevent memory leaks. for use with onScreenEvent(), removeScreenEvent(), and free().
+ */
+ destroy(): void;
+ /**
+ * Set the z-index of the element (changes rendering order).
+ */
+ setIndex(z: number): void;
+ /**
+ * Put the element in front of its siblings.*/
+ setFront(): void;
+ /**
+ * Put the element in back of its siblings.
+ */
+ setBack(): void;
+ /**
+ * text/options - Set the label text for the top-left corner. Example options: {text:'foo',side:'left'}
+ */
+ setLabel(arg: string | LabelOptions): void;
+ /**
+ * Remove the label completely.
+ */
+ removeLabel(): any;
+ /**
+ * text/options - Set a hover text box to follow the cursor. Similar to the "title" DOM attribute
+ * in the browser. Example options: {text:'foo'}
+ */
+ setHover(arg: string | LabelOptions): void;
+ /**
+ * Remove the hover label completely.
+ */
+ removeHover(): void;
+ /**
+ * Enable mouse events for the element (automatically called when a form of on('mouse') is bound).
+ */
+ enableMouse(): void;
+ /**
+ * Enable keypress events for the element (automatically called when a form of on('keypress') is bound).
+ */
+ enableKeys(): void;
+ /**
+ * Enable key and mouse events. Calls bot enableMouse and enableKeys.
+ */
+ enableInput(): void;
+ /**
+ * Enable dragging of the element.
+ */
+ enableDrag(): void;
+ /**
+ * Disable dragging of the element.
+ */
+ disableDrag(): void;
+ /**
+ * Take an SGR screenshot of the screen within the region. Returns a string containing only
+ * characters and SGR codes. Can be displayed by simply echoing it in a terminal.
+ */
+ screenshot(xi: number, xl: number, yi: number, yl: number): string;
+ screenshot(): void;
+
+ /*
+ Content Methods
+
+ Methods for dealing with text content, line by line. Useful for writing a text editor,
+ irc client, etc.
+
+ Note: All of these methods deal with pre-aligned, pre-wrapped text. If you use deleteTop()
+ on a box with a wrapped line at the top, it may remove 3-4 "real" lines (rows) depending
+ on how long the original line was.
+
+ The lines parameter can be a string or an array of strings. The line parameter must
+ be a string.
+ */
+
+ /**
+ * Set the content. Note: When text is input, it will be stripped of all non-SGR
+ * escape codes, tabs will be replaced with 8 spaces, and tags will be replaced
+ * with SGR codes (if enabled).
+ */
+ setContent(text: string): void;
+ /**
+ * Return content, slightly different from el.content. Assume the above formatting.
+ */
+ getContent(): string;
+ /**
+ * Similar to setContent, but ignore tags and remove escape codes.
+ */
+ setText(text: string): void;
+ /**
+ * Similar to getContent, but return content with tags and escape codes removed.
+ */
+ getText(): string;
+ /**
+ * Insert a line into the box's content.
+ */
+ insertLine(i: number, lines: string | string[]): void;
+ /**
+ * Delete a line from the box's content.
+ */
+ deleteLine(i: number): void;
+ /**
+ * Get a line from the box's content.
+ */
+ getLine(i: number): string;
+ /**
+ * Get a line from the box's content from the visible top.
+ */
+ getBaseLine(i: number): string;
+ /**
+ * Set a line in the box's content.
+ */
+ setLine(i: number, line: string | string[]): void;
+ /**
+ * Set a line in the box's content from the visible top.
+ */
+ setBaseLine(i: number, line: string | string[]): void;
+ /**
+ * Clear a line from the box's content.
+ */
+ clearLine(i: number): void;
+ /**
+ * Clear a line from the box's content from the visible top.
+ */
+ clearBaseLine(i: number): void;
+ /**
+ * Insert a line at the top of the box.
+ */
+ insertTop(lines: string | string[]): void;
+ /**
+ * Insert a line at the bottom of the box.
+ */
+ insertBottom(lines: string | string[]): void;
+ /**
+ * Delete a line at the top of the box.
+ */
+ deleteTop(): void;
+ /**
+ * Delete a line at the bottom of the box.
+ */
+ deleteBottom(): void;
+ /**
+ * Unshift a line onto the top of the content.
+ */
+ unshiftLine(lines: string | string[]): void;
+ /**
+ * Shift a line off the top of the content.
+ */
+ shiftLine(i: number): void;
+ /**
+ * Push a line onto the bottom of the content.
+ */
+ pushLine(lines: string | string[]): void;
+ /**
+ * Pop a line off the bottom of the content.
+ */
+ popLine(i: number): string;
+ /**
+ * An array containing the content lines.
+ */
+ getLines(): string[];
+ /**
+ * An array containing the lines as they are displayed on the screen.
+ */
+ getScreenLines(): string[];
+ /**
+ * Get a string's displayed width, taking into account double-width, surrogate pairs,
+ * combining characters, tags, and SGR escape codes.
+ */
+ strWidth(text: string): string;
+
+ // ** events ** //
+ }
+
+ export interface ScrollableBoxOptions extends ElementOptions {
+ /**
+ * A limit to the childBase. Default is Infinity.
+ */
+ baseLimit?: number;
+ /**
+ * A option which causes the ignoring of childOffset. This in turn causes the
+ * childBase to change every time the element is scrolled.
+ */
+ alwaysScroll?: boolean;
+ /**
+ * Object enabling a scrollbar.
+ * Style of the scrollbar track if present (takes regular style options).
+ */
+ scrollbar?: { style?: any; track?: any; ch?: string; }
+ }
+
+ export interface ScrollableTextOptions extends ScrollableBoxOptions {
+ /**
+ * Whether to enable automatic mouse support for this element.
+ * Use pre-defined mouse events (right-click for editor).
+ */
+ mouse?: boolean | (() => void);
+ /**
+ * Use pre-defined keys (i or enter for insert, e for editor, C-e for editor while inserting).
+ */
+ keys?: string | string[] | boolean;
+ /**
+ * Use vi keys with the keys option.
+ */
+ vi?: boolean;
+ }
+
+ export interface BoxOptions extends ScrollableTextOptions {
+ bindings?: any;
+ }
+
+ /**
+ * DEPRECATED - Use Box with the scrollable option instead. A box with scrollable content.
+ */
+ export class ScrollableBoxElement extends BlessedElement {
+ /**
+ * The offset of the top of the scroll content.
+ */
+ childBase: number;
+ /**
+ * The offset of the chosen item/line.
+ */
+ childOffset: number;
+
+ /**
+ * Scroll the content by a relative offset.
+ */
+ scroll(offset: number, always?: boolean): void;
+ /**
+ * Scroll the content to an absolute index.
+ */
+ scrollTo(index: number): void;
+ /**
+ * Same as scrollTo.
+ */
+ setScroll(index: number): void;
+ /**
+ * Set the current scroll index in percentage (0-100).
+ */
+ setScrollPerc(perc: number): void;
+ /**
+ * Get the current scroll index in lines.
+ */
+ getScroll(): void;
+ /**
+ * Get the actual height of the scrolling area.
+ */
+ getScrollHeight(): void;
+ /**
+ * Get the current scroll index in percentage.
+ */
+ getScrollPerc(): void;
+ /**
+ * Reset the scroll index to its initial state.
+ */
+ resetScroll(): void;
+
+ on(event: string, listener: Function): this;
+ /**
+ * Received when the element is scrolled.
+ */
+ on(event: "scroll", callback: () => void): this;
+ }
+
+ /**
+ * DEPRECATED - Use Box with the scrollable and alwaysScroll options instead.
+ * A scrollable text box which can display and scroll text, as well as handle
+ * pre-existing newlines and escape codes.
+ */
+ export class ScrollableTextElement extends ScrollableBoxElement {
+ }
+
+ /**
+ * A box element which draws a simple box containing content or other elements.
+ */
+ export class BoxElement extends ScrollableTextElement implements IHasOptions {
+ constructor(opts: BoxOptions);
+
+ /**
+ * Original options object.
+ */
+ options: BoxOptions;
+ }
+
+ export interface TextOptions extends ElementOptions {
+ /**
+ * Fill the entire line with chosen bg until parent bg ends, even if there
+ * is not enough text to fill the entire width.
+ */
+ fill?: boolean;
+ /**
+ * Text alignment: left, center, or right.
+ */
+ align?: Types.TAlign;
+ }
+
+ /**
+ * An element similar to Box, but geared towards rendering simple text elements.
+ */
+ export class TextElement extends BlessedElement implements IHasOptions {
+ constructor(opts: TextOptions);
+
+ /**
+ * Original options object.
+ */
+ options: TextOptions;
+ }
+
+ /**
+ * A simple line which can be line or bg styled.
+ */
+ export interface LineOptions extends BoxOptions {
+ /**
+ * Can be vertical or horizontal.
+ */
+ orientation?: "vertical" | "horizontal";
+ /**
+ * Treated the same as a border object. (attributes can be contained in style).
+ */
+ type?: string;
+ bg?: string;
+ fg?: string;
+ ch?: string;
+ }
+
+ /**
+ * A simple line which can be line or bg styled.
+ */
+ export class LineElement extends BoxElement implements IHasOptions {
+ constructor(opts: LineOptions);
+
+ /**
+ * Original options object.
+ */
+ options: LineOptions;
+ }
+
+ export interface BigTextOptions extends BoxOptions {
+ /**
+ * bdf->json font file to use (see ttystudio for instructions on compiling BDFs to JSON).
+ */
+ font?: string;
+ /**
+ * bdf->json bold font file to use (see ttystudio for instructions on compiling BDFs to JSON).
+ */
+ fontBold?: string;
+ /**
+ * foreground character. (default: ' ')
+ */
+ fch?: string;
+ }
+
+ /**
+ * A box which can render content drawn as 8x14 cell characters using the terminus font.
+ */
+ export class BigTextElement extends BoxElement implements IHasOptions {
+ constructor(opts: BigTextOptions);
+
+ /**
+ * Original options object.
+ */
+ options: BigTextOptions;
+ }
+
+ export interface ListElementStyle {
+ selected?: any;
+ item?: any;
+ }
+
+ export interface ListOptions extends BoxOptions {
+ /**
+ * Style for a selected item. Style for an unselected item.
+ */
+ style?: TStyle;
+ /**
+ * An array of strings which become the list's items.
+ */
+ items?: string[];
+ /**
+ * A function that is called when vi mode is enabled and the key / is pressed. This function accepts a
+ * callback function which should be called with the search string. The search string is then used to
+ * jump to an item that is found in items.
+ */
+ search?: () => void;
+ /**
+ * Whether the list is interactive and can have items selected (Default: true).
+ */
+ interactive?: boolean;
+ /**
+ * Whether to automatically override tags and invert fg of item when selected (Default: true).
+ */
+ invertSelected?: boolean;
+ }
+
+ export class ListElement extends BoxElement implements IHasOptions> {
+ constructor(opts: ListOptions);
+
+ /**
+ * Original options object.
+ */
+ options: ListOptions;
+
+ /**
+ * Add an item based on a string.
+ */
+ add(text: string): void;
+ /**
+ * Add an item based on a string.
+ */
+ addItem(text: string): void;
+ /**
+ * Removes an item from the list. Child can be an element, index, or string.
+ */
+ removeItem(child: BlessedElement): BlessedElement;
+ /**
+ * Push an item onto the list.
+ * */
+ pushItem(child: BlessedElement): number;
+ /**
+ * Pop an item off the list.
+ * */
+ popItem(): BlessedElement;
+ /**
+ * Unshift an item onto the list.
+ */
+ unshiftItem(child: BlessedElement): number;
+ /**
+ * Shift an item off the list.
+ * */
+ shiftItem(): BlessedElement;
+ /**
+ * Inserts an item to the list. Child can be an element, index, or string.
+ */
+ insertItem(i: number, child: BlessedElement): void;
+ /**
+ * Returns the item element. Child can be an element, index, or string.
+ */
+ getItem(child: BlessedElement): BlessedElement;
+ /**
+ * Set item to content.
+ */
+ setItem(child: BlessedElement, content: BlessedElement | string): void;
+ /**
+ * Remove and insert items to the list.
+ * */
+ spliceItem(i: number, n: number, ...items: BlessedElement[]): void;
+ /**
+ * Clears all items from the list.
+ * */
+ clearItems(): void;
+ /**
+ * Sets the list items to multiple strings.
+ */
+ setItems(items: BlessedElement[]): void;
+ /**
+ * Returns the item index from the list. Child can be an element, index, or string.
+ */
+ getItemIndex(child: BlessedElement): number;
+ /**
+ * Select an index of an item.
+ * */
+ select(index: number): void;
+ /**
+ * Select item based on current offset.
+ * */
+ move(offset: number): void;
+ /**
+ * Select item above selected.
+ * */
+ up(amount: number): void;
+ /**
+ * Select item below selected.
+ */
+ down(amount: number): void;
+ /**
+ * Show/focus list and pick an item. The callback is executed with the result.
+ */
+ pick(callback: () => void): void;
+ /**
+ * Find an item based on its text content.
+ */
+ fuzzyFind(arg: string | RegExp | (() => void)): void;
+
+ // ** events ** //
+
+ on(event: string, listener: Function): this;
+ /**
+ * Received when an item is selected.
+ */
+ on(event: "select", callback: (item: BoxElement, index: number) => void): this;
+ /**
+ * List was canceled (when esc is pressed with the keys option).
+ */
+ on(event: "cancel", callback: () => void): this;
+ /**
+ * Either a select or a cancel event was received.
+ */
+ on(event: "action", callback: () => void): this;
+
+ on(event: "create item", callback: () => void): this;
+ on(event: "add item", callback: () => void): this;
+ on(event: "remove item", callback: () => void): this;
+ on(event: "insert item", callback: () => void): this;
+ on(event: "set items", callback: () => void): this;
+ on(event: "select item", callback: (item: BlessedElement, index: number) => void): this;
+ }
+
+ export interface FileManagerOptions extends ListOptions {
+ /**
+ * Current working directory.
+ */
+ cwd?: string;
+ }
+
+ export class FileManagerElement extends ListElement implements IHasOptions {
+ constructor(opts: FileManagerOptions);
+
+ /**
+ * Original options object.
+ */
+ options: FileManagerOptions;
+ /**
+ * Current working directory.
+ */
+ cwd: string;
+
+ /**
+ * Refresh the file list (perform a readdir on cwd and update the list items).
+ */
+ refresh(cwd:string, callback: () => void): void;
+ refresh(callback: () => void): void;
+ refresh(): void;
+ /**
+ * Pick a single file and return the path in the callback.
+ */
+ pick(cwd:string, callback: () => void): void;
+ pick(callback: () => void): void;
+ /**
+ * Reset back to original cwd.
+ */
+ reset(cwd:string, callback: () => void): void;
+ reset(callback: () => void): void;
+ reset(): void;
+
+ // ** events ** //
+
+ on(event: string, listener: Function): this;
+ /**
+ * Received when an item is selected.
+ */
+ on(event: "cd", callback: (file: string, cwd: string) => void): this;
+ /**
+ * Received when an item is selected.
+ */
+ on(event: "file", callback: (file: string) => void): this;
+
+ on(event: "error", callback: (err: any, file: string) => void): this;
+ on(event: "refresh", callback: () => void): this;
+ }
+
+ export interface StyleListTable extends ListElementStyle {
+ /**
+ * Header style.
+ */
+ header?: any;
+ /**
+ * Cell style.
+ */
+ cell?: any;
+ }
+
+ export interface ListTableOptions extends ListOptions {
+ /**
+ * Array of array of strings representing rows.
+ */
+ rows?: string[];
+ data?: string[][];
+ /**
+ * Spaces to attempt to pad on the sides of each cell. 2 by default: one space on each side
+ * (only useful if the width is shrunken).
+ */
+ pad?: number;
+ /**
+ * Do not draw inner cells.
+ */
+ noCellBorders?: boolean;
+
+ style?: StyleListTable;
+ }
+
+ export class ListTableElement extends ListElement implements IHasOptions {
+ constructor(opts: ListTableOptions);
+
+ /**
+ * Original options object.
+ */
+ options: ListTableOptions;
+
+ /**
+ * Set rows in table. Array of arrays of strings.
+ * @example:
+ *
+ * table.setData([
+ [ 'Animals', 'Foods' ],
+ [ 'Elephant', 'Apple' ],
+ [ 'Bird', 'Orange' ]
+ ]);
+ */
+ setRows(rows: string[][]): void;
+ /**
+ * Set rows in table. Array of arrays of strings.
+ * @example:
+ *
+ * table.setData([
+ [ 'Animals', 'Foods' ],
+ [ 'Elephant', 'Apple' ],
+ [ 'Bird', 'Orange' ]
+ ]);
+ */
+ setData(rows: string[][]): void;
+ }
+
+ export interface ListbarOptions extends BoxOptions {
+ style?: ListElementStyle;
+ /**
+ * Set buttons using an object with keys as titles of buttons, containing of objects
+ * containing keys of keys and callback.
+ */
+ commands: Types.ListbarCommand[];
+ items: Types.ListbarCommand[];
+ /**
+ * Automatically bind list buttons to keys 0-9.
+ */
+ autoCommandKeys: boolean;
+ }
+
+ export class ListbarElement extends BoxElement implements IHasOptions {
+ constructor(opts: ListbarOptions);
+
+ /**
+ * Original options object.
+ */
+ options: ListbarOptions;
+
+ /**
+ * Set commands (see commands option above).
+ */
+ setItems(commands: Types.ListbarCommand[]): void;
+ /**
+ * Append an item to the bar.
+ */
+ add(item: Types.ListbarCommand, callback: () => void): void;
+ /**
+ * Append an item to the bar.
+ */
+ addItem(item: Types.ListbarCommand, callback: () => void): void;
+ /**
+ * Append an item to the bar.
+ */
+ appendItem(item: Types.ListbarCommand, callback: () => void): void;
+ /**
+ * Select an item on the bar.
+ */
+ select(offset: number): void;
+ /**
+ * Remove item from the bar.
+ */
+ removeItem(child: BlessedElement): void;
+ /**
+ * Move relatively across the bar.
+ */
+ move(offset: number): void;
+ /**
+ * Move left relatively across the bar.
+ */
+ moveLeft(offset: number): void;
+ /**
+ * Move right relatively across the bar.
+ */
+ moveRight(offset: number): void;
+ /**
+ * Select button and execute its callback.
+ */
+ selectTab(index: number): void;
+
+ // ** events ** //
+
+ on(event: string, listener: Function): this;
+
+ on(event: "set items", callback: () => void): this;
+ on(event: "remove item", callback: () => void): this;
+ on(event: "select tab", callback: () => void): this;
+ }
+
+ export interface FormOptions extends BoxOptions {
+ /**
+ * Allow default keys (tab, vi keys, enter).
+ */
+ keys?: any;
+ /**
+ * Allow vi keys.
+ */
+ vi?: boolean;
+ }
+
+ export class FormElement extends BoxElement implements IHasOptions {
+ constructor(opts: FormOptions);
+
+ /**
+ * Original options object.
+ */
+ options: FormOptions;
+ /**
+ * Last submitted data.
+ */
+ submission: TFormData;
+
+ /**
+ * Focus next form element.
+ */
+ focusNext(): void;
+ /**
+ * Focus previous form element.
+ */
+ focusPrevious(): void;
+ /**
+ * Submit the form.
+ */
+ submit(): void;
+ /**
+ * Discard the form.
+ */
+ cancel(): void;
+ /**
+ * Clear the form.
+ */
+ reset(): void;
+
+ // ** events ** //
+
+ on(event: string, listener: Function): this;
+ /**
+ * Form is submitted. Receives a data object.
+ */
+ on(event: "submit", callback: (out: TFormData) => void): this;
+ /**
+ * Form is discarded.
+ */
+ on(event: "cancel", callback: () => void): this;
+ /**
+ * Form is cleared.
+ */
+ on(event: "reset", callback: () => void): this;
+ }
+
+ export interface InputOptions extends BoxOptions { }
+
+ export abstract class InputElement extends BoxElement {
+ constructor(opts: InputOptions);
+ }
+
+ /**
+ * A box which allows multiline text input.
+ */
+ export interface TextareaOptions extends InputOptions {
+ /**
+ * Call readInput() when the element is focused. Automatically unfocus.
+ */
+ inputOnFocus?: boolean;
+ }
+
+ export class TextareaElement extends InputElement implements IHasOptions {
+ constructor(opts: TextareaOptions);
+
+ /**
+ * Original options object.
+ */
+ options: TextareaOptions;
+
+ /**
+ * The input text. read-only.
+ */
+ value: string;
+
+ /**
+ * Submit the textarea (emits submit).
+ */
+ submit(): void;
+ /**
+ * Cancel the textarea (emits cancel).
+ */
+ cancel(): void;
+ /**
+ * Grab key events and start reading text from the keyboard. Takes a callback which receives
+ * the final value.
+ */
+ readInput(callback?: (err: any, value?: string) => void): void;
+ /**
+ * Grab key events and start reading text from the keyboard. Takes a callback which receives
+ * the final value.
+ */
+ input(callback: (err: any, value?: string) => void): void;
+ /**
+ * Grab key events and start reading text from the keyboard. Takes a callback which receives
+ * the final value.
+ */
+ setInput(callback: (err: any, value?: string) => void): void;
+ /**
+ * Open text editor in $EDITOR, read the output from the resulting file. Takes a callback which
+ * receives the final value.
+ */
+ readEditor(callback: (err: any, value?: string) => void): void;
+ /**
+ * Open text editor in $EDITOR, read the output from the resulting file. Takes a callback which
+ * receives the final value.
+ */
+ editor(callback: (err: any, value?: string) => void): void;
+ /**
+ * Open text editor in $EDITOR, read the output from the resulting file. Takes a callback which
+ * receives the final value.
+ */
+ setEditor(callback: (err: any, value?: string) => void): void;
+ /**
+ * The same as this.value, for now.
+ */
+ getValue(): string;
+ /**
+ * Clear input.
+ */
+ clearValue(): void;
+ /**
+ * Set value.
+ */
+ setValue(text: string): void;
+
+ // ** events ** //
+
+ on(event: string, listener: Function): this;
+
+ on(event: "error", callback: (err: any) => void): this;
+
+ /**
+ * Value is submitted (enter).
+ */
+ on(event: "submit", callback: (value: any) => void): this;
+ /**
+ * Value is discared (escape).
+ */
+ on(event: "cancel", callback: (value: any) => void): this;
+ /**
+ * Either submit or cancel.
+ */
+ on(event: "action", callback: (value: any) => void): this;
+ }
+
+ export interface TextboxOptions extends TextareaOptions {
+ /**
+ * Completely hide text.
+ */
+ secret?: boolean;
+ /**
+ * Replace text with asterisks (*).
+ */
+ censor?: boolean;
+ }
+
+ export class TextboxElement extends TextareaElement implements IHasOptions {
+ constructor(opts: TextboxOptions);
+
+ /**
+ * Original options object.
+ */
+ options: TextboxOptions;
+
+ /**
+ * Completely hide text.
+ */
+ secret: boolean;
+ /**
+ * Replace text with asterisks (*).
+ */
+ censor: boolean;
+ }
+
+ export interface ButtonOptions extends BoxOptions { }
+
+ export class ButtonElement extends InputElement implements IHasOptions {
+ constructor(opts: ButtonOptions);
+
+ /**
+ * Original options object.
+ */
+ options: ButtonOptions;
+
+ /**
+ * Press button. Emits press.
+ */
+ press(): void;
+
+ on(event: string, listener: Function): this;
+
+ on(event: "press", callback: () => void): this;
+ }
+
+ export interface CheckboxOptions extends BoxOptions {
+ /**
+ * whether the element is checked or not.
+ * */
+ checked?: boolean;
+ /**
+ * enable mouse support.
+ * */
+ mouse?: boolean;
+ }
+
+ /**
+ * A checkbox which can be used in a form element.
+ * */
+ export class CheckboxElement extends InputElement implements IHasOptions {
+ constructor(options?: CheckboxOptions);
+
+ /**
+ * Original options object.
+ */
+ options: CheckboxOptions;
+
+ /**
+ * the text next to the checkbox (do not use setcontent, use `check.text = ''`).
+ * */
+ text: string;
+ /**
+ * whether the element is checked or not.
+ * */
+ checked: boolean;
+ /**
+ * same as `checked`.
+ * */
+ value: boolean;
+
+ /**
+ * check the element.
+ * */
+ check(): void;
+ /**
+ * uncheck the element.
+ * */
+ uncheck(): void;
+ /**
+ * toggle checked state.
+ * */
+ toggle(): void;
+ }
+
+ export interface RadioSetOptions extends BoxOptions { }
+
+ /**
+ * An element wrapping RadioButtons. RadioButtons within this element will be mutually exclusive
+ * with each other.
+ * */
+ export abstract class RadioSetElement extends BoxElement {
+ constructor(opts: RadioSetOptions);
+ }
+
+ export interface RadioButtonOptions extends BoxOptions { }
+
+ /**
+ * A radio button which can be used in a form element.
+ */
+ export abstract class RadioButtonElement extends CheckboxElement {
+ constructor(opts: RadioButtonOptions);
+ }
+
+ export interface PromptOptions extends BoxOptions { }
+
+ /**
+ * A prompt box containing a text input, okay, and cancel buttons (automatically hidden).
+ */
+ export class PromptElement extends BoxElement implements IHasOptions {
+ constructor(opts: PromptOptions);
+
+ options: PromptOptions;
+
+ /**
+ * Show the prompt and wait for the result of the textbox. Set text and initial value.
+ */
+ input(text: string, value: string, callback: (err: any, value: string) => void): void;
+ setInput(text: string, value: string, callback: (err: any, value: string) => void): void;
+ readInput(text: string, value: string, callback: (err: any, value: string) => void): void;
+ }
+
+ export interface QuestionOptions extends BoxOptions { }
+
+ /**
+ * A question box containing okay and cancel buttons (automatically hidden).
+ */
+ export class QuestionElement extends BoxElement implements IHasOptions {
+ constructor(opts: QuestionOptions);
+
+ options: QuestionOptions;
+
+ /**
+ * Ask a question. callback will yield the result.
+ */
+ ask(question: string, callback: (err: any, value: string) => void): void;
+ }
+
+ export interface MessageOptions extends BoxOptions { }
+
+ /**
+ * A box containing a message to be displayed (automatically hidden).
+ */
+ export class MessageElement extends BoxElement implements IHasOptions {
+ constructor(opts: MessageOptions);
+
+ options: MessageOptions;
+
+ /**
+ * Display a message for a time (default is 3 seconds). Set time to 0 for a perpetual message that is dismissed on keypress.
+ */
+ log(text: string, time: number, callback: (err: any) => void): void;
+ log(text: string, callback: (err: any) => void): void;
+ display(text: string, time: number, callback: (err: any) => void): void;
+ display(text: string, callback: (err: any) => void): void;
+
+ /**
+ * Display an error in the same way.
+ */
+ error(text: string, time: number, callback: () => void): void;
+ error(text: string, callback: () => void): void;
+ }
+
+ export interface LoadingOptions extends BoxOptions { }
+
+ /**
+ * A box with a spinning line to denote loading (automatically hidden).
+ */
+ export class LoadingElement extends BoxElement implements IHasOptions {
+ constructor(opts: LoadingOptions);
+
+ options: LoadingOptions;
+
+ /**
+ * Display the loading box with a message. Will lock keys until stop is called.
+ */
+ load(text: string): void;
+ /**
+ * Hide loading box. Unlock keys.
+ */
+ stop(): void;
+ }
+
+ export interface ProgressBarOptions extends BoxOptions {
+ /**
+ * can be `horizontal` or `vertical`.
+ * */
+ orientation: string;
+ /**
+ * the character to fill the bar with (default is space).
+ * */
+ pch: string;
+ /**
+ * the amount filled (0 - 100).
+ * */
+ filled: number;
+ /**
+ * same as `filled`.
+ * */
+ value: number;
+ /**
+ * enable key support.
+ * */
+ keys: boolean;
+ /**
+ * enable mouse support.
+ * */
+ mouse: boolean;
+ }
+
+ /**
+ * A progress bar allowing various styles. This can also be used as a form input.
+ */
+ export class ProgressBarElement extends InputElement implements IHasOptions {
+ constructor(options?: ProgressBarOptions);
+
+ options: ProgressBarOptions;
+
+ /**
+ * progress the bar by a fill amount.
+ * */
+ progress(amount:number): void;
+ /**
+ * set progress to specific amount.
+ * */
+ setProgress(amount:number): void;
+ /**
+ * reset the bar.
+ * */
+ reset(): void;
+
+ on(event: string, listener: Function): this;
+ /**
+ * Bar was reset.
+ */
+ on(event: "reset", callback: () => void): this;
+ /**
+ * Bar has completely filled.
+ */
+ on(event: "complete", callback: () => void): this;
+ }
+
+ export interface LogOptions extends ScrollableTextOptions {
+ /**
+ * amount of scrollback allowed. default: Infinity.
+ * */
+ scrollback?: number;
+ /**
+ * scroll to bottom on input even if the user has scrolled up. default: false.
+ * */
+ scrollOnInput?: boolean;
+ }
+
+ /**
+ * A log permanently scrolled to the bottom.
+ * */
+ export class Log extends ScrollableTextElement implements IHasOptions {
+ constructor(options?: LogOptions);
+
+ options: LogOptions;
+
+ /**
+ * amount of scrollback allowed. default: Infinity.
+ * */
+ scrollback: number;
+ /**
+ * scroll to bottom on input even if the user has scrolled up. default: false.
+ * */
+ scrollOnInput: boolean;
+
+ /**
+ * add a log line.
+ * */
+ log(text:string): void;
+ /**
+ * add a log line.
+ * */
+ add(text:string): void;
+ }
+
+ export interface TableOptions extends BoxOptions {
+ /**
+ * array of array of strings representing rows (same as `data`).
+ * */
+ rows?: string[][];
+ /**
+ * array of array of strings representing rows (same as `rows`).
+ * */
+ data?: string[][];
+ /**
+ * spaces to attempt to pad on the sides of each cell. `2` by default: one space on each side (only useful if the width is shrunken).
+ * */
+ pad?: number;
+ /**
+ * do not draw inner cells.
+ * */
+ noCellBorders?: boolean;
+ /**
+ * fill cell borders with the adjacent background color.
+ * */
+ fillCellBorders?: boolean;
+ }
+
+ /**
+ * A stylized table of text elements.
+ * */
+ export class TableElement extends BoxElement implements IHasOptions {
+ constructor(opts: TableOptions);
+
+ options: TableOptions;
+
+ /**
+ * set rows in table. array of arrays of strings.
+ * */
+ setData(rows: string[][]): void;
+ /**
+ * set rows in table. array of arrays of strings.
+ * */
+ setRows(rows: string[][]): void;
+ }
+
+ export interface TerminalOptions extends BoxOptions {
+ /**
+ * handler for input data.
+ * */
+ handler?: (userInput:Buffer) => void;
+ /**
+ * name of shell. $SHELL by default.
+ * */
+ shell?:string;
+ /**
+ * args for shell.
+ * */
+ args?:any;
+ /**
+ * can be line, underline, and block.
+ * */
+ cursor?: 'line'|'underline'|'block';
+
+ terminal?: string;
+
+ /**
+ * Object for process env.
+ */
+ env?: any;
+ }
+
+ export class TerminalElement extends BoxElement implements IHasOptions {
+ constructor(opts: TerminalOptions);
+
+ options: TerminalOptions;
+
+ /**
+ * reference to the headless term.js terminal.
+ * */
+ term: any;
+ /**
+ * reference to the pty.js pseudo terminal.
+ * */
+ pty: any;
+
+ /**
+ * write data to the terminal.
+ * */
+ write(data:string): void;
+
+ /**
+ * nearly identical to `element.screenshot`, however, the specified region includes the terminal's _entire_ scrollback, rather than just what is visible on the screen.
+ * */
+ screenshot(xi?:number, xl?:number, yi?:number, yl?:number): string;
+ }
+
+ export interface ImageOptions extends BoxOptions {
+ /**
+ * path to image.
+ * */
+ file: string;
+ /**
+ * path to w3mimgdisplay. if a proper w3mimgdisplay path is not given, blessed will search the entire disk for the binary.
+ * */
+ type: "ansi" | "overlay" | "w3m";
+ }
+
+ /**
+ * Display an image in the terminal (jpeg, png, gif) using w3mimgdisplay. Requires w3m to be installed. X11 required: works in xterm, urxvt, and possibly other terminals.
+ * */
+ export class ImageElement extends BoxElement implements IHasOptions {
+ constructor(options?: ImageOptions);
+
+ options: ImageOptions;
+ }
+
+ export interface ANSIImageOptions extends BoxOptions {
+ /**
+ * URL or path to PNG/GIF file. Can also be a buffer.
+ * */
+ file: string;
+ /**
+ * Scale cellmap down (0-1.0) from its original pixel width/height (Default: 1.0).
+ * */
+ scale: number;
+
+ /**
+ * This differs from other element's width or height in that only one of them is needed: blessed will maintain the aspect ratio of the image as it scales down to the proper number of cells. NOTE: PNG/GIF's are always automatically shrunken to size (based on scale) if a width or height is not given.
+ * */
+ width: number | string;
+ height: number | string;
+
+ /**
+ * Add various "density" ASCII characters over the rendering to give the image more detail, similar to libcaca/libcucul (the library mplayer uses to display videos in the terminal).
+ */
+ ascii: string;
+
+ /**
+ * Whether to animate if the image is an APNG/animating GIF. If false, only display the first frame or IDAT (Default: true).
+ */
+ animate: boolean;
+
+ /**
+ * Set the speed of animation. Slower: 0.0-1.0. Faster: 1-1000. It cannot go faster than 1 frame per millisecond, so 1000 is the fastest. (Default: 1.0)
+ */
+ speed: number;
+
+ /**
+ * mem or cpu. If optimizing for memory, animation frames will be rendered to bitmaps as the animation plays, using less memory. Optimizing for cpu will precompile all bitmaps beforehand, which may be faster, but might also OOM the process on large images. (Default: mem).
+ */
+ optimization: "mem" | "cpu";
+ }
+
+ /**
+ * Convert any .png file (or .gif, see below) to an ANSI image and display it as an element.
+ * */
+ export class ANSIImageElement extends BoxElement implements IHasOptions {
+ constructor(options?:ANSIImageOptions);
+
+ options: ANSIImageOptions;
+
+ /**
+ * Image object from the png reader.
+ */
+ img: Types.TImage;
+
+ /**
+ * set the image in the box to a new path.
+ * */
+ setImage(img: string, callback: () => void): void;
+ /**
+ * clear the current image.
+ * */
+ clearImage(callback: () => void): void;
+ /**
+ * Play animation if it has been paused or stopped.
+ */
+ play(): void;
+ /**
+ * Pause animation.
+ */
+ pause(): void;
+ /**
+ * Stop animation.
+ */
+ stop(): void;
+ }
+
+ export interface OverlayImageOptions extends BoxOptions {
+ /**
+ * Path to image.
+ */
+ file: string;
+ /**
+ * Render the file as ANSI art instead of using w3m to overlay Internally uses the ANSIImage element. See the ANSIImage element for more information/options. (Default: true).
+ */
+ ansi: boolean;
+ /**
+ * Path to w3mimgdisplay. If a proper w3mimgdisplay path is not given, blessed will search the entire disk for the binary.
+ */
+ w3m: string;
+ /**
+ * Whether to search /usr, /bin, and /lib for w3mimgdisplay (Default: true).
+ */
+ search: string;
+ }
+
+ /**
+ * Convert any .png file (or .gif, see below) to an ANSI image and display it as an element.
+ * */
+ export class OverlayImageElement extends BoxElement implements IHasOptions {
+ constructor(options?: OverlayImageOptions);
+
+ options: OverlayImageOptions;
+
+ /**
+ * set the image in the box to a new path.
+ * */
+ setImage(img: string, callback: () => void): void;
+ /**
+ * clear the current image.
+ * */
+ clearImage(callback: () => void): void;
+ /**
+ * get the size of an image file in pixels.
+ * */
+ imageSize(img:string, callback: () => void): void;
+ /**
+ * get the size of the terminal in pixels.
+ * */
+ termSize(callback: () => void): void;
+ /**
+ * get the pixel to cell ratio for the terminal.
+ * */
+ getPixelRatio(callback: () => void): void;
+ }
+
+ export interface VideoOptions extends BoxOptions {
+ /**
+ * Video to play.
+ */
+ file: string;
+ /**
+ * Start time in seconds.
+ */
+ start: number;
+ }
+
+ export class VideoElement extends BoxElement implements IHasOptions {
+ constructor(options?: VideoOptions);
+
+ options: VideoOptions;
+
+ /**
+ * The terminal element running mplayer or mpv.
+ */
+ tty: any;
+ }
+
+ export interface LayoutOptions extends ElementOptions {
+ /**
+ * A callback which is called right before the children are iterated over to be rendered. Should return an
+ * iterator callback which is called on each child element: iterator(el, i).
+ */
+ renderer?: () => void;
+
+ /**
+ * Using the default renderer, it provides two layouts: inline, and grid. inline is the default and will render
+ * akin to inline-block. grid will create an automatic grid based on element dimensions. The grid cells'
+ * width and height are always determined by the largest children in the layout.
+ */
+ layout: "inline" | "inline-block" | "grid";
+ }
+
+ export class LayoutElement extends BlessedElement implements IHasOptions {
+ constructor(options?: LayoutOptions);
+
+ options: LayoutOptions;
+
+ /**
+ * A callback which is called right before the children are iterated over to be rendered. Should return an
+ * iterator callback which is called on each child element: iterator(el, i).
+ */
+ renderer(coords: PositionCoords): void;
+ /**
+ * Check to see if a previous child element has been rendered and is visible on screen. This is only useful
+ * for checking child elements that have already been attempted to be rendered! see the example below.
+ */
+ isRendered(el: BlessedElement): boolean;
+ /**
+ * Get the last rendered and visible child element based on an index. This is useful for basing the position
+ * of the current child element on the position of the last child element.
+ */
+ getLast(i: number): Element;
+ /**
+ * Get the last rendered and visible child element coords based on an index. This is useful for basing the position
+ * of the current child element on the position of the last child element. See the example below.
+ */
+ getLastCoords(i: number): PositionCoords;
+ }
+
+ export class Program {
+ /**
+ Wrap the given text in terminal formatting codes corresponding to the given attribute
+ name. The `attr` string can be of the form `red fg` or `52 bg` where `52` is a 0-255
+ integer color number.
+ */
+ text (text:string, attr:string): string;
+ }
}
- export = Blessed;
+ export module widget {
+ export class Element extends Widgets.BlessedElement { }
+ export class Node extends Widgets.Node { }
+ export class Screen extends Widgets.Screen { }
+
+ export class Box extends Widgets.BoxElement { }
+ export class ScrollableBox extends Widgets.ScrollableBoxElement { }
+ export class ScrollableText extends Widgets.ScrollableTextElement { }
+ export class Text extends Widgets.BoxElement { }
+ export class Line extends Widgets.LineElement { }
+ export class BigText extends Widgets.BigTextElement { }
+ export class List extends Widgets.ListElement { }
+ export class FileManager extends Widgets.FileManagerElement { }
+ export class ListTable extends Widgets.ListTableElement { }
+ export class ListBar extends Widgets.ListbarElement { }
+ export class Form extends Widgets.FormElement { }
+ export class Textarea extends Widgets.TextareaElement { }
+ export class Button extends Widgets.ButtonElement { }
+ export class Checkbox extends Widgets.CheckboxElement { }
+ export class RadioSet extends Widgets.RadioSetElement { }
+ export class RadioButton extends Widgets.RadioButtonElement { }
+
+ export class Prompt extends Widgets.PromptElement { }
+ export class question extends Widgets.QuestionElement { }
+ export class Message extends Widgets.MessageElement { }
+ export class Loading extends Widgets.LoadingElement { }
+
+ export class ProgressBar extends Widgets.ProgressBarElement { }
+ export class Terminal extends Widgets.TerminalElement { }
+ }
+
+ export function screen(options?: Widgets.IScreenOptions): Widgets.Screen;
+
+ export function box(options?: Widgets.BoxOptions): Widgets.BoxElement;
+ export function text(options?: Widgets.TextOptions): Widgets.TextElement;
+ export function line(options?: Widgets.LineOptions): Widgets.LineElement;
+ export function scrollablebox(options?: Widgets.BoxOptions): Widgets.BoxElement;
+ export function scrollabletext(options?: Widgets.BoxOptions): Widgets.BoxElement;
+ export function bigtext(options?: Widgets.BigTextOptions): Widgets.BigTextElement;
+ export function list(options?: Widgets.ListOptions): Widgets.ListElement;
+ export function filemanager(options?: Widgets.FileManagerOptions): Widgets.FileManagerElement;
+ export function listtable(options?: Widgets.ListTableOptions): Widgets.ListTableElement;
+ export function listbar(options?: Widgets.ListbarOptions): Widgets.ListbarElement;
+ export function form(options?: Widgets.FormOptions): Widgets.FormElement;
+ export function input(options?: Widgets.InputOptions): Widgets.InputElement;
+ export function textarea(options?: Widgets.TextareaOptions): Widgets.TextareaElement;
+ export function textbox(options?: Widgets.TextboxOptions): Widgets.TextboxElement;
+ export function button(options?: Widgets.ButtonOptions): Widgets.ButtonElement;
+ export function checkbox(options?: Widgets.CheckboxOptions): Widgets.CheckboxElement;
+ export function radioset(options?: Widgets.RadioSetOptions): Widgets.RadioSetElement;
+ export function radiobutton(options?: Widgets.RadioButtonOptions): Widgets.RadioButtonElement;
+
+ export function table(options?: Widgets.TableOptions): Widgets.TableElement;
+
+ export function prompt(options?: Widgets.PromptOptions): Widgets.PromptElement;
+ export function question(options?: Widgets.QuestionOptions): Widgets.QuestionElement;
+ export function message(options?: Widgets.MessageOptions): Widgets.MessageElement;
+ export function loading(options?: Widgets.LoadingOptions): Widgets.LoadingElement;
+
+ export function progressbar(options?: Widgets.ProgressBarOptions): Widgets.ProgressBarElement;
+ export function terminal(options?: Widgets.TerminalOptions): Widgets.TerminalElement;
+
+ export function layout(options?: Widgets.LayoutOptions): Widgets.LayoutElement;
+
+ export function escape(item: any): any;
+ export const colors: {
+ match: (hexColor: string) => string
+ }
}
-
-
-
diff --git a/bluebird/bluebird-tests.ts b/bluebird/bluebird-tests.ts
index 59cef89b1a..d7995438c1 100644
--- a/bluebird/bluebird-tests.ts
+++ b/bluebird/bluebird-tests.ts
@@ -82,6 +82,7 @@ var voidProm: Promise;
var fooProm: Promise;
var barProm: Promise;
+var barOrVoidProm: Promise;
var fooOrBarProm: Promise