From e8c8cfa1d4aeb866c4c75fd96e043b25a1e3e244 Mon Sep 17 00:00:00 2001 From: Paulo Cesar Date: Fri, 7 Aug 2015 00:41:30 -0300 Subject: [PATCH 01/64] allow strictDi controller --- angular-ui-router/angular-ui-router-tests.ts | 9 ++++++- angular-ui-router/angular-ui-router.d.ts | 28 ++++++++++---------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/angular-ui-router/angular-ui-router-tests.ts b/angular-ui-router/angular-ui-router-tests.ts index a05f13dd8..ae4a8d7e5 100644 --- a/angular-ui-router/angular-ui-router-tests.ts +++ b/angular-ui-router/angular-ui-router-tests.ts @@ -54,6 +54,13 @@ myApp.config(( $scope.items = ["A", "List", "Of", "Items"]; } }) + .state('state1.list', { + url: "/list", + templateUrl: "partials/state1.list.html", + controller: ['$scope', function ($scope: MyAppScope) { + $scope.items = ["A", "List", "Of", "Items"]; + }] + }) .state('state2', { url: "/state2", templateUrl: "partials/state2.html" @@ -155,7 +162,7 @@ class UrlLocatorTestService implements IUrlLocatorTestService { this.$state.get("myState"); this.$state.get(); this.$state.reload(); - + // Accesses the currently resolved values for the current state // http://stackoverflow.com/questions/28026620/is-there-a-way-to-access-resolved-state-dependencies-besides-injecting-them-into/28027023#28027023 var resolvedValues = this.$state.$current.locals.globals; diff --git a/angular-ui-router/angular-ui-router.d.ts b/angular-ui-router/angular-ui-router.d.ts index 10b92db7d..4a70579a9 100644 --- a/angular-ui-router/angular-ui-router.d.ts +++ b/angular-ui-router/angular-ui-router.d.ts @@ -26,24 +26,24 @@ declare module angular.ui { /** * Function, returns HTML content string */ - templateProvider?: Function | Array; + templateProvider?: Function | Array; /** - * A controller paired to the state. Function OR name as String + * A controller paired to the state. Function, annotated array or name as String */ - controller?: Function | string; + controller?: Function|string|Array; controllerAs?: string; /** * Function (injectable), returns the actual controller function or string. */ - controllerProvider?: Function; - + controllerProvider?: Function|Array; + /** * Specifies the parent state of this state */ - parent?: string | IState - - - resolve?: {}; + parent?: string | IState; + + + resolve?: { [name:string]: any }; /** * A url with optional parameters. When a state is navigated or transitioned to, the $stateParams service will be populated with any parameters that were passed. */ @@ -55,18 +55,18 @@ declare module angular.ui { /** * Use the views property to set up multiple views. If you don't need multiple views within a single state this property is not needed. Tip: remember that often nested views are more useful and powerful than multiple sibling views. */ - views?: {}; + views?: { [name:string]: IState }; abstract?: boolean; /** * Callback function for when a state is entered. Good way to trigger an action or dispatch an event, such as opening a dialog. * If minifying your scripts, make sure to explicitly annotate this function, because it won't be automatically annotated by your build tools. */ - onEnter?: Function|(string|Function)[]; + onEnter?: Function|Array; /** * Callback functions for when a state is entered and exited. Good way to trigger an action or dispatch an event, such as opening a dialog. * If minifying your scripts, make sure to explicitly annotate this function, because it won't be automatically annotated by your build tools. */ - onExit?: Function|(string|Function)[]; + onExit?: Function|Array; /** * Arbitrary data object, useful for custom configuration. */ @@ -174,10 +174,10 @@ declare module angular.ui { current: IState; params: IStateParamsService; reload(): void; - + $current: IResolvedState; } - + interface IResolvedState { locals: { /** From fb94b1ef373912e0e546d4c6e4029d4d75a77551 Mon Sep 17 00:00:00 2001 From: use-strict Date: Thu, 17 Sep 2015 19:37:31 +0300 Subject: [PATCH 02/64] Update react.d.ts Make React.Component (static side) compatible with React.ComponentClass. This ensures validation when we use ES6-style classes to extend from React.Component, as opposed to using React.createClass. --- react/react.d.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/react/react.d.ts b/react/react.d.ts index 54d13d5eb..9dd616a1b 100644 --- a/react/react.d.ts +++ b/react/react.d.ts @@ -132,6 +132,11 @@ declare namespace __React { // Base component for plain JS classes class Component implements ComponentLifecycle { + static propTypes: ValidationMap; + static contextTypes: ValidationMap; + static childContextTypes: ValidationMap; + static defaultProps: Props; + constructor(props?: P, context?: any); setState(f: (prevState: S, props: P) => S, callback?: () => any): void; setState(state: S, callback?: () => any): void; @@ -929,6 +934,11 @@ declare module "react/addons" { // Base component for plain JS classes class Component implements ComponentLifecycle { + static propTypes: ValidationMap; + static contextTypes: ValidationMap; + static childContextTypes: ValidationMap; + static defaultProps: Props; + constructor(props?: P, context?: any); setState(f: (prevState: S, props: P) => S, callback?: () => any): void; setState(state: S, callback?: () => any): void; From 64cd3d9c56336ffaf2c64ff5de95438c52cda656 Mon Sep 17 00:00:00 2001 From: "Ciuca, Alexandru" Date: Thu, 17 Sep 2015 20:11:06 +0300 Subject: [PATCH 03/64] Fixed react tests caused by incompatibility of aliased props generics --- react-dnd/react-dnd-tests.ts | 4 ++++ react/react-addons-tests.ts | 2 ++ react/react-global-tests.ts | 2 ++ react/react-tests.ts | 2 ++ 4 files changed, 10 insertions(+) diff --git a/react-dnd/react-dnd-tests.ts b/react-dnd/react-dnd-tests.ts index d270a041d..45c492073 100644 --- a/react-dnd/react-dnd-tests.ts +++ b/react-dnd/react-dnd-tests.ts @@ -80,6 +80,8 @@ module Knight { } export class Knight extends React.Component { + static defaultProps: KnightP; + static create = React.createFactory(Knight); componentDidMount() { @@ -153,6 +155,8 @@ module BoardSquare { } export class BoardSquare extends React.Component { + static defaultProps: BoardSquareP; + private _renderOverlay = (color: string) => { return r.div({ style: { diff --git a/react/react-addons-tests.ts b/react/react-addons-tests.ts index 245cb78d8..4d8ed3212 100644 --- a/react/react-addons-tests.ts +++ b/react/react-addons-tests.ts @@ -84,6 +84,8 @@ class ModernComponent extends React.Component static childContextTypes: React.ValidationMap = { someOtherValue: React.PropTypes.string } + + static defaultProps: Props; context: Context; diff --git a/react/react-global-tests.ts b/react/react-global-tests.ts index a3f4a1484..0b20e4650 100644 --- a/react/react-global-tests.ts +++ b/react/react-global-tests.ts @@ -81,6 +81,8 @@ class ModernComponent extends React.Component someOtherValue: React.PropTypes.string } + static defaultProps: Props; + context: Context; getChildContext() { diff --git a/react/react-tests.ts b/react/react-tests.ts index 6540cc9f3..053a17eb9 100644 --- a/react/react-tests.ts +++ b/react/react-tests.ts @@ -82,6 +82,8 @@ class ModernComponent extends React.Component someOtherValue: React.PropTypes.string } + static defaultProps: Props; + context: Context; getChildContext() { From 3b595d8d45e1e74dc748fb6846dfd1784440dfc7 Mon Sep 17 00:00:00 2001 From: tigerxy Date: Sun, 20 Sep 2015 12:51:59 +0200 Subject: [PATCH 04/64] jquery.soap added --- jquery.soap/jquery.soap.d.ts | 75 ++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 jquery.soap/jquery.soap.d.ts diff --git a/jquery.soap/jquery.soap.d.ts b/jquery.soap/jquery.soap.d.ts new file mode 100644 index 000000000..9470cf12a --- /dev/null +++ b/jquery.soap/jquery.soap.d.ts @@ -0,0 +1,75 @@ +/// + + +declare module JQuerySOAP { + interface SOAPEnvelope { + attributes: any + bodies: any + headers: any + prefix: string + soapConfig: any + typeOf: string + addAttribute(name, value): void + addBody(soapObject: SOAPObject): void + addHeader(soapObject: SOAPObject): void + addNamespace(name, uri): void + toString(): string + send(options): void + } + interface SOAPResponse { + toJSON(): any + toString(): String + toXML(): XMLDocument + } + + interface SOAPObject { + attributes: any + children: any + name: string + ns: any + _parent: any + value: any + typeOf: string + addNamespace(name, url): void + addParameter(name, value) + appendChild(soapObject: SOAPObject) + attr(name, value) + end() + find(name) + hasChildren() + newChild(name) + parent() + toString(): string + val(value) + } + interface Options { + appendMethodToURL?: boolean; + async?: boolean; + beforeSend?: (SOAPEnvelope: SOAPEnvelope) => void; + context?: any; + data?: Object; + envAttributes?: any; + elementName?: string; + enableLogging?: boolean; + error?: (SOAPResponse: SOAPResponse) => void; + HTTPHeaders?: any; + method?: string; + namespaceQualifier?: string; + namespaceURL?: string; + noPrefix?: boolean; + request?: (SOAPEnvelope: SOAPEnvelope) => void; + soap12?: boolean; + SOAPAction?: string; + SOAPHeader?: any; + statusCode?: any; + success?: (SOAPResponse: SOAPResponse) => void; + url?: string; + wss?: any; + } + interface SOAP { + (options?: Options): JQueryXHR; + } +} +interface JQueryStatic { + soap: JQuerySOAP.SOAP; +} From d6f771e1d44a9217b763b9f054a7c397decb41f0 Mon Sep 17 00:00:00 2001 From: Roland Greim Date: Sun, 20 Sep 2015 13:01:30 +0200 Subject: [PATCH 05/64] Update jquery.soap.d.ts --- jquery.soap/jquery.soap.d.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/jquery.soap/jquery.soap.d.ts b/jquery.soap/jquery.soap.d.ts index 9470cf12a..9097145de 100644 --- a/jquery.soap/jquery.soap.d.ts +++ b/jquery.soap/jquery.soap.d.ts @@ -1,5 +1,9 @@ -/// +// Type definitions for jQuery.SOAP 1.6.7 +// Project: https://github.com/doedje/jquery.soap +// Definitions by: Roland Greim +// Definitions: https://github.com/borisyankov/DefinitelyTyped/ +/// declare module JQuerySOAP { interface SOAPEnvelope { From d5ea9a613f24fc5bbac32805814b9d9ea7ae6468 Mon Sep 17 00:00:00 2001 From: tigerxy Date: Sun, 20 Sep 2015 13:08:14 +0200 Subject: [PATCH 06/64] js-md5 added --- js-md5/md5.d.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 js-md5/md5.d.ts diff --git a/js-md5/md5.d.ts b/js-md5/md5.d.ts new file mode 100644 index 000000000..594531946 --- /dev/null +++ b/js-md5/md5.d.ts @@ -0,0 +1,18 @@ +// Type definitions for js-md5 v0.3.0 +// Project: https://github.com/emn178/js-md5 +// Definitions by: Roland Greim +// Definitions: https://github.com/borisyankov/DefinitelyTyped/ + +interface JQuery { + md5(value: string): string; +} + +interface JQueryStatic { + md5(value: string): string; +} + +interface md5 { + (value: string): string; +} + +declare var md5: md5; From 6e996ab243e91e705ac6f9cec3a8bf37ccb5409f Mon Sep 17 00:00:00 2001 From: tigerxy Date: Sun, 20 Sep 2015 17:54:14 +0200 Subject: [PATCH 07/64] Testfiles added --- jquery.soap/jquery.soap-tests.ts | 57 ++++++++++++++++++++++++++++++++ jquery.soap/jquery.soap.d.ts | 2 +- js-md5/md5-tests.ts | 20 +++++++++++ js-md5/md5.d.ts | 14 ++++++++ 4 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 jquery.soap/jquery.soap-tests.ts create mode 100644 js-md5/md5-tests.ts diff --git a/jquery.soap/jquery.soap-tests.ts b/jquery.soap/jquery.soap-tests.ts new file mode 100644 index 000000000..c8328c800 --- /dev/null +++ b/jquery.soap/jquery.soap-tests.ts @@ -0,0 +1,57 @@ +/// + +$.soap({ + url: 'http://my.server.com/soapservices/', //endpoint address for the service + method: 'helloWorld', // service operation name + // 1) will be appended to url if appendMethodToURL=true + // 2) will be used for request element name when building xml from JSON 'params' (unless 'elementName' is provided) + // 3) will be used to set SOAPAction request header if no SOAPAction is specified + appendMethodToURL: true, // method name will be appended to URL defaults to true + SOAPAction: 'action', // manually set the Request Header 'SOAPAction', defaults to the method specified above (optional) + soap12: false, // use SOAP 1.2 namespace and HTTP headers - default to false + context: document.body, // Used to set this in beforeSend, success, error and data callback functions + + // addional headers and namespaces + envAttributes: { // additional attributes (like namespaces) for the Envelope: + 'xmlns:another': 'http://anotherNamespace.com/' + }, + HTTPHeaders: { // additional http headers send with the $.ajax call, will be given to $.ajax({ headers: }) + 'Authorization': 'Basic ' + btoa('user:pass') + }, + + //data can be XML DOM, XML String, JSON or a function + data: { // JSON structure used to build request XML - SHOULD be coupled with ('namespaceQualifier' AND 'namespaceURL') AND ('method' OR 'elementName') + name: 'Remy Blom', + msg: 'Hi!' + }, + + //these options ONLY apply when the request XML is going to be built from JSON 'params' + namespaceQualifier: 'myns', // used as namespace prefix for all elements in request (optional) + namespaceURL: 'urn://service.my.server.com', // namespace url added to parent request element (optional) + noPrefix: false, // set to true if you don't want the namespaceQualifier to be the prefix for the nodes in params. defaults to false (optional) + elementName: 'requestElementName', // override 'method' as outer element (optional) + + //callback functions + beforeSend: function(SOAPEnvelope) { }, // callback function - SOAPEnvelope object is passed back prior to ajax call (optional) + success: function(SOAPResponse) { }, // callback function to handle successful return (optional) + error: function(SOAPResponse) { }, // callback function to handle fault return (optional) + statusCode: { // callback functions based on statusCode + 404: function() { + console.log('404 Not Found') + }, + 200: function() { + console.log('200 OK') + } + }, + + // WS-Security + wss: { + username: 'user', + password: 'pass', + nonce: 'w08370jf7340qephufqp3r4', + created: new Date().getTime() + }, + + // debugging + enableLogging: false // to enable the local log function set to true, defaults to false (optional) +}) \ No newline at end of file diff --git a/jquery.soap/jquery.soap.d.ts b/jquery.soap/jquery.soap.d.ts index 9097145de..68647b76a 100644 --- a/jquery.soap/jquery.soap.d.ts +++ b/jquery.soap/jquery.soap.d.ts @@ -3,7 +3,7 @@ // Definitions by: Roland Greim // Definitions: https://github.com/borisyankov/DefinitelyTyped/ -/// +/// declare module JQuerySOAP { interface SOAPEnvelope { diff --git a/js-md5/md5-tests.ts b/js-md5/md5-tests.ts new file mode 100644 index 000000000..a536773aa --- /dev/null +++ b/js-md5/md5-tests.ts @@ -0,0 +1,20 @@ +/// + +md5('Message to hash'); +md5(''); +md5('中文'); +md5([]); +md5(new Uint8Array([])); + +$.md5('message'); +$.md5('Message to hash'); +$.md5(''); +$.md5('中文'); +$.md5([]); +$.md5(new Uint8Array([])); + +'message'.md5('Message to hash'); +'message'.md5(''); +'message'.md5('中文'); +'message'.md5([]); +'message'.md5(new Uint8Array([])); \ No newline at end of file diff --git a/js-md5/md5.d.ts b/js-md5/md5.d.ts index 594531946..b944b134f 100644 --- a/js-md5/md5.d.ts +++ b/js-md5/md5.d.ts @@ -3,16 +3,30 @@ // Definitions by: Roland Greim // Definitions: https://github.com/borisyankov/DefinitelyTyped/ +/// + interface JQuery { md5(value: string): string; + md5(value: Array): string; + md5(value: Uint8Array): string; } interface JQueryStatic { md5(value: string): string; + md5(value: Array): string; + md5(value: Uint8Array): string; } interface md5 { (value: string): string; + (value: Array): string; + (value: Uint8Array): string; +} + +interface String { + md5(value: string): string; + md5(value: Array): string; + md5(value: Uint8Array): string; } declare var md5: md5; From 962946746c4d2e6d44294908c498f222ed8877b1 Mon Sep 17 00:00:00 2001 From: tigerxy Date: Sun, 20 Sep 2015 19:02:43 +0200 Subject: [PATCH 08/64] soap tests updated --- jquery.soap/jquery.soap-tests.ts | 239 +++++++++++++++++++++++++++++++ jquery.soap/jquery.soap.d.ts | 90 ++++++------ 2 files changed, 286 insertions(+), 43 deletions(-) diff --git a/jquery.soap/jquery.soap-tests.ts b/jquery.soap/jquery.soap-tests.ts index c8328c800..3390c2774 100644 --- a/jquery.soap/jquery.soap-tests.ts +++ b/jquery.soap/jquery.soap-tests.ts @@ -1,5 +1,25 @@ /// +$.soap({ + url: 'http://my.server.com/soapservices/', + method: 'helloWorld', + + data: { + name: 'Remy Blom', + msg: 'Hi!' + }, + + success: function (soapResponse) { + // do stuff with soapResponse + // if you want to have the response as JSON use soapResponse.toJSON(); + // or soapResponse.toString() to get XML string + // or soapResponse.toXML() to get XML DOM + }, + error: function (SOAPResponse) { + // show error + } +}); + $.soap({ url: 'http://my.server.com/soapservices/', //endpoint address for the service method: 'helloWorld', // service operation name @@ -54,4 +74,223 @@ $.soap({ // debugging enableLogging: false // to enable the local log function set to true, defaults to false (optional) +}) + +$.soap({ + +}).done(function(data, textStatus, jqXHR) { + // do stuff on success here... +}).fail(function(jqXHR, textStatus, errorThrown) { + // do stuff on error here... +}) + +$.soap({ + url: 'http://my.server.com/soapservices/', + namespaceQualifier: 'myns', + namespaceURL: 'urn://service.my.server.com', + error: function (soapResponse) { + // show error + } +}); + +$.soap({ + method: 'helloWorld', + data: { + name: 'Remy Blom', + msg: 'Hi!' + }, + success: function (soapResponse) { + // do stuff with soapResponse + } +}); + +$.soap({ + method: 'doSomethingElse', + data: {}, + success: function (soapResponse) { + // do stuff with soapResponse + } +}); + +$.soap({ + url: 'http://another.server.com/anotherService', + method: 'helloWorld', + data: { + name: 'Remy Blom', + msg: 'Hi!' + }, + success: function (soapResponse) { + // do stuff with soapResponse + }, + error: function (soapResponse) { + alert('that other server might be down...') + } +}); + +$.soap({ + // other parameters.. + + // WS-Security + wss: { + username: 'user', + password: 'pass', + nonce: 'w08370jf7340qephufqp3r4', + created: new Date().getTime() + } +}); + +var username = 'foo'; +var password = 'bar'; + +$.soap({ + // other parameters... + + HTTPHeaders: { + Authorization: 'Basic ' + btoa(username + ':' + password) + } +}); + +// jquery.soap/doc/options.md + +$.soap({ + url: 'http://server.com/webServices/', + method: 'getItem', + appendMethodToURL: false +}) + +$.soap({ + beforeSend: function(SOAPEnvelope) { + console.log(SOAPEnvelope.toString()); + } +}); + +$.soap({ + context: document.body, + success: function(SOAPResponse) { + console.log(this); + } +}); + +var xml = + ['', + '', + '', + '', + '', + '']; + +$.soap({ + data: xml.join('') +}); + +$.soap({ + method: 'requestNode', + data: { + name: 'Remy Blom', + msg: 'Hi!' + } +}); + +$.soap({ + envAttributes: { + 'xmlns:another': 'http://anotherNamespace.com/' + } +}) + +$.soap({ + method: 'helloWorld', + elementName: 'requestNode' +}) + +$.soap({ + enableLoggin: true +}) + +$.soap({ + error: function(SOAPResponse) { + console.log(SOAPResponse.toString()) + } +}) + +$.soap({ + HTTPHeaders: { + 'Authorization': 'Basic ' + btoa('user:pass') + } +}) + +$.soap({ + url: 'http://server.com/webServices/', + method: 'getItem' +}) + +$.soap({ + method: 'helloWorld', + namespaceQualifier: 'myns', + namespaceURL: 'urn://service.my.server.com' +}) + +$.soap({ + method: 'helloWorld', + namespaceQualifier: 'myns', + namespaceURL: 'urn://service.my.server.com' +}) + +$.soap({ + method: 'helloWorld', + namespaceQualifier: 'myns', + namespaceURL: 'urn://service.my.server.com', + noPrefix: true +}) + +$.soap({ + request: function(SOAPEnvelope) { + console.log(SOAPEnvelope.toString()); + } +}) + +$.soap({ + soap12: true +}) + +$.soap({ + url: 'http://server.com/webServices/', + method: 'getItem', + SOAPAction: 'getAnItem' +}) + +$.soap({ + SOAPHeader: { + test: [1,2,3] + } +}) + +$.soap({ + statusCode: { + 404: function() { + console.log('404 Not Found') + }, + 200: function() { + console.log('200 OK') + } + } +}) + +$.soap({ + success: function(SOAPResponse) { + console.log(SOAPResponse.toString()); + } +}) + +$.soap({ + url: 'http://server.com/webServices/', + method: 'getItem' +}) + +$.soap({ + wss: { + username: 'user', + password: 'pass', + nonce: 'w08370jf7340qephufqp3r4', + created: new Date().getTime() + } }) \ No newline at end of file diff --git a/jquery.soap/jquery.soap.d.ts b/jquery.soap/jquery.soap.d.ts index 68647b76a..abd65e783 100644 --- a/jquery.soap/jquery.soap.d.ts +++ b/jquery.soap/jquery.soap.d.ts @@ -7,68 +7,72 @@ declare module JQuerySOAP { interface SOAPEnvelope { - attributes: any - bodies: any - headers: any + attributes: Object + bodies: Array + headers: Array prefix: string soapConfig: any typeOf: string - addAttribute(name, value): void + addAttribute(name: String, value: string): void + addAttribute(name: String, value: number): void addBody(soapObject: SOAPObject): void addHeader(soapObject: SOAPObject): void - addNamespace(name, uri): void + addNamespace(name: String, uri: string): void toString(): string - send(options): void + send(options: Options): void } interface SOAPResponse { toJSON(): any toString(): String toXML(): XMLDocument } - + interface SOAPObject { - attributes: any - children: any + attributes: Object + children: Array name: string - ns: any - _parent: any + ns: Object + _parent: SOAPObject value: any typeOf: string - addNamespace(name, url): void - addParameter(name, value) - appendChild(soapObject: SOAPObject) - attr(name, value) - end() - find(name) - hasChildren() - newChild(name) - parent() + addNamespace(name: String, url: string): void + addParameter(name: String, value: string): void + addParameter(name: String, value: number): void + appendChild(soapObject: SOAPObject): SOAPObject + attr(name: string, value: string): Object + attr(name: string, value: number): Object + end(): SOAPObject + find(name: string): SOAPObject + hasChildren(): boolean + newChild(name: string): SOAPObject + parent(): SOAPObject toString(): string - val(value) + val(value: string): SOAPObject + val(value: number): SOAPObject } interface Options { - appendMethodToURL?: boolean; - async?: boolean; - beforeSend?: (SOAPEnvelope: SOAPEnvelope) => void; - context?: any; - data?: Object; - envAttributes?: any; - elementName?: string; - enableLogging?: boolean; - error?: (SOAPResponse: SOAPResponse) => void; - HTTPHeaders?: any; - method?: string; - namespaceQualifier?: string; - namespaceURL?: string; - noPrefix?: boolean; - request?: (SOAPEnvelope: SOAPEnvelope) => void; - soap12?: boolean; - SOAPAction?: string; - SOAPHeader?: any; - statusCode?: any; - success?: (SOAPResponse: SOAPResponse) => void; - url?: string; - wss?: any; + appendMethodToURL?: boolean; + async?: boolean; + beforeSend?: (SOAPEnvelope: SOAPEnvelope) => void; + context?: any; + data?: Object; + envAttributes?: Object; + elementName?: string; + enableLogging?: boolean; + error?: (SOAPResponse: SOAPResponse) => void; + HTTPHeaders?: Object; + method?: string; + namespaceQualifier?: string; + namespaceURL?: string; + noPrefix?: boolean; + request?: (SOAPEnvelope: SOAPEnvelope) => void; + soap12?: boolean; + SOAPAction?: string; + SOAPHeader?: Object; + statusCode?: Object; + success?: (SOAPResponse: SOAPResponse) => void; + url?: string; + wss?: Object; } interface SOAP { (options?: Options): JQueryXHR; From 5854d4b1be1dc4e0f105623fa81fdb3e36b5087d Mon Sep 17 00:00:00 2001 From: Mattanja Kern Date: Mon, 21 Sep 2015 15:33:14 +0200 Subject: [PATCH 09/64] snapsvg update version 0.4.1 + fix for Element.drag onmove handler --- snapsvg/snapsvg.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/snapsvg/snapsvg.d.ts b/snapsvg/snapsvg.d.ts index 56d6b27b4..ff2abf720 100644 --- a/snapsvg/snapsvg.d.ts +++ b/snapsvg/snapsvg.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Snap-SVG 0.3 +// Type definitions for Snap-SVG 0.4.1 // Project: https://github.com/adobe-webplatform/Snap.svg // Definitions by: Lars Klein // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -238,7 +238,7 @@ declare module Snap { unhover(hoverInHandler: (event: MouseEvent) => void, hoverOutHandler: (event: MouseEvent) => void): Snap.Element; drag():Snap.Element; - drag(onMove: (dx: number, dy: number, event: MouseEvent) => void, + drag(onMove: (dx: number, dy: number, x: number, y: number, event: MouseEvent) => void, onStart: (x: number, y: number, event: MouseEvent) => void, onEnd: (event: MouseEvent) => void, moveThisArg?: any, From 9196efffdc706918dfbda1b4df017e477bf5ca68 Mon Sep 17 00:00:00 2001 From: Mattanja Kern Date: Mon, 21 Sep 2015 15:33:43 +0200 Subject: [PATCH 10/64] snapsvg formatting, whitespace fixes --- snapsvg/snapsvg.d.ts | 99 +++++++++++++++++++++----------------------- 1 file changed, 48 insertions(+), 51 deletions(-) diff --git a/snapsvg/snapsvg.d.ts b/snapsvg/snapsvg.d.ts index ff2abf720..2b4cba390 100644 --- a/snapsvg/snapsvg.d.ts +++ b/snapsvg/snapsvg.d.ts @@ -53,13 +53,12 @@ declare function Snap(query:string):Snap.Paper; declare function Snap(DOM:SVGElement):Snap.Paper; declare module Snap { - export var filter:Filter; export var path:Path; - + export function Matrix(a:number,b:number,c:number,d:number,e:number,f:number):Matrix; export function Matrix(svgMatrix:SVGMatrix):Matrix; - + export function ajax(url:string,postData:string,callback:Function,scope?:Object):XMLHttpRequest; export function ajax(url:string,postData:Object,callback:Function,scope?:Object):XMLHttpRequest; export function ajax(url:string,callback:Function,scope?:Object):XMLHttpRequest; @@ -72,10 +71,10 @@ declare module Snap { export function select(query:string):Snap.Element; export function selectAll(query:string):any; export function snapTo(values:Array,value:number,tolerance?:number):number; - + export function animate(from:number|number[],to:number|number[],updater:(n:number)=>void,duration:number,easing?:(num:number)=>number,callback?:()=>void):mina.MinaAnimation; export function animation(attr:Object,duration:number,easing?:(num:number)=>number,callback?:()=>void):Snap.Animation; - + export function color(clr:string):RGBHSB; export function getRGB(color:string):RGB; export function hsb(h:number,s:number,b:number):HSB; @@ -89,26 +88,26 @@ declare module Snap { export function angle(x1:number,y1:number,x2:number,y2:number,x3?:number,y3?:number):number; export function rad(deg:number):number; export function deg(rad:number):number; - + export function parse(svg:string):Fragment; export function parsePathString(pathString:string):Array; export function parsePathString(pathString:Array):Array; export function parseTransformString(TString:string):Array; export function parseTransformString(TString:Array):Array; - + export interface RGB{ r:number; g:number; b:number; hex:string; } - + export interface HSB{ h:number; s:number; b:number; } - + export interface RGBHSB{ r:number; g:number; @@ -120,13 +119,13 @@ declare module Snap { v:number; l:number; } - + export interface HSL{ h:number; s:number; l:number; } - + export interface BBox{ cx:number; cy:number; @@ -144,7 +143,7 @@ declare module Snap { y2:number; y:number; } - + export interface TransformationDescriptor { string: string; globalMatrix: Snap.Matrix; @@ -154,6 +153,7 @@ declare module Snap { local: string; toString(): string; } + export interface Animation{ attr:{[attr:string]:string|number|boolean|any}; duration:number; @@ -207,8 +207,7 @@ declare module Snap { transform(): TransformationDescriptor; type:string; use():Object; - - + click(handler: (event: MouseEvent) => void, thisArg?: any): Snap.Element; dblclick(handler: (event: MouseEvent) => void, thisArg?: any): Snap.Element; mousedown(handler: (event: MouseEvent) => void, thisArg?: any): Snap.Element; @@ -220,7 +219,7 @@ declare module Snap { touchmove(handler: (event: MouseEvent) => void, thisArg?: any): Snap.Element; touchend(handler: (event: MouseEvent) => void, thisArg?: any): Snap.Element; touchcancel(handler: (event: MouseEvent) => void, thisArg?: any): Snap.Element; - + unclick(handler?: (event: MouseEvent) => void): Snap.Element; undblclick(handler: (event: MouseEvent) => void): Snap.Element; unmousedown(handler: (event: MouseEvent) => void): Snap.Element; @@ -236,7 +235,7 @@ declare module Snap { hover(hoverInHandler: (event: MouseEvent) => void, hoverOutHandler: (event: MouseEvent) => void, thisArg?: any): Snap.Element; hover(hoverInHandler: (event: MouseEvent) => void, hoverOutHandler: (event: MouseEvent) => void, inThisArg?: any, outThisArg?: any): Snap.Element; unhover(hoverInHandler: (event: MouseEvent) => void, hoverOutHandler: (event: MouseEvent) => void): Snap.Element; - + drag():Snap.Element; drag(onMove: (dx: number, dy: number, x: number, y: number, event: MouseEvent) => void, onStart: (x: number, y: number, event: MouseEvent) => void, @@ -249,15 +248,14 @@ declare module Snap { onStart: (x: number, y: number, event: MouseEvent) => void, onEnd: (event: MouseEvent) => void): Snap.Element; } - + export interface Fragment { //TODO: The documentation says that selectAll returns a set, but the getting started guide // uses .attr on the returned object. That's not supported by a set select(query:string):Snap.Element; selectAll(query ?:string):Snap.Set; } - - + export interface Matrix { add(a:number,b:number,c:number,d:number,e:number,f:number):Matrix; add(matrix:Matrix):Matrix; @@ -267,13 +265,13 @@ declare module Snap { rotate(a:number,x?:number,y?:number):Matrix; scale(x:number,y?:number,cx?:number,cy?:number):Matrix; split():ExplicitTransform; - toTransformString():string; + toTransformString():string; translate(x:number,y:number):Matrix; x(x:number,y:number):number; y(x:number,y:number):number; - + } - + interface ExplicitTransform { dx: number; dy: number; @@ -283,32 +281,31 @@ declare module Snap { rotate: number; isSimple: boolean; } - - interface Paper extends Snap.Element { - clear():void; - el(name:string, attr:Object):Snap.Element; - filter(filstr:string):Snap.Element; - gradient(gradient:string):any; - g(varargs?:any):any; - group(...els:any[]):any; - mask(varargs:any):Object; - ptrn(x:number,y:number,width:number,height:number,vbx:number,vby:number,vbw:number,vbh:number):Object; - svg(x:number,y:number,width:number,height:number,vbx:number,vby:number,vbw:number,vbh:number):Object; - toString():string; - use(id?:string):Object; - use(id?:Snap.Element):Object; - - circle(x:number,y:number,r:number):Snap.Element; - ellipse(x:number,y:number,rx:number,ry:number):Snap.Element; - image(src:string,x:number,y:number,width:number,height:number):Snap.Element; - line(x1:number,y1:number,x2:number,y2:number):Snap.Element; - path(pathString?:string):Snap.Element; - polygon(varargs:any[]):Snap.Element; - polyline(varargs:any[]):Snap.Element; - rect(x:number,y:number,width:number,height:number,rx?:number,ry?:number):Snap.Element; - text(x:number,y:number,text:string|number):Snap.Element; - text(x:number,y:number,text:Array):Snap.Element; + interface Paper extends Snap.Element { + clear():void; + el(name:string, attr:Object):Snap.Element; + filter(filstr:string):Snap.Element; + gradient(gradient:string):any; + g(varargs?:any):any; + group(...els:any[]):any; + mask(varargs:any):Object; + ptrn(x:number,y:number,width:number,height:number,vbx:number,vby:number,vbw:number,vbh:number):Object; + svg(x:number,y:number,width:number,height:number,vbx:number,vby:number,vbw:number,vbh:number):Object; + toString():string; + use(id?:string):Object; + use(id?:Snap.Element):Object; + + circle(x:number,y:number,r:number):Snap.Element; + ellipse(x:number,y:number,rx:number,ry:number):Snap.Element; + image(src:string,x:number,y:number,width:number,height:number):Snap.Element; + line(x1:number,y1:number,x2:number,y2:number):Snap.Element; + path(pathString?:string):Snap.Element; + polygon(varargs:any[]):Snap.Element; + polyline(varargs:any[]):Snap.Element; + rect(x:number,y:number,width:number,height:number,rx?:number,ry?:number):Snap.Element; + text(x:number,y:number,text:string|number):Snap.Element; + text(x:number,y:number,text:Array):Snap.Element; } export interface Set { @@ -327,7 +324,7 @@ declare module Snap { push(els:Snap.Element[]):Snap.Element; splice(index:number,count:number,insertion?:Object[]):Snap.Element[]; } - + interface Filter { blur(x:number,y?:number):string; brightness(amount:number):string; @@ -339,9 +336,9 @@ declare module Snap { sepia(amount:number):string; shadow(dx: number, dy: number, blur: number, color: string, opacity: number): string; shadow(dx: number, dy: number, color: string, opacity: number): string; - shadow(dx: number, dy: number, opacity: number): string; + shadow(dx: number, dy: number, opacity: number): string; } - + interface Path { bezierBBox(...args:number[]):BBox; bezierBBox(bez:Array):BBox; @@ -363,7 +360,7 @@ declare module Snap { toCubic(pathString:Array):Array; toRelative(path:string):Array; } - + interface IntersectionDot{ x:number, y:number, From 0099601758ceea43b60cee094a2723d92968edfc Mon Sep 17 00:00:00 2001 From: Mattanja Kern Date: Mon, 21 Sep 2015 16:03:15 +0200 Subject: [PATCH 11/64] snapsvg: update to version 0.4.1 according to changelog https://github.com/adobe-webplatform/Snap.svg/blob/master/history.md --- snapsvg/snapsvg.d.ts | 46 ++++++++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/snapsvg/snapsvg.d.ts b/snapsvg/snapsvg.d.ts index 2b4cba390..aff964a6d 100644 --- a/snapsvg/snapsvg.d.ts +++ b/snapsvg/snapsvg.d.ts @@ -1,6 +1,6 @@ // Type definitions for Snap-SVG 0.4.1 // Project: https://github.com/adobe-webplatform/Snap.svg -// Definitions by: Lars Klein +// Definitions by: Lars Klein , Mattanja Kern // Definitions: https://github.com/borisyankov/DefinitelyTyped declare function mina(a:number, A:number, b:number, B:number, get:Function, set:Function, easing?:(num:number)=>number):mina.AnimationDescriptor; @@ -13,7 +13,8 @@ declare module mina { status: Function; stop: Function; } - export interface AnimationDescriptor{ + + export interface AnimationDescriptor { id: string; start: number; end: number; @@ -88,6 +89,16 @@ declare module Snap { export function angle(x1:number,y1:number,x2:number,y2:number,x3?:number,y3?:number):number; export function rad(deg:number):number; export function deg(rad:number):number; + export function sin(angle: number): number; + export function cos(angle: number): number; + export function tan(angle: number): number; + export function asin(angle: number): number; + export function acos(angle: number): number; + export function atan(angle: number): number; + export function atan2(angle: number): number; + + export function len(x1: number, y1: number, x2: number, y2: number): number; + export function len2(x1: number, y1: number, x2: number, y2: number): number; export function parse(svg:string):Fragment; export function parsePathString(pathString:string):Array; @@ -95,20 +106,22 @@ declare module Snap { export function parseTransformString(TString:string):Array; export function parseTransformString(TString:Array):Array; - export interface RGB{ + export function closest(x: number, y: number, X: number, Y: number): boolean; + + export interface RGB { r:number; g:number; b:number; hex:string; } - export interface HSB{ + export interface HSB { h:number; s:number; b:number; } - export interface RGBHSB{ + export interface RGBHSB { r:number; g:number; b:number; @@ -120,13 +133,13 @@ declare module Snap { l:number; } - export interface HSL{ + export interface HSL { h:number; s:number; l:number; } - export interface BBox{ + export interface BBox { cx:number; cy:number; h:number; @@ -154,7 +167,7 @@ declare module Snap { toString(): string; } - export interface Animation{ + export interface Animation { attr:{[attr:string]:string|number|boolean|any}; duration:number; easing?:(num:number)=>number; @@ -165,16 +178,19 @@ declare module Snap { add(el:Snap.Element):Snap.Element; addClass(value:string):Snap.Element; after(el:Snap.Element):Snap.Element; - animate(attrs:{[attr:string]:string|number|boolean|any},duration:number,easing?:(num: number)=> number,callback?:()=>void):Snap.Element; + align(el: Snap.Element, way: string):Snap.Element; animate(animation:any):Snap.Element; + animate(attrs:{[attr:string]:string|number|boolean|any},duration:number,easing?:(num: number)=> number,callback?:()=>void):Snap.Element; append(el:Snap.Element):Snap.Element; appendTo(el:Snap.Element):Snap.Element; asPX(attr:string,value?:string):number; //TODO: check what is really returned - attr(params:{[attr:string]:string|number|boolean|any}):Snap.Element; attr(param:string):string; + attr(params:{[attr:string]:string|number|boolean|any}):Snap.Element; before(el:Snap.Element):Snap.Element; + children(): Snap.Element[]; clone():Snap.Element; data(key:string,value?:any):any; + getAlign(el: Snap.Element, way: string): string; getBBox():BBox; getPointAtLength(length:number):{x:number, y:number, alpha:number}; getSubpath(from:number,to:number):string; @@ -195,18 +211,19 @@ declare module Snap { removeClass(value:string):Snap.Element; removeData(key?:string):Snap.Element; select(query:string):Snap.Element; - selectAll(query: string): Snap.Set; - selectAll(): Snap.Set; stop():Snap.Element; toDefs():Snap.Element; + toJSON(): any; + toggleClass(value:string,flag:boolean):Snap.Element; toPattern(x:number,y:number,width:number,height:number):Object; toPattern(x:string,y:string,width:string,height:string):Object; toString():string; - toggleClass(value:string,flag:boolean):Snap.Element; - transform(tstr:string):Snap.Element; transform(): TransformationDescriptor; + transform(tstr:string):Snap.Element; type:string; use():Object; + selectAll(): Snap.Set; + selectAll(query: string): Snap.Set; click(handler: (event: MouseEvent) => void, thisArg?: any): Snap.Element; dblclick(handler: (event: MouseEvent) => void, thisArg?: any): Snap.Element; @@ -292,6 +309,7 @@ declare module Snap { mask(varargs:any):Object; ptrn(x:number,y:number,width:number,height:number,vbx:number,vby:number,vbw:number,vbh:number):Object; svg(x:number,y:number,width:number,height:number,vbx:number,vby:number,vbw:number,vbh:number):Object; + toDataUrl(): string; toString():string; use(id?:string):Object; use(id?:Snap.Element):Object; From f4beede5f5fb613626bf3be06b3b6bfde70109ed Mon Sep 17 00:00:00 2001 From: Ika Date: Tue, 22 Sep 2015 11:59:51 +0400 Subject: [PATCH 12/64] Update cometd.d.ts added couple of functions: clearListeners, clearSubscriptions, configure, handshake, disconnect; --- cometd/cometd.d.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cometd/cometd.d.ts b/cometd/cometd.d.ts index 592c6c963..d5165584c 100644 --- a/cometd/cometd.d.ts +++ b/cometd/cometd.d.ts @@ -8,12 +8,23 @@ declare module CometD { var onListenerException: (exception: any, subscriptionHandle: any, isListener: boolean, message: string) => void; function init(options: ConfigurationOptions): void; + + function configure(config: ConfigurationOptions): void; function addListener(channel: string, listener: (message: any) => void): void; function removeListener(listener: (message: any) => void): void; + function clearListeners(): void; + + function clearSubscriptions(): void; + + function handshake(handshake_params: any): void; + function publish(channel: string, message: any): void; + + function disconnect(): void; + interface ConfigurationOptions { url: string; logLevel?: string; From dfa35394688d14961b2fc258180f6f15c9c09a45 Mon Sep 17 00:00:00 2001 From: Ika Date: Tue, 22 Sep 2015 12:47:21 +0400 Subject: [PATCH 13/64] Update cometd.d.ts transformed cometD module to interface. usage: ``` var cometd: CometD; ``` added some methods: *clearListeners, clearSubscriptions, handshake, disconnect* added definition for jQuery: `$.cometd` returns CometD type --- cometd/cometd.d.ts | 51 ++++++++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/cometd/cometd.d.ts b/cometd/cometd.d.ts index d5165584c..d6f0f6e2a 100644 --- a/cometd/cometd.d.ts +++ b/cometd/cometd.d.ts @@ -5,26 +5,6 @@ declare module CometD { - var onListenerException: (exception: any, subscriptionHandle: any, isListener: boolean, message: string) => void; - - function init(options: ConfigurationOptions): void; - - function configure(config: ConfigurationOptions): void; - - function addListener(channel: string, listener: (message: any) => void): void; - function removeListener(listener: (message: any) => void): void; - - function clearListeners(): void; - - function clearSubscriptions(): void; - - function handshake(handshake_params: any): void; - - function publish(channel: string, message: any): void; - - - function disconnect(): void; - interface ConfigurationOptions { url: string; logLevel?: string; @@ -37,4 +17,35 @@ declare module CometD { appendMessageTypeToURL?: boolean; autoBatch?: boolean; } + +} + +interface CometD { + + onListenerException: (exception: any, subscriptionHandle: any, isListener: boolean, message: string) => void; + + init(options: CometD.ConfigurationOptions): void; + + configure(config: CometD.ConfigurationOptions): void; + + addListener(channel: string, listener: (message: any) => void): void; + removeListener(listener: (message: any) => void): void; + + clearListeners(): void; + + clearSubscriptions(): void; + + handshake(handshake_params: any): void; + + publish(channel: string, message: any): void; + + + disconnect(): void; + +} + + + +interface JQueryStatic { + cometd: CometD; } From 6fde16275a38d5203702d57c928545178450eb92 Mon Sep 17 00:00:00 2001 From: ridermansb Date: Tue, 22 Sep 2015 15:58:27 -0300 Subject: [PATCH 14/64] Add Stamplay js Sdk definitions --- stamplay-js-sdk/stamplay-js-sdk-tests.ts | 35 +++++++++++++++++++++ stamplay-js-sdk/stamplay-js-sdk.d.ts | 40 ++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 stamplay-js-sdk/stamplay-js-sdk-tests.ts create mode 100644 stamplay-js-sdk/stamplay-js-sdk.d.ts diff --git a/stamplay-js-sdk/stamplay-js-sdk-tests.ts b/stamplay-js-sdk/stamplay-js-sdk-tests.ts new file mode 100644 index 000000000..f17da5c13 --- /dev/null +++ b/stamplay-js-sdk/stamplay-js-sdk-tests.ts @@ -0,0 +1,35 @@ +/// + +var userFn = Stamplay.User(); +var user = new userFn.Model; + +var tags = new Stamplay.Cobject('tag').Collection; + +// Signing up +var registrationData = { + email : 'user@provider.com', + password: 'mySecret' + }; + +user.signup(registrationData).then(function(){ + user.set('phoneNumber', '020 123 4567' ); + return user.save(); + }).then(function(){ + var number = user.get('phoneNumber'); + console.log(number); // number value is 020 123 4567 + }); + + +// Action +var fooMod = new Stamplay.Cobject('foo').Model; +fooMod.fetch(5).then( + function(){ + return fooMod.upVote() + } +).then( + function(){ + //success callback + }, function( err ){ + //error callback + } +) diff --git a/stamplay-js-sdk/stamplay-js-sdk.d.ts b/stamplay-js-sdk/stamplay-js-sdk.d.ts new file mode 100644 index 000000000..50817ee2d --- /dev/null +++ b/stamplay-js-sdk/stamplay-js-sdk.d.ts @@ -0,0 +1,40 @@ +// Type definitions for stamplay-js-sdk 1.2.9 +// Project: https://github.com/Stamplay/stamplay-js-sdk and https://stamplay.com/docs/jssdk#api-ref-model +// Definitions by: Riderman de Sousa Barbosa +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module Stamplay { + + export interface IStamplayModel { + signup({}) : PromisesAPlus.Thenable + new() : IStamplayModel + get(property : string) + set(property : string, value: any) + unset(property : string) + fetch(id : any) + destroy() : PromisesAPlus.Thenable + save({}?) : PromisesAPlus.Thenable + } + + export interface IStamplayAction { + new() : IStamplayModel + upVote() : PromisesAPlus.Thenable + } + + export interface IStamplayUser { + Model : IStamplayModel + } + + export interface StamplayStatic { + User() : IStamplayUser + Cobject(collection : string) : void + } +} + +declare var Stamplay: Stamplay.StamplayStatic; + +declare module "Stamplay" { + export = Stamplay; +} From 3a68c5be79ecd6adbdc0b7cd8d04eefe00b0df69 Mon Sep 17 00:00:00 2001 From: Sixin Li Date: Tue, 22 Sep 2015 21:44:24 -0400 Subject: [PATCH 15/64] add missing scrollIntoView() typings --- codemirror/codemirror.d.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/codemirror/codemirror.d.ts b/codemirror/codemirror.d.ts index 0f548a3fa..01d0fafc4 100644 --- a/codemirror/codemirror.d.ts +++ b/codemirror/codemirror.d.ts @@ -228,6 +228,14 @@ declare module CodeMirror { The margin parameter is optional. When given, it indicates the amount of pixels around the given area that should be made visible as well. */ scrollIntoView(pos: { left: number; top: number; right: number; bottom: number; }, margin: number): void; + /** Scrolls the given element into view. pos is a { line, ch } object, in editor-local coordinates. + The margin parameter is optional. When given, it indicates the amount of pixels around the given area that should be made visible as well. */ + scrollIntoView(pos: { line: number, ch: number }, margin?: number): void; + + /** Scrolls the given element into view. pos is a { from, to } object, in editor-local coordinates. + The margin parameter is optional. When given, it indicates the amount of pixels around the given area that should be made visible as well. */ + scrollIntoView(pos: { from: CodeMirror.Position, to: CodeMirror.Position }, margin: number): void; + /** Returns an { left , top , bottom } object containing the coordinates of the cursor position. If mode is "local" , they will be relative to the top-left corner of the editable document. If it is "page" or not given, they are relative to the top-left corner of the page. From bd7be4ea62b08a1df4c4d0933329c03828df7235 Mon Sep 17 00:00:00 2001 From: ridermansb Date: Wed, 23 Sep 2015 07:44:16 -0300 Subject: [PATCH 16/64] Fix TS errors for stamplay-js-sdk --- stamplay-js-sdk/stamplay-js-sdk-tests.ts | 9 +++++---- stamplay-js-sdk/stamplay-js-sdk.d.ts | 8 ++++---- stamplay-js-sdk/tsconfig.json | 6 ++++++ 3 files changed, 15 insertions(+), 8 deletions(-) create mode 100644 stamplay-js-sdk/tsconfig.json diff --git a/stamplay-js-sdk/stamplay-js-sdk-tests.ts b/stamplay-js-sdk/stamplay-js-sdk-tests.ts index f17da5c13..644d2c5b9 100644 --- a/stamplay-js-sdk/stamplay-js-sdk-tests.ts +++ b/stamplay-js-sdk/stamplay-js-sdk-tests.ts @@ -2,8 +2,8 @@ var userFn = Stamplay.User(); var user = new userFn.Model; - -var tags = new Stamplay.Cobject('tag').Collection; +var colTags = new Stamplay.Cobject('tag'); +var tags = colTags.Collection; // Signing up var registrationData = { @@ -21,7 +21,8 @@ user.signup(registrationData).then(function(){ // Action -var fooMod = new Stamplay.Cobject('foo').Model; +var colFoo = new Stamplay.Cobject('foo'); +var fooMod = colFoo.Model; fooMod.fetch(5).then( function(){ return fooMod.upVote() @@ -29,7 +30,7 @@ fooMod.fetch(5).then( ).then( function(){ //success callback - }, function( err ){ + }, function( err : any ){ //error callback } ) diff --git a/stamplay-js-sdk/stamplay-js-sdk.d.ts b/stamplay-js-sdk/stamplay-js-sdk.d.ts index 50817ee2d..3cd9f3843 100644 --- a/stamplay-js-sdk/stamplay-js-sdk.d.ts +++ b/stamplay-js-sdk/stamplay-js-sdk.d.ts @@ -10,10 +10,10 @@ declare module Stamplay { export interface IStamplayModel { signup({}) : PromisesAPlus.Thenable new() : IStamplayModel - get(property : string) - set(property : string, value: any) - unset(property : string) - fetch(id : any) + get(property : string) : any + set(property : string, value: any) : void + unset(property : string) : void + fetch(id : any) : PromisesAPlus.Thenable destroy() : PromisesAPlus.Thenable save({}?) : PromisesAPlus.Thenable } diff --git a/stamplay-js-sdk/tsconfig.json b/stamplay-js-sdk/tsconfig.json new file mode 100644 index 000000000..8d5b43ce4 --- /dev/null +++ b/stamplay-js-sdk/tsconfig.json @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "target": "ES5", + "module": "amd" + } +} From c2c6dfa673ce234c7427ce7f53034f4ca1b99665 Mon Sep 17 00:00:00 2001 From: ridermansb Date: Wed, 23 Sep 2015 07:51:23 -0300 Subject: [PATCH 17/64] Change object user to object model --- stamplay-js-sdk/stamplay-js-sdk-tests.ts | 8 ++++---- stamplay-js-sdk/stamplay-js-sdk.d.ts | 14 ++++++-------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/stamplay-js-sdk/stamplay-js-sdk-tests.ts b/stamplay-js-sdk/stamplay-js-sdk-tests.ts index 644d2c5b9..bfc229d49 100644 --- a/stamplay-js-sdk/stamplay-js-sdk-tests.ts +++ b/stamplay-js-sdk/stamplay-js-sdk-tests.ts @@ -2,8 +2,8 @@ var userFn = Stamplay.User(); var user = new userFn.Model; -var colTags = new Stamplay.Cobject('tag'); -var tags = colTags.Collection; +var colTags = Stamplay.Cobject('tag'); +var tags = new colTags.Collection(); // Signing up var registrationData = { @@ -21,8 +21,8 @@ user.signup(registrationData).then(function(){ // Action -var colFoo = new Stamplay.Cobject('foo'); -var fooMod = colFoo.Model; +var colFoo = Stamplay.Cobject('foo'); +var fooMod = new colFoo.Model(); fooMod.fetch(5).then( function(){ return fooMod.upVote() diff --git a/stamplay-js-sdk/stamplay-js-sdk.d.ts b/stamplay-js-sdk/stamplay-js-sdk.d.ts index 3cd9f3843..2eb62206b 100644 --- a/stamplay-js-sdk/stamplay-js-sdk.d.ts +++ b/stamplay-js-sdk/stamplay-js-sdk.d.ts @@ -16,20 +16,18 @@ declare module Stamplay { fetch(id : any) : PromisesAPlus.Thenable destroy() : PromisesAPlus.Thenable save({}?) : PromisesAPlus.Thenable + upVote() : PromisesAPlus.Thenable } - export interface IStamplayAction { - new() : IStamplayModel - upVote() : PromisesAPlus.Thenable - } - - export interface IStamplayUser { + export interface IStamplayObject { Model : IStamplayModel + Collection : any + } export interface StamplayStatic { - User() : IStamplayUser - Cobject(collection : string) : void + User() : IStamplayObject + Cobject(object : string) : IStamplayObject } } From 1942dfab9229362cf9fd69a48814a59def7c1daf Mon Sep 17 00:00:00 2001 From: ridermansb Date: Wed, 23 Sep 2015 07:52:56 -0300 Subject: [PATCH 18/64] Fix linebreak --- stamplay-js-sdk/stamplay-js-sdk.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stamplay-js-sdk/stamplay-js-sdk.d.ts b/stamplay-js-sdk/stamplay-js-sdk.d.ts index 2eb62206b..154dc414e 100644 --- a/stamplay-js-sdk/stamplay-js-sdk.d.ts +++ b/stamplay-js-sdk/stamplay-js-sdk.d.ts @@ -1,5 +1,5 @@ // Type definitions for stamplay-js-sdk 1.2.9 -// Project: https://github.com/Stamplay/stamplay-js-sdk and https://stamplay.com/docs/jssdk#api-ref-model +// Project: https://github.com/Stamplay/stamplay-js-sdk // Definitions by: Riderman de Sousa Barbosa // Definitions: https://github.com/borisyankov/DefinitelyTyped From d01d6a3ec477bdf9cfcc3be0f4a8b1211526f661 Mon Sep 17 00:00:00 2001 From: Justin Unterreiner Date: Wed, 23 Sep 2015 15:31:47 -0700 Subject: [PATCH 19/64] Added definitions for the Urban Airship Cordova/Phonegap plugin --- phonegap-ua-push/phonegap-ua-push-tests.ts | 104 +++++ phonegap-ua-push/phonegap-ua-push.d.ts | 474 +++++++++++++++++++++ 2 files changed, 578 insertions(+) create mode 100644 phonegap-ua-push/phonegap-ua-push-tests.ts create mode 100644 phonegap-ua-push/phonegap-ua-push.d.ts diff --git a/phonegap-ua-push/phonegap-ua-push-tests.ts b/phonegap-ua-push/phonegap-ua-push-tests.ts new file mode 100644 index 000000000..f9ac96c44 --- /dev/null +++ b/phonegap-ua-push/phonegap-ua-push-tests.ts @@ -0,0 +1,104 @@ +/// + +//#region Basic Example taken from http://docs.urbanairship.com/platform/phonegap.html#actions + +// Register for any Urban Airship events +document.addEventListener("urbanairship.registration", function (event: UrbanAirshipPlugin.RegistrationEvent) { + if (event.error) { + console.log("There was an error registering for push notifications"); + } else { + console.log("Registered with channel ID: " + event.channelID); + console.log("Registered with device token: " + event.deviceToken); + } +}); + +document.addEventListener("urbanairship.push", function (event: UrbanAirshipPlugin.PushEvent) { + console.log("Incoming push: " + event.message); +}); + +// Set tags on a device, that you can push to +UAirship.setTags(["loves_cats", "shops_for_games"], function () { + UAirship.getTags(function (tags: string[]) { + tags.forEach(function (tag: string) { + console.log("Tag: " + tag); + }); + }); +}); + +// Set an alias, this lets you tie a device to a user in your system +UAirship.setAlias("awesomeuser22", function () { + UAirship.getAlias(function (alias: string) { + console.log("The user formerly known as " + alias); + }); +}); + +// Enable user notifications (will prompt the user to accept push notifications) +UAirship.setUserNotificationsEnabled(true, function (status: string) { + console.log("User notifications are enabled! Fire away!"); +}); + +//#endregion + +//#region Method signatures and parameter types + +UAirship.setUserNotificationsEnabled(true, (status: string) => {}); +UAirship.isUserNotificationsEnabled((enabled: boolean) => {}); +UAirship.getChannelID((id: string) => {}); + +UAirship.getLaunchNotification(true, (push: UrbanAirshipPlugin.PushEvent) => { + var message: string = push.message; + var extras: { [key: string]: any; } = push.extras; +}); + +UAirship.setQuietTimeEnabled(true, () => {}); +UAirship.isQuietTimeEnabled((enabled: boolean) => {}); +UAirship.setQuietTime(1, 1, 1, 1, () => {}); +UAirship.getQuietTime((quietTime: UrbanAirshipPlugin.QuietTimeTimeSpan) => {}); +UAirship.isInQuietTime((inQuietTime: boolean) => {}); + +UAirship.setNotificationTypes(UAirship.notificationType.sound, () => {}); +UAirship.setNotificationTypes(UAirship.notificationType.alert, () => {}); +UAirship.setNotificationTypes(UAirship.notificationType.badge, () => {}); +UAirship.setNotificationTypes(UAirship.notificationType.sound | UAirship.notificationType.badge, () => {}); + +UAirship.setAutobadgeEnabled(true, () => {}); +UAirship.setBadgeNumber(1, () => {}); +UAirship.getBadgeNumber((badgeNumber: number) => {}); +UAirship.resetBadge(() => {}); +UAirship.clearNotifications(() => {}); +UAirship.setSoundEnabled(true, () => {}); +UAirship.isSoundEnabled((enabled: boolean) => { var isEnabled: boolean = enabled; }); +UAirship.setVibrateEnabled(true, () => {}); +UAirship.isVibrateEnabled((enabled: boolean) => { var isEnabled: boolean = enabled; }); +UAirship.setTags(["a", "b", "c"], () => {}); +UAirship.getTags((tags: string[]) => { var results: string[] = tags; }); +UAirship.setAlias("a", () => {}); +UAirship.getAlias((alias: string) => { var result: string = alias; }) +UAirship.setNamedUser("a", () => {}); +UAirship.getNamedUser((namedUserId: string) => { var result: string = namedUserId; }); + +UAirship.editNamedUserTagGroups() + .addTags("loyalty", ["platinum-member", "gold-member"]) + .removeTags("loyalty", ["silver-member", "bronze-member"]) + .apply(); + +UAirship.editChannelTagGroups() + .addTags("loyalty", ["platinum-member", "gold-member"]) + .removeTags("loyalty", ["silver-member", "bronze-member"]) + .apply(); + +UAirship.setAnalyticsEnabled(true, () => {}); +UAirship.isAnalyticsEnabled((enabled: boolean) => { var result: boolean = enabled; }); + +UAirship.runAction("a", "b", (result: UrbanAirshipPlugin.RunActionResult) => { + var error: string = result.error; + var value: any = result.value; +}); + +UAirship.setLocationEnabled(true, () => {}); +UAirship.isLocationEnabled((enabled: boolean) => { var result: boolean = enabled; }); +UAirship.setBackgroundLocationEnabled(true, () => {}); +UAirship.isBackgroundLocationEnabled(() => {}); +UAirship.recordCurrentLocation(() => {}); + +//#endregion \ No newline at end of file diff --git a/phonegap-ua-push/phonegap-ua-push.d.ts b/phonegap-ua-push/phonegap-ua-push.d.ts new file mode 100644 index 000000000..c4a57d92b --- /dev/null +++ b/phonegap-ua-push/phonegap-ua-push.d.ts @@ -0,0 +1,474 @@ +// Type definitions for phonegap-ua-push 3.4.1 +// Project: https://github.com/urbanairship/phonegap-ua-push +// Definitions by: Justin Unterreiner +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +//#region API Types + +/** + * This is a wrapper "namespace" for the various types used by the UAirship module. + */ +declare module UrbanAirshipPlugin { + + //#region API Definitions + + /** + * Describes the chainable API object returned by editNamedUserTagGroups(). + */ + interface EditNamedUserTagGroupsApi { + + /** + * Used to add the given tags to the given tag group. + * + * @param tagGroup The tag group to add tags to. + * @param tags The tags to add to the group. + * + * @returns The chainable API instance. + */ + addTags: (tagGroup: string, tags: string[]) => EditNamedUserTagGroupsApi; + + /** + * Used to remove the given tags from the given tag group. + * + * @param tagGroup The tag group to remove tags from. + * @param tags The tags to remove from the group. + * + * @returns The chainable API instance. + */ + removeTags: (tagGroup: string, tags: string[]) => EditNamedUserTagGroupsApi; + + /** + * Used to apply the changes from the chained API call. + * + * @param callback The optional function to call on completion. + */ + apply: (callback?: () => void) => void; + } + + /** + * Describes the chainable API object returned by editChannelTagGroups(). + */ + interface EditChannelTagGroupsApi { + + /** + * Used to add the given tags to the given tag group. + * + * @param tagGroup The tag group to add tags to. + * @param tags The tags to add to the group. + * + * @returns The chainable API instance. + */ + addTags: (tagGroup: string, tags: string[]) => EditChannelTagGroupsApi; + + /** + * Used to remove the given tags from the given tag group. + * + * @param tagGroup The tag group to remove tags from. + * @param tags The tags to remove from the group. + * + * @returns The chainable API instance. + */ + removeTags: (tagGroup: string, tags: string[]) => EditChannelTagGroupsApi; + + /** + * Used to apply the changes from the chained API call. + * + * @param callback The optional function to call on completion. + */ + apply: (callback?: () => void) => void; + } + + //#endregion + + //#region Data Types + + interface PushEvent extends Event { + message: string; + extras: { [key: string]: any }; + } + + interface RegistrationEvent extends Event { + + error: string; + + /** + * The channel ID for the device. + */ + channelID: string; + + /** + * (iOS Only) + * + * The push token for the device. + */ + deviceToken: string; + } + + /** + * Represents a timespan during which notifications should be silenced. + * + * For example, 10PM - 6AM would be: + * { startHour: 22, startMinute: 0, endHour: 6, endMinute: 0 } + */ + interface QuietTimeTimeSpan { + startHour: number, + startMinute: number, + endHour: number, + endMinute: number + } + + /** + * The result of the runAction() call. + */ + interface RunActionResult { + error: string; + value: any; + } + + //#endregion +} + +//#endregion + +//#region UAirship Global Module + +/** + * Urban Airship plugin. + */ +declare module UAirship { + + export enum notificationType { + sound, + alert, + badge + } + + /** + * Enables or disables user notifications on the device. + * This will prompt users to opt-in to notifications on iOS. + * + * @param enabled Set to true to enable notifications, false to disable. + * @param callback The function to call on completion. + */ + export function setUserNotificationsEnabled(enabled: boolean, callback: (status: string) => void): void; + + /** + * Checks if user notifications are enabled or not. + * + * @param callback The function to call on completion. + */ + export function isUserNotificationsEnabled(callback: (enabled: boolean) => void): void; + + /** + * Get the push identifier for the device. The channel ID is used to send + * messages to the device for testing, and is the canonical identifier for + * the device in Urban Airship. + * + * @param callback The function to call on completion. + */ + export function getChannelID(callback: (id: string) => void): void; + + /** + * Returns the push message object that contains the data associated with a + * push notification. The extras dictionary can contain arbitrary key/value + * data that you use in your application. + * + * @param clear Set to true to clear the notification. + * @param callback The function to call on completion. + */ + export function getLaunchNotification(clear: boolean, callback: (push: UrbanAirshipPlugin.PushEvent) => void): void; + + /** + * Enables or disables quiet time. + * + * @param enabled Set to true to enable quiet time, false to disable. + * @param callback The function to call on completion. + */ + export function setQuietTimeEnabled(enabled: boolean, callback: () => void): void; + + /** + * Checks if quiet time is enabled or not. + * + * @param callback The function to call on completion. + */ + export function isQuietTimeEnabled(callback: (enabled: boolean) => void): void; + + /** + * Set the quiet time for the device. + * + * @param startHour The start hour for quiet time. + * @param startMinute The start minute for quiet time. + * @param endHour The end hour for quiet time. + * @param endMinute the end minute for quiet time. + * @param callback The function to call on completion. + */ + export function setQuietTime(startHour: number, startMinute: number, endHour: number, endMinute: number, callback: () => void): void; + + /** + * Get the current quiet time. The quietTime object represents a timespan + * during which notifications should be silenced. The typical use case is + * to expose a preference to your users so that they can enable this setting + * and specify an interval during which they do not wish to be disturbed. + * + * @param callback The function to call on completion. + */ + export function getQuietTime(callback: (quietTime: UrbanAirshipPlugin.QuietTimeTimeSpan) => void): void; + + /** + * Checks if quiet time is currently in effect. + * + * @param callback The function to call on completion. + */ + export function isInQuietTime(callback: (inQuietTime: boolean) => void): void; + + /** + * (iOS Only) + * + * On iOS, registration for push requires specifying what + * combination of badges, sound and alerts are desired. This function + * must be explicitly called in order to begin the registration process. + * + * For example: + * + * UAirship.setNotificationTypes(UAirship.notificationType.sound | + * UAirship.notificationType.alert); + * + * @param bitmask The notification types to set. + * @param callback The function to call on completion. + */ + export function setNotificationTypes(bitmask: UAirship.notificationType, callback: () => void): void; + + /** + * (iOS Only) + * + * Set whether the UA Autobadge feature is enabled. + * + * @param enabled Set to true to enable Autobadge, false to disable. + * @param callback The function to call on completion. + */ + export function setAutobadgeEnabled(enabled: boolean, callback: () => void): void; + + /** + * (iOS Only) + * + * Set the current application badge number. + * + * @param badge The number to use for the badge. + * @param callback The function to call on completion. + */ + export function setBadgeNumber(badge: number, callback: () => void): void; + + /** + * (iOS Only) + * + * Gets the current application badge number. + * + * @param callback The function to call on completion. + */ + export function getBadgeNumber(callback: (badgeNumber: number) => void): void; + + /** + * (iOS Only) + * + * Reset the badge number to zero. + * + * @param callback The function to call on completion. + */ + export function resetBadge(callback: () => void): void; + + /** + * (Android Only) + * + * Clears the notifications posted by the application. + * + * @param callback The function to call on completion. + */ + export function clearNotifications(callback: () => void): void; + + /** + * (Android only, iOS sound settings come in the push) + * + * Set whether the device makes sound on push. + * + * @param enabled Set to true to enable sound, false to disable. + * @param callback The function to call on completion. + */ + export function setSoundEnabled(enabled: boolean, callback: () => void): void; + + /** + * (Android Only) + * + * Checks if sound is enabled or not. + * + * @param callback The function to call on completion. + */ + export function isSoundEnabled(callback: (enabled: boolean) => void): void; + + /** + * (Android Only) + * + * Set whether the device vibrates on push. + * + * @param enabled Set to true to enable vibration, false to disable. + * @param callback The function to call on completion. + */ + export function setVibrateEnabled(enabled: boolean, callback: () => void): void; + + /** + * (Android Only) + * + * Checks if vibration is enabled or not. + * + * @param callback The function to call on completion. + */ + export function isVibrateEnabled(callback: (enabled: boolean) => void): void; + + /** + * Sets tags for the device. + * + * @param tags An array of tags. + * @param callback The function to call on completion. + */ + export function setTags(tags: string[], callback: () => void): void; + + /** + * Returns the tags for the device. + * + * @param callback The function to call on completion. + */ + export function getTags(callback: (tags: string[]) => void): void; + + /** + * Set alias for the device. + * + * @param alias The alias to set for this device. + * @param callback The function to call on completion. + */ + export function setAlias(alias: string, callback: () => void): void; + + /** + * Gets the alias for this device. + * + * @param callback The function to call on completion. + */ + export function getAlias(callback: (alias: string) => void): void; + + /** + * Set the named user ID for this device. + * + * @param namedUser The named user ID. + * @param callback The function to call on completion. + */ + export function setNamedUser(namedUserId: string, callback: () => void): void; + + /** + * Gets the named user ID for this device. + * + * @param callback The function to call on completion. + */ + export function getNamedUser(callback: (namedUserId: string) => void): void; + + /** + * Fluent API to edit the named user tag groups by adding or removing + * tags, then applying the changes. + * + * For example: + * + * UAirship.editNamedUserTagGroups() + * .addTags("loyalty", ["platinum-member", "gold-member"]) + * .removeTags("loyalty", ["silver-member", "bronze-member"]) + * .apply() + * + * @returns The chainable API instance. + */ + export function editNamedUserTagGroups(): UrbanAirshipPlugin.EditNamedUserTagGroupsApi; + + /** + * Fluent API to edit the channel tag groups by adding or removing tags, + * then applying the changes. + * + * For exmaple: + * + * UAirship.editChannelTagGroups() + * .addTags("loyalty", ["platinum-member", "gold-member"]) + * .removeTags("loyalty", ["silver-member", "bronze-member"]) + * .apply() + */ + export function editChannelTagGroups(): UrbanAirshipPlugin.EditChannelTagGroupsApi; + + /** + * Enables or disables analytics. Disabling analytics will delete any + * locally stored events and prevent any events from uploading. Features + * that depend on analytics being enabled may not work properly if it’s + * disabled (reports, region triggers, location segmentation, push to + * local time). + * + * @param enabled Set to true to enable analytics, false to disable. + * @param callback The function to call on completion. + */ + export function setAnalyticsEnabled(enabled: boolean, callback: () => void): void; + + /** + * Checks if analytics is enabled or not. + * + * @param callback The function to call on completion. + */ + export function isAnalyticsEnabled(callback: (enabled: boolean) => void): void; + + /** + * Runs an Urban Airship action. + * + * @param actionName The name of the action to run. + * @param actionValue The value for the action. + * @param callback The function to call on completion. + */ + export function runAction(actionName: string, actionValue: string, callback: (result: UrbanAirshipPlugin.RunActionResult) => void): void; + + /** + * Enables or disables Urban Airship location services on the device. + * + * @param enabled Set to true to enable location, false to disable. + * @param callback The function to call on completion. + */ + export function setLocationEnabled(enabled: boolean, callback: () => void): void; + + /** + * Checks if location is enabled or not. + * + * @param callback The function to call on completion. + */ + export function isLocationEnabled(callback: (enabled: boolean) => void): void; + + /** + * Enables or disables background location on the device. + * + * @param enabled Set to true to enable background location, false to disable. + * @param callback The function to call on completion. + */ + export function setBackgroundLocationEnabled(enabled: boolean, callback: () => void): void; + + /** + * Checks if background location updates are enabled or not. + * + * @param callback The function to call on completion. + */ + export function isBackgroundLocationEnabled(callback: () => void): void; + + /** + * Records the current location of the device. + * + * @param callback The function to call on completion. + */ + export function recordCurrentLocation(callback: () => void): void; +} + +//#endregion + +//#region Additional Document Events + +interface Document { + addEventListener(type: "urbanairship.push", listener: (ev: UrbanAirshipPlugin.PushEvent) => void, useCapture?: boolean): void; + addEventListener(type: "urbanairship.registration", listener: (ev: UrbanAirshipPlugin.RegistrationEvent) => void, useCapture?: boolean): void; +} + +//#endregion \ No newline at end of file From 8735a5278421929abf00ceb441397841d7ca417f Mon Sep 17 00:00:00 2001 From: Ralph Date: Thu, 24 Sep 2015 15:36:00 -0400 Subject: [PATCH 20/64] Added enum definition values to make Intellisense work in Visual Studio. Changed the type of Mapping to functions from enum Changed the type of PathActions members to a user type string from enum --- threejs/three.d.ts | 231 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 201 insertions(+), 30 deletions(-) diff --git a/threejs/three.d.ts b/threejs/three.d.ts index 66601f301..7e17a6db7 100644 --- a/threejs/three.d.ts +++ b/threejs/three.d.ts @@ -1,4 +1,4 @@ -// Type definitions for three.js r71 +// Type definitions for three.js r71 // Project: http://mrdoob.github.com/three.js/ // Definitions by: Kon , Satoru Kimura // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -8,22 +8,186 @@ interface WebGLRenderingContext {} declare module THREE { export var REVISION: string; - // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent.button - export enum MOUSE {LEFT, MIDDLE, RIGHT} + const enum MOUSE { + LEFT = 0, + MIDDLE = 1, + RIGHT = 2, + } // GL STATE CONSTANTS - export enum CullFace { } + const enum CullFace { + None = 0, + Back = 1, + Front = 2, + FrontBack = 3, + } + + + const enum FrontFaceDirection { + CW = 0, + CCW = 1, + } + + // Shadowing Type + const enum ShadowMapType { + Basic = 0, + PCF = 1, + PCFSoft = 2, + } + + // MATERIAL CONSTANTS + + // side + const enum Side { + Front = 0, + Back = 1, + Double = 2, + } + + // shading + const enum Shading { + None = 0, + Flat = 1, + Smooth = 2, + } + + // colors + const enum Colors { + None = 0, + Face = 1, + Vertex = 2, + } + + // blending modes + const enum Blending { + None = 0, + Normal = 1, + Additive = 2, + Subtractive = 3, + Multiply = 4, + Custom = 5, + } + + // custom blending equations + // (numbers start from 100 not to clash with other + // mappings to OpenGL constants defined in Texture.js) + const enum BlendingEquation { + Add = 100, + Subtract = 101, + ReverseSubtract = 102, + } + + // custom blending destination factors + const enum BlendingDstFactor { + Zero = 200, + One = 201, + SrcColor = 202, + OneMinusSrcColor = 203, + SrcAlpha = 204, + OneMinusSrcAlpha = 205, + DstAlpha = 206, + OneMinusDstAlpha = 207, + } + + // custom blending src factors + const enum BlendingSrcFactor { + //Zero = 200, + //One = 201, + //SrcAlpha = 204, + //OneMinusSrcAlpha = 205, + //DstAlpha = 206, + //OneMinusDstAlpha = 207, + DstColor = 208, + OneMinusDstColor = 209, + SrcAlphaSaturate = 210, + } + + // TEXTURE CONSTANTS + // Operations + const enum Combine { + Multiply = 0, + Mix = 1, + Add = 2, + } + + // Mapping modes + interface Mapping {e + new (): { }; + } + var UVMapping: Mapping; + var CubeReflectionMapping: Mapping; + var CubeRefractionMapping: Mapping; + var SphericalReflectionMapping: Mapping; + var SphericalRefractionMapping: Mapping; + + // Wrapping modes + const enum Wrapping { + Repeat = 1000, + ClampToEdge = 1001, + MirroredRepeat = 1002, + } + + // Filters + const enum TextureFilter { + Nearest = 1003, + NearestMipMapNearest = 1004, + NearestMipMapLinear = 1005, + Linear = 1006, + LinearMipMapNearest = 1007, + LinearMipMapLinear = 1008, + } + + // Data types + const enum TextureDataType { + UnsignedByte = 1009, + Byte = 1010, + Short = 1011, + UnsignedShort = 1012, + Int = 1013, + UnsignedInt = 1014, + Float = 1015, + } + + // Pixel types + const enum PixelType { + UnsignedShort4444 = 1016, + UnsignedShort5551 = 1017, + UnsignedShort565 = 1018, + } + + // Pixel formats + const enum PixelFormat { + Alpha = 1019, + RGB = 1020, + RGBA = 1021, + Luminance = 1022, + LuminanceAlpha = 1023, + } + + // Compressed texture formats + const enum CompressedPixelFormat { + RGB_S3TC_DXT1 = 2001, + RGBA_S3TC_DXT1 = 2002, + RGBA_S3TC_DXT3 = 2003, + RGBA_S3TC_DXT5 = 2004, + } + + // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent.button + // export enum MOUSE {LEFT, MIDDLE, RIGHT} + + // GL STATE CONSTANTS + // export enum CullFace { } export var CullFaceNone: CullFace; export var CullFaceBack: CullFace; export var CullFaceFront: CullFace; export var CullFaceFrontBack: CullFace; - export enum FrontFaceDirection { } + // export enum FrontFaceDirection { } export var FrontFaceDirectionCW: FrontFaceDirection; export var FrontFaceDirectionCCW: FrontFaceDirection; // Shadowing Type - export enum ShadowMapType { } + // export enum ShadowMapType { } export var BasicShadowMap: ShadowMapType; export var PCFShadowMap: ShadowMapType; export var PCFSoftShadowMap: ShadowMapType; @@ -31,25 +195,25 @@ declare module THREE { // MATERIAL CONSTANTS // side - export enum Side { } + // export enum Side { } export var FrontSide: Side; export var BackSide: Side; export var DoubleSide: Side; // shading - export enum Shading { } + // export enum Shading { } export var NoShading: Shading; export var FlatShading: Shading; export var SmoothShading: Shading; // colors - export enum Colors { } + // export enum Colors { } export var NoColors: Colors; export var FaceColors: Colors; export var VertexColors: Colors; // blending modes - export enum Blending { } + // export enum Blending { } export var NoBlending: Blending; export var NormalBlending: Blending; export var AdditiveBlending: Blending; @@ -60,7 +224,7 @@ declare module THREE { // custom blending equations // (numbers start from 100 not to clash with other // mappings to OpenGL constants defined in Texture.js) - export enum BlendingEquation { } + // export enum BlendingEquation { } export var AddEquation: BlendingEquation; export var SubtractEquation: BlendingEquation; export var ReverseSubtractEquation: BlendingEquation; @@ -68,7 +232,7 @@ declare module THREE { export var MaxEquation: BlendingEquation; // custom blending destination factors - export enum BlendingDstFactor { } + // export enum BlendingDstFactor { } export var ZeroFactor: BlendingDstFactor; export var OneFactor: BlendingDstFactor; export var SrcColorFactor: BlendingDstFactor; @@ -79,20 +243,25 @@ declare module THREE { export var OneMinusDstAlphaFactor: BlendingDstFactor; // custom blending src factors - export enum BlendingSrcFactor { } + // export enum BlendingSrcFactor { } export var DstColorFactor: BlendingSrcFactor; export var OneMinusDstColorFactor: BlendingSrcFactor; export var SrcAlphaSaturateFactor: BlendingSrcFactor; // TEXTURE CONSTANTS // Operations - export enum Combine { } + // export enum Combine { } export var MultiplyOperation: Combine; export var MixOperation: Combine; export var AddOperation: Combine; // Mapping modes - export enum Mapping { } + // export enum Mapping { } + // These are functions, not enums + export interface Mapping { + new (): {}; + } + export var UVMapping: Mapping; export var CubeReflectionMapping: Mapping; export var CubeRefractionMapping: Mapping; @@ -101,13 +270,13 @@ declare module THREE { export var SphericalReflectionMapping: Mapping; // Wrapping modes - export enum Wrapping { } + // export enum Wrapping { } export var RepeatWrapping: Wrapping; export var ClampToEdgeWrapping: Wrapping; export var MirroredRepeatWrapping: Wrapping; // Filters - export enum TextureFilter { } + // export enum TextureFilter { } export var NearestFilter: TextureFilter; export var NearestMipMapNearestFilter: TextureFilter; export var NearestMipMapLinearFilter: TextureFilter; @@ -116,7 +285,7 @@ declare module THREE { export var LinearMipMapLinearFilter: TextureFilter; // Data types - export enum TextureDataType { } + // export enum TextureDataType { } export var UnsignedByteType: TextureDataType; export var ByteType: TextureDataType; export var ShortType: TextureDataType; @@ -127,13 +296,13 @@ declare module THREE { export var HalfFloatType: TextureDataType; // Pixel types - export enum PixelType { } + // export enum PixelType { } export var UnsignedShort4444Type: PixelType; export var UnsignedShort5551Type: PixelType; export var UnsignedShort565Type: PixelType; // Pixel formats - export enum PixelFormat { } + // export enum PixelFormat { } export var AlphaFormat: PixelFormat; export var RGBFormat: PixelFormat; export var RGBAFormat: PixelFormat; @@ -143,7 +312,7 @@ declare module THREE { // Compressed texture formats // DDS / ST3C Compressed texture formats - export enum CompressedPixelFormat { } + // export enum CompressedPixelFormat { } export var RGB_S3TC_DXT1_Format: CompressedPixelFormat; export var RGBA_S3TC_DXT1_Format: CompressedPixelFormat; export var RGBA_S3TC_DXT3_Format: CompressedPixelFormat; @@ -5290,18 +5459,20 @@ declare module THREE { updateMatrixWorld(force?: boolean): void; } - export enum PathActions { - MOVE_TO, - LINE_TO, - QUADRATIC_CURVE_TO, // Bezier quadratic curve - BEZIER_CURVE_TO, // Bezier cubic curve - CSPLINE_THRU, // Catmull-rom spline - ARC, // Circle - ELLIPSE, + export type PathAct = string; // these are strings not enums + + export interface PathActions { + MOVE_TO: PathAct; + LINE_TO: PathAct; + QUADRATIC_CURVE_TO: PathAct; // Bezier quadratic curve + BEZIER_CURVE_TO: PathAct; // Bezier cubic curve + CSPLINE_THRU: PathAct; // Catmull-rom spline + ARC: PathAct; // Circle + ELLIPSE: PathAct; } export interface PathAction { - action: PathActions; + action: PathAct; args: any; } From ebe527eecc1216759385beef9cc53ce604953523 Mon Sep 17 00:00:00 2001 From: Igor Sechyn Date: Fri, 25 Sep 2015 15:30:25 +1000 Subject: [PATCH 21/64] Added definition for the hystrixjs library --- hystrixjs/hystrixjs-tests.ts | 86 ++++++++++++++++++++ hystrixjs/hystrixjs.d.ts | 148 +++++++++++++++++++++++++++++++++++ 2 files changed, 234 insertions(+) create mode 100644 hystrixjs/hystrixjs-tests.ts create mode 100644 hystrixjs/hystrixjs.d.ts diff --git a/hystrixjs/hystrixjs-tests.ts b/hystrixjs/hystrixjs-tests.ts new file mode 100644 index 000000000..80f840861 --- /dev/null +++ b/hystrixjs/hystrixjs-tests.ts @@ -0,0 +1,86 @@ +/// +/// + +import hystrixjs = require('hystrixjs'); +import q = require('q'); + +var commandFactory = hystrixjs.commandFactory; + +var command = commandFactory + .getOrCreate('testCommand', 'testGroup') + .circuitBreakerSleepWindowInMilliseconds(5000) + .errorHandler((error) => { + return false; + }) + .timeout(3000) + .circuitBreakerRequestVolumeThreshold(10) + .requestVolumeRejectionThreshold(10) + .circuitBreakerForceOpened(true) + .circuitBreakerForceClosed(false) + .statisticalWindowNumberOfBuckets(10) + .statisticalWindowLength(10) + .percentileWindowNumberOfBuckets(10) + .percentileWindowLength(60) + .circuitBreakerErrorThresholdPercentage(30) + .fallbackTo((error) => { + return q.resolve('fallback'); + }) + .run((args) => { + return q.resolve(args); + }) + .build(); + +command.execute('something').then((result) => { + console.log(result); +}) + +commandFactory.resetCache(); + +var metricsFactory = hystrixjs.metricsFactory; + +var metrics = metricsFactory.getOrCreate({ + commandKey: 'metricsKey', + commandGroup: 'metricsGroup' +}) +metrics.markSuccess(); +metrics.markFailure(); +metrics.markRejected(); +metrics.markTimeout(); +metrics.incrementExecutionCount(); +metrics.decrementExecutionCount(); +metrics.getCurrentExecutionCount(); +metrics.addExecutionTime(3000); +metrics.getRollingCount("FAILURE"); +var healthcounts = metrics.getHealthCounts(); +console.log(healthcounts.totalCount); +console.log(healthcounts.errorCount); +console.log(healthcounts.errorPercentage); + +metricsFactory.resetCache(); + +metricsFactory.getAllMetrics().map((metrics) => { + console.log(metrics.getCurrentExecutionCount()); +}); + +var hystrixConfig = hystrixjs.hystrixConfig; +console.log(hystrixConfig.metricsPercentileWindowBuckets()); +console.log(hystrixConfig.circuitBreakerForceClosed()); +console.log(hystrixConfig.circuitBreakerForceOpened()); +console.log(hystrixConfig.circuitBreakerSleepWindowInMilliseconds()); +console.log(hystrixConfig.circuitBreakerErrorThresholdPercentage()); +console.log(hystrixConfig.circuitBreakerRequestVolumeThreshold()); +console.log(hystrixConfig.circuitBreakerRequestVolumeThresholdForceOverride()); +console.log(hystrixConfig.circuitBreakerRequestVolumeThresholdOverride()); +console.log(hystrixConfig.executionTimeoutInMilliseconds()); +console.log(hystrixConfig.metricsStatisticalWindowBuckets()); +console.log(hystrixConfig.metricsStatisticalWindowInMilliseconds()); +console.log(hystrixConfig.metricsPercentileWindowInMilliseconds()); +console.log(hystrixConfig.requestVolumeRejectionThreshold()); +console.log(hystrixConfig.resetProperties()); +console.log(hystrixConfig.init({})); + +var hystrixSSEStream = hystrixjs.hystrixSSEStream; + +hystrixSSEStream.toObservable().subscribe((result) => { + console.log(result); +}) diff --git a/hystrixjs/hystrixjs.d.ts b/hystrixjs/hystrixjs.d.ts new file mode 100644 index 000000000..1fd55e7e5 --- /dev/null +++ b/hystrixjs/hystrixjs.d.ts @@ -0,0 +1,148 @@ +// Type definitions for dragula v2.1.2 +// Project: https://bitbucket.org/igor_sechyn/hystrixjs +// Definitions by: Igor Sechyn +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// +/// + +declare module HystrixJS { + + interface HystrixProperties { + "hystrix.force.circuit.open"?: boolean, + "hystrix.force.circuit.closed"?: boolean, + "hystrix.circuit.sleepWindowInMilliseconds"?:number, + "hystrix.circuit.errorThresholdPercentage"?: number, + "hystrix.circuit.volumeThreshold"?:number, + "hystrix.circuit.volumeThreshold.forceOverride"?: boolean, + "hystrix.circuit.volumeThreshold.override"?: number, + "hystrix.execution.timeoutInMilliseconds"?: number, + "hystrix.metrics.statistical.window.timeInMilliseconds"?: number, + "hystrix.metrics.statistical.window.bucketsNumber"?: number, + "hystrix.metrics.percentile.window.timeInMilliseconds"?: number, + "hystrix.metrics.percentile.window.bucketsNumber"?: number, + "hystrix.request.volume.rejectionThreshold"?: number + } + + interface HystrixConfig { + metricsPercentileWindowBuckets(): number; + circuitBreakerForceClosed(): boolean; + circuitBreakerForceOpened(): boolean; + circuitBreakerSleepWindowInMilliseconds(): number; + circuitBreakerErrorThresholdPercentage(): number; + circuitBreakerRequestVolumeThreshold(): number; + circuitBreakerRequestVolumeThresholdForceOverride(): boolean; + circuitBreakerRequestVolumeThresholdOverride(): number; + executionTimeoutInMilliseconds(): number; + metricsStatisticalWindowBuckets(): number; + metricsStatisticalWindowInMilliseconds(): number; + metricsPercentileWindowInMilliseconds(): number; + metricsPercentileWindowBuckets(): number; + requestVolumeRejectionThreshold(): number; + resetProperties(): void; + init(properties: HystrixProperties): void; + } + + interface Command { + execute(...args: any[]): Q.Promise; + } + + interface CommandBuilder { + circuitBreakerSleepWindowInMilliseconds(value: number): CommandBuilder; + errorHandler(value: (error: any) => boolean): CommandBuilder; + timeout(value: number): CommandBuilder; + circuitBreakerRequestVolumeThreshold(value: number): CommandBuilder; + requestVolumeRejectionThreshold(value: number): CommandBuilder; + circuitBreakerForceOpened(value: boolean): CommandBuilder; + circuitBreakerForceClosed(value: boolean): CommandBuilder; + statisticalWindowNumberOfBuckets(value: number): CommandBuilder; + statisticalWindowLength(value: number): CommandBuilder; + percentileWindowNumberOfBuckets(value: number): CommandBuilder; + percentileWindowLength(value: number): CommandBuilder; + circuitBreakerErrorThresholdPercentage(value: number): CommandBuilder; + run(value: (args: any) => Q.Promise): CommandBuilder; + fallbackTo(value: (...args: any[]) => Q.Promise): CommandBuilder; + context(value: any): CommandBuilder; + build(): Command; + } + + interface CommandFactory { + getOrCreate(commandKey: string, commandGroup?: string): CommandBuilder; + resetCache(): void; + } + + interface HealthCounts { + totalCount: number; + errorCount: number; + errorPercentage: number; + } + + interface CommandMetrics { + markSuccess(): void; + markRejected(): void; + markFailure(): void; + markTimeout(): void; + markShortCircuited(): void; + incrementExecutionCount(): void; + decrementExecutionCount(): void; + getCurrentExecutionCount(): number; + addExecutionTime(value: number): void; + getRollingCount(type: any): number; + getExecutionTime(percentile: any): number; + getHealthCounts(): HealthCounts; + reset(): void; + } + + interface MetricsProperties { + commandKey: string, + commandGroup: string, + statisticalWindowTimeInMilliSeconds?: number, + statisticalWindowNumberOfBuckets?: number, + percentileWindowTimeInMilliSeconds?: number, + percentileWindowNumberOfBuckets?: number + } + + interface MetricsFactory { + getOrCreate(config: MetricsProperties): CommandMetrics; + resetCache(): void; + getAllMetrics(): Array; + } + + interface CirctuiBreakerConfig { + circuitBreakerSleepWindowInMilliseconds: number, + commandKey: string, + circuitBreakerErrorThresholdPercentage: number, + circuitBreakerRequestVolumeThreshold: number, + commandGroup: string, + circuitBreakerForceClosed: boolean, + circuitBreakerForceOpened: boolean + } + + interface CircuitBreaker { + allowRequest(): boolean; + allowSingleTest(): boolean; + isOpen(): boolean; + markSuccess(): void; + } + + interface CircuitFactory { + getOrCreate(config: CirctuiBreakerConfig): CircuitBreaker; + getCache(): Array; + resetCache(): void; + } + + interface HystrixSSEStream { + toObservable(): Rx.Observable + } +} +declare var hystrixjs: { + commandFactory: HystrixJS.CommandFactory, + metricsFactory: HystrixJS.MetricsFactory, + circuitFactory: HystrixJS.CircuitFactory, + hystrixSSEStream: HystrixJS.HystrixSSEStream, + hystrixConfig: HystrixJS.HystrixConfig +}; + +declare module "hystrixjs" { + export = hystrixjs; +} From 9866dda46eae3d5aa6f0c876942e025297a05581 Mon Sep 17 00:00:00 2001 From: Igor Sechyn Date: Fri, 25 Sep 2015 15:37:59 +1000 Subject: [PATCH 22/64] added travis build hook --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c17e2f724..41b35dd81 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# DefinitelyTyped [![Build Status](https://travis-ci.org/borisyankov/DefinitelyTyped.png?branch=master)](https://travis-ci.org/borisyankov/DefinitelyTyped) +# DefinitelyTyped [![Build Status](https://travis-ci.org/igorsechyn/DefinitelyTyped.png?branch=hystrixjs_definition)](https://travis-ci.org/borisyankov/DefinitelyTyped) [![Join the chat at https://gitter.im/borisyankov/DefinitelyTyped](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/borisyankov/DefinitelyTyped?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) From ec96f4e404fb227e5ba797c17d97048ff9d316bb Mon Sep 17 00:00:00 2001 From: Igor Sechyn Date: Fri, 25 Sep 2015 15:40:08 +1000 Subject: [PATCH 23/64] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 41b35dd81..770777117 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# DefinitelyTyped [![Build Status](https://travis-ci.org/igorsechyn/DefinitelyTyped.png?branch=hystrixjs_definition)](https://travis-ci.org/borisyankov/DefinitelyTyped) +# DefinitelyTyped [![Build Status](https://travis-ci.org/igorsechyn/DefinitelyTyped.png?branch=hystrixjs_definition)](https://travis-ci.org/igorsechyn/DefinitelyTyped) [![Join the chat at https://gitter.im/borisyankov/DefinitelyTyped](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/borisyankov/DefinitelyTyped?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) From dc499c125d2319a4d78438945d0cbfd6bc48c763 Mon Sep 17 00:00:00 2001 From: Ralph Date: Fri, 25 Sep 2015 12:04:38 -0400 Subject: [PATCH 24/64] Fixed the implicit any and made several of the DataTexture constructor's arguments optional. --- threejs/three.d.ts | 56 +++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/threejs/three.d.ts b/threejs/three.d.ts index 7e17a6db7..a381715c5 100644 --- a/threejs/three.d.ts +++ b/threejs/three.d.ts @@ -1,7 +1,7 @@ // Type definitions for three.js r71 // Project: http://mrdoob.github.com/three.js/ // Definitions by: Kon , Satoru Kimura -// Definitions: https://github.com/borisyankov/DefinitelyTyped +// Definitions: https://github.com/borisyankov/DefinitelyTyped interface WebGLRenderingContext {} @@ -110,8 +110,8 @@ declare module THREE { Add = 2, } - // Mapping modes - interface Mapping {e + // Mapping modes + interface Mapping { new (): { }; } var UVMapping: Mapping; @@ -755,21 +755,21 @@ declare module THREE { * * # Example * var Car = function () { - * + * * EventDispatcher.call( this ); * this.start = function () { - * + * * this.dispatchEvent( { type: 'start', message: 'vroom vroom!' } ); - * + * * }; - * + * * }; * * var car = new Car(); * car.addEventListener( 'start', function ( event ) { - * + * * alert( event.message ); - * + * * } ); * car.start(); * @@ -1391,7 +1391,7 @@ declare module THREE { getObjectByName(name: string): Object3D; getObjectByProperty( name: string, value: string ): Object3D; - + getWorldPosition(optionalTarget?: Vector3): Vector3; getWorldQuaternion(optionalTarget?: Quaternion): Quaternion; getWorldRotation(optionalTarget?: Euler): Euler; @@ -1913,16 +1913,16 @@ declare module THREE { add(regex:string, loader:Loader):void; get(file: string):Loader; } - + export class BinaryTextureLoader { constructor(); - + load(url: string, onLoad: (dataTexture: DataTexture) => void, onProgress?: (event: any) => void, onError?: (event: any) => void): void; } export class BufferGeometryLoader { constructor(manager?: LoadingManager); - + manager: LoadingManager; load(url: string, onLoad: (bufferGeometry: BufferGeometry) => void, onProgress?: (event: any) => void, onError?: (event: any) => void): void; setCrossOrigin(crossOrigin: string): void; @@ -2060,10 +2060,10 @@ declare module THREE { */ export class TextureLoader { constructor(manager?: LoadingManager); - + manager: LoadingManager; crossOrigin: string; - + /** * Begin loading from url * @@ -3482,8 +3482,8 @@ declare module THREE { */ multiplyQuaternions(a: Quaternion, b: Quaternion): Quaternion; - /** - * Deprecated. Use Vector3.applyQuaternion instead + /** + * Deprecated. Use Vector3.applyQuaternion instead */ multiplyVector3(vector: Vector3): Vector3; slerp(qb: Quaternion, t: number): Quaternion; @@ -4414,7 +4414,7 @@ declare module THREE { normalizeSkinWeights(): void; updateMatrixWorld(force?: boolean): void; clone(object?: SkinnedMesh): SkinnedMesh; - + skeleton: Skeleton; } @@ -5088,13 +5088,13 @@ declare module THREE { data: ImageData, width: number, height: number, - format: PixelFormat, - type: TextureDataType, - mapping: Mapping, - wrapS: Wrapping, - wrapT: Wrapping, - magFilter: TextureFilter, - minFilter: TextureFilter, + format?: PixelFormat, + type?: TextureDataType, + mapping?: Mapping, + wrapS?: Wrapping, + wrapT?: Wrapping, + magFilter?: TextureFilter, + minFilter?: TextureFilter, anisotropy?: number ); @@ -5841,8 +5841,8 @@ declare module THREE { heightScale: number; }; } - - + + export class TubeGeometry extends Geometry { constructor(path: Path, segments?: number, radius?: number, radiusSegments?: number, closed?: boolean, taper?: (u: number) => number); @@ -5861,7 +5861,7 @@ declare module THREE { static NoTaper(u?: number): number; static SinusoidalTaper(u: number): number; static FrenetFrames(path: Path, segments: number, closed: boolean): void; - + } // Extras / Helpers ///////////////////////////////////////////////////////////////////// From 72d767a35cd543e4f74c69fd93e1cea529e11669 Mon Sep 17 00:00:00 2001 From: Ralph Date: Fri, 25 Sep 2015 15:28:56 -0400 Subject: [PATCH 25/64] Initial version of webcl definitions file. --- webcl/webcl-tests.ts | 626 ++++++++++++++++++++++++++++++++++++++ webcl/webcl.d.ts | 706 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 1332 insertions(+) create mode 100644 webcl/webcl-tests.ts create mode 100644 webcl/webcl.d.ts diff --git a/webcl/webcl-tests.ts b/webcl/webcl-tests.ts new file mode 100644 index 000000000..34c3841dd --- /dev/null +++ b/webcl/webcl-tests.ts @@ -0,0 +1,626 @@ +/// +/// + +class CLHException { + constructor( + public message: string + ) { } +} + +class PlatformInfo { + EXTENTION: string; + NAME: string; + PROFILE: string; + VENDOR: string; + VERSION: string; + + constructor( + public platform: WEBCL.WebCLPlatform, + public deviceInfos: DeviceInfo[]= new Array() + ) { + this.PROFILE = platform.getInfo(WEBCL.PlatformInfo.PLATFORM_PROFILE); + this.VERSION = platform.getInfo(WEBCL.PlatformInfo.PLATFORM_VERSION); + this.NAME = platform.getInfo(WEBCL.PlatformInfo.PLATFORM_NAME); + this.VENDOR = platform.getInfo(WEBCL.PlatformInfo.PLATFORM_VENDOR); + this.EXTENTION = platform.getInfo(WEBCL.PlatformInfo.PLATFORM_EXTENSIONS); + } +} + +class DeviceInfo { + ADDRESS_BITS: number; + AVAILABLE: boolean; + COMPILER_AVAILABLE: boolean; + DRIVER_VERSION: string; + ENDIAN_LITTLE: boolean; + ERROR_CORRECTION_SUPPORT: boolean; + EXECUTION_CAPABILITIES: WEBCL.DeviceExecCapabilitiesBits; + EXTENSIONS: string; + GLOBAL_MEM_CACHE_SIZE: number; + GLOBAL_MEM_CACHE_TYPE: WEBCL.DeviceMemCacheType; + GLOBAL_MEM_CACHELINE_SIZE: number; + GLOBAL_MEM_SIZE: number; + HOST_UNIFIED_MEMORY: boolean; + IMAGE_SUPPORT: boolean; + IMAGE2D_MAX_HEIGHT: number; + IMAGE2D_MAX_WIDTH: number; + IMAGE3D_MAX_DEPTH: number; + IMAGE3D_MAX_HEIGHT: number; + IMAGE3D_MAX_WIDTH: number; + LOCAL_MEM_SIZE: number; + LOCAL_MEM_TYPE: WEBCL.DeviceLocalMemType; + MAX_CLOCK_FREQUENCY: number; + MAX_COMPUTE_UNITS: number; + MAX_CONSTANT_ARGS: number; + MAX_CONSTANT_BUFFER_SIZE: number; + MAX_MEM_ALLOC_SIZE: number; + MAX_PARAMETER_SIZE: number; + MAX_READ_IMAGE_ARGS: number; + MAX_SAMPLERS: number; + MAX_WORK_GROUP_SIZE: number; + MAX_WORK_ITEM_DIMENSIONS: number; + MAX_WORK_ITEM_SIZES: number; + MAX_WRITE_IMAGE_ARGS: number; + MEM_BASE_ADDR_ALIGN: number; + NAME: string; + NATIVE_VECTOR_WIDTH_CHAR: number; + NATIVE_VECTOR_WIDTH_FLOAT: number; + NATIVE_VECTOR_WIDTH_INT: number; + NATIVE_VECTOR_WIDTH_LONG: number; + NATIVE_VECTOR_WIDTH_SHORT: number; + OPENCL_C_VERSION: string; + PLATFORM: WEBCL.WebCLPlatform; + PlatformInfo: PlatformInfo; + PREFERRED_VECTOR_WIDTH_CHAR: number; + PREFERRED_VECTOR_WIDTH_FLOAT: number; + PREFERRED_VECTOR_WIDTH_INT: number; + PREFERRED_VECTOR_WIDTH_LONG: number; + PREFERRED_VECTOR_WIDTH_SHORT: number; + PROFILE: string; + PROFILING_TIMER_RESOLUTION: number; + QUEUE_PROPERTIES: WEBCL.CommandQueueProperties; + SINGLE_FP_CONFIG: WEBCL.DeviceFPConfigBits; + TYPE: WEBCL.DeviceTypeBits; + VENDOR: string; + VENDOR_ID: number; + VERSION: string; + + constructor(public device: WEBCL.WebCLDevice, platformInfo: PlatformInfo) { + this.ADDRESS_BITS = device.getInfo(WEBCL.DeviceInfo.DEVICE_ADDRESS_BITS); + this.AVAILABLE = device.getInfo(WEBCL.DeviceInfo.DEVICE_AVAILABLE); + this.COMPILER_AVAILABLE = device.getInfo(WEBCL.DeviceInfo.DEVICE_COMPILER_AVAILABLE); + this.DRIVER_VERSION = device.getInfo(WEBCL.DeviceInfo.DRIVER_VERSION); + this.ENDIAN_LITTLE = device.getInfo(WEBCL.DeviceInfo.DEVICE_ENDIAN_LITTLE); + this.ERROR_CORRECTION_SUPPORT = device.getInfo(WEBCL.DeviceInfo.DEVICE_ERROR_CORRECTION_SUPPORT); + this.EXECUTION_CAPABILITIES = device.getInfo(WEBCL.DeviceInfo.DEVICE_EXECUTION_CAPABILITIES); + this.EXTENSIONS = device.getInfo(WEBCL.DeviceInfo.DEVICE_EXTENSIONS); + this.GLOBAL_MEM_CACHE_SIZE = device.getInfo(WEBCL.DeviceInfo.DEVICE_GLOBAL_MEM_CACHE_SIZE); + this.GLOBAL_MEM_CACHE_TYPE = device.getInfo(WEBCL.DeviceInfo.DEVICE_GLOBAL_MEM_CACHE_TYPE); + this.GLOBAL_MEM_CACHELINE_SIZE = device.getInfo(WEBCL.DeviceInfo.DEVICE_GLOBAL_MEM_CACHELINE_SIZE); + this.GLOBAL_MEM_SIZE = device.getInfo(WEBCL.DeviceInfo.DEVICE_GLOBAL_MEM_SIZE); + this.HOST_UNIFIED_MEMORY = device.getInfo(WEBCL.DeviceInfo.DEVICE_HOST_UNIFIED_MEMORY); + this.IMAGE_SUPPORT = device.getInfo(WEBCL.DeviceInfo.DEVICE_IMAGE_SUPPORT); + this.IMAGE2D_MAX_HEIGHT = device.getInfo(WEBCL.DeviceInfo.DEVICE_IMAGE2D_MAX_HEIGHT); + this.IMAGE2D_MAX_WIDTH = device.getInfo(WEBCL.DeviceInfo.DEVICE_IMAGE2D_MAX_WIDTH); + this.IMAGE3D_MAX_DEPTH = device.getInfo(WEBCL.DeviceInfo.DEVICE_IMAGE3D_MAX_DEPTH); + this.IMAGE3D_MAX_HEIGHT = device.getInfo(WEBCL.DeviceInfo.DEVICE_IMAGE3D_MAX_HEIGHT); + this.IMAGE3D_MAX_WIDTH = device.getInfo(WEBCL.DeviceInfo.DEVICE_IMAGE3D_MAX_WIDTH); + this.LOCAL_MEM_SIZE = device.getInfo(WEBCL.DeviceInfo.DEVICE_LOCAL_MEM_SIZE); + this.LOCAL_MEM_TYPE = device.getInfo(WEBCL.DeviceInfo.DEVICE_LOCAL_MEM_TYPE); + this.MAX_CLOCK_FREQUENCY = device.getInfo(WEBCL.DeviceInfo.DEVICE_MAX_CLOCK_FREQUENCY); + this.MAX_COMPUTE_UNITS = device.getInfo(WEBCL.DeviceInfo.DEVICE_MAX_COMPUTE_UNITS); + this.MAX_CONSTANT_ARGS = device.getInfo(WEBCL.DeviceInfo.DEVICE_MAX_CONSTANT_ARGS); + this.MAX_CONSTANT_BUFFER_SIZE = device.getInfo(WEBCL.DeviceInfo.DEVICE_MAX_CONSTANT_BUFFER_SIZE); + this.MAX_MEM_ALLOC_SIZE = device.getInfo(WEBCL.DeviceInfo.DEVICE_MAX_MEM_ALLOC_SIZE); + this.MAX_PARAMETER_SIZE = device.getInfo(WEBCL.DeviceInfo.DEVICE_MAX_PARAMETER_SIZE); + this.MAX_READ_IMAGE_ARGS = device.getInfo(WEBCL.DeviceInfo.DEVICE_MAX_READ_IMAGE_ARGS); + this.MAX_SAMPLERS = device.getInfo(WEBCL.DeviceInfo.DEVICE_MAX_SAMPLERS); + this.MAX_WORK_GROUP_SIZE = device.getInfo(WEBCL.DeviceInfo.DEVICE_MAX_WORK_GROUP_SIZE); + this.MAX_WORK_ITEM_DIMENSIONS = device.getInfo(WEBCL.DeviceInfo.DEVICE_MAX_WORK_ITEM_DIMENSIONS); + this.MAX_WORK_ITEM_SIZES = device.getInfo(WEBCL.DeviceInfo.DEVICE_MAX_WORK_ITEM_SIZES); + this.MAX_WRITE_IMAGE_ARGS = device.getInfo(WEBCL.DeviceInfo.DEVICE_MAX_WRITE_IMAGE_ARGS); + this.MEM_BASE_ADDR_ALIGN = device.getInfo(WEBCL.DeviceInfo.DEVICE_MEM_BASE_ADDR_ALIGN); + this.NAME = device.getInfo(WEBCL.DeviceInfo.DEVICE_NAME); + this.NATIVE_VECTOR_WIDTH_CHAR = device.getInfo(WEBCL.DeviceInfo.DEVICE_NATIVE_VECTOR_WIDTH_CHAR); + this.NATIVE_VECTOR_WIDTH_FLOAT = device.getInfo(WEBCL.DeviceInfo.DEVICE_NATIVE_VECTOR_WIDTH_FLOAT); + this.NATIVE_VECTOR_WIDTH_INT = device.getInfo(WEBCL.DeviceInfo.DEVICE_NATIVE_VECTOR_WIDTH_INT); + this.NATIVE_VECTOR_WIDTH_LONG = device.getInfo(WEBCL.DeviceInfo.DEVICE_NATIVE_VECTOR_WIDTH_LONG); + this.NATIVE_VECTOR_WIDTH_SHORT = device.getInfo(WEBCL.DeviceInfo.DEVICE_NATIVE_VECTOR_WIDTH_SHORT); + this.OPENCL_C_VERSION = device.getInfo(WEBCL.DeviceInfo.DEVICE_OPENCL_C_VERSION); + this.PLATFORM = device.getInfo(WEBCL.DeviceInfo.DEVICE_PLATFORM); + this.PlatformInfo = platformInfo; + this.PREFERRED_VECTOR_WIDTH_CHAR = device.getInfo(WEBCL.DeviceInfo.DEVICE_PREFERRED_VECTOR_WIDTH_CHAR); + this.PREFERRED_VECTOR_WIDTH_FLOAT = device.getInfo(WEBCL.DeviceInfo.DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT); + this.PREFERRED_VECTOR_WIDTH_INT = device.getInfo(WEBCL.DeviceInfo.DEVICE_PREFERRED_VECTOR_WIDTH_INT); + this.PREFERRED_VECTOR_WIDTH_LONG = device.getInfo(WEBCL.DeviceInfo.DEVICE_PREFERRED_VECTOR_WIDTH_LONG); + this.PREFERRED_VECTOR_WIDTH_SHORT = device.getInfo(WEBCL.DeviceInfo.DEVICE_PREFERRED_VECTOR_WIDTH_SHORT); + this.PROFILE = device.getInfo(WEBCL.DeviceInfo.DEVICE_PROFILE); + this.PROFILING_TIMER_RESOLUTION = device.getInfo(WEBCL.DeviceInfo.DEVICE_PROFILING_TIMER_RESOLUTION); + this.QUEUE_PROPERTIES = device.getInfo(WEBCL.DeviceInfo.DEVICE_QUEUE_PROPERTIES); + this.SINGLE_FP_CONFIG = device.getInfo(WEBCL.DeviceInfo.DEVICE_SINGLE_FP_CONFIG); + this.TYPE = device.getInfo(WEBCL.DeviceInfo.DEVICE_TYPE); + this.VENDOR = device.getInfo(WEBCL.DeviceInfo.DEVICE_VENDOR); + this.VENDOR_ID = device.getInfo(WEBCL.DeviceInfo.DEVICE_VENDOR_ID); + this.VERSION = device.getInfo(WEBCL.DeviceInfo.DEVICE_VERSION); + } +} + +class ContextInfo { + DEVICES: WEBCL.WebCLDevice[]; + + constructor( + public context: WEBCL.WebCLContext + ) { + this.DEVICES = context.getInfo(WEBCL.ContextInfo.CONTEXT_DEVICES); + } +} + +class KernelWorkGroupInfo { + KERNEL_COMPILE_WORK_GROUP_SIZE: number; + KERNEL_LOCAL_MEM_SIZE: number; + KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE: number; + KERNEL_PRIVATE_MEM_SIZE: number; + KERNEL_WORK_GROUP_SIZE: number; + + constructor(kernel: WEBCL.WebCLKernel, device: WEBCL.WebCLDevice) { + this.KERNEL_COMPILE_WORK_GROUP_SIZE = kernel.getWorkGroupInfo(device, WEBCL.KernelWorkGroupInfo.KERNEL_COMPILE_WORK_GROUP_SIZE); + this.KERNEL_LOCAL_MEM_SIZE = kernel.getWorkGroupInfo(device, WEBCL.KernelWorkGroupInfo.KERNEL_LOCAL_MEM_SIZE); + this.KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE = kernel.getWorkGroupInfo(device, WEBCL.KernelWorkGroupInfo.KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE); + this.KERNEL_PRIVATE_MEM_SIZE = kernel.getWorkGroupInfo(device, WEBCL.KernelWorkGroupInfo.KERNEL_PRIVATE_MEM_SIZE); + this.KERNEL_WORK_GROUP_SIZE = kernel.getWorkGroupInfo(device, WEBCL.KernelWorkGroupInfo.KERNEL_WORK_GROUP_SIZE); + } +} + +class CommandQueueInfo { + CONTEXT: WEBCL.WebCLContext; + DEVICE: WEBCL.WebCLDevice; + PROPERTIES: WEBCL.CommandQueueProperties; + + constructor( + public queue: WEBCL.WebCLCommandQueue + ) { + this.CONTEXT = queue.getInfo(WEBCL.ContextProperties.QUEUE_CONTEXT); + this.DEVICE = queue.getInfo(WEBCL.ContextProperties.QUEUE_DEVICE); + this.PROPERTIES = queue.getInfo(WEBCL.ContextProperties.QUEUE_PROPERTIES); + } +} + +class MemoryObjectInfo { + TYPE: WEBCL.MemObjectType; + FLAGS: WEBCL.MemFlagsBits; + SIZE: number; + CONTEXT: WEBCL.WebCLContext; + ASSOCIATED_MEMOBJECT: WEBCL.WebCLBuffer; + OFFSET: number; + + constructor( + public memoryObj: WEBCL.WebCLMemoryObject + ) { + this.TYPE = memoryObj.getInfo(WEBCL.MemInfo.MEM_TYPE); + this.FLAGS = memoryObj.getInfo(WEBCL.MemInfo.MEM_FLAGS); + this.SIZE = memoryObj.getInfo(WEBCL.MemInfo.MEM_SIZE); + this.CONTEXT = memoryObj.getInfo(WEBCL.MemInfo.MEM_CONTEXT); + this.ASSOCIATED_MEMOBJECT = memoryObj.getInfo(WEBCL.MemInfo.MEM_ASSOCIATED_MEMOBJECT); + this.OFFSET = memoryObj.getInfo(WEBCL.MemInfo.MEM_OFFSET); + } +} + +class DeviceContext { + deviceInfo: DeviceInfo; + context: WEBCL.WebCLContext; + + constructor(public device?: WEBCL.WebCLDevice) { + if (!device) { + this.context = window.webcl.createContext(); + this.device = this.context.getInfo(WEBCL.ContextInfo.CONTEXT_DEVICES)[0]; // just use the first default device + } + else { + this.context = window.webcl.createContext(device); // use the specified device + } + this.deviceInfo = new DeviceInfo(this.device, undefined); // save all the info about the device + } +} + +/** +* just enough for kernel args that are one of the +* UInt8Array, UInt16Array, etc. interfaces because they already the extra +* members. +* They will be used as +* either WEBCLBuffers or ArrayBufferViews +* TODO: How to handle WEBCLImages and WEBCLSamples +*/ +interface KernelArgArrayBufferView extends ArrayBufferView { + BYTES_PER_ELEMENT: number; + length: number; +} + +/** +* This holds the information for an argument +* passed as a WEBCLBuffer. +* This holds the original host buffer as a convenience if the +* same buffer is used for multiple calls. +* Multiple kernels can use the same arguments +*/ +class ArgCLBuffer { + public buffer: WEBCL.WebCLBuffer; + + constructor( + public helper: WebCLHelper, + public hostArray: KernelArgArrayBufferView, // NOTE: this can just be a UInt8Array, UInt16Array, etc. + public cpu2gpu: boolean, + public gpu2cpu: boolean + ) { + this.makeCLBuffer(this.helper.devContext); // make it as a buffer with the host array as the template + } + + makeCLBuffer(context: DeviceContext): void { + var rwflag: WEBCL.MemFlagsBits; + if (this.cpu2gpu) { + if (this.gpu2cpu) { + rwflag = WEBCL.MemFlagsBits.MEM_READ_WRITE; + } + else { + rwflag = WEBCL.MemFlagsBits.MEM_READ_ONLY; + } + } + else { + rwflag = WEBCL.MemFlagsBits.MEM_WRITE_ONLY; + } + + this.buffer = context.context.createBuffer(rwflag, this.hostArray.length * this.hostArray.BYTES_PER_ELEMENT, + this.hostArray); // make the CLBuffer for the host array + } + + queueGPU2CPU() { + if (this.gpu2cpu) { + this.helper.queue.enqueueReadBuffer(this.buffer, false, 0, this.hostArray.length * this.hostArray.BYTES_PER_ELEMENT, + this.hostArray); // queue up a write from the host mem to the GPU mem + } + } + + queueCPU2GPU() { + if (this.cpu2gpu) { + this.helper.queue.enqueueWriteBuffer(this.buffer, false, 0, this.hostArray.length * this.hostArray.BYTES_PER_ELEMENT, + this.hostArray); // queue up a write from the host mem to the GPU mem + } + } +} + +/** +* Holder for a single kernel +*/ +class Kernel { + argCount: number = 0; + CLBuffers: ArgCLBuffer[] = []; // the read and write buffers for the kernel + localWS: number[] = []; + globalWS: number[] = []; + bufferOffsets: number[] = []; + clEvent: WEBCL.WebCLEvent; + public executionTime: number; + + constructor( + public helper: WebCLHelper, + public name: string, + public kernel: WEBCL.WebCLKernel, + public workGroupInfo?: KernelWorkGroupInfo + ) { } + + addArg(arg: ArgCLBuffer): number; + addArg(arg: ArrayBufferView): number; + addArg(arg: number): number; + addArg(value: any): number { + if (typeof (value) === "number") { // integer values + this.kernel.setArg(this.argCount, new Int32Array([value])); + } else if (value instanceof ArgCLBuffer) { // clBuffer + this.kernel.setArg(this.argCount,( value).buffer); // use the CLBuffer + this.CLBuffers.push( value); // add to buffer array + } else { // all ArrayBufferView types + this.kernel.setArg(this.argCount, value); + } + this.argCount += 1; + return this.argCount - 1; + } + + replaceArg(argIdx: number, arg: ArgCLBuffer): void; + replaceArg(argIdx: number, arg: number): void; + replaceArg(argIdx: number, arg: ArrayBufferView): void; + replaceArg(argIdx: number, value: any): void { + if (typeof (value) === "number") { + this.kernel.setArg(argIdx, new Uint32Array([value])); + } else if (value instanceof ArgCLBuffer) { + this.kernel.setArg(argIdx, ( value).buffer); // use the CLBuffer + this.CLBuffers[argIdx] = value; // replace entry is buffer array + } + else { + this.kernel.setArg(this.argCount, value); + } + } + + setWorkSections(globalThreads: number[], localThreads?: number[], offsets?: number[]) { + this.globalWS = globalThreads; + + if (localThreads) { + this.localWS = []; + localThreads.forEach((count, index) => { + this.localWS.push(count); + this.globalWS[index] = Math.ceil(globalThreads[index] / count) * count; + }); + + } + else { + this.localWS = undefined; + } + + if (offsets) { + this.bufferOffsets = offsets; + } + else { + this.bufferOffsets = []; + globalThreads.forEach(() => { + this.bufferOffsets.push(0); + }); + } + } + + /** + * Queue the transfers from CPU to GPU memory + */ + queueCPU2GPUBuffers(whichBuffers?: ArgCLBuffer[]) { + var buffers: ArgCLBuffer[]; // which to use + if (whichBuffers) { + buffers = whichBuffers; // just the passed in ones + } else { // use all of them + buffers = this.CLBuffers; + } + + buffers.forEach((value, idx) => { + if (value.cpu2gpu) { + value.queueCPU2GPU(); + } + }); // load up all the GPU memory from the host for all the read arrays + + } + + /** + * Queue the transfers from GPU to CPU memory + */ + queueGPU2CPUBuffers(whichBuffers?: ArgCLBuffer[]) { + var buffers: ArgCLBuffer[]; // which to use + if (whichBuffers) { + buffers = whichBuffers; // just the passed in ones + } else { // use all of them + buffers = this.CLBuffers; + } + + buffers.forEach((value, idx) => { + if (value.gpu2cpu) { + value.queueGPU2CPU(); + } + }); // load up all the host arrays from the gpu memory for all the write arrays + + } + + /* + * add this kernel to the queue for execution + */ + queueExecution() { + this.clEvent = new WebCLEvent(); + this.helper.queue.enqueueNDRangeKernel(this.kernel, this.globalWS.length, this.bufferOffsets, this.globalWS, this.localWS, undefined, this.clEvent); // the kernel + } + + /** + * Load up all the GPU memory, queue the kernel, + * read the GPU memory back into the CPU memory + */ + queueBuffersAndExecute() { + this.queueCPU2GPUBuffers(); // load up all the GPU memory from the host for all the read arrays + + this.queueExecution(); + + this.queueGPU2CPUBuffers(); + + this.helper.finishQueue(); + + this.calcExecutionTime(); + + } + + calcExecutionTime() { + if (this.helper.profileFlag && this.clEvent) { + var startTime: number; + var endTime: number; + + startTime = this.clEvent.getProfilingInfo(WEBCL.ProfilingInfo.PROFILING_COMMAND_START); + endTime = this.clEvent.getProfilingInfo(WEBCL.ProfilingInfo.PROFILING_COMMAND_END); + this.executionTime = endTime - startTime; + } + else { + this.executionTime = undefined; + } + } +} + +/** +* This holds all the information and setup for a platform and device +* for a program. Multiple kernels and arguments can be created which are +* passed back to the user to manage. +*/ + +class WebCLHelper { + platforms: PlatformInfo[] = new Array(); + devContext: DeviceContext; // context or undefined if released + queue: WEBCL.WebCLCommandQueue; // the command queue for the device + programCode: string; // the code for this progam + program: WEBCL.WebCLProgram; + + // Create the helper and load up all the platforms and devices + constructor(public profileFlag: boolean = false) { + if (window.webcl == undefined) { + throw (new CLHException("Webcl not found")); + } + else { +// try { + var platforms = window.webcl.getPlatforms(); + if (platforms.length < 1) { + throw (new CLHException("WEBCL there but no platforms")); + } + else { + var devicesCount = 0; // keep track of total devices + platforms.forEach( + (platform) => { // setup info for platform and get all of its devices + var platformInfo = new PlatformInfo(platform); + var devices = platform.getDevices(); + devicesCount += devices.length; + devices.forEach( + (device) => { + var deviceInfo = new DeviceInfo(device, platformInfo); // get the info + platformInfo.deviceInfos.push(deviceInfo); // add to this platform's devices + }); + this.platforms.push(platformInfo); + }); + + } + if (devicesCount < 1) { + throw (new CLHException("Webcl there with " + this.platforms.length + " platforms, but no devices")); + } + this.setDeviceContext(); // set the device context using the default, can explicitly set if desired. +/* } + catch (ex) { + throw (ex) + } +*/ + } + } + + + /** + * Set a context for a particular device type using a list of types + * in preferred order. Normally this wouldn't be used since the helper constructor + * sets the default device as the context. + */ + setDeviceContext(deviceTypes: WEBCL.DeviceTypeBits[]= [WEBCL.DeviceTypeBits.DEVICE_TYPE_DEFAULT] // optional, if empty default + ): DeviceContext { + var device: DeviceInfo; + + deviceTypes.some((type) => { // go through the input types in preference order + if ((type & WEBCL.DeviceTypeBits.DEVICE_TYPE_DEFAULT) != 0) { + device = null; + return true; + } + else { + device = this.platforms.reduce((targetdevice, platform, index, array) => { + if (!targetdevice) { + platform.deviceInfos.some((deviceInfo: DeviceInfo) => { + if ((deviceInfo.TYPE & type) != 0) { + targetdevice = deviceInfo; + return true; + } + else { + return false; + } + }); + } + return targetdevice; + }, undefined); + return (device != undefined); + } // find the first device of the specified type + }); + + if (device === undefined) { + throw ("No device found"); + } + else { + if (this.devContext) { + this.devContext.context.release(); + this.devContext = undefined; + } + if (device === null) { + this.devContext = new DeviceContext(); // get the default context + } + else { // use a specific one + this.devContext = new DeviceContext(device.device); // get the context for the device + } + if (this.queue) { + this.queue.release(); + this.queue = undefined; + } + + this.queue = this.devContext.context.createCommandQueue(this.devContext.device, this.profileFlag ? WEBCL.CommandQueueProperties.QUEUE_PROFILING_ENABLE : undefined); + + return this.devContext; + } + } + + /* + * finish the queue + */ + finishQueue() { + if (this.queue) { + this.queue.finish(); + } + } + + /* + * Set context, GPU preferred + * Only used if the default device as set in the constructor isn't correct + */ + setGPUcontext(): DeviceContext { + return this.setDeviceContext([WEBCL.DeviceTypeBits.DEVICE_TYPE_GPU, WEBCL.DeviceTypeBits.DEVICE_TYPE_CPU]); + } + + /* + * Set context, CPU preferred + * Only used if the default device as set in the constructor isn't correct + */ + setCPUcontext(): DeviceContext { + return this.setDeviceContext([WEBCL.DeviceTypeBits.DEVICE_TYPE_CPU, WEBCL.DeviceTypeBits.DEVICE_TYPE_GPU]); + } + + /** + * release the current context + */ + releaseContext() { + if (this.devContext != undefined) { + this.devContext.context.releaseAll; + this.devContext = undefined; + this.queue = undefined; + } + } + + createProgramFromElement(htmlID: string, options: string = undefined) { + var element: JQuery = jQuery("#" + htmlID); //x_Utilities.JQueryUtils.tryJQuery(() => jQuery("#" + htmlID)); // get the kernel code item + this.createProgram(element.text(), options); + } + + createProgram(code: string, options: string = undefined) { + this.programCode = code; + this.program = this.devContext.context.createProgram(this.programCode); + this.program.build([this.devContext.device], options); + } + + createKernelFromString(programSource: string, kernelName: string, options: string = undefined): Kernel { + this.createProgram(programSource, options); + return this.createKernel(kernelName); + } + + createKernelFromElement(htmlID: string, kernelName: string, options: string = undefined) : Kernel { + this.createProgramFromElement(htmlID, options); + return this.createKernel(kernelName); + } + + createKernel(kernelName: string): Kernel { + var kernel: WEBCL.WebCLKernel = this.program.createKernel(kernelName); // create the kernel + var info: KernelWorkGroupInfo = new KernelWorkGroupInfo(kernel, this.devContext.device); // get the info about it's workgroup + return new Kernel(this, kernelName, kernel, info); // create and return the kernel holder + } + + executeKernel(kernel: Kernel) { + kernel.queueBuffersAndExecute (); + } + + createBufferArg(hostBuffer: KernelArgArrayBufferView, cpu2gpu: boolean, gpu2cpu: boolean): ArgCLBuffer { + return new ArgCLBuffer(this, hostBuffer, cpu2gpu, gpu2cpu); + } + + +} + diff --git a/webcl/webcl.d.ts b/webcl/webcl.d.ts new file mode 100644 index 000000000..7bd6a4e1c --- /dev/null +++ b/webcl/webcl.d.ts @@ -0,0 +1,706 @@ +// Type definitions for WebCL 1.0 +// Project: https://www.khronos.org/registry/webcl/specs/1.0.0/ +// Definitions by: Ralph Brown +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +// Version 1.3 - Changed enums to static enums for TS 1.5 +// Version 1.2 - Fixed some more bugs, added WebCLEvent +// Version 1.1 - Minor fixes to get more enums in place and fix some argument interface types +// Version 1.0 - Initial version + +interface Window { + webcl: WEBCL.WebCL; +} + +declare var WebCLEvent: { new (): WEBCL.WebCLEvent; }; + +declare module WEBCL { + // 3.6.1 + interface WebCLBuffer extends WebCLMemoryObject { + createSubBuffer(memFlags: MemFlagsBits, origin: number, sizeInBytes: number): WebCLBuffer; + } + + //2.5 + interface WebCLCallback { (event: WebCLEvent): void } + + + // 3.5 + interface WebCLCommandQueue { + + //////////////////////////////////////////////////////////////////////////// + // + // Copying: Buffer <-> Buffer, Image <-> Image, Buffer <-> Image + // + + enqueueCopyBuffer( + srcBuffer: WebCLBuffer, + dstBuffer: WebCLBuffer, + srcOffset: number, + dstOffset: number, + numBytes: number, + eventWaitList?: WebCLEvent[], + event?: WebCLEvent): void; + + enqueueCopyBufferRect( + srcBuffer: WebCLBuffer, + dstBuffer: WebCLBuffer, + srcOrigin: number[], + dstOrigin: number[], + region: number[], + srcRowPitch: number, + srcSlicePitch: number, + dstRowPitch: number, + dstSlicePitch: number, + eventWaitList?: WebCLEvent[], + event?: WebCLEvent): void; + + enqueueCopyImage( + srcImage: WebCLImage, + dstImage: WebCLImage, + srcOrigin: number[], + dstOrigin: number[], + region: number[], + eventWaitList?: WebCLEvent[], + event?: WebCLEvent): void; + + enqueueCopyImageToBuffer( + srcImage: WebCLImage, + dstBuffer: WebCLBuffer, + srcOrigin: number[], + srcRegion: number[], + dstOffset: number, + eventWaitList?: WebCLEvent[], + event?: WebCLEvent): void; + + enqueueCopyBufferToImage( + srcBuffer: WebCLBuffer, + dstImage: WebCLImage, + srcOffset: number, + dstOrigin: number[], + dstRegion: number[], + eventWaitList?: WebCLEvent[], + event?: WebCLEvent): void; + + //////////////////////////////////////////////////////////////////////////// + // + // Reading: Buffer -> Host, Image -> Host + // + + enqueueReadBuffer( + buffer: WebCLBuffer, + blockingRead: boolean, + bufferOffset: number, + numBytes: number, + hostPtr: ArrayBufferView, + eventWaitList?: WebCLEvent[], + event?: WebCLEvent): void; + + enqueueReadBufferRect( + buffer: WebCLBuffer, + blockingRead: boolean, + bufferOrigin: number[], + hostOrigin: number[], + region: number[], + bufferRowPitch: number, + bufferSlicePitch: number, + hostRowPitch: number, + hostSlicePitch: number, + hostPtr: ArrayBufferView, + eventWaitList?: WebCLEvent[], + event?: WebCLEvent): void; + + enqueueReadImage( + image: WebCLImage, + blockingRead: boolean, + origin: number[], + region: number[], + hostRowPitch: number, + hostPtr: ArrayBufferView, + eventWaitList?: WebCLEvent[], + event?: WebCLEvent): void; + + //////////////////////////////////////////////////////////////////////////// + // + // Writing: Host -> Buffer, Host -> Image + // + + enqueueWriteBuffer( + buffer: WebCLBuffer, + blockingWrite: boolean, + bufferOffset: number, + numBytes: number, + hostPtr: ArrayBufferView, + eventWaitList?: WebCLEvent[], + event?: WebCLEvent): void; + + enqueueWriteBufferRect( + buffer: WebCLBuffer, + blockingWrite: boolean, + bufferOrigin: number[], + hostOrigin: number[], + region: number[], + bufferRowPitch: number, + bufferSlicePitch: number, + hostRowPitch: number, + hostSlicePitch: number, + hostPtr: ArrayBufferView, + eventWaitList?: WebCLEvent[], + event?: WebCLEvent): void; + + enqueueWriteImage( + image: WebCLImage, + blockingWrite: boolean, + origin: number[], + region: number[], + hostRowPitch: number, + hostPtr: ArrayBufferView, + eventWaitList?: WebCLEvent[], + event?: WebCLEvent): void; + + //////////////////////////////////////////////////////////////////////////// + // + // Executing kernels + // + + enqueueNDRangeKernel( + kernel: WebCLKernel, + workDim: number, + globalWorkOffset: number[], + globalWorkSize: number[], + localWorkSize?: number[], + eventWaitList?: WebCLEvent[], + event?: WebCLEvent): void; + + //////////////////////////////////////////////////////////////////////////// + // + // Synchronization + // + + enqueueMarker(event: WebCLEvent): void; + + enqueueBarrier(): void; + + enqueueWaitForEvents(eventWaitList: WebCLEvent[]): void; + + finish(whenFinished?: WebCLCallback): void; + + flush(): void; + + //////////////////////////////////////////////////////////////////////////// + // + // Querying command queue information + // + + getInfo(name: ContextProperties): any; + + release(): void; + } + + //3.4 + interface WebCLContext { + + createBuffer(memFlags: MemFlagsBits, sizeInBytes: number, hostPtr?: ArrayBufferView): WebCLBuffer; + + createCommandQueue(device: WebCLDevice, properties?: CommandQueueProperties): WebCLCommandQueue; + + createImage(memFlags: MemFlagsBits, + descriptor: WebCLImageDescriptor, + hostPtr?: ArrayBufferView): WebCLImage; + + createProgram(source: string): WebCLProgram; + + createSampler(normalizedCoords: number, + addressingMode: AddressingMode, + filterMode: FilterMode): WebCLSampler; + + createUserEvent(): WebCLUserEvent; + + getInfo(name: ContextInfo): any; + + getSupportedImageFormats(memFlags?: MemFlagsBits): WebCLImageDescriptor[]; + + release(): void; + + releaseAll(): void; + } + + // 3.3 + interface WebCLDevice { + getInfo(name: DeviceInfo): any; + getSupportedExtensions(): string[]; + enableExtension(extensionName: string): boolean; + } + + // 3.10 + interface WebCLEvent { + getInfo(name: EventInfo): any; + getProfilingInfo(name: ProfilingInfo): number; + setCallback(commandExecCallbackType: CommandExecutionStatus, notify: WebCLCallback): void; + release(): void; + } + + interface WebCLException extends DOMException { + name: string; // A string representation of the numeric error code, e.g. "INVALID_VALUE" + message: string; // An implementation-specific description of what caused the exception + } + + // 3.6.2 + interface WebCLImage extends WebCLMemoryObject { + getInfo(): WebCLImageDescriptor; + } + + // 3.4.1 + interface WebCLImageDescriptor { + channelOrder: ChannelOrder; + channelType: ChannelType; + width: number; + height: number; + rowPitch: number; + } + + // 3.9 + interface WebCLKernel { + getInfo(name: KernelInfo): any; + getWorkGroupInfo(device: WebCLDevice, name: KernelWorkGroupInfo): any; + getArgInfo(index: number): WebCLKernelArgInfo; + setArg(index: number, buffer: WebCLBuffer): void; + setArg(index: number, image: WebCLImage): void; + setArg(index: number, value: WebCLSampler): void; + setArg(index: number, value: ArrayBufferView): void; + release(): void; + } + + // 3.9.1 + interface WebCLKernelArgInfo { + name: string; + typeName: string; // 'char', 'float', 'uint4', 'image2d_t', 'sampler_t', etc. + addressQualifier: string; // 'global', 'local', 'constant', or 'private' + accessQualifier: string; // 'read_only', 'write_only', or 'none' + } + + // 3.6 + interface WebCLMemoryObject { + getInfo(name: MemInfo): any; + release(): void; + } + + // 3.2 + interface WebCLPlatform { + getInfo(name: PlatformInfo): any; + getDevices(deviceType?: DeviceTypeBits): WebCLDevice[]; + getSupportedExtensions(): string[]; + enableExtension(extensionName: string): boolean; + } + + //3.8 + interface WebCLProgram { + getInfo(name: ProgramInfo): any; + + getBuildInfo(device: WebCLDevice, name: ProgramBuildInfo): any; + + build(devices?: WebCLDevice[], + options?: string, + whenFinished?: WebCLCallback): void; + + createKernel(kernelName: string): WebCLKernel; + + createKernelsInProgram(): WebCLKernel[]; + + release(): void; + } + + // 3.7 + interface WebCLSampler { + getInfo(name: SamplerInfo): any; + release(): void; + } + + // 3.10.1 + interface WebCLUserEvent extends WebCLEvent { + setStatus(executionStatus: CommandExecutionStatus): void; + } + + /* Error Codes */ + const enum ErrorCodes { + SUCCESS = 0, + DEVICE_NOT_FOUND = -1, + DEVICE_NOT_AVAILABLE = -2, + COMPILER_NOT_AVAILABLE = -3, + MEM_OBJECT_ALLOCATION_FAILURE = -4, + OUT_OF_RESOURCES = -5, + OUT_OF_HOST_MEMORY = -6, + PROFILING_INFO_NOT_AVAILABLE = -7, + MEM_COPY_OVERLAP = -8, + IMAGE_FORMAT_MISMATCH = -9, + IMAGE_FORMAT_NOT_SUPPORTED = -10, + BUILD_PROGRAM_FAILURE = -11, + MAP_FAILURE = -12, + MISALIGNED_SUB_BUFFER_OFFSET = -13, + EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST = -14, + INVALID_VALUE = -30, + INVALID_DEVICE_TYPE = -31, + INVALID_PLATFORM = -32, + INVALID_DEVICE = -33, + INVALID_CONTEXT = -34, + INVALID_QUEUE_PROPERTIES = -35, + INVALID_COMMAND_QUEUE = -36, + INVALID_HOST_PTR = -37, + INVALID_MEM_OBJECT = -38, + INVALID_IMAGE_FORMAT_DESCRIPTOR = -39, + INVALID_IMAGE_SIZE = -40, + INVALID_SAMPLER = -41, + INVALID_BINARY = -42, + INVALID_BUILD_OPTIONS = -43, + INVALID_PROGRAM = -44, + INVALID_PROGRAM_EXECUTABLE = -45, + INVALID_KERNEL_NAME = -46, + INVALID_KERNEL_DEFINITION = -47, + INVALID_KERNEL = -48, + INVALID_ARG_INDEX = -49, + INVALID_ARG_VALUE = -50, + INVALID_ARG_SIZE = -51, + INVALID_KERNEL_ARGS = -52, + INVALID_WORK_DIMENSION = -53, + INVALID_WORK_GROUP_SIZE = -54, + INVALID_WORK_ITEM_SIZE = -55, + INVALID_GLOBAL_OFFSET = -56, + INVALID_EVENT_WAIT_LIST = -57, + INVALID_EVENT = -58, + INVALID_OPERATION = -59, + //INVALID_GL_OBJECT = -60, // moved to extension + INVALID_BUFFER_SIZE = -61, + //INVALID_MIP_LEVEL = -62, // moved to extension + INVALID_GLOBAL_WORK_SIZE = -63, + INVALID_PROPERTY = -64, + } + + /* cl_bool */ + const enum Bool { + FALSE = 0, + TRUE = 1, + } + + /* cl_platforinfo */ + const enum PlatformInfo { + PLATFORM_PROFILE = 0x0900, + PLATFORM_VERSION = 0x0901, + PLATFORM_NAME = 0x0902, + PLATFORM_VENDOR = 0x0903, + PLATFORM_EXTENSIONS = 0x0904, + } + /* cl_device_type - bitfield */ + const enum DeviceTypeBits { + DEVICE_TYPE_DEFAULT = 0x1, + DEVICE_TYPE_CPU = 0x2, + DEVICE_TYPE_GPU = 0x4, + DEVICE_TYPE_ACCELERATOR = 0x8, + DEVICE_TYPE_ALL = 0xFFFFFFFF, + } + /* cl_device_info */ + const enum DeviceInfo { + DEVICE_TYPE = 0x1000, + DEVICE_VENDOR_ID = 0x1001, + DEVICE_MAX_COMPUTE_UNITS = 0x1002, + DEVICE_MAX_WORK_ITEM_DIMENSIONS = 0x1003, + DEVICE_MAX_WORK_GROUP_SIZE = 0x1004, + DEVICE_MAX_WORK_ITEM_SIZES = 0x1005, + DEVICE_PREFERRED_VECTOR_WIDTH_CHAR = 0x1006, + DEVICE_PREFERRED_VECTOR_WIDTH_SHORT = 0x1007, + DEVICE_PREFERRED_VECTOR_WIDTH_INT = 0x1008, + DEVICE_PREFERRED_VECTOR_WIDTH_LONG = 0x1009, + DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT = 0x100A, + //DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE = 0x100B, // moved to extension + DEVICE_MAX_CLOCK_FREQUENCY = 0x100C, + DEVICE_ADDRESS_BITS = 0x100D, + DEVICE_MAX_READ_IMAGE_ARGS = 0x100E, + DEVICE_MAX_WRITE_IMAGE_ARGS = 0x100F, + DEVICE_MAX_MEM_ALLOC_SIZE = 0x1010, + DEVICE_IMAGE2D_MAX_WIDTH = 0x1011, + DEVICE_IMAGE2D_MAX_HEIGHT = 0x1012, + DEVICE_IMAGE3D_MAX_WIDTH = 0x1013, + DEVICE_IMAGE3D_MAX_HEIGHT = 0x1014, + DEVICE_IMAGE3D_MAX_DEPTH = 0x1015, + DEVICE_IMAGE_SUPPORT = 0x1016, + DEVICE_MAX_PARAMETER_SIZE = 0x1017, + DEVICE_MAX_SAMPLERS = 0x1018, + DEVICE_MEM_BASE_ADDR_ALIGN = 0x1019, + //DEVICE_MIN_DATA_TYPE_ALIGN_SIZE = 0x101A, // removed, deprecated in Open1.2 + DEVICE_SINGLE_FP_CONFIG = 0x101B, + DEVICE_GLOBAL_MEM_CACHE_TYPE = 0x101C, + DEVICE_GLOBAL_MEM_CACHELINE_SIZE = 0x101D, + DEVICE_GLOBAL_MEM_CACHE_SIZE = 0x101E, + DEVICE_GLOBAL_MEM_SIZE = 0x101F, + DEVICE_MAX_CONSTANT_BUFFER_SIZE = 0x1020, + DEVICE_MAX_CONSTANT_ARGS = 0x1021, + DEVICE_LOCAL_MEM_TYPE = 0x1022, + DEVICE_LOCAL_MEM_SIZE = 0x1023, + DEVICE_ERROR_CORRECTION_SUPPORT = 0x1024, + DEVICE_PROFILING_TIMER_RESOLUTION = 0x1025, + DEVICE_ENDIAN_LITTLE = 0x1026, + DEVICE_AVAILABLE = 0x1027, + DEVICE_COMPILER_AVAILABLE = 0x1028, + DEVICE_EXECUTION_CAPABILITIES = 0x1029, + DEVICE_QUEUE_PROPERTIES = 0x102A, + DEVICE_NAME = 0x102B, + DEVICE_VENDOR = 0x102C, + DRIVER_VERSION = 0x102D, + DEVICE_PROFILE = 0x102E, + DEVICE_VERSION = 0x102F, + DEVICE_EXTENSIONS = 0x1030, + DEVICE_PLATFORM = 0x1031, + //DEVICE_DOUBLE_FP_CONFIG = 0x1032, // moved to extension + //DEVICE_HALF_FP_CONFIG = 0x1033, // moved to extension + //DEVICE_PREFERRED_VECTOR_WIDTH_HALF = 0x1034, // moved to extension + DEVICE_HOST_UNIFIED_MEMORY = 0x1035, + DEVICE_NATIVE_VECTOR_WIDTH_CHAR = 0x1036, + DEVICE_NATIVE_VECTOR_WIDTH_SHORT = 0x1037, + DEVICE_NATIVE_VECTOR_WIDTH_INT = 0x1038, + DEVICE_NATIVE_VECTOR_WIDTH_LONG = 0x1039, + DEVICE_NATIVE_VECTOR_WIDTH_FLOAT = 0x103A, + //DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE = 0x103B, // moved to extension + //DEVICE_NATIVE_VECTOR_WIDTH_HALF = 0x103C, // moved to extension + DEVICE_OPENCL_C_VERSION = 0x103D, + } + /* cl_device_fp_config - bitfield */ + const enum DeviceFPConfigBits { + FP_DENORM = 0x1, + FP_INF_NAN = 0x2, + FP_ROUND_TO_NEAREST = 0x4, + FP_ROUND_TO_ZERO = 0x8, + FP_ROUND_TO_INF = 0x10, + FP_FMA = 0x20, + FP_SOFT_FLOAT = 0x40, + } + /* cl_device_MEM_CACHE_type */ + const enum DeviceMemCacheType { + NONE = 0x0, + READ_ONLY_CACHE = 0x1, + READ_WRITE_CACHE = 0x2, + } + /* cl_device_local_mem_type */ + const enum DeviceLocalMemType { + LOCAL = 0x1, + GLOBAL = 0x2, + } + /* cl_device_exec_capabilities - bitfield */ + const enum DeviceExecCapabilitiesBits { + EXEC_KERNEL = 0x1, + //EXEC_NATIVE_KERNEL = 0x2, // disallowed + } + /* cl_command_queue_properties - bitfield */ + const enum CommandQueueProperties { + QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE = 0x1, + QUEUE_PROFILING_ENABLE = 0x2, + } + /* cl_context_info */ + const enum ContextInfo { + //CONTEXT_REFERENCE_COUNT = 0x1080, // disallowed + CONTEXT_DEVICES = 0x1081, + //CONTEXT_PROPERTIES = 0x1082, // disallowed, no context properties in WebCONTEXT_NUM_DEVICES = 0x1083, + } + /* cl_context_properties */ + const enum ContextProperties { + //CONTEXT_PLATFORM = 0x1084, // disallowed, no context properties in Web /* cl_command_queue_info */ + QUEUE_CONTEXT = 0x1090, + QUEUE_DEVICE = 0x1091, + //QUEUE_REFERENCE_COUNT = 0x1092, // disallowed + QUEUE_PROPERTIES = 0x1093, + } + /* cl_mem_flags - bitfield */ + const enum MemFlagsBits { + MEM_READ_WRITE = 0x1, + MEM_WRITE_ONLY = 0x2, + MEM_READ_ONLY = 0x4, + } + /* cl_channel_order */ + const enum ChannelOrder { + R = 0x10B0, + A = 0x10B1, + RG = 0x10B2, + RA = 0x10B3, + RGB = 0x10B4, + RGBA = 0x10B5, + BGRA = 0x10B6, + ARGB = 0x10B7, + INTENSITY = 0x10B8, + LUMINANCE = 0x10B9, + Rx = 0x10BA, + RGx = 0x10BB, + RGBx = 0x10BC, + } + /* cl_channel_type */ + const enum ChannelType { + SNORM_INT8 = 0x10D0, + SNORM_INT16 = 0x10D1, + UNORM_INT8 = 0x10D2, + UNORM_INT16 = 0x10D3, + UNORM_SHORT_565 = 0x10D4, + UNORM_SHORT_555 = 0x10D5, + UNORM_INT_101010 = 0x10D6, + SIGNED_INT8 = 0x10D7, + SIGNED_INT16 = 0x10D8, + SIGNED_INT32 = 0x10D9, + UNSIGNED_INT8 = 0x10DA, + UNSIGNED_INT16 = 0x10DB, + UNSIGNED_INT32 = 0x10DC, + HALF_FLOAT = 0x10DD, + FLOAT = 0x10DE, + } + /* cl_meobject_type */ + const enum MemObjectType { + MEM_OBJECT_BUFFER = 0x10F0, + MEM_OBJECT_IMAGE2D = 0x10F1, + MEM_OBJECT_IMAGE3D = 0x10F2, + } + /* cl_meinfo */ + const enum MemInfo { + MEM_TYPE = 0x1100, + MEM_FLAGS = 0x1101, + MEM_SIZE = 0x1102, + //MEM_HOST_PTR = 0x1103, // disallowed + //MEM_MAP_COUNT = 0x1104, // disallowed + //MEM_REFERENCE_COUNT = 0x1105, // disallowed + MEM_CONTEXT = 0x1106, + MEM_ASSOCIATED_MEMOBJECT = 0x1107, + MEM_OFFSET = 0x1108, + } + /* cl_image_info */ + const enum ImageInfo { + IMAGE_FORMAT = 0x1110, + IMAGE_ELEMENT_SIZE = 0x1111, + IMAGE_ROW_PITCH = 0x1112, + IMAGE_WIDTH = 0x1114, + IMAGE_HEIGHT = 0x1115, + } + /* cl_addressing_mode */ + const enum AddressingMode { + //ADDRESS_NONE = 0x1130, // disallowed + ADDRESS_CLAMP_TO_EDGE = 0x1131, + ADDRESS_CLAMP = 0x1132, + ADDRESS_REPEAT = 0x1133, + ADDRESS_MIRRORED_REPEAT = 0x1134, + } + /* cl_filter_mode */ + const enum FilterMode { + FILTER_NEAREST = 0x1140, + FILTER_LINEAR = 0x1141, + } + /* cl_sampler_info */ + const enum SamplerInfo { + //SAMPLER_REFERENCE_COUNT = 0x1150, // disallowed + SAMPLER_CONTEXT = 0x1151, + SAMPLER_NORMALIZED_COORDS = 0x1152, + SAMPLER_ADDRESSING_MODE = 0x1153, + SAMPLER_FILTER_MODE = 0x1154, + } + /* cl_map_flags - bitfield */ + //MAP_READ = 0x1, // disallowed + //MAP_WRITE = 0x2, // disallowed + + /* cl_prograinfo */ + const enum ProgramInfo { + //PROGRAM_REFERENCE_COUNT = 0x1160, // disallowed + PROGRAM_CONTEXT = 0x1161, + PROGRAM_NUM_DEVICES = 0x1162, + PROGRAM_DEVICES = 0x1163, + PROGRAM_SOURCE = 0x1164, + //PROGRAM_BINARY_SIZES = 0x1165, // disallowed + //PROGRAM_BINARIES = 0x1166, // disallowed + } + /* cl_program_build_info */ + const enum ProgramBuildInfo { + PROGRAM_BUILD_STATUS = 0x1181, + PROGRAM_BUILD_OPTIONS = 0x1182, + PROGRAM_BUILD_LOG = 0x1183, + } + /* cl_build_status */ + const enum BuildStatus { + BUILD_SUCCESS = 0, + BUILD_NONE = -1, + BUILD_ERROR = -2, + BUILD_IN_PROGRESS = -3, + } + /* cl_kernel_info */ + const enum KernelInfo { + KERNEL_FUNCTION_NAME = 0x1190, + KERNEL_NUM_RGS = 0x1191, + //KERNEL_REFERENCE_COUNT = 0x1192, // disallowed + KERNEL_CONTEXT = 0x1193, + KERNEL_PROGRAM = 0x1194, + } + /* cl_kernel_work_group_info */ + const enum KernelWorkGroupInfo { + KERNEL_WORK_GROUP_SIZE = 0x11B0, + KERNEL_COMPILE_WORK_GROUP_SIZE = 0x11B1, + KERNEL_LOCAL_MEM_SIZE = 0x11B2, + KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE = 0x11B3, + KERNEL_PRIVATE_MEM_SIZE = 0x11B4, + } + /* cl_event_info */ + const enum EventInfo { + EVENT_COMMAND_QUEUE = 0x11D0, + EVENT_COMMAND_TYPE = 0x11D1, + //EVENT_REFERENCE_COUNT = 0x11D2, // disallowed + EVENT_COMMAND_EXECUTION_STATUS = 0x11D3, + EVENT_CONTEXT = 0x11D4, + } + /* cl_command_type */ + const enum CommandType { + COMMAND_NDRANGE_KERNEL = 0x11F0, + COMMAND_TASK = 0x11F1, + //COMMAND_NATIVE_KERNEL = 0x11F2, // disallowed + COMMAND_READ_BUFFER = 0x11F3, + COMMAND_WRITE_BUFFER = 0x11F4, + COMMAND_COPY_BUFFER = 0x11F5, + COMMAND_READ_IMAGE = 0x11F6, + COMMAND_WRITE_IMAGE = 0x11F7, + COMMAND_COPY_IMAGE = 0x11F8, + COMMAND_COPY_IMAGE_TO_BUFFER = 0x11F9, + COMMAND_COPY_BUFFER_TO_IMAGE = 0x11FA, + //COMMAND_MAP_BUFFER = 0x11FB, // disallowed + //COMMAND_MAP_IMAGE = 0x11FC, // disallowed + //COMMAND_UNMAP_MEM_OBJECT = 0x11FD, // disallowed + COMMAND_MARKER = 0x11FE, + //COMMAND_ACQUIRE_GL_OBJECTS = 0x11FF, // moved to extension + //COMMAND_RELEASE_GL_OBJECTS = 0x1200, // moved to extension + COMMAND_READ_BUFFER_RECT = 0x1201, + COMMAND_WRITE_BUFFER_RECT = 0x1202, + COMMAND_COPY_BUFFER_RECT = 0x1203, + COMMAND_USER = 0x1204, + } + /* command execution status */ + const enum CommandExecutionStatus { + COMPLETE = 0x0, + RUNNING = 0x1, + SUBMITTED = 0x2, + QUEUED = 0x3, + } + /* cl_profiling_info */ + const enum ProfilingInfo { + PROFILING_COMMAND_QUEUED = 0x1280, + PROFILING_COMMAND_SUBMIT = 0x1281, + PROFILING_COMMAND_START = 0x1282, + PROFILING_COMMAND_END = 0x1283, + } + + interface WebCL { + getPlatforms(): WebCLPlatform[]; + + createContext(deviceType?: DeviceTypeBits): WebCLContext; + + createContext(platform: WebCLPlatform, deviceType?: DeviceTypeBits): WebCLContext; + + createContext(device: WebCLDevice): WebCLContext; + + createContext(devices: WebCLDevice[]): WebCLContext; + + getSupportedExtensions(): string[]; + + enableExtension(extensionName: string): boolean; + + waitForEvents(eventWaitList: WebCLEvent[], + whenFinished?: WebCLCallback): void; + + releaseAll(): void; + } +} From be1032591c1a9413782d862259f54f14b0351b41 Mon Sep 17 00:00:00 2001 From: Ralph Date: Fri, 25 Sep 2015 16:01:57 -0400 Subject: [PATCH 26/64] Initial webcl definitions without the updated threejs definitions I previously made a pull request for. --- threejs/three.d.ts | 281 +++++++++------------------------------------ 1 file changed, 55 insertions(+), 226 deletions(-) diff --git a/threejs/three.d.ts b/threejs/three.d.ts index a381715c5..66601f301 100644 --- a/threejs/three.d.ts +++ b/threejs/three.d.ts @@ -1,193 +1,29 @@ -// Type definitions for three.js r71 +// Type definitions for three.js r71 // Project: http://mrdoob.github.com/three.js/ // Definitions by: Kon , Satoru Kimura -// Definitions: https://github.com/borisyankov/DefinitelyTyped +// Definitions: https://github.com/borisyankov/DefinitelyTyped interface WebGLRenderingContext {} declare module THREE { export var REVISION: string; - const enum MOUSE { - LEFT = 0, - MIDDLE = 1, - RIGHT = 2, - } - - // GL STATE CONSTANTS - const enum CullFace { - None = 0, - Back = 1, - Front = 2, - FrontBack = 3, - } - - - const enum FrontFaceDirection { - CW = 0, - CCW = 1, - } - - // Shadowing Type - const enum ShadowMapType { - Basic = 0, - PCF = 1, - PCFSoft = 2, - } - - // MATERIAL CONSTANTS - - // side - const enum Side { - Front = 0, - Back = 1, - Double = 2, - } - - // shading - const enum Shading { - None = 0, - Flat = 1, - Smooth = 2, - } - - // colors - const enum Colors { - None = 0, - Face = 1, - Vertex = 2, - } - - // blending modes - const enum Blending { - None = 0, - Normal = 1, - Additive = 2, - Subtractive = 3, - Multiply = 4, - Custom = 5, - } - - // custom blending equations - // (numbers start from 100 not to clash with other - // mappings to OpenGL constants defined in Texture.js) - const enum BlendingEquation { - Add = 100, - Subtract = 101, - ReverseSubtract = 102, - } - - // custom blending destination factors - const enum BlendingDstFactor { - Zero = 200, - One = 201, - SrcColor = 202, - OneMinusSrcColor = 203, - SrcAlpha = 204, - OneMinusSrcAlpha = 205, - DstAlpha = 206, - OneMinusDstAlpha = 207, - } - - // custom blending src factors - const enum BlendingSrcFactor { - //Zero = 200, - //One = 201, - //SrcAlpha = 204, - //OneMinusSrcAlpha = 205, - //DstAlpha = 206, - //OneMinusDstAlpha = 207, - DstColor = 208, - OneMinusDstColor = 209, - SrcAlphaSaturate = 210, - } - - // TEXTURE CONSTANTS - // Operations - const enum Combine { - Multiply = 0, - Mix = 1, - Add = 2, - } - - // Mapping modes - interface Mapping { - new (): { }; - } - var UVMapping: Mapping; - var CubeReflectionMapping: Mapping; - var CubeRefractionMapping: Mapping; - var SphericalReflectionMapping: Mapping; - var SphericalRefractionMapping: Mapping; - - // Wrapping modes - const enum Wrapping { - Repeat = 1000, - ClampToEdge = 1001, - MirroredRepeat = 1002, - } - - // Filters - const enum TextureFilter { - Nearest = 1003, - NearestMipMapNearest = 1004, - NearestMipMapLinear = 1005, - Linear = 1006, - LinearMipMapNearest = 1007, - LinearMipMapLinear = 1008, - } - - // Data types - const enum TextureDataType { - UnsignedByte = 1009, - Byte = 1010, - Short = 1011, - UnsignedShort = 1012, - Int = 1013, - UnsignedInt = 1014, - Float = 1015, - } - - // Pixel types - const enum PixelType { - UnsignedShort4444 = 1016, - UnsignedShort5551 = 1017, - UnsignedShort565 = 1018, - } - - // Pixel formats - const enum PixelFormat { - Alpha = 1019, - RGB = 1020, - RGBA = 1021, - Luminance = 1022, - LuminanceAlpha = 1023, - } - - // Compressed texture formats - const enum CompressedPixelFormat { - RGB_S3TC_DXT1 = 2001, - RGBA_S3TC_DXT1 = 2002, - RGBA_S3TC_DXT3 = 2003, - RGBA_S3TC_DXT5 = 2004, - } - // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent.button - // export enum MOUSE {LEFT, MIDDLE, RIGHT} + export enum MOUSE {LEFT, MIDDLE, RIGHT} // GL STATE CONSTANTS - // export enum CullFace { } + export enum CullFace { } export var CullFaceNone: CullFace; export var CullFaceBack: CullFace; export var CullFaceFront: CullFace; export var CullFaceFrontBack: CullFace; - // export enum FrontFaceDirection { } + export enum FrontFaceDirection { } export var FrontFaceDirectionCW: FrontFaceDirection; export var FrontFaceDirectionCCW: FrontFaceDirection; // Shadowing Type - // export enum ShadowMapType { } + export enum ShadowMapType { } export var BasicShadowMap: ShadowMapType; export var PCFShadowMap: ShadowMapType; export var PCFSoftShadowMap: ShadowMapType; @@ -195,25 +31,25 @@ declare module THREE { // MATERIAL CONSTANTS // side - // export enum Side { } + export enum Side { } export var FrontSide: Side; export var BackSide: Side; export var DoubleSide: Side; // shading - // export enum Shading { } + export enum Shading { } export var NoShading: Shading; export var FlatShading: Shading; export var SmoothShading: Shading; // colors - // export enum Colors { } + export enum Colors { } export var NoColors: Colors; export var FaceColors: Colors; export var VertexColors: Colors; // blending modes - // export enum Blending { } + export enum Blending { } export var NoBlending: Blending; export var NormalBlending: Blending; export var AdditiveBlending: Blending; @@ -224,7 +60,7 @@ declare module THREE { // custom blending equations // (numbers start from 100 not to clash with other // mappings to OpenGL constants defined in Texture.js) - // export enum BlendingEquation { } + export enum BlendingEquation { } export var AddEquation: BlendingEquation; export var SubtractEquation: BlendingEquation; export var ReverseSubtractEquation: BlendingEquation; @@ -232,7 +68,7 @@ declare module THREE { export var MaxEquation: BlendingEquation; // custom blending destination factors - // export enum BlendingDstFactor { } + export enum BlendingDstFactor { } export var ZeroFactor: BlendingDstFactor; export var OneFactor: BlendingDstFactor; export var SrcColorFactor: BlendingDstFactor; @@ -243,25 +79,20 @@ declare module THREE { export var OneMinusDstAlphaFactor: BlendingDstFactor; // custom blending src factors - // export enum BlendingSrcFactor { } + export enum BlendingSrcFactor { } export var DstColorFactor: BlendingSrcFactor; export var OneMinusDstColorFactor: BlendingSrcFactor; export var SrcAlphaSaturateFactor: BlendingSrcFactor; // TEXTURE CONSTANTS // Operations - // export enum Combine { } + export enum Combine { } export var MultiplyOperation: Combine; export var MixOperation: Combine; export var AddOperation: Combine; // Mapping modes - // export enum Mapping { } - // These are functions, not enums - export interface Mapping { - new (): {}; - } - + export enum Mapping { } export var UVMapping: Mapping; export var CubeReflectionMapping: Mapping; export var CubeRefractionMapping: Mapping; @@ -270,13 +101,13 @@ declare module THREE { export var SphericalReflectionMapping: Mapping; // Wrapping modes - // export enum Wrapping { } + export enum Wrapping { } export var RepeatWrapping: Wrapping; export var ClampToEdgeWrapping: Wrapping; export var MirroredRepeatWrapping: Wrapping; // Filters - // export enum TextureFilter { } + export enum TextureFilter { } export var NearestFilter: TextureFilter; export var NearestMipMapNearestFilter: TextureFilter; export var NearestMipMapLinearFilter: TextureFilter; @@ -285,7 +116,7 @@ declare module THREE { export var LinearMipMapLinearFilter: TextureFilter; // Data types - // export enum TextureDataType { } + export enum TextureDataType { } export var UnsignedByteType: TextureDataType; export var ByteType: TextureDataType; export var ShortType: TextureDataType; @@ -296,13 +127,13 @@ declare module THREE { export var HalfFloatType: TextureDataType; // Pixel types - // export enum PixelType { } + export enum PixelType { } export var UnsignedShort4444Type: PixelType; export var UnsignedShort5551Type: PixelType; export var UnsignedShort565Type: PixelType; // Pixel formats - // export enum PixelFormat { } + export enum PixelFormat { } export var AlphaFormat: PixelFormat; export var RGBFormat: PixelFormat; export var RGBAFormat: PixelFormat; @@ -312,7 +143,7 @@ declare module THREE { // Compressed texture formats // DDS / ST3C Compressed texture formats - // export enum CompressedPixelFormat { } + export enum CompressedPixelFormat { } export var RGB_S3TC_DXT1_Format: CompressedPixelFormat; export var RGBA_S3TC_DXT1_Format: CompressedPixelFormat; export var RGBA_S3TC_DXT3_Format: CompressedPixelFormat; @@ -755,21 +586,21 @@ declare module THREE { * * # Example * var Car = function () { - * + * * EventDispatcher.call( this ); * this.start = function () { - * + * * this.dispatchEvent( { type: 'start', message: 'vroom vroom!' } ); - * + * * }; - * + * * }; * * var car = new Car(); * car.addEventListener( 'start', function ( event ) { - * + * * alert( event.message ); - * + * * } ); * car.start(); * @@ -1391,7 +1222,7 @@ declare module THREE { getObjectByName(name: string): Object3D; getObjectByProperty( name: string, value: string ): Object3D; - + getWorldPosition(optionalTarget?: Vector3): Vector3; getWorldQuaternion(optionalTarget?: Quaternion): Quaternion; getWorldRotation(optionalTarget?: Euler): Euler; @@ -1913,16 +1744,16 @@ declare module THREE { add(regex:string, loader:Loader):void; get(file: string):Loader; } - + export class BinaryTextureLoader { constructor(); - + load(url: string, onLoad: (dataTexture: DataTexture) => void, onProgress?: (event: any) => void, onError?: (event: any) => void): void; } export class BufferGeometryLoader { constructor(manager?: LoadingManager); - + manager: LoadingManager; load(url: string, onLoad: (bufferGeometry: BufferGeometry) => void, onProgress?: (event: any) => void, onError?: (event: any) => void): void; setCrossOrigin(crossOrigin: string): void; @@ -2060,10 +1891,10 @@ declare module THREE { */ export class TextureLoader { constructor(manager?: LoadingManager); - + manager: LoadingManager; crossOrigin: string; - + /** * Begin loading from url * @@ -3482,8 +3313,8 @@ declare module THREE { */ multiplyQuaternions(a: Quaternion, b: Quaternion): Quaternion; - /** - * Deprecated. Use Vector3.applyQuaternion instead + /** + * Deprecated. Use Vector3.applyQuaternion instead */ multiplyVector3(vector: Vector3): Vector3; slerp(qb: Quaternion, t: number): Quaternion; @@ -4414,7 +4245,7 @@ declare module THREE { normalizeSkinWeights(): void; updateMatrixWorld(force?: boolean): void; clone(object?: SkinnedMesh): SkinnedMesh; - + skeleton: Skeleton; } @@ -5088,13 +4919,13 @@ declare module THREE { data: ImageData, width: number, height: number, - format?: PixelFormat, - type?: TextureDataType, - mapping?: Mapping, - wrapS?: Wrapping, - wrapT?: Wrapping, - magFilter?: TextureFilter, - minFilter?: TextureFilter, + format: PixelFormat, + type: TextureDataType, + mapping: Mapping, + wrapS: Wrapping, + wrapT: Wrapping, + magFilter: TextureFilter, + minFilter: TextureFilter, anisotropy?: number ); @@ -5459,20 +5290,18 @@ declare module THREE { updateMatrixWorld(force?: boolean): void; } - export type PathAct = string; // these are strings not enums - - export interface PathActions { - MOVE_TO: PathAct; - LINE_TO: PathAct; - QUADRATIC_CURVE_TO: PathAct; // Bezier quadratic curve - BEZIER_CURVE_TO: PathAct; // Bezier cubic curve - CSPLINE_THRU: PathAct; // Catmull-rom spline - ARC: PathAct; // Circle - ELLIPSE: PathAct; + export enum PathActions { + MOVE_TO, + LINE_TO, + QUADRATIC_CURVE_TO, // Bezier quadratic curve + BEZIER_CURVE_TO, // Bezier cubic curve + CSPLINE_THRU, // Catmull-rom spline + ARC, // Circle + ELLIPSE, } export interface PathAction { - action: PathAct; + action: PathActions; args: any; } @@ -5841,8 +5670,8 @@ declare module THREE { heightScale: number; }; } - - + + export class TubeGeometry extends Geometry { constructor(path: Path, segments?: number, radius?: number, radiusSegments?: number, closed?: boolean, taper?: (u: number) => number); @@ -5861,7 +5690,7 @@ declare module THREE { static NoTaper(u?: number): number; static SinusoidalTaper(u: number): number; static FrenetFrames(path: Path, segments: number, closed: boolean): void; - + } // Extras / Helpers ///////////////////////////////////////////////////////////////////// From 7e6889ada840bbd338fe7af7e2c1aa8106f51664 Mon Sep 17 00:00:00 2001 From: Justin Unterreiner Date: Fri, 25 Sep 2015 14:08:21 -0700 Subject: [PATCH 27/64] Switched the module to a static interface --- phonegap-ua-push/phonegap-ua-push.d.ts | 663 +++++++++++++------------ 1 file changed, 333 insertions(+), 330 deletions(-) diff --git a/phonegap-ua-push/phonegap-ua-push.d.ts b/phonegap-ua-push/phonegap-ua-push.d.ts index c4a57d92b..2d17721d0 100644 --- a/phonegap-ua-push/phonegap-ua-push.d.ts +++ b/phonegap-ua-push/phonegap-ua-push.d.ts @@ -12,6 +12,337 @@ declare module UrbanAirshipPlugin { //#region API Definitions + interface UrbanAirshipStatic { + + /** + * The enumeration values for use with setNotificationTypes(). + */ + notificationType: { + none: number; + badge: number; + sound: number; + alert: number; + } + + /** + * Enables or disables user notifications on the device. + * This will prompt users to opt-in to notifications on iOS. + * + * @param enabled Set to true to enable notifications, false to disable. + * @param callback The function to call on completion. + */ + setUserNotificationsEnabled(enabled: boolean, callback: (status: string) => void): void; + + /** + * Checks if user notifications are enabled or not. + * + * @param callback The function to call on completion. + */ + isUserNotificationsEnabled(callback: (enabled: boolean) => void): void; + + /** + * Get the push identifier for the device. The channel ID is used to send + * messages to the device for testing, and is the canonical identifier for + * the device in Urban Airship. + * + * @param callback The function to call on completion. + */ + getChannelID(callback: (id: string) => void): void; + + /** + * Returns the push message object that contains the data associated with a + * push notification. The extras dictionary can contain arbitrary key/value + * data that you use in your application. + * + * @param clear Set to true to clear the notification. + * @param callback The function to call on completion. + */ + getLaunchNotification(clear: boolean, callback: (push: UrbanAirshipPlugin.PushEvent) => void): void; + + /** + * Enables or disables quiet time. + * + * @param enabled Set to true to enable quiet time, false to disable. + * @param callback The function to call on completion. + */ + setQuietTimeEnabled(enabled: boolean, callback: () => void): void; + + /** + * Checks if quiet time is enabled or not. + * + * @param callback The function to call on completion. + */ + isQuietTimeEnabled(callback: (enabled: boolean) => void): void; + + /** + * Set the quiet time for the device. + * + * @param startHour The start hour for quiet time. + * @param startMinute The start minute for quiet time. + * @param endHour The end hour for quiet time. + * @param endMinute the end minute for quiet time. + * @param callback The function to call on completion. + */ + setQuietTime(startHour: number, startMinute: number, endHour: number, endMinute: number, callback: () => void): void; + + /** + * Get the current quiet time. The quietTime object represents a timespan + * during which notifications should be silenced. The typical use case is + * to expose a preference to your users so that they can enable this setting + * and specify an interval during which they do not wish to be disturbed. + * + * @param callback The function to call on completion. + */ + getQuietTime(callback: (quietTime: UrbanAirshipPlugin.QuietTimeTimeSpan) => void): void; + + /** + * Checks if quiet time is currently in effect. + * + * @param callback The function to call on completion. + */ + isInQuietTime(callback: (inQuietTime: boolean) => void): void; + + /** + * (iOS Only) + * + * On iOS, registration for push requires specifying what + * combination of badges, sound and alerts are desired. This function + * must be explicitly called in order to begin the registration process. + * + * For example: + * + * UAirship.setNotificationTypes(UAirship.notificationType.sound | + * UAirship.notificationType.alert); + * + * @param bitmask The notification types to set. + * @param callback The function to call on completion. + */ + setNotificationTypes(bitmask: number, callback: () => void): void; + + /** + * (iOS Only) + * + * Set whether the UA Autobadge feature is enabled. + * + * @param enabled Set to true to enable Autobadge, false to disable. + * @param callback The function to call on completion. + */ + setAutobadgeEnabled(enabled: boolean, callback: () => void): void; + + /** + * (iOS Only) + * + * Set the current application badge number. + * + * @param badge The number to use for the badge. + * @param callback The function to call on completion. + */ + setBadgeNumber(badge: number, callback: () => void): void; + + /** + * (iOS Only) + * + * Gets the current application badge number. + * + * @param callback The function to call on completion. + */ + getBadgeNumber(callback: (badgeNumber: number) => void): void; + + /** + * (iOS Only) + * + * Reset the badge number to zero. + * + * @param callback The function to call on completion. + */ + resetBadge(callback: () => void): void; + + /** + * (Android Only) + * + * Clears the notifications posted by the application. + * + * @param callback The function to call on completion. + */ + clearNotifications(callback: () => void): void; + + /** + * (Android only, iOS sound settings come in the push) + * + * Set whether the device makes sound on push. + * + * @param enabled Set to true to enable sound, false to disable. + * @param callback The function to call on completion. + */ + setSoundEnabled(enabled: boolean, callback: () => void): void; + + /** + * (Android Only) + * + * Checks if sound is enabled or not. + * + * @param callback The function to call on completion. + */ + isSoundEnabled(callback: (enabled: boolean) => void): void; + + /** + * (Android Only) + * + * Set whether the device vibrates on push. + * + * @param enabled Set to true to enable vibration, false to disable. + * @param callback The function to call on completion. + */ + setVibrateEnabled(enabled: boolean, callback: () => void): void; + + /** + * (Android Only) + * + * Checks if vibration is enabled or not. + * + * @param callback The function to call on completion. + */ + isVibrateEnabled(callback: (enabled: boolean) => void): void; + + /** + * Sets tags for the device. + * + * @param tags An array of tags. + * @param callback The function to call on completion. + */ + setTags(tags: string[], callback: () => void): void; + + /** + * Returns the tags for the device. + * + * @param callback The function to call on completion. + */ + getTags(callback: (tags: string[]) => void): void; + + /** + * Set alias for the device. + * + * @param alias The alias to set for this device. + * @param callback The function to call on completion. + */ + setAlias(alias: string, callback: () => void): void; + + /** + * Gets the alias for this device. + * + * @param callback The function to call on completion. + */ + getAlias(callback: (alias: string) => void): void; + + /** + * Set the named user ID for this device. + * + * @param namedUser The named user ID. + * @param callback The function to call on completion. + */ + setNamedUser(namedUserId: string, callback: () => void): void; + + /** + * Gets the named user ID for this device. + * + * @param callback The function to call on completion. + */ + getNamedUser(callback: (namedUserId: string) => void): void; + + /** + * Fluent API to edit the named user tag groups by adding or removing + * tags, then applying the changes. + * + * For example: + * + * UAirship.editNamedUserTagGroups() + * .addTags("loyalty", ["platinum-member", "gold-member"]) + * .removeTags("loyalty", ["silver-member", "bronze-member"]) + * .apply() + * + * @returns The chainable API instance. + */ + editNamedUserTagGroups(): UrbanAirshipPlugin.EditNamedUserTagGroupsApi; + + /** + * Fluent API to edit the channel tag groups by adding or removing tags, + * then applying the changes. + * + * For exmaple: + * + * UAirship.editChannelTagGroups() + * .addTags("loyalty", ["platinum-member", "gold-member"]) + * .removeTags("loyalty", ["silver-member", "bronze-member"]) + * .apply() + */ + editChannelTagGroups(): UrbanAirshipPlugin.EditChannelTagGroupsApi; + + /** + * Enables or disables analytics. Disabling analytics will delete any + * locally stored events and prevent any events from uploading. Features + * that depend on analytics being enabled may not work properly if it’s + * disabled (reports, region triggers, location segmentation, push to + * local time). + * + * @param enabled Set to true to enable analytics, false to disable. + * @param callback The function to call on completion. + */ + setAnalyticsEnabled(enabled: boolean, callback: () => void): void; + + /** + * Checks if analytics is enabled or not. + * + * @param callback The function to call on completion. + */ + isAnalyticsEnabled(callback: (enabled: boolean) => void): void; + + /** + * Runs an Urban Airship action. + * + * @param actionName The name of the action to run. + * @param actionValue The value for the action. + * @param callback The function to call on completion. + */ + runAction(actionName: string, actionValue: string, callback: (result: UrbanAirshipPlugin.RunActionResult) => void): void; + + /** + * Enables or disables Urban Airship location services on the device. + * + * @param enabled Set to true to enable location, false to disable. + * @param callback The function to call on completion. + */ + setLocationEnabled(enabled: boolean, callback: () => void): void; + + /** + * Checks if location is enabled or not. + * + * @param callback The function to call on completion. + */ + isLocationEnabled(callback: (enabled: boolean) => void): void; + + /** + * Enables or disables background location on the device. + * + * @param enabled Set to true to enable background location, false to disable. + * @param callback The function to call on completion. + */ + setBackgroundLocationEnabled(enabled: boolean, callback: () => void): void; + + /** + * Checks if background location updates are enabled or not. + * + * @param callback The function to call on completion. + */ + isBackgroundLocationEnabled(callback: () => void): void; + + /** + * Records the current location of the device. + * + * @param callback The function to call on completion. + */ + recordCurrentLocation(callback: () => void): void; + } + /** * Describes the chainable API object returned by editNamedUserTagGroups(). */ @@ -130,337 +461,9 @@ declare module UrbanAirshipPlugin { //#endregion -//#region UAirship Global Module +//#region UAirship Global Variable Declaration -/** - * Urban Airship plugin. - */ -declare module UAirship { - - export enum notificationType { - sound, - alert, - badge - } - - /** - * Enables or disables user notifications on the device. - * This will prompt users to opt-in to notifications on iOS. - * - * @param enabled Set to true to enable notifications, false to disable. - * @param callback The function to call on completion. - */ - export function setUserNotificationsEnabled(enabled: boolean, callback: (status: string) => void): void; - - /** - * Checks if user notifications are enabled or not. - * - * @param callback The function to call on completion. - */ - export function isUserNotificationsEnabled(callback: (enabled: boolean) => void): void; - - /** - * Get the push identifier for the device. The channel ID is used to send - * messages to the device for testing, and is the canonical identifier for - * the device in Urban Airship. - * - * @param callback The function to call on completion. - */ - export function getChannelID(callback: (id: string) => void): void; - - /** - * Returns the push message object that contains the data associated with a - * push notification. The extras dictionary can contain arbitrary key/value - * data that you use in your application. - * - * @param clear Set to true to clear the notification. - * @param callback The function to call on completion. - */ - export function getLaunchNotification(clear: boolean, callback: (push: UrbanAirshipPlugin.PushEvent) => void): void; - - /** - * Enables or disables quiet time. - * - * @param enabled Set to true to enable quiet time, false to disable. - * @param callback The function to call on completion. - */ - export function setQuietTimeEnabled(enabled: boolean, callback: () => void): void; - - /** - * Checks if quiet time is enabled or not. - * - * @param callback The function to call on completion. - */ - export function isQuietTimeEnabled(callback: (enabled: boolean) => void): void; - - /** - * Set the quiet time for the device. - * - * @param startHour The start hour for quiet time. - * @param startMinute The start minute for quiet time. - * @param endHour The end hour for quiet time. - * @param endMinute the end minute for quiet time. - * @param callback The function to call on completion. - */ - export function setQuietTime(startHour: number, startMinute: number, endHour: number, endMinute: number, callback: () => void): void; - - /** - * Get the current quiet time. The quietTime object represents a timespan - * during which notifications should be silenced. The typical use case is - * to expose a preference to your users so that they can enable this setting - * and specify an interval during which they do not wish to be disturbed. - * - * @param callback The function to call on completion. - */ - export function getQuietTime(callback: (quietTime: UrbanAirshipPlugin.QuietTimeTimeSpan) => void): void; - - /** - * Checks if quiet time is currently in effect. - * - * @param callback The function to call on completion. - */ - export function isInQuietTime(callback: (inQuietTime: boolean) => void): void; - - /** - * (iOS Only) - * - * On iOS, registration for push requires specifying what - * combination of badges, sound and alerts are desired. This function - * must be explicitly called in order to begin the registration process. - * - * For example: - * - * UAirship.setNotificationTypes(UAirship.notificationType.sound | - * UAirship.notificationType.alert); - * - * @param bitmask The notification types to set. - * @param callback The function to call on completion. - */ - export function setNotificationTypes(bitmask: UAirship.notificationType, callback: () => void): void; - - /** - * (iOS Only) - * - * Set whether the UA Autobadge feature is enabled. - * - * @param enabled Set to true to enable Autobadge, false to disable. - * @param callback The function to call on completion. - */ - export function setAutobadgeEnabled(enabled: boolean, callback: () => void): void; - - /** - * (iOS Only) - * - * Set the current application badge number. - * - * @param badge The number to use for the badge. - * @param callback The function to call on completion. - */ - export function setBadgeNumber(badge: number, callback: () => void): void; - - /** - * (iOS Only) - * - * Gets the current application badge number. - * - * @param callback The function to call on completion. - */ - export function getBadgeNumber(callback: (badgeNumber: number) => void): void; - - /** - * (iOS Only) - * - * Reset the badge number to zero. - * - * @param callback The function to call on completion. - */ - export function resetBadge(callback: () => void): void; - - /** - * (Android Only) - * - * Clears the notifications posted by the application. - * - * @param callback The function to call on completion. - */ - export function clearNotifications(callback: () => void): void; - - /** - * (Android only, iOS sound settings come in the push) - * - * Set whether the device makes sound on push. - * - * @param enabled Set to true to enable sound, false to disable. - * @param callback The function to call on completion. - */ - export function setSoundEnabled(enabled: boolean, callback: () => void): void; - - /** - * (Android Only) - * - * Checks if sound is enabled or not. - * - * @param callback The function to call on completion. - */ - export function isSoundEnabled(callback: (enabled: boolean) => void): void; - - /** - * (Android Only) - * - * Set whether the device vibrates on push. - * - * @param enabled Set to true to enable vibration, false to disable. - * @param callback The function to call on completion. - */ - export function setVibrateEnabled(enabled: boolean, callback: () => void): void; - - /** - * (Android Only) - * - * Checks if vibration is enabled or not. - * - * @param callback The function to call on completion. - */ - export function isVibrateEnabled(callback: (enabled: boolean) => void): void; - - /** - * Sets tags for the device. - * - * @param tags An array of tags. - * @param callback The function to call on completion. - */ - export function setTags(tags: string[], callback: () => void): void; - - /** - * Returns the tags for the device. - * - * @param callback The function to call on completion. - */ - export function getTags(callback: (tags: string[]) => void): void; - - /** - * Set alias for the device. - * - * @param alias The alias to set for this device. - * @param callback The function to call on completion. - */ - export function setAlias(alias: string, callback: () => void): void; - - /** - * Gets the alias for this device. - * - * @param callback The function to call on completion. - */ - export function getAlias(callback: (alias: string) => void): void; - - /** - * Set the named user ID for this device. - * - * @param namedUser The named user ID. - * @param callback The function to call on completion. - */ - export function setNamedUser(namedUserId: string, callback: () => void): void; - - /** - * Gets the named user ID for this device. - * - * @param callback The function to call on completion. - */ - export function getNamedUser(callback: (namedUserId: string) => void): void; - - /** - * Fluent API to edit the named user tag groups by adding or removing - * tags, then applying the changes. - * - * For example: - * - * UAirship.editNamedUserTagGroups() - * .addTags("loyalty", ["platinum-member", "gold-member"]) - * .removeTags("loyalty", ["silver-member", "bronze-member"]) - * .apply() - * - * @returns The chainable API instance. - */ - export function editNamedUserTagGroups(): UrbanAirshipPlugin.EditNamedUserTagGroupsApi; - - /** - * Fluent API to edit the channel tag groups by adding or removing tags, - * then applying the changes. - * - * For exmaple: - * - * UAirship.editChannelTagGroups() - * .addTags("loyalty", ["platinum-member", "gold-member"]) - * .removeTags("loyalty", ["silver-member", "bronze-member"]) - * .apply() - */ - export function editChannelTagGroups(): UrbanAirshipPlugin.EditChannelTagGroupsApi; - - /** - * Enables or disables analytics. Disabling analytics will delete any - * locally stored events and prevent any events from uploading. Features - * that depend on analytics being enabled may not work properly if it’s - * disabled (reports, region triggers, location segmentation, push to - * local time). - * - * @param enabled Set to true to enable analytics, false to disable. - * @param callback The function to call on completion. - */ - export function setAnalyticsEnabled(enabled: boolean, callback: () => void): void; - - /** - * Checks if analytics is enabled or not. - * - * @param callback The function to call on completion. - */ - export function isAnalyticsEnabled(callback: (enabled: boolean) => void): void; - - /** - * Runs an Urban Airship action. - * - * @param actionName The name of the action to run. - * @param actionValue The value for the action. - * @param callback The function to call on completion. - */ - export function runAction(actionName: string, actionValue: string, callback: (result: UrbanAirshipPlugin.RunActionResult) => void): void; - - /** - * Enables or disables Urban Airship location services on the device. - * - * @param enabled Set to true to enable location, false to disable. - * @param callback The function to call on completion. - */ - export function setLocationEnabled(enabled: boolean, callback: () => void): void; - - /** - * Checks if location is enabled or not. - * - * @param callback The function to call on completion. - */ - export function isLocationEnabled(callback: (enabled: boolean) => void): void; - - /** - * Enables or disables background location on the device. - * - * @param enabled Set to true to enable background location, false to disable. - * @param callback The function to call on completion. - */ - export function setBackgroundLocationEnabled(enabled: boolean, callback: () => void): void; - - /** - * Checks if background location updates are enabled or not. - * - * @param callback The function to call on completion. - */ - export function isBackgroundLocationEnabled(callback: () => void): void; - - /** - * Records the current location of the device. - * - * @param callback The function to call on completion. - */ - export function recordCurrentLocation(callback: () => void): void; -} +declare var UAirship: UrbanAirshipPlugin.UrbanAirshipStatic; //#endregion From b2ddb24c416b0a3b749af04bf376c1b65c3909bd Mon Sep 17 00:00:00 2001 From: Roman Vaughan Date: Sun, 27 Sep 2015 00:27:36 +1200 Subject: [PATCH 28/64] Add AMD suport for strophe.js --- strophe/strophe.d.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/strophe/strophe.d.ts b/strophe/strophe.d.ts index b8fc33989..9aba3bb90 100644 --- a/strophe/strophe.d.ts +++ b/strophe/strophe.d.ts @@ -49,6 +49,11 @@ declare function $iq(attrs?: any): Strophe.Builder; */ declare function $pres(attrs?: any): Strophe.Builder; +// Support AMD require +declare module 'Strophe' { + export = Strophe; +} + declare module Strophe { /** Constant: VERSION * The version of the Strophe library. Unreleased builds will have From f431f550dd43f10d4be7b2e6a21e2062fb383163 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Fri, 25 Sep 2015 06:13:44 +0500 Subject: [PATCH 29/64] lodash: changed _.indexOf() method --- lodash/lodash-tests.ts | 22 +++++++++++-- lodash/lodash.d.ts | 72 +++++++++++++++--------------------------- 2 files changed, 45 insertions(+), 49 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 470a13a91..51c061825 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -317,9 +317,25 @@ module TestHead { result = _(list).head(); } -result = _.indexOf([1, 2, 3, 1, 2, 3], 2); -result = _.indexOf([1, 2, 3, 1, 2, 3], 2, 3); -result = _.indexOf([1, 1, 2, 2, 3, 3], 2, true); +// _.indexOf +module TestIndexOf { + let array: TResult[]; + let list: _.List; + let value: TResult; + let result: number; + result = _.indexOf(array, value); + result = _.indexOf(array, value, true); + result = _.indexOf(array, value, 42); + result = _.indexOf(list, value); + result = _.indexOf(list, value, true); + result = _.indexOf(list, value, 42); + result = _(array).indexOf(value); + result = _(array).indexOf(value, true); + result = _(array).indexOf(value, 42); + result = _(list).indexOf(value); + result = _(list).indexOf(value, true); + result = _(list).indexOf(value, 42); +} //_.initial { diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 918a24d35..d927303c7 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -762,60 +762,40 @@ declare module _ { //_.indexOf interface LoDashStatic { /** - * Gets the index at which the first occurrence of value is found using strict equality - * for comparisons, i.e. ===. If the array is already sorted providing true for fromIndex - * will run a faster binary search. - * @param array The array to search. - * @param value The value to search for. - * @param fromIndex The index to search from. - * @return The index of `value` within `array`. - **/ - indexOf( - array: Array, - value: T): number; - - /** - * @see _.indexOf - **/ - indexOf( - array: List, - value: T): number; - - /** - * @see _.indexOf - * @param fromIndex The index to search from - **/ - indexOf( - array: Array, - value: T, - fromIndex: number): number; - - /** - * @see _.indexOf - * @param fromIndex The index to search from - **/ + * Gets the index at which the first occurrence of value is found in array using SameValueZero for equality + * comparisons. If fromIndex is negative, it’s used as the offset from the end of array. If array is sorted + * providing true for fromIndex performs a faster binary search. + * + * @param array The array to search. + * @param value The value to search for. + * @param fromIndex The index to search from or true to perform a binary search on a sorted array. + * @return The index to search from or true to perform a binary search on a sorted array. + */ indexOf( array: List, value: T, - fromIndex: number): number; + fromIndex?: boolean|number + ): number; + } + interface LoDashArrayWrapper { /** - * @see _.indexOf - * @param isSorted True to perform a binary search on a sorted array. - **/ - indexOf( - array: Array, + * @see _.indexOf + */ + indexOf( value: T, - isSorted: boolean): number; + fromIndex?: boolean|number + ): number; + } + interface LoDashObjectWrapper { /** - * @see _.indexOf - * @param isSorted True to perform a binary search on a sorted array. - **/ - indexOf( - array: List, - value: T, - isSorted: boolean): number; + * @see _.indexOf + */ + indexOf( + value: TValue, + fromIndex?: boolean|number + ): number; } //_.initial From 5d368d0ecad9e7816cb3cec24db911efebd9981e Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Thu, 24 Sep 2015 10:28:16 +0500 Subject: [PATCH 30/64] lodash: changed _.take() method --- lodash/lodash-tests.ts | 19 ++++++++++--- lodash/lodash.d.ts | 64 +++++++++++++++++++----------------------- 2 files changed, 44 insertions(+), 39 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 470a13a91..fb6ab9860 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -275,14 +275,10 @@ module TestFirst { result = _(list).first(); } -result = _.take([1, 2, 3]); -result = _.take([1, 2, 3], 2); result = _.takeWhile([1, 2, 3], (num) => num < 3); result = _.takeWhile(foodsOrganic, 'organic'); result = _.takeWhile(foodsType, { 'type': 'fruit' }); -result = _([1, 2, 3]).take().value(); -result = _([1, 2, 3]).take(2).value(); result = _([1, 2, 3]).takeWhile(function (num) { return num < 3; }).value(); @@ -440,6 +436,21 @@ result = _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function return this.wordToNumber[word]; }, sortedIndexDict); +// _.take +module TestTake { + let array: TResult[]; + let list: _.List; + let result: TResult[]; + result = _.take(array); + result = _.take(array, 42); + result = _.take(list); + result = _.take(list, 42); + result = _(array).take().value(); + result = _(array).take(42).value(); + result = _(list).take().value(); + result = _(list).take(42).value(); +} + // _.takeRight { let testTakeRightArray: TResult[]; diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 918a24d35..f7f35ed15 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -587,30 +587,6 @@ declare module _ { } interface LoDashStatic { - /** - * @see _.first - **/ - take(array: Array): T[]; - - /** - * @see _.first - **/ - take(array: List): T[]; - - /** - * @see _.first - **/ - take( - array: Array, - n: number): T[]; - - /** - * @see _.first - **/ - take( - array: List, - n: number): T[]; - /** * Takes the first items from an array or list based on a predicate * @param array The array or list of items on which the result set will be based @@ -645,17 +621,6 @@ declare module _ { } interface LoDashArrayWrapper { - /** - * @see _.first - **/ - take(): LoDashArrayWrapper; - - /** - * @see _.first - * @param n The number of elements to return. - **/ - take(n: number): LoDashArrayWrapper; - /** * Takes the first items based on a predicate * @param predicate The function called per element. @@ -1304,6 +1269,35 @@ declare module _ { whereValue: W): number; } + //_.take + interface LoDashStatic { + /** + * Creates a slice of array with n elements taken from the beginning. + * + * @param array The array to query. + * @param n The number of elements to take. + * @return Returns the slice of array. + */ + take( + array: List, + n?: number + ): T[]; + } + + interface LoDashArrayWrapper { + /** + * @see _.take + */ + take(n?: number): LoDashArrayWrapper; + } + + interface LoDashObjectWrapper { + /** + * @see _.take + */ + take(n?: number): LoDashArrayWrapper; + } + //_.takeRight interface LoDashStatic { /** From 3effa383eb030e6fcb94d86398fd95fff1333a72 Mon Sep 17 00:00:00 2001 From: Roman Vaughan Date: Sun, 27 Sep 2015 18:13:26 +1300 Subject: [PATCH 31/64] Improve AMD support for strophe.js After reviewing Strophe.js, the library detects when an AMD loader is implemented and adjusts how it is exported. This behaviour has been noted and thus the typescript definition has been updated to reflect that --- strophe/strophe.d.ts | 2143 ++++++++++++++++++++++-------------------- 1 file changed, 1103 insertions(+), 1040 deletions(-) diff --git a/strophe/strophe.d.ts b/strophe/strophe.d.ts index 9aba3bb90..c3125d36e 100644 --- a/strophe/strophe.d.ts +++ b/strophe/strophe.d.ts @@ -2,30 +2,1094 @@ // Project: http://strophe.im/strophejs/ // Definitions by: David Deutsch // Definitions: https://github.com/borisyankov/DefinitelyTyped +declare module wrapper { + /** Function: $build + * Create a Strophe.Builder. + * This is an alias for 'new Strophe.Builder(name, attrs)'. + * + * Parameters: + * (String) name - The root element name. + * (Object) attrs - The attributes for the root element in object notation. + * + * Returns: + * A new Strophe.Builder object. + */ + function $build(name: string, attrs?: any): Strophe.Builder; + + /** Function: $msg + * Create a Strophe.Builder with a element as the root. + * + * Parmaeters: + * (Object) attrs - The element attributes in object notation. + * + * Returns: + * A new Strophe.Builder object. + */ + function $msg(attrs?: any): Strophe.Builder; + + /** Function: $iq + * Create a Strophe.Builder with an element as the root. + * + * Parameters: + * (Object) attrs - The element attributes in object notation. + * + * Returns: + * A new Strophe.Builder object. + */ + function $iq(attrs?: any): Strophe.Builder; + + /** Function: $pres + * Create a Strophe.Builder with a element as the root. + * + * Parameters: + * (Object) attrs - The element attributes in object notation. + * + * Returns: + * A new Strophe.Builder object. + */ + function $pres(attrs?: any): Strophe.Builder; + + module Strophe { + /** Constant: VERSION + * The version of the Strophe library. Unreleased builds will have + * a version of head-HASH where HASH is a partial revision. + */ + var VERSION: string; + + /** Constants: XMPP Namespace Constants + * Common namespace constants from the XMPP RFCs and XEPs. + * + * NS.HTTPBIND - HTTP BIND namespace from XEP 124. + * NS.BOSH - BOSH namespace from XEP 206. + * NS.CLIENT - Main XMPP client namespace. + * NS.AUTH - Legacy authentication namespace. + * NS.ROSTER - Roster operations namespace. + * NS.PROFILE - Profile namespace. + * NS.DISCO_INFO - Service discovery info namespace from XEP 30. + * NS.DISCO_ITEMS - Service discovery items namespace from XEP 30. + * NS.MUC - Multi-User Chat namespace from XEP 45. + * NS.SASL - XMPP SASL namespace from RFC 3920. + * NS.STREAM - XMPP Streams namespace from RFC 3920. + * NS.BIND - XMPP Binding namespace from RFC 3920. + * NS.SESSION - XMPP Session namespace from RFC 3920. + * NS.XHTML_IM - XHTML-IM namespace from XEP 71. + * NS.XHTML - XHTML body namespace from XEP 71. + */ + var NS: { + HTTPBIND: string; + BOSH: string; + CLIENT: string; + AUTH: string; + ROSTER: string; + PROFILE: string; + DISCO_INFO: string; + DISCO_ITEMS: string; + MUC: string; + SASL: string; + STREAM: string; + FRAMING: string; + BIND: string; + SESSION: string; + VERSION: string; + STANZAS: string; + XHTML_IM: string; + XHTML: string; + } + + /** Constants: Connection Status Constants + * Connection status constants for use by the connection handler + * callback. + * + * Status.ERROR - An error has occurred + * Status.CONNECTING - The connection is currently being made + * Status.CONNFAIL - The connection attempt failed + * Status.AUTHENTICATING - The connection is authenticating + * Status.AUTHFAIL - The authentication attempt failed + * Status.CONNECTED - The connection has succeeded + * Status.DISCONNECTED - The connection has been terminated + * Status.DISCONNECTING - The connection is currently being terminated + * Status.ATTACHED - The connection has been attached + */ + enum Status { + ERROR, + CONNECTING, + CONNFAIL, + AUTHENTICATING, + AUTHFAIL, + CONNECTED, + DISCONNECTED, + DISCONNECTING, + ATTACHED, + REDIRECT + } + + /** Constants: Log Level Constants + * Logging level indicators. + * + * LogLevel.DEBUG - Debug output + * LogLevel.INFO - Informational output + * LogLevel.WARN - Warnings + * LogLevel.ERROR - Errors + * LogLevel.FATAL - Fatal errors + */ + enum LogLevel { + DEBUG, + INFO, + WARN, + ERROR, + FATAL + } + + /** Function: addNamespace + * This function is used to extend the current namespaces in + * Strophe.NS. It takes a key and a value with the key being the + * name of the new namespace, with its actual value. + * For example: + * Strophe.addNamespace('PUBSUB', "http://jabber.org/protocol/pubsub"); + * + * Parameters: + * (String) name - The name under which the namespace will be + * referenced under Strophe.NS + * (String) value - The actual namespace. + */ + function addNamespace(name: string, value: string): void; + + /** Function: forEachChild + * Map a function over some or all child elements of a given element. + * + * This is a small convenience function for mapping a function over + * some or all of the children of an element. If elemName is null, all + * children will be passed to the function, otherwise only children + * whose tag names match elemName will be passed. + * + * Parameters: + * (XMLElement) elem - The element to operate on. + * (String) elemName - The child element tag name filter. + * (Function) func - The function to apply to each child. This + * function should take a single argument, a DOM element. + */ + function forEachChild(elem: Element, elemName: string, func: (child: Element) => any): void; + + /** Function: isTagEqual + * Compare an element's tag name with a string. + * + * This function is case sensitive. + * + * Parameters: + * (XMLElement) el - A DOM element. + * (String) name - The element name. + * + * Returns: + * true if the element's tag name matches _el_, and false + * otherwise. + */ + function isTagEqual(el: Element, name: string): boolean; + + /** Function: xmlGenerator + * Get the DOM document to generate elements. + * + * Returns: + * The currently used DOM document. + */ + function xmlGenerator(): Document; + + /** Function: xmlElement + * Create an XML DOM element. + * + * This function creates an XML DOM element correctly across all + * implementations. Note that these are not HTML DOM elements, which + * aren't appropriate for XMPP stanzas. + * + * Parameters: + * (String) name - The name for the element. + * (Array|Object) attrs - An optional array or object containing + * key/value pairs to use as element attributes. The object should + * be in the format {'key': 'value'} or {key: 'value'}. The array + * should have the format [['key1', 'value1'], ['key2', 'value2']]. + * (String) text - The text child data for the element. + * + * Returns: + * A new XML DOM element. + */ + function xmlElement(name: string, attrs?: any, text?: string): Element; + function xmlElement(name: string, text?: string, attrs?: any): Element; + + /* Function: xmlescape + * Excapes invalid xml characters. + * + * Parameters: + * (String) text - text to escape. + * + * Returns: + * Escaped text. + */ + function xmlescape(text: string): string; + + /* Function: xmlunescape + * Unexcapes invalid xml characters. + * + * Parameters: + * (String) text - text to unescape. + * + * Returns: + * Unescaped text. + */ + function xmlunescape(text: string): string; + + /** Function: xmlTextNode + * Creates an XML DOM text node. + * + * Provides a cross implementation version of document.createTextNode. + * + * Parameters: + * (String) text - The content of the text node. + * + * Returns: + * A new XML DOM text node. + */ + function xmlTextNode(text: string): Text; + + /** Function: xmlHtmlNode + * Creates an XML DOM html node. + * + * Parameters: + * (String) html - The content of the html node. + * + * Returns: + * A new XML DOM text node. + */ + function xmlHtmlNode(html: string): Document; + + /** Function: getText + * Get the concatenation of all text children of an element. + * + * Parameters: + * (XMLElement) elem - A DOM element. + * + * Returns: + * A String with the concatenated text of all text element children. + */ + function getText(elem: Element): string; + + /** Function: copyElement + * Copy an XML DOM element. + * + * This function copies a DOM element and all its descendants and returns + * the new copy. + * + * Parameters: + * (XMLElement) elem - A DOM element. + * + * Returns: + * A new, copied DOM element tree. + */ + function copyElement(elem: Element): Element; + + /** Function: createHtml + * Copy an HTML DOM element into an XML DOM. + * + * This function copies a DOM element and all its descendants and returns + * the new copy. + * + * Parameters: + * (Element) elem - A DOM element. + * + * Returns: + * A new, copied DOM element tree. + */ + function createHtml(elem: Element): Element; + + /** Function: escapeNode + * Escape the node part (also called local part) of a JID. + * + * Parameters: + * (String) node - A node (or local part). + * + * Returns: + * An escaped node (or local part). + */ + function escapeNode(node: string): string; + + /** Function: unescapeNode + * Unescape a node part (also called local part) of a JID. + * + * Parameters: + * (String) node - A node (or local part). + * + * Returns: + * An unescaped node (or local part). + */ + function unescapeNode(node: string): string; + + /** Function: getNodeFromJid + * Get the node portion of a JID String. + * + * Parameters: + * (String) jid - A JID. + * + * Returns: + * A String containing the node. + */ + function getNodeFromJid(jid: string): string; + + /** Function: getDomainFromJid + * Get the domain portion of a JID String. + * + * Parameters: + * (String) jid - A JID. + * + * Returns: + * A String containing the domain. + */ + function getDomainFromJid(jid: string): string; + + /** Function: getResourceFromJid + * Get the resource portion of a JID String. + * + * Parameters: + * (String) jid - A JID. + * + * Returns: + * A String containing the resource. + */ + function getResourceFromJid(jid: string): string; + + /** Function: getBareJidFromJid + * Get the bare JID from a JID String. + * + * Parameters: + * (String) jid - A JID. + * + * Returns: + * A String containing the bare JID. + */ + function getBareJidFromJid(jid: string): string; + + /** Function: log + * User overrideable logging function. + * + * This function is called whenever the Strophe library calls any + * of the logging functions. The default implementation of this + * function does nothing. If client code wishes to handle the logging + * messages, it should override this with + * > Strophe.log = function (level, msg) { + * > (user code here) + * > }; + * + * Please note that data sent and received over the wire is logged + * via Strophe.Connection.rawInput() and Strophe.Connection.rawOutput(). + * + * The different levels and their meanings are + * + * DEBUG - Messages useful for debugging purposes. + * INFO - Informational messages. This is mostly information like + * 'disconnect was called' or 'SASL auth succeeded'. + * WARN - Warnings about potential problems. This is mostly used + * to report transient connection errors like request timeouts. + * ERROR - Some error occurred. + * FATAL - A non-recoverable fatal error occurred. + * + * Parameters: + * (Integer) level - The log level of the log message. This will + * be one of the values in Strophe.LogLevel. + * (String) msg - The log message. + */ + function log(level: LogLevel, msg: string): void; + + /** Functions: debug, info, warn, error + * Log a message at the appropriate Strophe.LogLevel + * + * Parameters: + * (String) msg - The log message. + */ + function debug(msg: string): void; + function info(msg: string): void; + function warn(msg: string): void; + function error(msg: string): void; + function fatal(msg: string): void; + + /** Function: serialize + * Render a DOM element and all descendants to a String. + * + * Parameters: + * (XMLElement) elem - A DOM element. + * + * Returns: + * The serialized element tree as a String. + */ + function serialize(elem: Element | Builder): string; + + /** Function: addConnectionPlugin + * Extends the Strophe.Connection object with the given plugin. + * + * Parameters: + * (String) name - The name of the extension. + * (Object) ptype - The plugin's prototype. + */ + function addConnectionPlugin(name: string, ptype: any): void; + + var Builder: { + /** Constructor: Strophe.Builder + * Create a Strophe.Builder object. + * + * The attributes should be passed in object notation. For example + * > var b = new Builder('message', {to: 'you', from: 'me'}); + * or + * > var b = new Builder('messsage', {'xml:lang': 'en'}); + * + * Parameters: + * (String) name - The name of the root element. + * (Object) attrs - The attributes for the root element in object notation. + * + * Returns: + * A new Strophe.Builder. + */ + new (name: string, attrs?: any): Builder; + prototype: any; + } + + + /** Class: Strophe.Builder + * XML DOM builder. + * + * This object provides an interface similar to JQuery but for building + * DOM element easily and rapidly. All the functions except for toString() + * and tree() return the object, so calls can be chained. Here's an + * example using the $iq() builder helper. + * > $iq({to: 'you', from: 'me', type: 'get', id: '1'}) + * > .c('query', {xmlns: 'strophe:example'}) + * > .c('example') + * > .toString() + * The above generates this XML fragment + * > + * > + * > + * > + * > + * The corresponding DOM manipulations to get a similar fragment would be + * a lot more tedious and probably involve several helper variables. + * + * Since adding children makes new operations operate on the child, up() + * is provided to traverse up the tree. To add two children, do + * > builder.c('child1', ...).up().c('child2', ...) + * The next operation on the Builder will be relative to the second child. + */ + interface Builder { + /** Function: tree + * Return the DOM tree. + * + * This function returns the current DOM tree as an element object. This + * is suitable for passing to functions like Strophe.Connection.send(). + * + * Returns: + * The DOM tree as a element object. + */ + tree(): Element; + + /** Function: toString + * Serialize the DOM tree to a String. + * + * This function returns a string serialization of the current DOM + * tree. It is often used internally to pass data to a + * Strophe.Request object. + * + * Returns: + * The serialized DOM tree in a String. + */ + toString(): string; + + /** Function: up + * Make the current parent element the new current element. + * + * This function is often used after c() to traverse back up the tree. + * For example, to add two children to the same element + * > builder.c('child1', {}).up().c('child2', {}); + * + * Returns: + * The Stophe.Builder object. + */ + up(): Builder; + + /** Function: attrs + * Add or modify attributes of the current element. + * + * The attributes should be passed in object notation. This function + * does not move the current element pointer. + * + * Parameters: + * (Object) moreattrs - The attributes to add/modify in object notation. + * + * Returns: + * The Strophe.Builder object. + */ + attrs(moreattrs: any): Builder; + + /** Function: c + * Add a child to the current element and make it the new current + * element. + * + * This function moves the current element pointer to the child, + * unless text is provided. If you need to add another child, it + * is necessary to use up() to go back to the parent in the tree. + * + * Parameters: + * (String) name - The name of the child. + * (Object) attrs - The attributes of the child in object notation. + * (String) text - The text to add to the child. + * + * Returns: + * The Strophe.Builder object. + */ + c(name: string, attrs?: any, text?: string): Builder; + + /** Function: cnode + * Add a child to the current element and make it the new current + * element. + * + * This function is the same as c() except that instead of using a + * name and an attributes object to create the child it uses an + * existing DOM element object. + * + * Parameters: + * (XMLElement) elem - A DOM element. + * + * Returns: + * The Strophe.Builder object. + */ + cnode(elem: Node): Builder; + + /** Function: t + * Add a child text element. + * + * This *does not* make the child the new current element since there + * are no children of text elements. + * + * Parameters: + * (String) text - The text data to append to the current element. + * + * Returns: + * The Strophe.Builder object. + */ + t(text: string): Builder; + + /** Function: h + * Replace current element contents with the HTML passed in. + * + * This *does not* make the child the new current element + * + * Parameters: + * (String) html - The html to insert as contents of current element. + * + * Returns: + * The Strophe.Builder object. + */ + h(html: string): Builder; + } + + interface ConnectionOptions { + protocol?: string; + sync?: boolean; + } + var Connection: { + /** Constructor: Strophe.Connection + * Create and initialize a Strophe.Connection object. + * + * The transport-protocol for this connection will be chosen automatically + * based on the given service parameter. URLs starting with "ws://" or + * "wss://" will use WebSockets, URLs starting with "http://", "https://" + * or without a protocol will use BOSH. + * + * To make Strophe connect to the current host you can leave out the protocol + * and host part and just pass the path, e.g. + * + * > var conn = new Strophe.Connection("/http-bind/"); + * + * WebSocket options: + * + * If you want to connect to the current host with a WebSocket connection you + * can tell Strophe to use WebSockets through a "protocol" attribute in the + * optional options parameter. Valid values are "ws" for WebSocket and "wss" + * for Secure WebSocket. + * So to connect to "wss://CURRENT_HOSTNAME/xmpp-websocket" you would call + * + * > var conn = new Strophe.Connection("/xmpp-websocket/", {protocol: "wss"}); + * + * Note that relative URLs _NOT_ starting with a "/" will also include the path + * of the current site. + * + * Also because downgrading security is not permitted by browsers, when using + * relative URLs both BOSH and WebSocket connections will use their secure + * variants if the current connection to the site is also secure (https). + * + * BOSH options: + * + * by adding "sync" to the options, you can control if requests will + * be made synchronously or not. The default behaviour is asynchronous. + * If you want to make requests synchronous, make "sync" evaluate to true: + * > var conn = new Strophe.Connection("/http-bind/", {sync: true}); + * You can also toggle this on an already established connection: + * > conn.options.sync = true; + * + * + * Parameters: + * (String) service - The BOSH or WebSocket service URL. + * (Object) options - A hash of configuration options + * + * Returns: + * A new Strophe.Connection object. + */ + new (service: string, options?: ConnectionOptions): Connection; + prototype: any; + } + + /** Class: Strophe.Connection + * XMPP Connection manager. + * + * This class is the main part of Strophe. It manages a BOSH connection + * to an XMPP server and dispatches events to the user callbacks as + * data arrives. It supports SASL PLAIN, SASL DIGEST-MD5, SASL SCRAM-SHA1 + * and legacy authentication. + * + * After creating a Strophe.Connection object, the user will typically + * call connect() with a user supplied callback to handle connection level + * events like authentication failure, disconnection, or connection + * complete. + * + * The user will also have several event handlers defined by using + * addHandler() and addTimedHandler(). These will allow the user code to + * respond to interesting stanzas or do something periodically with the + * connection. These handlers will be active once authentication is + * finished. + * + * To send data to the connection, use send(). + */ + interface Connection { + + jid: string; + authzid: string; + pass: string; + authcid: string; + domain: string; + servtype: string; + maxRetries: number; + //todo: what other members are meant to be public? + + /** Function: reset + * Reset the connection. + * + * This function should be called after a connection is disconnected + * before that connection is reused. + */ + reset(): void; + + /** Function: pause + * Pause the request manager. + * + * This will prevent Strophe from sending any more requests to the + * server. This is very useful for temporarily pausing + * BOSH-Connections while a lot of send() calls are happening quickly. + * This causes Strophe to send the data in a single request, saving + * many request trips. + */ + pause(): void; + + /** Function: resume + * Resume the request manager. + * + * This resumes after pause() has been called. + */ + resume(): void; + + /** Function: getUniqueId + * Generate a unique ID for use in elements. + * + * All stanzas are required to have unique id attributes. This + * function makes creating these easy. Each connection instance has + * a counter which starts from zero, and the value of this counter + * plus a colon followed by the suffix becomes the unique id. If no + * suffix is supplied, the counter is used as the unique id. + * + * Suffixes are used to make debugging easier when reading the stream + * data, and their use is recommended. The counter resets to 0 for + * every new connection for the same reason. For connections to the + * same server that authenticate the same way, all the ids should be + * the same, which makes it easy to see changes. This is useful for + * automated testing as well. + * + * Parameters: + * (String) suffix - A optional suffix to append to the id. + * + * Returns: + * A unique string to be used for the id attribute. + */ + getUniqueId(suffix?: string | number): string; + + /** Function: connect + * Starts the connection process. + * + * As the connection process proceeds, the user supplied callback will + * be triggered multiple times with status updates. The callback + * should take two arguments - the status code and the error condition. + * + * The status code will be one of the values in the Strophe.Status + * constants. The error condition will be one of the conditions + * defined in RFC 3920 or the condition 'strophe-parsererror'. + * + * The Parameters _wait_, _hold_ and _route_ are optional and only relevant + * for BOSH connections. Please see XEP 124 for a more detailed explanation + * of the optional parameters. + * + * Parameters: + * (String) jid - The user's JID. This may be a bare JID, + * or a full JID. If a node is not supplied, SASL ANONYMOUS + * authentication will be attempted. + * (String) pass - The user's password. + * (Function) callback - The connect callback function. + * (Integer) wait - The optional HTTPBIND wait value. This is the + * time the server will wait before returning an empty result for + * a request. The default setting of 60 seconds is recommended. + * (Integer) hold - The optional HTTPBIND hold value. This is the + * number of connections the server will hold at one time. This + * should almost always be set to 1 (the default). + * (String) route - The optional route value. + */ + connect(jid?: string, pass?: string, callback?: (status: Status, condition: string) => any, wait?: number, hold?: number, route?: string): void; + + /** Function: attach + * Attach to an already created and authenticated BOSH session. + * + * This function is provided to allow Strophe to attach to BOSH + * sessions which have been created externally, perhaps by a Web + * application. This is often used to support auto-login type features + * without putting user credentials into the page. + * + * Parameters: + * (String) jid - The full JID that is bound by the session. + * (String) sid - The SID of the BOSH session. + * (String) rid - The current RID of the BOSH session. This RID + * will be used by the next request. + * (Function) callback The connect callback function. + * (Integer) wait - The optional HTTPBIND wait value. This is the + * time the server will wait before returning an empty result for + * a request. The default setting of 60 seconds is recommended. + * Other settings will require tweaks to the Strophe.TIMEOUT value. + * (Integer) hold - The optional HTTPBIND hold value. This is the + * number of connections the server will hold at one time. This + * should almost always be set to 1 (the default). + * (Integer) wind - The optional HTTBIND window value. This is the + * allowed range of request ids that are valid. The default is 5. + */ + attach(jid: string, sid: string, rid: string, callback?: (status: Status, condition: string) => any, wait?: number, hold?: number, wind?: number): void; + + /** Function: xmlInput + * User overrideable function that receives XML data coming into the + * connection. + * + * The default function does nothing. User code can override this with + * > Strophe.Connection.xmlInput = function (elem) { + * > (user code) + * > }; + * + * Due to limitations of current Browsers' XML-Parsers the opening and closing + * tag for WebSocket-Connoctions will be passed as selfclosing here. + * + * BOSH-Connections will have all stanzas wrapped in a tag. See + * if you want to strip this tag. + * + * Parameters: + * (XMLElement) elem - The XML data received by the connection. + */ + xmlInput(elem: Element): void; + + /** Function: xmlOutput + * User overrideable function that receives XML data sent to the + * connection. + * + * The default function does nothing. User code can override this with + * > Strophe.Connection.xmlOutput = function (elem) { + * > (user code) + * > }; + * + * Due to limitations of current Browsers' XML-Parsers the opening and closing + * tag for WebSocket-Connoctions will be passed as selfclosing here. + * + * BOSH-Connections will have all stanzas wrapped in a tag. See + * if you want to strip this tag. + * + * Parameters: + * (XMLElement) elem - The XMLdata sent by the connection. + */ + xmlOutput(elem: Element): void; + + /** Function: rawInput + * User overrideable function that receives raw data coming into the + * connection. + * + * The default function does nothing. User code can override this with + * > Strophe.Connection.rawInput = function (data) { + * > (user code) + * > }; + * + * Parameters: + * (String) data - The data received by the connection. + */ + rawInput(data: string): void; + + /** Function: rawOutput + * User overrideable function that receives raw data sent to the + * connection. + * + * The default function does nothing. User code can override this with + * > Strophe.Connection.rawOutput = function (data) { + * > (user code) + * > }; + * + * Parameters: + * (String) data - The data sent by the connection. + */ + rawOutput(data: string): void; + + /** Function: send + * Send a stanza. + * + * This function is called to push data onto the send queue to + * go out over the wire. Whenever a request is sent to the BOSH + * server, all pending data is sent and the queue is flushed. + * + * Parameters: + * (XMLElement | + * [XMLElement] | + * Strophe.Builder) elem - The stanza to send. + */ + send(elem: Element | Element[]| Builder): void; + + /** Function: flush + * Immediately send any pending outgoing data. + * + * Normally send() queues outgoing data until the next idle period + * (100ms), which optimizes network use in the common cases when + * several send()s are called in succession. flush() can be used to + * immediately send all pending data. + */ + flush(): void; + + /** Function: sendIQ + * Helper function to send IQ stanzas. + * + * Parameters: + * (XMLElement) elem - The stanza to send. + * (Function) callback - The callback function for a successful request. + * (Function) errback - The callback function for a failed or timed + * out request. On timeout, the stanza will be null. + * (Integer) timeout - The time specified in milliseconds for a + * timeout to occur. + * + * Returns: + * The id used to send the IQ. + */ + sendIQ(elem: Element | Builder, callback?: (stanza: Element) => any, errback?: (stanza: Element) => any, timeout?: number): string; //todo: Is callback correct? + + /** Function: addTimedHandler + * Add a timed handler to the connection. + * + * This function adds a timed handler. The provided handler will + * be called every period milliseconds until it returns false, + * the connection is terminated, or the handler is removed. Handlers + * that wish to continue being invoked should return true. + * + * Because of method binding it is necessary to save the result of + * this function if you wish to remove a handler with + * deleteTimedHandler(). + * + * Note that user handlers are not active until authentication is + * successful. + * + * Parameters: + * (Integer) period - The period of the handler. + * (Function) handler - The callback function. + * + * Returns: + * A reference to the handler that can be used to remove it. + */ + addTimedHandler(period: number, handler: () => boolean): any; + + /** Function: deleteTimedHandler + * Delete a timed handler for a connection. + * + * This function removes a timed handler from the connection. The + * handRef parameter is *not* the function passed to addTimedHandler(), + * but is the reference returned from addTimedHandler(). + * + * Parameters: + * (Strophe.TimedHandler) handRef - The handler reference. + */ + deleteTimedHandler(handRef: any): void; + + + /** Function: addHandler + * Add a stanza handler for the connection. + * + * This function adds a stanza handler to the connection. The + * handler callback will be called for any stanza that matches + * the parameters. Note that if multiple parameters are supplied, + * they must all match for the handler to be invoked. + * + * The handler will receive the stanza that triggered it as its argument. + * *The handler should return true if it is to be invoked again; + * returning false will remove the handler after it returns.* + * + * As a convenience, the ns parameters applies to the top level element + * and also any of its immediate children. This is primarily to make + * matching /iq/query elements easy. + * + * The options argument contains handler matching flags that affect how + * matches are determined. Currently the only flag is matchBare (a + * boolean). When matchBare is true, the from parameter and the from + * attribute on the stanza will be matched as bare JIDs instead of + * full JIDs. To use this, pass {matchBare: true} as the value of + * options. The default value for matchBare is false. + * + * The return value should be saved if you wish to remove the handler + * with deleteHandler(). + * + * Parameters: + * (Function) handler - The user callback. + * (String) ns - The namespace to match. + * (String) name - The stanza name to match. + * (String) type - The stanza type attribute to match. + * (String) id - The stanza id attribute to match. + * (String) from - The stanza from attribute to match. + * (String) options - The handler options + * + * Returns: + * A reference to the handler that can be used to remove it. + */ + addHandler(handler: (stanza: Element) => boolean, ns: string, name: string, type?: string, id?: string, from?: string, options?: { matchBare: boolean }): any; //todo: is callback correct? Also, are the elements specified as optional truly optional? + + /** Function: deleteHandler + * Delete a stanza handler for a connection. + * + * This function removes a stanza handler from the connection. The + * handRef parameter is *not* the function passed to addHandler(), + * but is the reference returned from addHandler(). + * + * Parameters: + * (Strophe.Handler) handRef - The handler reference. + */ + deleteHandler(handRef: any): void; + + /** Function: disconnect + * Start the graceful disconnection process. + * + * This function starts the disconnection process. This process starts + * by sending unavailable presence and sending BOSH body of type + * terminate. A timeout handler makes sure that disconnection happens + * even if the BOSH server does not respond. + * If the Connection object isn't connected, at least tries to abort all pending requests + * so the connection object won't generate successful requests (which were already opened). + * + * The user supplied connection callback will be notified of the + * progress as this process happens. + * + * Parameters: + * (String) reason - The reason the disconnect is occuring. + */ + disconnect(reason: string): void; + } + + /** Interface: Strophe.SASLMechanism + * + * encapsulates SASL authentication mechanisms. + * + * User code may override the priority for each mechanism or disable it completely. + * See for information about changing priority and for informatian on + * how to disable a mechanism. + * + * By default, all mechanisms are enabled and the priorities are + * + * SCRAM-SHA1 - 40 + * DIGEST-MD5 - 30 + * Plain - 20 + */ + interface SASLMechanism { + /** + * Function: test + * Checks if mechanism able to run. + * To disable a mechanism, make this return false; + * + * To disable plain authentication run + * > Strophe.SASLPlain.test = function() { + * > return false; + * > } + * + * See for a list of available mechanisms. + * + * Parameters: + * (Strophe.Connection) connection - Target Connection. + * + * Returns: + * (Boolean) If mechanism was able to run. + */ + test(connection: Connection): boolean; + + /** Variable: priority + * Determines which is chosen for authentication (Higher is better). + * Users may override this to prioritize mechanisms differently. + * + * In the default configuration the priorities are + * + * SCRAM-SHA1 - 40 + * DIGEST-MD5 - 30 + * Plain - 20 + * + * Example: (This will cause Strophe to choose the mechanism that the server sent first) + * + * > Strophe.SASLMD5.priority = Strophe.SASLSHA1.priority; + * + * See for a list of available mechanisms. + * + */ + priority: number; + } + + /** Constants: SASL mechanisms + * Available authentication mechanisms + * + * Strophe.SASLAnonymous - SASL Anonymous authentication. + * Strophe.SASLPlain - SASL Plain authentication. + * Strophe.SASLMD5 - SASL Digest-MD5 authentication + * Strophe.SASLSHA1 - SASL SCRAM-SHA1 authentication + */ + var SASLAnonymous: SASLMechanism; + var SASLPlain: SASLMechanism; + var SASLSHA1: SASLMechanism; + var SASLMD5: SASLMechanism; + } +} /** Function: $build - * Create a Strophe.Builder. - * This is an alias for 'new Strophe.Builder(name, attrs)'. - * - * Parameters: - * (String) name - The root element name. - * (Object) attrs - The attributes for the root element in object notation. - * - * Returns: - * A new Strophe.Builder object. - */ -declare function $build(name: string, attrs?: any): Strophe.Builder; + * Create a Strophe.Builder. + * This is an alias for 'new Strophe.Builder(name, attrs)'. + * + * Parameters: + * (String) name - The root element name. + * (Object) attrs - The attributes for the root element in object notation. + * + * Returns: + * A new Strophe.Builder object. + */ +declare function $build(name: string, attrs?: any): wrapper.Strophe.Builder; /** Function: $msg - * Create a Strophe.Builder with a element as the root. - * - * Parmaeters: - * (Object) attrs - The element attributes in object notation. - * - * Returns: - * A new Strophe.Builder object. - */ -declare function $msg(attrs?: any): Strophe.Builder; + * Create a Strophe.Builder with a element as the root. + * + * Parmaeters: + * (Object) attrs - The element attributes in object notation. + * + * Returns: + * A new Strophe.Builder object. + */ +declare function $msg(attrs?: any): wrapper.Strophe.Builder; /** Function: $iq * Create a Strophe.Builder with an element as the root. @@ -36,7 +1100,7 @@ declare function $msg(attrs?: any): Strophe.Builder; * Returns: * A new Strophe.Builder object. */ -declare function $iq(attrs?: any): Strophe.Builder; +declare function $iq(attrs?: any): wrapper.Strophe.Builder; /** Function: $pres * Create a Strophe.Builder with a element as the root. @@ -47,1027 +1111,26 @@ declare function $iq(attrs?: any): Strophe.Builder; * Returns: * A new Strophe.Builder object. */ -declare function $pres(attrs?: any): Strophe.Builder; +declare function $pres(attrs?: any): wrapper.Strophe.Builder; + +import Strophe = wrapper.Strophe; // Support AMD require +declare module '$build' { + export = wrapper.$build; +} +declare module '$msg' { + export = wrapper.$msg; +} +declare module '$iq' { + export = wrapper.$iq; +} +declare module '$pres' { + export = wrapper.$pres; +} declare module 'Strophe' { - export = Strophe; + export = wrapper.Strophe; } - -declare module Strophe { - /** Constant: VERSION - * The version of the Strophe library. Unreleased builds will have - * a version of head-HASH where HASH is a partial revision. - */ - var VERSION: string; - - /** Constants: XMPP Namespace Constants - * Common namespace constants from the XMPP RFCs and XEPs. - * - * NS.HTTPBIND - HTTP BIND namespace from XEP 124. - * NS.BOSH - BOSH namespace from XEP 206. - * NS.CLIENT - Main XMPP client namespace. - * NS.AUTH - Legacy authentication namespace. - * NS.ROSTER - Roster operations namespace. - * NS.PROFILE - Profile namespace. - * NS.DISCO_INFO - Service discovery info namespace from XEP 30. - * NS.DISCO_ITEMS - Service discovery items namespace from XEP 30. - * NS.MUC - Multi-User Chat namespace from XEP 45. - * NS.SASL - XMPP SASL namespace from RFC 3920. - * NS.STREAM - XMPP Streams namespace from RFC 3920. - * NS.BIND - XMPP Binding namespace from RFC 3920. - * NS.SESSION - XMPP Session namespace from RFC 3920. - * NS.XHTML_IM - XHTML-IM namespace from XEP 71. - * NS.XHTML - XHTML body namespace from XEP 71. - */ - var NS: { - HTTPBIND: string; - BOSH: string; - CLIENT: string; - AUTH: string; - ROSTER: string; - PROFILE: string; - DISCO_INFO: string; - DISCO_ITEMS: string; - MUC: string; - SASL: string; - STREAM: string; - FRAMING: string; - BIND: string; - SESSION: string; - VERSION: string; - STANZAS: string; - XHTML_IM: string; - XHTML: string; - } - - /** Constants: Connection Status Constants - * Connection status constants for use by the connection handler - * callback. - * - * Status.ERROR - An error has occurred - * Status.CONNECTING - The connection is currently being made - * Status.CONNFAIL - The connection attempt failed - * Status.AUTHENTICATING - The connection is authenticating - * Status.AUTHFAIL - The authentication attempt failed - * Status.CONNECTED - The connection has succeeded - * Status.DISCONNECTED - The connection has been terminated - * Status.DISCONNECTING - The connection is currently being terminated - * Status.ATTACHED - The connection has been attached - */ - enum Status { - ERROR, - CONNECTING, - CONNFAIL, - AUTHENTICATING, - AUTHFAIL, - CONNECTED, - DISCONNECTED, - DISCONNECTING, - ATTACHED, - REDIRECT - } - - /** Constants: Log Level Constants - * Logging level indicators. - * - * LogLevel.DEBUG - Debug output - * LogLevel.INFO - Informational output - * LogLevel.WARN - Warnings - * LogLevel.ERROR - Errors - * LogLevel.FATAL - Fatal errors - */ - enum LogLevel { - DEBUG, - INFO, - WARN, - ERROR, - FATAL - } - - /** Function: addNamespace - * This function is used to extend the current namespaces in - * Strophe.NS. It takes a key and a value with the key being the - * name of the new namespace, with its actual value. - * For example: - * Strophe.addNamespace('PUBSUB', "http://jabber.org/protocol/pubsub"); - * - * Parameters: - * (String) name - The name under which the namespace will be - * referenced under Strophe.NS - * (String) value - The actual namespace. - */ - function addNamespace(name: string, value: string): void; - - /** Function: forEachChild - * Map a function over some or all child elements of a given element. - * - * This is a small convenience function for mapping a function over - * some or all of the children of an element. If elemName is null, all - * children will be passed to the function, otherwise only children - * whose tag names match elemName will be passed. - * - * Parameters: - * (XMLElement) elem - The element to operate on. - * (String) elemName - The child element tag name filter. - * (Function) func - The function to apply to each child. This - * function should take a single argument, a DOM element. - */ - function forEachChild(elem: Element, elemName: string, func:(child: Element) => any): void; - - /** Function: isTagEqual - * Compare an element's tag name with a string. - * - * This function is case sensitive. - * - * Parameters: - * (XMLElement) el - A DOM element. - * (String) name - The element name. - * - * Returns: - * true if the element's tag name matches _el_, and false - * otherwise. - */ - function isTagEqual(el: Element, name: string): boolean; - - /** Function: xmlGenerator - * Get the DOM document to generate elements. - * - * Returns: - * The currently used DOM document. - */ - function xmlGenerator(): Document; - - /** Function: xmlElement - * Create an XML DOM element. - * - * This function creates an XML DOM element correctly across all - * implementations. Note that these are not HTML DOM elements, which - * aren't appropriate for XMPP stanzas. - * - * Parameters: - * (String) name - The name for the element. - * (Array|Object) attrs - An optional array or object containing - * key/value pairs to use as element attributes. The object should - * be in the format {'key': 'value'} or {key: 'value'}. The array - * should have the format [['key1', 'value1'], ['key2', 'value2']]. - * (String) text - The text child data for the element. - * - * Returns: - * A new XML DOM element. - */ - function xmlElement(name: string, attrs?: any, text?: string): Element; - function xmlElement(name: string, text?: string, attrs?: any): Element; - - /* Function: xmlescape - * Excapes invalid xml characters. - * - * Parameters: - * (String) text - text to escape. - * - * Returns: - * Escaped text. - */ - function xmlescape(text: string): string; - - /* Function: xmlunescape - * Unexcapes invalid xml characters. - * - * Parameters: - * (String) text - text to unescape. - * - * Returns: - * Unescaped text. - */ - function xmlunescape(text: string): string; - - /** Function: xmlTextNode - * Creates an XML DOM text node. - * - * Provides a cross implementation version of document.createTextNode. - * - * Parameters: - * (String) text - The content of the text node. - * - * Returns: - * A new XML DOM text node. - */ - function xmlTextNode(text: string): Text; - - /** Function: xmlHtmlNode - * Creates an XML DOM html node. - * - * Parameters: - * (String) html - The content of the html node. - * - * Returns: - * A new XML DOM text node. - */ - function xmlHtmlNode(html: string): Document; - - /** Function: getText - * Get the concatenation of all text children of an element. - * - * Parameters: - * (XMLElement) elem - A DOM element. - * - * Returns: - * A String with the concatenated text of all text element children. - */ - function getText(elem: Element): string; - - /** Function: copyElement - * Copy an XML DOM element. - * - * This function copies a DOM element and all its descendants and returns - * the new copy. - * - * Parameters: - * (XMLElement) elem - A DOM element. - * - * Returns: - * A new, copied DOM element tree. - */ - function copyElement(elem: Element): Element; - - /** Function: createHtml - * Copy an HTML DOM element into an XML DOM. - * - * This function copies a DOM element and all its descendants and returns - * the new copy. - * - * Parameters: - * (Element) elem - A DOM element. - * - * Returns: - * A new, copied DOM element tree. - */ - function createHtml(elem: Element): Element; - - /** Function: escapeNode - * Escape the node part (also called local part) of a JID. - * - * Parameters: - * (String) node - A node (or local part). - * - * Returns: - * An escaped node (or local part). - */ - function escapeNode(node: string): string; - - /** Function: unescapeNode - * Unescape a node part (also called local part) of a JID. - * - * Parameters: - * (String) node - A node (or local part). - * - * Returns: - * An unescaped node (or local part). - */ - function unescapeNode(node: string): string; - - /** Function: getNodeFromJid - * Get the node portion of a JID String. - * - * Parameters: - * (String) jid - A JID. - * - * Returns: - * A String containing the node. - */ - function getNodeFromJid(jid: string): string; - - /** Function: getDomainFromJid - * Get the domain portion of a JID String. - * - * Parameters: - * (String) jid - A JID. - * - * Returns: - * A String containing the domain. - */ - function getDomainFromJid(jid: string): string; - - /** Function: getResourceFromJid - * Get the resource portion of a JID String. - * - * Parameters: - * (String) jid - A JID. - * - * Returns: - * A String containing the resource. - */ - function getResourceFromJid(jid: string): string; - - /** Function: getBareJidFromJid - * Get the bare JID from a JID String. - * - * Parameters: - * (String) jid - A JID. - * - * Returns: - * A String containing the bare JID. - */ - function getBareJidFromJid(jid: string): string; - - /** Function: log - * User overrideable logging function. - * - * This function is called whenever the Strophe library calls any - * of the logging functions. The default implementation of this - * function does nothing. If client code wishes to handle the logging - * messages, it should override this with - * > Strophe.log = function (level, msg) { - * > (user code here) - * > }; - * - * Please note that data sent and received over the wire is logged - * via Strophe.Connection.rawInput() and Strophe.Connection.rawOutput(). - * - * The different levels and their meanings are - * - * DEBUG - Messages useful for debugging purposes. - * INFO - Informational messages. This is mostly information like - * 'disconnect was called' or 'SASL auth succeeded'. - * WARN - Warnings about potential problems. This is mostly used - * to report transient connection errors like request timeouts. - * ERROR - Some error occurred. - * FATAL - A non-recoverable fatal error occurred. - * - * Parameters: - * (Integer) level - The log level of the log message. This will - * be one of the values in Strophe.LogLevel. - * (String) msg - The log message. - */ - function log(level: LogLevel, msg: string): void; - - /** Functions: debug, info, warn, error - * Log a message at the appropriate Strophe.LogLevel - * - * Parameters: - * (String) msg - The log message. - */ - function debug(msg: string): void; - function info(msg: string): void; - function warn(msg: string): void; - function error(msg: string): void; - function fatal(msg: string): void; - - /** Function: serialize - * Render a DOM element and all descendants to a String. - * - * Parameters: - * (XMLElement) elem - A DOM element. - * - * Returns: - * The serialized element tree as a String. - */ - function serialize(elem: Element | Builder): string; - - /** Function: addConnectionPlugin - * Extends the Strophe.Connection object with the given plugin. - * - * Parameters: - * (String) name - The name of the extension. - * (Object) ptype - The plugin's prototype. - */ - function addConnectionPlugin(name: string, ptype: any): void; - - var Builder: { - /** Constructor: Strophe.Builder - * Create a Strophe.Builder object. - * - * The attributes should be passed in object notation. For example - * > var b = new Builder('message', {to: 'you', from: 'me'}); - * or - * > var b = new Builder('messsage', {'xml:lang': 'en'}); - * - * Parameters: - * (String) name - The name of the root element. - * (Object) attrs - The attributes for the root element in object notation. - * - * Returns: - * A new Strophe.Builder. - */ - new (name: string, attrs?: any): Builder; - prototype: any; - } - - - /** Class: Strophe.Builder - * XML DOM builder. - * - * This object provides an interface similar to JQuery but for building - * DOM element easily and rapidly. All the functions except for toString() - * and tree() return the object, so calls can be chained. Here's an - * example using the $iq() builder helper. - * > $iq({to: 'you', from: 'me', type: 'get', id: '1'}) - * > .c('query', {xmlns: 'strophe:example'}) - * > .c('example') - * > .toString() - * The above generates this XML fragment - * > - * > - * > - * > - * > - * The corresponding DOM manipulations to get a similar fragment would be - * a lot more tedious and probably involve several helper variables. - * - * Since adding children makes new operations operate on the child, up() - * is provided to traverse up the tree. To add two children, do - * > builder.c('child1', ...).up().c('child2', ...) - * The next operation on the Builder will be relative to the second child. - */ - interface Builder { - /** Function: tree - * Return the DOM tree. - * - * This function returns the current DOM tree as an element object. This - * is suitable for passing to functions like Strophe.Connection.send(). - * - * Returns: - * The DOM tree as a element object. - */ - tree(): Element; - - /** Function: toString - * Serialize the DOM tree to a String. - * - * This function returns a string serialization of the current DOM - * tree. It is often used internally to pass data to a - * Strophe.Request object. - * - * Returns: - * The serialized DOM tree in a String. - */ - toString(): string; - - /** Function: up - * Make the current parent element the new current element. - * - * This function is often used after c() to traverse back up the tree. - * For example, to add two children to the same element - * > builder.c('child1', {}).up().c('child2', {}); - * - * Returns: - * The Stophe.Builder object. - */ - up(): Builder; - - /** Function: attrs - * Add or modify attributes of the current element. - * - * The attributes should be passed in object notation. This function - * does not move the current element pointer. - * - * Parameters: - * (Object) moreattrs - The attributes to add/modify in object notation. - * - * Returns: - * The Strophe.Builder object. - */ - attrs(moreattrs: any): Builder; - - /** Function: c - * Add a child to the current element and make it the new current - * element. - * - * This function moves the current element pointer to the child, - * unless text is provided. If you need to add another child, it - * is necessary to use up() to go back to the parent in the tree. - * - * Parameters: - * (String) name - The name of the child. - * (Object) attrs - The attributes of the child in object notation. - * (String) text - The text to add to the child. - * - * Returns: - * The Strophe.Builder object. - */ - c(name: string, attrs?: any, text?: string): Builder; - - /** Function: cnode - * Add a child to the current element and make it the new current - * element. - * - * This function is the same as c() except that instead of using a - * name and an attributes object to create the child it uses an - * existing DOM element object. - * - * Parameters: - * (XMLElement) elem - A DOM element. - * - * Returns: - * The Strophe.Builder object. - */ - cnode(elem: Node): Builder; - - /** Function: t - * Add a child text element. - * - * This *does not* make the child the new current element since there - * are no children of text elements. - * - * Parameters: - * (String) text - The text data to append to the current element. - * - * Returns: - * The Strophe.Builder object. - */ - t(text: string): Builder; - - /** Function: h - * Replace current element contents with the HTML passed in. - * - * This *does not* make the child the new current element - * - * Parameters: - * (String) html - The html to insert as contents of current element. - * - * Returns: - * The Strophe.Builder object. - */ - h(html: string): Builder; - } - - interface ConnectionOptions { - protocol?: string; - sync?: boolean; - } - var Connection: { - /** Constructor: Strophe.Connection - * Create and initialize a Strophe.Connection object. - * - * The transport-protocol for this connection will be chosen automatically - * based on the given service parameter. URLs starting with "ws://" or - * "wss://" will use WebSockets, URLs starting with "http://", "https://" - * or without a protocol will use BOSH. - * - * To make Strophe connect to the current host you can leave out the protocol - * and host part and just pass the path, e.g. - * - * > var conn = new Strophe.Connection("/http-bind/"); - * - * WebSocket options: - * - * If you want to connect to the current host with a WebSocket connection you - * can tell Strophe to use WebSockets through a "protocol" attribute in the - * optional options parameter. Valid values are "ws" for WebSocket and "wss" - * for Secure WebSocket. - * So to connect to "wss://CURRENT_HOSTNAME/xmpp-websocket" you would call - * - * > var conn = new Strophe.Connection("/xmpp-websocket/", {protocol: "wss"}); - * - * Note that relative URLs _NOT_ starting with a "/" will also include the path - * of the current site. - * - * Also because downgrading security is not permitted by browsers, when using - * relative URLs both BOSH and WebSocket connections will use their secure - * variants if the current connection to the site is also secure (https). - * - * BOSH options: - * - * by adding "sync" to the options, you can control if requests will - * be made synchronously or not. The default behaviour is asynchronous. - * If you want to make requests synchronous, make "sync" evaluate to true: - * > var conn = new Strophe.Connection("/http-bind/", {sync: true}); - * You can also toggle this on an already established connection: - * > conn.options.sync = true; - * - * - * Parameters: - * (String) service - The BOSH or WebSocket service URL. - * (Object) options - A hash of configuration options - * - * Returns: - * A new Strophe.Connection object. - */ - new (service: string, options?: ConnectionOptions): Connection; - prototype: any; - } - - /** Class: Strophe.Connection - * XMPP Connection manager. - * - * This class is the main part of Strophe. It manages a BOSH connection - * to an XMPP server and dispatches events to the user callbacks as - * data arrives. It supports SASL PLAIN, SASL DIGEST-MD5, SASL SCRAM-SHA1 - * and legacy authentication. - * - * After creating a Strophe.Connection object, the user will typically - * call connect() with a user supplied callback to handle connection level - * events like authentication failure, disconnection, or connection - * complete. - * - * The user will also have several event handlers defined by using - * addHandler() and addTimedHandler(). These will allow the user code to - * respond to interesting stanzas or do something periodically with the - * connection. These handlers will be active once authentication is - * finished. - * - * To send data to the connection, use send(). - */ - interface Connection { - - jid: string; - authzid: string; - pass: string; - authcid: string; - domain: string; - servtype: string; - maxRetries: number; - //todo: what other members are meant to be public? - - /** Function: reset - * Reset the connection. - * - * This function should be called after a connection is disconnected - * before that connection is reused. - */ - reset(): void; - - /** Function: pause - * Pause the request manager. - * - * This will prevent Strophe from sending any more requests to the - * server. This is very useful for temporarily pausing - * BOSH-Connections while a lot of send() calls are happening quickly. - * This causes Strophe to send the data in a single request, saving - * many request trips. - */ - pause(): void; - - /** Function: resume - * Resume the request manager. - * - * This resumes after pause() has been called. - */ - resume(): void; - - /** Function: getUniqueId - * Generate a unique ID for use in elements. - * - * All stanzas are required to have unique id attributes. This - * function makes creating these easy. Each connection instance has - * a counter which starts from zero, and the value of this counter - * plus a colon followed by the suffix becomes the unique id. If no - * suffix is supplied, the counter is used as the unique id. - * - * Suffixes are used to make debugging easier when reading the stream - * data, and their use is recommended. The counter resets to 0 for - * every new connection for the same reason. For connections to the - * same server that authenticate the same way, all the ids should be - * the same, which makes it easy to see changes. This is useful for - * automated testing as well. - * - * Parameters: - * (String) suffix - A optional suffix to append to the id. - * - * Returns: - * A unique string to be used for the id attribute. - */ - getUniqueId(suffix?: string | number): string; - - /** Function: connect - * Starts the connection process. - * - * As the connection process proceeds, the user supplied callback will - * be triggered multiple times with status updates. The callback - * should take two arguments - the status code and the error condition. - * - * The status code will be one of the values in the Strophe.Status - * constants. The error condition will be one of the conditions - * defined in RFC 3920 or the condition 'strophe-parsererror'. - * - * The Parameters _wait_, _hold_ and _route_ are optional and only relevant - * for BOSH connections. Please see XEP 124 for a more detailed explanation - * of the optional parameters. - * - * Parameters: - * (String) jid - The user's JID. This may be a bare JID, - * or a full JID. If a node is not supplied, SASL ANONYMOUS - * authentication will be attempted. - * (String) pass - The user's password. - * (Function) callback - The connect callback function. - * (Integer) wait - The optional HTTPBIND wait value. This is the - * time the server will wait before returning an empty result for - * a request. The default setting of 60 seconds is recommended. - * (Integer) hold - The optional HTTPBIND hold value. This is the - * number of connections the server will hold at one time. This - * should almost always be set to 1 (the default). - * (String) route - The optional route value. - */ - connect(jid?: string, pass?: string, callback?: (status: Status, condition: string) => any, wait?: number, hold?: number, route?: string): void; - - /** Function: attach - * Attach to an already created and authenticated BOSH session. - * - * This function is provided to allow Strophe to attach to BOSH - * sessions which have been created externally, perhaps by a Web - * application. This is often used to support auto-login type features - * without putting user credentials into the page. - * - * Parameters: - * (String) jid - The full JID that is bound by the session. - * (String) sid - The SID of the BOSH session. - * (String) rid - The current RID of the BOSH session. This RID - * will be used by the next request. - * (Function) callback The connect callback function. - * (Integer) wait - The optional HTTPBIND wait value. This is the - * time the server will wait before returning an empty result for - * a request. The default setting of 60 seconds is recommended. - * Other settings will require tweaks to the Strophe.TIMEOUT value. - * (Integer) hold - The optional HTTPBIND hold value. This is the - * number of connections the server will hold at one time. This - * should almost always be set to 1 (the default). - * (Integer) wind - The optional HTTBIND window value. This is the - * allowed range of request ids that are valid. The default is 5. - */ - attach(jid: string, sid: string, rid: string, callback?: (status: Status, condition: string) => any, wait?: number, hold?: number, wind?: number): void; - - /** Function: xmlInput - * User overrideable function that receives XML data coming into the - * connection. - * - * The default function does nothing. User code can override this with - * > Strophe.Connection.xmlInput = function (elem) { - * > (user code) - * > }; - * - * Due to limitations of current Browsers' XML-Parsers the opening and closing - * tag for WebSocket-Connoctions will be passed as selfclosing here. - * - * BOSH-Connections will have all stanzas wrapped in a tag. See - * if you want to strip this tag. - * - * Parameters: - * (XMLElement) elem - The XML data received by the connection. - */ - xmlInput(elem: Element): void; - - /** Function: xmlOutput - * User overrideable function that receives XML data sent to the - * connection. - * - * The default function does nothing. User code can override this with - * > Strophe.Connection.xmlOutput = function (elem) { - * > (user code) - * > }; - * - * Due to limitations of current Browsers' XML-Parsers the opening and closing - * tag for WebSocket-Connoctions will be passed as selfclosing here. - * - * BOSH-Connections will have all stanzas wrapped in a tag. See - * if you want to strip this tag. - * - * Parameters: - * (XMLElement) elem - The XMLdata sent by the connection. - */ - xmlOutput(elem: Element): void; - - /** Function: rawInput - * User overrideable function that receives raw data coming into the - * connection. - * - * The default function does nothing. User code can override this with - * > Strophe.Connection.rawInput = function (data) { - * > (user code) - * > }; - * - * Parameters: - * (String) data - The data received by the connection. - */ - rawInput(data: string): void; - - /** Function: rawOutput - * User overrideable function that receives raw data sent to the - * connection. - * - * The default function does nothing. User code can override this with - * > Strophe.Connection.rawOutput = function (data) { - * > (user code) - * > }; - * - * Parameters: - * (String) data - The data sent by the connection. - */ - rawOutput(data: string): void; - - /** Function: send - * Send a stanza. - * - * This function is called to push data onto the send queue to - * go out over the wire. Whenever a request is sent to the BOSH - * server, all pending data is sent and the queue is flushed. - * - * Parameters: - * (XMLElement | - * [XMLElement] | - * Strophe.Builder) elem - The stanza to send. - */ - send(elem: Element | Element[]| Builder): void; - - /** Function: flush - * Immediately send any pending outgoing data. - * - * Normally send() queues outgoing data until the next idle period - * (100ms), which optimizes network use in the common cases when - * several send()s are called in succession. flush() can be used to - * immediately send all pending data. - */ - flush(): void; - - /** Function: sendIQ - * Helper function to send IQ stanzas. - * - * Parameters: - * (XMLElement) elem - The stanza to send. - * (Function) callback - The callback function for a successful request. - * (Function) errback - The callback function for a failed or timed - * out request. On timeout, the stanza will be null. - * (Integer) timeout - The time specified in milliseconds for a - * timeout to occur. - * - * Returns: - * The id used to send the IQ. - */ - sendIQ(elem: Element | Builder, callback?: (stanza: Element) => any, errback?: (stanza: Element) => any, timeout?: number): string; //todo: Is callback correct? - - /** Function: addTimedHandler - * Add a timed handler to the connection. - * - * This function adds a timed handler. The provided handler will - * be called every period milliseconds until it returns false, - * the connection is terminated, or the handler is removed. Handlers - * that wish to continue being invoked should return true. - * - * Because of method binding it is necessary to save the result of - * this function if you wish to remove a handler with - * deleteTimedHandler(). - * - * Note that user handlers are not active until authentication is - * successful. - * - * Parameters: - * (Integer) period - The period of the handler. - * (Function) handler - The callback function. - * - * Returns: - * A reference to the handler that can be used to remove it. - */ - addTimedHandler(period: number, handler: () => boolean): any; - - /** Function: deleteTimedHandler - * Delete a timed handler for a connection. - * - * This function removes a timed handler from the connection. The - * handRef parameter is *not* the function passed to addTimedHandler(), - * but is the reference returned from addTimedHandler(). - * - * Parameters: - * (Strophe.TimedHandler) handRef - The handler reference. - */ - deleteTimedHandler(handRef: any): void; - - - /** Function: addHandler - * Add a stanza handler for the connection. - * - * This function adds a stanza handler to the connection. The - * handler callback will be called for any stanza that matches - * the parameters. Note that if multiple parameters are supplied, - * they must all match for the handler to be invoked. - * - * The handler will receive the stanza that triggered it as its argument. - * *The handler should return true if it is to be invoked again; - * returning false will remove the handler after it returns.* - * - * As a convenience, the ns parameters applies to the top level element - * and also any of its immediate children. This is primarily to make - * matching /iq/query elements easy. - * - * The options argument contains handler matching flags that affect how - * matches are determined. Currently the only flag is matchBare (a - * boolean). When matchBare is true, the from parameter and the from - * attribute on the stanza will be matched as bare JIDs instead of - * full JIDs. To use this, pass {matchBare: true} as the value of - * options. The default value for matchBare is false. - * - * The return value should be saved if you wish to remove the handler - * with deleteHandler(). - * - * Parameters: - * (Function) handler - The user callback. - * (String) ns - The namespace to match. - * (String) name - The stanza name to match. - * (String) type - The stanza type attribute to match. - * (String) id - The stanza id attribute to match. - * (String) from - The stanza from attribute to match. - * (String) options - The handler options - * - * Returns: - * A reference to the handler that can be used to remove it. - */ - addHandler(handler: (stanza: Element) => boolean, ns: string, name: string, type?: string, id?: string, from?: string, options?: { matchBare: boolean }): any; //todo: is callback correct? Also, are the elements specified as optional truly optional? - - /** Function: deleteHandler - * Delete a stanza handler for a connection. - * - * This function removes a stanza handler from the connection. The - * handRef parameter is *not* the function passed to addHandler(), - * but is the reference returned from addHandler(). - * - * Parameters: - * (Strophe.Handler) handRef - The handler reference. - */ - deleteHandler(handRef: any): void; - - /** Function: disconnect - * Start the graceful disconnection process. - * - * This function starts the disconnection process. This process starts - * by sending unavailable presence and sending BOSH body of type - * terminate. A timeout handler makes sure that disconnection happens - * even if the BOSH server does not respond. - * If the Connection object isn't connected, at least tries to abort all pending requests - * so the connection object won't generate successful requests (which were already opened). - * - * The user supplied connection callback will be notified of the - * progress as this process happens. - * - * Parameters: - * (String) reason - The reason the disconnect is occuring. - */ - disconnect(reason: string): void; - } - - /** Interface: Strophe.SASLMechanism - * - * encapsulates SASL authentication mechanisms. - * - * User code may override the priority for each mechanism or disable it completely. - * See for information about changing priority and for informatian on - * how to disable a mechanism. - * - * By default, all mechanisms are enabled and the priorities are - * - * SCRAM-SHA1 - 40 - * DIGEST-MD5 - 30 - * Plain - 20 - */ - interface SASLMechanism { - /** - * Function: test - * Checks if mechanism able to run. - * To disable a mechanism, make this return false; - * - * To disable plain authentication run - * > Strophe.SASLPlain.test = function() { - * > return false; - * > } - * - * See for a list of available mechanisms. - * - * Parameters: - * (Strophe.Connection) connection - Target Connection. - * - * Returns: - * (Boolean) If mechanism was able to run. - */ - test(connection: Connection): boolean; - - /** Variable: priority - * Determines which is chosen for authentication (Higher is better). - * Users may override this to prioritize mechanisms differently. - * - * In the default configuration the priorities are - * - * SCRAM-SHA1 - 40 - * DIGEST-MD5 - 30 - * Plain - 20 - * - * Example: (This will cause Strophe to choose the mechanism that the server sent first) - * - * > Strophe.SASLMD5.priority = Strophe.SASLSHA1.priority; - * - * See for a list of available mechanisms. - * - */ - priority: number; - } - - /** Constants: SASL mechanisms - * Available authentication mechanisms - * - * Strophe.SASLAnonymous - SASL Anonymous authentication. - * Strophe.SASLPlain - SASL Plain authentication. - * Strophe.SASLMD5 - SASL Digest-MD5 authentication - * Strophe.SASLSHA1 - SASL SCRAM-SHA1 authentication - */ - var SASLAnonymous: SASLMechanism; - var SASLPlain: SASLMechanism; - var SASLSHA1: SASLMechanism; - var SASLMD5: SASLMechanism; +declare module 'strophe' { + export = wrapper; } - From 811d795bce313be675267ce9b727701b19b724a8 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Sun, 27 Sep 2015 11:32:08 +0500 Subject: [PATCH 32/64] lodash: added _.matches() method --- lodash/lodash-tests.ts | 17 +++++++++++++++++ lodash/lodash.d.ts | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 1d5525300..8a66f8da1 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -2412,6 +2412,23 @@ result = <() => {}>_({}).constant<{}>(); result = _({}).iteratee(any).value(); } +// _.matches +module TestMatches { + let source: TResult; + + { + let result: (value: any) => boolean; + result = _.matches(source); + result = _(source).matches().value(); + } + + { + let result: (value: TResult) => boolean; + result = _.matches(source); + result = _(source).matches().value(); + } +} + // _.method class TestMethod { a = { diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 102811a16..db17ff79a 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -8449,6 +8449,38 @@ declare module _ { iteratee(thisArg?: any): LoDashObjectWrapper<(...args: any[]) => TResult>; } + //_.matches + interface LoDashStatic { + /** + * Creates a function that performs a deep comparison between a given object and source, returning true if the + * given object has equivalent property values, else false. + * + * Note: This method supports comparing arrays, booleans, Date objects, numbers, Object objects, regexes, and + * strings. Objects are compared by their own, not inherited, enumerable properties. For comparing a single own + * or inherited property value see _.matchesProperty. + * + * @param source The object of property values to match. + * @return Returns the new function. + */ + matches( + source: T + ): (value: any) => boolean; + + /** + * @see _.matches + */ + matches( + source: T + ): (value: V) => boolean; + } + + interface LoDashWrapperBase { + /** + * @see _.matches + */ + matches(): LoDashObjectWrapper<(value: V) => boolean>; + } + //_.method interface LoDashStatic { /** From adb9289a589ae1a51d323dd3a2a7a93cf3f1d016 Mon Sep 17 00:00:00 2001 From: Igor Sechyn Date: Mon, 28 Sep 2015 07:43:30 +1000 Subject: [PATCH 33/64] reverted travis ci changes in readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 770777117..5cc7045d7 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# DefinitelyTyped [![Build Status](https://travis-ci.org/igorsechyn/DefinitelyTyped.png?branch=hystrixjs_definition)](https://travis-ci.org/igorsechyn/DefinitelyTyped) +# DefinitelyTyped [![Build Status](https://travis-ci.org/borisyankov/DefinitelyTyped.png?branch=master)](https://travis-ci.org/borisyankov/DefinitelyTyped) [![Join the chat at https://gitter.im/borisyankov/DefinitelyTyped](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/borisyankov/DefinitelyTyped?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) @@ -16,7 +16,7 @@ Include a line like this: ## Contributions -DefinitelyTyped only works because of contributions by users like you! +DefinitelyTyped only works because of contributions by users like you! Please see the [contribution guide](http://definitelytyped.org/guides/contributing.html) on how to contribute to DefinitelyTyped. From ac1292d9fc638271de1942c80948607c2b5503ba Mon Sep 17 00:00:00 2001 From: Shahar Talmi Date: Mon, 28 Sep 2015 01:21:23 +0300 Subject: [PATCH 34/64] Add missing literal/constant properties in ICompiledExpression As documented in https://docs.angularjs.org/api/ng/service/$parse --- angularjs/angular-tests.ts | 24 +++++++++++++++++------- angularjs/angular.d.ts | 3 +++ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/angularjs/angular-tests.ts b/angularjs/angular-tests.ts index 0174a0d61..94b38d565 100644 --- a/angularjs/angular-tests.ts +++ b/angularjs/angular-tests.ts @@ -387,31 +387,31 @@ module TestPromise { var tresult: TResult; var tresultPromise: ng.IPromise; - + var tother: TOther; var totherPromise: ng.IPromise; - + var promise: angular.IPromise; // promise.then result = >promise.then((result) => any); result = >promise.then((result) => any, (any) => any); result = >promise.then((result) => any, (any) => any, (any) => any); - + result = >promise.then((result) => result); result = >promise.then((result) => result, (any) => any); result = >promise.then((result) => result, (any) => any, (any) => any); result = >promise.then((result) => tresultPromise); result = >promise.then((result) => tresultPromise, (any) => any); result = >promise.then((result) => tresultPromise, (any) => any, (any) => any); - + result = >promise.then((result) => tother); result = >promise.then((result) => tother, (any) => any); result = >promise.then((result) => tother, (any) => any, (any) => any); result = >promise.then((result) => totherPromise); result = >promise.then((result) => totherPromise, (any) => any); result = >promise.then((result) => totherPromise, (any) => any, (any) => any); - + // promise.catch result = >promise.catch((err) => any); result = >promise.catch((err) => tresult); @@ -937,7 +937,7 @@ function NgModelControllerTyping() { function ngFilterTyping() { var $filter: angular.IFilterService; var items: string[]; - + $filter("name")(items, "test"); $filter("name")(items, {name: "test"}); $filter("name")(items, (val, index, array) => { @@ -948,4 +948,14 @@ function ngFilterTyping() { }, (actual, expected) => { return actual == expected; }); -} \ No newline at end of file +} + +function parseTyping() { + var $parse: angular.IParseService; + var compiledExp = $parse('a.b.c'); + if (compiledExp.constant) { + return compiledExp({}); + } else if (compiledExp.literal) { + return compiledExp({}, {a: {b: {c: 42}}}); + } +} diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index 9f7fa07b0..4abe6542d 100644 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -910,6 +910,9 @@ declare module angular { interface ICompiledExpression { (context: any, locals?: any): any; + literal: boolean; + constant: boolean; + // If value is not provided, undefined is gonna be used since the implementation // does not check the parameter. Let's force a value for consistency. If consumer // whants to undefine it, pass the undefined value explicitly. From 2ea60e19c0ab2d5152d93286db10b25a59357375 Mon Sep 17 00:00:00 2001 From: Justin Unterreiner Date: Sun, 27 Sep 2015 19:37:12 -0700 Subject: [PATCH 35/64] Renamed to urbanairship-cordova --- .../urbanairship-cordova-tests.ts | 2 +- .../urbanairship-cordova.d.ts | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename phonegap-ua-push/phonegap-ua-push-tests.ts => urbanairship-cordova/urbanairship-cordova-tests.ts (98%) rename phonegap-ua-push/phonegap-ua-push.d.ts => urbanairship-cordova/urbanairship-cordova.d.ts (100%) diff --git a/phonegap-ua-push/phonegap-ua-push-tests.ts b/urbanairship-cordova/urbanairship-cordova-tests.ts similarity index 98% rename from phonegap-ua-push/phonegap-ua-push-tests.ts rename to urbanairship-cordova/urbanairship-cordova-tests.ts index f9ac96c44..b8665be43 100644 --- a/phonegap-ua-push/phonegap-ua-push-tests.ts +++ b/urbanairship-cordova/urbanairship-cordova-tests.ts @@ -1,4 +1,4 @@ -/// +/// //#region Basic Example taken from http://docs.urbanairship.com/platform/phonegap.html#actions diff --git a/phonegap-ua-push/phonegap-ua-push.d.ts b/urbanairship-cordova/urbanairship-cordova.d.ts similarity index 100% rename from phonegap-ua-push/phonegap-ua-push.d.ts rename to urbanairship-cordova/urbanairship-cordova.d.ts From 3435a1eca98c629c59edfe645c7eab13b2e89db7 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Mon, 28 Sep 2015 10:50:05 +0500 Subject: [PATCH 36/64] lodash: changed _.findKey() method --- lodash/lodash-tests.ts | 28 ++++++++++++-- lodash/lodash.d.ts | 85 ++++++++++++++++++++++++++++++------------ 2 files changed, 86 insertions(+), 27 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 1d5525300..05bf046c0 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -1766,9 +1766,31 @@ var TestDefaultsDeepSource = {'user': {'name': 'fred', 'age': 36}}; result = _.defaultsDeep(TestDefaultsDeepObject, TestDefaultsDeepSource); result = _(TestDefaultsDeepObject).defaultsDeep(TestDefaultsDeepSource).value(); -result = _.findKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function (num) { - return num % 2 == 0; -}); +// _.findKey +module TestFindKey { + let predicateFn: (value: any, key?: string, object?: {}) => boolean; + let result: string; + + result = _.findKey<{a: string;}>({a: ''}); + + result = _.findKey<{a: string;}>({a: ''}, predicateFn); + result = _.findKey<{a: string;}>({a: ''}, predicateFn, any); + + result = _.findKey<{a: string;}>({a: ''}, ''); + result = _.findKey<{a: string;}>({a: ''}, '', any); + + result = _.findKey<{a: number;}, {a: string;}>({a: ''}, {a: 42}); + + result = _<{a: string;}>({a: ''}).findKey(); + + result = _<{a: string;}>({a: ''}).findKey(predicateFn); + result = _<{a: string;}>({a: ''}).findKey(predicateFn, any); + + result = _<{a: string;}>({a: ''}).findKey(''); + result = _<{a: string;}>({a: ''}).findKey('', any); + + result = _<{a: string;}>({a: ''}).findKey<{a: number;}>({a: 42}); +} result = _.findLastKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function (num) { return num % 2 == 1; diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 102811a16..48610c926 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -6951,33 +6951,70 @@ declare module _ { //_.findKey interface LoDashStatic { /** - * This method is like _.findIndex except that it returns the key of the first element that - * passes the callback check, instead of the element itself. - * @param object The object to search. - * @param callback The function called per iteration. - * @param thisArg The this binding of callback. - * @return The key of the found element, else undefined. - **/ - findKey( - object: any, - callback: (value: any) => boolean, - thisArg?: any): string; + * This method is like _.find except that it returns the key of the first element predicate returns truthy for + * instead of the element itself. + * + * If a property name is provided for predicate the created _.property style callback returns the property + * value of the given element. + * + * If a value is also provided for thisArg the created _.matchesProperty style callback returns true for + * elements that have a matching property value, else false. + * + * If an object is provided for predicate the created _.matches style callback returns true for elements that + * have the properties of the given object, else false. + * + * @param object The object to search. + * @param predicate The function invoked per iteration. + * @param thisArg The this binding of predicate. + * @return Returns the key of the matched element, else undefined. + */ + findKey( + object: TObject, + predicate?: ObjectIterator, + thisArg?: any + ): string; /** - * @see _.findKey - * @param pluckValue _.pluck style callback - **/ - findKey( - object: any, - pluckValue: string): string; + * @see _.findKey + */ + findKey( + object: TObject, + predicate?: string, + thisArg?: any + ): string; /** - * @see _.findKey - * @param whereValue _.where style callback - **/ - findKey, T>( - object: T, - whereValue: W): string; + * @see _.findKey + */ + findKey, TObject>( + object: TObject, + predicate?: TWhere + ): string; + } + + interface LoDashObjectWrapper { + /** + * @see _.findKey + */ + findKey( + predicate?: ObjectIterator, + thisArg?: any + ): string; + + /** + * @see _.findKey + */ + findKey( + predicate?: string, + thisArg?: any + ): string; + + /** + * @see _.findKey + */ + findKey>( + predicate?: TWhere + ): string; } //_.findLastKey @@ -8787,7 +8824,7 @@ declare module _ { } interface ObjectIterator { - (element: T, key: string, collection: any): TResult; + (element: T, key?: string, collection?: any): TResult; } interface MemoVoidIterator { From df92a872b9d6f2084d87b1a764c693c40911f8e5 Mon Sep 17 00:00:00 2001 From: use-strict Date: Mon, 28 Sep 2015 12:06:37 +0300 Subject: [PATCH 37/64] Paper and ToolbarTitle should allow regular HTML attributes. --- material-ui/material-ui.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/material-ui/material-ui.d.ts b/material-ui/material-ui.d.ts index c5c37ee91..627d91b58 100644 --- a/material-ui/material-ui.d.ts +++ b/material-ui/material-ui.d.ts @@ -654,7 +654,7 @@ declare namespace __MaterialUI { export class Overlay extends React.Component { } - interface PaperProps extends React.Props { + interface PaperProps extends React.HTMLAttributesBase { circle?: boolean; rounded?: boolean; transitionEnabled?: boolean; @@ -1256,7 +1256,7 @@ declare namespace __MaterialUI { export class ToolbarSeparator extends React.Component { } - interface ToolbarTitleProps extends React.Props { + interface ToolbarTitleProps extends React.HTMLAttributesBase { text?: string; } export class ToolbarTitle extends React.Component { From 4c5c2776008873e224d4b20eb5d1ebff70acd0e8 Mon Sep 17 00:00:00 2001 From: tigerxy Date: Mon, 28 Sep 2015 13:09:05 +0200 Subject: [PATCH 38/64] Typings changed --- jquery.soap/jquery.soap-tests.ts | 24 ++++++++++++------------ jquery.soap/jquery.soap.d.ts | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/jquery.soap/jquery.soap-tests.ts b/jquery.soap/jquery.soap-tests.ts index 3390c2774..e40379325 100644 --- a/jquery.soap/jquery.soap-tests.ts +++ b/jquery.soap/jquery.soap-tests.ts @@ -9,13 +9,13 @@ $.soap({ msg: 'Hi!' }, - success: function (soapResponse) { + success: function(soapResponse) { // do stuff with soapResponse // if you want to have the response as JSON use soapResponse.toJSON(); // or soapResponse.toString() to get XML string // or soapResponse.toXML() to get XML DOM }, - error: function (SOAPResponse) { + error: function(SOAPResponse) { // show error } }); @@ -77,7 +77,7 @@ $.soap({ }) $.soap({ - + }).done(function(data, textStatus, jqXHR) { // do stuff on success here... }).fail(function(jqXHR, textStatus, errorThrown) { @@ -88,7 +88,7 @@ $.soap({ url: 'http://my.server.com/soapservices/', namespaceQualifier: 'myns', namespaceURL: 'urn://service.my.server.com', - error: function (soapResponse) { + error: function(soapResponse) { // show error } }); @@ -99,7 +99,7 @@ $.soap({ name: 'Remy Blom', msg: 'Hi!' }, - success: function (soapResponse) { + success: function(soapResponse) { // do stuff with soapResponse } }); @@ -107,7 +107,7 @@ $.soap({ $.soap({ method: 'doSomethingElse', data: {}, - success: function (soapResponse) { + success: function(soapResponse) { // do stuff with soapResponse } }); @@ -119,10 +119,10 @@ $.soap({ name: 'Remy Blom', msg: 'Hi!' }, - success: function (soapResponse) { + success: function(soapResponse) { // do stuff with soapResponse }, - error: function (soapResponse) { + error: function(soapResponse) { alert('that other server might be down...') } }); @@ -174,10 +174,10 @@ $.soap({ var xml = ['', '', - '', - '', + '', + '', '', - '']; + '']; $.soap({ data: xml.join('') @@ -260,7 +260,7 @@ $.soap({ $.soap({ SOAPHeader: { - test: [1,2,3] + test: [1, 2, 3] } }) diff --git a/jquery.soap/jquery.soap.d.ts b/jquery.soap/jquery.soap.d.ts index abd65e783..7b7eeedbb 100644 --- a/jquery.soap/jquery.soap.d.ts +++ b/jquery.soap/jquery.soap.d.ts @@ -56,7 +56,7 @@ declare module JQuerySOAP { beforeSend?: (SOAPEnvelope: SOAPEnvelope) => void; context?: any; data?: Object; - envAttributes?: Object; + envAttributes?: any; elementName?: string; enableLogging?: boolean; error?: (SOAPResponse: SOAPResponse) => void; From 49fa3fa6d1d9fa14b7f978a59b7e580aa8256fca Mon Sep 17 00:00:00 2001 From: tigerxy Date: Mon, 28 Sep 2015 13:14:23 +0200 Subject: [PATCH 39/64] test changed --- jquery.soap/jquery.soap-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery.soap/jquery.soap-tests.ts b/jquery.soap/jquery.soap-tests.ts index e40379325..acef40d8c 100644 --- a/jquery.soap/jquery.soap-tests.ts +++ b/jquery.soap/jquery.soap-tests.ts @@ -203,7 +203,7 @@ $.soap({ }) $.soap({ - enableLoggin: true + enableLogging: true }) $.soap({ From 1a574a99ba9eae72197cfb12e6d62247e5be2798 Mon Sep 17 00:00:00 2001 From: Vasya Aksyonov Date: Mon, 28 Sep 2015 18:12:20 +0500 Subject: [PATCH 40/64] Module name fix and tests --- hammerjs/hammerjs-commonjs-tests.ts | 117 ++++++++++++++++++++++++++++ hammerjs/hammerjs.d.ts | 2 +- 2 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 hammerjs/hammerjs-commonjs-tests.ts diff --git a/hammerjs/hammerjs-commonjs-tests.ts b/hammerjs/hammerjs-commonjs-tests.ts new file mode 100644 index 000000000..e9f1d209f --- /dev/null +++ b/hammerjs/hammerjs-commonjs-tests.ts @@ -0,0 +1,117 @@ +// Tests based on examples at http://hammerjs.github.io/examples/ + +/// + +import Hammer = require("hammerjs"); + +(() => +{ + var myElement = document.getElementById( 'myElement' ); + + // create a simple instance + // by default, it only adds horizontal recognizers + var mc = new Hammer( myElement ); + + // listen to events... + mc.on( "panleft panright tap press", function ( ev ) + { + myElement.textContent = ev.type + " gesture detected."; + } ); +})(); + + +(() => +{ + var myElement = document.getElementById( 'myElement' ); + + // create a simple instance + // by default, it only adds horizontal recognizers + var mc = new Hammer( myElement ); + + // let the pan gesture support all directions. + // this will block the vertical scrolling on a touch-device while on the element + mc.get( 'pan' ).set( {direction: Hammer.DIRECTION_ALL} ); + + // listen to events... + mc.on( "panleft panright panup pandown tap press", function ( ev:HammerInput ) + { + myElement.textContent = ev.type + " gesture detected."; + } ); +})(); + + +(() => +{ + var myElement = document.getElementById( 'myElement' ); + + var mc = new Hammer.Manager( myElement ); + + // create a pinch and rotate recognizer + // these require 2 pointers + var pinch = new Hammer.Pinch(); + var rotate = new Hammer.Rotate(); + + // we want to detect both the same time + pinch.recognizeWith( rotate ); + + // add to the Manager + mc.add( [pinch, rotate] ); + + + mc.on( "pinch rotate", function ( ev:HammerInput ) + { + myElement.textContent += ev.type + " "; + } ); +})(); + + +(() => +{ + var myElement = document.getElementById( 'myElement' ); + + // We create a manager object, which is the same as Hammer(), but without the presetted recognizers. + var mc = new Hammer.Manager( myElement ); + + // Default, tap recognizer + mc.add( new Hammer.Tap() ); + + // Tap recognizer with minimal 4 taps + mc.add( new Hammer.Tap( {event: 'quadrupletap', taps: 4} ) ); + + // we want to recognize this simulatenous, so a quadrupletap will be detected even while a tap has been recognized. + // the tap event will be emitted on every tap + mc.get( 'quadrupletap' ).recognizeWith( 'tap' ); + + + mc.on( "tap quadrupletap", function ( ev ) + { + myElement.textContent += ev.type + " "; + } ); +})(); + + +(() => +{ + var myElement = document.getElementById( 'myElement' ); + + // We create a manager object, which is the same as Hammer(), but without the presetted recognizers. + var mc = new Hammer.Manager( myElement ); + + + // Tap recognizer with minimal 2 taps + mc.add( new Hammer.Tap( {event: 'doubletap', taps: 2} ) ); + // Single tap recognizer + mc.add( new Hammer.Tap( {event: 'singletap'} ) ); + + + // we want to recognize this simulatenous, so a quadrupletap will be detected even while a tap has been recognized. + mc.get( 'doubletap' ).recognizeWith( 'singletap' ); + // we only want to trigger a tap, when we don't have detected a doubletap + mc.get( 'singletap' ).requireFailure( 'doubletap' ); + + + mc.on( "singletap doubletap", function ( ev ) + { + myElement.textContent += ev.type + " "; + } ); +})(); diff --git a/hammerjs/hammerjs.d.ts b/hammerjs/hammerjs.d.ts index 4d1091f68..5ea8165b0 100644 --- a/hammerjs/hammerjs.d.ts +++ b/hammerjs/hammerjs.d.ts @@ -7,7 +7,7 @@ declare var Hammer:HammerStatic; -declare module "Hammer" { +declare module "hammerjs" { export = Hammer; } From d5c1e03517c2c8790004f81a51664447c49d06e1 Mon Sep 17 00:00:00 2001 From: tkqubo Date: Mon, 28 Sep 2015 22:53:23 +0900 Subject: [PATCH 41/64] Add undertaker --- undertaker/undertaker-tests.ts | 46 +++++++++++++ undertaker/undertaker.d.ts | 117 +++++++++++++++++++++++++++++++++ 2 files changed, 163 insertions(+) create mode 100644 undertaker/undertaker-tests.ts create mode 100644 undertaker/undertaker.d.ts diff --git a/undertaker/undertaker-tests.ts b/undertaker/undertaker-tests.ts new file mode 100644 index 000000000..b40e19af1 --- /dev/null +++ b/undertaker/undertaker-tests.ts @@ -0,0 +1,46 @@ +/// +/// +/// + +var fs = require('fs'); +var Undertaker = require('undertaker'); +import { Registry } from 'undertaker'; +require('es6-promise'); + +var taker = new Undertaker(); + +taker.task('task1', function(cb: () => void){ + // do things + + cb(); // when everything is done +}); + +taker.task('task2', function(){ + return fs.createReadStream('./myFile.js') + .pipe(fs.createWriteStream('./myFile.copy.js')); +}); + +taker.task('task3', function(){ + return new Promise(function(resolve, reject){ + // do things + + resolve(); // when everything is done + }); +}); + +taker.task('combined', taker.series('task1', 'task2')); + +taker.task('all', taker.parallel('combined', 'task3')); + +var registry: Registry; +function CommonRegistry(options: { buildDir: string }): Registry { + return registry; +} + +var taker = new Undertaker(CommonRegistry({ buildDir: '/dist' })); + +taker.task('build', taker.series('clean', function build(cb: () => void) { + // do things + cb(); +})); + diff --git a/undertaker/undertaker.d.ts b/undertaker/undertaker.d.ts new file mode 100644 index 000000000..b31b6646d --- /dev/null +++ b/undertaker/undertaker.d.ts @@ -0,0 +1,117 @@ +// Type definitions for undertaker 0.12.0 +// Project: https://github.com/phated/undertaker +// Definitions by: Qubo +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module "undertaker" { + + export interface UndertakerStatic { + new(registry?: Registry): Undertaker; + } + + export interface Undertaker { + task: TaskMethod; + /** + * Takes a variable amount of strings (taskName) and/or functions (fn) + * and returns a function of the composed tasks or functions. + * Any taskNames are retrieved from the registry using the get method. + * + * When the returned function is executed, the tasks or functions will be executed in series, + * each waiting for the prior to finish. If an error occurs, execution will stop. + * @param task + */ + series(...tasks: (string|Task)[]): Task; + /** + * Takes a variable amount of strings (taskName) and/or functions (fn) + * and returns a function of the composed tasks or functions. + * Any taskNames are retrieved from the registry using the get method. + * + * When the returned function is executed, the tasks or functions will be executed in parallel, + * all being executed at the same time. If an error occurs, all execution will complete. + * @param tasks + */ + parallel(...tasks: (string|Task)[]): Task; + /** + * Returns the current registry object. + */ + registry(): Registry; + /** + * The tasks from the current registry will be transferred to it + * and the current registry will be replaced with the new registry. + * @param registry + */ + registry(registry: Registry): void; + /** + * Optionally takes an object (options) and returns an object representing the tree of registered tasks. + * @param options + */ + tree(options?: { deep?: boolean }): Node[]|string[]; + /** + * Takes a string or function (task) and returns a timestamp of the last time the task was run successfully. + * The time will be the time the task started. Returns undefined if the task has not been run. + * @param task + * @param timeResolution + */ + lastRun(task: string, timeResolution?: number): number; + } + + export interface Task { + (cb?: Function): any; + } + + export interface TaskMethod { + /** + * Returns the registered function. + * @param taskName + */ + (taskName: string): Task; + /** + * Register the task by the taskName. + * @param taskName + * @param fn + */ + (taskName: string, fn: Task): void; + /** + * Register the task by the name property of the function. + * @param fn + */ + (fn: Task): void; + /** + * Register the task by the displayName property of the function. + * @param fn + */ + (fn: Task & { displayName: string }): void; + } + + export interface Registry { + /** + * receives the undertaker instance to set pre-defined tasks using the task(taskName, fn) method. + * @param taker + */ + init(taker: Undertaker): void; + /** + * returns the task with that name or undefined if no task is registered with that name. + * @param taskName + */ + get(taskName: string): Task; + /** + * add task to the registry. If set modifies a task, it should return the new task. + * @param taskName + * @param fn + */ + set(taskName: string, fn: Task): void; + /** + * returns an object listing all tasks in the registry. + */ + tasks(): { [taskName: string]: Task }; + } + + export interface Node { + label: string; + type: string; + nodes: Node[]; + } + + export default UndertakerStatic; +} + From c98ea9de9706cebe7573fb6383ef78ff300b11bd Mon Sep 17 00:00:00 2001 From: Yuce Tekol Date: Mon, 28 Sep 2015 22:28:39 +0300 Subject: [PATCH 42/64] Added definitions for flake-idgen --- flake-idgen/flake-idgen-tests.ts | 27 +++++++++++++++++++++++++++ flake-idgen/flake-idgen.d.ts | 22 ++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 flake-idgen/flake-idgen-tests.ts create mode 100644 flake-idgen/flake-idgen.d.ts diff --git a/flake-idgen/flake-idgen-tests.ts b/flake-idgen/flake-idgen-tests.ts new file mode 100644 index 000000000..5828bc913 --- /dev/null +++ b/flake-idgen/flake-idgen-tests.ts @@ -0,0 +1,27 @@ +/// + +// require flake-idgen +import FlakeId = require('flake-idgen'); +let flakeIdGen1 = new FlakeId({datacenter: 9, worker: 7}); + +// create flake IDs +console.log(flakeIdGen1.next()); +console.log(flakeIdGen1.next()); +console.log(flakeIdGen1.next()); + +// create flake IDs using a callback +flakeIdGen1.next((err, id) => { + console.info(id); +}); + +flakeIdGen1.next((err, id) => { + console.info(id); +}); + +let flakeIdGen2 = new FlakeId(); +let flakeIdGen3 = new FlakeId({datacenter: 9, worker: 7}); +let flakeIdGen4 = new FlakeId({epoch: 1300000000000}) +console.info(flakeIdGen2.next()); +console.info(flakeIdGen3.next()); +console.info(flakeIdGen4.next()); + diff --git a/flake-idgen/flake-idgen.d.ts b/flake-idgen/flake-idgen.d.ts new file mode 100644 index 000000000..9462eaba4 --- /dev/null +++ b/flake-idgen/flake-idgen.d.ts @@ -0,0 +1,22 @@ +// Type definitions for flakge-idgen 0.1.4 +// Project: https://github.com/T-PWK/flake-idgen +// Definitions by: Yuce Tekol +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module 'flake-idgen' { + interface ConstructorOptions { + datacenter?: number; + worker?: number; + id?: number; + epoch?: number; + seqMask?: number; + } + + class FlakeId { + constructor(options?: ConstructorOptions); + next(callback?: (err: Error, id: Buffer) => void): Buffer; + } + export = FlakeId; +} From 1789faf3a07903515227919d7f37a38ff1a6da48 Mon Sep 17 00:00:00 2001 From: drillbits Date: Tue, 29 Sep 2015 10:55:22 +0900 Subject: [PATCH 43/64] add markitup definition file --- markitup/markitup-tests.ts | 89 ++++++++++++++ markitup/markitup.d.ts | 237 +++++++++++++++++++++++++++++++++++++ 2 files changed, 326 insertions(+) create mode 100644 markitup/markitup-tests.ts create mode 100644 markitup/markitup.d.ts diff --git a/markitup/markitup-tests.ts b/markitup/markitup-tests.ts new file mode 100644 index 000000000..e5b03ed5a --- /dev/null +++ b/markitup/markitup-tests.ts @@ -0,0 +1,89 @@ +/// +/// + +// https://github.com/markitup/1.x/blob/master/markitup/sets/default/set.js +var mySettings = { + onShiftEnter: { + keepDefault: false, + replaceWith: '
\n' + }, + onCtrlEnter: { + keepDefault: false, + openWith: '\n

', + closeWith: '

' + }, + onTab: { + keepDefault: false, + replaceWith: ' ' + }, + markupSet: [ + { + name: 'Bold', + key: 'B', + openWith: '(!(|!|)!)', + closeWith: '(!(|!|)!)' + }, + { + name: 'Italic', + key: 'I', + openWith: '(!(|!|)!)', + closeWith: '(!(|!|)!)' + }, + { + name: 'Stroke through', + key: 'S', + openWith: '', + closeWith: '' + }, + {separator: '---------------'}, + { + name: 'Bulleted List', + openWith: '
  • ', + closeWith: '
  • ', + multiline: true, + openBlockWith: '
      \n', + closeBlockWith: '\n
    ' + }, + { + name: 'Numeric List', + openWith: '
  • ', + closeWith: '
  • ', + multiline: true, + openBlockWith: '
      \n', + closeBlockWith: '\n
    ' + }, + { + separator: '---------------' + }, + { + name: 'Picture', + key: 'P', + replaceWith: '[![Alternative text]!]' + }, + { + name: 'Link', + key: 'L', + openWith: '', + closeWith: '', + placeHolder: 'Your text to link...' + }, + { + separator: '---------------' + }, + { + name: 'Clean', + className: 'clean', + replaceWith: (markitup: MarkItUp.MarkupSet): string => { + return markitup.selection.replace(/<(.*?)>/g, "") + } + }, + { + name: 'Preview', + className: 'preview', + call: 'preview' + } + ] +}; + +// http://markitup.jaysalvat.com/documentation/ +$('#markItUp').markItUp(mySettings); diff --git a/markitup/markitup.d.ts b/markitup/markitup.d.ts new file mode 100644 index 000000000..317540ece --- /dev/null +++ b/markitup/markitup.d.ts @@ -0,0 +1,237 @@ +// Type definitions for markitup/1.x +// Project: https://github.com/markitup/1.x +// Definitions by: drillbits +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module MarkItUp { + interface Options { + /** + * Apply a specific className to the wrapping Div. Useful to prevent CSS conflicts between instances. + */ + nameSpace?: string; + + /** + * Enable/Disable the handle to resize the editor. + */ + resizeHandle?: boolean; + + /** + * Display the preview in a popup window with comma-separated list of specs. If empty or false, the preview will be displayed in the built-in iFrame preview. + */ + previewInWindow?: string; + + /** + * AutoRefresh the preview iFrame or window when the editor is used. + */ + previewAutoRefresh?: boolean; + + /** + * You can set the path of your own parser to preview markup languages other than html. If this property is set, the built-in preview will be overridden by your own preview script. + * Use ~/ for markItUp! root. + */ + previewParserPath?: string; + + /** + * Name of the var posted with the editor content to the parser defined above. + * + * default: 'data' + */ + previewParserVar?: string; + + /** + * Path to the Html preview template. + * Use ~/ for markItUp! root. + * + * default: '~/templates/preview.html' + */ + previewTemplatePath?: string; + + /** + * Parse the content with the javascript parser of your choice before passing it to the preview. + * + * default: false + */ + previewParser?: boolean; + + /** + * Position of the Built-in preview before or after the main textarea. + * 'before'|'after' + * + * default: 'after' + */ + previewPosition?: string; + + /** + * Define what to do when Enter key is pressed. + */ + onEnter?: MarkupSet; + + /** + * Define what to do when Ctrl+Enter keys are pressed. + */ + onCtrlEnter?: MarkupSet; + + /** + * Define what to do when Shift+Enter keys are pressed. + */ + onShiftEnter?: MarkupSet; + + /** + * Define what to do when Tab key is pressed. Warning, this key is also used to jump at the end of a new inserted markup. + */ + onTab?: MarkupSet; + + /** + * Function to be called before any markup insertion. + */ + beforeInsert?: (h: MarkupSet) => string; + + /** + * Function to be called after any markup insertion. + */ + afterInsert?: (h: MarkupSet) => string; + + /** + * Note that most of the settings below are used by the engine for all insertion calls ($.markItUp( {} ), onEnter, onShiftEnter, onCtrlEnter, onTab) except exclusive button properties marked by + */ + markupSet?: MarkupSet[]; + } + + interface MarkupSet { + /** + * Button name + */ + name?: string; + + /** + * Classname to be applied to this very button. + */ + className?: string; + + /** + * Shortcut key to be applied to the button. Ctrl+key trigger the action of a button. + */ + key?: string; + + /** + * Markup to be added before selection. Accepts functions. + */ + openWith?: string|((h: MarkupSet) => string); + + /** + * Markup to be added after selection. Accepts functions. + */ + closeWith?: string|((h: MarkupSet) => string); + + /** + * Text to be added in place of the cursor or selection. Accepts functions. + */ + replaceWith?: string|((h: MarkupSet) => string); + + /** + * Text to be added before a whole block. Accepts functions. + */ + openBlockWith?: string|((h: MarkupSet) => string); + + /** + * Text to be added after a whole block. Accepts functions. + */ + closeBlockWith?: string|((h: MarkupSet) => string); + + /** + * Set whether the tags has to be inserted at each line or on the whole selected block. + */ + multiline?: boolean; + + /** + * Placeholder text to be inserted if no text is selected by the user. + */ + placeHolder?: string|((h: MarkupSet) => string); + + /** + * Function to be called just before a markup insertion. If a global beforeInsert callback is already defined this function is fired just after. + */ + beforeInsert?: (h: MarkupSet) => string; + + /** + * Function to be called just after a markup insertion. If a global afterInsert callback is already defined this function is fired before. + */ + afterInsert?: (h: MarkupSet) => string; + + /** + * Function to be called before a multiline markup insertion. + */ + beforeMultiInsert?: (h: MarkupSet) => string; + + /** + * Function to be called after a multiline markup insertion. + */ + afterMultiInsert?: (h: MarkupSet) => string; + + /** + * Open a dropdown menu with another button set. + */ + dropMenu?: MarkupSet[]; + + /** + * Keep (true) or not (false) the default behaviour of the key. + */ + keepDefault?: boolean; + + /** + * Returns the selection. + */ + selection?: string; + + /** + * Returns the textarea object. + */ + textarea?: HTMLElement; + + /** + * Returns the position of the selection. + */ + caretPosition?: number; + + /** + * Returns the position of the scrollbar. + */ + scrollPosition?: number; + + /** + * If a multi-line edition is trigged (Ctrl + Shift + click). This property return the number of the line being processed. + */ + line?: number; + + /** + * Returns true if the Control key is pressed when the callback is fired. + */ + ctrlKey?: boolean; + + /** + * Returns true if the Shift key is pressed when the callback is fired. + */ + shiftKey?: boolean; + + /** + * Returns true if the Alt key is pressed when the callback is fired. + */ + altKey?: boolean; + } + + interface Static { + (): JQuery; + (settings: Options): JQuery; + } +} + +interface JQueryStatic { + markItUp: MarkItUp.Static; +} + +interface JQuery { + markItUp(settings?: MarkItUp.Options): JQuery; + markItUpRemove(): JQuery; +} From fe917d27e973d78b1d72176fb6b6cfbd6cf76af8 Mon Sep 17 00:00:00 2001 From: Marco Gonzalez Date: Mon, 28 Sep 2015 21:00:52 -0600 Subject: [PATCH 44/64] Added resolve method to angular.IQService. --- angularjs/angular-tests.ts | 11 +++++++++++ angularjs/angular.d.ts | 10 +++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/angularjs/angular-tests.ts b/angularjs/angular-tests.ts index 0174a0d61..de4414ad2 100644 --- a/angularjs/angular-tests.ts +++ b/angularjs/angular-tests.ts @@ -296,6 +296,17 @@ module TestQ { result = $q.reject(''); } + // $q.resolve + { + let result: angular.IPromise; + result = $q.resolve(); + } + { + let result: angular.IPromise; + result = $q.resolve(tResult); + result = $q.resolve(promiseTResult); + } + // $q.when { let result: angular.IPromise; diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index 9f7fa07b0..9e554528a 100644 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -1052,12 +1052,20 @@ declare module angular { * * @param value Value or a promise */ - when(value: IPromise|T): IPromise; + resolve(value: IPromise|T): IPromise; + /** + * Wraps an object that might be a value or a (3rd party) then-able promise into a $q promise. This is useful when you are dealing with an object that might or might not be a promise, or if the promise comes from a source that can't be trusted. + */ + resolve(): IPromise; /** * Wraps an object that might be a value or a (3rd party) then-able promise into a $q promise. This is useful when you are dealing with an object that might or might not be a promise, or if the promise comes from a source that can't be trusted. * * @param value Value or a promise */ + when(value: IPromise|T): IPromise; + /** + * Wraps an object that might be a value or a (3rd party) then-able promise into a $q promise. This is useful when you are dealing with an object that might or might not be a promise, or if the promise comes from a source that can't be trusted. + */ when(): IPromise; } From 5b142e5679d60c865c5f398883e42b025dc94612 Mon Sep 17 00:00:00 2001 From: drillbits Date: Tue, 29 Sep 2015 12:10:29 +0900 Subject: [PATCH 45/64] Fix header --- markitup/markitup.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/markitup/markitup.d.ts b/markitup/markitup.d.ts index 317540ece..0267a12c6 100644 --- a/markitup/markitup.d.ts +++ b/markitup/markitup.d.ts @@ -1,4 +1,4 @@ -// Type definitions for markitup/1.x +// Type definitions for markitup 1.x // Project: https://github.com/markitup/1.x // Definitions by: drillbits // Definitions: https://github.com/borisyankov/DefinitelyTyped From f0237f419948b7932dc6929a971ec9272d1fdb29 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Tue, 29 Sep 2015 13:12:16 +0500 Subject: [PATCH 46/64] lodash: changed _.last() method --- lodash/lodash-tests.ts | 13 +++++++++++-- lodash/lodash.d.ts | 20 ++++++++++++++------ 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 1d5525300..0e4b1cc0d 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -345,8 +345,17 @@ result = _.indexOf([1, 1, 2, 2, 3, 3], 2, true); result = _(testIntersectionList).intersection(testIntersectionList, testIntersectionArray).value(); } -result = _.last([1, 2, 3]); -result = _([1, 2, 3]).last(); +// _.last +module TestLast { + let array: TResult[]; + let list: _.List; + let result: TResult; + + result = _.last(array); + result = _.last(list); + result = _(array).last(); + result = _(list).last(); +} result = _.lastIndexOf([1, 2, 3, 1, 2, 3], 2); result = _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 102811a16..f0c6f186c 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -872,20 +872,28 @@ declare module _ { //_.last interface LoDashStatic { /** - * Gets the last element of an array. - * @param array The array to query. - * @return Returns the last element of array. - **/ - last(array: Array): T; + * Gets the last element of array. + * + * @param array The array to query. + * @return Returns the last element of array. + */ + last(array: List): T; } interface LoDashArrayWrapper { /** * @see _.last - **/ + */ last(): T; } + interface LoDashObjectWrapper { + /** + * @see _.last + */ + last(): T; + } + //_.lastIndexOf interface LoDashStatic { /** From c8223d68d246f0ed71af83162148bf2024225611 Mon Sep 17 00:00:00 2001 From: Ali Taheri Date: Tue, 29 Sep 2015 13:20:24 +0330 Subject: [PATCH 47/64] [Sequelize] Added BelongsTo association mixin helper types. --- sequelize/sequelize.d.ts | 104 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) diff --git a/sequelize/sequelize.d.ts b/sequelize/sequelize.d.ts index ba465db5e..6328f4917 100644 --- a/sequelize/sequelize.d.ts +++ b/sequelize/sequelize.d.ts @@ -20,6 +20,110 @@ declare module "sequelize" { // https://github.com/sequelize/sequelize/tree/v3.4.1/lib/associations // + + /** + * The options for the get mixin of the BelongsTo association. + * @see BelongsToAssociationGetMixin + */ + interface BelongsToAssociationGetMixinOptions { + /** + * Apply a scope on the related model, or remove its default scope by passing false. + */ + scope: string | boolean; + } + + /** + * The get association mixin applied to models with BelongsTo. + * An example of usage is as follows: + * + * ```js + * interface UserInstance extends Sequelize.Instance, UserAttrib { + * getRole: Sequelize.BelongsToAssociationGetMixin; + * // setRole... + * // createRole... + * } + * ``` + * + * @see http://docs.sequelizejs.com/en/latest/api/associations/belongs-to/ + * @see Instance + */ + interface BelongsToAssociationGetMixin { + /** + * Get the associated instance. + * @param options The obtions to use when getting the association. + */ + (options?: BelongsToAssociationGetMixinOptions): Promise + } + + /** + * The options for the set mixin of the BelongsTo association. + * @see BelongsToAssociationSetMixin + */ + interface BelongsToAssociationSetMixinOptions { + /** + * Skip saving this after setting the foreign key if false. + */ + save: boolean; + } + + /** + * The set association mixin applied to models with BelongsTo. + * An example of usage is as follows: + * + * ```js + * interface UserInstance extends Sequelize.Instance, UserAttributes { + * // getRole... + * setRole: BelongsToAssociationSetMixin; + * // createRole... + * } + * ``` + * + * @see http://docs.sequelizejs.com/en/latest/api/associations/belongs-to/ + * @see Instance + */ + interface BelongsToAssociationSetMixin { + /** + * Get the associated instance. + * @param newAssociation An instance or the primary key of an instance to associate with this. Pass null or undefined to remove the association. + * @param options The obtions to use when setting the association. + */ + (newAssociation: TInstance | TInstancePrimaryKey, options?: BelongsToAssociationSetMixinOptions): Promise + } + + /** + * The options for the create mixin of the BelongsTo association. + * @see BelongsToAssociationCreateMixin + */ + interface BelongsToAssociationCreateMixinOptions extends CreateOptions, BelongsToAssociationSetMixinOptions {} + + /** + * The create association mixin applied to models with BelongsTo. + * An example of usage is as follows: + * + * ```js + * interface UserInstance extends Sequelize.Instance, UserAttributes { + * // getRole... + * // setRole... + * createRole: BelongsToAssociationCreateMixin; + * } + * ``` + * + * @see http://docs.sequelizejs.com/en/latest/api/associations/belongs-to/ + * @see Instance + */ + interface BelongsToAssociationCreateMixin { + /** + * Create a new instance of the associated model and associate it with this. + * @param values The values used to create the association. + * @param options The options passed to `target.create` and `setAssociation`. + */ + (values?: TAttributes, options?: BelongsToAssociationCreateMixinOptions): Promise + } + + // TODO: HasOne Associations + // TODO: HasMany Associations + // TODO: BelongsToMany Associations + /** * Foreign Key Options * From 7abab20604754400b1c7f43f97def8a5dc6f3556 Mon Sep 17 00:00:00 2001 From: Ali Taheri Date: Tue, 29 Sep 2015 13:42:02 +0330 Subject: [PATCH 48/64] Fixed a typo in create mixin's docs --- sequelize/sequelize.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sequelize/sequelize.d.ts b/sequelize/sequelize.d.ts index 6328f4917..ba8d03d94 100644 --- a/sequelize/sequelize.d.ts +++ b/sequelize/sequelize.d.ts @@ -104,7 +104,7 @@ declare module "sequelize" { * interface UserInstance extends Sequelize.Instance, UserAttributes { * // getRole... * // setRole... - * createRole: BelongsToAssociationCreateMixin; + * createRole: BelongsToAssociationCreateMixin; * } * ``` * From 1342d27f016fe52c2889aca5ca99ba754749c11a Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 30 Sep 2015 13:48:47 +0200 Subject: [PATCH 49/64] changed contentAsHTML as boolean --- tooltipster/tooltipster.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tooltipster/tooltipster.d.ts b/tooltipster/tooltipster.d.ts index 7afa46ddb..b1c263c16 100644 --- a/tooltipster/tooltipster.d.ts +++ b/tooltipster/tooltipster.d.ts @@ -42,7 +42,7 @@ declare module JQueryTooltipster { * If the content of the tooltip is provided as a string, it is displayed as plain text by default. * If this content should actually be interpreted as HTML, set this option to true. Default: false */ - contentAsHTML?: string; + contentAsHTML?: boolean; /** * If you provide a jQuery object to the 'content' option, this sets if it is a clone of this object that should actually be used. Default: true From e084d1f9264cfb116549446972e01acc81d3bec0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D1=82=D0=B0=D0=BD=D0=B8=D1=81=D0=BB=D0=B0=D0=B2=20?= =?UTF-8?q?=D0=92=D1=8B=D1=89=D0=B5=D0=BF=D0=B0=D0=BD?= Date: Thu, 1 Oct 2015 03:59:18 +0300 Subject: [PATCH 50/64] Added forms definitions and fixed some "any" types --- sharepoint/SharePoint.d.ts | 344 ++++++++++++++++----------- sharepoint/SharePoint.d.ts.tscparams | 2 +- 2 files changed, 208 insertions(+), 138 deletions(-) diff --git a/sharepoint/SharePoint.d.ts b/sharepoint/SharePoint.d.ts index 181c40491..57613b0ee 100644 --- a/sharepoint/SharePoint.d.ts +++ b/sharepoint/SharePoint.d.ts @@ -1,4 +1,4 @@ -// Type definitions for SharePoint 2010 and 2013 +// Type definitions for SharePoint 2010 and 2013 // Project: http://sptypescript.codeplex.com // Definitions by: Stanislav Vyshchepan , Andrey Markeev // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -72,7 +72,7 @@ declare module SP { static isUndefined(obj: any): boolean; static replaceOrAddQueryString(url: string, key: string, value: string): string; static removeHtml(str: string): string; - static removeStyleChildren(element: HTMLElement): any; + static removeStyleChildren(element: HTMLElement): void; static removeHtmlAndTrimStringWithEllipsis(str: string, maxLength: number): string; static setTextAreaElementValue(textAreaElement: HTMLTextAreaElement, newValue: string): void; static truncateToInt(n: number): number; @@ -116,12 +116,12 @@ declare module SP { export function refreshView(viewId: string): void; } export module Selection { - export function selectListItem(iid: string, bSelect: boolean): any; + export function selectListItem(iid: string, bSelect: boolean): void; export function getSelectedItems(): { id: number; fsObjType: FileSystemObjectType; }[]; export function getSelectedList(): string; export function getSelectedView(): string; export function navigateUp(viewId: string): void; - export function deselectAllListItems(iid: string): any; + export function deselectAllListItems(iid: string): void; } export module Overrides { export function overrideDeleteConfirmation(listId: string, overrideText: string): void; @@ -321,7 +321,7 @@ interface ContextInfo extends SPClientTemplates.RenderContext { } declare function GetCurrentCtx(): ContextInfo; -declare function SetFullScreenMode(fullscreen: boolean): any; +declare function SetFullScreenMode(fullscreen: boolean): void; declare module SP { export enum RequestExecutorErrors { requestAbortedOrTimedout, @@ -348,7 +348,7 @@ declare module SP { method?: string; headers?: { [key: string]: string; }; /** Can be string or bytearray depending on binaryStringRequestBody field */ - body?: string|Uint8Array; + body?: string | Uint8Array; binaryStringRequestBody?: boolean; /** Currently need fix to get ginary response. Details: http://techmikael.blogspot.ru/2013/07/how-to-copy-files-between-sites-using.html */ @@ -367,7 +367,7 @@ declare module SP { headers?: { [key: string]: string; }; contentType?: string; /** Can be string or bytearray depending on request.binaryStringResponseBody field */ - body?: string|Uint8Array; + body?: string | Uint8Array; state?: any; } @@ -651,7 +651,7 @@ declare class CalloutActionMenuEntry { declare class CalloutActionMenu { constructor(actionsId: any); - addAction(action: CalloutAction): any; + addAction(action: CalloutAction): void; getActions(): CalloutAction[]; render(): void; refreshActions(): void; @@ -664,9 +664,9 @@ declare class CalloutAction { getText(): string; getToolTop(): string; getDisabledToolTip(): string; - getOnClickCallback(): (event: any, action: CalloutAction) => any; - getIsDisabledCallback(): (action: CalloutAction) => boolean; - getIsVisibleCallback(): (action: CalloutAction) => boolean; + getOnClickCallback(event: any, action: CalloutAction): any; + getIsDisabledCallback(action: CalloutAction): boolean; + getIsVisibleCallback(action: CalloutAction): boolean; getIsMenu(): boolean; getMenuEntries(): CalloutActionMenuEntry[]; render(): void; @@ -680,7 +680,7 @@ declare class Callout { set(options: CalloutOptions): any; /** Adds event handler to the callout. @param eventName one of the following: "opened", "opening", "closing", "closed" */ - addEventCallback(eventName: string, callback: (callout: Callout) => void): any; + addEventCallback(eventName: string, callback: (callout: Callout) => void): void; /** Returns the launch point element of the callout. */ getLaunchPoint(): HTMLElement; /** Returns the ID of the callout. */ @@ -714,13 +714,13 @@ declare class Callout { /** Returns the callout actions menu */ getActionMenu(): CalloutActionMenu; /** Adds a link to the actions panel in the bottom part of the callout window */ - addAction(action: CalloutAction): any; + addAction(action: CalloutAction): void; /** Re-renders the actions menu. Call after the actions menu is changed. */ refreshActions(): void; /** Display the callout. Animation can be used only for IE9+ */ - open(useAnimation?: boolean): any; + open(useAnimation: boolean): void; /** Hide the callout. Animation can be used only for IE9+ */ - close(useAnimation?: boolean): any; + close(useAnimation: boolean): void; /** Display if hidden, hide if shown. */ toggle(): void; /** Do not call this directly. Instead, use CalloutManager.remove */ @@ -774,7 +774,7 @@ declare class CalloutManager { /** Checks if callout with specified ID already exists. If it doesn't, creates it, otherwise returns the existing one. */ static createNewIfNecessary(options: CalloutOptions): Callout; /** Detaches callout from the launch point and destroys it. */ - static remove(callout: Callout): any; + static remove(callout: Callout): void; /** Searches for a callout associated with the specified launch point. Throws error if not found. */ static getFromLaunchPoint(launchPoint: HTMLElement): Callout; /** Searches for a callout associated with the specified launch point. Returns null if not found. */ @@ -785,7 +785,7 @@ declare class CalloutManager { /** Finds the closest launch point based on the specified descendant element, and returns callout associated with the launch point. */ static getFromCalloutDescendant(descendant: HTMLElement): Callout; /** Perform some action for each callout on the page. */ - static forEach(callback: (callout: Callout) => void): any; + static forEach(callback: (callout: Callout) => void): void; /** Closes all callouts on the page */ static closeAll(): boolean; /** Returns true if at least one of the defined on page callouts is opened. */ @@ -1346,15 +1346,15 @@ declare module SPClientTemplates { View?: RenderCallback | string; // TODO: determine appropriate context type and purpose of this template Body?: RenderCallback | string; // TODO: determine appropriate context type and purpose of this template /** Defines templates for rendering groups (aggregations). */ - Group?: GroupCallback| string; + Group?: GroupCallback | string; /** Defines templates for list items rendering. */ - Item?: ItemCallback| string; + Item?: ItemCallback | string; /** Defines template for rendering list view header. Can be either string or SingleTemplateCallback */ - Header?: SingleTemplateCallback| string; + Header?: SingleTemplateCallback | string; /** Defines template for rendering list view footer. Can be either string or SingleTemplateCallback */ - Footer?: SingleTemplateCallback| string; + Footer?: SingleTemplateCallback | string; /** Defines templates for fields rendering. The field is specified by it's internal name. */ Fields?: FieldTemplates; } @@ -1367,15 +1367,15 @@ declare module SPClientTemplates { View?: RenderCallback | string; // TODO: determine appropriate context type and purpose of this template Body?: RenderCallback | string; // TODO: determine appropriate context type and purpose of this template /** Defines templates for rendering groups (aggregations). */ - Group?: GroupCallback| string; + Group?: GroupCallback | string; /** Defines templates for list items rendering. */ - Item?: ItemCallback| string; + Item?: ItemCallback | string; /** Defines template for rendering list view header. Can be either string or SingleTemplateCallback */ - Header?: SingleTemplateCallback| string; + Header?: SingleTemplateCallback | string; /** Defines template for rendering list view footer. Can be either string or SingleTemplateCallback */ - Footer?: SingleTemplateCallback| string; + Footer?: SingleTemplateCallback | string; /** Defines templates for fields rendering. The field is specified by it's internal name. */ Fields?: FieldTemplateMap; } @@ -1397,7 +1397,7 @@ declare module SPClientTemplates { ListTemplateType?: number; /** Base view ID (SPView.BaseViewID) for which the template should be applied. If not defined, the templates will be applied to all views. */ - BaseViewID?: number|string; + BaseViewID?: number | string; } export class TemplateManager { static RegisterTemplateOverrides(renderCtx: TemplateOverridesOptions): void; @@ -1481,7 +1481,7 @@ declare module SPClientTemplates { registerGetValueCallback(fieldname: string, callback: () => any): void; updateControlValue(fieldname: string, value: any): void; registerClientValidator(fieldname: string, validator: SPClientForms.ClientValidation.ValidatorSet): void; - registerHasValueChangedCallback(fieldname: string, callback: (eventArg?: any) => void): any; + registerHasValueChangedCallback(fieldname: string, callback: (eventArg?: any) => void): void; } } @@ -1499,7 +1499,7 @@ declare module SPClientForms { } export class ValidatorSet { - public RegisterValidator(validator: IValidator): any; + public RegisterValidator(validator: IValidator): void; } export interface IValidator { @@ -1509,6 +1509,43 @@ declare module SPClientForms { export class RequiredValidator implements IValidator { Validate(value: any): ValidationResult; } + + export class RequiredFileValidator implements IValidator { + Validate(value: any): ValidationResult; + } + + export class RequiredRichTextValidator implements IValidator { + Validate(value: any): ValidationResult; + } + + export class MaxLengthUrlValidator implements IValidator { + Validate(value: any): ValidationResult; + } + + + } + + export enum FormManagerEvents { + Event_OnControlValueChanged,//: 1, + Event_OnControlInitializedCallback,//: 2, + Event_OnControlFocusSetCallback,//: 3, + Event_GetControlValueCallback,//: 4, + Event_OnControlValidationError,//: 5, + Event_RegisterControlValidator,//: 6, + Event_GetHasValueChangedCallback//: 7 + } + + export class ClientForm { + constructor(qualifier: string); + RenderClientForm(): void; + SubmitClientForm(): boolean; + NotifyControlEvent(eventName: FormManagerEvents, fldName: string, eventArg: any): void; + } + + export class ClientFormManager { + static GetClientForm(qualifier: string): ClientForm; + static RegisterClientForm(qualifier: string): void; + static SubmitClientForm(qualifier: string): boolean; } } @@ -1521,6 +1558,31 @@ declare class SPMgr { declare var spMgr: SPMgr; +declare function SPField_FormDisplay_Default(ctx: SPClientTemplates.RenderContext_FieldInForm): string; +declare function SPField_FormDisplay_DefaultNoEncode(ctx: SPClientTemplates.RenderContext_FieldInForm): string; +declare function SPField_FormDisplay_Empty(ctx: SPClientTemplates.RenderContext_FieldInForm): string; +declare function SPFieldText_Edit(ctx: SPClientTemplates.RenderContext_FieldInForm): string; +declare function SPFieldNumber_Edit(ctx: SPClientTemplates.RenderContext_FieldInForm): string; +declare function SPFieldBoolean_Edit(ctx: SPClientTemplates.RenderContext_FieldInForm): string; +declare function SPFieldNote_Display(ctx: SPClientTemplates.RenderContext_FieldInForm): string; +declare function SPFieldNote_Edit(ctx: SPClientTemplates.RenderContext_FieldInForm): string; +declare function SPFieldFile_Display(ctx: SPClientTemplates.RenderContext_FieldInForm): string; +declare function SPFieldFile_Edit(ctx: SPClientTemplates.RenderContext_FieldInForm): string; +declare function SPFieldChoice_Edit(ctx: SPClientTemplates.RenderContext_FieldInForm): string; +declare function SPFieldChoice_Dropdown_Edit(ctx: SPClientTemplates.RenderContext_FieldInForm): string; +declare function SPFieldChoice_Radio_Edit(ctx: SPClientTemplates.RenderContext_FieldInForm): string; +declare function SPFieldMultiChoice_Edit(ctx: SPClientTemplates.RenderContext_FieldInForm): string; +declare function SPFieldDateTime_Display(ctx: SPClientTemplates.RenderContext_FieldInForm): string; +declare function SPFieldDateTime_Edit(ctx: SPClientTemplates.RenderContext_FieldInForm): string; +declare function SPFieldUrl_Display(ctx: SPClientTemplates.RenderContext_FieldInForm): string; +declare function SPFieldUrl_Edit(ctx: SPClientTemplates.RenderContext_FieldInForm): string; +declare function SPFieldUserMulti_Display(ctx: SPClientTemplates.RenderContext_FieldInForm): string; +declare function SPClientPeoplePickerCSRTemplate(ctx: SPClientTemplates.RenderContext_FieldInForm): string; +declare function SPFieldLookup_Display(ctx: SPClientTemplates.RenderContext_FieldInForm): string; +declare function SPFieldLookup_Edit(ctx: SPClientTemplates.RenderContext_FieldInForm): string; +declare function SPFieldLookupMulti_Edit(ctx: SPClientTemplates.RenderContext_FieldInForm): string; +declare function SPFieldAttachments_Default(ctx: SPClientTemplates.RenderContext_FieldInForm): string; + declare module SPAnimation { export enum Attribute { PositionX, @@ -1563,7 +1625,7 @@ declare module SPAnimation { export class State { - SetAttribute(attributeId: Attribute, value: number): any; + SetAttribute(attributeId: Attribute, value: number): void; GetAttribute(attributeId: Attribute): number; GetDataIndex(attributeId: Attribute): number } @@ -4817,6 +4879,9 @@ declare module SP { loadAndInstallApp(appPackageStream: SP.Base64EncodedByteArray): SP.AppInstance; ensureUser(logonName: string): SP.User; applyTheme(colorPaletteUrl: string, fontSchemeUrl: string, backgroundImageUrl: string, shareGenerated: boolean): void; + + /** Available after March 2015 CU for SharePoint 2013*/ + getList(url: string): List; } export class WebCollection extends SP.ClientObjectCollection { itemAt(index: number): SP.Web; @@ -5105,7 +5170,7 @@ declare module Microsoft.SharePoint.Client.Search { set_maxSnippetLength: (value: number) => void; get_personalizationData: () => QueryPersonalizationData; - set_personalizationData: (QueryPersonalizationData: any) => void; + set_personalizationData: (value: QueryPersonalizationData) => void; get_processBestBets: () => boolean; set_processBestBets: (value: boolean) => void; @@ -5149,7 +5214,7 @@ declare module Microsoft.SharePoint.Client.Search { set_startRow: (value: number) => void; get_summaryLength: () => number; - set_summaryLength: (number: any) => void; + set_summaryLength: (value: number) => void; get_timeout: () => number; set_timeout: (value: number) => void; @@ -5167,11 +5232,11 @@ declare module Microsoft.SharePoint.Client.Search { getQuerySuggestionsWithResults: (iNumberOfQuerySuggestions: number, - iNumberOfResultSuggestions: number, - fPreQuerySuggestions: boolean, - fHitHighlighting: boolean, - fCapitalizeFirstLetters: boolean, - fPrefixMatchAllTerms: boolean) => QuerySuggestionResults; + iNumberOfResultSuggestions: number, + fPreQuerySuggestions: boolean, + fHitHighlighting: boolean, + fCapitalizeFirstLetters: boolean, + fPrefixMatchAllTerms: boolean) => QuerySuggestionResults; } @@ -5217,15 +5282,15 @@ declare module Microsoft.SharePoint.Client.Search { executeQuery: (query: Query) => SP.JsonObjectResult; executeQueries: (queryIds: string[], queries: Query[], handleExceptions: boolean) => SP.JsonObjectResult; recordPageClick: ( - pageInfo: string, - clickType: string, - blockType: number, - clickedResultId: string, - subResultIndex: number, - immediacySourceId: string, - immediacyQueryString: string, - immediacyTitle: string, - immediacyUrl: string) => void; + pageInfo: string, + clickType: string, + blockType: number, + clickedResultId: string, + subResultIndex: number, + immediacySourceId: string, + immediacyQueryString: string, + immediacyTitle: string, + immediacyUrl: string) => void; exportPopularQueries: (web: SP.Web, sourceId: SP.Guid) => SP.JsonObjectResult; } @@ -5531,14 +5596,14 @@ declare module Microsoft.SharePoint.Client.Search { export class DocumentCrawlLog extends SP.ClientObject { constructor(context: SP.ClientContext, site: SP.Site); getCrawledUrls: (getCountOnly: boolean, - maxRows: { High: number; Low: number; }, - queryString: string, - isLike: boolean, - contentSourceID: number, - errorLevel: number, - errorID: number, - startDateTime: Date, - endDateTime: Date) => SP.JsonObjectResult; + maxRows: { High: number; Low: number; }, + queryString: string, + isLike: boolean, + contentSourceID: number, + errorLevel: number, + errorID: number, + startDateTime: Date, + endDateTime: Date) => SP.JsonObjectResult; } export class SearchObjectOwner extends SP.ClientObject { @@ -7336,8 +7401,8 @@ declare module SP { } export module Workplace { - export function add_resized(handler: Function): any; - export function remove_resized(handler: Function): any; + export function add_resized(handler: Function): void; + export function remove_resized(handler: Function): void; } export module UIUtility { @@ -7562,7 +7627,7 @@ declare module SP { Pictures in bmp, jpg and png formats and up to 5,000,000 bytes are supported. A user can upload a picture only to the user's own profile. @param data Binary content of an image file */ - setMyProfilePicture(data: any): void; + setMyProfilePicture(data: SP.Base64EncodedByteArray): void; } /** Specifies the capabilities of a personal site. */ @@ -7803,17 +7868,17 @@ declare module SP { /** Specifies the item of this item */ set_title(value: string): string; /** Specifies the GUID for this item in the Content database. */ - get_uniqueId(): any; + get_uniqueId(): SP.Guid; /** Specifies the GUID for this item in the Content database. */ - set_uniqueId(value: any): any; + set_uniqueId(value: SP.Guid): SP.Guid; /** Specifies the URL of this item. */ get_url(): string; /** Specifies the URL of this item. */ set_url(value: string): string; /** Specifies the site identification (GUID) in the Content database for this item if it is a site, or the identification of its parent site if this item is a document. */ - get_webId(): string; + get_webId(): SP.Guid; /** Specifies the site identification (GUID) in the Content database for this item if it is a site, or the identification of its parent site if this item is a document. */ - set_webId(value: any): any; + set_webId(value: SP.Guid): any; } export enum FollowedItemType { @@ -8060,7 +8125,7 @@ declare module SP { export module DateTimeUtil { export class SimpleDate { - construction(year: number, month: number, day: number, era: number): any; + constructor(year: number, month: number, day: number, era: number); get_year(): number; set_year(value: number): void; get_month(): number; @@ -8233,10 +8298,10 @@ declare module SP.WorkflowServices { export class InteropService extends SP.ClientObject { constructor(context: SP.ClientRuntimeContext, objectPath: SP.ObjectPathStaticProperty); static getCurrent(context: SP.ClientRuntimeContext): InteropService; - enableEvents(listId: any, itemGuid: any): void; - disableEvents(listId: any, itemGuid: any): void; - startWorkflow(associationName: any, correlationId: any, listId: any, itemGuid: any, workflowParameters: any): SP.GuidResult; - cancelWorkflow(instanceId: any): void; + enableEvents(listId: SP.Guid, itemGuid: SP.Guid): void; + disableEvents(listId: SP.Guid, itemGuid: SP.Guid): void; + startWorkflow(associationName: string, correlationId: SP.Guid, listId: SP.Guid, itemGuid: SP.Guid, workflowParameters: any): SP.GuidResult; + cancelWorkflow(instanceId: SP.Guid): void; } /** Represents a workflow definition and associated properties. */ @@ -8312,7 +8377,6 @@ declare module SP.WorkflowServices { /** Manages workflow definitions and workflow activity authoring. */ export class WorkflowDeploymentService extends SP.ClientObject { - constructor(context: SP.ClientRuntimeContext, objectPath: SP.ObjectPathStaticProperty); /** Returns an XML representation of a list of valid Workflow Manager Client 1.0 actions for the specified web (WorkflowInfo element). */ getDesignerActions(web: SP.Web): SP.StringResult; /** Returns an XML representation of a collection of XAML class signatures for workflow definitions. @@ -8336,7 +8400,7 @@ declare module SP.WorkflowServices { getDefinition(definitionId: string): WorkflowDefinition; /** Saves the collateral file of a workflow definition. @param workflowDefinitionId The guid identifier of the workflow definition.*/ - saveCollateral(workflowDefinitionId: string, leafFileName: string, fileContent: any): void; + saveCollateral(workflowDefinitionId: string, leafFileName: string, fileContent: Base64EncodedByteArray): void; /** Deletes the URL of a workflow definition's collateral file. @param workflowDefinitionId The guid identifier of the workflow definition. */ deleteCollateral(workflowDefinitionId: string, leafFileName: string): void; @@ -8353,7 +8417,7 @@ declare module SP.WorkflowServices { @param packageDefaultFilename The default filename to choose for the new package. @param packageTitle The title of the package. @param packageDescription The description of the package. */ - packageDefinition(definitionId: any, packageDefaultFilename: any, packageTitle: any, packageDescription: any): SP.StringResult; + packageDefinition(definitionId: SP.Guid, packageDefaultFilename: string, packageTitle: string, packageDescription: string): SP.StringResult; } /** Represents an instance of a workflow association that performs on a list item the process that is defined in a workflow template */ @@ -8451,9 +8515,9 @@ declare module SP.WorkflowServices { /** Base class representing subscriptions for the external workflow host. */ export class WorkflowSubscription extends SP.ClientObject { /** Gets the unique ID of the workflow definition to activate. */ - get_definitionId(): any; + get_definitionId(): SP.Guid; /** Sets the unique ID of the workflow definition to activate. */ - set_definitionId(value: any): any; + set_definitionId(value: SP.Guid): SP.Guid; /** Gets a boolean value that specifies if the workflow subscription is enabled. When disabled, new instances of the subscription cannot be started, but existing instances will continue to run. */ get_enabled(): boolean; @@ -8479,9 +8543,9 @@ declare module SP.WorkflowServices { /** Boolean value that specifies whether multiple workflow instances can be started manually on the same list item at the same time. This property can be used for list workflows only. */ set_manualStartBypassesActivationLimit(value: boolean): boolean; /** Gets the name of the workflow subscription for the specified event source. */ - get_name(): any; + get_name(): string; /** Sets the name of the workflow subscription for the specified event source. */ - set_name(value: any): any; + set_name(value: string): string; /** Gets the properties and values to pass to the workflow definition when the subscription is matched. */ get_propertyDefinitions(): any; /** Gets the name of the workflow status field on the specified list. */ @@ -8520,8 +8584,8 @@ declare module SP.WorkflowServices { @param listId GUID of the list containing the event receiver to be unregistered. @eventName eventName The name of the event to be removed. */ unregisterInterestInList(listId: string, eventName: string): void; - getSubscription(subscriptionId: any): WorkflowSubscription; - deleteSubscription(subscriptionId: any): WorkflowSubscription; + getSubscription(subscriptionId: SP.Guid): WorkflowSubscription; + deleteSubscription(subscriptionId: SP.Guid): WorkflowSubscription; /** Retrieves workflow subscriptions that contains all of the workflow subscriptions on the Web */ enumerateSubscriptions(): WorkflowSubscriptionCollection; /** Retrieves workflow subscriptions based on workflow definition */ @@ -8764,7 +8828,7 @@ declare module SP { public get_view(): NavigationTermSetView; - public createTerm(termName: string, linkType: NavigationLinkType, termId: Guid): any; + public createTerm(termName: string, linkType: NavigationLinkType, termId: Guid): Taxonomy.Term; public getTaxonomyTermStore(): Taxonomy.TermStore; @@ -8821,7 +8885,7 @@ declare module SP { public getResolvedAssociatedFolderUrl(): StringResult; - public getWebRelativeFriendlyUrl(): any; StringResult: any; + public getWebRelativeFriendlyUrl(): StringResult; public getAllParentTerms(): NavigationTermCollection; @@ -8898,11 +8962,11 @@ declare module SP { export class TaxonomyNavigation { static getWebNavigationSettings(context: ClientContext, web: Web): WebNavigationSettings; static getTermSetForWeb(context: ClientContext, web: Web, siteMapProviderName: string, includeInheritedSettings: boolean): NavigationTermSet; - static setCrawlAsFriendlyUrlPage(context: ClientContext, navigationTerm: any, crawlAsFriendlyUrlPage: any): BooleanResult; + static setCrawlAsFriendlyUrlPage(context: ClientContext, navigationTerm: Taxonomy.Term, crawlAsFriendlyUrlPage: boolean): BooleanResult; static getNavigationLcidForWeb(context: ClientContext, web: Web): IntResult; static flushSiteFromCache(context: ClientContext, site: Site): void; static flushWebFromCache(context: ClientContext, web: Web): void; - static flushTermSetFromCache(context: ClientContext, webForPermissions: any, termStoreId: Guid, termSetId: Guid): void; + static flushTermSetFromCache(context: ClientContext, webForPermissions: Web, termStoreId: Guid, termSetId: Guid): void; } export class WebNavigationSettings extends ClientObject { @@ -8946,7 +9010,6 @@ declare module SP { } export class SPContainerId extends ClientObject { - constructor(context: ClientRuntimeContext, objectPath: ObjectPath); static createFromList(context: ClientRuntimeContext, list: List): SPContainerId; static createFromWeb(context: ClientRuntimeContext, web: Web): SPContainerId; static createFromSite(context: ClientRuntimeContext, site: Site): SPContainerId; @@ -8980,7 +9043,6 @@ declare module SP { } export class SPPolicyAssociation extends ClientObject { - constructor(context: ClientRuntimeContext, objectPath: ObjectPath); get_allowOverride(): boolean; set_allowOverride(value: boolean): boolean; @@ -9026,7 +9088,6 @@ declare module SP { } export class SPPolicyBinding extends ClientObject { - constructor(context: ClientRuntimeContext, objectPath: ObjectPath); get_identity(): any; set_identity(value: any): any; @@ -9072,7 +9133,6 @@ declare module SP { } export class SPPolicyDefinition extends ClientObject { - constructor(context: ClientRuntimeContext, objectPath: ObjectPath); get_comment(): string; set_comment(value: string): string; @@ -9080,8 +9140,8 @@ declare module SP { get_createdBy(): any; set_createdBy(value: any): any; - get_defaultPolicyRuleConfigId: any; - set_defaultPolicyRuleConfigId: any; + get_defaultPolicyRuleConfigId(): any; + set_defaultPolicyRuleConfigId(value: any): any; get_description(): string; set_description(value: string): string; @@ -9120,7 +9180,6 @@ declare module SP { } export class SPPolicyRule extends ClientObject { - constructor(context: ClientRuntimeContext, objectPath: ObjectPath); get_comment(): string; set_comment(value: string): string; @@ -9176,7 +9235,7 @@ declare module SP { deletePolicyRule(policyRuleId: any): void; - notifyUnifiedPolicySync(notificationId: any, syncSvcUrl: string, changeInfos: any, syncNow: boolean, fullSyncForTenant: any): void; + notifyUnifiedPolicySync(notificationId: any, syncSvcUrl: string, changeInfos: any, syncNow: boolean, fullSyncForTenant: boolean): void; updatePolicyDefinition(policyDefinition: SPPolicyDefinition): void; @@ -9394,7 +9453,7 @@ declare class SPClientPeoplePicker { public SetInitialValue(entities: ISPClientPeoplePickerEntity[], initialErrorMsg?: string): void public AddUserKeys(userKeys: string, bSearch: boolean): void; - public BatchAddUserKeysOperation(allKeys: string[], numProcessed: number): any; + public BatchAddUserKeysOperation(allKeys: string[], numProcessed: number): void; public ResolveAllUsers(fnContinuation: () => void): void; public ExecutePickerQuery(queryIds: string, onSuccess: (queryId: string, result: SP.StringResult) => void, onFailure: (queryId: string, result: SP.StringResult) => void, fnContinuation: () => void): void; public AddUnresolvedUserFromEditor(bRunQuery?: boolean): void; @@ -9437,7 +9496,7 @@ declare class SPClientPeoplePicker { public AddLoadingSuggestionMenuOption(): void; public ShowingLocalSuggestions(): boolean; public ShouldUsePPMRU(): boolean; - public AddResolvedUserToLocalCache(resolvedEntity: ISPClientPeoplePickerEntity, resolveText: string): any; + public AddResolvedUserToLocalCache(resolvedEntity: ISPClientPeoplePickerEntity, resolveText: string): void; } interface ISPClientPeoplePickerSchema { @@ -9532,7 +9591,7 @@ declare class SPClientPeoplePickerProcessedUser { ErrorDescription: string;// '', ResolveText: string;// '', public UpdateResolvedUser(newUserInfo: ISPClientPeoplePickerEntity, strNewElementId: string): void; - public UpdateSuggestions(entity: ISPClientPeoplePickerEntity): any; + public UpdateSuggestions(entity: ISPClientPeoplePickerEntity): void; public BuildUserHTML(): string; public UpdateUserMaxWidth(): void; public ResolvedAsUnverifiedEmail(): string; @@ -9551,16 +9610,17 @@ declare module Microsoft { export module ReputationModel { export class Reputation { constructor(); - static setLike(context: SP.ClientContext, listId: string, itemId: number, like: boolean): any; - static setRating(context: SP.ClientContext, listId: string, itemId: number, rating: number): any; + static setLike(context: SP.ClientContext, listId: string, itemId: number, like: boolean): void; + static setRating(context: SP.ClientContext, listId: string, itemId: number, rating: number): void; } } } } } + /** Available only in SharePoint Online*/ declare module Define { - export function loadScript(url: string, successCallback: () => void, errCallback: () => void): any; + export function loadScript(url: string, successCallback: () => void, errCallback: () => void): void; /** Loads script from _layouts/15/[req].js */ export function require(req: string, callback: Function): void; /** Loads script from _layouts/15/[req].js */ @@ -9570,7 +9630,7 @@ declare module Define { /** Available only in SharePoint Online*/ declare module Verify { - export function ArgumentType(arg: string, expected: any): any; + export function ArgumentType(arg: string, expected: any): void; } @@ -9582,7 +9642,7 @@ declare module BrowserStorage { /** Available only in SharePoint Online*/ interface CachedStorage { getItem(key: string): string; - setItem(key: string, value: string): any; + setItem(key: string, value: string): void; removeItem(key: string): void; clead(): void; length: number; @@ -9621,7 +9681,7 @@ declare module DOM { export function GetEventSrcElement(evt: Event): HTMLElement; export function GetInnerText(el: HTMLElement): string; export function PreventDefaultNavigation(evt: Event): void; - export function SetEvent(eventName: string, eventFunc: Function, el: HTMLElement): any; + export function SetEvent(eventName: string, eventFunc: Function, el: HTMLElement): void; } /** Available only in SharePoint Online*/ @@ -9645,8 +9705,8 @@ declare module IE8Support { /** Available only in SharePoint Online*/ declare module StringUtil { - export function BuildParam(stPattern: string, ...params: any[]): any; - export function ApplyStringTemplate(str: string, ...params: any[]): any; + export function BuildParam(stPattern: string, ...params: any[]): string; + export function ApplyStringTemplate(str: string, ...params: any[]): string; } /** Available only in SharePoint Online*/ @@ -9867,10 +9927,20 @@ declare module SP { HideInitialLoadingBanner(): void; ShowInitialGridErrorMsg(errorMsg: string): void; ShowGridErrorMsg(errorMsg: string): void; - LaunchPrintView(additionalScriptFiles: any, beforeInitFnName: any, beforeInitFnArgsObj: any, title: any, bEnableGantt: any, optGanttDelegateNames: any, optInitTableViewParamsFnName: any, optInitTableViewParamsFnArgsObj: any, optInitGanttStylesFnName: any, optInitGanttStylesFnArgsObj: any): void; + LaunchPrintView( + additionalScriptFiles: any, + beforeInitFnName: any, + beforeInitFnArgsObj: any, + title: string, + bEnableGantt: boolean, + optGanttDelegateNames?: any, + optInitTableViewParamsFnName?: any, + optInitTableViewParamsFnArgsObj?: any, + optInitGanttStylesFnName?: any, + optInitGanttStylesFnArgsObj?: any): void; GetAllDataJson(fnOnFinished: any, optFnGetCellStyleID?: any): void; SetTableView(tableViewParams: any): void; - SetRowView(rowViewParams: any): void; + SetRowView(rowViewParam: any): void; /** Enable grid after Disable. */ Enable(): void; @@ -9885,7 +9955,7 @@ declare module SP { /** Switches the currently selected cell into edit mode: displays edit control and sets focus into it. Returns true if success. */ TryBeginEdit(): boolean; - FinalizeEditing(fnContinue: any, fnError: any): void; + FinalizeEditing(fnContinue: Function, fnError: Function): void; /** Get diff tracker object that tracks changes to the grid data. */ GetDiffTracker(): SP.JsGrid.Internal.DiffTracker; /** Moves focus to the JsGrid control */ @@ -9943,7 +10013,7 @@ declare module SP { MoveRecordsUpByOne(recordKeys: any): any; MoveRecordsDownByOne(recordKeys: any): any; GetReorderRange(recordKeys: any): any; - GetNodeExpandCollapseState(recordKey: any): any; + GetNodeExpandCollapseState(recordKey: number): any; ToggleExpandCollapse(recordKey: number): void; /** Attach event handler to a particular event type */ @@ -10002,7 +10072,7 @@ declare module SP { HideColumn(columnKey: string): void; /** Update column descriptions */ UpdateColumns(columnInfoCollection: ColumnInfoCollection): void; - GetColumns(optPaneId?: any): ColumnInfo[]; + GetColumns(optPaneId?: string): ColumnInfo[]; /** Get ColumnInfo object by fieldKey @fieldKey when working with SharePoint data sources, fieldKey corresponds to field internal name */ GetColumnByFieldKey(fieldKey: string, optPaneId?: any): ColumnInfo; @@ -10060,12 +10130,12 @@ declare module SP { /** Moves cursor to entry record (the row that is used to add new records) */ JumpToEntryRecord(): void; - SelectRowRange(rowIdx1: any, rowIdx2: any, bAppend: any, optPaneId?: any): void; - SelectColumnRange(colIdx1: any, colIdx2: any, bAppend: any, optPaneId?: any): void; - SelectCellRange(rowIdx1: any, rowIdx2: any, colIdx1: any, colIdx2: any, bAppend: any, optPaneId: any): void; - SelectRowRangeByKey(rowKey1: any, rowKey2: any, bAppend: any, optPaneId?: any): void; - SelectColumnRangeByKey(colKey1: any, colKey2: any, bAppend: any, optPaneId?: any): void; - SelectCellRangeByKey(recordKey1: string, recordKey2: string, colKey1: any, colKey2: any, bAppend: any, optPaneId?: any): void; + SelectRowRange(rowIdx1: number, rowIdx2: number, bAppend: boolean, optPaneId?: string): void; + SelectColumnRange(colIdx1: number, colIdx2: number, bAppend: boolean, optPaneId?: string): void; + SelectCellRange(rowIdx1: number, rowIdx2: number, colIdx1: number, colIdx2: number, bAppend: boolean, optPaneId?: string): void; + SelectRowRangeByKey(rowKey1: any, rowKey2: any, bAppend: boolean, optPaneId?: string): void; + SelectColumnRangeByKey(colKey1: any, colKey2: any, bAppend: boolean, optPaneId?: string): void; + SelectCellRangeByKey(recordKey1: string, recordKey2: string, colKey1: any, colKey2: any, bAppend: boolean, optPaneId?: string): void; ChangeKeys(oldKey: any, newKey: any): void; GetSelectedRowRanges(optPaneId?: any): any; @@ -10261,14 +10331,14 @@ declare module SP { validationState: SP.JsGrid.ValidationState; } export class RecordInserted implements IEventArgs { - constructor(recordKey: any, recordIdx: any, afterRecordKey: any, changeKey: any); + constructor(recordKey: number, recordIdx: number, afterRecordKey: number, changeKey: JsGrid.IChangeKey); recordKey: number; recordIdx: number; afterRecordKey: number; changeKey: JsGrid.IChangeKey; } export class RecordDeleted implements IEventArgs { - constructor(recordKey: any, recordIdx: any, changeKey: any); + constructor(recordKey: number, recordIdx: number, changeKey: JsGrid.IChangeKey); recordKey: number; recordIdx: number; changeKey: JsGrid.IChangeKey; @@ -10279,7 +10349,7 @@ declare module SP { bChecked: boolean; } export class OnCellErrorStateChanged implements IEventArgs { - constructor(recordKey: any, fieldKey: any, bAddingError: any, bCellCurrentlyHasError: any, bCellHadError: any, errorId: any); + constructor(recordKey: number, fieldKey: string, bAddingError: boolean, bCellCurrentlyHasError: boolean, bCellHadError: boolean, errorId: number); recordKey: number; fieldKey: string; bAddingError: boolean; @@ -10288,7 +10358,7 @@ declare module SP { errorId: number; } export class OnRowErrorStateChanged implements IEventArgs { - constructor(recordKey: any, bAddingError: any, bErrorCurrentlyInRow: any, bRowHadError: any, errorId: any, message: any); + constructor(recordKey: number, bAddingError: boolean, bErrorCurrentlyInRow: boolean, bRowHadError: boolean, errorId: number, message: string); recordKey: number; bAddingError: boolean; bErrorCurrentlyInRow: boolean; @@ -10412,8 +10482,8 @@ declare module SP { UpdateSplitterStyleFromCss(styleObject: IStyleType.Splitter, splitterStyleNameCollection: any): void; UpdateHeaderStyleFromCss(styleObject: IStyleType.Header, headerStyleNameCol: any): void; UpdateGridPaneStyleFromCss(styleObject: IStyleType.GridPane, gridStyleNameCollection: any): void; - UpdateDefaultCellStyleFromCss(styleObject: IStyleType.Cell, cssClass: any): void; - UpdateGroupStylesFromCss(styleObject: any, prefix: any): void; + UpdateDefaultCellStyleFromCss(styleObject: IStyleType.Cell, cssClass: string): void; + UpdateGroupStylesFromCss(styleObject: IStyleType.Cell, prefix: string): void; } export interface IStyleType { } @@ -10530,15 +10600,15 @@ declare module SP { static SetRTL: { (rtlObject: any): void; }; static MakeJsGridStyleManager: { (): IStyleManager }; - static CreateStyleFromCss: { (styleType: IStyleType, cssStyleName: string, optExistingStyle: any, optClassId: any): any; }; + static CreateStyleFromCss: { (styleType: IStyleType, cssStyleName: string, optExistingStyle?: any, optClassId?: any): any; }; static CreateStyle: { (styleType: IStyleType, styleProps: any): any; }; static MergeCellStyles: { (majorStyle: any, minorStyle: any): any; }; - static ApplyCellStyle: { (td: any, style: any): void; }; - static ApplyRowHeaderStyle: { (domObj: any, style: any, fnGetHeaderSibling: any): void; }; - static ApplyCornerHeaderBorderStyle: { (domObj: any, colStyle: any, rowStyle: any): void; }; - static ApplyHeaderInnerBorderStyle: { (domObj: any, bIsRowHeader: any, headerObject: any): void }; - static ApplyColumnContextMenuStyle: { (domObj: any, style: any): void }; - static ApplySplitterStyle: { (domObj: any, style: any): void }; + static ApplyCellStyle: { (td: HTMLTableCellElement, style: any): void; }; + static ApplyRowHeaderStyle: { (domObj: HTMLElement, style: any, fnGetHeaderSibling: Function): void; }; + static ApplyCornerHeaderBorderStyle: { (domObj: HTMLElement, colStyle: any, rowStyle: any): void; }; + static ApplyHeaderInnerBorderStyle: { (domObj: HTMLElement, bIsRowHeader: any, headerObject: any): void }; + static ApplyColumnContextMenuStyle: { (domObj: HTMLElement, style: any): void }; + static ApplySplitterStyle: { (domObj: HTMLElement, style: any): void }; static MakeBorderString: { (width: number, style: string, color: string): string }; static GetCellStyleDefaultBackgroundColor: { (): string }; @@ -10649,7 +10719,7 @@ declare module SP { constructor(gridFieldMap: any, keyColumnName: string, fnGetPropType: any); gridFieldMap: any; /** Create a new record */ - MakeRecord(dataPropMap: any, localizedPropMap: any, bKeepRawData: any): IRecord; + MakeRecord(dataPropMap: any, localizedPropMap: any, bKeepRawData: boolean): IRecord; } export interface IPropertyBase { @@ -10800,11 +10870,11 @@ declare module SP { export class Utils { - static RegisterDisplayControl(name: string, singleton: any, requiredFunctionNames: string[]): any; - static RegisterEditControl(name: string, factory: (gridContext: IEditControlGridContext, gridTextInputElement: HTMLElement) => IEditControl, requiredFunctionNames: string[]): any; - static RegisterWidgetControl(name: string, factory: { (ddContext: any): IPropertyType; }, requiredFunctionNames: string[]): any; + static RegisterDisplayControl(name: string, singleton: any, requiredFunctionNames: string[]): void; + static RegisterEditControl(name: string, factory: (gridContext: IEditControlGridContext, gridTextInputElement: HTMLElement) => IEditControl, requiredFunctionNames: string[]): void; + static RegisterWidgetControl(name: string, factory: { (ddContext: any): IPropertyType; }, requiredFunctionNames: string[]): void; - static UpdateDisplayControlForPropType(propTypeName: string, displayControlType: string): any; + static UpdateDisplayControlForPropType(propTypeName: string, displayControlType: string): void; } } @@ -10819,7 +10889,7 @@ declare module SP { export module Internal { export class DiffTracker { - constructor(objBag: any, fnGetChange: any); + constructor(objBag: any, fnGetChange: Function); ExternalAPI: { AnyChanges(): boolean; ChangeKeySliceInfo(): any; @@ -10827,7 +10897,7 @@ declare module SP { EventSliceInfo(): any; GetChanges(optStartEvent: any, optEndEvent: any, optRecordKeys: any, bFirstStartEvent: boolean, bStartInclusive: boolean, bEndInclusive: boolean, bIncludeInvalidPropUpdates: boolean, bLastEndEvent: boolean): any; GetChangesAsJson(changeQuery: any, optfnPreProcessUpdateForSerialize?: any): string; - GetUniquePropertyChanges(changeQuery: any, optfnFilter: any): any; + GetUniquePropertyChanges(changeQuery: any, optfnFilter?: any): any; RegisterEvent(changeKey: IChangeKey, eventObject: any): void; UnregisterEvent(changeKey: IChangeKey, eventObject: any): void; }; @@ -10874,20 +10944,20 @@ declare module SP { export interface IEditControl { SupportedWriteMode?: SP.JsGrid.EditActorWriteType; SupportedReadMode?: SP.JsGrid.EditActorReadType; - GetCellContext? (): IEditControlCellContext; - GetOriginalValue? (): IValue; - SetValue? (value: IValue): void; + GetCellContext?(): IEditControlCellContext; + GetOriginalValue?(): IValue; + SetValue?(value: IValue): void; Dispose(): void; - GetInputElement? (): HTMLElement; - Focus? (eventInfo: Sys.UI.DomEvent): void; + GetInputElement?(): HTMLElement; + Focus?(eventInfo: Sys.UI.DomEvent): void; BindToCell(cellContext: IEditControlCellContext): void; OnBeginEdit(eventInfo: Sys.UI.DomEvent): void; Unbind(): void; OnEndEdit(): void; - OnCellMove? (): void; - OnValueChanged? (newValue: IValue): void; - IsCurrentlyUsingGridTextInputElement? (): boolean; - SetSize? (width: number, height: number): void; + OnCellMove?(): void; + OnValueChanged?(newValue: IValue): void; + IsCurrentlyUsingGridTextInputElement?(): boolean; + SetSize?(width: number, height: number): void; } } diff --git a/sharepoint/SharePoint.d.ts.tscparams b/sharepoint/SharePoint.d.ts.tscparams index d3f5a12fa..ac975cac6 100644 --- a/sharepoint/SharePoint.d.ts.tscparams +++ b/sharepoint/SharePoint.d.ts.tscparams @@ -1 +1 @@ - +--noImplicitAny \ No newline at end of file From a0c689f1b7c0d46e66677c77bdabe16412650101 Mon Sep 17 00:00:00 2001 From: Christian Holm Diget Date: Thu, 1 Oct 2015 09:51:10 +0200 Subject: [PATCH 51/64] Added satnav --- satnav/satnav-tests.ts | 18 ++++++++++++++++++ satnav/satnav.d.ts | 22 ++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 satnav/satnav-tests.ts create mode 100644 satnav/satnav.d.ts diff --git a/satnav/satnav-tests.ts b/satnav/satnav-tests.ts new file mode 100644 index 000000000..6382c0481 --- /dev/null +++ b/satnav/satnav-tests.ts @@ -0,0 +1,18 @@ +/// +Satnav({}) +.navigate({ + path: 'product/{required}/?{optional}', + directions: (params) => { + // Logic for product route + console.log(params.required); + console.log(params.hasOwnProperty('optional')); + } +}) +.otherwise('/product/1') +.change(function (hash, params, old) { + // Logic for any change + console.log(hash); + console.log(params); + console.log(old); +}) +.go(); //Resolve current route \ No newline at end of file diff --git a/satnav/satnav.d.ts b/satnav/satnav.d.ts new file mode 100644 index 000000000..a6eee950d --- /dev/null +++ b/satnav/satnav.d.ts @@ -0,0 +1,22 @@ +declare type Callback = () => void; + +interface ISatnavOptions { + html5?: boolean, + force?: boolean, + poll?: number +} + +interface INavigationOptions { + path?: string, + directions?: (params : any) => any, + title?: string | Callback +} + +interface ISatnav { + navigate(navigationOptions: INavigationOptions): ISatnav; + otherwise(route: string): ISatnav; + change(onChange: (hash: string, params: any, old: any) => any): ISatnav; + go(): ISatnav; +} + +declare function Satnav(options?: ISatnavOptions): ISatnav; \ No newline at end of file From a27393c98bde3793f7b6dea5c062bbc36e9227e9 Mon Sep 17 00:00:00 2001 From: Christian Holm Diget Date: Thu, 1 Oct 2015 10:00:26 +0200 Subject: [PATCH 52/64] Added required comments --- satnav/satnav.d.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/satnav/satnav.d.ts b/satnav/satnav.d.ts index a6eee950d..3ad690941 100644 --- a/satnav/satnav.d.ts +++ b/satnav/satnav.d.ts @@ -1,3 +1,8 @@ +// Type definitions for satnav +// Project: https://github.com/f5io/satnav-js +// Definitions by: Christian Holm Diget +// Definitions: https://github.com/borisyankov/DefinitelyTyped + declare type Callback = () => void; interface ISatnavOptions { From db43dd03f58aa57e2e1c9453465ca1a27ce1551d Mon Sep 17 00:00:00 2001 From: Christian Holm Diget Date: Thu, 1 Oct 2015 10:41:25 +0200 Subject: [PATCH 53/64] Added matchAll property --- satnav/satnav.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/satnav/satnav.d.ts b/satnav/satnav.d.ts index 3ad690941..5b16a3ffb 100644 --- a/satnav/satnav.d.ts +++ b/satnav/satnav.d.ts @@ -8,7 +8,8 @@ declare type Callback = () => void; interface ISatnavOptions { html5?: boolean, force?: boolean, - poll?: number + poll?: number, + matchAll?: boolean } interface INavigationOptions { From 2179e38badc9c4954f2f72dd1f1856cf8e623755 Mon Sep 17 00:00:00 2001 From: Panu Horsmalahti Date: Thu, 1 Oct 2015 11:46:34 +0300 Subject: [PATCH 54/64] Add Jade type definition. --- jade/jade-tests.ts | 10 ++++++++++ jade/jade.d.ts | 19 +++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 jade/jade-tests.ts create mode 100644 jade/jade.d.ts diff --git a/jade/jade-tests.ts b/jade/jade-tests.ts new file mode 100644 index 000000000..8a2b6b48d --- /dev/null +++ b/jade/jade-tests.ts @@ -0,0 +1,10 @@ +/// + +import jade from 'jade'; + +jade.compile("b")(); +jade.compileFile("foo.jade", {})(); +jade.compileClient("a")({ a: 1 }); +jade.compileClientWithDependenciesTracked("test").body(); +jade.render("h1",{}); +jade.renderFile("foo.jade"); \ No newline at end of file diff --git a/jade/jade.d.ts b/jade/jade.d.ts new file mode 100644 index 000000000..78bfbf1a2 --- /dev/null +++ b/jade/jade.d.ts @@ -0,0 +1,19 @@ +// Type definitions for jade +// Project: https://github.com/jadejs/jade +// Definitions by: Panu Horsmalahti +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module 'jade' { + module jade { + function compile(template: string, options?: any): (locals?: any) => string; + function compileFile(path: string, options?: any): (locals?: any) => string; + function compileClient(template: string, options?: any): (locals?: any) => string; + function compileClientWithDependenciesTracked(template: string, options?: any): { + body: (locals?: any) => string; + dependencies: string[]; + }; + function render(template: string, options?: any): string; + function renderFile(path: string, options?: any): string; + } + export default jade; +} From 28598f90d12b6972e66962f1e1d06d8ab4d784db Mon Sep 17 00:00:00 2001 From: Panu Horsmalahti Date: Thu, 1 Oct 2015 11:55:32 +0300 Subject: [PATCH 55/64] Change email to url. --- jade/jade.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jade/jade.d.ts b/jade/jade.d.ts index 78bfbf1a2..9615fa8c8 100644 --- a/jade/jade.d.ts +++ b/jade/jade.d.ts @@ -1,6 +1,6 @@ // Type definitions for jade // Project: https://github.com/jadejs/jade -// Definitions by: Panu Horsmalahti +// Definitions by: Panu Horsmalahti // Definitions: https://github.com/borisyankov/DefinitelyTyped declare module 'jade' { From 7a79c29c2647a71584faf6352ff922740caf953c Mon Sep 17 00:00:00 2001 From: Dan Marshall Date: Thu, 1 Oct 2015 10:29:15 -0700 Subject: [PATCH 56/64] added layer --- maker.js/makerjs-tests.ts | 9 +++++++++ maker.js/makerjs.d.ts | 16 ++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/maker.js/makerjs-tests.ts b/maker.js/makerjs-tests.ts index be5b53229..59a50e4fc 100644 --- a/maker.js/makerjs-tests.ts +++ b/maker.js/makerjs-tests.ts @@ -116,6 +116,15 @@ function test() { new makerjs.paths.Chord(paths.arc); new makerjs.paths.Parallel(paths.line, 4, [1,1]); + //paths.line.layer = "0"; + + var x: MakerJs.IPathLine = { + type: "line", + origin: [9,9], + end: [8,8], + layer: "4" + }; + return paths; } diff --git a/maker.js/makerjs.d.ts b/maker.js/makerjs.d.ts index bcba375f8..69cd3dbb7 100644 --- a/maker.js/makerjs.d.ts +++ b/maker.js/makerjs.d.ts @@ -96,11 +96,15 @@ declare module MakerJs { /** * The type of the path, e.g. "line", "circle", or "arc". These strings are enumerated in pathType. */ - type: string; + "type": string; /** * The main point of reference for this path. */ origin: IPoint; + /** + * Optional layer of this path. + */ + layer?: string; } /** * Test to see if an object implements the required properties of a path. @@ -193,7 +197,7 @@ declare module MakerJs { /** * Key is the type of a path, value is a function which accepts a path object a point object as its parameters. */ - [type: string]: (id: string, pathValue: IPath, origin: IPoint) => void; + [type: string]: (id: string, pathValue: IPath, origin: IPoint, layer: string) => void; } /** * String-based enumeration of all paths types. @@ -276,7 +280,7 @@ declare module MakerJs { /** * A model may want to specify its type, but this value is not employed yet. */ - type?: string; + "type"?: string; /** * Optional array of path objects in this model. */ @@ -293,6 +297,10 @@ declare module MakerJs { * An author may wish to add notes to this model instance. */ notes?: string; + /** + * Optional layer of this model. + */ + layer?: string; } /** * Test to see if an object implements the required properties of a model. @@ -844,7 +852,7 @@ declare module MakerJs.exporter { * @param pathToExport The path to export. * @param offset The offset position of the path. */ - exportPath(id: string, pathToExport: IPath, offset: IPoint): void; + exportPath(id: string, pathToExport: IPath, offset: IPoint, layer: string): void; /** * Export a model. * From 369a31db8892db37c8d2e913adef42e867c74113 Mon Sep 17 00:00:00 2001 From: ridermansb Date: Thu, 1 Oct 2015 14:47:26 -0300 Subject: [PATCH 57/64] Remove tsconfig file --- stamplay-js-sdk/tsconfig.json | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 stamplay-js-sdk/tsconfig.json diff --git a/stamplay-js-sdk/tsconfig.json b/stamplay-js-sdk/tsconfig.json deleted file mode 100644 index 8d5b43ce4..000000000 --- a/stamplay-js-sdk/tsconfig.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "compilerOptions": { - "target": "ES5", - "module": "amd" - } -} From 5fb76e8991af6beddb73715e68937808dafa0990 Mon Sep 17 00:00:00 2001 From: Julio Casal Date: Thu, 1 Oct 2015 22:47:44 -0700 Subject: [PATCH 58/64] Adds support for opening QuickStart and Users blades, multiple APIs to support the canpinAllBladeParts test and support for waiting for notifications --- msportalfx-test/msportalfx-test-tests.ts | 55 +++++++++++++++- msportalfx-test/msportalfx-test.d.ts | 82 +++++++++++++++++++++--- 2 files changed, 125 insertions(+), 12 deletions(-) diff --git a/msportalfx-test/msportalfx-test-tests.ts b/msportalfx-test/msportalfx-test-tests.ts index 98f86dcd4..7d647106d 100644 --- a/msportalfx-test/msportalfx-test-tests.ts +++ b/msportalfx-test/msportalfx-test-tests.ts @@ -17,11 +17,11 @@ var extensionUrl = 'https://localhost:44300/'; var voidPromise: Q.Promise; var boolPromise: Q.Promise; var anyPromise: Q.Promise; +var stringPromise: Q.Promise; var summaryBlade = new testFx.Blades.Blade(resourceName); -function TestPortal() { - +function TestPortal() { testFx.portal.portalContext.signInEmail = userName; testFx.portal.portalContext.signInPassword = password; testFx.portal.portalContext.features = [{ name: "greatfeature", value: "true" }]; @@ -35,11 +35,17 @@ function TestPortal() { var stringPromise = testFx.portal.takeScreenshot("TestPortal"); var stringArrayPromise = testFx.portal.getBrowserLogs(testFx.LogLevel.All); anyPromise = testFx.portal.waitUntilElementDoesNotContainAttribute(testFx.Locators.By.className('part'), 'class', 'invalid'); + voidPromise = testFx.portal.goHome(); + boolPromise = testFx.portal.waitForElementVisible(summaryBlade.getLocator()); + var anyArrayPromise = testFx.portal.waitForElementsLocated(summaryBlade.getLocator()); + var voidPromise = testFx.portal.executeScript("console.log('hello from script');"); + stringPromise = testFx.portal.getCurrentUrl(); } function TestBlades() { var blade = new testFx.Blades.Blade(resourceName); - blade.clickCommand('Delete'); + var bladePromise = blade.clickCommand('Delete'); + var tilesPromise = blade.getTiles(); var createBlade = new testFx.Blades.CreateBlade(bladeTitle); voidPromise = createBlade.actionBar.createButton.click(); @@ -52,6 +58,11 @@ function TestBlades() { var specPickerBlade = new testFx.Blades.SpecPickerBlade(bladeTitle); specPickerBlade.pickSpec('S2'); + + var quickStartBlade = new testFx.Blades.QuickStartBlade(); + voidPromise = quickStartBlade.clickLink('Learn more'); + + var usersBlade = new testFx.Blades.UsersBlade(); } function TestParts() { @@ -60,12 +71,21 @@ function TestParts() { boolPromise = part.isSelected(); boolPromise = part.waitUntilLoaded(); boolPromise = part.isLoaded(); + boolPromise = part.isClickable(); + boolPromise = part.hasError(); var resourceSummary = new testFx.Parts.ResourceSummaryPart(summaryBlade.getLocator()); var count = resourceSummary.properties.length; + voidPromise = resourceSummary.quickStartHotSpot.click(); + voidPromise = resourceSummary.accessHotSpot.click(); var pricingTier = new testFx.Parts.PricingTierPart(summaryBlade.getLocator()); voidPromise = pricingTier.click(); + + var tile = new testFx.Parts.Tile(summaryBlade.getLocator()); + voidPromise = tile.tryPin(); + var part: testFx.Parts.Part = tile.getPart(); + voidPromise = tile.waitUntilLoaded(); } function TestControls() { @@ -78,6 +98,9 @@ function TestControls() { var textField = new testFx.Controls.TextField(summaryBlade.getLocator(), "Resource name"); var textFieldPromise = textField.sendKeys(resourceName); + + var hotSpot = new testFx.Controls.HotSpot(summaryBlade.getLocator()); + boolPromise = hotSpot.isSelected(); } function TestActionBars() { @@ -90,4 +113,30 @@ function TestActionBars() { var pickerBar = new testFx.ActionBars.PickerActionBar(summaryBlade.getLocator()); voidPromise = pickerBar.selectButton.click(); +} + +function TestCommands() { + var menu = new testFx.Commands.ContextMenu(); + var itemName = "Pin"; + boolPromise = menu.hasItem(itemName); + voidPromise = menu.clickItem(itemName); + + var item = new testFx.Commands.ContextMenuItem(menu.getLocator(), itemName); + voidPromise = item.click(); +} + +function TestStartBoard() { + var board = new testFx.StartBoard(); + var tilesPromise = board.getTiles(); +} + +function TestNotifications() { + var menu = new testFx.Notifications.NotificationsMenu(); + menu.waitForNewNotification("success").then((notification) => { + stringPromise = notification.getDescription(); + }); +} + +function TestTests() { + boolPromise = testFx.Tests.Parts.canPinAllBladeParts(resourceId, bladeTitle); } \ No newline at end of file diff --git a/msportalfx-test/msportalfx-test.d.ts b/msportalfx-test/msportalfx-test.d.ts index 5ba413484..626038786 100644 --- a/msportalfx-test/msportalfx-test.d.ts +++ b/msportalfx-test/msportalfx-test.d.ts @@ -76,6 +76,7 @@ declare module MsPortalTestFx { constructor(title: string); clickCommand(commandText: string): Q.Promise; + getTiles(): Q.Promise; } export class CreateBlade extends Blade { @@ -95,6 +96,15 @@ declare module MsPortalTestFx { export class SpecPickerBlade extends Blade { pickSpec(specCode: string): Q.Promise; } + + export class QuickStartBlade extends Blade { + constructor(); + clickLink(linkText: string): Q.Promise; + } + + export class UsersBlade extends Blade { + constructor(); + } } export module Controls { @@ -127,12 +137,17 @@ declare module MsPortalTestFx { export class TextField extends FormElement { constructor(parentLocator?: Locators.Locator, label?: string, baseLocator?: Locators.Locator); - sendKeys(...var_args: string[]): Q.Promise; + sendKeys(...var_args: string[]): Q.Promise; } export class ResourceFilterTextField extends TextField { constructor(parentLocator?: Locators.Locator); } + + export class HotSpot extends PortalElement { + constructor(parentLocator?: Locators.Locator, baseLocator?: Locators.Locator); + isSelected(): Q.Promise; + } } export module Parts { @@ -143,6 +158,8 @@ declare module MsPortalTestFx { isSelected(): Q.Promise; isLoaded(): Q.Promise; waitUntilLoaded(timeout?: number): Q.Promise; + isClickable(): Q.Promise; + hasError(): Q.Promise; } export class PartProperty extends MsPortalTestFx.PortalElement { @@ -155,6 +172,8 @@ declare module MsPortalTestFx { export class ResourceSummaryPart extends Part { public properties: Array; public resourceGroupProperty: PartProperty; + public quickStartHotSpot: Controls.HotSpot; + public accessHotSpot: Controls.HotSpot; constructor(parentLocator?: Locators.Locator); } @@ -166,17 +185,57 @@ declare module MsPortalTestFx { public progressLocator: Locators.Locator; constructor(parentLocator?: Locators.Locator); + tryPin(): Q.Promise; + getPart(): Part; + waitUntilLoaded(timeout?: number): Q.Promise; + } + } + + export module Commands { + export class ContextMenu extends PortalElement { + constructor(); + public hasItem(text: string): Q.Promise; + public clickItem(text: string): Q.Promise; + } + + export class ContextMenuItem extends PortalElement { + constructor(parentLocator: Locators.Locator, text?: string); + } + } + + export module Notifications { + export class Notification extends PortalElement { + constructor(); + getTitle(): Q.Promise; + getDescription(): Q.Promise; + } + + export class NotificationsMenu extends PortalElement { + constructor(); + waitForNewNotification(title?: string, description?: string, timeout?: number): Q.Promise; + } + } + + export module Tests { + export module Parts { + export function canPinAllBladeParts(targetBladeDeepLink: string, targetBladeTitle: string, timeout?: number): Q.Promise; } } export class PortalElement { - protected baseLocator: Locators.Locator; + public baseLocator: Locators.Locator; protected parentLocator: Locators.Locator; constructor(baseLocator: Locators.Locator, parentLocator?: Locators.Locator); - getLocator(): Locators.Locator; click(): Q.Promise; + rightClick(): Q.Promise; getAttribute(attributeName: string): Q.Promise; + sendKeys(...var_args: string[]): Q.Promise; + getText(): Q.Promise; + isPresent(): Q.Promise; + isElementPresent(subLocator: Locators.Locator): Q.Promise; + isDisplayed(): Q.Promise; + getLocator(): Locators.Locator; } export interface TestExtension { @@ -216,23 +275,23 @@ declare module MsPortalTestFx { export class Portal { portalContext: PortalContext; - click(locator: Locators.Locator): Q.Promise; - sendKeys(locator: Locators.Locator, ...var_args: string[]): Q.Promise - getText(locator: Locators.Locator): Q.Promise; + + goHome(timeout?: number): Q.Promise; openGalleryCreateBlade(galleryPackageName: string, bladeTitle: string, timeout?: number): Q.Promise; openBrowseBlade(resourceProvider: string, resourceType: string, bladeTitle: string, timeout?: number): Q.Promise; openResourceBlade(resourceId: string, bladeTitle: string, timeout?: number): Q.Promise; navigateToDeepLink(deepLink: string, timeout?: number): Q.Promise; - getAttribute(locator: Locators.Locator, attributeName: string, timeout?: number): Q.Promise; + waitForElementVisible(locator: Locators.Locator, timeout?: number): Q.Promise; waitForElementNotVisible(locator: Locators.Locator, timeout?: number): Q.Promise; waitUntilElementContainsAttribute(locator: Locators.Locator, attributeName: string, attributeValue: string, timeout?: number): Q.Promise; waitUntilElementDoesNotContainAttribute(locator: Locators.Locator, attributeName: string, attributeValue: string, timeout?: number): Q.Promise; waitForElementLocated(locator: Locators.Locator, timeout?: number): Q.Promise; + waitForElementsLocated(locator: Locators.Locator, timeout?: number): Q.Promise; takeScreenshot(filePrefix?: string): Q.Promise; - goHome(timeout?: number): Q.Promise; getBrowserLogs(level: LogLevel): Q.Promise; - applyFeature(name: string, value: string): void; executeScript(script: string): Q.Promise; + applyFeature(name: string, value: string): void; + getCurrentUrl(): Q.Promise; quit(): Q.Promise; } @@ -240,6 +299,11 @@ declare module MsPortalTestFx { clickUntrustedExtensionsOkButton(): Q.Promise; } + export class StartBoard extends PortalElement { + constructor(); + getTiles(): Q.Promise; + } + export var portal: Portal; } From a3d29f3201ac679da1af8c618ecf105f363f7174 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Sat, 3 Oct 2015 05:56:12 +0500 Subject: [PATCH 59/64] lodash: changed _.remove() method --- lodash/lodash-tests.ts | 39 +++++++++-- lodash/lodash.d.ts | 145 ++++++++++++++++++++++++----------------- 2 files changed, 120 insertions(+), 64 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 1d5525300..a1f8ce973 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -411,10 +411,41 @@ result = <_.LoDashObjectWrapper<_.Dictionary>>_([['moe', 30], ['larry', 40] result = <_.Dictionary>_.object([['moe', 30], ['larry', 40]]); result = <_.LoDashObjectWrapper<_.Dictionary>>_([['moe', 30], ['larry', 40]]).object(); -result = _.remove([1, 2, 3, 4, 5, 6], function (num: number) { return num % 2 == 0; }); -result = _.remove(foodsOrganic, 'organic'); -result = _.remove(foodsType, { 'type': 'vegetable' }); -var typedResult: IFoodType[] = _.remove([ { name: 'apple' }, { name: 'orange' }], { name: 'orange' }); +// _.remove +module TestRemove { + let array: TResult[]; + let list: _.List; + let predicateFn: (value: TResult, index?: number, collection?: _.List) => boolean; + let result: TResult[]; + + result = _.remove(array); + result = _.remove(array, predicateFn); + result = _.remove(array, predicateFn, any); + result = _.remove(array, ''); + result = _.remove(array, '', any); + result = _.remove<{a: number}, TResult>(array, {a: 42}); + + result = _.remove(list); + result = _.remove(list, predicateFn); + result = _.remove(list, predicateFn, any); + result = _.remove(list, ''); + result = _.remove(list, '', any); + result = _.remove<{a: number}, TResult>(list, {a: 42}); + + result = _(array).remove().value(); + result = _(array).remove(predicateFn).value(); + result = _(array).remove(predicateFn, any).value(); + result = _(array).remove('').value(); + result = _(array).remove('', any).value(); + result = _(array).remove<{a: number}>({a: 42}).value(); + + result = _(list).remove().value(); + result = _(list).remove(predicateFn).value(); + result = _(list).remove(predicateFn, any).value(); + result = _(list).remove('').value(); + result = _(list).remove('', any).value(); + result = _(list).remove<{a: number}, TResult>({a: 42}).value(); +} // _.slice { diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 102811a16..176986a47 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -985,72 +985,97 @@ declare module _ { //_.remove interface LoDashStatic { /** - * Removes all elements from an array that the callback returns truey for and returns - * an array of removed elements. The callback is bound to thisArg and invoked with three - * arguments; (value, index, array). - * - * If a property name is provided for callback the created "_.pluck" style callback will - * return the property value of the given element. - * - * If an object is provided for callback the created "_.where" style callback will return - * true for elements that have the properties of the given object, else false. - * @param array The array to modify. - * @param callback The function called per iteration. - * @param thisArg The this binding of callback. - * @return A new array of removed elements. - **/ - remove( - array: Array, - callback?: ListIterator, - thisArg?: any): T[]; - - /** - * @see _.remove - **/ + * Removes all elements from array that predicate returns truthy for and returns an array of the removed + * elements. The predicate is bound to thisArg and invoked with three arguments: (value, index, array). + * + * If a property name is provided for predicate the created _.property style callback returns the property + * value of the given element. + * + * If a value is also provided for thisArg the created _.matchesProperty style callback returns true for + * elements that have a matching property value, else false. + * + * If an object is provided for predicate the created _.matches style callback returns true for elements that + * have the properties of the given object, else false. + * + * Note: Unlike _.filter, this method mutates array. + * + * @param array The array to modify. + * @param predicate The function invoked per iteration. + * @param thisArg The this binding of predicate. + * @return Returns the new array of removed elements. + */ remove( array: List, - callback?: ListIterator, - thisArg?: any): T[]; - - /** - * @see _.remove - * @param pluckValue _.pluck style callback - **/ - remove( - array: Array, - pluckValue?: string): T[]; - - /** - * @see _.remove - * @param pluckValue _.pluck style callback - **/ - remove( - array: List, - pluckValue?: string): T[]; - - /** - * @see _.remove - * @param whereValue _.where style callback - **/ - remove( - array: Array, - wherealue?: Dictionary): T[]; - - /** - * @see _.remove - * @param whereValue _.where style callback - **/ - remove( - array: List, - wherealue?: Dictionary): T[]; + predicate?: ListIterator, + thisArg?: any + ): T[]; /** * @see _.remove - * @param item The item to remove - **/ + */ remove( - array:Array, - item:T): T[]; + array: List, + predicate?: string, + thisArg?: any + ): T[]; + + /** + * @see _.remove + */ + remove( + array: List, + predicate?: W + ): T[]; + } + + interface LoDashArrayWrapper { + /** + * @see _.remove + */ + remove( + predicate?: ListIterator, + thisArg?: any + ): LoDashArrayWrapper; + + /** + * @see _.remove + */ + remove( + predicate?: string, + thisArg?: any + ): LoDashArrayWrapper; + + /** + * @see _.remove + */ + remove( + predicate?: W + ): LoDashArrayWrapper; + } + + interface LoDashObjectWrapper { + /** + * @see _.remove + */ + remove( + predicate?: ListIterator, + thisArg?: any + ): LoDashArrayWrapper; + + /** + * @see _.remove + */ + remove( + predicate?: string, + thisArg?: any + ): LoDashArrayWrapper; + + /** + * @see _.remove + */ + remove( + predicate?: W + ): LoDashArrayWrapper; } //_.rest From 0ad3e356528d68c10647248d56ab34a1de9e3b34 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Fri, 2 Oct 2015 21:15:06 +0500 Subject: [PATCH 60/64] lodash: changed _.findLastIndex() method --- lodash/lodash-tests.ts | 40 ++++++++++++-- lodash/lodash.d.ts | 117 ++++++++++++++++++++++++++++------------- 2 files changed, 114 insertions(+), 43 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 1d5525300..e032ca7e8 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -258,11 +258,41 @@ result = _.findIndex(['apple', 'banana', 'beet'], function (f) { result = _.findIndex(['apple', 'banana', 'beet'], 'apple'); result = _.findIndex([{ food: 'apple' }, { food: 'banana' }, { food: 'beet' }], { food: 'apple' }); -result = _.findLastIndex(['apple', 'banana', 'beet'], function (f: string) { - return /^b/.test(f); -}); -result = _.findLastIndex(['apple', 'banana', 'beet'], 'apple'); -result = _.findLastIndex([{ food: 'apple' }, { food: 'banana' }, { food: 'beet' }], { food: 'apple' }); +// _.findLastIndex +module TestFindLastIndex { + let array: TResult[]; + let list: _.List; + let predicateFn: (value: TResult, index?: number, collection?: _.List) => boolean; + let result: number; + + result = _.findLastIndex(array); + result = _.findLastIndex(array, predicateFn); + result = _.findLastIndex(array, predicateFn, any); + result = _.findLastIndex(array, ''); + result = _.findLastIndex(array, '', any); + result = _.findLastIndex<{a: number}, TResult>(array, {a: 42}); + + result = _.findLastIndex(list); + result = _.findLastIndex(list, predicateFn); + result = _.findLastIndex(list, predicateFn, any); + result = _.findLastIndex(list, ''); + result = _.findLastIndex(list, '', any); + result = _.findLastIndex<{a: number}, TResult>(list, {a: 42}); + + result = _(array).findLastIndex(); + result = _(array).findLastIndex(predicateFn); + result = _(array).findLastIndex(predicateFn, any); + result = _(array).findLastIndex(''); + result = _(array).findLastIndex('', any); + result = _(array).findLastIndex<{a: number}>({a: 42}); + + result = _(list).findLastIndex(); + result = _(list).findLastIndex(predicateFn); + result = _(list).findLastIndex(predicateFn, any); + result = _(list).findLastIndex(''); + result = _(list).findLastIndex('', any); + result = _(list).findLastIndex<{a: number}>({a: 42}); +} // _.first module TestFirst { diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 102811a16..83dc78c8d 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -510,53 +510,94 @@ declare module _ { //_.findLastIndex interface LoDashStatic { /** - * This method is like _.findIndex except that it iterates over elements of a collection from right to left. - * @param array The array to search. - * @param {(Function|Object|string)} callback The function called per iteration. If a property name or object is provided it will be - * used to create a ".pluck" or ".where" style callback, respectively. - * @param thisArg The this binding of callback. - * @return Returns the index of the found element, else -1. - **/ - findLastIndex( - array: Array, - callback: ListIterator, - thisArg?: any): number; - - /** - * @see _.findLastIndex - **/ + * This method is like _.findIndex except that it iterates over elements of collection from right to left. + * + * If a property name is provided for predicate the created _.property style callback returns the property + * value of the given element. + * + * If a value is also provided for thisArg the created _.matchesProperty style callback returns true for + * elements that have a matching property value, else false. + * + * If an object is provided for predicate the created _.matches style callback returns true for elements that + * have the properties of the given object, else false. + * + * @param array The array to search. + * @param predicate The function invoked per iteration. + * @param thisArg The function invoked per iteration. + * @return Returns the index of the found element, else -1. + */ findLastIndex( array: List, - callback: ListIterator, - thisArg?: any): number; + predicate?: ListIterator, + thisArg?: any + ): number; /** - * @see _.findLastIndex - **/ - findLastIndex( - array: Array, - pluckValue: string): number; - - /** - * @see _.findLastIndex - **/ + * @see _.findLastIndex + */ findLastIndex( array: List, - pluckValue: string): number; + predicate?: string, + thisArg?: any + ): number; /** - * @see _.findLastIndex - **/ - findLastIndex( - array: Array, - whereDictionary: Dictionary): number; - - /** - * @see _.findLastIndex - **/ - findLastIndex( + * @see _.findLastIndex + */ + findLastIndex( array: List, - whereDictionary: Dictionary): number; + predicate?: W + ): number; + } + + interface LoDashArrayWrapper { + /** + * @see _.findLastIndex + */ + findLastIndex( + predicate?: ListIterator, + thisArg?: any + ): number; + + /** + * @see _.findLastIndex + */ + findLastIndex( + predicate?: string, + thisArg?: any + ): number; + + /** + * @see _.findLastIndex + */ + findLastIndex( + predicate?: W + ): number; + } + + interface LoDashObjectWrapper { + /** + * @see _.findLastIndex + */ + findLastIndex( + predicate?: ListIterator, + thisArg?: any + ): number; + + /** + * @see _.findLastIndex + */ + findLastIndex( + predicate?: string, + thisArg?: any + ): number; + + /** + * @see _.findLastIndex + */ + findLastIndex( + predicate?: W + ): number; } //_.first From 57b587be31d4fc9fe1ba123021f098ea16191926 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Thu, 1 Oct 2015 04:03:32 +0500 Subject: [PATCH 61/64] lodash: changed _.findIndex() method --- lodash/lodash-tests.ts | 39 ++++++++++++-- lodash/lodash.d.ts | 117 ++++++++++++++++++++++++++++------------- 2 files changed, 113 insertions(+), 43 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 1d5525300..98b5eee8b 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -251,12 +251,41 @@ result = <_.List>_.fill(testFillList, 'a', 0, 3); result = _(testFillArray).fill(0, 0, 3).value(); result = <_.List>_(testFillList).fill(0, 0, 3).value(); +// _.findIndex +module TestFindIndex { + let array: TResult[]; + let list: _.List; + let predicateFn: (value: TResult, index?: number, collection?: _.List) => boolean; + let result: number; -result = _.findIndex(['apple', 'banana', 'beet'], function (f) { - return /^b/.test(f); -}); -result = _.findIndex(['apple', 'banana', 'beet'], 'apple'); -result = _.findIndex([{ food: 'apple' }, { food: 'banana' }, { food: 'beet' }], { food: 'apple' }); + result = _.findIndex(array); + result = _.findIndex(array, predicateFn); + result = _.findIndex(array, predicateFn, any); + result = _.findIndex(array, ''); + result = _.findIndex(array, '', any); + result = _.findIndex<{a: number}, TResult>(array, {a: 42}); + + result = _.findIndex(list); + result = _.findIndex(list, predicateFn); + result = _.findIndex(list, predicateFn, any); + result = _.findIndex(list, ''); + result = _.findIndex(list, '', any); + result = _.findIndex<{a: number}, TResult>(list, {a: 42}); + + result = _(array).findIndex(); + result = _(array).findIndex(predicateFn); + result = _(array).findIndex(predicateFn, any); + result = _(array).findIndex(''); + result = _(array).findIndex('', any); + result = _(array).findIndex<{a: number}>({a: 42}); + + result = _(list).findIndex(); + result = _(list).findIndex(predicateFn); + result = _(list).findIndex(predicateFn, any); + result = _(list).findIndex(''); + result = _(list).findIndex('', any); + result = _(list).findIndex<{a: number}>({a: 42}); +} result = _.findLastIndex(['apple', 'banana', 'beet'], function (f: string) { return /^b/.test(f); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 102811a16..e50b3ffe6 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -457,54 +457,95 @@ declare module _ { //_.findIndex interface LoDashStatic { /** - * This method is like _.find except that it returns the index of the first element that passes - * the callback check, instead of the element itself. - * @param array The array to search. - * @param {(Function|Object|string)} callback The function called per iteration. If a property name or object is provided it will be - * used to create a ".pluck" or ".where" style callback, respectively. - * @param thisArg The this binding of callback. - * @return Returns the index of the found element, else -1. - **/ - findIndex( - array: Array, - callback: ListIterator, - thisArg?: any): number; - - /** - * @see _.findIndex - **/ + * This method is like _.find except that it returns the index of the first element predicate returns truthy + * for instead of the element itself. + * + * If a property name is provided for predicate the created _.property style callback returns the property + * value of the given element. + * + * If a value is also provided for thisArg the created _.matchesProperty style callback returns true for + * elements that have a matching property value, else false. + * + * If an object is provided for predicate the created _.matches style callback returns true for elements that + * have the properties of the given object, else false. + * + * @param array The array to search. + * @param predicate The function invoked per iteration. + * @param thisArg The this binding of predicate. + * @return Returns the index of the found element, else -1. + */ findIndex( array: List, - callback: ListIterator, - thisArg?: any): number; + predicate?: ListIterator, + thisArg?: any + ): number; /** - * @see _.findIndex - **/ - findIndex( - array: Array, - pluckValue: string): number; - - /** - * @see _.findIndex - **/ + * @see _.findIndex + */ findIndex( array: List, - pluckValue: string): number; + predicate?: string, + thisArg?: any + ): number; /** - * @see _.findIndex - **/ - findIndex( - array: Array, - whereDictionary: W): number; - - /** - * @see _.findIndex - **/ + * @see _.findIndex + */ findIndex( array: List, - whereDictionary: W): number; + predicate?: W + ): number; + } + + interface LoDashArrayWrapper { + /** + * @see _.findIndex + */ + findIndex( + predicate?: ListIterator, + thisArg?: any + ): number; + + /** + * @see _.findIndex + */ + findIndex( + predicate?: string, + thisArg?: any + ): number; + + /** + * @see _.findIndex + */ + findIndex( + predicate?: W + ): number; + } + + interface LoDashObjectWrapper { + /** + * @see _.findIndex + */ + findIndex( + predicate?: ListIterator, + thisArg?: any + ): number; + + /** + * @see _.findIndex + */ + findIndex( + predicate?: string, + thisArg?: any + ): number; + + /** + * @see _.findIndex + */ + findIndex( + predicate?: W + ): number; } //_.findLastIndex From c84d19d4ad54cc3422f2c304a391d6bcc18dd998 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Wed, 30 Sep 2015 21:25:51 +0500 Subject: [PATCH 62/64] lodash: changed _.compact() method --- lodash/lodash-tests.ts | 14 ++++++++++++-- lodash/lodash.d.ts | 27 +++++++++++++++------------ 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 1d5525300..bdab83269 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -174,8 +174,18 @@ module TestChunk { result = _(list).chunk(42).value(); } -result = _.compact([0, 1, false, 2, '', 3]); -result = <_.LoDashArrayWrapper>_([0, 1, false, 2, '', 3]).compact(); +// _.compact +module TestCompact { + let array: TResult[]; + let list: _.List; + let result: TResult[]; + + result = _.compact(); + result = _.compact(array); + result = _.compact(list); + result = _(array).compact().value(); + result = _(list).compact().value(); +} // _.difference { diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 102811a16..c93152e75 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -349,26 +349,29 @@ declare module _ { //_.compact interface LoDashStatic { /** - * Returns a copy of the array with all falsy values removed. In JavaScript, false, null, 0, "", - * undefined and NaN are all falsy. - * @param array Array to compact. - * @return (Array) Returns a new array of filtered values. - **/ - compact(array?: Array): T[]; - - /** - * @see _.compact - **/ + * Creates an array with all falsey values removed. The values false, null, 0, "", undefined, and NaN are + * falsey. + * + * @param array The array to compact. + * @return (Array) Returns the new array of filtered values. + */ compact(array?: List): T[]; } interface LoDashArrayWrapper { /** - * @see _.compact - **/ + * @see _.compact + */ compact(): LoDashArrayWrapper; } + interface LoDashObjectWrapper { + /** + * @see _.compact + */ + compact(): LoDashArrayWrapper; + } + //_.difference interface LoDashStatic { /** From 80ff55a5b89dd62824d97a9cfb6e82545224ea0c Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Sun, 4 Oct 2015 04:49:09 +0500 Subject: [PATCH 63/64] lodash: changed _.every() method (and alias _.all()) --- lodash/lodash-tests.ts | 100 +++++++++++++- lodash/lodash.d.ts | 306 +++++++++++++++++++++++------------------ 2 files changed, 263 insertions(+), 143 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 1d5525300..8bbfa68e0 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -650,6 +650,54 @@ result = _([1, 2]).zipWith([1, 2], [1, 2], [1, 2], [1, 2], [1, * Collection * **************/ +// _.all +module TestAll { + let array: TResult[]; + let list: _.List; + let dictionary: _.Dictionary; + + let listIterator: (value: TResult, index: number, collection: _.List) => boolean; + let dictionaryIterator: (value: TResult, key: string, collection: _.Dictionary) => boolean; + + let result: boolean; + + result = _.all(array); + result = _.all(array, listIterator); + result = _.all(array, listIterator, any); + result = _.all(array, ''); + result = _.all<{a: number}, TResult>(array, {a: 42}); + + result = _.all(list); + result = _.all(list, listIterator); + result = _.all(list, listIterator, any); + result = _.all(list, ''); + result = _.all<{a: number}, TResult>(list, {a: 42}); + + result = _.all(dictionary); + result = _.all(dictionary, dictionaryIterator); + result = _.all(dictionary, dictionaryIterator, any); + result = _.all(dictionary, ''); + result = _.all<{a: number}, TResult>(dictionary, {a: 42}); + + result = _(array).all(); + result = _(array).all(listIterator); + result = _(array).all(listIterator, any); + result = _(array).all(''); + result = _(array).all<{a: number}>({a: 42}); + + result = _(list).all(); + result = _(list).all(listIterator); + result = _(list).all(listIterator, any); + result = _(list).all(''); + result = _(list).all<{a: number}>({a: 42}); + + result = _(dictionary).all(); + result = _(dictionary).all(dictionaryIterator); + result = _(dictionary).all(dictionaryIterator, any); + result = _(dictionary).all(''); + result = _(dictionary).all<{a: number}>({a: 42}); +} + // _.at { let testAtArray: TResult[]; @@ -747,13 +795,53 @@ result = <_.LoDashObjectWrapper<_.Dictionary>>_([4.3, 6.1, 6.4]).countBy result = <_.LoDashObjectWrapper<_.Dictionary>>_([4.3, 6.1, 6.4]).countBy(function (num) { return this.floor(num); }, Math); result = <_.LoDashObjectWrapper<_.Dictionary>>_(['one', 'two', 'three']).countBy('length'); -result = _.every([true, 1, null, 'yes'], Boolean); -result = _.every(stoogesAges, 'age'); -result = _.every(stoogesAges, { 'age': 50 }); +// _.every +module TestEvery { + let array: TResult[]; + let list: _.List; + let dictionary: _.Dictionary; -result = _.all([true, 1, null, 'yes'], Boolean); -result = _.all(stoogesAges, 'age'); -result = _.all(stoogesAges, { 'age': 50 }); + let listIterator: (value: TResult, index: number, collection: _.List) => boolean; + let dictionaryIterator: (value: TResult, key: string, collection: _.Dictionary) => boolean; + + let result: boolean; + + result = _.every(array); + result = _.every(array, listIterator); + result = _.every(array, listIterator, any); + result = _.every(array, ''); + result = _.every<{a: number}, TResult>(array, {a: 42}); + + result = _.every(list); + result = _.every(list, listIterator); + result = _.every(list, listIterator, any); + result = _.every(list, ''); + result = _.every<{a: number}, TResult>(list, {a: 42}); + + result = _.every(dictionary); + result = _.every(dictionary, dictionaryIterator); + result = _.every(dictionary, dictionaryIterator, any); + result = _.every(dictionary, ''); + result = _.every<{a: number}, TResult>(dictionary, {a: 42}); + + result = _(array).every(); + result = _(array).every(listIterator); + result = _(array).every(listIterator, any); + result = _(array).every(''); + result = _(array).every<{a: number}>({a: 42}); + + result = _(list).every(); + result = _(list).every(listIterator); + result = _(list).every(listIterator, any); + result = _(list).every(''); + result = _(list).every<{a: number}>({a: 42}); + + result = _(dictionary).every(); + result = _(dictionary).every(dictionaryIterator); + result = _(dictionary).every(dictionaryIterator, any); + result = _(dictionary).every(''); + result = _(dictionary).every<{a: number}>({a: 42}); +} result = _.filter([1, 2, 3, 4, 5, 6]); result = _.filter([1, 2, 3, 4, 5, 6], function (num) { return num % 2 == 0; }); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 102811a16..19667ba4a 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -2004,6 +2004,94 @@ declare module _ { * Collection * **************/ + //_.all + interface LoDashStatic { + /** + * @see _.every + */ + all( + collection: List, + predicate?: ListIterator, + thisArg?: any + ): boolean; + + /** + * @see _.every + */ + all( + collection: Dictionary, + predicate?: DictionaryIterator, + thisArg?: any + ): boolean; + + /** + * @see _.every + */ + all( + collection: List|Dictionary, + predicate?: string, + thisArg?: any + ): boolean; + + /** + * @see _.every + */ + all( + collection: List|Dictionary, + predicate?: TObject + ): boolean; + } + + interface LoDashArrayWrapper { + /** + * @see _.every + */ + all( + predicate?: ListIterator, + thisArg?: any + ): boolean; + + /** + * @see _.every + */ + all( + predicate?: string, + thisArg?: any + ): boolean; + + /** + * @see _.every + */ + all( + predicate?: TObject + ): boolean; + } + + interface LoDashObjectWrapper { + /** + * @see _.every + */ + all( + predicate?: ListIterator|DictionaryIterator, + thisArg?: any + ): boolean; + + /** + * @see _.every + */ + all( + predicate?: string, + thisArg?: any + ): boolean; + + /** + * @see _.every + */ + all( + predicate?: TObject + ): boolean; + } + //_.at interface LoDashStatic { /** @@ -2383,162 +2471,106 @@ declare module _ { //_.every interface LoDashStatic { /** - * Checks if the given callback returns truey value for all elements of a collection. - * The callback is bound to thisArg and invoked with three arguments; (value, index|key, - * collection). - * - * If a property name is provided for callback the created "_.pluck" style callback will - * return the property value of the given element. - * - * If an object is provided for callback the created "_.where" style callback will return - * true for elements that have the properties of the given object, else false. - * @param collection The collection to iterate over. - * @param callback The function called per iteration. - * @param thisArg The this binding of callback. - * @return True if all elements passed the callback check, else false. - **/ - every( - collection: Array, - callback?: ListIterator, - thisArg?: any): boolean; - - /** - * @see _.every - * @param pluckValue _.pluck style callback - **/ + * Checks if predicate returns truthy for all elements of collection. The predicate is bound to thisArg and + * invoked with three arguments: (value, index|key, collection). + * + * If a property name is provided for predicate the created _.property style callback returns the property + * value of the given element. + * + * If a value is also provided for thisArg the created _.matchesProperty style callback returns true for + * elements that have a matching property value, else false. + * + * If an object is provided for predicate the created _.matches style callback returns true for elements that + * have the properties of the given object, else false. + * + * @alias _.all + * + * @param collection The collection to iterate over. + * @param predicate The function invoked per iteration. + * @param thisArg The this binding of predicate. + * @return Returns true if all elements pass the predicate check, else false. + */ every( collection: List, - callback?: ListIterator, - thisArg?: any): boolean; + predicate?: ListIterator, + thisArg?: any + ): boolean; /** - * @see _.every - * @param pluckValue _.pluck style callback - **/ + * @see _.every + */ every( collection: Dictionary, - callback?: DictionaryIterator, - thisArg?: any): boolean; + predicate?: DictionaryIterator, + thisArg?: any + ): boolean; /** - * @see _.every - * @param pluckValue _.pluck style callback - **/ + * @see _.every + */ every( - collection: Array, - pluckValue: string): boolean; + collection: List|Dictionary, + predicate?: string, + thisArg?: any + ): boolean; /** - * @see _.every - * @param pluckValue _.pluck style callback - **/ - every( - collection: List, - pluckValue: string): boolean; + * @see _.every + */ + every( + collection: List|Dictionary, + predicate?: TObject + ): boolean; + } + + interface LoDashArrayWrapper { + /** + * @see _.every + */ + every( + predicate?: ListIterator, + thisArg?: any + ): boolean; /** - * @see _.every - * @param pluckValue _.pluck style callback - **/ - every( - collection: Dictionary, - pluckValue: string): boolean; + * @see _.every + */ + every( + predicate?: string, + thisArg?: any + ): boolean; /** - * @see _.every - * @param whereValue _.where style callback - **/ - every( - collection: Array, - whereValue: W): boolean; + * @see _.every + */ + every( + predicate?: TObject + ): boolean; + } + + interface LoDashObjectWrapper { + /** + * @see _.every + */ + every( + predicate?: ListIterator|DictionaryIterator, + thisArg?: any + ): boolean; /** - * @see _.every - * @param whereValue _.where style callback - **/ - every( - collection: List, - whereValue: W): boolean; + * @see _.every + */ + every( + predicate?: string, + thisArg?: any + ): boolean; /** - * @see _.every - * @param whereValue _.where style callback - **/ - every( - collection: Dictionary, - whereValue: W): boolean; - - /** - * @see _.every - **/ - all( - collection: Array, - callback?: ListIterator, - thisArg?: any): boolean; - - /** - * @see _.every - **/ - all( - collection: List, - callback?: ListIterator, - thisArg?: any): boolean; - - /** - * @see _.every - **/ - all( - collection: Dictionary, - callback?: DictionaryIterator, - thisArg?: any): boolean; - - /** - * @see _.every - * @param pluckValue _.pluck style callback - **/ - all( - collection: Array, - pluckValue: string): boolean; - - /** - * @see _.every - * @param pluckValue _.pluck style callback - **/ - all( - collection: List, - pluckValue: string): boolean; - - /** - * @see _.every - * @param pluckValue _.pluck style callback - **/ - all( - collection: Dictionary, - pluckValue: string): boolean; - - /** - * @see _.every - * @param whereValue _.where style callback - **/ - all( - collection: Array, - whereValue: W): boolean; - - /** - * @see _.every - * @param whereValue _.where style callback - **/ - all( - collection: List, - whereValue: W): boolean; - - /** - * @see _.every - * @param whereValue _.where style callback - **/ - all( - collection: Dictionary, - whereValue: W): boolean; + * @see _.every + */ + every( + predicate?: TObject + ): boolean; } //_.fill From 21572bf9a7a2c3691296f15767bd2933f9415479 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Mon, 5 Oct 2015 05:54:55 +0500 Subject: [PATCH 64/64] lodash: changed _.lastIndexOf() method --- lodash/lodash-tests.ts | 25 +++++++++++++++++++++-- lodash/lodash.d.ts | 46 ++++++++++++++++++++++++++---------------- 2 files changed, 52 insertions(+), 19 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 1d5525300..1e05faf55 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -348,8 +348,29 @@ result = _.indexOf([1, 1, 2, 2, 3, 3], 2, true); result = _.last([1, 2, 3]); result = _([1, 2, 3]).last(); -result = _.lastIndexOf([1, 2, 3, 1, 2, 3], 2); -result = _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); +// _.lastIndexOf +module TestLastIndexOf { + let array: TResult[]; + let list: _.List; + let value: TResult; + let result: number; + + result = _.lastIndexOf(array, value); + result = _.lastIndexOf(array, value, true); + result = _.lastIndexOf(array, value, 42); + + result = _.lastIndexOf(list, value); + result = _.lastIndexOf(list, value, true); + result = _.lastIndexOf(list, value, 42); + + result = _(array).lastIndexOf(value); + result = _(array).lastIndexOf(value, true); + result = _(array).lastIndexOf(value, 42); + + result = _(list).lastIndexOf(value); + result = _(list).lastIndexOf(value, true); + result = _(list).lastIndexOf(value, 42); +} // _.pull { diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 102811a16..15c8e971b 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -889,26 +889,38 @@ declare module _ { //_.lastIndexOf interface LoDashStatic { /** - * Gets the index at which the last occurrence of value is found using strict equality - * for comparisons, i.e. ===. If fromIndex is negative, it is used as the offset from the - * end of the collection. - * @param array The array to search. - * @param value The value to search for. - * @param fromIndex The index to search from. - * @return The index of the matched value or -1. - **/ - lastIndexOf( - array: Array, - value: T, - fromIndex?: number): number; - - /** - * @see _.lastIndexOf - **/ + * This method is like _.indexOf except that it iterates over elements of array from right to left. + * + * @param array The array to search. + * @param value The value to search for. + * @param fromIndex The index to search from or true to perform a binary search on a sorted array. + * @return Returns the index of the matched value, else -1. + */ lastIndexOf( array: List, value: T, - fromIndex?: number): number; + fromIndex?: boolean|number + ): number; + } + + interface LoDashArrayWrapper { + /** + * @see _.lastIndexOf + */ + lastIndexOf( + value: T, + fromIndex?: boolean|number + ): number; + } + + interface LoDashObjectWrapper { + /** + * @see _.lastIndexOf + */ + lastIndexOf( + value: TResult, + fromIndex?: boolean|number + ): number; } //_.pull