From b7dda17cc1b21040560192daeccead6114fdce8f Mon Sep 17 00:00:00 2001 From: Paulo Cesar Date: Sat, 2 Aug 2014 13:59:17 -0300 Subject: [PATCH 01/30] angular directive changes, still missing #2605 --- angularjs/angular-tests.ts | 461 ++++++++++++++++++++----------------- angularjs/angular.d.ts | 38 +-- 2 files changed, 269 insertions(+), 230 deletions(-) diff --git a/angularjs/angular-tests.ts b/angularjs/angular-tests.ts index a1577856e..2507d7f8c 100644 --- a/angularjs/angular-tests.ts +++ b/angularjs/angular-tests.ts @@ -231,11 +231,11 @@ foo.then((x) => { }).then((x) => { // Object is inferred here x.a = 123; - //Try a promise + //Try a promise var y: ng.IPromise; - return y; + return y; }).then((x) => { - // x is infered to be a number, which is the resolved value of a promise + // x is infered to be a number, which is the resolved value of a promise x.toFixed(); }); @@ -281,252 +281,279 @@ test_IAttributes({ $attr: {} }); +class SampleDirective implements ng.IDirective { + public restrict = 'A'; + name = 'doh'; + + compile(templateElement: any) { + return this.link; + } + + link(scope: any) { + + } +} + +class SampleDirective2 implements ng.IDirective { + public restrict = 'EAC'; + + compile(templateElement: any) { + return { + pre: this.link + }; + } + + link(scope: any) { + + } +} + // test from https://docs.angularjs.org/guide/directive angular.module('docsSimpleDirective', []) - .controller('Controller', ['$scope', function($scope: any) { - $scope.customer = { - name: 'Naomi', - address: '1600 Amphitheatre' - }; - }]) - .directive('myCustomer', function() { - return { - template: 'Name: {{customer.name}} Address: {{customer.address}}' - }; - }); + .controller('Controller', ['$scope', function($scope: any) { + $scope.customer = { + name: 'Naomi', + address: '1600 Amphitheatre' + }; + }]) + .directive('myCustomer', function() { + return { + template: 'Name: {{customer.name}} Address: {{customer.address}}' + }; + }); angular.module('docsTemplateUrlDirective', []) - .controller('Controller', ['$scope', function($scope: any) { - $scope.customer = { - name: 'Naomi', - address: '1600 Amphitheatre' - }; - }]) - .directive('myCustomer', function() { - return { - templateUrl: 'my-customer.html' - }; - }); + .controller('Controller', ['$scope', function($scope: any) { + $scope.customer = { + name: 'Naomi', + address: '1600 Amphitheatre' + }; + }]) + .directive('myCustomer', function() { + return { + templateUrl: 'my-customer.html' + }; + }); angular.module('docsRestrictDirective', []) - .controller('Controller', ['$scope', function($scope: any) { - $scope.customer = { - name: 'Naomi', - address: '1600 Amphitheatre' - }; - }]) - .directive('myCustomer', function() { - return { - restrict: 'E', - templateUrl: 'my-customer.html' - }; - }); + .controller('Controller', ['$scope', function($scope: any) { + $scope.customer = { + name: 'Naomi', + address: '1600 Amphitheatre' + }; + }]) + .directive('myCustomer', function() { + return { + restrict: 'E', + templateUrl: 'my-customer.html' + }; + }); angular.module('docsScopeProblemExample', []) - .controller('NaomiController', ['$scope', function($scope: any) { - $scope.customer = { - name: 'Naomi', - address: '1600 Amphitheatre' - }; - }]) - .controller('IgorController', ['$scope', function($scope: any) { - $scope.customer = { - name: 'Igor', - address: '123 Somewhere' - }; - }]) - .directive('myCustomer', function() { - return { - restrict: 'E', - templateUrl: 'my-customer.html' - }; - }); + .controller('NaomiController', ['$scope', function($scope: any) { + $scope.customer = { + name: 'Naomi', + address: '1600 Amphitheatre' + }; + }]) + .controller('IgorController', ['$scope', function($scope: any) { + $scope.customer = { + name: 'Igor', + address: '123 Somewhere' + }; + }]) + .directive('myCustomer', function() { + return { + restrict: 'E', + templateUrl: 'my-customer.html' + }; + }); angular.module('docsIsolateScopeDirective', []) - .controller('Controller', ['$scope', function($scope: any) { - $scope.naomi = { name: 'Naomi', address: '1600 Amphitheatre' }; - $scope.igor = { name: 'Igor', address: '123 Somewhere' }; - }]) - .directive('myCustomer', function() { - return { - restrict: 'E', - scope: { - customerInfo: '=info' - }, - templateUrl: 'my-customer-iso.html' - }; - }); + .controller('Controller', ['$scope', function($scope: any) { + $scope.naomi = { name: 'Naomi', address: '1600 Amphitheatre' }; + $scope.igor = { name: 'Igor', address: '123 Somewhere' }; + }]) + .directive('myCustomer', function() { + return { + restrict: 'E', + scope: { + customerInfo: '=info' + }, + templateUrl: 'my-customer-iso.html' + }; + }); angular.module('docsIsolationExample', []) - .controller('Controller', ['$scope', function($scope: any) { - $scope.naomi = { name: 'Naomi', address: '1600 Amphitheatre' }; - $scope.vojta = { name: 'Vojta', address: '3456 Somewhere Else' }; - }]) - .directive('myCustomer', function() { - return { - restrict: 'E', - scope: { - customerInfo: '=info' - }, - templateUrl: 'my-customer-plus-vojta.html' - }; - }); + .controller('Controller', ['$scope', function($scope: any) { + $scope.naomi = { name: 'Naomi', address: '1600 Amphitheatre' }; + $scope.vojta = { name: 'Vojta', address: '3456 Somewhere Else' }; + }]) + .directive('myCustomer', function() { + return { + restrict: 'E', + scope: { + customerInfo: '=info' + }, + templateUrl: 'my-customer-plus-vojta.html' + }; + }); angular.module('docsTimeDirective', []) - .controller('Controller', ['$scope', function($scope: any) { - $scope.format = 'M/d/yy h:mm:ss a'; - }]) - .directive('myCurrentTime', ['$interval', 'dateFilter', function($interval: any, dateFilter: any): ng.IDirective { + .controller('Controller', ['$scope', function($scope: any) { + $scope.format = 'M/d/yy h:mm:ss a'; + }]) + .directive('myCurrentTime', ['$interval', 'dateFilter', function($interval: any, dateFilter: any): ng.IDirective { - return { - link: function(scope: any, element: any, attrs: any) { - var format: any, - timeoutId: any; + return { + link: function(scope: any, element: any, attrs: any) { + var format: any, + timeoutId: any; - function updateTime() { - element.text(dateFilter(new Date(), format)); - } + function updateTime() { + element.text(dateFilter(new Date(), format)); + } - scope.$watch(attrs.myCurrentTime, function (value: any) { - format = value; - updateTime(); - }); + scope.$watch(attrs.myCurrentTime, function (value: any) { + format = value; + updateTime(); + }); - element.on('$destroy', function () { - $interval.cancel(timeoutId); - }); + element.on('$destroy', function () { + $interval.cancel(timeoutId); + }); - // start the UI update process; save the timeoutId for canceling - timeoutId = $interval(function () { - updateTime(); // update DOM - }, 1000); - } - }; - }]); + // start the UI update process; save the timeoutId for canceling + timeoutId = $interval(function () { + updateTime(); // update DOM + }, 1000); + } + }; + }]); angular.module('docsTransclusionDirective', []) - .controller('Controller', ['$scope', function($scope: any) { - $scope.name = 'Tobias'; - }]) - .directive('myDialog', function() { - return { - restrict: 'E', - transclude: true, - templateUrl: 'my-dialog.html' - }; - }); + .controller('Controller', ['$scope', function($scope: any) { + $scope.name = 'Tobias'; + }]) + .directive('myDialog', function() { + return { + restrict: 'E', + transclude: true, + templateUrl: 'my-dialog.html' + }; + }); angular.module('docsTransclusionExample', []) - .controller('Controller', ['$scope', function($scope: any) { - $scope.name = 'Tobias'; - }]) - .directive('myDialog', function() { - return { - restrict: 'E', - transclude: true, - scope: {}, - templateUrl: 'my-dialog.html', - link: function (scope: any, element: any) { - scope.name = 'Jeff'; - } - }; - }); + .controller('Controller', ['$scope', function($scope: any) { + $scope.name = 'Tobias'; + }]) + .directive('myDialog', function() { + return { + restrict: 'E', + transclude: true, + scope: {}, + templateUrl: 'my-dialog.html', + link: function (scope: any, element: any) { + scope.name = 'Jeff'; + } + }; + }); angular.module('docsIsoFnBindExample', []) - .controller('Controller', ['$scope', '$timeout', function($scope: any, $timeout: any) { - $scope.name = 'Tobias'; - $scope.hideDialog = function () { - $scope.dialogIsHidden = true; - $timeout(function () { - $scope.dialogIsHidden = false; - }, 2000); - }; - }]) - .directive('myDialog', function() { - return { - restrict: 'E', - transclude: true, - scope: { - 'close': '&onClose' - }, - templateUrl: 'my-dialog-close.html' - }; - }); + .controller('Controller', ['$scope', '$timeout', function($scope: any, $timeout: any) { + $scope.name = 'Tobias'; + $scope.hideDialog = function () { + $scope.dialogIsHidden = true; + $timeout(function () { + $scope.dialogIsHidden = false; + }, 2000); + }; + }]) + .directive('myDialog', function() { + return { + restrict: 'E', + transclude: true, + scope: { + 'close': '&onClose' + }, + templateUrl: 'my-dialog-close.html' + }; + }); angular.module('dragModule', []) - .directive('myDraggable', ['$document', function($document: any) { - return function(scope: any, element: any, attr: any) { - var startX = 0, startY = 0, x = 0, y = 0; + .directive('myDraggable', ['$document', function($document: any) { + return function(scope: any, element: any, attr: any) { + var startX = 0, startY = 0, x = 0, y = 0; - element.css({ - position: 'relative', - border: '1px solid red', - backgroundColor: 'lightgrey', - cursor: 'pointer' - }); + element.css({ + position: 'relative', + border: '1px solid red', + backgroundColor: 'lightgrey', + cursor: 'pointer' + }); - element.on('mousedown', function(event: any) { - // Prevent default dragging of selected content - event.preventDefault(); - startX = event.pageX - x; - startY = event.pageY - y; - $document.on('mousemove', mousemove); - $document.on('mouseup', mouseup); - }); + element.on('mousedown', function(event: any) { + // Prevent default dragging of selected content + event.preventDefault(); + startX = event.pageX - x; + startY = event.pageY - y; + $document.on('mousemove', mousemove); + $document.on('mouseup', mouseup); + }); - function mousemove(event: any) { - y = event.pageY - startY; - x = event.pageX - startX; - element.css({ - top: y + 'px', - left: x + 'px' - }); - } + function mousemove(event: any) { + y = event.pageY - startY; + x = event.pageX - startX; + element.css({ + top: y + 'px', + left: x + 'px' + }); + } - function mouseup() { - $document.off('mousemove', mousemove); - $document.off('mouseup', mouseup); - } - }; - }]); + function mouseup() { + $document.off('mousemove', mousemove); + $document.off('mouseup', mouseup); + } + }; + }]); angular.module('docsTabsExample', []) - .directive('myTabs', function() { - return { - restrict: 'E', - transclude: true, - scope: {}, - controller: function($scope: any) { - var panes: any = $scope.panes = []; + .directive('myTabs', function() { + return { + restrict: 'E', + transclude: true, + scope: {}, + controller: function($scope: any) { + var panes: any = $scope.panes = []; - $scope.select = function(pane: any) { - angular.forEach(panes, function(pane: any) { - pane.selected = false; - }); - pane.selected = true; - }; + $scope.select = function(pane: any) { + angular.forEach(panes, function(pane: any) { + pane.selected = false; + }); + pane.selected = true; + }; - this.addPane = function(pane: any) { - if (panes.length === 0) { - $scope.select(pane); - } - panes.push(pane); - }; - }, - templateUrl: 'my-tabs.html' - }; - }) - .directive('myPane', function() { - return { - require: '^myTabs', - restrict: 'E', - transclude: true, - scope: { - title: '@' - }, - link: function(scope, element, attrs, tabsCtrl) { - tabsCtrl.addPane(scope); - }, - templateUrl: 'my-pane.html' - }; - }); + this.addPane = function(pane: any) { + if (panes.length === 0) { + $scope.select(pane); + } + panes.push(pane); + }; + }, + templateUrl: 'my-tabs.html' + }; + }) + .directive('myPane', function() { + return { + require: '^myTabs', + restrict: 'E', + transclude: true, + scope: { + title: '@' + }, + link: function(scope: any, element: any, attrs: any, tabsCtrl: any) { + tabsCtrl.addPane(scope); + }, + templateUrl: 'my-pane.html' + }; + }); diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index e447985fb..b1b5e358f 100755 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -1031,22 +1031,34 @@ declare module ng { (...args: any[]): IDirective; } + interface IDirectiveLinkFn { + ( + scope?: IScope, + instanceElement?: IAugmentedJQuery, + instanceAttributes?: IAttributes, + controller?: any, + transclude?: ITranscludeFunction + ): void; + } - interface IDirective{ - compile?: - (templateElement: IAugmentedJQuery, - templateAttributes: IAttributes, - transclude: ITranscludeFunction - ) => any; + interface IDirectivePrePost { + pre?: IDirectiveLinkFn; + post?: IDirectiveLinkFn; + } + + interface IDirectiveCompileFn { + ( + templateElement?: IAugmentedJQuery, + templateAttributes?: IAttributes, + transclude?: ITranscludeFunction + ): IDirectivePrePost; + } + + interface IDirective { + compile?: IDirectiveCompileFn; controller?: any; controllerAs?: string; - link?: - (scope: IScope, - instanceElement: IAugmentedJQuery, - instanceAttributes: IAttributes, - controller: any, - transclude: ITranscludeFunction - ) => void; + link?: IDirectivePrePost; name?: string; priority?: number; replace?: boolean; From 64795f2f0f0b96d7bf95d1d485e11dbc6d6703d1 Mon Sep 17 00:00:00 2001 From: James Roland Cabresos Date: Sun, 3 Aug 2014 04:47:28 +0800 Subject: [PATCH 02/30] Added morgan definitions --- morgan/morgan-tests.ts | 29 +++++++++++++ morgan/morgan.d.ts | 93 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 122 insertions(+) create mode 100644 morgan/morgan-tests.ts create mode 100644 morgan/morgan.d.ts diff --git a/morgan/morgan-tests.ts b/morgan/morgan-tests.ts new file mode 100644 index 000000000..00e67f875 --- /dev/null +++ b/morgan/morgan-tests.ts @@ -0,0 +1,29 @@ +/// +/** + * Created by staticfunction on 8/3/14. + */ + +import morgan = require('morgan'); + +// a pre-defined name +morgan('combined') +morgan('common') +morgan('short') +morgan('tiny') + +// a format string +morgan(':remote-addr :method :url') + +// a custom function +morgan(function (req, res) { + return req.method + ' ' + req.url +}) + +morgan('combined', { + buffer: true, + immediate: true, + skip: function (req, res) { return res.statusCode < 400 }, + stream: (str: string) => { + console.log(str); + } +}); diff --git a/morgan/morgan.d.ts b/morgan/morgan.d.ts new file mode 100644 index 000000000..b889bc7be --- /dev/null +++ b/morgan/morgan.d.ts @@ -0,0 +1,93 @@ +// Type definitions for morgan 1.2.2 +// Project: https://github.com/expressjs/morgan +// Definitions by: James Roland Cabresos +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// +declare module "morgan" { + + import express = require('express'); + + module morgan { + + export function token(name: string, callback: (req: express.Request, res: express.Response) => T): express.RequestHandler; + + /*** + * Morgan accepts these properties in the options object. + */ + export interface Options { + + /*** + * Buffer duration before writing logs to the stream, defaults to false. When set to true, defaults to 1000 ms. + */ + buffer?: boolean; + + /*** + * Write log line on request instead of response. This means that a requests will be logged even if the server crashes, but data from the response cannot be logged (like the response code). + */ + immediate?: boolean; + + /*** + * Function to determine if logging is skipped, defaults to false. This function will be called as skip(req, res). + */ + skip?: (req: express.Request, res: express.Response) => boolean; + + /*** + * Output stream for writing log lines, defaults to process.stdout. + * @param str + */ + stream?: (str: string) => void; + } + } + + /*** + * Create a new morgan logger middleware function using the given format and options. The format argument may be a string of a predefined name (see below for the names), a string of a format string, or a function that will produce a log entry. + * @param format + * @param options + */ + function morgan(format: string, options?: morgan.Options): express.RequestHandler; + + /*** + * Standard Apache combined log output. + * :remote-addr - :remote-user [:date] ":method :url HTTP/:http-version" :status :res[content-length] ":referrer" ":user-agent" + * @param format + * @param options + */ + function morgan(format: 'combined', options?: morgan.Options): express.RequestHandler; + + /*** + * Standard Apache common log output. + * :remote-addr - :remote-user [:date] ":method :url HTTP/:http-version" :status :res[content-length] + * @param format + * @param options + */ + function morgan(format: 'common', options?: morgan.Options): express.RequestHandler; + + /*** + * Concise output colored by response status for development use. The :status token will be colored red for server error codes, yellow for client error codes, cyan for redirection codes, and uncolored for all other codes. + * :method :url :status :response-time ms - :res[content-length] + * @param format + * @param options + */ + function morgan(format: 'dev', options?: morgan.Options): express.RequestHandler; + + /*** + * Shorter than default, also including response time. + * :remote-addr :remote-user :method :url HTTP/:http-version :status :res[content-length] - :response-time ms + * @param format + * @param options + */ + function morgan(format: 'short', options?: morgan.Options): express.RequestHandler; + + /*** + * The minimal output. + * :method :url :status :res[content-length] - :response-time ms + * @param format + * @param options + */ + function morgan(format: 'tiny', options?: morgan.Options): express.RequestHandler; + + function morgan(custom: (req: express.Request, res: express.Response) => string): express.RequestHandler + + export = morgan; +} \ No newline at end of file From df1080e63a50158f3a315b9e9d938e27f45e2fb3 Mon Sep 17 00:00:00 2001 From: James Roland Cabresos Date: Mon, 4 Aug 2014 20:54:42 +0800 Subject: [PATCH 03/30] Added htmlparser2 definitions --- htmlparser2/htmlparser2.d.ts | 89 +++++++++++++++++++++++++++++++++ htmlparser2/htmlparser2tests.ts | 24 +++++++++ 2 files changed, 113 insertions(+) create mode 100644 htmlparser2/htmlparser2.d.ts create mode 100644 htmlparser2/htmlparser2tests.ts diff --git a/htmlparser2/htmlparser2.d.ts b/htmlparser2/htmlparser2.d.ts new file mode 100644 index 000000000..77fb0b983 --- /dev/null +++ b/htmlparser2/htmlparser2.d.ts @@ -0,0 +1,89 @@ +// Type definitions for htmlparser2 v3.7.x +// Project: https://github.com/fb55/htmlparser2/ +// Definitions by: James Roland Cabresos +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +declare module "htmlparser2" { + + export interface Handler { + onopentag?:(name:string, attribs:{[type:string]: string}) => void; + onopentagname?:(name:string) => void; + onattribute?:(name:string, value:string) => void; + ontext?:(text:string) => void; + onclosetag?: (text:string) => void; + onprocessinginstruction?:(name:string, data:string) => void; + oncomment?:(data:string) => void; + oncommentend?:() => void; + oncdatastart?:() => void; + oncdataend?:() => void; + onerror?:(error:Error) => void; + onreset?:() => void; + onend?:() => void; + } + + export interface Options { + + /*** + * Indicates whether special tags ("); +parser.end(); \ No newline at end of file From afc1fc3ed4679698884fae628d1b5214af683963 Mon Sep 17 00:00:00 2001 From: James Roland Cabresos Date: Mon, 4 Aug 2014 20:59:50 +0800 Subject: [PATCH 04/30] Added htmlparser2, morgan, and passport-facebook contributor --- CONTRIBUTORS.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index af326634b..216b74568 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -124,6 +124,7 @@ All definitions files include a header with the author and editors, so at some p * [highlight.js](https://github.com/isagalaev/highlight.js) (by [Niklas Mollenhauer](https://github.com/nikeee)) * [History.js](https://github.com/browserstate/history.js) (by [Boris Yankov](https://github.com/borisyankov)) * [Html2Canvas.js](https://github.com/niklasvh/html2canvas/) (by [Richard Hepburn](https://github.com/rwhepburn)) +* [htmlparser2](https://github.com/fb55/htmlparser2/) (by [James Roland Cabresos](https://github.com/staticfunction)) * [Humane.js](http://wavded.github.com/humane-js/) (by [John Vrbanac](https://github.com/jmvrbanac)) * [i18next](http://i18next.com/) (by [Maarten Docter](https://github.com/mdocter)) * [iCheck](http://damirfoy.com/iCheck/) (by [Dániel Tar](https://github.com/qcz)) @@ -244,6 +245,7 @@ All definitions files include a header with the author and editors, so at some p * [Moment.js](https://github.com/timrwood/moment) (by [Michael Lakerveld](https://github.com/Lakerfield)) * [MongoDB](http://mongodb.github.io/node-mongodb-native/) (from TypeScript samples, updated by [Niklas Mollenhauer](https://github.com/nikeee)) * [mongoose](http://mongoosejs.com/) (by [Hiroki Horiuchi](https://github.com/horiuchi/)) +* [morgan](hhttps://github.com/expressjs/morgan) (by [James Roland Cabresos](https://github.com/staticfunction/)) * [Mousetrap](http://craig.is/killing/mice) (by [Dániel Tar](https://github.com/qcz)) * [msgpack.js](https://github.com/uupaa/msgpack.js) (by [Shinya Mochizuki](https://github.com/enrapt-mochizuki)) * [Mustache.js](https://github.com/janl/mustache.js) (by [Boris Yankov](https://github.com/borisyankov)) @@ -267,6 +269,7 @@ All definitions files include a header with the author and editors, so at some p * [OpenLayers](https://github.com/openlayers/openlayers) (by [Ilya Bolkhovsky](https://github.com/bolhovsky/)) * [Optimist](https://github.com/substack/node-optimist) (by [Carlos Ballesteros Velasco](https://github.com/soywiz)) * [Passport](http://passportjs.org/) (by [Hiroki Horiuchi](https://github.com/horiuchi/)) +* [passport-facebook](https://github.com/jaredhanson/passport-facebook) (by [James Roland Cabresos](https://github.com/staticfunction/)) * [passport-strategy](https://github.com/jaredhanson/passport-strategy) (by [Lior Mualem](https://github.com/liorm)) * [pathwatcher](http://atom.github.io/node-pathwatcher/) (by [vvakame](https://github.com/vvakame)) * [Parallel.js](https://github.com/adambom/parallel.js) (by [Josh Baldwin](https://github.com/jbaldwin)) From 9a0a71177653bda672905ba6605aa319877dcf8e Mon Sep 17 00:00:00 2001 From: James Roland Cabresos Date: Mon, 4 Aug 2014 21:02:17 +0800 Subject: [PATCH 05/30] fix a typo --- CONTRIBUTORS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 216b74568..8098540ed 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -245,7 +245,7 @@ All definitions files include a header with the author and editors, so at some p * [Moment.js](https://github.com/timrwood/moment) (by [Michael Lakerveld](https://github.com/Lakerfield)) * [MongoDB](http://mongodb.github.io/node-mongodb-native/) (from TypeScript samples, updated by [Niklas Mollenhauer](https://github.com/nikeee)) * [mongoose](http://mongoosejs.com/) (by [Hiroki Horiuchi](https://github.com/horiuchi/)) -* [morgan](hhttps://github.com/expressjs/morgan) (by [James Roland Cabresos](https://github.com/staticfunction/)) +* [morgan](https://github.com/expressjs/morgan/) (by [James Roland Cabresos](https://github.com/staticfunction/)) * [Mousetrap](http://craig.is/killing/mice) (by [Dániel Tar](https://github.com/qcz)) * [msgpack.js](https://github.com/uupaa/msgpack.js) (by [Shinya Mochizuki](https://github.com/enrapt-mochizuki)) * [Mustache.js](https://github.com/janl/mustache.js) (by [Boris Yankov](https://github.com/borisyankov)) From f1a45e0d4e2d5260408a5f6f6a5f99269ed133de Mon Sep 17 00:00:00 2001 From: Paulo Cesar Date: Sat, 2 Aug 2014 13:59:17 -0300 Subject: [PATCH 06/30] directive accept classes --- angularjs/angular-tests.ts | 471 ++++++++++++++++++++----------------- angularjs/angular.d.ts | 38 ++- 2 files changed, 279 insertions(+), 230 deletions(-) diff --git a/angularjs/angular-tests.ts b/angularjs/angular-tests.ts index a1577856e..9c1cc0ab4 100644 --- a/angularjs/angular-tests.ts +++ b/angularjs/angular-tests.ts @@ -231,11 +231,11 @@ foo.then((x) => { }).then((x) => { // Object is inferred here x.a = 123; - //Try a promise + //Try a promise var y: ng.IPromise; - return y; + return y; }).then((x) => { - // x is infered to be a number, which is the resolved value of a promise + // x is infered to be a number, which is the resolved value of a promise x.toFixed(); }); @@ -281,252 +281,289 @@ test_IAttributes({ $attr: {} }); +class SampleDirective implements ng.IDirective { + public restrict = 'A'; + name = 'doh'; + + compile(templateElement: any) { + return this.link; + } + + static instance():ng.IDirective { + return new SampleDirective(); + } + + link(scope: any) { + + } +} + +class SampleDirective2 implements ng.IDirective { + public restrict = 'EAC'; + + compile(templateElement: any) { + return { + pre: this.link + }; + } + + static instance():ng.IDirective { + return new SampleDirective2(); + } + + link(scope: any) { + + } +} + +angular.module('SameplDirective', []).directive('sampleDirective', SampleDirective.instance).directive('sameplDirective2', SampleDirective2.instance); + // test from https://docs.angularjs.org/guide/directive angular.module('docsSimpleDirective', []) - .controller('Controller', ['$scope', function($scope: any) { - $scope.customer = { - name: 'Naomi', - address: '1600 Amphitheatre' - }; - }]) - .directive('myCustomer', function() { - return { - template: 'Name: {{customer.name}} Address: {{customer.address}}' - }; - }); + .controller('Controller', ['$scope', function($scope: any) { + $scope.customer = { + name: 'Naomi', + address: '1600 Amphitheatre' + }; + }]) + .directive('myCustomer', function() { + return { + template: 'Name: {{customer.name}} Address: {{customer.address}}' + }; + }); angular.module('docsTemplateUrlDirective', []) - .controller('Controller', ['$scope', function($scope: any) { - $scope.customer = { - name: 'Naomi', - address: '1600 Amphitheatre' - }; - }]) - .directive('myCustomer', function() { - return { - templateUrl: 'my-customer.html' - }; - }); + .controller('Controller', ['$scope', function($scope: any) { + $scope.customer = { + name: 'Naomi', + address: '1600 Amphitheatre' + }; + }]) + .directive('myCustomer', function() { + return { + templateUrl: 'my-customer.html' + }; + }); angular.module('docsRestrictDirective', []) - .controller('Controller', ['$scope', function($scope: any) { - $scope.customer = { - name: 'Naomi', - address: '1600 Amphitheatre' - }; - }]) - .directive('myCustomer', function() { - return { - restrict: 'E', - templateUrl: 'my-customer.html' - }; - }); + .controller('Controller', ['$scope', function($scope: any) { + $scope.customer = { + name: 'Naomi', + address: '1600 Amphitheatre' + }; + }]) + .directive('myCustomer', function() { + return { + restrict: 'E', + templateUrl: 'my-customer.html' + }; + }); angular.module('docsScopeProblemExample', []) - .controller('NaomiController', ['$scope', function($scope: any) { - $scope.customer = { - name: 'Naomi', - address: '1600 Amphitheatre' - }; - }]) - .controller('IgorController', ['$scope', function($scope: any) { - $scope.customer = { - name: 'Igor', - address: '123 Somewhere' - }; - }]) - .directive('myCustomer', function() { - return { - restrict: 'E', - templateUrl: 'my-customer.html' - }; - }); + .controller('NaomiController', ['$scope', function($scope: any) { + $scope.customer = { + name: 'Naomi', + address: '1600 Amphitheatre' + }; + }]) + .controller('IgorController', ['$scope', function($scope: any) { + $scope.customer = { + name: 'Igor', + address: '123 Somewhere' + }; + }]) + .directive('myCustomer', function() { + return { + restrict: 'E', + templateUrl: 'my-customer.html' + }; + }); angular.module('docsIsolateScopeDirective', []) - .controller('Controller', ['$scope', function($scope: any) { - $scope.naomi = { name: 'Naomi', address: '1600 Amphitheatre' }; - $scope.igor = { name: 'Igor', address: '123 Somewhere' }; - }]) - .directive('myCustomer', function() { - return { - restrict: 'E', - scope: { - customerInfo: '=info' - }, - templateUrl: 'my-customer-iso.html' - }; - }); + .controller('Controller', ['$scope', function($scope: any) { + $scope.naomi = { name: 'Naomi', address: '1600 Amphitheatre' }; + $scope.igor = { name: 'Igor', address: '123 Somewhere' }; + }]) + .directive('myCustomer', function() { + return { + restrict: 'E', + scope: { + customerInfo: '=info' + }, + templateUrl: 'my-customer-iso.html' + }; + }); angular.module('docsIsolationExample', []) - .controller('Controller', ['$scope', function($scope: any) { - $scope.naomi = { name: 'Naomi', address: '1600 Amphitheatre' }; - $scope.vojta = { name: 'Vojta', address: '3456 Somewhere Else' }; - }]) - .directive('myCustomer', function() { - return { - restrict: 'E', - scope: { - customerInfo: '=info' - }, - templateUrl: 'my-customer-plus-vojta.html' - }; - }); + .controller('Controller', ['$scope', function($scope: any) { + $scope.naomi = { name: 'Naomi', address: '1600 Amphitheatre' }; + $scope.vojta = { name: 'Vojta', address: '3456 Somewhere Else' }; + }]) + .directive('myCustomer', function() { + return { + restrict: 'E', + scope: { + customerInfo: '=info' + }, + templateUrl: 'my-customer-plus-vojta.html' + }; + }); angular.module('docsTimeDirective', []) - .controller('Controller', ['$scope', function($scope: any) { - $scope.format = 'M/d/yy h:mm:ss a'; - }]) - .directive('myCurrentTime', ['$interval', 'dateFilter', function($interval: any, dateFilter: any): ng.IDirective { + .controller('Controller', ['$scope', function($scope: any) { + $scope.format = 'M/d/yy h:mm:ss a'; + }]) + .directive('myCurrentTime', ['$interval', 'dateFilter', function($interval: any, dateFilter: any): ng.IDirective { - return { - link: function(scope: any, element: any, attrs: any) { - var format: any, - timeoutId: any; + return { + link: function(scope: any, element: any, attrs: any) { + var format: any, + timeoutId: any; - function updateTime() { - element.text(dateFilter(new Date(), format)); - } + function updateTime() { + element.text(dateFilter(new Date(), format)); + } - scope.$watch(attrs.myCurrentTime, function (value: any) { - format = value; - updateTime(); - }); + scope.$watch(attrs.myCurrentTime, function (value: any) { + format = value; + updateTime(); + }); - element.on('$destroy', function () { - $interval.cancel(timeoutId); - }); + element.on('$destroy', function () { + $interval.cancel(timeoutId); + }); - // start the UI update process; save the timeoutId for canceling - timeoutId = $interval(function () { - updateTime(); // update DOM - }, 1000); - } - }; - }]); + // start the UI update process; save the timeoutId for canceling + timeoutId = $interval(function () { + updateTime(); // update DOM + }, 1000); + } + }; + }]); angular.module('docsTransclusionDirective', []) - .controller('Controller', ['$scope', function($scope: any) { - $scope.name = 'Tobias'; - }]) - .directive('myDialog', function() { - return { - restrict: 'E', - transclude: true, - templateUrl: 'my-dialog.html' - }; - }); + .controller('Controller', ['$scope', function($scope: any) { + $scope.name = 'Tobias'; + }]) + .directive('myDialog', function() { + return { + restrict: 'E', + transclude: true, + templateUrl: 'my-dialog.html' + }; + }); angular.module('docsTransclusionExample', []) - .controller('Controller', ['$scope', function($scope: any) { - $scope.name = 'Tobias'; - }]) - .directive('myDialog', function() { - return { - restrict: 'E', - transclude: true, - scope: {}, - templateUrl: 'my-dialog.html', - link: function (scope: any, element: any) { - scope.name = 'Jeff'; - } - }; - }); + .controller('Controller', ['$scope', function($scope: any) { + $scope.name = 'Tobias'; + }]) + .directive('myDialog', function() { + return { + restrict: 'E', + transclude: true, + scope: {}, + templateUrl: 'my-dialog.html', + link: function (scope: any, element: any) { + scope.name = 'Jeff'; + } + }; + }); angular.module('docsIsoFnBindExample', []) - .controller('Controller', ['$scope', '$timeout', function($scope: any, $timeout: any) { - $scope.name = 'Tobias'; - $scope.hideDialog = function () { - $scope.dialogIsHidden = true; - $timeout(function () { - $scope.dialogIsHidden = false; - }, 2000); - }; - }]) - .directive('myDialog', function() { - return { - restrict: 'E', - transclude: true, - scope: { - 'close': '&onClose' - }, - templateUrl: 'my-dialog-close.html' - }; - }); + .controller('Controller', ['$scope', '$timeout', function($scope: any, $timeout: any) { + $scope.name = 'Tobias'; + $scope.hideDialog = function () { + $scope.dialogIsHidden = true; + $timeout(function () { + $scope.dialogIsHidden = false; + }, 2000); + }; + }]) + .directive('myDialog', function() { + return { + restrict: 'E', + transclude: true, + scope: { + 'close': '&onClose' + }, + templateUrl: 'my-dialog-close.html' + }; + }); angular.module('dragModule', []) - .directive('myDraggable', ['$document', function($document: any) { - return function(scope: any, element: any, attr: any) { - var startX = 0, startY = 0, x = 0, y = 0; + .directive('myDraggable', ['$document', function($document: any) { + return function(scope: any, element: any, attr: any) { + var startX = 0, startY = 0, x = 0, y = 0; - element.css({ - position: 'relative', - border: '1px solid red', - backgroundColor: 'lightgrey', - cursor: 'pointer' - }); + element.css({ + position: 'relative', + border: '1px solid red', + backgroundColor: 'lightgrey', + cursor: 'pointer' + }); - element.on('mousedown', function(event: any) { - // Prevent default dragging of selected content - event.preventDefault(); - startX = event.pageX - x; - startY = event.pageY - y; - $document.on('mousemove', mousemove); - $document.on('mouseup', mouseup); - }); + element.on('mousedown', function(event: any) { + // Prevent default dragging of selected content + event.preventDefault(); + startX = event.pageX - x; + startY = event.pageY - y; + $document.on('mousemove', mousemove); + $document.on('mouseup', mouseup); + }); - function mousemove(event: any) { - y = event.pageY - startY; - x = event.pageX - startX; - element.css({ - top: y + 'px', - left: x + 'px' - }); - } + function mousemove(event: any) { + y = event.pageY - startY; + x = event.pageX - startX; + element.css({ + top: y + 'px', + left: x + 'px' + }); + } - function mouseup() { - $document.off('mousemove', mousemove); - $document.off('mouseup', mouseup); - } - }; - }]); + function mouseup() { + $document.off('mousemove', mousemove); + $document.off('mouseup', mouseup); + } + }; + }]); angular.module('docsTabsExample', []) - .directive('myTabs', function() { - return { - restrict: 'E', - transclude: true, - scope: {}, - controller: function($scope: any) { - var panes: any = $scope.panes = []; + .directive('myTabs', function() { + return { + restrict: 'E', + transclude: true, + scope: {}, + controller: function($scope: any) { + var panes: any = $scope.panes = []; - $scope.select = function(pane: any) { - angular.forEach(panes, function(pane: any) { - pane.selected = false; - }); - pane.selected = true; - }; + $scope.select = function(pane: any) { + angular.forEach(panes, function(pane: any) { + pane.selected = false; + }); + pane.selected = true; + }; - this.addPane = function(pane: any) { - if (panes.length === 0) { - $scope.select(pane); - } - panes.push(pane); - }; - }, - templateUrl: 'my-tabs.html' - }; - }) - .directive('myPane', function() { - return { - require: '^myTabs', - restrict: 'E', - transclude: true, - scope: { - title: '@' - }, - link: function(scope, element, attrs, tabsCtrl) { - tabsCtrl.addPane(scope); - }, - templateUrl: 'my-pane.html' - }; - }); + this.addPane = function(pane: any) { + if (panes.length === 0) { + $scope.select(pane); + } + panes.push(pane); + }; + }, + templateUrl: 'my-tabs.html' + }; + }) + .directive('myPane', function() { + return { + require: '^myTabs', + restrict: 'E', + transclude: true, + scope: { + title: '@' + }, + link: function(scope: any, element: any, attrs: any, tabsCtrl: any) { + tabsCtrl.addPane(scope); + }, + templateUrl: 'my-pane.html' + }; + }); diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index e447985fb..e66a6c973 100755 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -1031,22 +1031,34 @@ declare module ng { (...args: any[]): IDirective; } + interface IDirectiveLinkFn { + ( + scope?: IScope, + instanceElement?: IAugmentedJQuery, + instanceAttributes?: IAttributes, + controller?: any, + transclude?: ITranscludeFunction + ): void; + } - interface IDirective{ - compile?: - (templateElement: IAugmentedJQuery, - templateAttributes: IAttributes, - transclude: ITranscludeFunction - ) => any; + interface IDirectivePrePost { + pre?: IDirectiveLinkFn; + post?: IDirectiveLinkFn; + } + + interface IDirectiveCompileFn { + ( + templateElement?: IAugmentedJQuery, + templateAttributes?: IAttributes, + transclude?: ITranscludeFunction + ): IDirectivePrePost; + } + + interface IDirective { + compile?: IDirectiveCompileFn; controller?: any; controllerAs?: string; - link?: - (scope: IScope, - instanceElement: IAugmentedJQuery, - instanceAttributes: IAttributes, - controller: any, - transclude: ITranscludeFunction - ) => void; + link?: IDirectiveLinkFn; name?: string; priority?: number; replace?: boolean; From a90450655f562a62fc329378ce323321c80ad6f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20H=C3=A4berle?= Date: Wed, 6 Aug 2014 14:16:51 +0200 Subject: [PATCH 07/30] Added dependency to express --- express-validator/express-validator.d.ts | 318 ++++++++++++----------- 1 file changed, 165 insertions(+), 153 deletions(-) diff --git a/express-validator/express-validator.d.ts b/express-validator/express-validator.d.ts index b18b17e96..5a5df2fa0 100644 --- a/express-validator/express-validator.d.ts +++ b/express-validator/express-validator.d.ts @@ -1,161 +1,173 @@ // Type definitions for express-validator // Project: https://github.com/ctavan/express-validator -// Definitions by: Nathan Ridley +// Definitions by: Nathan Ridley , Jonathan Häberle // Definitions: https://github.com/borisyankov/DefinitelyTyped -declare module ExpressValidator { - export interface ValidationError { - msg: string; - param: string; - } +/// - export interface RequestValidation { - check(field: string, message: string): Validator; - assert(field: string, message: string): Validator; - sanitize(field: string): Sanitizer; - onValidationError(func: (msg: string) => void): void; - } - - export interface Validator { - /** - * Alias for regex() - */ - is(): Validator; - /** - * Alias for notRegex() - */ - not(): Validator; - isEmail(): Validator; - /** - * Accepts http, https, ftp - */ - isUrl(): Validator; - /** - * Combines isIPv4 and isIPv6 - */ - isIP(): Validator; - isIPv4(): Validator; - isIPv6(): Validator; - isAlpha(): Validator; - isAlphanumeric(): Validator; - isNumeric(): Validator; - isHexadecimal(): Validator; - /** - * Accepts valid hexcolors with or without # prefix - */ - isHexColor(): Validator; - /** - * isNumeric accepts zero padded numbers, e.g. '001', isInt doesn't - */ - isInt(): Validator; - isLowercase(): Validator; - isUppercase(): Validator; - isDecimal(): Validator; - /** - * Alias for isDecimal - */ - isFloat(): Validator; - /** - * Check if length is 0 - */ - notNull(): Validator; - isNull(): Validator; - /** - * Not just whitespace (input.trim().length !== 0) - */ - notEmpty(): Validator; - equals(equals: any): Validator; - contains(str: string): Validator; - notContains(str: string): Validator; - /** - * Usage: regex(/[a-z]/i) or regex('[a-z]','i') - */ - regex(pattern: string, modifiers: string): Validator; - notRegex(pattern: string, modifiers: string): Validator; - /** - * max is optional - */ - len(min: number, max?: number): Validator; - /** - * Version can be 3, 4 or 5 or empty, see http://en.wikipedia.org/wiki/Universally_unique_identifier - */ - isUUID(version: number): Validator; - /** - * Alias for isUUID(3) - */ - isUUIDv3(): Validator; - /** - * Alias for isUUID(4) - */ - isUUIDv4(): Validator; - /** - * Alias for isUUID(5) - */ - isUUIDv5(): Validator; - /** - * Uses Date.parse() - regex is probably a better choice - */ - isDate(): Validator; - /** - * Argument is optional and defaults to today. Comparison is non-inclusive - */ - isAfter(date: Date): Validator; - /** - * Argument is optional and defaults to today. Comparison is non-inclusive - */ - isBefore(date: Date): Validator; - isIn(options: string): Validator; - isIn(options: string[]): Validator; - notIn(options: string): Validator; - notIn(options: string[]): Validator; - max(val: string): Validator; - min(val: string): Validator; - /** - * Will work against Visa, MasterCard, American Express, Discover, Diners Club, and JCB card numbering formats - */ - isCreditCard(): Validator; - } - - interface Sanitizer { - /** - * Trim optional `chars`, default is to trim whitespace (\r\n\t ) - */ - trim(...chars: string[]): Sanitizer; - ltrim(...chars: string[]): Sanitizer; - rtrim(...chars: string[]): Sanitizer; - ifNull(replace: any): Sanitizer; - toFloat(): Sanitizer; - toInt(): Sanitizer; - /** - * True unless str = '0', 'false', or str.length == 0 - */ - toBoolean(): Sanitizer; - /** - * False unless str = '1' or 'true' - */ - toBooleanStrict(): Sanitizer; - /** - * Decode HTML entities - */ - entityDecode(): Sanitizer; - entityEncode(): Sanitizer; - /** - * Escape &, <, >, and " - */ - escape(): Sanitizer; - /** - * Remove common XSS attack vectors from user-supplied HTML - */ - xss(): Sanitizer; - /** - * Remove common XSS attack vectors from images - */ - xss(fromImages: boolean): Sanitizer; - } -} - -declare function ExpressValidator(): void; declare module "express-validator" { - export = ExpressValidator; + import express = require('express'); + + module ExpressValidator { + + export interface ValidationError { + msg: string; + param: string; + } + + export interface RequestValidation { + check(field:string, message:string): Validator; + assert(field:string, message:string): Validator; + sanitize(field:string): Sanitizer; + onValidationError(func:(msg:string) => void): void; + validationErrors() : any; + } + + export interface Validator { + /** + * Alias for regex() + */ + is(): Validator; + /** + * Alias for notRegex() + */ + not(): Validator; + isEmail(): Validator; + /** + * Accepts http, https, ftp + */ + isUrl(): Validator; + /** + * Combines isIPv4 and isIPv6 + */ + isIP(): Validator; + isIPv4(): Validator; + isIPv6(): Validator; + isAlpha(): Validator; + isAlphanumeric(): Validator; + isNumeric(): Validator; + isHexadecimal(): Validator; + /** + * Accepts valid hexcolors with or without # prefix + */ + isHexColor(): Validator; + /** + * isNumeric accepts zero padded numbers, e.g. '001', isInt doesn't + */ + isInt(): Validator; + isLowercase(): Validator; + isUppercase(): Validator; + isDecimal(): Validator; + /** + * Alias for isDecimal + */ + isFloat(): Validator; + /** + * Check if length is 0 + */ + notNull(): Validator; + isNull(): Validator; + /** + * Not just whitespace (input.trim().length !== 0) + */ + notEmpty(): Validator; + equals(equals:any): Validator; + contains(str:string): Validator; + notContains(str:string): Validator; + /** + * Usage: regex(/[a-z]/i) or regex('[a-z]','i') + */ + regex(pattern:string, modifiers:string): Validator; + notRegex(pattern:string, modifiers:string): Validator; + /** + * max is optional + */ + len(min:number, max?:number): Validator; + /** + * Version can be 3, 4 or 5 or empty, see http://en.wikipedia.org/wiki/Universally_unique_identifier + */ + isUUID(version:number): Validator; + /** + * Alias for isUUID(3) + */ + isUUIDv3(): Validator; + /** + * Alias for isUUID(4) + */ + isUUIDv4(): Validator; + /** + * Alias for isUUID(5) + */ + isUUIDv5(): Validator; + /** + * Uses Date.parse() - regex is probably a better choice + */ + isDate(): Validator; + /** + * Argument is optional and defaults to today. Comparison is non-inclusive + */ + isAfter(date:Date): Validator; + /** + * Argument is optional and defaults to today. Comparison is non-inclusive + */ + isBefore(date:Date): Validator; + isIn(options:string): Validator; + isIn(options:string[]): Validator; + notIn(options:string): Validator; + notIn(options:string[]): Validator; + max(val:string): Validator; + min(val:string): Validator; + /** + * Will work against Visa, MasterCard, American Express, Discover, Diners Club, and JCB card numbering formats + */ + isCreditCard(): Validator; + } + + interface Sanitizer { + /** + * Trim optional `chars`, default is to trim whitespace (\r\n\t ) + */ + trim(...chars:string[]): Sanitizer; + ltrim(...chars:string[]): Sanitizer; + rtrim(...chars:string[]): Sanitizer; + ifNull(replace:any): Sanitizer; + toFloat(): Sanitizer; + toInt(): Sanitizer; + /** + * True unless str = '0', 'false', or str.length == 0 + */ + toBoolean(): Sanitizer; + /** + * False unless str = '1' or 'true' + */ + toBooleanStrict(): Sanitizer; + /** + * Decode HTML entities + */ + entityDecode(): Sanitizer; + entityEncode(): Sanitizer; + /** + * Escape &, <, >, and " + */ + escape(): Sanitizer; + /** + * Remove common XSS attack vectors from user-supplied HTML + */ + xss(): Sanitizer; + /** + * Remove common XSS attack vectors from images + */ + xss(fromImages:boolean): Sanitizer; + } + } + + /** + * + * @middlewareOptions see: https://github.com/ctavan/express-validator#middleware-options + */ + function ExpressValidator(middlewareOptions?:any):express.RequestHandler; + + + export = ExpressValidator; } From 8badcfa1b3483d78cffe8740ddf974677a94b7e4 Mon Sep 17 00:00:00 2001 From: James Roland Cabresos Date: Wed, 6 Aug 2014 21:33:04 +0800 Subject: [PATCH 08/30] merge new contributors --- CONTRIBUTORS.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 330bda381..1b2eda33d 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -125,11 +125,8 @@ All definitions files include a header with the author and editors, so at some p * [highlight.js](https://github.com/isagalaev/highlight.js) (by [Niklas Mollenhauer](https://github.com/nikeee)) * [History.js](https://github.com/browserstate/history.js) (by [Boris Yankov](https://github.com/borisyankov)) * [Html2Canvas.js](https://github.com/niklasvh/html2canvas/) (by [Richard Hepburn](https://github.com/rwhepburn)) -<<<<<<< HEAD * [htmlparser2](https://github.com/fb55/htmlparser2/) (by [James Roland Cabresos](https://github.com/staticfunction)) -======= * [http-string-parser](https://github.com/apiaryio/http-string-parser) (by [MIZUNE Pine](https://github.com/pine613)) ->>>>>>> upstream/master * [Humane.js](http://wavded.github.com/humane-js/) (by [John Vrbanac](https://github.com/jmvrbanac)) * [i18next](http://i18next.com/) (by [Maarten Docter](https://github.com/mdocter)) * [iCheck](http://damirfoy.com/iCheck/) (by [Dániel Tar](https://github.com/qcz)) From 95434e76f1875ef0be89d27e775afef70deaa07c Mon Sep 17 00:00:00 2001 From: Benjamin Cosman Date: Wed, 6 Aug 2014 15:33:20 -0700 Subject: [PATCH 09/30] d3: Typed Scale interface to remove duplicate code --- d3/d3.d.ts | 199 ++++++++--------------------------------------------- 1 file changed, 29 insertions(+), 170 deletions(-) diff --git a/d3/d3.d.ts b/d3/d3.d.ts index 8f66f47a6..619d2bb36 100755 --- a/d3/d3.d.ts +++ b/d3/d3.d.ts @@ -1648,13 +1648,13 @@ declare module D3 { /** * Gets the x-scale associated with the brush */ - (): D3.Scale.Scale; + (): D3.Scale.UntypedScale; /** * Sets the x-scale associated with the brush * * @param accessor The new Scale */ - (scale: D3.Scale.Scale): Brush; + (scale: D3.Scale.UntypedScale): Brush; }; /** * Gets or sets the x-scale associated with the brush @@ -1663,13 +1663,13 @@ declare module D3 { /** * Gets the x-scale associated with the brush */ - (): D3.Scale.Scale; + (): D3.Scale.UntypedScale; /** * Sets the x-scale associated with the brush * * @param accessor The new Scale */ - (scale: D3.Scale.Scale): Brush; + (scale: D3.Scale.UntypedScale): Brush; }; /** * Gets or sets the current brush extent @@ -2518,21 +2518,23 @@ declare module D3 { threshold(): ThresholdScale; } - export interface Scale { + export interface Scale { (value: any): any; domain: { - (values: any[]): Scale; + (values: any[]): S; (): any[]; }; range: { - (values: any[]): Scale; + (values: any[]): S; (): any[]; }; invertExtent?(y: any): any[]; - copy(): Scale; + copy(): S; } - export interface QuantitativeScale extends Scale { + export interface UntypedScale extends Scale { } + + export interface QuantitativeScale extends Scale { /** * Get the range value corresponding to a given domain value. * @@ -2546,47 +2548,17 @@ declare module D3 { */ invert(value: number): number; /** - * Get or set the scale's input domain. - */ - domain: { - /** - * Set the scale's input domain. - * - * @param value The input domain - */ - (values: any[]): QuantitativeScale; - /** - * Get the scale's input domain. - */ - (): any[]; - }; - /** - * get or set the scale's output range. - */ - range: { - /** - * Set the scale's output range. - * - * @param value The output range. - */ - (values: any[]): QuantitativeScale; - /** - * Get the scale's output range. - */ - (): any[]; - }; - /** * Set the scale's output range, and enable rounding. * * @param value The output range. */ - rangeRound: (values: any[]) => QuantitativeScale; + rangeRound: (values: any[]) => S; /** * get or set the scale's output interpolator. */ interpolate: { (): D3.Transition.Interpolate; - (factory: D3.Transition.Interpolate): QuantitativeScale; + (factory: D3.Transition.Interpolate): S; }; /** * enable or disable clamping of the output range. @@ -2595,14 +2567,14 @@ declare module D3 { */ clamp: { (): boolean; - (clamp: boolean): QuantitativeScale; + (clamp: boolean): S; } /** * extend the scale domain to nice round numbers. * * @param count Optional number of ticks to exactly fit the domain */ - nice(count?: number): QuantitativeScale; + nice(count?: number): S; /** * get representative values from the input domain. * @@ -2615,22 +2587,11 @@ declare module D3 { * @param count Aproximate representative values to return */ tickFormat(count: number, format?: string): (n: number) => string; - /** - * create a new scale from an existing scale.. - */ - copy(): QuantitativeScale; } - export interface LinearScale extends QuantitativeScale { - /** - * Get the range value corresponding to a given domain value. - * - * @param value Domain Value - */ - (value: number): number; - } + export interface LinearScale extends QuantitativeScale { } - export interface IdentityScale extends Scale { + export interface IdentityScale extends Scale { /** * Get the range value corresponding to a given domain value. * @@ -2657,132 +2618,31 @@ declare module D3 { tickFormat(count: number): (n: number) => string; } - export interface SqrtScale extends QuantitativeScale { - /** - * Get the range value corresponding to a given domain value. - * - * @param value Domain Value - */ - (value: number): number; - } + export interface SqrtScale extends QuantitativeScale { } - export interface PowScale extends QuantitativeScale { - /** - * Get the range value corresponding to a given domain value. - * - * @param value Domain Value - */ - (value: number): number; - } + export interface PowScale extends QuantitativeScale { } - export interface LogScale extends QuantitativeScale { - /** - * Get the range value corresponding to a given domain value. - * - * @param value Domain Value - */ - (value: number): number; - } + export interface LogScale extends QuantitativeScale { } - export interface OrdinalScale extends Scale { - /** - * Get the range value corresponding to a given domain value. - * - * @param value Domain Value - */ - (value: any): any; - /** - * Get or set the scale's input domain. - */ - domain: { - /** - * Set the scale's input domain. - * - * @param value The input domain - */ - (values: any[]): OrdinalScale; - /** - * Get the scale's input domain. - */ - (): any[]; - }; - /** - * get or set the scale's output range. - */ - range: { - /** - * Set the scale's output range. - * - * @param value The output range. - */ - (values: any[]): OrdinalScale; - /** - * Get the scale's output range. - */ - (): any[]; - }; + export interface OrdinalScale extends Scale { rangePoints(interval: any[], padding?: number): OrdinalScale; rangeBands(interval: any[], padding?: number, outerPadding?: number): OrdinalScale; rangeRoundBands(interval: any[], padding?: number, outerPadding?: number): OrdinalScale; rangeBand(): number; rangeExtent(): any[]; - /** - * create a new scale from an existing scale.. - */ - copy(): OrdinalScale; } - export interface QuantizeScale extends Scale { - (value: any): any; - domain: { - (values: number[]): QuantizeScale; - (): any[]; - }; - range: { - (values: any[]): QuantizeScale; - (): any[]; - }; - copy(): QuantizeScale; - } + export interface QuantizeScale extends Scale { } - export interface ThresholdScale extends Scale { - (value: any): any; - domain: { - (values: number[]): ThresholdScale; - (): any[]; - }; - range: { - (values: any[]): ThresholdScale; - (): any[]; - }; - copy(): ThresholdScale; - } + export interface ThresholdScale extends Scale { } - export interface QuantileScale extends Scale { - (value: any): any; - domain: { - (values: number[]): QuantileScale; - (): any[]; - }; - range: { - (values: any[]): QuantileScale; - (): any[]; - }; + export interface QuantileScale extends Scale { quantiles(): any[]; - copy(): QuantileScale; } - export interface TimeScale extends Scale { + export interface TimeScale extends Scale { (value: Date): number; invert(value: number): Date; - domain: { - (values: any[]): TimeScale; - (): any[]; - }; - range: { - (values: any[]): TimeScale; - (): any[]; - }; rangeRound: (values: any[]) => TimeScale; interpolate: { (): D3.Transition.Interpolate; @@ -2794,7 +2654,6 @@ declare module D3 { (range: D3.Time.Range, count: number): any[]; }; tickFormat(count: number): (n: number) => string; - copy(): TimeScale; nice(count?: number): TimeScale; } } @@ -2883,13 +2742,13 @@ declare module D3 { /** * Get the X-Scale */ - (): D3.Scale.Scale; + (): D3.Scale.UntypedScale; /** * Set the X-Scale to be adjusted * * @param x The X Scale */ - (x: D3.Scale.Scale): Zoom; + (x: D3.Scale.UntypedScale): Zoom; }; @@ -2900,13 +2759,13 @@ declare module D3 { /** * Get the Y-Scale */ - (): D3.Scale.Scale; + (): D3.Scale.UntypedScale; /** * Set the Y-Scale to be adjusted * * @param y The Y Scale */ - (y: D3.Scale.Scale): Zoom; + (y: D3.Scale.UntypedScale): Zoom; }; } From 5f62479f18b6b2d80e8e213d5afca562a64d735f Mon Sep 17 00:00:00 2001 From: James Roland Cabresos Date: Thu, 7 Aug 2014 21:10:37 +0800 Subject: [PATCH 10/30] Rename htmlparser2tests.ts to htmlparser2-tests.ts --- htmlparser2/{htmlparser2tests.ts => htmlparser2-tests.ts} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename htmlparser2/{htmlparser2tests.ts => htmlparser2-tests.ts} (97%) diff --git a/htmlparser2/htmlparser2tests.ts b/htmlparser2/htmlparser2-tests.ts similarity index 97% rename from htmlparser2/htmlparser2tests.ts rename to htmlparser2/htmlparser2-tests.ts index 7ff887e65..c002da0e2 100644 --- a/htmlparser2/htmlparser2tests.ts +++ b/htmlparser2/htmlparser2-tests.ts @@ -21,4 +21,4 @@ var parser = new htmlparser.Parser({ }); parser.write("Xyz "); -parser.end(); \ No newline at end of file +parser.end(); From fcfe9fee87ea637598c57fe3ed07bb7b33a70359 Mon Sep 17 00:00:00 2001 From: Steven Date: Thu, 7 Aug 2014 18:24:19 -0700 Subject: [PATCH 11/30] Color.brighter has an optional number parameter --- d3/d3.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/d3/d3.d.ts b/d3/d3.d.ts index 8f66f47a6..4b7f91ad7 100755 --- a/d3/d3.d.ts +++ b/d3/d3.d.ts @@ -1492,7 +1492,7 @@ declare module D3 { /** * increase lightness by some exponential factor (gamma) */ - brighter(k: number): Color; + brighter(k?: number): Color; /** * decrease lightness by some exponential factor (gamma) */ From cc05933bbc0b8a7994ff743a33805218226ed5bc Mon Sep 17 00:00:00 2001 From: James Roland Cabresos Date: Fri, 8 Aug 2014 10:22:24 +0800 Subject: [PATCH 12/30] fix htmlparser tests --- htmlparser2/htmlparser2-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htmlparser2/htmlparser2-tests.ts b/htmlparser2/htmlparser2-tests.ts index c002da0e2..53f6ee2aa 100644 --- a/htmlparser2/htmlparser2-tests.ts +++ b/htmlparser2/htmlparser2-tests.ts @@ -6,7 +6,7 @@ import htmlparser = require("htmlparser2"); var parser = new htmlparser.Parser({ onopentag: (name:string, attribs:{[s:string]:string}) => { - if(name === "script" && attribs.type === "text/javascript"){ + if(name === "script" && attribs['type'] === "text/javascript"){ console.log("JS! Hooray!"); } }, From ad0059764af8e64555d9ddecebcbe62c7b1204db Mon Sep 17 00:00:00 2001 From: VILIC VANE Date: Fri, 8 Aug 2014 12:05:20 +0800 Subject: [PATCH 13/30] add Q.delay(ms: number) --- q/Q.d.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/q/Q.d.ts b/q/Q.d.ts index 617bf0140..90ec8b461 100644 --- a/q/Q.d.ts +++ b/q/Q.d.ts @@ -294,7 +294,10 @@ declare module Q { * Returns a promise that will have the same result as promise, but will only be fulfilled or rejected after at least ms milliseconds have passed. */ export function delay(value: T, ms: number): Promise; - + /** + * Returns a promise that will be fulfilled with undefined after at least ms milliseconds have passed. + */ + export function delay(ms: number): Promise ; /** * Returns whether a given promise is in the fulfilled state. When the static version is used on non-promises, the result is always true. */ From fa83d0d39c561d98454f72ffc0e32a741a2c7994 Mon Sep 17 00:00:00 2001 From: Benjamin Cosman Date: Thu, 7 Aug 2014 21:50:52 -0700 Subject: [PATCH 14/30] d3: Changed Scale names for consistency --- d3/d3.d.ts | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/d3/d3.d.ts b/d3/d3.d.ts index 619d2bb36..07f071647 100755 --- a/d3/d3.d.ts +++ b/d3/d3.d.ts @@ -1648,13 +1648,13 @@ declare module D3 { /** * Gets the x-scale associated with the brush */ - (): D3.Scale.UntypedScale; + (): D3.Scale.Scale; /** * Sets the x-scale associated with the brush * * @param accessor The new Scale */ - (scale: D3.Scale.UntypedScale): Brush; + (scale: D3.Scale.Scale): Brush; }; /** * Gets or sets the x-scale associated with the brush @@ -1663,13 +1663,13 @@ declare module D3 { /** * Gets the x-scale associated with the brush */ - (): D3.Scale.UntypedScale; + (): D3.Scale.Scale; /** * Sets the x-scale associated with the brush * * @param accessor The new Scale */ - (scale: D3.Scale.UntypedScale): Brush; + (scale: D3.Scale.Scale): Brush; }; /** * Gets or sets the current brush extent @@ -2518,7 +2518,7 @@ declare module D3 { threshold(): ThresholdScale; } - export interface Scale { + export interface GenericScale { (value: any): any; domain: { (values: any[]): S; @@ -2532,9 +2532,9 @@ declare module D3 { copy(): S; } - export interface UntypedScale extends Scale { } + export interface Scale extends GenericScale { } - export interface QuantitativeScale extends Scale { + export interface GenericQuantitativeScale extends GenericScale { /** * Get the range value corresponding to a given domain value. * @@ -2589,9 +2589,11 @@ declare module D3 { tickFormat(count: number, format?: string): (n: number) => string; } - export interface LinearScale extends QuantitativeScale { } + export interface QuantitativeScale extends GenericQuantitativeScale { } - export interface IdentityScale extends Scale { + export interface LinearScale extends GenericQuantitativeScale { } + + export interface IdentityScale extends GenericScale { /** * Get the range value corresponding to a given domain value. * @@ -2618,13 +2620,13 @@ declare module D3 { tickFormat(count: number): (n: number) => string; } - export interface SqrtScale extends QuantitativeScale { } + export interface SqrtScale extends GenericQuantitativeScale { } - export interface PowScale extends QuantitativeScale { } + export interface PowScale extends GenericQuantitativeScale { } - export interface LogScale extends QuantitativeScale { } + export interface LogScale extends GenericQuantitativeScale { } - export interface OrdinalScale extends Scale { + export interface OrdinalScale extends GenericScale { rangePoints(interval: any[], padding?: number): OrdinalScale; rangeBands(interval: any[], padding?: number, outerPadding?: number): OrdinalScale; rangeRoundBands(interval: any[], padding?: number, outerPadding?: number): OrdinalScale; @@ -2632,15 +2634,15 @@ declare module D3 { rangeExtent(): any[]; } - export interface QuantizeScale extends Scale { } + export interface QuantizeScale extends GenericScale { } - export interface ThresholdScale extends Scale { } + export interface ThresholdScale extends GenericScale { } - export interface QuantileScale extends Scale { + export interface QuantileScale extends GenericScale { quantiles(): any[]; } - export interface TimeScale extends Scale { + export interface TimeScale extends GenericScale { (value: Date): number; invert(value: number): Date; rangeRound: (values: any[]) => TimeScale; @@ -2742,13 +2744,13 @@ declare module D3 { /** * Get the X-Scale */ - (): D3.Scale.UntypedScale; + (): D3.Scale.Scale; /** * Set the X-Scale to be adjusted * * @param x The X Scale */ - (x: D3.Scale.UntypedScale): Zoom; + (x: D3.Scale.Scale): Zoom; }; @@ -2759,13 +2761,13 @@ declare module D3 { /** * Get the Y-Scale */ - (): D3.Scale.UntypedScale; + (): D3.Scale.Scale; /** * Set the Y-Scale to be adjusted * * @param y The Y Scale */ - (y: D3.Scale.UntypedScale): Zoom; + (y: D3.Scale.Scale): Zoom; }; } From 2f1b69b353b7feea498ce886abf059018131ddd3 Mon Sep 17 00:00:00 2001 From: Daniel Mane Date: Thu, 7 Aug 2014 22:36:44 -0700 Subject: [PATCH 15/30] Add missing properties to definitions for D3.set and D3.map. Paramaterize the function type for Set.add --- d3/d3.d.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/d3/d3.d.ts b/d3/d3.d.ts index 8f66f47a6..e6f26cbd5 100755 --- a/d3/d3.d.ts +++ b/d3/d3.d.ts @@ -848,14 +848,18 @@ declare module D3 { values(): Array; entries(): Array; forEach(func: (key: string, value: any) => void ): void; + empty(): boolean; + size(): number; } - export interface Set{ + export interface Set { has(value: any): boolean; - add(value: any): any; + add(value: T): T; remove(value: any): boolean; values(): Array; forEach(func: (value: any) => void ): void; + empty(): boolean; + size(): number; } export interface Random { From 3994e6d6a4da8d0b5c13d5f84653c0e28c4c12dd Mon Sep 17 00:00:00 2001 From: Eraknelo Date: Fri, 8 Aug 2014 15:45:39 +0200 Subject: [PATCH 16/30] Capitalization error http://msdn.microsoft.com/en-us/library/office/jj245318(v=office.15).aspx --- sharepoint/SharePoint.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sharepoint/SharePoint.d.ts b/sharepoint/SharePoint.d.ts index 1f7a2feaf..0be396fe6 100644 --- a/sharepoint/SharePoint.d.ts +++ b/sharepoint/SharePoint.d.ts @@ -4573,7 +4573,7 @@ declare module SP { get_id(): number; get_information(): SP.TimeZoneInformation; localTimeToUTC(date: Date): SP.DateTimeResult; - uTCToLocalTime(date: Date): SP.DateTimeResult; + utcToLocalTime(date: Date): SP.DateTimeResult; } export class TimeZoneCollection extends SP.ClientObjectCollection { itemAt(index: number): SP.TimeZone; From 82447ac01078f1f5d9b25ea27712c3317f94adde Mon Sep 17 00:00:00 2001 From: Paulo Cesar Date: Fri, 8 Aug 2014 12:24:43 -0300 Subject: [PATCH 17/30] squash! fix tabs directive interface definition and tests --- angularjs/angular-tests.ts | 32 +++++++++++++++++--------------- angularjs/angular.d.ts | 19 ++++++++++--------- 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/angularjs/angular-tests.ts b/angularjs/angular-tests.ts index 9c1cc0ab4..220a63dec 100644 --- a/angularjs/angular-tests.ts +++ b/angularjs/angular-tests.ts @@ -285,15 +285,17 @@ class SampleDirective implements ng.IDirective { public restrict = 'A'; name = 'doh'; - compile(templateElement: any) { - return this.link; + compile(templateElement: ng.IAugmentedJQuery) { + return { + post: this.link + }; } static instance():ng.IDirective { return new SampleDirective(); } - link(scope: any) { + link(scope: ng.IScope) { } } @@ -301,7 +303,7 @@ class SampleDirective implements ng.IDirective { class SampleDirective2 implements ng.IDirective { public restrict = 'EAC'; - compile(templateElement: any) { + compile(templateElement: ng.IAugmentedJQuery) { return { pre: this.link }; @@ -311,7 +313,7 @@ class SampleDirective2 implements ng.IDirective { return new SampleDirective2(); } - link(scope: any) { + link(scope: ng.IScope) { } } @@ -413,10 +415,10 @@ angular.module('docsTimeDirective', []) .controller('Controller', ['$scope', function($scope: any) { $scope.format = 'M/d/yy h:mm:ss a'; }]) - .directive('myCurrentTime', ['$interval', 'dateFilter', function($interval: any, dateFilter: any): ng.IDirective { + .directive('myCurrentTime', ['$interval', 'dateFilter', function($interval: any, dateFilter: any) { return { - link: function(scope: any, element: any, attrs: any) { + link: function(scope: ng.IScope, element: ng.IAugmentedJQuery, attrs:ng.IAttributes) { var format: any, timeoutId: any; @@ -424,7 +426,7 @@ angular.module('docsTimeDirective', []) element.text(dateFilter(new Date(), format)); } - scope.$watch(attrs.myCurrentTime, function (value: any) { + scope.$watch(attrs['myCurrentTime'], function (value: any) { format = value; updateTime(); }); @@ -463,8 +465,8 @@ angular.module('docsTransclusionExample', []) transclude: true, scope: {}, templateUrl: 'my-dialog.html', - link: function (scope: any, element: any) { - scope.name = 'Jeff'; + link: function (scope: ng.IScope, element: ng.IAugmentedJQuery) { + scope['name'] = 'Jeff'; } }; }); @@ -533,10 +535,10 @@ angular.module('docsTabsExample', []) restrict: 'E', transclude: true, scope: {}, - controller: function($scope: any) { - var panes: any = $scope.panes = []; + controller: function($scope: ng.IScope) { + var panes: any = $scope['panes'] = []; - $scope.select = function(pane: any) { + $scope['select'] = function(pane: any) { angular.forEach(panes, function(pane: any) { pane.selected = false; }); @@ -545,7 +547,7 @@ angular.module('docsTabsExample', []) this.addPane = function(pane: any) { if (panes.length === 0) { - $scope.select(pane); + $scope['select'](pane); } panes.push(pane); }; @@ -561,7 +563,7 @@ angular.module('docsTabsExample', []) scope: { title: '@' }, - link: function(scope: any, element: any, attrs: any, tabsCtrl: any) { + link: function(scope: ng.IScope, element: ng.IAugmentedJQuery, attrs: ng.IAttributes, tabsCtrl: any) { tabsCtrl.addPane(scope); }, templateUrl: 'my-pane.html' diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index 83dcc151f..282463bcb 100755 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -316,6 +316,7 @@ declare module ng { // see http://docs.angularjs.org/api/ng.$rootScope.Scope /////////////////////////////////////////////////////////////////////////// interface IScope { + [index: string]: any; $apply(): any; $apply(exp: string): any; $apply(exp: (scope: IScope) => any): any; @@ -1033,11 +1034,11 @@ declare module ng { interface IDirectiveLinkFn { ( - scope?: IScope, - instanceElement?: IAugmentedJQuery, - instanceAttributes?: IAttributes, - controller?: any, - transclude?: ITranscludeFunction + scope: IScope, + instanceElement: IAugmentedJQuery, + instanceAttributes: IAttributes, + controller: any, + transclude: ITranscludeFunction ): void; } @@ -1048,13 +1049,13 @@ declare module ng { interface IDirectiveCompileFn { ( - templateElement?: IAugmentedJQuery, - templateAttributes?: IAttributes, - transclude?: ITranscludeFunction + templateElement: IAugmentedJQuery, + templateAttributes: IAttributes, + transclude: ITranscludeFunction ): IDirectivePrePost; } - interface IDirective{ + interface IDirective { compile?: IDirectiveCompileFn; controller?: any; controllerAs?: string; From 3878a37dfad2c3ad01d6be3988aa7d5460519b58 Mon Sep 17 00:00:00 2001 From: Pedro Casaubon Date: Fri, 8 Aug 2014 19:10:43 +0200 Subject: [PATCH 18/30] Added node-webkit definitions --- node-webkit/node-webkit-tests.ts | 203 ++++++++++++++++++++++++++++ node-webkit/node-webkit.d.ts | 221 +++++++++++++++++++++++++++++++ 2 files changed, 424 insertions(+) create mode 100644 node-webkit/node-webkit-tests.ts create mode 100644 node-webkit/node-webkit.d.ts diff --git a/node-webkit/node-webkit-tests.ts b/node-webkit/node-webkit-tests.ts new file mode 100644 index 000000000..da10f2901 --- /dev/null +++ b/node-webkit/node-webkit-tests.ts @@ -0,0 +1,203 @@ +/// +/// +// Load native UI library +var gui: typeof nw.gui; + + +/* WINDOW */ + + // Get the current window + var win = gui.Window.get(); + + // Listen to the minimize event + win.on('minimize', function() { + console.log('Window is minimized'); + }); + + // Minimize the window + win.minimize(); + + // Unlisten the minimize event + win.removeAllListeners('minimize'); + + // Create a new window and get it + var new_win = gui.Window.get( + window.open('https://github.com') + ); + + // And listen to new window's focus event + new_win.on('focus', function() { + console.log('New window is focused'); + }); + + + // Get the current window + var win = gui.Window.get(); + + // Create a new window and get it + var new_win = gui.Window.get( + window.open('https://github.com') + ); + + // png as base64string + win.capturePage(function(base64string:string){ + // do something with the base64string + }, { format : 'png', datatype : 'raw'} ); + + // png as node buffer + win.capturePage(function(buffer:Buffer){ + // do something with the buffer + }, { format : 'png', datatype : 'buffer'} ); + + + // Open a new window. + var win = gui.Window.get( + window.open('popup.html') + ); + + // Release the 'win' object here after the new window is closed. + win.on('closed', function() { + win = null; + }); + + // Listen to main window's close event + gui.Window.get().on('close', function() { + // Hide the window to give user the feeling of closing immediately + this.hide(); + + // If the new window is still open then close it. + if (win != null) + win.close(true); + + // After closing the new window, close the main window. + this.close(true); + }); + + +/* MENU */ + + // Create an empty menu + var menu = new gui.Menu(); + + // Add some items + menu.append(new gui.MenuItem({ label: 'Item A' })); + menu.append(new gui.MenuItem({ label: 'Item B' })); + menu.append(new gui.MenuItem({ type: 'separator' })); + menu.append(new gui.MenuItem({ label: 'Item C' })); + + // Remove one item + menu.removeAt(1); + + // Popup as context menu + menu.popup(10, 10); + + // Iterate menu's items + for (var i = 0; i < menu.items.length; ++i) { + console.log(menu.items[i]); + } + + + var win = gui.Window.get(); + var nativeMenuBar = new gui.Menu({ type: "menubar" }); + nativeMenuBar.createMacBuiltin("My App"); + win.menu = nativeMenuBar; + + nativeMenuBar.createMacBuiltin("My App", { + hideEdit: true, + hideWindow: true + }); + +/* MENU ITEM */ + + var itemc:nw.gui.MenuItem; + + // Create a separator + itemc = new gui.MenuItem({ type: 'separator' }); + + // Create a normal item with label and icon + itemc = new gui.MenuItem({ + type: "normal", + label: "I'm a menu item", + icon: "img/icon.png" + }); + + // Or you can omit the 'type' field for normal items + itemc = new gui.MenuItem({ label: 'Simple item' }); + + // Bind a callback to item + itemc = new gui.MenuItem({ + label: "Click me", + click: function() { + console.log("I'm clicked"); + }, + key: "s", + modifiers: "ctrl-alt", + }); + + // You can have submenu! + var submenu = new gui.Menu(); + submenu.append(new gui.MenuItem({ label: 'Item 1' })); + submenu.append(new gui.MenuItem({ label: 'Item 2' })); + submenu.append(new gui.MenuItem({ label: 'Item 3' })); + itemc.submenu = submenu; + + // And everything can be changed at runtime + itemc.label = 'New label'; + itemc.click = function() { console.log('New click callback'); }; + + +/* APP */ + + // Print arguments + console.log(gui.App.argv); + + // Quit current app + gui.App.quit(); + + // Get the name field in manifest + gui.App.manifest.name + + gui.App.addOriginAccessWhitelistEntry('http://github.com/', 'app', 'myapp', true); + + +/* CLIPBOARD */ + + // We can not create a clipboard, we have to receive the system clipboard + var clipboard = gui.Clipboard.get(); + + // Read from clipboard + var text = clipboard.get('text'); + console.log(text); + + // Or write something + clipboard.set('I love node-webkit :)', 'text'); + + // And clear it! + clipboard.clear(); + + +/* TRAY */ + + // Create a tray icon + var tray = new gui.Tray({ title: 'Tray', icon: 'img/icon.png' }); + + // Give it a menu + var menu = new gui.Menu(); + menu.append(new gui.MenuItem({ type: 'checkbox', label: 'box1' })); + tray.menu = menu; + + // Remove the tray + tray.remove(); + tray = null; + + +/* SHELL */ + + // Open URL with default browser. + gui.Shell.openExternal('https://github.com/rogerwang/node-webkit'); + + // Open a text file with default text editor. + gui.Shell.openItem('test.txt'); + + // Open a file in file explorer. + gui.Shell.showItemInFolder('test.txt'); \ No newline at end of file diff --git a/node-webkit/node-webkit.d.ts b/node-webkit/node-webkit.d.ts new file mode 100644 index 000000000..92afbff2d --- /dev/null +++ b/node-webkit/node-webkit.d.ts @@ -0,0 +1,221 @@ +// Type definitions for node-webkit +// Project: https://github.com/rogerwang/node-webkit +// Definitions by: Pedro Casaubon +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module nw.gui { + + interface IEventEmitter { + addListener(event: string, listener: Function): EventEmitter; + on(event: string, listener: Function): EventEmitter; + once(event: string, listener: Function): EventEmitter; + removeListener(event: string, listener: Function): EventEmitter; + removeAllListeners(event?: string): EventEmitter; + setMaxListeners(n: number): void; + listeners(event: string): Function[]; + emit(event: string, ...args: any[]): boolean; + } + + class EventEmitter implements IEventEmitter { + addListener(event: string, listener: Function): EventEmitter; + on(event: string, listener: Function): EventEmitter; + once(event: string, listener: Function): EventEmitter; + removeListener(event: string, listener: Function): EventEmitter; + removeAllListeners(event?: string): EventEmitter; + setMaxListeners(n: number): void; + listeners(event: string): Function[]; + emit(event: string, ...args: any[]): boolean; + } + + export interface MenuConfig { + type?: string; + } + + export interface HideMenusOptions { + hideEdit: boolean; + hideWindow: boolean; + } + + export interface MenuItemConfig { + label?: string; + click?: Function; + type?: string; + submenu?: Menu; + icon?: string; + tooltip?: string; + checked?: boolean; + enabled?: boolean; + key?: string; + modifiers?: string; + } + + export class MenuItem extends EventEmitter implements MenuItemConfig { + constructor(config: MenuItemConfig); + label: string; + click: Function; + type: string; + submenu: Menu; + icon: string; + tooltip: string; + checked: boolean; + enabled: boolean; + key: string; + modifiers: string; + } + + export class Menu { + constructor(config?: MenuConfig); + items: MenuItem[]; + append(item: MenuItem): void; + remove(item: MenuItem): void; + insert(item: MenuItem, atPosition: number): void; + removeAt(index: number): void; + popup(x: number, y: number): void; + // since v0.10.0-rc1 + createMacBuiltin(appname: string, options?: HideMenusOptions): void; + + } + + export interface ShortcutOption { + key: string; + active: Function; + failed: Function; + } + + export class Shortcut extends EventEmitter { + constructor(option: ShortcutOption); + key: string; + active: Function; + failed: Function; + } + + export interface WindowManifestOptions { + + title?: string; + icon?: string; + toolbar?: boolean; + frame?: boolean; + width?: number; + height?: number; + position?: string; + min_width?: number; + min_height?: number; + max_width?: number; + max_height?: number; + } + + export class Window extends EventEmitter { + static get(windowObject?: any): Window; + static open(url: string, options?: WindowManifestOptions): Window; + x: number; + y: number; + width: number; + height: number; + title: string; + menu: Menu; + isFullScreen: boolean; + isKioskMode: boolean; + zoomLevel: number; + moveTo(x: number, y: number): void; + moveBy(x: number, y: number): void; + resizeTo(width: number, height: number): void; + resizeBy(width: number, height: number): void; + focus(): void; + blur(): void; + show(): void; + hide(): void; + close(force?: boolean): void; + reload(): void; + reloadIgnoringCache(): void; + maximize(): void; + unmaximize(): void; + minimize(): void; + restore(): void; + enterFullscreen(): void; + leaveFullscreen(): void; + toggleFullscreen(): void; + enterKioskMode(): void; + leaveKioskMode(): void; + toggleKioskMode(): void; + showDevTools(id?: string, headless?: boolean): void; + showDevTools(id: HTMLIFrameElement, headless?: boolean): void; + closeDevTools(): void; + isDevToolsOpen(): boolean; + setMaximumSize(width: number, height: number): void; + setMinimumSize(width: number, height: number): void; + setResizable(resizable: boolean): void; + setAlwaysOnTop(top: boolean): void; + setPosition(position: string): void; + setShowInTaskbar(show: boolean): void; + requestAttention(attention: boolean): void; + requestAttention(attention: number): void; + capturePage(callback: Function, imageformat?: string): void; + capturePage(callback: Function, config_object: { format: string; datatype: string }): void; + setProgressBar(progress: number): void; + setBadgeLabel(label: string): void; + eval(frame: HTMLIFrameElement, script: string): void; + } + + export interface App { + argv: any; + fullArgv: any; + dataPath: string; + manifest: any; + clearCache(): void; + closeAllWindows(): void; + crashBrowser(): void; + crashRenderer(): void; + getProxyForURL(url: string): void; + quit(): void; + setCrashDumpDir(dir: string): void; + addOriginAccessWhitelistEntry( + sourceOrigin: string + , destinationProtocol: string + , destinationHost: string + , allowDestinationSubdomains: boolean + ): void; + removeOriginAccessWhitelistEntry( + sourceOrigin: string + , destinationProtocol: string + , destinationHost: string + , allowDestinationSubdomains: boolean + ): void; + registerGlobalHotKey(shortcut: Shortcut): void; + unregisterGlobalHotKey(shortcut: Shortcut): void; + } + + export class Clipboard { + static get(): Clipboard; + get(type?: string): string; + set(data: string, type?: string): void; + clear(): void; + } + + export interface TrayOption { + title?: string; + tooltip?: string; + icon?: string; + alticon?: string; + menu?: Menu; + } + + export class Tray implements TrayOption { + constructor(option: TrayOption); + title: string; + tooltip: string; + icon: string; + alticon: string; + menu: Menu; + remove(): void; + } + + interface Shell { + openExternal(uri: string): void; + openItem(file_path: string): void; + showItemInFolder(file_path: string): void; + } + + export var App: App; + export var Shell: Shell; + +} From a2c53774bb554ac7f73ab4ff0212ad1eccef48d3 Mon Sep 17 00:00:00 2001 From: nitram509 Date: Fri, 8 Aug 2014 23:11:14 +0200 Subject: [PATCH 19/30] added missing method 'getBoundingRect()' for fabric.js, which is available since ~1.0.4 --- fabricjs/fabricjs.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/fabricjs/fabricjs.d.ts b/fabricjs/fabricjs.d.ts index eec70c8f6..cfca6c481 100644 --- a/fabricjs/fabricjs.d.ts +++ b/fabricjs/fabricjs.d.ts @@ -335,6 +335,7 @@ declare module fabric { drawBorders(context: CanvasRenderingContext2D): IObject; drawCorners(context: CanvasRenderingContext2D): IObject; get (property: string): any; + getBoundingRect(): {left:number; top:number; width:number; height:number}; getBoundingRectHeight(): number; getBoundingRectWidth(): number; getSvgStyles(): string; From c8706caad0a134f84c889381e990454f7791304f Mon Sep 17 00:00:00 2001 From: Anthony Date: Fri, 8 Aug 2014 19:57:23 -0400 Subject: [PATCH 20/30] New definitions for Jasmine data driven tests --- .../jasmine-data_driven_tests-tests.ts | 54 +++++++++++++++++++ .../jasmine-data_driven_tests.d.ts | 7 +++ 2 files changed, 61 insertions(+) create mode 100644 jasmine-data_driven_tests/jasmine-data_driven_tests-tests.ts create mode 100644 jasmine-data_driven_tests/jasmine-data_driven_tests.d.ts diff --git a/jasmine-data_driven_tests/jasmine-data_driven_tests-tests.ts b/jasmine-data_driven_tests/jasmine-data_driven_tests-tests.ts new file mode 100644 index 000000000..df48df8cf --- /dev/null +++ b/jasmine-data_driven_tests/jasmine-data_driven_tests-tests.ts @@ -0,0 +1,54 @@ +/// +/// + +all("A data driven test is a suite with multiple specs", + ['a', 'b', 'c'], + (value: string) => { + expect(value).not.toBe('d'); + } +); + +all("A data driven test can have many arguments", + [ + [1, 2, 3], + [2, 4, 6] + ], + (a: number, b: number, c: number) => { + expect(c - (a + b)).toBe(0); + } +); + +all("A data driven test can be asynchronous", + [ + [3, 1], + [5, 2] + ], + (a: number, b: number, done: () => void) => { + setTimeout(() => { + expect(a - b > 0).toBe(true); + done(); + }, 50); + } +); + +xall("A data driven test can be pending", + [1, 2, 3], + (value: number) => { + expect(value < 4).toBe(true); + } +); + +describe("A suite", () => { + var a: number; + + beforeEach(() => { + a = 5; + }); + + all("can contain data driven tests", + [1, 2, 3], + (b: number) => { + expect(a - b > 0).toBe(true); + } + ); +}); \ No newline at end of file diff --git a/jasmine-data_driven_tests/jasmine-data_driven_tests.d.ts b/jasmine-data_driven_tests/jasmine-data_driven_tests.d.ts new file mode 100644 index 000000000..c0936872b --- /dev/null +++ b/jasmine-data_driven_tests/jasmine-data_driven_tests.d.ts @@ -0,0 +1,7 @@ +// Type definitions for Jasmine Data Driven Tests +// Project: https://github.com/gburghardt/jasmine-data_driven_tests +// Definitions by: Anthony MacKinnon +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare function all(description: string, dataset: any[], specDefinitions: (...args: any[]) => void): void; +declare function xall(description: string, dataset: any[], specDefinitions: (...args: any[]) => void): void; \ No newline at end of file From 153b4f3fa354d799090212979ae559ec44dd05c4 Mon Sep 17 00:00:00 2001 From: Anthony Date: Sat, 9 Aug 2014 00:15:18 -0400 Subject: [PATCH 21/30] Renamed callback to assertion to be consistent with Jasmine naming --- jasmine-data_driven_tests/jasmine-data_driven_tests.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jasmine-data_driven_tests/jasmine-data_driven_tests.d.ts b/jasmine-data_driven_tests/jasmine-data_driven_tests.d.ts index c0936872b..912720e7f 100644 --- a/jasmine-data_driven_tests/jasmine-data_driven_tests.d.ts +++ b/jasmine-data_driven_tests/jasmine-data_driven_tests.d.ts @@ -3,5 +3,5 @@ // Definitions by: Anthony MacKinnon // Definitions: https://github.com/borisyankov/DefinitelyTyped -declare function all(description: string, dataset: any[], specDefinitions: (...args: any[]) => void): void; -declare function xall(description: string, dataset: any[], specDefinitions: (...args: any[]) => void): void; \ No newline at end of file +declare function all(description: string, dataset: any[], assertion: (...args: any[]) => void): void; +declare function xall(description: string, dataset: any[], assertion: (...args: any[]) => void): void; \ No newline at end of file From 343cca373bca9e0241911b3cace7c4d303e5fd02 Mon Sep 17 00:00:00 2001 From: VILIC VANE Date: Sat, 9 Aug 2014 23:17:03 +0800 Subject: [PATCH 22/30] add definitions for q-retry --- CONTRIBUTORS.md | 1 + q-retry/q-retry-tests.ts | 39 +++++++++++++++++++++++++++++++++++++++ q-retry/q-retry.d.ts | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 q-retry/q-retry-tests.ts create mode 100644 q-retry/q-retry.d.ts diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 1b2eda33d..fceb55e98 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -291,6 +291,7 @@ All definitions files include a header with the author and editors, so at some p * [ProgressJs](http://usablica.github.io/progress.js/) (by [Shunsuke Ohtani](https://github.com/zaneli)) * [Q](https://github.com/kriskowal/q) (by Barrie Nemetchek, Andrew Gaspar) * [Q-io](https://github.com/kriskowal/q-io) (by [Bart van der Schoor](https://github.com/Bartvds)) +* [q-retry](https://github.com/vilic/q-retry) (by [VILIC VANE](https://github.com/vilic)) * [QUnit](http://qunitjs.com/) (by [Diullei Gomes](https://github.com/Diullei)) * [Raven.js](https://github.com/getsentry/raven-js) (by [Santi Albo](https://github.com/santialbo)) * [Recaptcha.js](https://www.google.com/recaptcha) (by [Brent Jenkins](https://github.com/brentj73)) diff --git a/q-retry/q-retry-tests.ts b/q-retry/q-retry-tests.ts new file mode 100644 index 000000000..bf72f8ad7 --- /dev/null +++ b/q-retry/q-retry-tests.ts @@ -0,0 +1,39 @@ +import Q = require('q-retry'); + +Q + .retry(() => { + return ''; + }) + .then(str => { + str.charAt; + return 0; + }) + .retry(num => { + num.toFixed; + }) + .retry(() => { + + }, 5) + .retry(() => { + + }, (reason, retries) => { + retries.toFixed; + }) + .retry(() => { + + }, (reason, retries) => { + retries.toFixed; + }, 10) + .retry(() => { + return ''; + }, (reason, retries) => { + + }, { + limit: 10, + interval: 1000, + maxInterval: 20000, + intervalMultiplier: 1.5 + }) + .then(str => { + str.charAt; + }); \ No newline at end of file diff --git a/q-retry/q-retry.d.ts b/q-retry/q-retry.d.ts new file mode 100644 index 000000000..fe6b42fd8 --- /dev/null +++ b/q-retry/q-retry.d.ts @@ -0,0 +1,39 @@ +// Type definitions for q-retry +// Project: https://github.com/vilic/q-retry +// Definitions by: VILIC VANE +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module Q { + export interface IRetryOptions { + limit?: number; + interval?: number; + maxInterval?: number; + intervalMultiplier?: number; + } + + export function retry(process: () => IPromise, onFail: (reason: any, retries: number) => void, limit: number): Promise; + export function retry(process: () => IPromise, onFail: (reason: any, retries: number) => void, options?: IRetryOptions): Promise; + export function retry(process: () => IPromise, limit: number): Promise; + export function retry(process: () => IPromise, options?: IRetryOptions): Promise; + export function retry(process: () => U, onFail: (reason: any, retries: number) => void, limit: number): Promise; + export function retry(process: () => U, onFail: (reason: any, retries: number) => void, options?: IRetryOptions): Promise; + export function retry(process: () => U, limit: number): Promise; + export function retry(process: () => U, options?: IRetryOptions): Promise; + + interface Promise { + retry(process: (value: T) => IPromise, onFail: (reason: any, retries: number) => void, limit: number): Promise; + retry(process: (value: T) => IPromise, onFail: (reason: any, retries: number) => void, options?: IRetryOptions): Promise; + retry(process: (value: T) => IPromise, limit: number): Promise; + retry(process: (value: T) => IPromise, options?: IRetryOptions): Promise; + retry(process: (value: T) => U, onFail: (reason: any, retries: number) => void, limit: number): Promise; + retry(process: (value: T) => U, onFail: (reason: any, retries: number) => void, options?: IRetryOptions): Promise; + retry(process: (value: T) => U, limit: number): Promise; + retry(process: (value: T) => U, options?: IRetryOptions): Promise; + } +} + +declare module "q-retry" { + export = Q; +} \ No newline at end of file From f402bb57bdc4cba9132a1498e7dc566b68629b98 Mon Sep 17 00:00:00 2001 From: VILIC VANE Date: Sun, 10 Aug 2014 00:55:22 +0800 Subject: [PATCH 23/30] add definitions for promise-pool --- CONTRIBUTORS.md | 1 + promise-pool/promise-pool-tests.ts | 47 +++++++++++ promise-pool/promise-pool.d.ts | 124 +++++++++++++++++++++++++++++ 3 files changed, 172 insertions(+) create mode 100644 promise-pool/promise-pool-tests.ts create mode 100644 promise-pool/promise-pool.d.ts diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index fceb55e98..960b5dff2 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -289,6 +289,7 @@ All definitions files include a header with the author and editors, so at some p * [PouchDB](http://pouchdb.com) (by [Bill Sears](https://github.com/MrBigDog2U/)) * [PreloadJS](http://www.createjs.com/#!/PreloadJS) (by [Pedro Ferreira](https://bitbucket.org/drk4)) * [ProgressJs](http://usablica.github.io/progress.js/) (by [Shunsuke Ohtani](https://github.com/zaneli)) +* [promise-pool](https://github.com/vilic/promise-pool) (by [VILIC VANE](https://github.com/vilic)) * [Q](https://github.com/kriskowal/q) (by Barrie Nemetchek, Andrew Gaspar) * [Q-io](https://github.com/kriskowal/q-io) (by [Bart van der Schoor](https://github.com/Bartvds)) * [q-retry](https://github.com/vilic/q-retry) (by [VILIC VANE](https://github.com/vilic)) diff --git a/promise-pool/promise-pool-tests.ts b/promise-pool/promise-pool-tests.ts new file mode 100644 index 000000000..783d571ca --- /dev/null +++ b/promise-pool/promise-pool-tests.ts @@ -0,0 +1,47 @@ +import Q = require('q'); +import promisePool = require('promise-pool'); + +var pool = new promisePool.Pool((taskDataId, index) => { + return Q.delay(Math.floor(Math.random() * 5000)).then(function () { + taskDataId == 0; + index == 0; + }); +}, 20); + +pool + .pause() + .delay(5000) + .then(function () { + pool.resume(); + }); + +pool.retries == 0; +pool.retryInterval == 0; +pool.maxRetryInterval == 0; +pool.retryIntervalMultiplier == 0; + +pool.add(0); + +pool + .start(onProgress) + .then(result => { + result.total == 0; + return pool.reset(); + }) + .then(() => { + return pool.start(onProgress); + }) + .then(result => { + result.total == 0; + return pool.reset(); + }) + .then(() => { + pool.endless == true; + }); + +function onProgress(progress: promisePool.IProgress) { + progress.success == true; + progress.fulfilled == 0; + progress.total == 0; + progress.index == 0; +} \ No newline at end of file diff --git a/promise-pool/promise-pool.d.ts b/promise-pool/promise-pool.d.ts new file mode 100644 index 000000000..b38a54262 --- /dev/null +++ b/promise-pool/promise-pool.d.ts @@ -0,0 +1,124 @@ +// Type definitions for promise-pool +// Project: https://github.com/vilic/promise-pool +// Definitions by: VILIC VANE +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "promise-pool" { + /** + * interface for the final result. + */ + export interface IResult { + fulfilled: number; + rejected: number; + total: number; + } + /** + * interface for progress data. + */ + export interface IProgress { + index: number; + success: boolean; + error: any; + retries: number; + fulfilled: number; + rejected: number; + pending: number; + total: number; + } + /** + * tasks pool that manages concurrency. + */ + export class Pool { + /** + * (get/set) the max concurrency of this task pool. + */ + public concurrency: number; + private _tasksData; + /** + * (get/set) the processor function that handles tasks data. + */ + public processor: (data: T, index: number) => Q.Promise; + private _deferred; + private _pauseDeferred; + /** + * (get) the number of successful tasks. + */ + public fulfilled: number; + /** + * (get) the number of failed tasks. + */ + public rejected: number; + /** + * (get) the number of pending tasks. + */ + public pending: number; + /** + * (get) the number of completed tasks and pending tasks in total. + */ + public total: number; + /** + * (get/set) indicates whether this task pool is endless, if so, tasks can still be added even after all previous tasks have been fulfilled. + */ + public endless: boolean; + /** + * (get/set) defaults to 0, the number or retries that this task pool will take for every single task, could be Infinity. + */ + public retries: number; + /** + * (get/set) defaults to 0, interval (milliseconds) between each retries. + */ + public retryInterval: number; + /** + * (get/set) defaults to Infinity, max retry interval when retry interval multiplier applied. + */ + public maxRetryInterval: number; + /** + * (get/set) defaults to 1, the multiplier applies to interval after every retry. + */ + public retryIntervalMultiplier: number; + private _index; + private _currentConcurrency; + public onProgress: (progress: IProgress) => void; + /** + * initialize a task pool. + * @param processor a function takes the data and index as parameters and returns a promise. + * @param concurrency the concurrency of this task pool. + * @param endless defaults to false. indicates whether this task pool is endless, if so, tasks can still be added even after all previous tasks have been fulfilled. + * @param tasksData an initializing array of task data. + */ + constructor(processor: (data: T, index: number) => Q.Promise, concurrency: number, endless?: boolean, tasksData?: T[]); + /** + * add a data item. + * @param taskData task data to add. + */ + public add(taskData: T): void; + /** + * add data items. + * @param tasskData tasks data to add. + */ + public add(tasksData: T[]): void; + /** + * start tasks, return a promise that will be fulfilled after all tasks accomplish if endless is false. + * @param onProgress a callback that will be triggered every time when a single task is fulfilled. + */ + public start(onProgress?: (progress: IProgress) => void): Q.Promise; + private _start(); + private _process(data, index); + private _notifyProgress(index, success, err, retries); + private _next(); + /** + * pause tasks and return a promise that will be fulfilled after the running tasks accomplish. this will wait for running tasks to complete instead of aborting them. + */ + public pause(): Q.Promise; + /** + * resume tasks. + */ + public resume(): void; + /** + * pause tasks, then clear pending tasks data and reset counters. return a promise that will be fulfilled after resetting accomplish. + */ + public reset(): Q.Promise; + } +} \ No newline at end of file From 8ce72b147361bc618129405bd8ccaf5a5ac8e05c Mon Sep 17 00:00:00 2001 From: VILIC VANE Date: Sun, 10 Aug 2014 01:40:01 +0800 Subject: [PATCH 24/30] change processor return type from Q.Promise to Q.IPromise --- promise-pool/promise-pool.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/promise-pool/promise-pool.d.ts b/promise-pool/promise-pool.d.ts index b38a54262..b9214e7f0 100644 --- a/promise-pool/promise-pool.d.ts +++ b/promise-pool/promise-pool.d.ts @@ -39,7 +39,7 @@ declare module "promise-pool" { /** * (get/set) the processor function that handles tasks data. */ - public processor: (data: T, index: number) => Q.Promise; + public processor: (data: T, index: number) => Q.IPromise; private _deferred; private _pauseDeferred; /** @@ -88,7 +88,7 @@ declare module "promise-pool" { * @param endless defaults to false. indicates whether this task pool is endless, if so, tasks can still be added even after all previous tasks have been fulfilled. * @param tasksData an initializing array of task data. */ - constructor(processor: (data: T, index: number) => Q.Promise, concurrency: number, endless?: boolean, tasksData?: T[]); + constructor(processor: (data: T, index: number) => Q.IPromise, concurrency: number, endless?: boolean, tasksData?: T[]); /** * add a data item. * @param taskData task data to add. From 79139ac1702e0089445e2b8f8af4fb3160e2742c Mon Sep 17 00:00:00 2001 From: Anthony Date: Sat, 9 Aug 2014 13:54:31 -0400 Subject: [PATCH 25/30] Added name to contributors --- CONTRIBUTORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 5292ba4bf..c53c7559f 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -138,6 +138,7 @@ All definitions files include a header with the author and editors, so at some p * [IxJS (Interactive extensions)](https://github.com/Reactive-Extensions/IxJS) (by [Igor Oleinikov](https://github.com/Igorbek)) * [jake](https://github.com/mde/jake) (by [Kon](http://phyzkit.net/)) * [Jasmine](http://pivotal.github.com/jasmine/) (by [Boris Yankov](https://github.com/borisyankov)) +* [Jasmine-data_driven_tests](https://github.com/gburghardt/jasmine-data_driven_tests) (by [Anthony MacKinnon](https://github.com/AnthonyMacKinnon)) * [Jasmine-jQuery](https://github.com/velesin/jasmine-jquery) (by [Gregor Stamac](https://github.com/gstamac)) * [jDataView](https://github.com/jDataView/jDataView) (by [Ingvar Stepanyan](https://github.com/RReverser)) * [JointJS](http://www.jointjs.com/) (by [Aidan Reel](http://github.com/areel)) From f2de3867de193326103f9a394701efec4b452618 Mon Sep 17 00:00:00 2001 From: Paulo Cesar Date: Sat, 9 Aug 2014 18:15:54 -0300 Subject: [PATCH 26/30] squash! squash! fix tabs rootscope <> iscope --- angularjs/angular.d.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index 282463bcb..1c3e96160 100755 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -315,8 +315,7 @@ declare module ng { // Scope // see http://docs.angularjs.org/api/ng.$rootScope.Scope /////////////////////////////////////////////////////////////////////////// - interface IScope { - [index: string]: any; + interface IRootScopeService { $apply(): any; $apply(exp: string): any; $apply(exp: (scope: IScope) => any): any; @@ -353,6 +352,7 @@ declare module ng { $parent: IScope; $root: IRootScopeService; + this: IRootScopeService; $id: string; @@ -967,7 +967,9 @@ declare module ng { // RootScopeService // see http://docs.angularjs.org/api/ng.$rootScope /////////////////////////////////////////////////////////////////////////// - interface IRootScopeService extends IScope {} + interface IScope extends IRootScopeService { + [index: string]: any; + } /////////////////////////////////////////////////////////////////////////// // SCEService From 186c0182cd72798b4aa0ad11b7bf0f47db10ee09 Mon Sep 17 00:00:00 2001 From: Adrien Bustany Date: Sat, 9 Aug 2014 23:44:06 +0200 Subject: [PATCH 27/30] d3: Enable usage as an external module --- d3/d3.d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/d3/d3.d.ts b/d3/d3.d.ts index 173603354..2229fa8a4 100755 --- a/d3/d3.d.ts +++ b/d3/d3.d.ts @@ -3353,3 +3353,7 @@ declare module D3 { } declare var d3: D3.Base; + +declare module "d3" { + export = d3; +} From 548cb78ce6cd35fba48d31ec693f9dec44af433f Mon Sep 17 00:00:00 2001 From: Adrien Bustany Date: Sat, 9 Aug 2014 23:44:45 +0200 Subject: [PATCH 28/30] d3: Fix file permissions There is no reason to have this file executable. --- d3/d3.d.ts | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 d3/d3.d.ts diff --git a/d3/d3.d.ts b/d3/d3.d.ts old mode 100755 new mode 100644 From 16dffed6f38c4c6f12e42282b4b259336049e4ba Mon Sep 17 00:00:00 2001 From: basarat Date: Sun, 10 Aug 2014 20:59:13 +1000 Subject: [PATCH 29/30] angular: $scope extends $rootScope. closes #2593 --- angularjs/angular.d.ts | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index 1c3e96160..cacf7647b 100755 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -312,8 +312,8 @@ declare module ng { } /////////////////////////////////////////////////////////////////////////// - // Scope - // see http://docs.angularjs.org/api/ng.$rootScope.Scope + // Scope and RootScope + // see https://docs.angularjs.org/api/ng/type/$rootScope.Scope and http://docs.angularjs.org/api/ng.$rootScope /////////////////////////////////////////////////////////////////////////// interface IRootScopeService { $apply(): any; @@ -361,6 +361,10 @@ declare module ng { $$phase: any; } + interface IScope extends IRootScopeService { + [index: string]: any; + } + interface IAngularEvent { targetScope: IScope; currentScope: IScope; @@ -963,14 +967,6 @@ declare module ng { /////////////////////////////////////////////////////////////////////////// interface ITemplateCacheService extends ICacheObject {} - /////////////////////////////////////////////////////////////////////////// - // RootScopeService - // see http://docs.angularjs.org/api/ng.$rootScope - /////////////////////////////////////////////////////////////////////////// - interface IScope extends IRootScopeService { - [index: string]: any; - } - /////////////////////////////////////////////////////////////////////////// // SCEService // see http://docs.angularjs.org/api/ng.$sce From 455f9dce68a893a55d8ba17ce748b4b2932966be Mon Sep 17 00:00:00 2001 From: vvakame Date: Tue, 12 Aug 2014 17:15:17 +0900 Subject: [PATCH 30/30] update angular-ui-router.d.ts --- angular-ui/angular-ui-router.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/angular-ui/angular-ui-router.d.ts b/angular-ui/angular-ui-router.d.ts index 081d35723..0f8eb5c57 100644 --- a/angular-ui/angular-ui-router.d.ts +++ b/angular-ui/angular-ui-router.d.ts @@ -13,6 +13,7 @@ declare module ng.ui { templateUrl?: any; templateProvider?: () => string; controller?: any; + controllerAs?: string; controllerProvider?: any; resolve?: {}; url?: string;