From 90fe3e51ea05b90acd58cd65ccc17dd578771b65 Mon Sep 17 00:00:00 2001 From: Javier Date: Tue, 21 Apr 2015 11:14:03 -0700 Subject: [PATCH 0001/1238] PlayerOptions width and height should be strings, adds Player.destroy() Per https://developers.google.com/youtube/iframe_api_reference PlayerOptions can be other than numbers, in fact in the API reference are created as strings even though they are specified as numbers: '100%' works. Also adds the Player.destroy() method, which removes the iframe from the DOM. --- youtube/youtube.d.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/youtube/youtube.d.ts b/youtube/youtube.d.ts index 85f96b22f8..42262f452c 100644 --- a/youtube/youtube.d.ts +++ b/youtube/youtube.d.ts @@ -50,8 +50,8 @@ declare module YT { } export interface PlayerOptions { - width?: number; - height?: number; + width?: string; + height?: string; videoId?: string; playerVars?: PlayerVars; events?: Events; @@ -147,6 +147,9 @@ declare module YT { // Event Listener addEventListener(event: string, handler: EventHandler): void; + + // DOM + destroy(): void; } export enum PlayerState { From eaf505ec376a948681f7bae7d3557f793b9787cb Mon Sep 17 00:00:00 2001 From: Dustin Wehr Date: Mon, 15 Jun 2015 13:35:40 -0400 Subject: [PATCH 0002/1238] type defs for debug() and newInMemoryDocument() --- .../google-drive-realtime-api.d.ts | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/google-drive-realtime-api/google-drive-realtime-api.d.ts b/google-drive-realtime-api/google-drive-realtime-api.d.ts index 95f239a349..8d549355db 100644 --- a/google-drive-realtime-api/google-drive-realtime-api.d.ts +++ b/google-drive-realtime-api/google-drive-realtime-api.d.ts @@ -483,6 +483,36 @@ declare module gapi.drive.realtime { saveAs(fileId:string) : void; } + + // INCOMPLETE + // https://developers.google.com/google-apps/realtime/reference/gapi.drive.realtime.Error + export class Error { } + + // Complete + // Opens the debugger application on the current page. The debugger shows all realtime documents that the + // page has loaded and is able to view, edit and debug all aspects of each realtime document. + export function debug() : void; + + /* Creates a new file with fake network communications. This file will not talk to the server and will only + exist in memory for as long as the browser session persists. + https://developers.google.com/google-apps/realtime/reference/gapi.drive.realtime#.newInMemoryDocument + @Param opt_onLoaded {function(non-null gapi.drive.realtime.Document)} + A callback that will be called when the realtime document is ready. The created or opened realtime document + object will be passed to this function. + + @Param opt_initializerFn {function(non-null gapi.drive.realtime.Model)} + An optional initialization function that will be called before onLoaded only the first time that the document + is loaded. The document's gapi.drive.realtime.Model object will be passed to this function. + + @Param opt_errorFn {function(non-null gapi.drive.realtime.Error)} + An optional error handling function that will be called if an error occurs while the document is being + loaded or edited. A gapi.drive.realtime.Error object describing the error will be passed to this function. + */ + export function newInMemoryDocument( + opt_onLoaded? : (d:Document) => void, + opt_initializerFn? : (m:Model) => void, + opt_errorFn? : (e:gapi.drive.realtime.Error) => void + ) : Document; } From 1c4dd1d54fa50115c605b514d13fc083ef130a1c Mon Sep 17 00:00:00 2001 From: Maxime Fabre Date: Fri, 24 Jul 2015 11:43:24 +0200 Subject: [PATCH 0003/1238] Add introjs definition --- introjs/introjs-tests.ts | 54 +++++++++++++++++++++++++++++++ introjs/introjs.d.ts | 70 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 124 insertions(+) create mode 100644 introjs/introjs-tests.ts create mode 100644 introjs/introjs.d.ts diff --git a/introjs/introjs-tests.ts b/introjs/introjs-tests.ts new file mode 100644 index 0000000000..151222d47d --- /dev/null +++ b/introjs/introjs-tests.ts @@ -0,0 +1,54 @@ +/// + +var intro = introJs(); + +intro.setOption('doneLabel', 'Next page'); +intro.setOptions({ + steps: [ + { + intro: "Hello world!" + }, + { + element: document.querySelector('#step1'), + intro : "This is a tooltip." + }, + { + element : document.querySelectorAll('#step2')[0], + intro : "Ok, wasn't that fun?", + position: 'right' + }, + { + element : '#step3', + intro : 'More features, more fun.', + position: 'left' + }, + { + element : '#step4', + intro : "Another step.", + position: 'bottom' + }, + { + element: '#step5', + intro : 'Get it, use it.' + } + ] +}); + +intro.start() + .nextStep() + .previousStep() + .goToStep(2) + .exit() + .refresh() + .onbeforechange(function (element) { + element.getAttribute('class'); + }) + .onafterchange(function (element) { + element.getAttribute('class'); + }) + .onchange(function () { + alert('Changed'); + }) + .oncomplete(function () { + alert('Done'); + }); diff --git a/introjs/introjs.d.ts b/introjs/introjs.d.ts new file mode 100644 index 0000000000..f74733c5e3 --- /dev/null +++ b/introjs/introjs.d.ts @@ -0,0 +1,70 @@ +// Type definitions for intro.js +// Project: https://github.com/usablica/intro.js +// Definitions by: Maxime Fabre +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module IntroJs { + enum Positions { + top, + left, + right, + bottom + } + + interface Step { + intro: string; + element?: string|HTMLElement; + position?: Positions; + } + + interface Options { + nextLabel?: string; + prevLabel?: string; + skipLabel?: string; + doneLabel?: string; + tooltipPosition?: string; + tooltipClass?: string; + highlightClass?: string; + exitOnEsc?: boolean; + exitOnOverlayClick?: boolean; + showStepNumbers?: boolean; + keyboardNavigation?: boolean; + showButtons?: boolean; + showBullets?: boolean; + showProgress?: boolean; + scrollToElement?: boolean; + overlayOpacity?: number; + positionPrecedence?: string[]; + disableInteraction?: boolean; + steps: Step[]; + } + + interface IntroJs { + start(): IntroJs; + exit(): IntroJs; + + goToStep(step: number): IntroJs; + nextStep(): IntroJs; + previousStep(): IntroJs; + + refresh(): IntroJs; + + setOption(option: string, value: string|number): IntroJs; + setOptions(options: Options): IntroJs; + + onexit(callback: Function): IntroJs; + onbeforechange(callback: (element: HTMLElement) => any): IntroJs; + onafterchange(callback: (element: HTMLElement) => any): IntroJs; + onchange(callback: Function): IntroJs; + oncomplete(callback: Function): IntroJs; + } + + interface Factory { + (element?: string): IntroJs; + } +} + +declare var introJs: IntroJs.Factory; +declare module 'intro.js' { + export = IntroJs; +} From 1890b86fee132877a507bdae615d37c044bc88c4 Mon Sep 17 00:00:00 2001 From: Maxime Fabre Date: Fri, 24 Jul 2015 13:40:06 +0200 Subject: [PATCH 0004/1238] Add version to header --- introjs/introjs.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/introjs/introjs.d.ts b/introjs/introjs.d.ts index f74733c5e3..d54a5456ef 100644 --- a/introjs/introjs.d.ts +++ b/introjs/introjs.d.ts @@ -1,4 +1,4 @@ -// Type definitions for intro.js +// Type definitions for intro.js 1.0.0 // Project: https://github.com/usablica/intro.js // Definitions by: Maxime Fabre // Definitions: https://github.com/borisyankov/DefinitelyTyped From c1e7392f397fa3901d3b67cedf711058bcb2d698 Mon Sep 17 00:00:00 2001 From: Maxime Fabre Date: Tue, 28 Jul 2015 17:16:35 +0200 Subject: [PATCH 0005/1238] Rename files --- introjs/introjs-tests.ts => intro.js/intro.js-tests.ts | 0 introjs/introjs.d.ts => intro.js/intro.js.d.ts | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename introjs/introjs-tests.ts => intro.js/intro.js-tests.ts (100%) rename introjs/introjs.d.ts => intro.js/intro.js.d.ts (100%) diff --git a/introjs/introjs-tests.ts b/intro.js/intro.js-tests.ts similarity index 100% rename from introjs/introjs-tests.ts rename to intro.js/intro.js-tests.ts diff --git a/introjs/introjs.d.ts b/intro.js/intro.js.d.ts similarity index 100% rename from introjs/introjs.d.ts rename to intro.js/intro.js.d.ts From 733c28850d96ddeb6cf181be1d5c0006d3ffc589 Mon Sep 17 00:00:00 2001 From: Maxime Fabre Date: Thu, 6 Aug 2015 10:11:40 +0200 Subject: [PATCH 0006/1238] Fix reference in test --- intro.js/intro.js-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intro.js/intro.js-tests.ts b/intro.js/intro.js-tests.ts index 151222d47d..b49eb5078e 100644 --- a/intro.js/intro.js-tests.ts +++ b/intro.js/intro.js-tests.ts @@ -1,4 +1,4 @@ -/// +/// var intro = introJs(); From 6a02cedcf0a68b7d46c45f588427a6a4965f4ba4 Mon Sep 17 00:00:00 2001 From: Alvaro Dias Date: Sun, 13 Sep 2015 04:49:18 -0700 Subject: [PATCH 0007/1238] Add bundles, skipDataMain and onNodeCreated --- requirejs/require.d.ts | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/requirejs/require.d.ts b/requirejs/require.d.ts index 58fb4f6f12..113ead6356 100644 --- a/requirejs/require.d.ts +++ b/requirejs/require.d.ts @@ -1,4 +1,4 @@ -// Type definitions for RequireJS 2.1.8 +// Type definitions for RequireJS 2.1.20 // Project: http://requirejs.org/ // Definitions by: Josh Baldwin // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -88,6 +88,10 @@ interface RequireConfig { // baseUrl. paths?: { [key: string]: any; }; + // Allows configuring multiple module IDs to be found in + // another script. + bundles?: { [key: string]: any; }; + // Dictionary of Shim's. // does not cover case of key->string[] shim?: { [key: string]: RequireShim; }; @@ -182,6 +186,20 @@ interface RequireConfig { **/ scriptType?: string; + /** + * If set to true, skips the data-main attribute scanning done + * to start module loading. Useful if RequireJS is embedded in + * a utility library that may interact with other RequireJS + * library on the page, and the embedded version should not do + * data-main loading. + **/ + skipDataMain?: boolean; + + /** + * Allow extending requirejs to support Subresource Integrity + * (SRI). + **/ + onNodeCreated?: (node: HTMLScriptElement, config: RequireConfig, moduleName: string, url: string) => void; } // todo: not sure what to do with this guy From e4ff04e164e36ee9a9de52268be208f4a162c36e Mon Sep 17 00:00:00 2001 From: lgrignon Date: Mon, 14 Sep 2015 10:56:09 +0200 Subject: [PATCH 0008/1238] added polymer ts definition --- polymer-ts/polymer-ts.d.ts | 127 +++++++++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 polymer-ts/polymer-ts.d.ts diff --git a/polymer-ts/polymer-ts.d.ts b/polymer-ts/polymer-ts.d.ts new file mode 100644 index 0000000000..4f44de6d28 --- /dev/null +++ b/polymer-ts/polymer-ts.d.ts @@ -0,0 +1,127 @@ +declare module polymer { + class PolymerBase extends HTMLElement { + $: any; + $$: any; + root: HTMLElement; + shadyRoot: HTMLElement; + style: CSSStyleDeclaration; + customStyle: { + [property: string]: string; + }; + arrayDelete(path: string, item: string | any): any; + async(callback: Function, waitTime?: number): any; + attachedCallback(): void; + attributeFollows(name: string, toElement: HTMLElement, fromElement: HTMLElement): void; + cancelAsync(handle: number): void; + cancelDebouncer(jobName: string): void; + classFollows(name: string, toElement: HTMLElement, fromElement: HTMLElement): void; + create(tag: string, props: Object): any; + debounce(jobName: string, callback: Function, wait?: number): void; + deserialize(value: string, type: any): any; + distributeContent(): void; + domHost(): void; + elementMatches(selector: string, node: Element): any; + fire(type: string, detail?: Object, options?: FireOptions): any; + flushDebouncer(jobName: string): void; + get(path: string | Array): any; + getContentChildNodes(slctr: string): any; + getContentChildren(slctr: string): any; + getNativePrototype(tag: string): any; + getPropertyInfo(property: string): any; + importHref(href: string, onload?: Function, onerror?: Function): any; + instanceTemplate(template: any): any; + isDebouncerActive(jobName: string): any; + linkPaths(to: string, from: string): void; + listen(node: Element, eventName: string, methodName: string): void; + mixin(target: Object, source: Object): void; + notifyPath(path: string, value: any, fromAbove?: any): void; + pop(path: string): any; + push(path: string, value: any): any; + reflectPropertyToAttribute(name: string): void; + resolveUrl(url: string): any; + scopeSubtree(container: Element, shouldObserve: boolean): void; + serialize(value: string): any; + serializeValueToAttribute(value: any, attribute: string, node: Element): void; + set(path: string, value: any, root?: Object): any; + setScrollDirection(direction: string, node: HTMLElement): void; + shift(path: string, value: any): any; + splice(path: string, start: number, deleteCount: number): any; + toggleAttribute(name: string, bool: boolean, node?: HTMLElement): void; + toggleClass(name: string, bool: boolean, node?: HTMLElement): void; + transform(transform: string, node?: HTMLElement): void; + translate3d(x: any, y: any, z: any, node?: HTMLElement): void; + unlinkPaths(path: string): void; + unshift(path: string, value: any): any; + updateStyles(): void; + } + interface dom { + (node: HTMLElement): HTMLElement; + (node: polymer.Base): HTMLElement; + flush(): any; + } + interface FireOptions { + node?: HTMLElement | polymer.Base; + bubbles?: boolean; + cancelable?: boolean; + } + interface Element { + properties?: Object; + listeners?: Object; + behaviors?: Object[]; + observers?: String[]; + factoryImpl?(...args: any[]): void; + ready?(): void; + created?(): void; + attached?(): void; + detached?(): void; + attributeChanged?(attrName: string, oldVal: any, newVal: any): void; + prototype?: Object; + } + interface PolymerTSElement { + $custom_cons?: FunctionConstructor; + $custom_cons_args?: any[]; + template?: string; + style?: string; + } + interface Property { + name?: string; + type?: any; + value?: any; + reflectToAttribute?: boolean; + readonly?: boolean; + notify?: boolean; + computed?: string; + observer?: string; + } + class Base extends polymer.PolymerBase implements polymer.Element { + static create(...args: any[]): T; + static register(): void; + is: string; + } + function createEs6PolymerBase(): void; + function prepareForRegistration(elementClass: Function): polymer.Element; + function createDomModule(definition: polymer.Element): void; + function createElement(element: new (...args: any[]) => T): new (...args: any[]) => T; + function createClass(element: new (...args: any[]) => T): new (...args: any[]) => T; + function isRegistered(element: polymer.Element): boolean; +} +declare var Polymer: { + (prototype: polymer.Element): FunctionConstructor; + Class(prototype: polymer.Element): Function; + dom: polymer.dom; + appendChild(node: HTMLElement): HTMLElement; + insertBefore(node: HTMLElement, beforeNode: HTMLElement): HTMLElement; + removeChild(node: HTMLElement): HTMLElement; + updateStyles(): void; + Base: any; +}; +declare function component(tagname: string, extendsTag?: string): (target: Function) => void; +declare function extend(tagname: string): (target: Function) => void; +declare function template(templateString: string): (target: Function) => void; +declare function style(styleString: string): (target: Function) => void; +declare function hostAttributes(attributes: Object): (target: Function) => void; +declare function property(ob?: polymer.Property): (target: polymer.Element, propertyKey: string) => void; +declare function computed(ob?: polymer.Property): (target: polymer.Element, computedFuncName: string) => void; +declare function listen(eventName: string): (target: polymer.Element, propertyKey: string) => void; +declare function behavior(behaviorObject: any): any; +declare function observe(observedProps: string): (target: polymer.Element, observerFuncName: string) => void; From ec3fd22445c7d10ee983baf056ca2215511a4ea9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81xel=20Costas=20Pena?= Date: Wed, 16 Sep 2015 17:05:54 +0200 Subject: [PATCH 0009/1238] Add simpleStorage type definitions. Add simpleStorage to CONTRIBUTORS.md. *NOTE file naming includes uppercase characters disregarding the Contribution guide Quality Criteria because of another different package named simplestorage already existing on npm.* --- CONTRIBUTORS.md | 1 + simpleStorage/simpleStorage.d.ts | 110 +++++++++++++++++++++++++++++++ 2 files changed, 111 insertions(+) create mode 100644 simpleStorage/simpleStorage.d.ts diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index d4a3000cbc..0b6c2f7145 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -1024,6 +1024,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](signature_pad/signature_pad.d.ts) [signature_pad](https://github.com/szimek/signature_pad) by [Abubaker Bashir](https://github.com/AbubakerB) * [:link:](simple-cw-node/simple-cw-node.d.ts) [simple-cw-node](https://github.com/astronaughts/simple-cw-node) by [vvakame](https://github.com/vvakame) * [:link:](jquery.simplemodal/jquery.simplemodal.d.ts) [SimpleModal](http://www.ericmmartin.com/projects/simplemodal) by [Friedrich von Never](https://github.com/ForNeVeR) +* [:link:](simpleStorage/simpleStorage.d.ts) [simpleStorage](https://github.com/andris9/simpleStorage) by [Áxel Costas Pena](https://github.com/axelcostaspena) * [:link:](sinon/sinon.d.ts) [Sinon](http://sinonjs.org) by [William Sears](https://github.com/mrbigdog2u) * [:link:](sinon-chai/sinon-chai.d.ts) [sinon-chai](https://github.com/domenic/sinon-chai) by [Kazi Manzur Rashid](https://github.com/kazimanzurrashid), [Jed Mao](https://github.com/jedmao) * [:link:](sinon-chrome/sinon-chrome.d.ts) [Sinon-Chrome](https://github.com/vitalets/sinon-chrome) by [Tim Perry](https://github.com/pimterry) diff --git a/simpleStorage/simpleStorage.d.ts b/simpleStorage/simpleStorage.d.ts new file mode 100644 index 0000000000..52c4f27eec --- /dev/null +++ b/simpleStorage/simpleStorage.d.ts @@ -0,0 +1,110 @@ +// Type definitions for simpleStorage v0.1.3 +// Project: https://github.com/andris9/simpleStorage +// Definitions by: Áxel Costas Pena +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module andris9_simpleStorage { + + /** + * {@link simpleStorage} API is a subset of {@link http://www.jstorage.info/|jStorage} with slight modifications, so for most cases it should work out of the box if you are converting from {@link http://www.jstorage.info/|jStorage}. Main difference is between return values - if an action failed because of an error (storage full, storage not available, invalid data used etc.), you get the error object as the return value. {@link http://www.jstorage.info/|jStorage} never indicated anything if an error occurred. + * @see https://github.com/andris9/simpleStorage#usage + */ + export interface SimpleStorage { + + version: string; + + /** + * Check if local storage can be used. + * Returns true if storage is available. + * @see https://github.com/andris9/simpleStorage#canuse + */ + canUse(): boolean; + + /** + * Store or update a value in local storage. + * Returns true if value was stored, false if value was not stored or {@link Error} object if value was not stored because of an error. + * @param key The key for the value. + * @param value Value to be stored (can be any JSONeable value). + * @param [options] Optional options object. + * @see https://github.com/andris9/simpleStorage#setkey-value-options + */ + set(key: string, value: any, options?: SetOptions): boolean|Error; + + /** + * Retrieve a value from local storage. + * Returns the value for a key or undefined if the key was not found. + * @param key The key to be retrieved. + * @see https://github.com/andris9/simpleStorage#getkey + */ + get(key: string): any; + + /** + * Removes a value from local storage. + * Returns true if the value was deleted, false if the value was not found or {@link Error} object if value was not deleted because of an error. + * @param key The key to be deleted. + * @see https://github.com/andris9/simpleStorage#deletekeykey + */ + deleteKey(key: string): boolean|Error; + + /** + * Set a millisecond timeout. When the timeout is reached, the key is removed automatically from local storage. + * Returns true if ttl was set, false if value was not found or {@link Error} object if ttl was not set because of an error. + * @param key The key to be updated. + * @param ttl Timeout in milliseconds. If the value is 0, timeout is cleared from the key. + * @see https://github.com/andris9/simpleStorage#setttlkey-ttl + */ + setTTL(key: string, ttl: number): boolean|Error; + + /** + * Retrieve remaining milliseconds for a key with TTL. + * Returns the finite number of remaining milliseconds, Infinity if TTL is not set for the selected key or false if the selected key does not exist or is expired. + * @param key The key to be checked. + * @see https://github.com/andris9/simpleStorage#getttlkey + */ + getTTL(key: string): number|boolean; + + /** + * Clear all values. + * Returns true if storage was flushed or {@link Error} object if storage was not flushed because of an error. + * @see https://github.com/andris9/simpleStorage#flush + */ + flush(): boolean|Error; + + /** + * Retrieve all used keys as an array. + * Returns an array of keys. + * @see https://github.com/andris9/simpleStorage#index + */ + index(): [string]|boolean; + + /** + * Get used storage in symbol count. + * @see https://github.com/andris9/simpleStorage#storagesize + */ + storageSize(): number; + } + + /** + * @see https://github.com/andris9/simpleStorage#setkey-value-options + */ + export interface SetOptions { + /** + * Sets the time-to-live (TTL) value in milliseconds for the given key/value. + */ + TTL?: number; + } + +} + +declare module "simpleStorage" { + export = simpleStorage; +} + +/** + * Cross-browser key-value store database to store data locally in the browser. + * {@link simpleStorage} is a fork of {@link http://www.jstorage.info/|jStorage} that only includes the minimal set of features. Basically it is a wrapper for native {@link JSON} + {@link WindowLocalStorage.localStorage|localStorage} with some TTL magic mixed in. + * The module has no dependencies, you can use it as a standalone script (introduces {@link simpleStorage} global) or as an AMD module. All modern browsers (including mobile) are supported, older browsers (IE7, Firefox 3) are not. + * {@link simpleStorage} is very small - about 1kB in size when minimized and gzipped. + * @see https://github.com/andris9/simpleStorage#simplestorage + */ +declare var simpleStorage:andris9_simpleStorage.SimpleStorage; From 2775004106418bd2eb92d8825aa02a893949d63f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81xel=20Costas=20Pena?= Date: Wed, 16 Sep 2015 17:06:25 +0200 Subject: [PATCH 0010/1238] Add simpleStorage tests. --- simpleStorage/simpleStorage-tests.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 simpleStorage/simpleStorage-tests.ts diff --git a/simpleStorage/simpleStorage-tests.ts b/simpleStorage/simpleStorage-tests.ts new file mode 100644 index 0000000000..9ffcd18534 --- /dev/null +++ b/simpleStorage/simpleStorage-tests.ts @@ -0,0 +1,17 @@ +/// + +var versionTest: string = simpleStorage.version; +var canUseTest: boolean = simpleStorage.canUse(); +var simpleStorageTest1: boolean|Error = simpleStorage.set("string", 7); +var simpleStorageTest2: boolean|Error = simpleStorage.set("string", 7, {}); +var simpleStorageTest3: boolean|Error = simpleStorage.set("string", 7, { TTL: 7 }); +var simpleStorageTest4: boolean|Error = simpleStorage.set("string", undefined); +var simpleStorageTest5: boolean|Error = simpleStorage.set("string", undefined, {}); +var simpleStorageTest6: boolean|Error = simpleStorage.set("string", undefined, { TTL: 7 }); +var getTest: any = simpleStorage.get("string"); +var deleteKeyTest: boolean|Error = simpleStorage.deleteKey("string"); +var setTTLTest: boolean|Error = simpleStorage.setTTL("string", 7); +var getTTLTest: number|boolean = simpleStorage.getTTL("string"); +var flushTest: boolean|Error = simpleStorage.flush(); +var indexTest: [string]|boolean = simpleStorage.index(); +var storageSizeTest: number = simpleStorage.storageSize(); From da0bddb559bd1dc599237a0fbc808d45bb71ad87 Mon Sep 17 00:00:00 2001 From: lgrignon Date: Fri, 18 Sep 2015 16:33:30 +0200 Subject: [PATCH 0011/1238] added backbone local storage def --- .../backbone.localStorage.d.ts | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 backbone.localStorage/backbone.localStorage.d.ts diff --git a/backbone.localStorage/backbone.localStorage.d.ts b/backbone.localStorage/backbone.localStorage.d.ts new file mode 100644 index 0000000000..b0a554828e --- /dev/null +++ b/backbone.localStorage/backbone.localStorage.d.ts @@ -0,0 +1,46 @@ + + +declare module Backbone { + interface Serializer { + serialize(item: any): any; + deserialize(data: any): any; + } + + declare class LocalStorage { + name: string; + serializer: Serializer; + records: string[]; + + constructor(name: string, serializer?: Serializer); + + save(); + + // Add a model, giving it a (hopefully)-unique GUID, if it doesn't already + // have an id of it's own. + create(model: any): any; + + // Update a model by replacing its copy in `this.data`. + update(model: any): any; + + // Retrieve a model from `this.data` by id. + find(model: any): any; + + // Return the array of all models currently in storage. + findAll(): any; + + // Delete a model from `this.data`, returning it. + destroy(model: T): T; + + localStorage(): any; + + // Clear localStorage for specific collection. + _clear(): void; + + _storageSize(): number; + + _itemName(id): string; + }; +} + +export Store = Backbone.LocalStorage; + From ea76cec95c4f1698cda13ae5f0393eb30dcbc178 Mon Sep 17 00:00:00 2001 From: lgrignon Date: Fri, 18 Sep 2015 16:40:41 +0200 Subject: [PATCH 0012/1238] wrong version committed --- backbone.localStorage/backbone.localStorage.d.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/backbone.localStorage/backbone.localStorage.d.ts b/backbone.localStorage/backbone.localStorage.d.ts index b0a554828e..e0af97e1d2 100644 --- a/backbone.localStorage/backbone.localStorage.d.ts +++ b/backbone.localStorage/backbone.localStorage.d.ts @@ -1,12 +1,11 @@ - declare module Backbone { interface Serializer { serialize(item: any): any; deserialize(data: any): any; } - declare class LocalStorage { + class LocalStorage { name: string; serializer: Serializer; records: string[]; @@ -39,8 +38,8 @@ declare module Backbone { _storageSize(): number; _itemName(id): string; - }; + } } -export Store = Backbone.LocalStorage; +import Store = Backbone.LocalStorage; From 581d094508cb40e4b571e2027142d5dd6134722e Mon Sep 17 00:00:00 2001 From: lgrignon Date: Fri, 18 Sep 2015 16:44:37 +0200 Subject: [PATCH 0013/1238] added def typed header comments --- backbone.localStorage/backbone.localStorage.d.ts | 6 ++++++ polymer-ts/polymer-ts.d.ts | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/backbone.localStorage/backbone.localStorage.d.ts b/backbone.localStorage/backbone.localStorage.d.ts index e0af97e1d2..5696fa3d9f 100644 --- a/backbone.localStorage/backbone.localStorage.d.ts +++ b/backbone.localStorage/backbone.localStorage.d.ts @@ -1,3 +1,9 @@ +// Type definitions for backbone.localStorage 1.0.0 +// Project: https://github.com/jeromegn/Backbone.localStorage +// Definitions by: Louis Grignon +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// declare module Backbone { interface Serializer { diff --git a/polymer-ts/polymer-ts.d.ts b/polymer-ts/polymer-ts.d.ts index 4f44de6d28..cd96dfe21a 100644 --- a/polymer-ts/polymer-ts.d.ts +++ b/polymer-ts/polymer-ts.d.ts @@ -1,3 +1,8 @@ +// Type definitions for PolymerTS 0.1.17 +// Project: https://github.com/nippur72/PolymerTS +// Definitions by: Louis Grignon +// Definitions: https://github.com/borisyankov/DefinitelyTyped + declare module polymer { class PolymerBase extends HTMLElement { $: any; From 99a76bb80179d43f48d5e942257135e41ddc4781 Mon Sep 17 00:00:00 2001 From: lgrignon Date: Fri, 18 Sep 2015 16:46:49 +0200 Subject: [PATCH 0014/1238] fixed implicit any --- backbone.localStorage/backbone.localStorage.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backbone.localStorage/backbone.localStorage.d.ts b/backbone.localStorage/backbone.localStorage.d.ts index 5696fa3d9f..122c475876 100644 --- a/backbone.localStorage/backbone.localStorage.d.ts +++ b/backbone.localStorage/backbone.localStorage.d.ts @@ -18,7 +18,7 @@ declare module Backbone { constructor(name: string, serializer?: Serializer); - save(); + save(): void; // Add a model, giving it a (hopefully)-unique GUID, if it doesn't already // have an id of it's own. @@ -43,7 +43,7 @@ declare module Backbone { _storageSize(): number; - _itemName(id): string; + _itemName(id: any): string; } } From 8088f834010654f82033838c8baabc1b35c285e9 Mon Sep 17 00:00:00 2001 From: lgrignon Date: Sun, 20 Sep 2015 10:17:47 +0200 Subject: [PATCH 0015/1238] deleted for rename --- .../backbone.localStorage.d.ts | 51 ------------------- 1 file changed, 51 deletions(-) delete mode 100644 backbone.localStorage/backbone.localStorage.d.ts diff --git a/backbone.localStorage/backbone.localStorage.d.ts b/backbone.localStorage/backbone.localStorage.d.ts deleted file mode 100644 index 122c475876..0000000000 --- a/backbone.localStorage/backbone.localStorage.d.ts +++ /dev/null @@ -1,51 +0,0 @@ -// Type definitions for backbone.localStorage 1.0.0 -// Project: https://github.com/jeromegn/Backbone.localStorage -// Definitions by: Louis Grignon -// Definitions: https://github.com/borisyankov/DefinitelyTyped - -/// - -declare module Backbone { - interface Serializer { - serialize(item: any): any; - deserialize(data: any): any; - } - - class LocalStorage { - name: string; - serializer: Serializer; - records: string[]; - - constructor(name: string, serializer?: Serializer); - - save(): void; - - // Add a model, giving it a (hopefully)-unique GUID, if it doesn't already - // have an id of it's own. - create(model: any): any; - - // Update a model by replacing its copy in `this.data`. - update(model: any): any; - - // Retrieve a model from `this.data` by id. - find(model: any): any; - - // Return the array of all models currently in storage. - findAll(): any; - - // Delete a model from `this.data`, returning it. - destroy(model: T): T; - - localStorage(): any; - - // Clear localStorage for specific collection. - _clear(): void; - - _storageSize(): number; - - _itemName(id: any): string; - } -} - -import Store = Backbone.LocalStorage; - From 7f6349d245f67a5b56cf6c339a51bd80a293a359 Mon Sep 17 00:00:00 2001 From: lgrignon Date: Sun, 20 Sep 2015 10:20:47 +0200 Subject: [PATCH 0016/1238] renamed backbone.localStorage to backbone.localstorage --- .../backbone.localstorage.d.ts | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 backbone.localstorage/backbone.localstorage.d.ts diff --git a/backbone.localstorage/backbone.localstorage.d.ts b/backbone.localstorage/backbone.localstorage.d.ts new file mode 100644 index 0000000000..122c475876 --- /dev/null +++ b/backbone.localstorage/backbone.localstorage.d.ts @@ -0,0 +1,51 @@ +// Type definitions for backbone.localStorage 1.0.0 +// Project: https://github.com/jeromegn/Backbone.localStorage +// Definitions by: Louis Grignon +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module Backbone { + interface Serializer { + serialize(item: any): any; + deserialize(data: any): any; + } + + class LocalStorage { + name: string; + serializer: Serializer; + records: string[]; + + constructor(name: string, serializer?: Serializer); + + save(): void; + + // Add a model, giving it a (hopefully)-unique GUID, if it doesn't already + // have an id of it's own. + create(model: any): any; + + // Update a model by replacing its copy in `this.data`. + update(model: any): any; + + // Retrieve a model from `this.data` by id. + find(model: any): any; + + // Return the array of all models currently in storage. + findAll(): any; + + // Delete a model from `this.data`, returning it. + destroy(model: T): T; + + localStorage(): any; + + // Clear localStorage for specific collection. + _clear(): void; + + _storageSize(): number; + + _itemName(id: any): string; + } +} + +import Store = Backbone.LocalStorage; + From 86bbeb0727634a4167760128de57790a5ccb1d2a Mon Sep 17 00:00:00 2001 From: Sergey Buturlakin Date: Tue, 29 Sep 2015 20:54:55 +0300 Subject: [PATCH 0017/1238] Update react-router 0.13.3 -> 1.0.0-rc1 --- react-router/history.d.ts | 152 ++++++++ react-router/react-router-test.ts | 425 ---------------------- react-router/react-router.d.ts | 570 ++++++++++++++---------------- 3 files changed, 423 insertions(+), 724 deletions(-) create mode 100644 react-router/history.d.ts delete mode 100644 react-router/react-router-test.ts diff --git a/react-router/history.d.ts b/react-router/history.d.ts new file mode 100644 index 0000000000..ede3d719c9 --- /dev/null +++ b/react-router/history.d.ts @@ -0,0 +1,152 @@ +// Type definitions for history v1.11.1 +// Project: https://github.com/rackt/history +// Definitions by: Sergey Buturlakin +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +declare namespace HistoryModule { + + // types based on https://github.com/rackt/history/blob/master/docs/Terms.md + + type Action = string + + type BeforeUnloadHook = () => string + + type CreateHistory = (options: HistoryOptions) => History + + type CreateHistoryEnhancer = (createHistory: CreateHistory) => CreateHistory + + interface History { + listenBefore: (hook: TransitionHook) => Function + listen: (listener: LocationListener) => Function + transitionTo(location: Location): void + pushState(state: LocationState, path: Path): void + replaceState(state: LocationState, path: Path): void + setState(state: LocationState): void + go(n: number): void + goBack(): void + goForward(): void + createKey(): LocationKey + createPath(path: Path): Path + createHref(path: Path): Href + } + + type HistoryOptions = Object + + type Href = string + + type Location = { + pathname: Pathname + search: QueryString + query: Query + state: LocationState + action: Action + key: LocationKey + } + + type LocationKey = string + + type LocationListener = (location: Location) => void + + type LocationState = Object + + type Path = string // Pathname + QueryString + + type Pathname = string + + type QueryString = string + + type Query = Object + + type TransitionHook = (location: Location, callback: Function) => any + +} + + +declare module "history/lib/createBrowserHistory" { + + export default function createBrowserHistory(): HistoryModule.History + +} + + +declare module "history/lib/createHashHistory" { + + export default function createHashHistory(): HistoryModule.History + +} + + +declare module "history/lib/createMemoryHistory" { + + export default function createMemoryHistory(): HistoryModule.History + +} + + +declare module "history/lib/createLocation" { + + export default function createLocation(): HistoryModule.Location + +} + + +declare module "history/lib/useBasename" { + + export default function useBasename(enhancer: HistoryModule.CreateHistoryEnhancer): HistoryModule.CreateHistory + +} + + +declare module "history/lib/useBeforeUnload" { + + export default function useBeforeUnload(enhancer: HistoryModule.CreateHistoryEnhancer): HistoryModule.CreateHistory + +} + + +declare module "history/lib/useQueries" { + + export default function useQueries(enhancer: HistoryModule.CreateHistoryEnhancer): HistoryModule.CreateHistory + +} + + +declare module "history/lib/actions" { + + export const PUSH: string + + export const REPLACE: string + + export const POP: string + + export default { + PUSH, + REPLACE, + POP + } + +} + + +declare module "history" { + + export { default as createHistory } from "history/lib/createBrowserHistory" + + export { default as createHashHistory } from "history/lib/createHashHistory" + + export { default as createMemoryHistory } from "history/lib/createMemoryHistory" + + export { default as createLocation } from "history/lib/createLocation" + + export { default as useBasename } from "history/lib/useBasename" + + export { default as useBeforeUnload } from "history/lib/useBeforeUnload" + + export { default as useQueries } from "history/lib/useQueries" + + import * as Actions from "history/lib/actions" + + export { Actions } + +} diff --git a/react-router/react-router-test.ts b/react-router/react-router-test.ts deleted file mode 100644 index 115c8b77f9..0000000000 --- a/react-router/react-router-test.ts +++ /dev/null @@ -1,425 +0,0 @@ -/// -"use strict"; - -import React = require('react'); -import ReactAddons = require('react/addons'); -import Router = require('react-router'); - -// Mixin -class NavigationTest { - v: T; - - makePath() { - var v1: string = this.v.makePath('to'); - var v2: string = this.v.makePath('to', {id: 1}); - var v3: string = this.v.makePath('to', {id: 1}, {type: 'json'}); - } - makeHref() { - var v1: string = this.v.makeHref('to'); - var v2: string = this.v.makeHref('to', {id: 1}); - var v3: string = this.v.makeHref('to', {id: 1}, {type: 'json'}); - } - transitionTo() { - var v1: void = this.v.transitionTo('to'); - var v2: void = this.v.transitionTo('to', {id: 1}); - var v3: void = this.v.transitionTo('to', {id: 1}, {type: 'json'}); - } - replaceWith() { - var v1: void = this.v.replaceWith('to'); - var v2: void = this.v.replaceWith('to', {id: 1}); - var v3: void = this.v.replaceWith('to', {id: 1}, {type: 'json'}); - } - goBack() { - var v1: void = this.v.goBack(); - } -} - -class StateTest { - v: T; - - getPath() { - var v1: string = this.v.getPath(); - } - - getRoutes() { - var v1: Router.Route[] = this.v.getRoutes(); - } - - getPathname() { - var v1: string = this.v.getPathname(); - } - - getParams() { - var v1: {} = this.v.getParams(); - } - - getQuery() { - var v1: {} = this.v.getQuery(); - } - - isActive() { - var v1: boolean = this.v.isActive('to'); - var v2: boolean = this.v.isActive('to', {id: 1}); - var v3: boolean = this.v.isActive('to', {id: 1}, {type: 'json'}); - } -} - - -// Location -class LocationTest { - v: T; - - push() { - var v1: void = this.v.push('path/to/hoge'); - } - - replace() { - var v1: void = this.v.replace('path/to/hoge'); - } - - pop() { - var v1: void = this.v.pop(); - } - - getCurrentPath() { - var v1: void = this.v.getCurrentPath(); - } -} -new LocationTest(); -new LocationTest(); -new LocationTest(); - -class LocationListenerTest { - v: T; - - addChangeListener() { - var v1: void = this.v.addChangeListener(() => console.log(1)); - } - - removeChangeListener() { - var v1: void = this.v.removeChangeListener(() => console.log(1)); - } -} -new LocationListenerTest(); -new LocationListenerTest(); - - -// Behavior -class ScrollBehaviorTest { - v: T; - - updateScrollPosition() { - var v1: void = this.v.updateScrollPosition({x: 33, y: 102}, 'scrollTop'); - } -} -new ScrollBehaviorTest(); -new ScrollBehaviorTest(); - - -// Component -class DefaultRouteTest { - v: Router.DefaultRoute; - - props() { - var name: string = this.v.props.name; - var handler: React.ComponentClass = this.v.props.handler; - } - - createElement() { - var Handler: React.ComponentClass; - React.createElement(Router.DefaultRoute, null); - React.createElement(Router.DefaultRoute, {name: 'name', handler: Handler}); - - ReactAddons.createElement(Router.DefaultRoute, null); - ReactAddons.createElement(Router.DefaultRoute, {name: 'name', handler: Handler}); - } -} - -class LinkTest { - v: Router.Link; - - constructor() { - new NavigationTest(); - new StateTest(); - } - - props() { - var activeClassName: string = this.v.props.activeClassName; - var to: string = this.v.props.to; - var params: {} = this.v.props.params; - var query: {} = this.v.props.query; - var onClick: Function = this.v.props.onClick; - } - - getHref() { - var v1: string = this.v.getHref(); - } - - getClassName() { - var v1: string = this.v.getClassName(); - } - - createElement() { - React.createElement(Router.Link, null); - React.createElement(Router.Link, {to: 'home'}); - React.createElement(Router.Link, { - activeClassName: 'name', - to: 'home', - params: {}, - query: {}, - onClick: () => console.log(1) - }); - - ReactAddons.createElement(Router.Link, null); - ReactAddons.createElement(Router.Link, {to: 'home'}); - ReactAddons.createElement(Router.Link, { - activeClassName: 'name', - to: 'home', - params: {}, - query: {}, - onClick: () => console.log(1) - }); - } -} - -class NotFoundRouteTest { - v: Router.NotFoundRoute; - - props() { - var name: string = this.v.props.name; - var handler: React.ComponentClass = this.v.props.handler; - } - - createElement() { - var Handler: React.ComponentClass; - React.createElement(Router.NotFoundRoute, null); - React.createElement(Router.NotFoundRoute, {handler: Handler}); - React.createElement(Router.NotFoundRoute, {handler: Handler, name: "home"}); - - ReactAddons.createElement(Router.NotFoundRoute, null); - ReactAddons.createElement(Router.NotFoundRoute, {handler: Handler}); - ReactAddons.createElement(Router.NotFoundRoute, {handler: Handler, name: "home"}); - } -} - -class RedirectTest { - v: Router.Redirect; - - props() { - var path: string = this.v.props.path; - var from: string = this.v.props.from; - var to: string = this.v.props.to; - } - - createElement() { - React.createElement(Router.Redirect, null); - React.createElement(Router.Redirect, {}); - React.createElement(Router.Redirect, {path: 'a', from: 'a', to: 'b'}); - - ReactAddons.createElement(Router.Redirect, null); - ReactAddons.createElement(Router.Redirect, {}); - ReactAddons.createElement(Router.Redirect, {path: 'a', from: 'a', to: 'b'}); - } -} - -class RouteTest { - v: Router.Route; - - props() { - var name: string = this.v.props.name; - var path: string = this.v.props.path; - var handler: React.ComponentClass = this.v.props.handler; - var ignoreScrollBehavior: boolean = this.v.props.ignoreScrollBehavior; - } - - createElement() { - var Handler: React.ComponentClass; - React.createElement(Router.Route, null); - React.createElement(Router.Route, {}); - React.createElement(Router.Route, {name: "home", path: "/", handler: Handler, ignoreScrollBehavior: true}); - - ReactAddons.createElement(Router.Route, null); - ReactAddons.createElement(Router.Route, {}); - ReactAddons.createElement(Router.Route, {name: "home", path: "/", handler: Handler, ignoreScrollBehavior: true}); - } -} - -class RouteHandlerTest { - v: Router.RouteHandler; - - createElement() { - React.createElement(Router.RouteHandler, null); - React.createElement(Router.RouteHandler, {}); - - ReactAddons.createElement(Router.RouteHandler, null); - ReactAddons.createElement(Router.RouteHandler, {}); - } -} - - -// History -class HistoryTest { - v: Router.History; - - length() { - var v1: number = this.v.length; - } - - back() { - var v1: void = this.v.back(); - } -} - - -// Router -class CreateTest { - v: Router.Router; - - constructor() { - // React.createElement() version - this.v = Router.create({ - routes: React.createElement(Router.Route, null) - }); - this.v = Router.create({ - routes: React.createElement(Router.Route, null), - location: Router.HistoryLocation, - scrollBehavior: Router.ImitateBrowserBehavior - }); - - // React.createFactory() version - this.v = Router.create({ - routes: React.createFactory(Router.Route)() - }); - this.v = Router.create({ - routes: React.createFactory(Router.Route)(), - location: Router.HistoryLocation, - scrollBehavior: Router.ImitateBrowserBehavior - }); - } - - run() { - this.v.run((Handler) => console.log(Handler)); - this.v.run((Handler, state) => console.log(Handler, state)); - } -} - -class RunTest { - constructor() { - // React.createElement() version - var v1: Router.Router = Router.run(React.createElement(Router.Route, null), (Handler) => { - React.render(React.createElement(Handler, null), document.body); - }); - var v2: Router.Router = Router.run(React.createElement(Router.Route, null), Router.HistoryLocation, (Handler, state) => { - React.render(React.createElement(Handler, null), document.body); - }); - var v3: Router.Router = Router.run(React.createElement(Router.Route, null), '/foo/bar', (Handler, state) => { - React.render(React.createElement(Handler, null), document.body); - }); - - // React.createFactory() version - var v4: Router.Router = Router.run(React.createFactory(Router.Route)(), (Handler) => { - React.render(React.createElement(Handler, null), document.body); - }); - var v5: Router.Router = Router.run(React.createFactory(Router.Route)(), Router.HistoryLocation, (Handler, state) => { - React.render(React.createElement(Handler, null), document.body); - }); - var v6: Router.Router = Router.run(React.createFactory(Router.Route)(), '/foo/bar', (Handler, state) => { - React.render(React.createElement(Handler, null), document.body); - }); - } -} - - -// Transition -class TransitionTest { - constructor() { - var v1: Router.TransitionStaticLifecycle = { - willTransitionTo: (transition, params, query, callback) => { - transition.abort(); - transition.redirect('to'); - transition.redirect('to', {id: 1}); - transition.redirect('to', {id: 1}, {type: 'json'}); - transition.retry(); - }, - willTransitionFrom: (transition, component, callback) => {} - }; - var v2: Router.TransitionStaticLifecycle = { - willTransitionTo: (transition, params, query) => {}, - willTransitionFrom: (transition, component) => {} - }; - var v3: Router.TransitionStaticLifecycle = { - willTransitionTo: (transition, params) => {}, - willTransitionFrom: (transition) => {} - }; - var v4: Router.TransitionStaticLifecycle = { - willTransitionTo: (transition) => {}, - willTransitionFrom: () => {} - }; - var v5: Router.TransitionStaticLifecycle = { - willTransitionTo: () => {} - }; - var v6: Router.TransitionStaticLifecycle = { - willTransitionFrom: () => {} - }; - } -} - - -// Context -class ContextTest { - v: Router.Context - - makePath() { - var v1: string = this.v.makePath('home'); - var v2: string = this.v.makePath('home', {p1: 1}); - var v3: string = this.v.makePath('home', {p1: 1}, {q1: 1}); - } - - makeHref() { - var v1: string = this.v.makeHref('home'); - var v2: string = this.v.makeHref('home', {p1: 1}); - var v3: string = this.v.makeHref('home', {p1: 1}, {q1: 1}); - } - - transitionTo() { - var v1: void = this.v.transitionTo('home'); - var v2: void = this.v.transitionTo('home', {p1: 1}); - var v3: void = this.v.transitionTo('home', {p1: 1}, {q1: 1}); - } - - replaceWith() { - var v1: void = this.v.replaceWith('home'); - var v2: void = this.v.replaceWith('home', {p1: 1}); - var v3: void = this.v.replaceWith('home', {p1: 1}, {q1: 1}); - } - - goBack() { - var v: void = this.v.goBack(); - } - - getCurrentPath() { - var v: string = this.v.getCurrentPath(); - } - - getCurrentRoutes() { - var v: Router.Route[] = this.v.getCurrentRoutes(); - } - - getCurrentPathname() { - var v: string = this.v.getCurrentPathname(); - } - - getCurrentParams() { - var v: {} = this.v.getCurrentParams(); - } - - getCurrentQuery() { - var v: {} = this.v.getCurrentQuery(); - } - - isActive() { - var v1: boolean = this.v.isActive('home'); - var v2: boolean = this.v.isActive('home', {p1: 1}); - var v3: boolean = this.v.isActive('home', {p1: 1}, {q1: 1}); - } -} diff --git a/react-router/react-router.d.ts b/react-router/react-router.d.ts index 4cebcfab36..b1da6e0060 100644 --- a/react-router/react-router.d.ts +++ b/react-router/react-router.d.ts @@ -1,354 +1,326 @@ -// Type definitions for React Router 0.13.3 +// Type definitions for history v1.0.0-rc1 // Project: https://github.com/rackt/react-router -// Definitions by: Yuichi Murata , Václav Ostrožlík +// Definitions by: Sergey Buturlakin // Definitions: https://github.com/borisyankov/DefinitelyTyped -/// -declare module ReactRouter { - import React = __React; +/// - // - // Transition - // ---------------------------------------------------------------------- - interface Transition { - path: string; - abortReason: any; - retry(): void; - abort(reason?: any): void; - redirect(to: string, params?: {}, query?: {}): void; - cancel(): void; - from: (transition: Transition, routes: Route[], components?: React.ReactElement[], callback?: (error?: any) => void) => void; - to: (transition: Transition, routes: Route[], params?: {}, query?: {}, callback?: (error?: any) => void) => void; + +declare namespace ReactRouter { + + // types based on https://github.com/rackt/react-router/blob/master/docs/Glossary.md + + type Action = string + + type Component = React.ReactType + + type EnterHook = (nextState: RouterState, replaceState: RedirectFunction, callback?: Function) => any + + type LeaveHook = () => any + + interface Location { + pathname: Pathname + search: QueryString + query: Query + state: LocationState + action: Action + key: LocationKey } - interface TransitionStaticLifecycle { - willTransitionTo?( - transition: Transition, - params: {}, - query: {}, - callback: Function - ): void; + type LocationKey = string - willTransitionFrom?( - transition: Transition, - component: React.ReactElement, - callback: Function - ): void; + type LocationListener = (location: Location) => void + + type LocationState = Object + + type Params = Object + + type Path = string // Pathname + QueryString + + type Pathname = string + + type Query = Object + + type QueryString = string + + type RedirectFunction = (state: LocationState, pathname: Pathname | Path, query?: Query) => void + + interface RouteComponentProps { + history?: RouterObject + location?: Location + params?: Params + route?: RouteObject + routeParams?: Params + routes?: PlainRoute[] } - // - // Route Configuration - // ---------------------------------------------------------------------- - // DefaultRoute - interface DefaultRouteProp { - name?: string; - handler: React.ComponentClass; - } - interface DefaultRoute extends React.ReactElement {} - interface DefaultRouteClass extends React.ComponentClass {} + type RouteComponent = React.ComponentClass - // NotFoundRoute - interface NotFoundRouteProp { - name?: string; - handler: React.ComponentClass; - } - interface NotFoundRoute extends React.ReactElement {} - interface NotFoundRouteClass extends React.ComponentClass {} + type RouteConfig = RouteObject[] - // Redirect - interface RedirectProp { - path?: string; - from?: string; - to?: string; - } - interface Redirect extends React.ReactElement {} - interface RedirectClass extends React.ComponentClass {} + type RouteHook = (nextLocation?: Location) => any - // Route - interface RouteProp { - name?: string; - path?: string; - handler?: React.ComponentClass; - ignoreScrollBehavior?: boolean; - } - interface Route extends React.ReactElement {} - interface RouteClass extends React.ComponentClass {} + type RoutePattern = string - var DefaultRoute: DefaultRouteClass; - var NotFoundRoute: NotFoundRouteClass; - var Redirect: RedirectClass; - var Route: RouteClass; - - interface CreateRouteOptions { - name?: string; - path?: string; - ignoreScrollBehavior?: boolean; - isDefault?: boolean; - isNotFound?: boolean; - onEnter?: (transition: Transition, params: {}, query: {}, callback: Function) => void; - onLeave?: (transition: Transition, wtf: any, callback: Function) => void; - handler?: Function; - parentRoute?: Route; + interface RouteObject { + component: RouteComponent + path: RoutePattern + onEnter: EnterHook + onLeave: LeaveHook } - type CreateRouteCallback = (route: Route) => void; - - function createRoute(callback: CreateRouteCallback): Route; - function createRoute(options: CreateRouteOptions | string, callback: CreateRouteCallback): Route; - function createDefaultRoute(options?: CreateRouteOptions | string): Route; - function createNotFoundRoute(options?: CreateRouteOptions | string): Route; - - interface CreateRedirectOptions extends CreateRouteOptions { - path?: string; - from?: string; - to: string; - params?: {}; - query?: {}; + interface RouterObject { + transitionTo: (location: Location) => void + pushState: (state: LocationState, pathname: Pathname | Path, query?: Query) => void + replaceState: (state: LocationState, pathname: Pathname | Path, query?: Query) => void + go(n: Number): void + listen(listener: RouterListener): Function + match(location: Location, callback: RouterListener): void } - function createRedirect(options: CreateRedirectOptions): Redirect; - function createRoutesFromReactChildren(children: Route): Route[]; - // - // Components - // ---------------------------------------------------------------------- - // Link - interface LinkProp extends React.HTMLAttributes { - activeClassName?: string; - activeStyle?: {}; - to: string; - params?: {}; - query?: {}; - } - interface Link extends React.ReactElement, Navigation, State { - handleClick(event: any): void; - getHref(): string; - getClassName(): string; - getActiveState(): boolean; - } - interface LinkClass extends React.ComponentClass {} - - // RouteHandler - interface RouteHandlerProp { } - interface RouteHandlerChildContext { - routeDepth: number; - } - interface RouteHandler extends React.ReactElement { - getChildContext(): RouteHandlerChildContext; - getRouteDepth(): number; - createChildRouteHandler(props: {}): RouteHandler; - } - interface RouteHandlerClass extends React.ComponentClass {} - - var Link: LinkClass; - var RouteHandler: RouteHandlerClass; - - - // - // Top-Level - // ---------------------------------------------------------------------- - interface Router extends React.ReactElement { - run(callback: RouterRunCallback): void; - } + type RouterListener = (error: Error, nextState: RouterState) => void interface RouterState { - path: string; - action: string; - pathname: string; - params: {}; - query: {}; - routes: Route[]; + location: Location + routes: RouteConfig + params: Params + components: Component[] } - interface RouterCreateOption { - routes: Route; - location?: LocationBase; - scrollBehavior?: ScrollBehaviorBase; - onError?: (error: any) => void; - onAbort?: (error: any) => void; + + interface HistoryProp { + listen(listener: LocationListener): Function + pushState(state: LocationState, path: Path): void + replaceState(state: LocationState, path: Path): void + go(n: number): void } - type RouterRunCallback = (Handler: RouteClass, state: RouterState) => void; + type RouteType = Route | IndexRoute | PlainRoute | Redirect - function create(options: RouterCreateOption): Router; - function run(routes: Route, callback: RouterRunCallback): Router; - function run(routes: Route, location: LocationBase | string, callback: RouterRunCallback): Router; + type Components = { [key: string]: Component } - // - // Location - // ---------------------------------------------------------------------- - interface LocationBase { - getCurrentPath(): void; - toString(): string; + interface RouterProps { + history?: HistoryProp + children?: RouteType[] + routes?: RouteType[] // alias for children + createElement?: (component: Component, props: Object) => any + onError?: (err: any) => any + onUpdate?: () => any + parseQueryString?: (queryString: QueryString) => Query + stringifyQuery?: (queryObject: Query) => QueryString } - interface Location extends LocationBase { - push(path: string): void; - replace(path: string): void; - pop(): void; + interface Router extends React.ComponentClass {} + interface RouterElement extends React.ReactElement {} + const Router: Router + + + interface LinkProps extends React.HTMLAttributesBase { + activeStyle?: React.CSSProperties + activeClassName?: string + onlyActiveOnIndex?: boolean + to: RoutePattern + query?: Query + state?: LocationState + } + interface Link extends React.ComponentClass {} + interface LinkElement extends React.DOMElement {} + const Link: Link + + + interface RoutePropsBase { + children?: RouteType[] + ignoreScrollBehavior?: boolean + component?: Component + components?: Components + getComponent?: (location: Location, cb: (err: any, component?: Component) => void) => void + getComponents?: (location: Location, cb: (err: any, components?: Components) => void) => void + onEnter?: EnterHook + onLeave?: LeaveHook } - interface LocationListener { - addChangeListener(listener: Function): void; - removeChangeListener(listener: Function): void; + interface RouteProps extends RoutePropsBase { + path?: RoutePattern + } + interface Route extends React.ComponentClass {} + interface RouteElement extends React.ReactElement {} + const Route: Route + + + interface PlainRoute extends RoutePropsBase { + childRoutes: RouteType[] + getChildRoutes: (location: Location, cb: (err: any, routesArray: RouteType[]) => void) => void } - interface HashLocation extends Location, LocationListener { } - interface HistoryLocation extends Location, LocationListener { } - interface RefreshLocation extends Location { } - interface StaticLocation extends LocationBase { } - interface TestLocation extends Location, LocationListener { } - var HashLocation: HashLocation; - var HistoryLocation: HistoryLocation; - var RefreshLocation: RefreshLocation; - var StaticLocation: StaticLocation; - var TestLocation: TestLocation; + interface RedirectProps { + path?: RoutePattern + from?: RoutePattern // alias for path + to: RoutePattern + query?: Query + state?: LocationState - - // - // Behavior - // ---------------------------------------------------------------------- - interface ScrollBehaviorBase { - updateScrollPosition(position: { x: number; y: number; }, actionType: string): void; } - interface ImitateBrowserBehavior extends ScrollBehaviorBase { } - interface ScrollToTopBehavior extends ScrollBehaviorBase { } - - var ImitateBrowserBehavior: ImitateBrowserBehavior; - var ScrollToTopBehavior: ScrollToTopBehavior; + interface Redirect extends React.ReactElement {} + interface RedirectELement extends React.ReactElement {} + const Redirect: Redirect - // - // Mixin - // ---------------------------------------------------------------------- - interface Navigation { - makePath(to: string, params?: {}, query?: {}): string; - makeHref(to: string, params?: {}, query?: {}): string; - transitionTo(to: string, params?: {}, query?: {}): void; - replaceWith(to: string, params?: {}, query?: {}): void; - goBack(): void; - } + interface IndexRouteProps extends RoutePropsBase {} + interface IndexRoute extends React.ComponentClass {} + interface IndexRouteElement extends React.ReactElement {} + const IndexRoute: IndexRoute - interface State { - getPath(): string; - getRoutes(): Route[]; - getPathname(): string; - getParams(): {}; - getQuery(): {}; - isActive(to: string, params?: {}, query?: {}): boolean; - } - - var Navigation: Navigation; - var State: State; - - - // - // History - // ---------------------------------------------------------------------- - interface History { - back(): void; - length: number; - } - var History: History; - - - // - // Context - // ---------------------------------------------------------------------- - interface Context { - makePath(to: string, params?: {}, query?: {}): string; - makeHref(to: string, params?: {}, query?: {}): string; - transitionTo(to: string, params?: {}, query?: {}): void; - replaceWith(to: string, params?: {}, query?: {}): void; - goBack(): void; - - getCurrentPath(): string; - getCurrentRoutes(): Route[]; - getCurrentPathname(): string; - getCurrentParams(): {}; - getCurrentQuery(): {}; - isActive(to: string, params?: {}, query?: {}): boolean; - } } + +declare module "react-router/lib/Router" { + + export default ReactRouter.Router + +} + + +declare module "react-router/lib/Link" { + + export default ReactRouter.Link + +} + + +declare module "react-router/lib/IndexRoute" { + + export default ReactRouter.IndexRoute + +} + + +declare module "react-router/lib/Redirect" { + + export default ReactRouter.Redirect + +} + + +declare module "react-router/lib/Route" { + + export default ReactRouter.Route + +} + + +declare module "react-router/lib/History" { + + const History: any + + export default History + +} + + +declare module "react-router/lib/Lifecycle" { + + const Lifecycle: any + + export default Lifecycle + +} + + +declare module "react-router/lib/RouteContext" { + + const RouteContext: any + + export default RouteContext + +} + + +declare module "react-router/lib/useRoutes" { + + const useRoutes: any + + export default useRoutes + +} + + +declare module "react-router/lib/RouteUtils" { + + export const createRoutes: any + +} + + +declare module "react-router/lib/RoutingContext" { + + const RoutingContext: any + + export default RoutingContext + +} + + +declare module "react-router/lib/PropTypes" { + + const PropTypes: any + + export default PropTypes + +} + + +declare module "react-router/lib/match" { + + const match: any + + export default match + +} + + declare module "react-router" { - export = ReactRouter; -} -declare module __React { + import Router from "react-router/lib/Router" - // for DefaultRoute - function createElement( - type: ReactRouter.DefaultRouteClass, - props: ReactRouter.DefaultRouteProp, - ...children: __React.ReactNode[]): ReactRouter.DefaultRoute; + import Link from "react-router/lib/Link" - // for Link - function createElement( - type: ReactRouter.LinkClass, - props: ReactRouter.LinkProp, - ...children: __React.ReactNode[]): ReactRouter.Link; + import IndexRoute from "react-router/lib/IndexRoute" - // for NotFoundRoute - function createElement( - type: ReactRouter.NotFoundRouteClass, - props: ReactRouter.NotFoundRouteProp, - ...children: __React.ReactNode[]): ReactRouter.NotFoundRoute; + import Redirect from "react-router/lib/Redirect" - // for Redirect - function createElement( - type: ReactRouter.RedirectClass, - props: ReactRouter.RedirectProp, - ...children: __React.ReactNode[]): ReactRouter.Redirect; + import Route from "react-router/lib/Route" - // for Route - function createElement( - type: ReactRouter.RouteClass, - props: ReactRouter.RouteProp, - ...children: __React.ReactNode[]): ReactRouter.Route; + import History from "react-router/lib/History" - // for RouteHandler - function createElement( - type: ReactRouter.RouteHandlerClass, - props: ReactRouter.RouteHandlerProp, - ...children: __React.ReactNode[]): ReactRouter.RouteHandler; -} + import Lifecycle from "react-router/lib/Lifecycle" -declare module "react/addons" { - // for DefaultRoute - function createElement( - type: ReactRouter.DefaultRouteClass, - props: ReactRouter.DefaultRouteProp, - ...children: __React.ReactNode[]): ReactRouter.DefaultRoute; + import RouteContext from "react-router/lib/RouteContext" - // for Link - function createElement( - type: ReactRouter.LinkClass, - props: ReactRouter.LinkProp, - ...children: __React.ReactNode[]): ReactRouter.Link; + import { createRoutes } from "react-router/lib/RouteUtils" - // for NotFoundRoute - function createElement( - type: ReactRouter.NotFoundRouteClass, - props: ReactRouter.NotFoundRouteProp, - ...children: __React.ReactNode[]): ReactRouter.NotFoundRoute; + import RoutingContext from "react-router/lib/RoutingContext" - // for Redirect - function createElement( - type: ReactRouter.RedirectClass, - props: ReactRouter.RedirectProp, - ...children: __React.ReactNode[]): ReactRouter.Redirect; + import PropTypes from "react-router/lib/PropTypes" - // for Route - function createElement( - type: ReactRouter.RouteClass, - props: ReactRouter.RouteProp, - ...children: __React.ReactNode[]): ReactRouter.Route; + import match from "react-router/lib/match" + + export { + Router, + Link, + IndexRoute, + Redirect, + Route, + History, + Lifecycle, + RouteContext, + createRoutes, + RoutingContext, + PropTypes, + match + } + + export default Router - // for RouteHandler - function createElement( - type: ReactRouter.RouteHandlerClass, - props: ReactRouter.RouteHandlerProp, - ...children: __React.ReactNode[]): ReactRouter.RouteHandler; } From fb14688db7ba1f2dd4cf5978ef03cbc318d45b40 Mon Sep 17 00:00:00 2001 From: Sergey Buturlakin Date: Wed, 30 Sep 2015 17:51:09 +0300 Subject: [PATCH 0018/1238] Update History for use as global and minor fixes --- react-router/history.d.ts | 40 ++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/react-router/history.d.ts b/react-router/history.d.ts index ede3d719c9..e432a2418c 100644 --- a/react-router/history.d.ts +++ b/react-router/history.d.ts @@ -12,13 +12,12 @@ declare namespace HistoryModule { type BeforeUnloadHook = () => string - type CreateHistory = (options: HistoryOptions) => History + type CreateHistory = (options?: HistoryOptions) => History type CreateHistoryEnhancer = (createHistory: CreateHistory) => CreateHistory - interface History { - listenBefore: (hook: TransitionHook) => Function - listen: (listener: LocationListener) => Function + interface HistoryBase { + listenBefore(hook: TransitionHook): Function transitionTo(location: Location): void pushState(state: LocationState, path: Path): void replaceState(state: LocationState, path: Path): void @@ -31,6 +30,10 @@ declare namespace HistoryModule { createHref(path: Path): Href } + interface History { + listen(listener: LocationListener): Function + } + type HistoryOptions = Object type Href = string @@ -54,32 +57,51 @@ declare namespace HistoryModule { type Pathname = string - type QueryString = string - type Query = Object + type QueryString = string + type TransitionHook = (location: Location, callback: Function) => any + // Global usage, without modules, needs the small trick, because lib.d.ts + // already has `history` and `History` global definitions: + // var history_: HistoryModule.Module = window['History']; + // history_.createHistory(); + interface Module { + createHistory: CreateHistory + createHashHistory: CreateHistory + createMemoryHistory: CreateHistory + createLocation(): Location + useBasename(enhancer: CreateHistoryEnhancer): CreateHistory + useBeforeUnload(enhancer: CreateHistoryEnhancer): CreateHistory + useQueries(enhancer: CreateHistoryEnhancer): CreateHistory + actions: { + PUSH: string + REPLACE: string + POP: string + } + } + } declare module "history/lib/createBrowserHistory" { - export default function createBrowserHistory(): HistoryModule.History + export default function createBrowserHistory(options?: HistoryModule.HistoryOptions): HistoryModule.History } declare module "history/lib/createHashHistory" { - export default function createHashHistory(): HistoryModule.History + export default function createHashHistory(options?: HistoryModule.HistoryOptions): HistoryModule.History } declare module "history/lib/createMemoryHistory" { - export default function createMemoryHistory(): HistoryModule.History + export default function createMemoryHistory(options?: HistoryModule.HistoryOptions): HistoryModule.History } From ef5f58533485fd056b4c642d9c49c92667d8f290 Mon Sep 17 00:00:00 2001 From: Sergey Buturlakin Date: Wed, 30 Sep 2015 17:52:15 +0300 Subject: [PATCH 0019/1238] Complete react-router v1.0.0-rc1 definitions --- react-router/react-router.d.ts | 215 ++++++++++++++++++++------------- 1 file changed, 132 insertions(+), 83 deletions(-) diff --git a/react-router/react-router.d.ts b/react-router/react-router.d.ts index b1da6e0060..c96fe284dc 100644 --- a/react-router/react-router.d.ts +++ b/react-router/react-router.d.ts @@ -1,17 +1,18 @@ -// Type definitions for history v1.0.0-rc1 +// Type definitions for react-router v1.0.0-rc1 // Project: https://github.com/rackt/react-router // Definitions by: Sergey Buturlakin // Definitions: https://github.com/borisyankov/DefinitelyTyped -/// +/// +/// declare namespace ReactRouter { // types based on https://github.com/rackt/react-router/blob/master/docs/Glossary.md - type Action = string + import H = HistoryModule type Component = React.ReactType @@ -19,38 +20,17 @@ declare namespace ReactRouter { type LeaveHook = () => any - interface Location { - pathname: Pathname - search: QueryString - query: Query - state: LocationState - action: Action - key: LocationKey - } - - type LocationKey = string - - type LocationListener = (location: Location) => void - - type LocationState = Object - type Params = Object - type Path = string // Pathname + QueryString + type ParseQueryString = (queryString: H.QueryString) => H.Query - type Pathname = string - - type Query = Object - - type QueryString = string - - type RedirectFunction = (state: LocationState, pathname: Pathname | Path, query?: Query) => void + type RedirectFunction = (state: H.LocationState, pathname: H.Pathname | H.Path, query?: H.Query) => void interface RouteComponentProps { - history?: RouterObject + history?: History location?: Location params?: Params - route?: RouteObject + route?: PlainRoute routeParams?: Params routes?: PlainRoute[] } @@ -63,20 +43,24 @@ declare namespace ReactRouter { type RoutePattern = string - interface RouteObject { - component: RouteComponent - path: RoutePattern - onEnter: EnterHook - onLeave: LeaveHook - } + type RouteObject = PlainRoute - interface RouterObject { - transitionTo: (location: Location) => void - pushState: (state: LocationState, pathname: Pathname | Path, query?: Query) => void - replaceState: (state: LocationState, pathname: Pathname | Path, query?: Query) => void - go(n: Number): void + type StringifyQuery = (queryObject: H.Query) => H.QueryString + + + interface History extends H.HistoryBase { + pushState(state: H.LocationState, pathname: H.Pathname | H.Path, query?: H.Query): void + replaceState(state: H.LocationState, pathname: H.Pathname | H.Path, query?: H.Query): void + createPath(path: H.Path, query?: H.Query): H.Path + createHref(path: H.Path, query?: H.Query): H.Href + isActive(pathname: H.Pathname, query: H.Query): boolean + registerRouteHook(route: PlainRoute, hook: H.LocationListener): void + unregisterRouteHook(route: PlainRoute, hook: H.LocationListener): void listen(listener: RouterListener): Function - match(location: Location, callback: RouterListener): void + match(location: H.Location, callback: (error: any, nextState: RouterState, nextLocation: H.Location) => void): void + routes: PlainRoute[] + parseQueryString?: ParseQueryString + stringifyQuery?: StringifyQuery } type RouterListener = (error: Error, nextState: RouterState) => void @@ -89,27 +73,22 @@ declare namespace ReactRouter { } - interface HistoryProp { - listen(listener: LocationListener): Function - pushState(state: LocationState, path: Path): void - replaceState(state: LocationState, path: Path): void - go(n: number): void - } - type RouteType = Route | IndexRoute | PlainRoute | Redirect + type RouteTypes = RouteType | RouteType[] + type Components = { [key: string]: Component } interface RouterProps { - history?: HistoryProp - children?: RouteType[] - routes?: RouteType[] // alias for children + history?: H.History + children?: RouteTypes + routes?: RouteTypes // alias for children createElement?: (component: Component, props: Object) => any onError?: (err: any) => any onUpdate?: () => any - parseQueryString?: (queryString: QueryString) => Query - stringifyQuery?: (queryObject: Query) => QueryString + parseQueryString?: ParseQueryString + stringifyQuery?: StringifyQuery } interface Router extends React.ComponentClass {} interface RouterElement extends React.ReactElement {} @@ -121,8 +100,8 @@ declare namespace ReactRouter { activeClassName?: string onlyActiveOnIndex?: boolean to: RoutePattern - query?: Query - state?: LocationState + query?: H.Query + state?: H.LocationState } interface Link extends React.ComponentClass {} interface LinkElement extends React.DOMElement {} @@ -130,7 +109,7 @@ declare namespace ReactRouter { interface RoutePropsBase { - children?: RouteType[] + children?: RouteTypes ignoreScrollBehavior?: boolean component?: Component components?: Components @@ -148,9 +127,9 @@ declare namespace ReactRouter { const Route: Route - interface PlainRoute extends RoutePropsBase { - childRoutes: RouteType[] - getChildRoutes: (location: Location, cb: (err: any, routesArray: RouteType[]) => void) => void + interface PlainRoute extends RouteProps { + childRoutes: RouteTypes + getChildRoutes: (location: Location, cb: (err: any, routesArray: RouteTypes) => void) => void } @@ -158,12 +137,11 @@ declare namespace ReactRouter { path?: RoutePattern from?: RoutePattern // alias for path to: RoutePattern - query?: Query - state?: LocationState - + query?: H.Query + state?: H.LocationState } interface Redirect extends React.ReactElement {} - interface RedirectELement extends React.ReactElement {} + interface RedirectElement extends React.ReactElement {} const Redirect: Redirect @@ -172,6 +150,51 @@ declare namespace ReactRouter { interface IndexRouteElement extends React.ReactElement {} const IndexRoute: IndexRoute + + interface RoutingContextProps { + history: H.History + createElement?: (component: Component, props: Object) => any + location: Location + routes: RouteTypes + params: Params + components?: Components + } + interface RoutingContext extends React.ReactElement {} + interface RoutingContextElement extends React.ReactElement {} + const RoutingContext: RoutingContext + + + interface LifecycleMixin { + routerWillLeave(nextLocation: Location): string | boolean + } + const Lifecycle: React.Mixin + + + const RouteContext: React.Mixin + + + interface HistoryMixin { + history: History + } + const History: React.Mixin + + + function useRoutes(enhancer: H.CreateHistoryEnhancer): H.CreateHistory + + function createRoutes(routes: RouteTypes): PlainRoute[] + + interface MatchArgs { + routes?: RouteTypes + history?: H.History + location?: Location + parseQueryString?: ParseQueryString + stringifyQuery?: StringifyQuery + } + interface MatchState extends RouterState { + history: History + } + function match(args: MatchArgs, cb: (error: any, nextLocation: H.Location, nextState: MatchState) => void): void + } @@ -189,6 +212,15 @@ declare module "react-router/lib/Link" { } +declare module "react-router/lib/IndexLink" { + + const IndexLink: ReactRouter.Link + + export default IndexLink + +} + + declare module "react-router/lib/IndexRoute" { export default ReactRouter.IndexRoute @@ -212,70 +244,87 @@ declare module "react-router/lib/Route" { declare module "react-router/lib/History" { - const History: any - - export default History + export default ReactRouter.History } declare module "react-router/lib/Lifecycle" { - const Lifecycle: any - - export default Lifecycle + export default ReactRouter.Lifecycle } declare module "react-router/lib/RouteContext" { - const RouteContext: any - - export default RouteContext + export default ReactRouter.RouteContext } declare module "react-router/lib/useRoutes" { - const useRoutes: any - - export default useRoutes + export default ReactRouter.useRoutes } declare module "react-router/lib/RouteUtils" { - export const createRoutes: any + type E = React.ReactElement + + export function isReactChildren(object: E | E[]): boolean + + export function createRouteFromReactElement(element: E): ReactRouter.PlainRoute + + export function createRoutesFromReactChildren(children: E | E[], parentRoute: ReactRouter.PlainRoute): ReactRouter.PlainRoute[] + + import createRoutes = ReactRouter.createRoutes + + export { createRoutes } } declare module "react-router/lib/RoutingContext" { - const RoutingContext: any - - export default RoutingContext + export default ReactRouter.RoutingContext } declare module "react-router/lib/PropTypes" { - const PropTypes: any + export function falsy(props: any, propName: string, componentName: string): Error; - export default PropTypes + export const history: React.Requireable + + export const location: React.Requireable + + export const component: React.Requireable + + export const components: React.Requireable + + export const route: React.Requireable + + export const routes: React.Requireable + + export default { + falsy, + history, + location, + component, + components, + route + } } declare module "react-router/lib/match" { - const match: any - - export default match + export default ReactRouter.match } From 4a33c914d17fd680916dc0dbfa27df1ce41aea26 Mon Sep 17 00:00:00 2001 From: Sergey Buturlakin Date: Wed, 30 Sep 2015 19:27:10 +0300 Subject: [PATCH 0020/1238] Add tests Restore old definitions as react-router-0.13.3.d.ts Update react-redux to use old definitions --- react-redux/react-redux-tests.tsx | 2 +- react-router/history.d.ts | 7 +- react-router/react-router-0.13.3.d.ts | 354 ++++++++++++++++++ react-router/react-router-tests.tsx | 67 ++++ react-router/react-router-tests.tsx.tscparams | 1 + react-router/react-router.d.ts | 8 +- 6 files changed, 430 insertions(+), 9 deletions(-) create mode 100644 react-router/react-router-0.13.3.d.ts create mode 100644 react-router/react-router-tests.tsx create mode 100644 react-router/react-router-tests.tsx.tscparams diff --git a/react-redux/react-redux-tests.tsx b/react-redux/react-redux-tests.tsx index 9bd662295a..eb2a5b5bc1 100644 --- a/react-redux/react-redux-tests.tsx +++ b/react-redux/react-redux-tests.tsx @@ -1,7 +1,7 @@ /// /// /// -/// +/// /// import { Component } from 'react'; diff --git a/react-router/history.d.ts b/react-router/history.d.ts index e432a2418c..c982bd2299 100644 --- a/react-router/history.d.ts +++ b/react-router/history.d.ts @@ -63,10 +63,9 @@ declare namespace HistoryModule { type TransitionHook = (location: Location, callback: Function) => any - // Global usage, without modules, needs the small trick, because lib.d.ts - // already has `history` and `History` global definitions: - // var history_: HistoryModule.Module = window['History']; - // history_.createHistory(); + // Global usage, without modules, needs the small trick, because lib.d.ts + // already has `history` and `History` global definitions: + // var createHistory = ((window as any).History as HistoryModule.Module).createHistory; interface Module { createHistory: CreateHistory createHashHistory: CreateHistory diff --git a/react-router/react-router-0.13.3.d.ts b/react-router/react-router-0.13.3.d.ts new file mode 100644 index 0000000000..4cebcfab36 --- /dev/null +++ b/react-router/react-router-0.13.3.d.ts @@ -0,0 +1,354 @@ +// Type definitions for React Router 0.13.3 +// Project: https://github.com/rackt/react-router +// Definitions by: Yuichi Murata , Václav Ostrožlík +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module ReactRouter { + import React = __React; + + // + // Transition + // ---------------------------------------------------------------------- + interface Transition { + path: string; + abortReason: any; + retry(): void; + abort(reason?: any): void; + redirect(to: string, params?: {}, query?: {}): void; + cancel(): void; + from: (transition: Transition, routes: Route[], components?: React.ReactElement[], callback?: (error?: any) => void) => void; + to: (transition: Transition, routes: Route[], params?: {}, query?: {}, callback?: (error?: any) => void) => void; + } + + interface TransitionStaticLifecycle { + willTransitionTo?( + transition: Transition, + params: {}, + query: {}, + callback: Function + ): void; + + willTransitionFrom?( + transition: Transition, + component: React.ReactElement, + callback: Function + ): void; + } + + // + // Route Configuration + // ---------------------------------------------------------------------- + // DefaultRoute + interface DefaultRouteProp { + name?: string; + handler: React.ComponentClass; + } + interface DefaultRoute extends React.ReactElement {} + interface DefaultRouteClass extends React.ComponentClass {} + + // NotFoundRoute + interface NotFoundRouteProp { + name?: string; + handler: React.ComponentClass; + } + interface NotFoundRoute extends React.ReactElement {} + interface NotFoundRouteClass extends React.ComponentClass {} + + // Redirect + interface RedirectProp { + path?: string; + from?: string; + to?: string; + } + interface Redirect extends React.ReactElement {} + interface RedirectClass extends React.ComponentClass {} + + // Route + interface RouteProp { + name?: string; + path?: string; + handler?: React.ComponentClass; + ignoreScrollBehavior?: boolean; + } + interface Route extends React.ReactElement {} + interface RouteClass extends React.ComponentClass {} + + var DefaultRoute: DefaultRouteClass; + var NotFoundRoute: NotFoundRouteClass; + var Redirect: RedirectClass; + var Route: RouteClass; + + interface CreateRouteOptions { + name?: string; + path?: string; + ignoreScrollBehavior?: boolean; + isDefault?: boolean; + isNotFound?: boolean; + onEnter?: (transition: Transition, params: {}, query: {}, callback: Function) => void; + onLeave?: (transition: Transition, wtf: any, callback: Function) => void; + handler?: Function; + parentRoute?: Route; + } + + type CreateRouteCallback = (route: Route) => void; + + function createRoute(callback: CreateRouteCallback): Route; + function createRoute(options: CreateRouteOptions | string, callback: CreateRouteCallback): Route; + function createDefaultRoute(options?: CreateRouteOptions | string): Route; + function createNotFoundRoute(options?: CreateRouteOptions | string): Route; + + interface CreateRedirectOptions extends CreateRouteOptions { + path?: string; + from?: string; + to: string; + params?: {}; + query?: {}; + } + function createRedirect(options: CreateRedirectOptions): Redirect; + function createRoutesFromReactChildren(children: Route): Route[]; + + // + // Components + // ---------------------------------------------------------------------- + // Link + interface LinkProp extends React.HTMLAttributes { + activeClassName?: string; + activeStyle?: {}; + to: string; + params?: {}; + query?: {}; + } + interface Link extends React.ReactElement, Navigation, State { + handleClick(event: any): void; + getHref(): string; + getClassName(): string; + getActiveState(): boolean; + } + interface LinkClass extends React.ComponentClass {} + + // RouteHandler + interface RouteHandlerProp { } + interface RouteHandlerChildContext { + routeDepth: number; + } + interface RouteHandler extends React.ReactElement { + getChildContext(): RouteHandlerChildContext; + getRouteDepth(): number; + createChildRouteHandler(props: {}): RouteHandler; + } + interface RouteHandlerClass extends React.ComponentClass {} + + var Link: LinkClass; + var RouteHandler: RouteHandlerClass; + + + // + // Top-Level + // ---------------------------------------------------------------------- + interface Router extends React.ReactElement { + run(callback: RouterRunCallback): void; + } + + interface RouterState { + path: string; + action: string; + pathname: string; + params: {}; + query: {}; + routes: Route[]; + } + + interface RouterCreateOption { + routes: Route; + location?: LocationBase; + scrollBehavior?: ScrollBehaviorBase; + onError?: (error: any) => void; + onAbort?: (error: any) => void; + } + + type RouterRunCallback = (Handler: RouteClass, state: RouterState) => void; + + function create(options: RouterCreateOption): Router; + function run(routes: Route, callback: RouterRunCallback): Router; + function run(routes: Route, location: LocationBase | string, callback: RouterRunCallback): Router; + + + // + // Location + // ---------------------------------------------------------------------- + interface LocationBase { + getCurrentPath(): void; + toString(): string; + } + interface Location extends LocationBase { + push(path: string): void; + replace(path: string): void; + pop(): void; + } + + interface LocationListener { + addChangeListener(listener: Function): void; + removeChangeListener(listener: Function): void; + } + + interface HashLocation extends Location, LocationListener { } + interface HistoryLocation extends Location, LocationListener { } + interface RefreshLocation extends Location { } + interface StaticLocation extends LocationBase { } + interface TestLocation extends Location, LocationListener { } + + var HashLocation: HashLocation; + var HistoryLocation: HistoryLocation; + var RefreshLocation: RefreshLocation; + var StaticLocation: StaticLocation; + var TestLocation: TestLocation; + + + // + // Behavior + // ---------------------------------------------------------------------- + interface ScrollBehaviorBase { + updateScrollPosition(position: { x: number; y: number; }, actionType: string): void; + } + interface ImitateBrowserBehavior extends ScrollBehaviorBase { } + interface ScrollToTopBehavior extends ScrollBehaviorBase { } + + var ImitateBrowserBehavior: ImitateBrowserBehavior; + var ScrollToTopBehavior: ScrollToTopBehavior; + + + // + // Mixin + // ---------------------------------------------------------------------- + interface Navigation { + makePath(to: string, params?: {}, query?: {}): string; + makeHref(to: string, params?: {}, query?: {}): string; + transitionTo(to: string, params?: {}, query?: {}): void; + replaceWith(to: string, params?: {}, query?: {}): void; + goBack(): void; + } + + interface State { + getPath(): string; + getRoutes(): Route[]; + getPathname(): string; + getParams(): {}; + getQuery(): {}; + isActive(to: string, params?: {}, query?: {}): boolean; + } + + var Navigation: Navigation; + var State: State; + + + // + // History + // ---------------------------------------------------------------------- + interface History { + back(): void; + length: number; + } + var History: History; + + + // + // Context + // ---------------------------------------------------------------------- + interface Context { + makePath(to: string, params?: {}, query?: {}): string; + makeHref(to: string, params?: {}, query?: {}): string; + transitionTo(to: string, params?: {}, query?: {}): void; + replaceWith(to: string, params?: {}, query?: {}): void; + goBack(): void; + + getCurrentPath(): string; + getCurrentRoutes(): Route[]; + getCurrentPathname(): string; + getCurrentParams(): {}; + getCurrentQuery(): {}; + isActive(to: string, params?: {}, query?: {}): boolean; + } +} + +declare module "react-router" { + export = ReactRouter; +} + +declare module __React { + + // for DefaultRoute + function createElement( + type: ReactRouter.DefaultRouteClass, + props: ReactRouter.DefaultRouteProp, + ...children: __React.ReactNode[]): ReactRouter.DefaultRoute; + + // for Link + function createElement( + type: ReactRouter.LinkClass, + props: ReactRouter.LinkProp, + ...children: __React.ReactNode[]): ReactRouter.Link; + + // for NotFoundRoute + function createElement( + type: ReactRouter.NotFoundRouteClass, + props: ReactRouter.NotFoundRouteProp, + ...children: __React.ReactNode[]): ReactRouter.NotFoundRoute; + + // for Redirect + function createElement( + type: ReactRouter.RedirectClass, + props: ReactRouter.RedirectProp, + ...children: __React.ReactNode[]): ReactRouter.Redirect; + + // for Route + function createElement( + type: ReactRouter.RouteClass, + props: ReactRouter.RouteProp, + ...children: __React.ReactNode[]): ReactRouter.Route; + + // for RouteHandler + function createElement( + type: ReactRouter.RouteHandlerClass, + props: ReactRouter.RouteHandlerProp, + ...children: __React.ReactNode[]): ReactRouter.RouteHandler; +} + +declare module "react/addons" { + // for DefaultRoute + function createElement( + type: ReactRouter.DefaultRouteClass, + props: ReactRouter.DefaultRouteProp, + ...children: __React.ReactNode[]): ReactRouter.DefaultRoute; + + // for Link + function createElement( + type: ReactRouter.LinkClass, + props: ReactRouter.LinkProp, + ...children: __React.ReactNode[]): ReactRouter.Link; + + // for NotFoundRoute + function createElement( + type: ReactRouter.NotFoundRouteClass, + props: ReactRouter.NotFoundRouteProp, + ...children: __React.ReactNode[]): ReactRouter.NotFoundRoute; + + // for Redirect + function createElement( + type: ReactRouter.RedirectClass, + props: ReactRouter.RedirectProp, + ...children: __React.ReactNode[]): ReactRouter.Redirect; + + // for Route + function createElement( + type: ReactRouter.RouteClass, + props: ReactRouter.RouteProp, + ...children: __React.ReactNode[]): ReactRouter.Route; + + // for RouteHandler + function createElement( + type: ReactRouter.RouteHandlerClass, + props: ReactRouter.RouteHandlerProp, + ...children: __React.ReactNode[]): ReactRouter.RouteHandler; +} diff --git a/react-router/react-router-tests.tsx b/react-router/react-router-tests.tsx new file mode 100644 index 0000000000..4c2abc7ef7 --- /dev/null +++ b/react-router/react-router-tests.tsx @@ -0,0 +1,67 @@ + +/// +/// +/// + + +import * as React from "react"; + +import { Router, Route, IndexRoute, Link } from "react-router"; + +import createHistory from "history/lib/createBrowserHistory" + + +class Master extends React.Component, {}> { + + render() { + return
+

Master

+ Dashboard Users +

{this.props.children}

+
+ } + +} + + +class Dashboard extends React.Component<{}, {}> { + + render() { + return
+ This is a dashboard +
+ } + +} + +class NotFound extends React.Component<{}, {}> { + + render() { + return
+ This path does not exists +
+ } + +} + + +class Users extends React.Component<{}, {}> { + + render() { + return
+ This is a user list +
+ } + +} + + +React.render(( + + + + + + + +), document.body) diff --git a/react-router/react-router-tests.tsx.tscparams b/react-router/react-router-tests.tsx.tscparams new file mode 100644 index 0000000000..f479837784 --- /dev/null +++ b/react-router/react-router-tests.tsx.tscparams @@ -0,0 +1 @@ +--noImplicitAny -jsx react --target es5 \ No newline at end of file diff --git a/react-router/react-router.d.ts b/react-router/react-router.d.ts index c96fe284dc..2a6445a3f1 100644 --- a/react-router/react-router.d.ts +++ b/react-router/react-router.d.ts @@ -26,16 +26,16 @@ declare namespace ReactRouter { type RedirectFunction = (state: H.LocationState, pathname: H.Pathname | H.Path, query?: H.Query) => void - interface RouteComponentProps { + interface RouteComponentProps { history?: History location?: Location - params?: Params + params?: P route?: PlainRoute - routeParams?: Params + routeParams?: R routes?: PlainRoute[] } - type RouteComponent = React.ComponentClass + type RouteComponent = React.ComponentClass type RouteConfig = RouteObject[] From f0d5440f90b1c40292a1c345d75bdc8656cded18 Mon Sep 17 00:00:00 2001 From: Sergey Buturlakin Date: Thu, 1 Oct 2015 11:03:39 +0300 Subject: [PATCH 0021/1238] Micro update of createRoutes export --- react-router/react-router.d.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/react-router/react-router.d.ts b/react-router/react-router.d.ts index 2a6445a3f1..3869978764 100644 --- a/react-router/react-router.d.ts +++ b/react-router/react-router.d.ts @@ -280,9 +280,7 @@ declare module "react-router/lib/RouteUtils" { export function createRoutesFromReactChildren(children: E | E[], parentRoute: ReactRouter.PlainRoute): ReactRouter.PlainRoute[] - import createRoutes = ReactRouter.createRoutes - - export { createRoutes } + export import createRoutes = ReactRouter.createRoutes } From 0d64ea1b82ad1d804892ceec14d98a9be85f64fb Mon Sep 17 00:00:00 2001 From: Sergey Buturlakin Date: Thu, 1 Oct 2015 12:31:03 +0300 Subject: [PATCH 0022/1238] History enhancers definitions improved using union types --- react-router/history.d.ts | 42 ++++++++++++++++++------------ react-router/react-router.d.ts | 47 +++++++++++++++++++--------------- 2 files changed, 52 insertions(+), 37 deletions(-) diff --git a/react-router/history.d.ts b/react-router/history.d.ts index c982bd2299..2d88184e68 100644 --- a/react-router/history.d.ts +++ b/react-router/history.d.ts @@ -12,12 +12,13 @@ declare namespace HistoryModule { type BeforeUnloadHook = () => string - type CreateHistory = (options?: HistoryOptions) => History + type CreateHistory = (options?: HistoryOptions) => T - type CreateHistoryEnhancer = (createHistory: CreateHistory) => CreateHistory + type CreateHistoryEnhancer = (createHistory: CreateHistory) => CreateHistory - interface HistoryBase { + interface History { listenBefore(hook: TransitionHook): Function + listen(listener: LocationListener): Function transitionTo(location: Location): void pushState(state: LocationState, path: Path): void replaceState(state: LocationState, path: Path): void @@ -30,10 +31,6 @@ declare namespace HistoryModule { createHref(path: Path): Href } - interface History { - listen(listener: LocationListener): Function - } - type HistoryOptions = Object type Href = string @@ -63,17 +60,30 @@ declare namespace HistoryModule { type TransitionHook = (location: Location, callback: Function) => any + + interface HistoryBeforeUnload { + listenBeforeUnload(hook: () => string | boolean): Function + } + + interface HistoryQueries { + pushState(state: LocationState, pathname: Pathname | Path, query?: Query): void + replaceState(state: LocationState, pathname: Pathname | Path, query?: Query): void + createPath(path: Path, query?: Query): Path + createHref(path: Path, query?: Query): Href + } + + // Global usage, without modules, needs the small trick, because lib.d.ts // already has `history` and `History` global definitions: // var createHistory = ((window as any).History as HistoryModule.Module).createHistory; interface Module { - createHistory: CreateHistory - createHashHistory: CreateHistory - createMemoryHistory: CreateHistory + createHistory: CreateHistory + createHashHistory: CreateHistory + createMemoryHistory: CreateHistory createLocation(): Location - useBasename(enhancer: CreateHistoryEnhancer): CreateHistory - useBeforeUnload(enhancer: CreateHistoryEnhancer): CreateHistory - useQueries(enhancer: CreateHistoryEnhancer): CreateHistory + useBasename(createHistory: CreateHistory): CreateHistory + useBeforeUnload(createHistory: CreateHistory): CreateHistory + useQueries(createHistory: CreateHistory): CreateHistory actions: { PUSH: string REPLACE: string @@ -114,21 +124,21 @@ declare module "history/lib/createLocation" { declare module "history/lib/useBasename" { - export default function useBasename(enhancer: HistoryModule.CreateHistoryEnhancer): HistoryModule.CreateHistory + export default function useBasename(createHistory: HistoryModule.CreateHistory): HistoryModule.CreateHistory } declare module "history/lib/useBeforeUnload" { - export default function useBeforeUnload(enhancer: HistoryModule.CreateHistoryEnhancer): HistoryModule.CreateHistory + export default function useBeforeUnload(createHistory: HistoryModule.CreateHistory): HistoryModule.CreateHistory } declare module "history/lib/useQueries" { - export default function useQueries(enhancer: HistoryModule.CreateHistoryEnhancer): HistoryModule.CreateHistory + export default function useQueries(createHistory: HistoryModule.CreateHistory): HistoryModule.CreateHistory } diff --git a/react-router/react-router.d.ts b/react-router/react-router.d.ts index 3869978764..0834954048 100644 --- a/react-router/react-router.d.ts +++ b/react-router/react-router.d.ts @@ -16,6 +16,8 @@ declare namespace ReactRouter { type Component = React.ReactType + type Components = { [key: string]: Component } + type EnterHook = (nextState: RouterState, replaceState: RedirectFunction, callback?: Function) => any type LeaveHook = () => any @@ -47,24 +49,6 @@ declare namespace ReactRouter { type StringifyQuery = (queryObject: H.Query) => H.QueryString - - interface History extends H.HistoryBase { - pushState(state: H.LocationState, pathname: H.Pathname | H.Path, query?: H.Query): void - replaceState(state: H.LocationState, pathname: H.Pathname | H.Path, query?: H.Query): void - createPath(path: H.Path, query?: H.Query): H.Path - createHref(path: H.Path, query?: H.Query): H.Href - isActive(pathname: H.Pathname, query: H.Query): boolean - registerRouteHook(route: PlainRoute, hook: H.LocationListener): void - unregisterRouteHook(route: PlainRoute, hook: H.LocationListener): void - listen(listener: RouterListener): Function - match(location: H.Location, callback: (error: any, nextState: RouterState, nextLocation: H.Location) => void): void - routes: PlainRoute[] - parseQueryString?: ParseQueryString - stringifyQuery?: StringifyQuery - } - - type RouterListener = (error: Error, nextState: RouterState) => void - interface RouterState { location: Location routes: RouteConfig @@ -72,12 +56,18 @@ declare namespace ReactRouter { components: Component[] } - type RouteType = Route | IndexRoute | PlainRoute | Redirect type RouteTypes = RouteType | RouteType[] - type Components = { [key: string]: Component } + + interface HistoryBase extends H.History { + routes: PlainRoute[] + parseQueryString?: ParseQueryString + stringifyQuery?: StringifyQuery + } + + type History = HistoryBase & H.HistoryQueries & HistoryRoutes interface RouterProps { @@ -179,10 +169,22 @@ declare namespace ReactRouter { const History: React.Mixin - function useRoutes(enhancer: H.CreateHistoryEnhancer): H.CreateHistory + type RouterListener = (error: Error, nextState: RouterState) => void + + interface HistoryRoutes { + isActive(pathname: H.Pathname, query: H.Query): boolean + registerRouteHook(route: PlainRoute, hook: H.LocationListener): void + unregisterRouteHook(route: PlainRoute, hook: H.LocationListener): void + listen(listener: RouterListener): Function + match(location: H.Location, callback: (error: any, nextState: RouterState, nextLocation: H.Location) => void): void + } + + function useRoutes(createHistory: HistoryModule.CreateHistory): HistoryModule.CreateHistory + function createRoutes(routes: RouteTypes): PlainRoute[] + interface MatchArgs { routes?: RouteTypes history?: H.History @@ -345,6 +347,8 @@ declare module "react-router" { import RouteContext from "react-router/lib/RouteContext" + import useRoutes from "react-router/lib/useRoutes" + import { createRoutes } from "react-router/lib/RouteUtils" import RoutingContext from "react-router/lib/RoutingContext" @@ -362,6 +366,7 @@ declare module "react-router" { History, Lifecycle, RouteContext, + useRoutes, createRoutes, RoutingContext, PropTypes, From 29485a77a86145ac34d189372ae5a35e1cec1011 Mon Sep 17 00:00:00 2001 From: Alexandru Ciuca Date: Fri, 2 Oct 2015 19:09:05 +0300 Subject: [PATCH 0023/1238] material-ui - Also export types in named modules --- material-ui/material-ui-tests.tsx | 23 +-- material-ui/material-ui.d.ts | 292 +++++++++++++++++++----------- 2 files changed, 200 insertions(+), 115 deletions(-) diff --git a/material-ui/material-ui-tests.tsx b/material-ui/material-ui-tests.tsx index 39691caa84..4c69f34104 100644 --- a/material-ui/material-ui-tests.tsx +++ b/material-ui/material-ui-tests.tsx @@ -2,7 +2,7 @@ /// import * as React from "react/addons"; -import mui = require("material-ui"); +import Checkbox = require("material-ui/lib/checkbox"); import Colors = require("material-ui/lib/styles/colors"); import AppBar = require("material-ui/lib/app-bar"); import IconButton = require("material-ui/lib/icon-button"); @@ -27,6 +27,7 @@ import IconMenu = require("material-ui/lib/menus/icon-menu"); import Menu = require('material-ui/lib/menus/menu'); import MenuItem = require('material-ui/lib/menus/menu-item'); import MenuDivider = require('material-ui/lib/menus/menu-divider'); +import ThemeManager = require('material-ui/lib/styles/theme-manager'); import NavigationClose = require("material-ui/lib/svg-icon"); // TODO: Should actually import the actual "material-ui/lib/svg-icons/navigation/close", but they aren't defined yet. import FileFolder = require("material-ui/lib/svg-icon"); // TODO: Should actually import the actual "material-ui/lib/svg-icons/file/folder", but they aren't defined yet. @@ -35,37 +36,37 @@ import ActionGrade = require("material-ui/lib/svg-icon"); // TODO: Should actua import ToggleStarBorder = require("material-ui/lib/svg-icon"); // TODO: Should actually import the actual "material-ui/lib/svg-icons/toggle/star-border", but they aren't defined yet. import ArrowDropRight = require("material-ui/lib/svg-icon"); // TODO: Should actually import the actual "material-ui/lib/svg-icons/toggle/star-border", but they aren't defined yet. +type CheckboxProps = __MaterialUI.CheckboxProps; +type MuiTheme = __MaterialUI.Styles.MuiTheme; +type TouchTapEvent = __MaterialUI.TouchTapEvent; + class MaterialUiTests extends React.Component<{}, {}> implements React.LinkedStateMixin { // injected with mixin linkState: (key: string) => React.ReactLink; - dialog: mui.Dialog; - //dialog2: Dialog; // can't get type directly from require("material-ui/lib/dialog"); + dialog: Dialog; - private touchTapEventHandler(e: __MaterialUI.TouchTapEvent) { + private touchTapEventHandler(e: TouchTapEvent) { this.dialog.show(); - //this.dialog2.show(); } private formEventHandler(e: React.FormEvent) { } - private selectFieldChangeHandler(e: __MaterialUI.TouchTapEvent, si: number, mi: any) { + private selectFieldChangeHandler(e: TouchTapEvent, si: number, mi: any) { } render() { // "http://material-ui.com/#/customization/themes" - let ThemeManager = mui.Styles.ThemeManager; - let muiTheme: mui.Styles.MuiTheme = ThemeManager.getMuiTheme({ + let muiTheme: MuiTheme = ThemeManager.getMuiTheme({ palette: { accent1Color: Colors.cyan100 }, spacing: { - + } }); // "http://material-ui.com/#/customization/inline-styles" - let Checkbox = mui.Checkbox; let element: React.ReactElement; element = implements React.LinkedSta iconStyle={{ fill: '#FF4081' }}/> - element = React.createElement<__MaterialUI.CheckboxProps>(Checkbox, { + element = React.createElement(Checkbox, { id: "checkboxId1", name: "checkboxName1", value: "checkboxValue1", label: "went for a run today", style: { width: '50%', margin: '0 auto' diff --git a/material-ui/material-ui.d.ts b/material-ui/material-ui.d.ts index 87bd32a09b..3bb7f37625 100644 --- a/material-ui/material-ui.d.ts +++ b/material-ui/material-ui.d.ts @@ -6,8 +6,6 @@ /// declare module "material-ui" { - // The reason for exporting the namespace types (__MaterialUI.*) is to also export the type for casting variable. - export import AppBar = __MaterialUI.AppBar; // require('material-ui/lib/app-bar'); export import AppCanvas = __MaterialUI.AppCanvas; // require('material-ui/lib/app-canvas'); export import Avatar = __MaterialUI.Avatar; // require('material-ui/lib/avatar'); @@ -51,16 +49,7 @@ declare module "material-ui" { export import SelectField = __MaterialUI.SelectField; // require('material-ui/lib/select-field'); export import Slider = __MaterialUI.Slider; // require('material-ui/lib/slider'); export import SvgIcon = __MaterialUI.SvgIcon; // require('material-ui/lib/svg-icon'); - - import NavigationMenu = require('material-ui/lib/svg-icons/navigation/menu'); - import NavigationChevronLeft = require('material-ui/lib/svg-icons/navigation/chevron-left'); - import NavigationChevronRight = require('material-ui/lib/svg-icons/navigation/chevron-right'); - export var Icons: { - NavigationMenu: __MaterialUI.NavigationMenu; - NavigationChevronLeft: __MaterialUI.NavigationChevronLeft; - NavigationChevronRight: __MaterialUI.NavigationChevronRight; - }; - + export import Icons = __MaterialUI.Icons; export import Styles = __MaterialUI.Styles; // require('material-ui/lib/styles/'); export import Snackbar = __MaterialUI.Snackbar; // require('material-ui/lib/snackbar'); export import Tab = __MaterialUI.Tabs.Tab; // require('material-ui/lib/tabs/tab'); @@ -84,9 +73,9 @@ declare module "material-ui" { export import Utils = __MaterialUI.Utils; // require('material-ui/lib/utils/'); // export type definitions - export import TouchTapEvent = __MaterialUI.TouchTapEvent; - export import TouchTapEventHandler = __MaterialUI.TouchTapEventHandler; - export import DialogAction = __MaterialUI.DialogAction; + export type TouchTapEvent = __MaterialUI.TouchTapEvent; + export type TouchTapEventHandler = __MaterialUI.TouchTapEventHandler; + export type DialogAction = __MaterialUI.DialogAction; } declare namespace __MaterialUI { @@ -805,6 +794,12 @@ declare namespace __MaterialUI { export class SvgIcon extends React.Component { } + export namespace Icons { + export import NavigationMenu = __MaterialUI.NavigationMenu; + export import NavigationChevronLeft = __MaterialUI.NavigationChevronLeft; + export import NavigationChevronRight = __MaterialUI.NavigationChevronRight; + } + interface NavigationMenuProps extends React.Props { } export class NavigationMenu extends React.Component { @@ -1478,127 +1473,158 @@ declare namespace __MaterialUI { } // __MaterialUI declare module 'material-ui/lib/app-bar' { - export = __MaterialUI.AppBar; + import AppBar = __MaterialUI.AppBar; + export = AppBar; } declare module 'material-ui/lib/app-canvas' { - export = __MaterialUI.AppCanvas; + import AppCanvas = __MaterialUI.AppCanvas; + export = AppCanvas; } declare module 'material-ui/lib/avatar' { - export = __MaterialUI.Avatar; + import Avatar = __MaterialUI.Avatar; + export = Avatar; } declare module 'material-ui/lib/before-after-wrapper' { - export = __MaterialUI.BeforeAfterWrapper; + import BeforeAfterWrapper = __MaterialUI.BeforeAfterWrapper; + export = BeforeAfterWrapper; } declare module 'material-ui/lib/card/card' { - export = __MaterialUI.Card.Card; + import Card = __MaterialUI.Card.Card; + export = Card; } declare module 'material-ui/lib/card/card-actions' { - export = __MaterialUI.Card.CardActions; + import CardActions = __MaterialUI.Card.CardActions; + export = CardActions; } declare module 'material-ui/lib/card/card-expandable' { - export = __MaterialUI.Card.CardExpandable; + import CardExpandable = __MaterialUI.Card.CardExpandable; + export = CardExpandable; } declare module 'material-ui/lib/card/card-header' { - export = __MaterialUI.Card.CardHeader; + import CardHeader = __MaterialUI.Card.CardHeader; + export = CardHeader; } declare module 'material-ui/lib/card/card-media' { - export = __MaterialUI.Card.CardMedia; + import CardMedia = __MaterialUI.Card.CardMedia; + export = CardMedia; } declare module 'material-ui/lib/card/card-text' { - export = __MaterialUI.Card.CardText; + import CardText = __MaterialUI.Card.CardText; + export = CardText; } declare module 'material-ui/lib/card/card-title' { - export = __MaterialUI.Card.CardTitle; + import CardTitle = __MaterialUI.Card.CardTitle; + export = CardTitle; } declare module 'material-ui/lib/checkbox' { - export = __MaterialUI.Checkbox; + import Checkbox = __MaterialUI.Checkbox; + export = Checkbox; } declare module 'material-ui/lib/circular-progress' { - export = __MaterialUI.CircularProgress; + import CircularProgress = __MaterialUI.CircularProgress; + export = CircularProgress; } declare module 'material-ui/lib/clearfix' { - export = __MaterialUI.ClearFix; + import ClearFix = __MaterialUI.ClearFix; + export = ClearFix; } declare module 'material-ui/lib/date-picker/date-picker' { - export = __MaterialUI.DatePicker.DatePicker; + import DatePicker = __MaterialUI.DatePicker.DatePicker; + export = DatePicker; } declare module 'material-ui/lib/date-picker/date-picker-dialog' { - export = __MaterialUI.DatePicker.DatePickerDialog; + import DatePickerDialog = __MaterialUI.DatePicker.DatePickerDialog; + export = DatePickerDialog; } declare module 'material-ui/lib/dialog' { - export = __MaterialUI.Dialog; + import Dialog = __MaterialUI.Dialog; + export = Dialog; } declare module 'material-ui/lib/drop-down-icon' { - export = __MaterialUI.DropDownIcon; + import DropDownIcon = __MaterialUI.DropDownIcon; + export = DropDownIcon; } declare module 'material-ui/lib/drop-down-menu' { - export = __MaterialUI.DropDownMenu; + import DropDownMenu = __MaterialUI.DropDownMenu; + export = DropDownMenu; } declare module 'material-ui/lib/enhanced-button' { - export = __MaterialUI.EnhancedButton; + import EnhancedButton = __MaterialUI.EnhancedButton; + export = EnhancedButton; } declare module 'material-ui/lib/flat-button' { - export = __MaterialUI.FlatButton; + import FlatButton = __MaterialUI.FlatButton; + export = FlatButton; } declare module 'material-ui/lib/floating-action-button' { - export = __MaterialUI.FloatingActionButton; + import FloatingActionButton = __MaterialUI.FloatingActionButton; + export = FloatingActionButton; } declare module 'material-ui/lib/font-icon' { - export = __MaterialUI.FontIcon; + import FontIcon = __MaterialUI.FontIcon; + export = FontIcon; } declare module 'material-ui/lib/icon-button' { - export = __MaterialUI.IconButton; + import IconButton = __MaterialUI.IconButton; + export = IconButton; } declare module 'material-ui/lib/left-nav' { - export = __MaterialUI.LeftNav; + import LeftNav = __MaterialUI.LeftNav; + export = LeftNav; } declare module 'material-ui/lib/linear-progress' { - export = __MaterialUI.LinearProgress; + import LinearProgress = __MaterialUI.LinearProgress; + export = LinearProgress; } declare module 'material-ui/lib/lists/list' { - export = __MaterialUI.Lists.List; + import List = __MaterialUI.Lists.List; + export = List; } declare module 'material-ui/lib/lists/list-divider' { - export = __MaterialUI.Lists.ListDivider; + import ListDivider = __MaterialUI.Lists.ListDivider; + export = ListDivider; } declare module 'material-ui/lib/lists/list-item' { - export = __MaterialUI.Lists.ListItem; + import ListItem = __MaterialUI.Lists.ListItem; + export = ListItem; } declare module 'material-ui/lib/menu/menu' { - export = __MaterialUI.Menu.Menu; + import Menu = __MaterialUI.Menu.Menu; + export = Menu; } declare module 'material-ui/lib/menu/menu-item' { - export = __MaterialUI.Menu.MenuItem; + import MenuItem = __MaterialUI.Menu.MenuItem; + export = MenuItem; } declare module 'material-ui/lib/mixins/' { @@ -1609,43 +1635,53 @@ declare module 'material-ui/lib/mixins/' { } declare module 'material-ui/lib/mixins/click-awayable' { - export = __MaterialUI.Mixins.ClickAwayable; + import ClickAwayable = __MaterialUI.Mixins.ClickAwayable; + export = ClickAwayable; } declare module 'material-ui/lib/mixins/window-listenable' { - export = __MaterialUI.Mixins.WindowListenable; + import WindowListenable = __MaterialUI.Mixins.WindowListenable; + export = WindowListenable; } declare module 'material-ui/lib/mixins/style-propable' { - export = __MaterialUI.Mixins.StylePropable; + import StylePropable = __MaterialUI.Mixins.StylePropable; + export = StylePropable; } declare module 'material-ui/lib/mixins/style-resizable' { - export = __MaterialUI.Mixins.StyleResizable; + import StyleResizable = __MaterialUI.Mixins.StyleResizable; + export = StyleResizable; } declare module 'material-ui/lib/overlay' { - export = __MaterialUI.Overlay; + import Overlay = __MaterialUI.Overlay; + export = Overlay; } declare module 'material-ui/lib/paper' { - export = __MaterialUI.Paper; + import Paper = __MaterialUI.Paper; + export = Paper; } declare module 'material-ui/lib/radio-button' { - export = __MaterialUI.RadioButton; + import RadioButton = __MaterialUI.RadioButton; + export = RadioButton; } declare module 'material-ui/lib/radio-button-group' { - export = __MaterialUI.RadioButtonGroup; + import RadioButtonGroup = __MaterialUI.RadioButtonGroup; + export = RadioButtonGroup; } declare module 'material-ui/lib/raised-button' { - export = __MaterialUI.RaisedButton; + import RaisedButton = __MaterialUI.RaisedButton; + export = RaisedButton; } declare module 'material-ui/lib/refresh-indicator' { - export = __MaterialUI.RefreshIndicator; + import RefreshIndicator = __MaterialUI.RefreshIndicator; + export = RefreshIndicator; } declare module 'material-ui/lib/ripples/' { @@ -1655,27 +1691,33 @@ declare module 'material-ui/lib/ripples/' { } declare module 'material-ui/lib/select-field' { - export = __MaterialUI.SelectField; + import SelectField = __MaterialUI.SelectField; + export = SelectField; } declare module 'material-ui/lib/slider' { - export = __MaterialUI.Slider; + import Slider = __MaterialUI.Slider; + export = Slider; } declare module 'material-ui/lib/svg-icon' { - export = __MaterialUI.SvgIcon; + import SvgIcon = __MaterialUI.SvgIcon; + export = SvgIcon; } declare module 'material-ui/lib/svg-icons/navigation/menu' { - export = __MaterialUI.NavigationMenu; + import NavigationMenu = __MaterialUI.NavigationMenu; + export = NavigationMenu; } declare module 'material-ui/lib/svg-icons/navigation/chevron-left' { - export = __MaterialUI.NavigationChevronLeft; + import NavigationChevronLeft = __MaterialUI.NavigationChevronLeft; + export = NavigationChevronLeft; } declare module 'material-ui/lib/svg-icons/navigation/chevron-right' { - export = __MaterialUI.NavigationChevronRight; + import NavigationChevronRight = __MaterialUI.NavigationChevronRight; + export = NavigationChevronRight; } declare module 'material-ui/lib/styles/' { @@ -1691,113 +1733,140 @@ declare module 'material-ui/lib/styles/' { } declare module 'material-ui/lib/styles/auto-prefix' { - export = __MaterialUI.Styles.AutoPrefix; + import AutoPrefix = __MaterialUI.Styles.AutoPrefix; + export = AutoPrefix; } declare module 'material-ui/lib/styles/spacing' { - var Spacing: __MaterialUI.Styles.Spacing; + type Spacing = __MaterialUI.Styles.Spacing; + var Spacing: Spacing; export = Spacing; } declare module 'material-ui/lib/styles/theme-manager' { - export = __MaterialUI.Styles.ThemeManager; + import ThemeManager = __MaterialUI.Styles.ThemeManager; + export = ThemeManager; } declare module 'material-ui/lib/styles/transitions' { - export = __MaterialUI.Styles.Transitions; + import Transitions = __MaterialUI.Styles.Transitions; + export = Transitions; } declare module 'material-ui/lib/styles/typography' { - export = __MaterialUI.Styles.Typography; + import Typography = __MaterialUI.Styles.Typography; + export = Typography; } declare module 'material-ui/lib/styles/raw-themes/light-raw-theme' { - export = __MaterialUI.Styles.LightRawTheme; + import LightRawTheme = __MaterialUI.Styles.LightRawTheme; + export = LightRawTheme; } declare module 'material-ui/lib/styles/raw-themes/dark-raw-theme' { - export = __MaterialUI.Styles.DarkRawTheme; + import DarkRawTheme = __MaterialUI.Styles.DarkRawTheme; + export = DarkRawTheme; } declare module 'material-ui/lib/styles/theme-decorator' { - export = __MaterialUI.Styles.ThemeDecorator; + import ThemeDecorator = __MaterialUI.Styles.ThemeDecorator; + export = ThemeDecorator; } declare module 'material-ui/lib/snackbar' { - export = __MaterialUI.Snackbar; + import Snackbar = __MaterialUI.Snackbar; + export = Snackbar; } declare module 'material-ui/lib/tabs/tab' { - export = __MaterialUI.Tabs.Tab; + import Tab = __MaterialUI.Tabs.Tab; + export = Tab; } declare module 'material-ui/lib/tabs/tabs' { - export = __MaterialUI.Tabs.Tabs; + import Tabs = __MaterialUI.Tabs.Tabs; + export = Tabs; } declare module 'material-ui/lib/table/table' { - export = __MaterialUI.Table.Table; + import Table = __MaterialUI.Table.Table; + export = Table; } declare module 'material-ui/lib/table/table-body' { - export = __MaterialUI.Table.TableBody; + import TableBody = __MaterialUI.Table.TableBody; + export = TableBody; } declare module 'material-ui/lib/table/table-footer' { - export = __MaterialUI.Table.TableFooter; + import TableFooter = __MaterialUI.Table.TableFooter; + export = TableFooter; } declare module 'material-ui/lib/table/table-header' { - export = __MaterialUI.Table.TableHeader; + import TableHeader = __MaterialUI.Table.TableHeader; + export = TableHeader; } declare module 'material-ui/lib/table/table-header-column' { - export = __MaterialUI.Table.TableHeaderColumn; + import TableHeaderColumn = __MaterialUI.Table.TableHeaderColumn; + export = TableHeaderColumn; } declare module 'material-ui/lib/table/table-row' { - export = __MaterialUI.Table.TableRow; + import TableRow = __MaterialUI.Table.TableRow; + export = TableRow; } declare module 'material-ui/lib/table/table-row-column' { - export = __MaterialUI.Table.TableRowColumn; + import TableRowColumn = __MaterialUI.Table.TableRowColumn; + export = TableRowColumn; } declare module 'material-ui/lib/theme-wrapper' { - export = __MaterialUI.ThemeWrapper; + import ThemeWrapper = __MaterialUI.ThemeWrapper; + export = ThemeWrapper; } declare module 'material-ui/lib/toggle' { - export = __MaterialUI.Toggle; + import Toggle = __MaterialUI.Toggle; + export = Toggle; } declare module 'material-ui/lib/time-picker' { - export = __MaterialUI.TimePicker; + import TimePicker = __MaterialUI.TimePicker; + export = TimePicker; } declare module 'material-ui/lib/text-field' { - export = __MaterialUI.TextField; + import TextField = __MaterialUI.TextField; + export = TextField; } declare module 'material-ui/lib/toolbar/toolbar' { - export = __MaterialUI.Toolbar.Toolbar; + import Toolbar = __MaterialUI.Toolbar.Toolbar; + export = Toolbar; } declare module 'material-ui/lib/toolbar/toolbar-group' { - export = __MaterialUI.Toolbar.ToolbarGroup; + import ToolbarGroup = __MaterialUI.Toolbar.ToolbarGroup; + export = ToolbarGroup; } declare module 'material-ui/lib/toolbar/toolbar-separator' { - export = __MaterialUI.Toolbar.ToolbarSeparator; + import ToolbarSeparator = __MaterialUI.Toolbar.ToolbarSeparator; + export = ToolbarSeparator; } declare module 'material-ui/lib/toolbar/toolbar-title' { - export = __MaterialUI.Toolbar.ToolbarTitle; + import ToolbarTitle = __MaterialUI.Toolbar.ToolbarTitle; + export = ToolbarTitle; } declare module 'material-ui/lib/tooltip' { - export = __MaterialUI.Tooltip; + import Tooltip = __MaterialUI.Tooltip; + export = Tooltip; } declare module 'material-ui/lib/utils/' { @@ -1814,63 +1883,78 @@ declare module 'material-ui/lib/utils/' { } declare module 'material-ui/lib/utils/color-manipulator' { - export = __MaterialUI.Utils.ColorManipulator; + import ColorManipulator = __MaterialUI.Utils.ColorManipulator; + export = ColorManipulator; } declare module 'material-ui/lib/utils/css-event' { - export = __MaterialUI.Utils.CssEvent; + import CssEvent = __MaterialUI.Utils.CssEvent; + export = CssEvent; } declare module 'material-ui/lib/utils/dom' { - export = __MaterialUI.Utils.Dom; + import Dom = __MaterialUI.Utils.Dom; + export = Dom; } declare module 'material-ui/lib/utils/events' { - export = __MaterialUI.Utils.Events; + import Events = __MaterialUI.Utils.Events; + export = Events; } declare module 'material-ui/lib/utils/extend' { - export = __MaterialUI.Utils.Extend; + import Extend = __MaterialUI.Utils.Extend; + export = Extend; } declare module 'material-ui/lib/utils/immutability-helper' { - export = __MaterialUI.Utils.ImmutabilityHelper; + import ImmutabilityHelper = __MaterialUI.Utils.ImmutabilityHelper; + export = ImmutabilityHelper; } declare module 'material-ui/lib/utils/key-code' { - export = __MaterialUI.Utils.KeyCode; + import KeyCode = __MaterialUI.Utils.KeyCode; + export = KeyCode; } declare module 'material-ui/lib/utils/key-line' { - export = __MaterialUI.Utils.KeyLine; + import KeyLine = __MaterialUI.Utils.KeyLine; + export = KeyLine; } declare module 'material-ui/lib/utils/unique-id' { - export = __MaterialUI.Utils.UniqueId; + import UniqueId = __MaterialUI.Utils.UniqueId; + export = UniqueId; } declare module 'material-ui/lib/utils/styles' { - export = __MaterialUI.Utils.Styles; + import Styles = __MaterialUI.Utils.Styles; + export = Styles; } declare module "material-ui/lib/menus/icon-menu" { - export = __MaterialUI.Menus.IconMenu; + import IconMenu = __MaterialUI.Menus.IconMenu; + export = IconMenu; } declare module "material-ui/lib/menus/menu" { - export = __MaterialUI.Menus.Menu; + import Menu = __MaterialUI.Menus.Menu; + export = Menu; } declare module "material-ui/lib/menus/menu-item" { - export = __MaterialUI.Menus.MenuItem; + import MenuItem = __MaterialUI.Menus.MenuItem; + export = MenuItem; } declare module "material-ui/lib/menus/menu-divider" { - export = __MaterialUI.Menus.MenuDivider; + import MenuDivider = __MaterialUI.Menus.MenuDivider; + export = MenuDivider; } declare module "material-ui/lib/styles/colors" { - export = __MaterialUI.Styles.Colors; + import Colors = __MaterialUI.Styles.Colors; + export = Colors; } declare namespace __MaterialUI.Styles { From da423b45597264225413158966ac1278e5ec62f8 Mon Sep 17 00:00:00 2001 From: Brandon Luong Date: Fri, 2 Oct 2015 16:45:49 -0700 Subject: [PATCH 0024/1238] add LTS to longDateFormat --- moment/moment-node.d.ts | 2 ++ moment/moment-tests.ts | 2 ++ 2 files changed, 4 insertions(+) diff --git a/moment/moment-node.d.ts b/moment/moment-node.d.ts index b109893a3c..da60a5c53a 100644 --- a/moment/moment-node.d.ts +++ b/moment/moment-node.d.ts @@ -343,11 +343,13 @@ declare module moment { LLL: string; LLLL: string; LT: string; + LTS: string; l?: string; ll?: string; lll?: string; llll?: string; lt?: string; + lts?: string; } diff --git a/moment/moment-tests.ts b/moment/moment-tests.ts index 29712c1156..67724068f5 100644 --- a/moment/moment-tests.ts +++ b/moment/moment-tests.ts @@ -378,6 +378,7 @@ moment.locale('en', { moment.locale('en', { longDateFormat : { + LTS: "h:mm:ss A", LT: "h:mm A", L: "MM/DD/YYYY", l: "M/D/YYYY", @@ -392,6 +393,7 @@ moment.locale('en', { moment.locale('en', { longDateFormat : { + LTS: "h:mm A", LT: "h:mm A", L: "MM/DD/YYYY", LL: "MMMM Do YYYY", From 5570a79a99d6cd990c498abc0b480680fa2d777b Mon Sep 17 00:00:00 2001 From: Brandon Luong Date: Fri, 2 Oct 2015 16:55:58 -0700 Subject: [PATCH 0025/1238] fixing tests --- moment/moment-external-tests.ts | 3 +++ moment/moment-tests.ts | 1 + 2 files changed, 4 insertions(+) diff --git a/moment/moment-external-tests.ts b/moment/moment-external-tests.ts index ed3e1e2a82..c8108d1b99 100644 --- a/moment/moment-external-tests.ts +++ b/moment/moment-external-tests.ts @@ -255,6 +255,7 @@ moment.locale('en', { weekdaysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], weekdaysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], longDateFormat: { + LTS: "h:mm:ss A", LT: "h:mm A", L: "MM/DD/YYYY", LL: "MMMM D YYYY", @@ -376,6 +377,7 @@ moment.locale('en', { moment.locale('en', { longDateFormat : { + LTS: "h:mm:ss A", LT: "h:mm A", L: "MM/DD/YYYY", l: "M/D/YYYY", @@ -390,6 +392,7 @@ moment.locale('en', { moment.locale('en', { longDateFormat : { + LTS: "h:mm:ss A", LT: "h:mm A", L: "MM/DD/YYYY", LL: "MMMM Do YYYY", diff --git a/moment/moment-tests.ts b/moment/moment-tests.ts index 67724068f5..26b2f1d0f6 100644 --- a/moment/moment-tests.ts +++ b/moment/moment-tests.ts @@ -257,6 +257,7 @@ moment.locale('en', { weekdaysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], weekdaysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], longDateFormat: { + LTS: "h:mm:ss A", LT: "h:mm A", L: "MM/DD/YYYY", LL: "MMMM D YYYY", From 158f0715ab75c32dcef74c361b64d79a1fa305b9 Mon Sep 17 00:00:00 2001 From: Tadeusz Hucal Date: Sat, 3 Oct 2015 18:58:28 +0200 Subject: [PATCH 0026/1238] Restangular: restore synchronization with Angular's request configuration --- restangular/restangular.d.ts | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/restangular/restangular.d.ts b/restangular/restangular.d.ts index b09e4affd0..b407cefd4d 100644 --- a/restangular/restangular.d.ts +++ b/restangular/restangular.d.ts @@ -29,17 +29,6 @@ declare module restangular { $object: T[]; } - interface IRequestConfig { - params?: any; - headers?: any; - cache?: any; - withCredentials?: boolean; - data?: any; - transformRequest?: any; - transformResponse?: any; - timeout?: any; // number | promise - } - interface IResponse { status: number; data: any; @@ -65,8 +54,8 @@ declare module restangular { addResponseInterceptor(responseInterceptor: (data: any, operation: string, what: string, url: string, response: IResponse, deferred: ng.IDeferred) => any): void; setRequestInterceptor(requestInterceptor: (element: any, operation: string, what: string, url: string) => any): void; addRequestInterceptor(requestInterceptor: (element: any, operation: string, what: string, url: string) => any): void; - setFullRequestInterceptor(fullRequestInterceptor: (element: any, operation: string, what: string, url: string, headers: any, params: any, httpConfig: IRequestConfig) => {element: any; headers: any; params: any}): void; - addFullRequestInterceptor(requestInterceptor: (element: any, operation: string, what: string, url: string, headers: any, params: any, httpConfig: IRequestConfig) => {headers: any; params: any; element: any; httpConfig: IRequestConfig}): void; + setFullRequestInterceptor(fullRequestInterceptor: (element: any, operation: string, what: string, url: string, headers: any, params: any, httpConfig: ng.IRequestShortcutConfig) => {element: any; headers: any; params: any}): void; + addFullRequestInterceptor(requestInterceptor: (element: any, operation: string, what: string, url: string, headers: any, params: any, httpConfig: ng.IRequestShortcutConfig) => {headers: any; params: any; element: any; httpConfig: ng.IRequestShortcutConfig}): void; setErrorInterceptor(errorInterceptor: (response: IResponse, deferred: ng.IDeferred) => any): void; setRestangularFields(fields: {[fieldName: string]: string}): void; setMethodOverriders(overriders: string[]): void; @@ -124,7 +113,7 @@ declare module restangular { clone(): IElement; plain(): any; plain(): T; - withHttpConfig(httpConfig: IRequestConfig): IElement; + withHttpConfig(httpConfig: ng.IRequestShortcutConfig): IElement; save(queryParams?: any, headers?: any): IPromise; getRestangularUrl(): string; } @@ -139,7 +128,7 @@ declare module restangular { options(queryParams?: any, headers?: any): IPromise; patch(queryParams?: any, headers?: any): IPromise; putElement(idx: any, params: any, headers: any): IPromise; - withHttpConfig(httpConfig: IRequestConfig): ICollection; + withHttpConfig(httpConfig: ng.IRequestShortcutConfig): ICollection; clone(): ICollection; plain(): any; plain(): T[]; From 1c1d000362c240f6a6f9318e6325de9fbfce052c Mon Sep 17 00:00:00 2001 From: Per Kastman Date: Sun, 4 Oct 2015 15:20:31 +0200 Subject: [PATCH 0027/1238] Added typings for jquery cropbox plugin --- jquery.cropbox/jquery.cropbox.d.ts | 115 +++++++++++++++++++++++++ jquery.cropbox/jquery.cropbox.tests.ts | 39 +++++++++ 2 files changed, 154 insertions(+) create mode 100644 jquery.cropbox/jquery.cropbox.d.ts create mode 100644 jquery.cropbox/jquery.cropbox.tests.ts diff --git a/jquery.cropbox/jquery.cropbox.d.ts b/jquery.cropbox/jquery.cropbox.d.ts new file mode 100644 index 0000000000..70e09a46ae --- /dev/null +++ b/jquery.cropbox/jquery.cropbox.d.ts @@ -0,0 +1,115 @@ +// Type definitions for jQuery cropbox +// Project: https://github.com/acornejo/jquery-cropbox +// Definitions by: Per Kastman +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module jQueryCropBox { + + enum ShowControls { + never, + always, + hover, + auto + } + + interface CropboxArea { + cropX: number; + cropY: number; + cropW: number; + cropH: number; + } + + interface CropboxOptions { + /** + * Width in pixels of the cropping window + */ + width?: number; + /** + * Height in pixels of the cropping window + */ + height?: number; + /** + * Number of incremental zoom steps. With the default of 10, you have to click the zoom-in button 9 times to reach 100%. + */ + zoom?: number; + /** + * Maximum zoom value. With the default of 1.0 users can't zoom beyond the maximum image resolution. + */ + maxZoom?: number; + /** + * If not null, this is the entire html block that should appear on hover over the image for instructions and/or buttons (could include the zoom in/out buttons for example). If null, the default html block is used which has the text "Click to drag" and the zoom in/out buttons. Use false to disable controls. + */ + controls?: any; + /** + * Set the initial cropping area + */ + result?: CropboxArea; + /** + * This flag is used to determine when to display the controls. Never, always and hover do exactly what you would expect (never show them, always show them, show them on hover). The auto flag is the same as the hover flag, except that on mobile devices it always shows the controls (since there is no hover event). + */ + showControls?: ShowControls + } + + interface CropboxDragOptions { + startX: number, + startY: number, + dx: number, + dy: number + } + + interface CropboxSetCropOptions { + cropX: number, + cropY: number, + cropW: number, + cropH: number + } + + interface Cropbox { + /** + * Increase image zoom level by one step + */ + zoomIn(): void; + /** + * Decrease image zoom level by one step + */ + zoomOut(): void; + /** + * Set zoom leevl to a value between 0 and 1. Need to call update to reflect the changes. + */ + zoom(percent: number): void; + /** + * Simulate image dragging, starting from (startX,startY) and moving a delta of (dx,dy). Need to call update to reflect the changes. + */ + drag(options: CropboxDragOptions): void; + /** + * Set crop window. + */ + setCrop(options: CropboxSetCropOptions): void; + /** + * Update the cropped result (must call after zoom and drag). + */ + update(): void; + /** + * Generate a URL for the cropped image on the client (requires HTML5 compliant browser). + */ + getDataURL(): string; + /** + * Generate a Blob with the cropped image (requires HTML5 compliant browser). + */ + getBlob(): any; + /** + * Remove the cropbox functionality from the image. + */ + remove(): void; + } + +} +interface JQuery { + cropbox(params?: jQueryCropBox.CropboxOptions): jQueryCropBox.Cropbox +} + +interface JQueryStatic { + cropbox(params?: jQueryCropBox.CropboxOptions): jQueryCropBox.Cropbox +} diff --git a/jquery.cropbox/jquery.cropbox.tests.ts b/jquery.cropbox/jquery.cropbox.tests.ts new file mode 100644 index 0000000000..cb8f0be5ac --- /dev/null +++ b/jquery.cropbox/jquery.cropbox.tests.ts @@ -0,0 +1,39 @@ +/// +/// + +var cropboxWithDefaultSettings = $("#element").cropbox(); + +var cropboxOptions: jQueryCropBox.CropboxOptions = { + height: 500, + zoom: 5, + width: 0.5, +}; + +var cropboxWithOptions = $("#element").cropbox(cropboxOptions); + +cropboxWithOptions.zoomIn(); +cropboxWithOptions.zoomOut(); +cropboxWithOptions.zoom(50); + +var cropDragOption: jQueryCropBox.CropboxDragOptions = { + startX: 10, + startY: 0, + dx: 100, + dy: 100 +}; + +cropboxWithOptions.drag(cropDragOption); + +var cropboxSetCropOption: jQueryCropBox.CropboxSetCropOptions = { + cropX: 10, + cropY: 10, + cropW: 50, + cropH: 50 +}; + +cropboxWithOptions.setCrop(cropboxSetCropOption); + +cropboxWithOptions.update(); +cropboxWithOptions.getDataURL(); +cropboxWithOptions.getBlob(); +cropboxWithOptions.remove(); From 10c7ec397f4617dfb0fc7274fa9a8c054ff362b2 Mon Sep 17 00:00:00 2001 From: Per Kastman Date: Sun, 4 Oct 2015 15:25:44 +0200 Subject: [PATCH 0028/1238] Cleanup --- jquery.cropbox/jquery.cropbox.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery.cropbox/jquery.cropbox.d.ts b/jquery.cropbox/jquery.cropbox.d.ts index 70e09a46ae..82b550bf30 100644 --- a/jquery.cropbox/jquery.cropbox.d.ts +++ b/jquery.cropbox/jquery.cropbox.d.ts @@ -104,8 +104,8 @@ declare module jQueryCropBox { */ remove(): void; } - } + interface JQuery { cropbox(params?: jQueryCropBox.CropboxOptions): jQueryCropBox.Cropbox } From 0be6de745e7ed0374ad64299bc5afbc1b3ceb800 Mon Sep 17 00:00:00 2001 From: jessesh Date: Mon, 5 Oct 2015 13:24:59 -0700 Subject: [PATCH 0029/1238] This commit contains lots of changes to update the WinJS.d.ts file from WinJS 3.X to WinJS 4.4 --- winjs/winjs.d.ts | 3293 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 2473 insertions(+), 820 deletions(-) diff --git a/winjs/winjs.d.ts b/winjs/winjs.d.ts index 195ecb66ec..acf6802bfc 100644 --- a/winjs/winjs.d.ts +++ b/winjs/winjs.d.ts @@ -4,18 +4,12 @@ // Definitions: https://github.com/borisyankov/DefinitelyTyped /* ***************************************************************************** -Copyright (c) Microsoft Corporation. All rights reserved. -Licensed under the Apache License, Version 2.0 (the "License"); you may not use -this file except in compliance with the License. You may obtain a copy of the -License at http://www.apache.org/licenses/LICENSE-2.0 - -THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED -WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, -MERCHANTABLITY OR NON-INFRINGEMENT. - -See the Apache Version 2.0 License for specific language governing permissions -and limitations under the License. +Copyright (c) Microsoft Corporation. All rights reserved. +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ""Software""), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ***************************************************************************** */ /** @@ -58,6 +52,11 @@ interface IOHelper { * @returns A promise that is completed when the file has been written. **/ writeText(fileName: string, text: string): WinJS.Promise; + + /** + * This API supports the WinJS infrastructure and is not intended to be used directly from your code. + **/ + storage: any; } /** @@ -88,16 +87,6 @@ declare module WinJS.Application { //#endregion Objects - //#region Methods - - /** - * Informs the application object that asynchronous work is being performed, and that this event handler should not be considered complete until the promise completes. This function can be set inside the handlers for all WinJS.Application events: onactivated oncheckpoint onerror onloaded onready onsettings onunload. - * @param promise The promise that should complete before processing is complete. - **/ - function setPromise(promise: Promise): void; - - //#endregion Methods - //#region Functions /** @@ -141,47 +130,61 @@ declare module WinJS.Application { //#region Events + interface IPromiseEvent extends CustomEvent { + /** + * Informs the application object that asynchronous work is being performed, and that this event handler should not be considered complete until the promise completes. This function can be set inside the handlers for all WinJS.Application events: onactivated oncheckpoint onerror onloaded onready onsettings onunload. + * @param promise The promise that should complete before processing is complete. + **/ + setPromise(promise: IPromise): void; + } + /** * Occurs when WinRT activation has occurred. The name of this event is "activated" (and also "mainwindowactivated"). This event occurs after the loaded event and before the ready event. * @param eventInfo An object that contains information about the event. For more information about event arguments, see the WinRT event argument classes: WebUICachedFileUpdaterActivatedEventArgs, WebUICameraSettingsActivatedEventArgs, WebUIContactPickerActivatedEventArgs, WebUIDeviceActivatedEventArgs, WebUIFileActivatedEventArgs, WebUIFileOpenPickerActivatedEventArgs, WebUIFileSavePickerActivatedEventArgs, WebUILaunchActivatedEventArgs, WebUIPrintTaskSettingsActivatedEventArgs, WebUIProtocolActivatedEventArgs, WebUISearchActivatedEventArgs, WebUIShareTargetActivatedEventArgs. **/ - function onactivated(eventInfo: CustomEvent): void; + function onactivated(eventInfo: IPromiseEvent): void; /** * Occurs when receiving PLM notification or when the checkpoint function is called. * @param eventInfo An object that contains information about the event. The detail property of this object includes the following subproperties: type, setPromise. **/ - function oncheckpoint(eventInfo: CustomEvent): void; + function oncheckpoint(eventInfo: IPromiseEvent): void; /** * Occurs when an unhandled error has been raised. * @param eventInfo An object that contains information about the event. **/ - function onerror(eventInfo: CustomEvent): void; + function onerror(eventInfo: IPromiseEvent): void; /** * Occurs after the DOMContentLoaded event, which fires after the page has been parsed but before all the resources are loaded. This event occurs before the activated event and the ready event. * @param eventInfo An object that contains information about the event. The detail property of this object includes the following subproperties: type, setPromise. **/ - function onloaded(eventInfo: CustomEvent): void; + function onloaded(eventInfo: IPromiseEvent): void; /** * Occurs when the application is ready. This event occurs after the loaded event and the activated event. * @param eventInfo An object that contains information about the event. The detail property of this object includes the following sub-properties: type, setPromise. **/ - function onready(eventInfo: CustomEvent): void; + function onready(eventInfo: IPromiseEvent): void; /** * Occurs when the settings charm is invoked. * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: type, applicationcommands. **/ - function onsettings(eventInfo: CustomEvent): void; + function onsettings(eventInfo: IPromiseEvent): void; /** * Occurs when the application is about to be unloaded. * @param eventInfo An object that contains information about the event. The detail property of this object includes the following sub-properties: type, setPromise. **/ - function onunload(eventInfo: CustomEvent): void; + function onunload(eventInfo: IPromiseEvent): void; + + /** + * Occurs whenever a user clicks the hardware backbutton. + * @param eventInfo An object that contains information about the event. The detail property of this object includes the following sub-properties: type + **/ + function onbackclick(eventInfo: IPromiseEvent): void; //#endregion Events @@ -192,11 +195,6 @@ declare module WinJS.Application { declare module WinJS.Binding { //#region Properties - /** - * Determines whether or not binding should automatically set the ID of an element. This property should be set to true in apps that use WinJS (WinJS) binding. - **/ - var optimizeBindingReferences: boolean; - //#endregion Properties //#region Objects @@ -276,7 +274,7 @@ declare module WinJS.Binding { /** * Do not instantiate. A list returned by the createFiltered method. **/ - class FilteredListProjection extends ListProjection { + interface FilteredListProjection extends ListProjection { //#region Methods /** @@ -320,9 +318,9 @@ declare module WinJS.Binding { } /** - * Do not instantiate. A list of groups. + * A list of groups. **/ - class GroupsListProjection extends ListBase { + interface GroupsListProjection extends ListBase { //#region Methods /** @@ -362,13 +360,13 @@ declare module WinJS.Binding { /** * Do not instantiate. Sorts the underlying list by group key and within a group respects the position of the item in the underlying list. Returned by createGrouped. **/ - class GroupedSortedListProjection extends SortedListProjection { + interface GroupedSortedListProjection extends SortedListProjection { //#region Properties /** * Gets a List, which is a projection of the groups that were identified in this list. **/ - groups: GroupsListProjection; + groups: GroupsListProjection; //#endregion Properties @@ -383,12 +381,12 @@ declare module WinJS.Binding { /** * Represents a list of objects that can be accessed by index or by a string key. Provides methods to search, sort, filter, and manipulate the data. **/ - class List extends ListBaseWithMutators { + class List implements ListBaseWithMutators { //#region Constructors /** * Creates a List object. - * @constructor + * @constructor * @param list The array containing the elements to initalize the list. * @param options You can set two Boolean options: binding and proxy. If options.binding is true, the list contains the result of calling as on the element values. If options.proxy is true, the list specified as the first parameter is used as the storage for the List. This option should be used with care, because uncoordinated edits to the data storage may result in errors. **/ @@ -396,86 +394,6 @@ declare module WinJS.Binding { //#endregion Constructors - //#region Methods - - /** - * Gets a key/data pair for the specified list index. - * @param index The index of value to retrieve. - * @returns An object with .key and .data properties. - **/ - getItem(index: number): IKeyDataPair; - - /** - * Gets a key/data pair for the list item key specified. - * @param key The key of the value to retrieve. - * @returns An object with .key and .data properties. - **/ - getItemFromKey(key: string): IKeyDataPair; - - /** - * Gets the index of the first occurrence of a key in a list. - * @param key The key to locate in the list. - * @returns The index of the first occurrence of a key in a list, or -1 if not found. - **/ - indexOfKey(key: string): number; - - /** - * Moves the value at index to the specified position. - * @param index The original index of the value. - * @param newIndex The index of the value after the move. - **/ - move(index: number, newIndex: number): void; - - /** - * Forces the list to send a itemmutated notification to any listeners for the value at the specified index. - * @param index The index of the value that was mutated. - **/ - notifyMutated(index: number): void; - - /** - * Returns a list with the elements reversed. This method reverses the elements of a list object in place. It does not create a new list object during execution. - **/ - reverse(): void; - - /** - * Replaces the value at the specified index with a new value. - * @param index The index of the value that was replaced. - * @param newValue The new value. - **/ - setAt(index: number, newValue: T): void; - - /** - * Returns a list with the elements sorted. This method sorts the elements of a list object in place. It does not create a new list object during execution. - * @param sortFunction The function used to determine the order of the elements. If omitted, the elements are sorted in ascending, ASCII character order. This function must always return the same results, given the same inputs. The results should not depend on values that are subject to change. You must call notifyMutated each time an item changes. Do not batch change notifications. - **/ - sort(sortFunction?: (left: T, right: T) => number): void; - - /** - * Removes elements from a list and, if necessary, inserts new elements in their place, returning the deleted elements. - * @param start The zero-based location in the list from which to start removing elements. - * @param howMany The number of elements to remove. - * @param item The elements to insert into the list in place of the deleted elements. - * @returns The deleted elements. - **/ - splice(start: number, howMany?: number, ...item: T[]): T[]; - - //#endregion Methods - - //#region Properties - - /** - * Gets or sets the length of the list, which is an integer value one higher than the highest element defined in the list. - **/ - length: number; - - //#endregion Properties - - } - - /** - * Represents a base class for lists. - **/ - class ListBase { //#region Events /** @@ -555,7 +473,341 @@ declare module WinJS.Binding { * @param groupSorter A function that accepts two arguments. The function is called with pairs of group keys found in the list. It must return one of the following numeric values: negative if the first argument is less than the second (sorted before), zero if the two arguments are equivalent, positive if the first argument is greater than the second (sorted after). * @returns A grouped projection over the list. **/ - createGrouped(groupKey: (x: T) => string, groupData: (x: T) => any, groupSorter?: (left: string, right: string) => number): GroupedSortedListProjection; + createGrouped(groupKey: (x: T) => string, groupData: (x: T) => G, groupSorter?: (left: string, right: string) => number): GroupedSortedListProjection; + + /** + * Creates a live sorted projection over this list. As the list changes, the sorted projection reacts to those changes and may also change. + * @param sorter A function that accepts two arguments. The function is called with elements in the list. It must return one of the following numeric values: negative if the first argument is less than the second, zero if the two arguments are equivalent, positive if the first argument is greater than the second. This function must always return the same results, given the same inputs. The results should not depend on values that are subject to change. You must call notifyMutated each time an item changes. Do not batch change notifications. + * @returns A sorted projection over the list. + **/ + createSorted(sorter: (left: T, right: T) => number): SortedListProjection; + + /** + * Raises an event of the specified type and with the specified additional properties. + * @param type The type (name) of the event. + * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. + * @returns true if preventDefault was called on the event. + **/ + dispatchEvent(type: string, eventProperties: any): boolean; + + /** + * Checks whether the specified callback function returns true for all elements in a list. + * @param callback A function that accepts up to three arguments. This function is called for each element in the list until it returns false or the end of the list is reached. + * @param thisArg An object to which the this keyword can refer in the callback function. If thisArg is omitted, undefined is used. + * @returns true if the callback returns true for all elements in the list. + **/ + every(callback: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; + + /** + * Returns the elements of a list that meet the condition specified in a callback function. + * @param callback A function that accepts up to three arguments. The function is called for each element in the list. This function must always return the same results, given the same inputs. The results should not depend on values that are subject to change. You must call notifyMutated each time an item changes. Do not batch change notifications. + * @param thisArg An object to which the this keyword can refer in the callback function. If thisArg is omitted, undefined is used. + * @returns An array containing the elements that meet the condition specified in the callback function. + **/ + filter(callback: (value: T, index: number, array: T[]) => any, thisArg?: any): T[]; + + /** + * Calls the specified callback function for each element in a list. + * @param callback A function that accepts up to three arguments. The function is called for each element in the list. The arguments are as follows: value, index, array. + * @param thisArg An object to which the this keyword can refer in the callback function. If thisArg is omitted, undefined is used. + **/ + forEach(callback: (value: T, index: number, array: T[]) => void, thisArg?: any): void; + + /** + * Gets the value at the specified index. + * @param index The index of the value to get. + * @returns The value at the specified index. + **/ + getAt(index: number): T; + + /** + * Gets a key/data pair for the specified list index. + * @param index The index of value to retrieve. + * @returns An object with .key and .data properties. + **/ + getItem(index: number): IKeyDataPair; + + /** + * Gets a key/data pair for the list item key specified. + * @param key The key of the value to retrieve. + * @returns An object with .key and .data properties. + **/ + getItemFromKey(key: string): IKeyDataPair; + + /** + * Gets the index of the first occurrence of the specified value in a list. + * @param searchElement The value to locate in the list. + * @param fromIndex The index at which to begin the search. If fromIndex is omitted, the search starts at index 0. + * @returns The index of the first occurrence of a value in a list or -1 if not found. + **/ + indexOf(searchElement: T, fromIndex?: number): number; + + /** + * Gets the index of the first occurrence of a key in a list. + * @param key The key to locate in the list. + * @returns The index of the first occurrence of a key in a list, or -1 if not found. + **/ + indexOfKey(key: string): number; + + /** + * Returns a string consisting of all the elements of a list separated by the specified separator string. + * @param separator A string used to separate the elements of a list. If this parameter is omitted, the list elements are separated with a comma. + * @returns The elements of a list separated by the specified separator string. + **/ + join(separator?: string): string; + + /** + * Gets the index of the last occurrence of the specified value in a list. + * @param searchElement The value to locate in the list. + * @param fromIndex The index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the list. + * @returns The index of the last occurrence of a value in a list, or -1 if not found. + **/ + lastIndexOf(searchElement: T, fromIndex?: number): number; + + /** + * Calls the specified callback function on each element of a list, and returns an array that contains the results. + * @param callback A function that accepts up to three arguments. The function is called for each element in the list. + * @param thisArg n object to which the this keyword can refer in the callback function. If thisArg is omitted, undefined is used. + * @returns An array containing the result of calling the callback function on each element in the list. + **/ + map(callback: (value: T, index: number, array: T[]) => G, thisArg?: any): G[]; + + /** + * Moves the value at index to the specified position. + * @param index The original index of the value. + * @param newIndex The index of the value after the move. + **/ + move(index: number, newIndex: number): void; + + /** + * Notifies listeners that a property value was updated. + * @param name The name of the property that is being updated. + * @param newValue The new value for the property. + * @param oldValue The old value for the property. + * @returns A promise that is completed when the notifications are complete. + **/ + notify(name: string, newValue: any, oldValue: any): Promise; + + /** + * Forces the list to send a itemmutated notification to any listeners for the value at the specified index. + * @param index The index of the value that was mutated. + **/ + notifyMutated(index: number): void; + + /** + * Forces the list to send a reload notification to any listeners. + **/ + notifyReload(): void; + + /** + * Removes the last element from a list and returns it. + * @returns The last element from the list. + **/ + pop(): T; + + /** + * Appends new element(s) to a list, and returns the new length of the list. + * @param value The element to insert at the end of the list. + * @returns The new length of the list. + **/ + push(value: T): number; + push(...values: T[]): number; + + /** + * Accumulates a single result by calling the specified callback function for all elements in a list. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callback A function that accepts up to four arguments. These arguments are: previousValue, currentValue, currentIndex, array. The function is called for each element in the list. + * @param initiallValue If initialValue is specified, it is used as the value with which to start the accumulation. The first call to the function provides this value as an argument instead of a list value. + * @returns The return value from the last call to the callback function. + **/ + reduce(callback: (previousValue: any, currentValue: any, currentIndex: number, array: T[]) => T, initiallValue?: T): T; + + /** + * Accumulates a single result by calling the specified callback function for all elements in a list, starting with the last member of the list. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callback A function that accepts up to four arguments. These arguments are: previousValue, currentValue, currentIndex, array. The function is called for each element in the list. + * @param initialValue If initialValue is specified, it is used as the value with which to start the accumulation. The first call to the callback function provides this value as an argument instead of a list value. + * @returns The return value from the last call to callback function. + **/ + reduceRight(callback: (previousValue: any, currentValue: any, currentIndex: number, array: T[]) => T, initialValue?: T): T; + + /** + * Removes an event listener from the control. + * @param type The type (name) of the event. + * @param listener The listener to remove. + * @param useCapture true if capture is to be initiated, otherwise false. + **/ + removeEventListener(type: string, listener: Function, useCapture?: boolean): void; + + /** + * Returns a list with the elements reversed. This method reverses the elements of a list object in place. It does not create a new list object during execution. + **/ + reverse(): void; + + /** + * Replaces the value at the specified index with a new value. + * @param index The index of the value that was replaced. + * @param newValue The new value. + **/ + setAt(index: number, newValue: T): void; + + /** + * Removes the first element from a list and returns it. + * @returns The first element from the list. + **/ + shift(): T; + + /** + * Extracts a section of a list and returns a new list. + * @param begin The index that specifies the beginning of the section. + * @param end The index that specifies the end of the section. + * @returns Returns a section of list. + **/ + slice(begin: number, end?: number): T[]; + + /** + * Checks whether the specified callback function returns true for any element of a list. + * @param callback A function that accepts up to three arguments. The function is called for each element in the list until it returns true, or until the end of the list. + * @param thisArg An object to which the this keyword can refer in the callback function. If thisArg is omitted, undefined is used. + * @returns true if callback returns true for any element in the list. + **/ + some(callback: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; + + /** + * Returns a list with the elements sorted. This method sorts the elements of a list object in place. It does not create a new list object during execution. + * @param sortFunction The function used to determine the order of the elements. If omitted, the elements are sorted in ascending, ASCII character order. This function must always return the same results, given the same inputs. The results should not depend on values that are subject to change. You must call notifyMutated each time an item changes. Do not batch change notifications. + **/ + sort(sortFunction?: (left: T, right: T) => number): void; + + /** + * Removes elements from a list and, if necessary, inserts new elements in their place, returning the deleted elements. + * @param start The zero-based location in the list from which to start removing elements. + * @param howMany The number of elements to remove. + * @param item The elements to insert into the list in place of the deleted elements. + * @returns The deleted elements. + **/ + splice(start: number, howMany?: number, ...item: T[]): T[]; + + /** + * Removes one or more listeners from the notification list for a given property. + * @param name The name of the property to unbind. If this parameter is omitted, all listeners for all events are removed. + * @param action The function to remove from the listener list for the specified property. If this parameter is omitted, all listeners are removed for the specific property. + * @returns This object is returned. + **/ + unbind(name: string, action: Function): any; + + /** + * Appends new element(s) to a list, and returns the new length of the list. + * @param value The element to insert at the start of the list. + * @returns The new length of the list. + **/ + unshift(value: T): number; + unshift(...values: T[]): number; + + //#endregion Methods + + //#region Properties + + /** + * Gets the IListDataSource for the list. The only purpose of this property is to adapt a List to the data model that is used by ListView and FlipView. + **/ + dataSource: WinJS.UI.IListDataSource; + + /** + * Gets or sets the length of the list, which is an integer value one higher than the highest element defined in the list. + **/ + length: number; + + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + + //#endregion Properties + } + + /** + * Represents a base class for lists. + **/ + interface ListBase { + //#region Events + + /** + * An item in the list has changed its value. + * @param eventInfo An object that contains information about the event. The detail contains the following information: index, key, newItem, newValue, oldItem, oldValue. + **/ + onitemchanged(eventInfo: CustomEvent): void; + + /** + * A new item has been inserted into the list. + * @param eventInfo An object that contains information about the event. The detail contains the following information: index, key, value. + **/ + oniteminserted(eventInfo: CustomEvent): void; + + /** + * An item has been changed locations in the list. + * @param eventInfo An object that contains information about the event. The detail contains the following information: index, key, value. + **/ + onitemmoved(eventInfo: CustomEvent): void; + + /** + * An item has been mutated. This event occurs as a result of calling the notifyMutated method. + * @param eventInfo An object that contains information about the event. The detail contains the following information: index, key, value. + **/ + onitemmutated(eventInfo: CustomEvent): void; + + /** + * An item has been removed from the list. + * @param eventInfo An object that contains information about the event. The detail contains the following information: index, key, value. + **/ + onitemremoved(eventInfo: CustomEvent): void; + + /** + * The list has been refreshed. Any references to items in the list may be incorrect. + * @param eventInfo An object that contains information about the event. The detail property of this object is null. + **/ + onreload(eventInfo: CustomEvent): void; + + //#endregion Events + + //#region Methods + + /** + * Adds an event listener to the control. + * @param type The type (name) of the event. + * @param listener The listener to invoke when the event gets raised. + * @param useCapture If true, initiates capture, otherwise false. + **/ + addEventListener(type: string, listener: Function, useCapture?: boolean): void; + + /** + * Links the specified action to the property specified in the name parameter. This function is invoked when the value of the property may have changed. It is not guaranteed that the action will be called only when a value has actually changed, nor is it guaranteed that the action will be called for every value change. The implementation of this function coalesces change notifications, such that multiple updates to a property value may result in only a single call to the specified action. + * @param name The name of the property to which to bind the action. + * @param action The function to invoke asynchronously when the property may have changed. + * @returns A reference to this observableMixin object. + **/ + bind(name: string, action: Function): any; + + /** + * Returns a new list consisting of a combination of two arrays. + * @param item Additional items to add to the end of the list. + * @returns An array containing the concatenation of the list and any other supplied items. + **/ + concat(...item: T[]): T[]; + + /** + * Creates a live filtered projection over this list. As the list changes, the filtered projection reacts to those changes and may also change. + * @param predicate A function that accepts a single argument. The createFiltered function calls the callback with each element in the list. If the function returns true, that element will be included in the filtered list. This function must always return the same results, given the same inputs. The results should not depend on values that are subject to change. You must call notifyMutated each time an item changes. Do not batch change notifications. + * @returns A filtered projection over the list. + **/ + createFiltered(predicate: (x: T) => boolean): FilteredListProjection; + + /** + * Creates a live grouped projection over this list. As the list changes, the grouped projection reacts to those changes and may also change. The grouped projection sorts all the elements of the list to be in group-contiguous order. The grouped projection also contains a .groups property, which is a List representing the groups that were found in the list. + * @param groupKey A function that accepts a single argument. The function is called with each element in the list, the function should return a string representing the group containing the element. This function must always return the same results, given the same inputs. The results should not depend on values that are subject to change. You must call notifyMutated each time an item changes. Do not batch change notifications. + * @param groupData A function that accepts a single argument. The function is called once, on one element per group. It should return the value that should be set as the data of the .groups list element for this group. The data value usually serves as summary or header information for the group. + * @param groupSorter A function that accepts two arguments. The function is called with pairs of group keys found in the list. It must return one of the following numeric values: negative if the first argument is less than the second (sorted before), zero if the two arguments are equivalent, positive if the first argument is greater than the second (sorted after). + * @returns A grouped projection over the list. + **/ + createGrouped(groupKey: (x: T) => string, groupData: (x: T) => G, groupSorter?: (left: string, right: string) => number): GroupedSortedListProjection; /** * Creates a live sorted projection over this list. As the list changes, the sorted projection reacts to those changes and may also change. @@ -704,18 +956,13 @@ declare module WinJS.Binding { **/ dataSource: WinJS.UI.IListDataSource; - /** - * Indicates that the object is compatibile with declarative processing. - **/ - static supportedForProcessing: boolean; - //#endregion Properties } /** * Represents a base class for normal list modifying operations. **/ - class ListBaseWithMutators extends ListBase { + interface ListBaseWithMutators extends ListBase { //#region Methods /** @@ -752,7 +999,7 @@ declare module WinJS.Binding { /** * Represents a base class for list projections. **/ - class ListProjection extends ListBaseWithMutators { + interface ListProjection extends ListBaseWithMutators { //#region Methods /** @@ -897,7 +1144,7 @@ declare module WinJS.Binding { /** * Do not instantiate. Returned by the createSorted method. **/ - class SortedListProjection extends ListProjection { + interface SortedListProjection extends ListProjection { //#region Methods /** @@ -948,30 +1195,35 @@ declare module WinJS.Binding { /** * Creates a template that provides a reusable declarative binding element. - * @constructor + * @constructor * @param element The DOM element to convert to a template. * @param options If this parameter is supplied, the template is loaded from the URI and the content of the element parameter is ignored. You can add the following options: href. **/ - constructor(element: HTMLElement, options?:any); + constructor(element: HTMLElement, options?: any); //#endregion Constructors //#region Methods /** - * Binds values from the specified data context to elements that are descendants of the specified root element that have the declarative binding attributes specified (data-win-bind). - * @param dataContext The object to use for default data binding. - * @param container The element to which to add this rendered template. If this parameter is omitted, a new DIV is created. - * @returns A Promise that will be completed after binding has finished. The value is either container or the created DIV. promise that is completed after binding has finished. + * Binds values from the specified data context to elements that are descendants of the specified root element that have the declarative binding attributes specified (data-win-bind). + * @param dataContext The object to use for default data binding. + * @param container The element to which to add this rendered template. If this parameter is omitted, a new DIV is created. + * @returns A Promise that will be completed after binding has finished. The value is either container or the created DIV. promise that is completed after binding has finished. **/ render(dataContext: any, container?: HTMLElement): Promise; /** - * Renders a template based on the specified URI (static method). - * @param href The URI from which to load the template. - * @param dataContext The object to use for default data binding. - * @param container The element to which to add this rendered template. If this parameter is omitted, a new DIV is created. - * @returns A promise that is completed after binding has finished. The value is either the object in the container parameter or the created DIV. + * This API supports the WinJS infrastructure and is not intended to be used directly from your code. Use render instead. + **/ + renderItem(item: WinJS.Promise, recyled: HTMLElement): { element: WinJS.Promise; renderComplete: WinJS.Promise; }; + + /** + * Renders a template based on the specified URI (static method). + * @param href The URI from which to load the template. + * @param dataContext The object to use for default data binding. + * @param container The element to which to add this rendered template. If this parameter is omitted, a new DIV is created. + * @returns A promise that is completed after binding has finished. The value is either the object in the container parameter or the created DIV. **/ static render(href: string, dataContext: any, container?: HTMLElement): Promise; @@ -1004,10 +1256,21 @@ declare module WinJS.Binding { **/ extractChild: boolean; + /** + * Gets or sets the Number of milliseconds to delay instantiating declarative controls. Zero (0) will result in no delay, any negative number + * will result in a setImmediate delay, any positive number will be treated as the number of milliseconds. + **/ + processTimeout: number; + /** * Determines whether the Template contains declarative controls that must be processed separately. This property is always true. The controls that belong to a Template object's children are instantiated when a Template instance is rendered. **/ - isDeclarativeControlContainer: boolean; + static isDeclarativeControlContainer: boolean; + + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; //#endregion Properties @@ -1071,6 +1334,11 @@ declare module WinJS.Binding { **/ function expandProperties(shape: any): any; + /** + * This API supports the WinJS infrastructure and is not intended to be used directly from your code. + **/ + function getValue(obj: any, path?: any) + /** * Marks a custom initializer function as being compatible with declarative data binding. * @param customInitializer The custom initializer to be marked as compatible with declarative data binding. @@ -1078,15 +1346,6 @@ declare module WinJS.Binding { **/ function initializer(customInitializer: Function): Function; - /** - * Notifies listeners that a property value was updated. - * @param name The name of the property that is being updated. - * @param newValue The new value for the property. - * @param oldValue The old value for the property. - * @returns A promise that is completed when the notifications are complete. - **/ - function notify(name: string, newValue: string, oldValue: string): Promise; - /** * Sets the destination property to the value of the source property. * @param source The source object. @@ -1211,7 +1470,7 @@ declare module WinJS { /** * Creates an Error object with the specified name and message properties. - * @constructor + * @constructor * @param name The name of this error. The name is meant to be consumed programmatically and should not be localized. * @param message The message for this error. The message is meant to be consumed by humans and should be localized. **/ @@ -1219,6 +1478,15 @@ declare module WinJS { //#endregion Constructors + //#region Properties + + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + + //#endregion Properties + } interface IPromise { @@ -1243,7 +1511,7 @@ declare module WinJS { /** * A promise provides a mechanism to schedule work to be done on a value that has not yet been computed. It is a convenient abstraction for managing interactions with asynchronous APIs. For more information about asynchronous programming, see Asynchronous programming. For more information about promises in JavaScript, see Asynchronous programming in JavaScript. For more information about using promises, see the WinJS Promise sample. - * @constructor + * @constructor * @param init The function that is called during construction of the Promise that contains the implementation of the operation that the Promise will represent. This can be synchronous or asynchronous, depending on the nature of the operation. Note that placing code within this function does not automatically run it asynchronously; that must be done explicitly with other asynchronous APIs such as setImmediate, setTimeout, requestAnimationFrame, and the Windows Runtime asynchronous APIs. The init function is given three arguments: completeDispatch, errorDispatch, progressDispatch. This parameter is optional. * @param onCancel The function to call if a consumer of this promise wants to cancel its undone work. Promises are not required to support cancellation. **/ @@ -1460,6 +1728,15 @@ declare module WinJS { //#endregion Methods + //#region Properties + + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + + //#endregion Properties + } //#endregion Objects @@ -1473,12 +1750,7 @@ declare module WinJS { * @param type The type of message (error, warning, info, etc.). **/ function log(message: string, tags?: string, type?: string): void; - function log(message: ()=>string, tags?: string, type?: string): void; - - /** - * This method has been deprecated. Strict processing is always on; you don't have to call this method to turn it on. - **/ - function strictProcessing(): void; + function log(message: () => string, tags?: string, type?: string): void; /** * Wraps calls to XMLHttpRequest in a promise. @@ -1499,7 +1771,7 @@ declare module WinJS { headers?: any; data?: any; responseType?: string; - customRequestInitializer?:(request: XMLHttpRequest) => void; + customRequestInitializer?: (request: XMLHttpRequest) => void; } //#endregion Interfaces @@ -1692,7 +1964,7 @@ declare module WinJS.UI.Animation { /** * Creates an object that performs an animation that adds an item or items to a list. * @param added Element or elements to add to the list. - * @param affected Element or elements affected by the added items. + * @param affected Element or elements affected by the added items. Typically, this is all other items displayed in the list. * @returns An object whose execute method is used to execute the animation. The execute method returns a Promise that completes when the animation is finished. **/ function createAddToListAnimation(added: any, affected: any): IAnimationMethodResponse; @@ -1700,7 +1972,7 @@ declare module WinJS.UI.Animation { /** * Creates an object that performs an animation that adds an item or items to a list of search results. * @param added Element or elements to add to the list. - * @param affected Element or elements affected by the added items. + * @param affected Element or elements affected by the added items. Typically, this is all other items displayed in the list. * @returns An object whose execute method is used to execute the animation. The execute method returns a Promise that completes when the animation is finished. **/ function createAddToSearchListAnimation(added: any, affected: any): IAnimationMethodResponse; @@ -1708,7 +1980,7 @@ declare module WinJS.UI.Animation { /** * Creates an object that performs an animation that collapses a list. * @param hidden Element or elements hidden as a result of the collapse. - * @param affected Element or elements affected by the hidden items. + * @param affected Element or elements affected by the hidden items. Typically, this is all other items displayed in the list. * @returns An object whose execute method is used to execute the animation. The execute method returns a Promise that completes when the animation is finished. **/ function createCollapseAnimation(hidden: any, affected: any): IAnimationMethodResponse; @@ -1716,7 +1988,7 @@ declare module WinJS.UI.Animation { /** * Creates an object that performs an animation that removes an item or items from a list. * @param deleted Element or elements to delete from the list. - * @param remaining Element or elements affected by the removal of the deleted items. + * @param remaining Element or elements affected by the removal of the deleted items. Typically, this is all other items displayed in the list. * @returns An object whose execute method is used to execute the animation. The execute method returns a Promise that completes when the animation is finished. **/ function createDeleteFromListAnimation(deleted: any, remaining: any): IAnimationMethodResponse; @@ -1724,7 +1996,7 @@ declare module WinJS.UI.Animation { /** * Creates an object that performs an animation that removes an item or items from a list of search results. * @param deleted Element or elements to delete from the list. - * @param remaining Element or elements affected by the removal of the deleted items. + * @param remaining Element or elements affected by the removal of the deleted items. Typically, this is all other items displayed in the list. * @returns An object whose execute method is used to execute the animation. The execute method returns a Promise that completes when the animation is finished. **/ function createDeleteFromSearchListAnimation(deleted: any, remaining: any): IAnimationMethodResponse; @@ -1732,11 +2004,21 @@ declare module WinJS.UI.Animation { /** * Creates an object that performs an animation that expands a list. * @param revealed Element or elements revealed by the expansion. - * @param affected Element or elements affected by the newly revealed items. + * @param affected Element or elements affected by the newly revealed items. Typically, this is all other items displayed in the list. * @returns An object whose execute method is used to execute the animation. The execute method returns a Promise that completes when the animation is finished. **/ function createExpandAnimation(revealed: any, affected: any): IAnimationMethodResponse; + /** + * Creates an exit and entrance animation to play for a page navigation given the current and incoming pages' + * animation preferences and whether the pages are navigating forwards or backwards. + * @param currentPreferredAnimation A value from WinJS.UI.PageNavigationAnimation describing the animation the current page prefers to use. + * @param A value from nextPreferredAnimation WinJS.UI.PageNavigationAnimation describing the animation the incoming page prefers to use. + * @param movingBackwards Boolean value for whether the navigation is moving backwards. + * @returns an object containing the exit and entrance animations to play based on the parameters given. + **/ + function createPageNavigationAnimations(currentPreferredAnimation: string, nextPreferredAnimation: string, movingBackwards: boolean): { exit: Function; entrance: Function }; + /** * Creates an object that performs a peek animation. * @param element Element or elements involved in the peek. @@ -1791,6 +2073,34 @@ declare module WinJS.UI.Animation { **/ function dragSourceStart(dragSource: any, affected?: any): Promise; + /** + * Execute the incoming phase of the drill in animation, scaling up the incoming page while fading it in. + * @param incomingPage Element to be scaled up and faded in. + * @returns Promise object that completes when the animation is complete. + **/ + function drillInIncoming(incomingPage: HTMLElement): Promise; + + /** + * Execute the outgoing phase of the drill in animation, scaling up the outgoing page while fading it out. + * @param incomingPage Element to be scaled up and faded out. + * @returns Promise object that completes when the animation is complete. + **/ + function drillInOutgoing(outgoingPage: HTMLElement): Promise; + + /** + * Execute the incoming phase of the drill out animation, scaling down the incoming page while fading it in. + * @param incomingPage Element to be scaled up and faded in. + * @returns Promise object that completes when the animation is complete. + **/ + function drillOutIncoming(incomingPage: HTMLElement): Promise; + + /** + * Execute the outgoing phase of the drill out animation, scaling down the outgoing page while fading it out. + * @param outgoingPage Element to be scaled down and faded out. + * @returns Promise object that completes when the animation is complete. + **/ + function drillOutOutgoing(outgoingPage: HTMLElement): Promise; + /** * Performs an animation that displays one or more elements on a page. * @param incoming Element or elements that compose the incoming content. @@ -2264,7 +2574,8 @@ declare module WinJS.UI { threebars, fourbars, scan, - preview + preview, + hamburger } /** @@ -2313,6 +2624,10 @@ declare module WinJS.UI { * The edit operation timed out. **/ noResponse, + /** + * The edit operation was canceled. + **/ + canceled, /** * The data source cannot be written to. **/ @@ -2390,7 +2705,15 @@ declare module WinJS.UI { /** * The object is an item in the list. **/ - item + item, + /** + * The object is the header for the list. + **/ + header, + /** + * The object is the footer for the list. + **/ + footer } /** @@ -2461,10 +2784,147 @@ declare module WinJS.UI { none } + /** + * Specifies what animation type should be returned by WinJS.UI.Animation.createPageNavigationAnimations. + **/ + enum PageNavigationAnimation { + /** + * The pages will exit and enter using a turnstile animation. + **/ + turnstile, + /** + * The pages will exit and enter using an animation that slides up/down. + **/ + slide, + /** + * The pages will enter using an enterPage animation, and exit with no animation. + **/ + enterPage, + /** + * The pages will exit and enter using a continuum animation. + **/ + continuum, + } + //#endregion Enumerations //#region Interfaces + /** + * Define the shape of a Command object to be used in AppBar and ToolBar controls. + **/ + export interface ICommand { + //#region Methods + + /** + * Registers an event handler for the specified event. + * @param type The event type to register. + * @param listener The event handler function to associate with the event. + * @param useCapture Set to true to register the event handler for the capturing phase; otherwise, set to false to register the event handler for the bubbling phase. + **/ + addEventListener(type: string, listener: Function, useCapture?: boolean): void; + + /** + * Releases resources held by this ICommand. Call this method when the ICommand is no longer needed. After calling this method, the ICommand becomes unusable. + **/ + dispose(): void; + + /** + * Removes an event handler that the addEventListener method registered. + * @param type The event type to unregister. + * @param listener The event handler function to remove. + * @param useCapture Set to true to remove the capturing phase event handler; set to false to remove the bubbling phase event handler. + **/ + removeEventListener(type: string, listener: Function, useCapture?: boolean): void; + + //#endregion Methods + + //#region Properties + + /** + * Gets or sets a value that indicates whether the ICommand is disabled. + **/ + disabled: boolean; + + /** + * Gets the DOM element that hosts the ICommand. + **/ + element: HTMLElement; + + /** + * Adds an extra CSS class during construction. + **/ + extraClass: string; + + /** + * Gets or sets the HTMLElement with a 'content' type ICommand that should receive focus whenever focus moves by the user pressing HOME or the arrow keys, from the previous ICommand to this ICommand. + **/ + firstElementFocus: HTMLElement; + + /** + * Gets or sets the Flyout object displayed by this command. The specified flyout is shown when the ICommand's button is invoked. + **/ + flyout: Flyout; + + /** + * Gets or sets a value that indicates whether the ICommand is hiding or in the process of becoming hidden. + **/ + hidden: boolean; + + /** + * Gets or sets the icon of the ICommand. + **/ + icon: string; + + /** + * Gets the element identifier (ID) of the command. + **/ + id: string; + + /** + * Gets or sets the label of the command. + **/ + label: string; + + /** + * Gets or sets the HTMLElement with a 'content' type ICommand that should receive focus whenever focus moves by the user pressing END or the arrow keys, from the previous Command to this Command. + **/ + lastElementFocus: HTMLElement; + + /** + * Gets or sets the function to be invoked when the command is clicked. + **/ + onclick: Function; + + /** + * Gets the section of the parent control that the command is in. The section can only be set through constructor options. + **/ + section: string; + + /** + * Gets or sets the selected state of a toggle button. + **/ + selected: boolean; + + /** + * Gets or sets the tooltip of the command. + **/ + tooltip: string; + + /** + * Gets the type of the command. The type can only be set through constructor options. + **/ + type: string; + + /** + * Gets or sets the priority of the command. + **/ + priority: number; + + //#endregion Properties + } + + /** * Contains items that were requested from an IListDataAdapter and provides some information about those items. **/ @@ -2575,145 +3035,6 @@ declare module WinJS.UI { } - /** - * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. Represents a layout for the ListView. - **/ - interface ILayout { - //#region Methods - - /** - * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. - * @param beginScrollPosition The first visible pixel in the ListView. For horizontal layouts, this is the x-coordinate of the pixel. For vertical layouts, this is the y-coordinate. - * @param wholeItem true if the item must be completely visible; otherwise, false if its ok for the item to be partially visible. Promise. - * @returns A Promise for the index of the first visible item at the specified point. - **/ - calculateFirstVisible(beginScrollPosition: number, wholeItem: boolean): Promise; - - /** - * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. - * @param endScrollPosition The last visible pixel in the ListView. For horizontal layouts, this is the x-coordinate of the pixel. For vertical layouts, this is the y-coordinate. - * @param wholeItem true if the item must be completely visible; otherwise, false if its ok for the item to be partially visible. Promise. - * @returns A Promise for the index of the last visible item at the specified point. - **/ - calculateLastVisible(endScrollPosition: number, wholeItem: boolean): Promise; - - /** - * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. - * @returns A object that has these properties: animationPromise, newEndIndex. - **/ - endLayout(): any; - - /** - * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. - * @param itemIndex The index of the item. - * @returns A Promise that returns an object with these properties: left, top, contentWidth, contentHeight, totalWidth, totalHeight. - **/ - getItemPosition(itemIndex: number): Promise; - - /** - * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. - * @param itemIndex The data source index of the current item. - * @param element The element for the current item. - * @param keyPressed The key that was pressed. This function must check for the arrow keys (leftArrow, upArrow, rightArrow, downArrow), pageDown, and pageUp and determine which item the user navigated to. - * @returns A Promise that contains the index of the next item (This item becomes the current item). - **/ - getKeyboardNavigatedItem(itemIndex: number, element: HTMLElement, keyPressed: WinJS.Utilities.Key): Promise; - - /** - * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. - * @returns A Promise that returns an object that has these properties: beginScrollPosition, endScrollPosition. - **/ - getScrollBarRange(): Promise; - - /** - * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. - * @param x The x-coordinate to test. - * @param y The y-coordinate to test. - **/ - hitTest(x: number, y: number): void; - - /** - * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. - * @param elements The elements that represent the items that were added. - **/ - itemsAdded(elements: HTMLElement[]): void; - - /** - * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. - **/ - itemsMoved(): void; - - /** - * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. - * @param elements The elements that represent the items that were removed. - **/ - itemsRemoved(elements: HTMLElement[]): void; - - /** - * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. - * @param groupIndex The index of the group in the group data source. - * @param element The element to render for the group header. - **/ - layoutHeader(groupIndex: number, element: HTMLElement): void; - - /** - * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. - * @param itemIndex The index of the item in the data source. - * @param element The element to render for the item. - **/ - layoutItem(itemIndex: number, element: HTMLElement): void; - - /** - * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. - * @param element The element that represents a header in the data source. - **/ - prepareHeader(element: HTMLElement): void; - - /** - * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. - * @param element An element that represents an item in the data source. - **/ - prepareItem(element: HTMLElement): void; - - /** - * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. - * @param element The element being released. - **/ - releaseItem(element: HTMLElement): void; - - /** - * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. - **/ - reset(): void; - - /** - * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. - * @param site The layout site for the layout. You can use this object to query the hosting ListView for info you might need to lay out items. - **/ - setSite(site: ILayoutSite): void; - - /** - * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. - * @param beginScrollPosition The starting pixel of the area to which the items are rendered. - * @param endScrollPosition The last pixel of the area to which the items are rendered. - * @param count The upper bound of the number of items to render. - * @returns A Promise that returns an object that has these properties: beginIndex, endIndex. - **/ - startLayout(beginScrollPosition: number, endScrollPosition: number, count: number): Promise; - - //#endregion Methods - - //#region Properties - - /** - * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. - **/ - horizontal: boolean; - - //#endregion Properties - - } - /** * Represents a layout for the ListView. **/ @@ -3613,14 +3934,15 @@ declare module WinJS.UI { //#region Objects /** - * Represents an application toolbar for displaying commands. + * Displays ICommands in overlayed application pane that opens and closes at the top or bottom of the main view. **/ class AppBar { + //#region Constructors /** * Creates a new AppBar object. - * @constructor + * @constructor * @param element The DOM element that will host the control. * @param options The set of properties and values to apply to the new AppBar. **/ @@ -3631,28 +3953,28 @@ declare module WinJS.UI { //#region Events /** - * Occurs immediately after the AppBar is hidden. + * Occurs immediately after the AppBar is closed. * @param eventInfo An object that contains information about the event. **/ - onafterhide(eventInfo: Event): void; + onafterclose: (eventInfo: CustomEvent) => void; /** - * Occurs after the AppBar is shown. + * Occurs immeidately after the AppBar is opened. * @param eventInfo An object that contains information about the event. **/ - onaftershow(eventInfo: Event): void; + onafteropen: (eventInfo: CustomEvent) => void; /** - * Occurs before the AppBar is hidden. + * Occurs immediately before the AppBar is closed. Is cancelable. * @param eventInfo An object that contains information about the event. **/ - onbeforehide(eventInfo: Event): void; + onbeforeclose: (eventInfo: CustomEvent) => void; /** - * Occurs before a hidden AppBar is shown. + * Occurs immediately before the AppBar is opened. Is cancelable. * @param eventInfo An object that contains information about the event. **/ - onbeforeshow(eventInfo: Event): void; + onbeforeopen: (eventInfo: CustomEvent) => void; //#endregion Events @@ -3660,11 +3982,19 @@ declare module WinJS.UI { /** * Registers an event handler for the specified event. - * @param type The event type to register. It must be beforeshow, beforehide, aftershow, or afterhide. + * @param type The event type to register. It must be beforeopen, beforeclose, afteropen, or afterclose. * @param listener The event handler function to associate with the event. * @param useCapture Set to true to register the event handler for the capturing phase; otherwise, set to false to register the event handler for the bubbling phase. **/ - addEventListener(type: string, listener: Function, useCapture?: boolean): void; + addEventListener(eventName: string, eventHandler: Function, useCapture?: boolean): void; + + /** + * Removes an event handler that the addEventListener method registered. + * @param type The event type to unregister. It must be beforeopen, beforeclose, afteropen, or afterclose. + * @param listener The event handler function to remove. + * @param useCapture Set to true to remove the capturing phase event handler; set to false to remove the bubbling phase event handler. + **/ + removeEventListener(eventName: string, eventHandler: Function, useCapture?: boolean): void; /** * Raises an event of the specified type and with additional properties. @@ -3672,7 +4002,7 @@ declare module WinJS.UI { * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. * @returns true if preventDefault was called on the event, otherwise false. **/ - dispatchEvent(type: string, eventProperties: any): boolean; + dispatchEvent(eventName: string, eventProperties: any): boolean; /** * Releases resources held by this AppBar. Call this method when the AppBar is no longer needed. After calling this method, the AppBar becomes unusable. @@ -3680,69 +4010,46 @@ declare module WinJS.UI { dispose(): void; /** - * Returns the AppBarCommand object identified by id. + * Returns the Command object identified by id. * @param id The element idenitifier (ID) of the command to be returned. - * @returns The command identified by id. If multiple commands have the same ID, returns an array of all the commands matching the ID. + * @returns The command identified by id. If multiple commands have the same ID, returns the first command found. **/ - getCommandById(id: string): AppBarCommand; - - /** - * Hides the AppBar. - **/ - hide(): void; - - /** - * Hides the specified commands of the AppBar. - * @param commands The commands to hide. The array elements may be AppBarCommand objects, or the string identifiers (IDs) of commands. - * @param immediate The parameter immediate is not supported and may be altered or unavailable in the future. true to hide the commands immediately, without animating them; otherwise, false. - **/ - hideCommands(commands: any[], immediate?: boolean): void; - - /** - * Removes an event handler that the addEventListener method registered. - * @param type The event type to unregister. It must be beforeshow, beforehide, aftershow, or afterhide. - * @param listener The event handler function to remove. - * @param useCapture Set to true to remove the capturing phase event handler; set to false to remove the bubbling phase event handler. - **/ - removeEventListener(type: string, listener: Function, useCapture?: boolean): void; - - /** - * Shows the AppBar if it is not disabled. - **/ - show(): void; - - /** - * Shows the specified commands of the AppBar. - * @param commands The commands to show. The array elements may be AppBarCommand objects, or the string identifiers (IDs) of commands. - * @param immediate The parameter immediate is not supported and may be altered or unavailable in the future. true to show the commands immediately, without animating them; otherwise, false. - **/ - showCommands(commands: any[], immediate?: boolean): void; + getCommandById(id: string): ICommand; /** * Shows the specified commands of the AppBar while hiding all other commands. - * @param commands The commands to show. The array elements may be AppBarCommand objects, or the string identifiers (IDs) of commands. - * @param immediate The parameter immediate is not supported and may be altered or unavailable in the future. true to show the specified commands (and hide the others) immediately, without animating them; otherwise, false. + * @param commands The commands to show. The array elements may be ICommand objects, or the string identifiers (IDs) of commands. **/ - showOnlyCommands(commands: any[], immediate?: boolean): void; + showOnlyCommands(commands: Array): void; + + /** + * Opens the AppBar. + **/ + open(): void; + + /** + * Closes the AppBar. + **/ + close(): void; + + /** + * Forces the AppBar to update its layout. + **/ + forceLayout(): void; //#endregion Methods //#region Properties /** - * Gets/Sets how AppBar will display itself while hidden. Values are "none" and "minimal". + * Gets/Sets how AppBar will display itself while closed. Values are "none" , "minimal", "compact" and "full". **/ closedDisplayMode: string; /** - * Sets the AppBarCommand objects that appear in the app bar. + * Gets or sets the Binding List of WinJS.UI.Command for the AppBar. **/ - commands: AppBarCommand[]; - - /** - * Gets or sets a value that indicates whether the AppBar is disabled. - **/ - disabled: boolean; + data: WinJS.Binding.List; /** * Gets the DOM element that hosts the AppBar. @@ -3750,24 +4057,55 @@ declare module WinJS.UI { element: HTMLElement; /** - * Gets a value that indicates whether the AppBar is hidden or in the process of becoming hidden. + * Gets or sets whether the AppBar is currently opened. **/ - hidden: boolean; - - /** - * Gets or sets the layout of the app bar contents. - **/ - layout: string; + opened: boolean; /** * Gets or sets a value that specifies whether the AppBar appears at the top or bottom of the main view. **/ placement: string; - /** - * Gets or sets a value that indicates whether the AppBar is sticky (won't light dismiss). If not sticky, the app bar dismisses normally when the user touches outside of the appbar. + /** + * Display options for the AppBar when closed. **/ - sticky: boolean; + static ClosedDisplayMode: { + /** + * When the AppBar is closed, it is not visible and doesn't take up any space. + **/ + none: string; + /** + * When the AppBar is closed, its height is reduced to the minimal height required to display only its overflowbutton. All other content in the AppBar is not displayed. + **/ + minimal: string; + /** + * When the AppBar is closed, its height is reduced such that button commands are still visible, but their labels are hidden. + **/ + compact: string; + /** + * When the AppBar is closed, its height is always sized to content. + **/ + full: string; + }; + + /** + * Display options for AppBar placement in relation to the main view. + */ + static Placement: { + /** + * The AppBar appears at the top of the main view + **/ + top: string; + /** + * The AppBar appears at the bottom of the main view + **/ + bottom: string; + }; + + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; //#endregion Properties @@ -3776,12 +4114,12 @@ declare module WinJS.UI { /** * Represents a command to be displayed in an app bar. **/ - class AppBarCommand { + class AppBarCommand implements ICommand { //#region Constructors /** * Creates a new AppBarCommand object. - * @constructor + * @constructor * @param element The DOM element that will host the control. * @param options The set of properties and values to apply to the new AppBarCommand. **/ @@ -3806,7 +4144,7 @@ declare module WinJS.UI { /** * Removes an event handler that the addEventListener method registered. - * @param type The event type to unregister. It must be beforeshow, beforehide, aftershow, or afterhide. + * @param type The event type to unregister. * @param listener The event handler function to remove. * @param useCapture Set to true to remove the capturing phase event handler; set to false to remove the bubbling phase event handler. **/ @@ -3872,7 +4210,7 @@ declare module WinJS.UI { onclick: Function; /** - * Gets the section of the app bar that the command is in. + * Gets the section of the parent control that the command is in. The section can only be set through constructor options. **/ section: string; @@ -3887,14 +4225,159 @@ declare module WinJS.UI { tooltip: string; /** - * Gets the type of the command. + * Gets the type of the command. The type can only be set through constructor options. **/ type: string; + /** + * Gets or sets the priority of the command + **/ + priority: number; + + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + //#endregion Properties } + /** + * A rich input box that provides suggestions as the user types. + **/ + class AutoSuggestBox { + //#region Constructors + + /** + * Creates a new AutoSuggestBox. + * @constructor + * @param element The DOM element hosts the new AutoSuggestBox. + * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. + **/ + constructor(element?: HTMLElement, options?: any); + + //#endregion Constructors + + //#region Events + + /** + * Raised when the user or the app changes the queryText. + * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.language, detail.queryText, detail.linguisticDetails. + **/ + onquerychanged(eventInfo: CustomEvent): void; + + /** + * Raised awhen the user presses Enter. + * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.language, detail.queryText, detail.linguisticDetails, detail.keyModifiers. + **/ + onquerysubmitted(eventInfo: CustomEvent): void; + + /** + * Raised when the user selects a suggested option for their query. + * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.tag, detail.keyModifiers, detail.storageFile. + **/ + onresultsuggestionchosen(eventInfo: CustomEvent): void; + + /** + * Raised when the system requests suggestions from this app. + * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.language, detail.linguisticDetails, detail.queryText, detail.searchSuggestionCollection. + **/ + onsuggestionsrequested(eventInfo: CustomEvent): void; + + //#endregion Events + + //#region Methods + + /** + * Registers an event handler for the specified event. + * @param eventName The name of the event to handle. Note that you drop the "on" when specifying the event name. For example, instead of specifying "onclick", you specify "click". + * @param eventHandler The event handler function to associate with the event. + * @param useCapture Set to true to register the event handler for the capturing phase; otherwise, set to false to register the event handler for the bubbling phase. + **/ + addEventListener(eventName: string, eventHandler: Function, useCapture?: boolean): void; + + /** + * Raises an event of the specified type and with additional properties. + * @param type The type (name) of the event. + * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. + * @returns true if preventDefault was called on the event, otherwise false. + **/ + dispatchEvent(type: string, eventProperties: any): boolean; + + /** + * Releases resources held by this AutoSuggestBox. Call this method when the AutoSuggestBox is no longer needed. After calling this method, the AutoSuggestBox becomes unusable. + **/ + dispose(): void; + + /** + * Removes an event handler that the addEventListener method registered. + * @param eventName The name of the event that the event handler is registered for. + * @param eventCallback The event handler function to remove. + * @param useCapture Set to true to remove the capturing phase event handler; set to false to remove the bubbling phase event handler. + **/ + removeEventListener(eventName: string, eventCallback: Function, useCapture?: boolean): void; + + /** + * Specifies whether suggestions based on local files are automatically displayed in the input field, and defines the criteria that + * the system uses to locate and filter these suggestions. + * @param settings The new settings for local content suggestions. + **/ + setLocalContentSuggestionSettings(settings: any): void + + //#endregion Methods + + //#region Properties + + /** + * Gets or sets whether the first suggestion is chosen when the user presses Enter. + **/ + chooseSuggestionOnEnter: boolean; + + /** + * Gets or sets a value that specifies whether the AutoSuggestBox is disabled. If the control is disabled, it won't receive focus. + **/ + disabled: boolean; + + /** + * Gets the DOM element that hosts the AutoSuggestBox. + **/ + element: HTMLElement; + + /** + * Gets or sets the placeholder text for the AutoSuggestBox. This text is displayed if there is no other text in the input box. + **/ + placeholderText: string; + + /** + * Gets or sets the query text for the AutoSuggestBox. + **/ + queryText: string; + + /** + * Gets or sets the history context. This context is used a secondary key (the app ID is the primary key) for storing history. + **/ + searchHistoryContext: string; + + /** + * Gets or sets a value that specifies whether history is disabled. + **/ + searchHistoryDisabled: boolean; + + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + + //#endregion Properties + + /** + * Creates the image argument for SearchSuggestionCollection.appendResultSuggestion. + * @param url The url of the image. + **/ + static createResultSuggestionImage(url: string): any; + } + /** * Provides backwards navigation in the form of a button. **/ @@ -3903,7 +4386,7 @@ declare module WinJS.UI { /** * Creates a new BackButton. - * @constructor + * @constructor * @param element The DOM element hosts the new BackButton. * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. **/ @@ -3956,6 +4439,11 @@ declare module WinJS.UI { **/ element: HTMLElement; + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + //#endregion Properties } @@ -3968,7 +4456,7 @@ declare module WinJS.UI { /** * Creates a new CellSpanningLayout. - * @constructor + * @constructor * @param options An object that contains one or more property/value pairs to apply to the new CellSpanningLayout. Each property of the options object corresponds to one of the object's properties or events. Event names must begin with "on". **/ constructor(options?: any); @@ -4023,10 +4511,10 @@ declare module WinJS.UI { /** * This API supports the WinJS infrastructure and is not intended to be used directly from your code. - * @param tree - * @param changedRange - * @param modifiedItems - * @param modifiedGroups + * @param tree + * @param changedRange + * @param modifiedItems + * @param modifiedGroups **/ layout(tree: ILayoutSite2, changedRange: any, modifiedItems: any, modifiedGroups: any): void; @@ -4074,10 +4562,178 @@ declare module WinJS.UI { **/ orientation: WinJS.UI.Orientation; + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + //#endregion Properties } + /** + * Data associated with hiding a dialog. + **/ + interface ContentDialogHideInfo { + /*** + * The dialog's dismissal result. May be 'primary', 'secondary', 'none', or whatever custom value was passed to hide. + **/ + result: string + } + + /** + * Event object associated with hiding a dialog. + **/ + interface ContentDialogHideEvent extends Event { + detail: ContentDialogHideInfo + } + + /** + * Represents a command to be displayed in an AppBar or ToolBar + **/ + class Command extends AppBarCommand implements ICommand { + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + } + + /** + * Displays a modal dialog which can display arbitrary HTML content. + **/ + class ContentDialog { + /** + * Specifies the result of dismissing the ContentDialog. + **/ + static DismissalResult: { + /** + * The dialog was dismissed without the user selecting any of the commands. The user may have dismissed the dialog by hitting the escape key or pressing the hardware back button. + **/ + none: string; + /** + * The user dismissed the dialog by pressing the primary command. + **/ + primary: string; + /** + * The user dismissed the dialog by pressing the secondary command. + **/ + secondary: string + } + + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + + /** + * Creates a new ContentDialog control. + * @constructor + * @param The DOM element that hosts the ContentDialog control. + * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. + **/ + constructor(element?: HTMLElement, options?: any); + + /** + * Gets the DOM element that hosts the ContentDialog control. + **/ + element: HTMLElement; + + /** + * Gets or sets the ContentDialog's visibility. + **/ + hidden: boolean; + + /** + * The text displayed as the title of the dialog. + **/ + title: string; + + /** + * The text displayed on the primary command's button. + **/ + primaryCommandText: string; + + /** + * Indicates whether the button representing the primary command is currently disabled. + **/ + primaryCommandDisabled: boolean; + + /** + * The text displayed on the secondary command's button. + **/ + secondaryCommandText: string; + + /** + * Indicates whether the button representing the secondary command is currently disabled. + **/ + secondaryCommandDisabled: boolean; + + /** + * Shows the ContentDialog. Only one ContentDialog may be shown at a time. If another ContentDialog is already shown, this ContentDialog will remain hidden. + * @returns A promise which is successfully fulfilled when the dialog is dismissed. The completion value indicates the dialog's dismissal result. This may be 'primary', 'secondary', 'none', or whatever custom value was passed to hide. If this ContentDialog cannot be shown because a ContentDialog is already showing or the ContentDialog is disposed, then the return value is a promise which is in an error state. If preventDefault() is called on the beforeshow event, then this promise will be canceled. + **/ + show(): Promise; + + /** + * Hides the ContentDialog. + * @param result A value indicating why the dialog is being hidden. The promise returned by show will be fulfilled with this value. + **/ + hide(result?: any): void; + + /** + * Disposes this control. + **/ + dispose(): void; + + /** + * Registers an event handler for the specified event. + * @param eventName The name of the event to handle. Note that you drop the "on" when specifying the event name. For example, instead of specifying "onclick", you specify "click". + * @param eventHandler The event handler function to associate with the event. + * @param useCapture Set to true to register the event handler for the capturing phase; otherwise, set to false to register the event handler for the bubbling phase. + **/ + addEventListener(type: string, listener: Function, useCapture?: boolean): void; + + /** + * Removes an event handler that the addEventListener method registered. + * @param eventName The name of the event that the event handler is registered for. + * @param eventCallback The event handler function to remove. + * @param useCapture Set to true to remove the capturing phase event handler; set to false to remove the bubbling phase event handler. + **/ + removeEventListener(type: string, listener: Function, useCapture?: boolean): void; + + /** + * Raises an event of the specified type and with additional properties. + * @param type The type (name) of the event. + * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. + * @returns true if preventDefault was called on the event, otherwise false. + **/ + dispatchEvent(type: string, eventProperties: any): boolean; + + /** + * Raised just before showing a dialog. Call preventDefault on this event to stop the dialog from being shown. + * @param eventInfo An object that contains information about the event. + **/ + onbeforeshow(eventInfo: Event): void; + + /** + * Raised immediately after a dialog is fully shown. + * @param eventInfo An object that contains information about the event. + **/ + onaftershow(eventInfo: Event): void; + + /** + * Raised just before hiding a dialog. Call preventDefault on this event to stop the dialog from being hidden. + * @param eventInfo An object that contains information about the event. + **/ + onbeforehide(eventInfo: ContentDialogHideEvent): void; + + /** + * Raised immediately after a dialog is fully hidden. + * @param eventInfo An object that contains information about the event. + **/ + onafterhide(eventInfo: ContentDialogHideEvent): void; + } + /** * Allows users to pick a date value. **/ @@ -4086,7 +4742,7 @@ declare module WinJS.UI { /** * Initializes a new instance of the DatePicker control. - * @constructor + * @constructor * @param element The DOM element associated with the DatePicker control. * @param options The set of options to be applied initially to the DatePicker control. The options are the following: calendar, current, datePattern, disabled, maxYear, minYear, monthPattern, yearPattern. **/ @@ -4128,12 +4784,9 @@ declare module WinJS.UI { dispose(): void; /** - * Raises an event of the specified type and with additional properties. - * @param type The type (name) of the event. - * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. - * @returns true if preventDefault was called on the event, otherwise false. + * This API supports the WinJS infrastructure and is not intended to be used directly from your code. Use render instead. **/ - raiseEvent(type: string, eventProperties: any): boolean; + static getInformation(startDate: any, endDate: any, calendar?: any, datePatterns?: any): any; /** * Removes a listener for the specified event. @@ -4192,6 +4845,11 @@ declare module WinJS.UI { **/ yearPattern: string; + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + //#endregion Properties } @@ -4199,7 +4857,7 @@ declare module WinJS.UI { /** * Adds event-related methods to the control. **/ - class DOMEventMixin { + module DOMEventMixin { //#region Methods /** @@ -4208,7 +4866,7 @@ declare module WinJS.UI { * @param listener The listener to invoke when the event gets raised. * @param useCapture true to initiate capture; otherwise, false. **/ - addEventListener(type: string, listener: Function, useCapture?: boolean): void; + export function addEventListener(type: string, listener: Function, useCapture?: boolean): void; /** * Raises an event of the specified type, adding the specified additional properties. @@ -4216,7 +4874,7 @@ declare module WinJS.UI { * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. * @returns true if preventDefault was called on the event, otherwise false. **/ - dispatchEvent(type: string, eventProperties: any): boolean; + export function dispatchEvent(type: string, eventProperties: any): boolean; /** * Removes an event listener from the control. @@ -4224,17 +4882,9 @@ declare module WinJS.UI { * @param listener The listener to remove. * @param useCapture true to initiate capture; otherwise, false. **/ - removeEventListener(type: string, listener: Function, useCapture?: boolean): void; - - /** - * Adds the set of declaratively specified options (properties and events) to the specified control. If the name of the options property begins with "on", the property value is a function and the control supports addEventListener. This method calls the addEventListener method on the control. - * @param control The control on which the properties and events are to be applied. - * @param options The set of options that are specified declaratively. - **/ - setOptions(control: any, options: any): void; + export function removeEventListener(type: string, listener: Function, useCapture?: boolean): void; //#endregion Methods - } /** @@ -4245,7 +4895,7 @@ declare module WinJS.UI { /** * Creates a new FlipView. - * @constructor + * @constructor * @param element The DOM element that hosts the control. * @param options An object that contains one or more property/value pairs to apply to the new control. Each property corresponds to one of the control's properties or events. Event names must begin with "on". For example, to provide a handler for the pageselected event, add a property named "onpageselected" and set its value to the event handler. **/ @@ -4375,6 +5025,31 @@ declare module WinJS.UI { **/ orientation: string; + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + + /** + * Event Name + **/ + static datasourceCountChangedEvent: string; + + /** + * Event Name + **/ + static pageCompletedEvent: string; + + /** + * Event Name + **/ + static pageSelectedEvent: string; + + /** + * Event Name + **/ + static pageVisibilityChangedEvent: string; + //#endregion Properties } @@ -4387,7 +5062,7 @@ declare module WinJS.UI { /** * Creates a new Flyout object. - * @constructor + * @constructor * @param element The DOM element that will host the control. * @param options The set of properties and values to apply to the new Flyout. **/ @@ -4433,6 +5108,14 @@ declare module WinJS.UI { **/ addEventListener(type: string, listener: Function, useCapture?: boolean): void; + /** + * Raises an event of the specified type and with additional properties. + * @param type The type (name) of the event. + * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. + * @returns true if preventDefault was called on the event, otherwise false. + **/ + dispatchEvent(eventName: string, eventProperties: any): boolean; + /** * Releases resources held by this object. Call this method when the object is no longer needed. After calling this method, the object becomes unusable. **/ @@ -4443,6 +5126,26 @@ declare module WinJS.UI { **/ hide(): void; + /** + * Shows the Flyout, if hidden, regardless of other states. + * @param anchor. DOM element to temporarily anchor the position of the Flyout to. This is optional if Flyout.anchor has already been set. + * @param placement The placement of the Flyout to the anchor: the string literal "top", "bottom", "left", or "right". + * @param alignment For "top" or "bottom" placement, the alignment of the Flyout to the anchor's edge: the string literal "center", "left", or "right". + **/ + show(anchor?: HTMLElement, placement?: string, alignment?: string): void; + + /** + * Shows the Flyout, if hidden, regardless of other states, top and left aligned at the specified coordinates, + * @param coordinates Required. The point where the top left corner of the flyout will appear, relative to the top and left edge of the visual viewport. + **/ + showAt(coordinates: { x: number; y: number; }): void; + + /** + * Shows the Flyout, if hidden, regardless of other states, top and left aligned at the location of the mouse event object, + * @param mouseEventObj Required. The MouseEvent Object specifying where to show the Flyout. + **/ + showAt(mouseEventObj: MouseEvent): void; + /** * Removes an event handler that the addEventListener method registered. * @param type The event type to unregister. It must be beforeshow, beforehide, aftershow, or afterhide. @@ -4451,14 +5154,6 @@ declare module WinJS.UI { **/ removeEventListener(type: string, listener: Function, useCapture?: boolean): void; - /** - * Shows the Flyout, if hidden, regardless of other states. - * @param anchor Required. The DOM element to anchor the Flyout. - * @param placement The placement of the Flyout to the anchor: the string literal "top", "bottom", "left", or "right". - * @param alignment For "top" or "bottom" placement, the alignment of the Flyout to the anchor's edge: the string literal "center", "left", or "right". - **/ - show(anchor: HTMLElement, placement?: string, alignment?: string): void; - //#endregion Methods //#region Properties @@ -4473,13 +5168,18 @@ declare module WinJS.UI { **/ anchor: HTMLElement; + /** + * Gets or sets a value that indicates whether the Flyout is disabled. + **/ + disabled: boolean; + /** * Gets the DOM element that hosts the Flyout. **/ element: HTMLElement; /** - * Gets a value that indicates whether the Flyout is hidden or in the process of becoming hidden. + * Gets a value that indicates whether the Flyout is hidden or in the process of becoming hidden, or sets the Flyout to hide or show itself. **/ hidden: boolean; @@ -4488,6 +5188,11 @@ declare module WinJS.UI { **/ placement: string; + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + //#endregion Properties } @@ -4500,7 +5205,7 @@ declare module WinJS.UI { /** * Creates a new GridLayout object. - * @constructor + * @constructor * @param options The set of properties and values to apply to the new GridLayout. **/ constructor(options?: any); @@ -4509,20 +5214,6 @@ declare module WinJS.UI { //#region Methods - /** - * This method is no longer supported. - * @param beginScrollPosition - * @param wholeItem - **/ - calculateFirstVisible(beginScrollPosition: number, wholeItem: boolean): void; - - /** - * This method is no longer supported. - * @param endScrollPosition - * @param wholeItem - **/ - calculateLastVisible(endScrollPosition: number, wholeItem: boolean): void; - /** * This API supports the WinJS infrastructure and is not intended to be used directly from your code. **/ @@ -4533,11 +5224,6 @@ declare module WinJS.UI { **/ dragOver(): void; - /** - * This method is no longer supported. - **/ - endLayout(): void; - /** * This API supports the WinJS infrastructure and is not intended to be used directly from your code. **/ @@ -4551,27 +5237,6 @@ declare module WinJS.UI { **/ getAdjacent(currentItem: any, pressedKey: WinJS.Utilities.Key): any; - /** - * This method is no longer supported. - * @param itemIndex - **/ - getItemPosition(itemIndex: number): void; - - /** - * This method is no longer supported. - * @param itemIndex - * @param element - * @param keyPressed - **/ - getKeyboardNavigatedItem(itemIndex: number, element: any, keyPressed: any): void; - - /** - * This method is no longer supported. - * @param beginScrollPosition - * @param endScrollPosition - **/ - getScrollbarRange(beginScrollPosition: number, endScrollPosition: number): void; - /** * This API supports the WinJS infrastructure and is not intended to be used directly from your code. * @param x The x-coordinate, or the horizontal position on the screen. @@ -4579,11 +5244,6 @@ declare module WinJS.UI { **/ hitTest(x: number, y: number): void; - /** - * This method is no longer supported. - **/ - init(): void; - /** * This API supports the WinJS infrastructure and is not intended to be used directly from your code. * @param site The rendering site for the layout. @@ -4591,12 +5251,6 @@ declare module WinJS.UI { **/ initialize(site: ILayoutSite2, groupsEnabled: boolean): void; - /** - * This method is no longer supported. - * @param elements - **/ - itemsAdded(elements: any): void; - /** * This API supports the WinJS infrastructure and is not intended to be used directly from your code. * @param firstPixel The first pixel the range of items falls between. @@ -4604,94 +5258,25 @@ declare module WinJS.UI { **/ itemsFromRange(firstPixel: number, lastPixel: number): void; - /** - * This method is no longer supported. - **/ - itemsMoved(): void; - - /** - * This method is no longer supported. - * @param elements - **/ - itemsRemoved(elements: any): void; - /** * This API supports the WinJS infrastructure and is not intended to be used directly from your code. - * @param tree - * @param changedRange - * @param modifiedItems - * @param modifiedGroups + * @param tree + * @param changedRange + * @param modifiedItems + * @param modifiedGroups **/ layout(tree: any, changedRange: any, modifiedItems: any, modifiedGroups: any): void; - /** - * This method is no longer supported. - * @param groupIndex - * @param element A DOM element. - **/ - layoutHeader(groupIndex: number, element: any): void; - - /** - * This method is no longer supported. - * @param itemIndex - * @param element A DOM element. - **/ - layoutItem(itemIndex: number, element: any): void; - - /** - * This method is no longer supported. - * @param element - **/ - prepareHeader(element: HTMLElement): void; - - /** - * This method is no longer supported. - * @param itemIndex - * @param element A DOM element. - **/ - prepareItem(itemIndex: number, element: any): void; - - /** - * This method is no longer supported. - * @param item - * @param newItem - **/ - releaseItem(item: any, newItem: any): void; - - /** - * This method is no longer supported. - **/ - reset(): void; - - /** - * This method is no longer supported. - * @param layoutSite - **/ - setSite(layoutSite: any): void; - /** * This API supports the WinJS infrastructure and is not intended to be used directly from your code. **/ setupAnimations(): void; - /** - * This method is no longer supported. - * @param beginScrollPosition - * @param endScrollPositionScrollPosition - **/ - startLayout(beginScrollPosition: number, endScrollPositionScrollPosition: number): void; - /** * This API supports the WinJS infrastructure and is not intended to be used directly from your code. **/ uninitialize(): void; - /** - * This method is no longer supported. - * @param count - **/ - updateBackdrop(count: number): void; - //#endregion Methods //#region Properties @@ -4716,11 +5301,6 @@ declare module WinJS.UI { **/ groupInfo: Function; - /** - * This property is no longer supported. Starting with the Windows Library for JavaScript 2.0, use the orientation property instead. - **/ - horizontal: boolean; - /** * This property is no longer supported. Starting with the Windows Library for JavaScript 2.0, use a CellSpanningLayout. **/ @@ -4746,6 +5326,11 @@ declare module WinJS.UI { **/ orientation: WinJS.UI.Orientation; + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + //#endregion Properties } @@ -4758,7 +5343,7 @@ declare module WinJS.UI { /** * Creates a new Hub control. - * @constructor + * @constructor * @param element The DOM element that will host the Hub control. * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. Event names must begin with "on". For example, to provide a handler for the contentanimating event, add a property named "oncontentanimating" to the options object and set its value to the event handler. **/ @@ -4811,6 +5396,12 @@ declare module WinJS.UI { **/ dispose(): void; + /** + * Forces the Hub to update its layout. + * Use this function when making the Hub visible again after you've set its style.display property to "none” or after style changes have been made that affect the size of the HubSections. + **/ + forceLayout(): void; + /** * Removes an event handler that the addEventListener method registered. * @param eventName The name of the event that the event handler is registered for. @@ -4873,6 +5464,47 @@ declare module WinJS.UI { **/ zoomableView: IZoomableView; + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + + /** + * Specifies whether the Hub animation is an entrance animation or a transition animation. + **/ + static AnimationType: { + /** + * The animation plays when the Hub is first displayed. + **/ + entrance: string; + /** + * The animation plays when the Hub is changing its content. + **/ + contentTransition: string; + /** + * The animation plays when a section is inserted into the Hub. + **/ + insert: string; + /** + * The animation plays when a section is removed into the Hub. + **/ + remove: string; + } + + /** + * Gets the current loading state of the Hub. + **/ + static LoadingState: { + /** + * The Hub is loading sections. + **/ + loading: string; + /** + * All sections are loaded and animations are complete. + **/ + complete: string; + } + //#endregion Properties } @@ -4885,7 +5517,7 @@ declare module WinJS.UI { /** * Creates a new HubSection. - * @constructor + * @constructor * @param element The DOM element hosts the new HubSection. * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. **/ @@ -4924,6 +5556,16 @@ declare module WinJS.UI { **/ isHeaderStatic: boolean; + /** + * This object supports the WinJS infrastructure and is not intended to be used directly from your code. + **/ + static isDeclarativeControlContainer: any; + + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + //#endregion Properties } @@ -4944,6 +5586,15 @@ declare module WinJS.UI { //#endregion Constructors + //#region Properties + + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + + //#endregion Properties + } /** @@ -4954,7 +5605,7 @@ declare module WinJS.UI { /** * Creates a new ItemContainer. - * @constructor + * @constructor * @param element The DOM element hosts the new ItemContainer. For the ItemContainer to be accessible, this element must have its role attribute set to "list" or "listbox". If tapBehavior is set to none and selectionDisabled is true, then use the "list" role; otherwise, use the "listbox" role. * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. **/ @@ -5059,6 +5710,11 @@ declare module WinJS.UI { **/ tapBehavior: TapBehavior; + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + //#endregion Properties } @@ -5067,6 +5723,10 @@ declare module WinJS.UI { * This object supports the WinJS infrastructure and is not intended to be used directly from your code. **/ class Layout { + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; } /** @@ -5077,7 +5737,7 @@ declare module WinJS.UI { /** * Creates a new ListLayout. - * @constructor + * @constructor * @param options An object that contains one or more property/value pairs to apply to the new ListLayout. Each property of the options object corresponds to one of the object's properties or events. Event names must begin with "on". **/ constructor(options?: any); @@ -5086,20 +5746,6 @@ declare module WinJS.UI { //#region Methods - /** - * This method is no longer supported. - * @param beginScrollPosition - * @param wholeItem - **/ - calculateFirstVisible(beginScrollPosition: number, wholeItem: boolean): void; - - /** - * This method is no longer supported. - * @param endScrollPosition - * @param wholeItem - **/ - calculateLastVisible(endScrollPosition: number, wholeItem: boolean): void; - /** * This API supports the WinJS infrastructure and is not intended to be used directly from your code. **/ @@ -5110,11 +5756,6 @@ declare module WinJS.UI { **/ dragOver(): void; - /** - * This method is no longer supported. - **/ - endLayout(): void; - /** * This API supports the WinJS infrastructure and is not intended to be used directly from your code. **/ @@ -5128,27 +5769,6 @@ declare module WinJS.UI { **/ getAdjacent(currentItem: any, pressedKey: WinJS.Utilities.Key): any; - /** - * This method is no longer supported. - * @param itemIndex - **/ - getItemPosition(itemIndex: number): void; - - /** - * This method is no longer supported. - * @param itemIndex - * @param element - * @param keyPressed - **/ - getKeyboardNavigatedItem(itemIndex: number, element: HTMLElement, keyPressed: any): void; - - /** - * This method is no longer supported. - * @param beginScrollPosition - * @param endScrollPosition - **/ - getScrollbarRange(beginScrollPosition: number, endScrollPosition: number): void; - /** * This API supports the WinJS infrastructure and is not intended to be used directly from your code. * @param x The x-coordinate, or the horizontal position on the screen. @@ -5156,117 +5776,37 @@ declare module WinJS.UI { **/ hitTest(x: number, y: number): void; - /** - * This method is no longer supported. - **/ - init(): void; - /** * This API supports the WinJS infrastructure and is not intended to be used directly from your code. **/ initialize(): void; - /** - * This method is no longer supported. - * @param elements - **/ - itemsAdded(elements: any): void; - /** * This API supports the WinJS infrastructure and is not intended to be used directly from your code. - * @param firstPixel - * @param lastPixel + * @param firstPixel + * @param lastPixel **/ itemsFromRange(firstPixel: number, lastPixel: number): void; - /** - * This method is no longer supported. - **/ - itemsMoved(): void; - - /** - * This method is no longer supported. - * @param elements - **/ - itemsRemoved(elements: any): void; - /** * This API supports the WinJS infrastructure and is not intended to be used directly from your code. - * @param tree - * @param changedRange - * @param modifiedItems - * @param modifiedGroups + * @param tree + * @param changedRange + * @param modifiedItems + * @param modifiedGroups **/ layout(tree: any, changedRange: any, modifiedItems: any, modifiedGroups: any): void; - /** - * This method is no longer supported. - * @param groupIndex - * @param element A DOM element. - **/ - layoutHeader(groupIndex: number, element: any): void; - - /** - * This method is no longer supported. - * @param itemIndex - * @param element A DOM element. - **/ - layoutItem(itemIndex: number, element: any): void; - - /** - * This method is no longer supported. - * @param element - **/ - prepareHeader(element: HTMLElement): void; - - /** - * This method is no longer supported. - * @param itemIndex - * @param element A DOM element. - **/ - prepareItem(itemIndex: number, element: any): void; - - /** - * This method is no longer supported. - * @param item - * @param newItem - **/ - releaseItem(item: any, newItem: any): void; - - /** - * This method is no longer supported. - **/ - reset(): void; - - /** - * This method is no longer supported. - * @param layoutSite - **/ - setSite(layoutSite: any): void; - /** * This API supports the WinJS infrastructure and is not intended to be used directly from your code. **/ setupAnimations(): void; - /** - * This method is no longer supported. - * @param beginScrollPosition - * @param endScrollPositionScrollPosition - **/ - startLayout(beginScrollPosition: number, endScrollPositionScrollPosition: number): void; - /** * This API supports the WinJS infrastructure and is not intended to be used directly from your code. **/ uninitialize(): void; - /** - * This method is no longer supported. - * @param count - **/ - updateBackdrop(count: number): void; - //#endregion Methods //#region Properties @@ -5286,21 +5826,6 @@ declare module WinJS.UI { **/ groupHeaderPosition: WinJS.UI.HeaderPosition; - /** - * This property is no longer supported. Starting with the Windows Library for JavaScript 2.0, use a CellSpanningLayout. - **/ - groupInfo: Function; - - /** - * This property is no longer supported. Starting with the Windows Library for JavaScript 2.0, use the orientation property instead. - **/ - horizontal: boolean; - - /** - * This property is no longer supported. Starting with the Windows Library for JavaScript 2.0, use a CellSpanningLayout. - **/ - itemInfo: Function; - /** * This API supports the WinJS infrastructure and is not intended to be used directly from your code. **/ @@ -5311,6 +5836,11 @@ declare module WinJS.UI { **/ orientation: WinJS.UI.Orientation; + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + //#endregion Properties } @@ -5323,7 +5853,7 @@ declare module WinJS.UI { /** * Creates a new ListView. - * @constructor + * @constructor * @param element The DOM element that hosts the ListView control. * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. Event names must begin with "on". For example, to provide a handler for the selectionchanged event, add a property named "onselectionchanged" to the options object and set its value to the event handler. **/ @@ -5333,6 +5863,12 @@ declare module WinJS.UI { //#region Events + /** + * Raised when the accessibility attributes have been added to the ListView items. + * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties detail.firstIndex, detail.lastIndex, detail.firstHeaderIndex, detail.lastHeaderIndex. + **/ + onaccessibilityannotationcomplete(eventInfo: CustomEvent): void; + /** * Occurs when the ListView is about to play an entrance or contentTransition animation. * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.type, detail.setPromise. @@ -5417,6 +5953,18 @@ declare module WinJS.UI { **/ onselectionchanging(eventInfo: CustomEvent): void; + /** + * Raised when the header's visibility property changes. + * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.visible. + **/ + onheadervisibilitychanged(eventInfo: CustomEvent): void; + + /** + * Raised when the footer's visibility property changes. + * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.visible. + **/ + onfootervisibilitychanged(eventInfo: CustomEvent): void; + //#endregion Events //#region Methods @@ -5559,6 +6107,16 @@ declare module WinJS.UI { **/ layout: ILayout2; + /** + * Gets or sets the footer of the ListView. + **/ + footer: HTMLElement; + + /** + * Gets or sets the header of the ListView. + **/ + header: HTMLElement; + /** * Gets or sets a value that specifies how the ListView fetches items and adds and removes them to the DOM. Don't change the value of this property after the ListView has begun loading data. **/ @@ -5575,15 +6133,25 @@ declare module WinJS.UI { maxDeferredItemCleanup: number; /** - * Gets or sets the number of pages to load when the loadingBehavior property is set to "incremental" and the user scrolls beyond the threshold specified by the pagesToLoadThreshold property. + * This property is deprecated. Gets or sets the number of pages to load when the loadingBehavior property is set to "incremental" and the user scrolls beyond the threshold specified by the pagesToLoadThreshold property. **/ pagesToLoad: number; /** - * Gets or sets the threshold (in pages) for initiating an incremental load. When the last visible item is within the specified number of pages from the end of the loaded portion of the list, and if automaticallyLoadPages is true and loadingBehavior is set to "incremental", the ListView initiates an incremental load. + * This property is deprecated. Gets or sets the threshold (in pages) for initiating an incremental load. When the last visible item is within the specified number of pages from the end of the loaded portion of the list, and if automaticallyLoadPages is true and loadingBehavior is set to "incremental", the ListView initiates an incremental load. **/ pagesToLoadThreshold: number; + /** + * Gets or sets the maximum number of pages to prefetch in the leading buffer for virtualization. + **/ + maxLeadingPages: number; + + /** + * Gets or sets the maximum number of pages to prefetch in the trailing buffer for virtualization. + **/ + maxTrailingPages: number; + /** * Gets or sets the function that is called when the ListView discards or recycles the element representation of a group header. **/ @@ -5624,19 +6192,59 @@ declare module WinJS.UI { **/ zoomableView: IZoomableView>; + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + //#endregion Properties } /** - * A tab control that displays multiple items. -**/ + * An enumeration of Media commands that the transport bar buttons support. + **/ + interface MediaCommand { + audioTracks: string; + cast: string; + chapterSkipBack: string; + chapterSkipForward: string; + closedCaptions: string; + fastForward: string; + goToLive: string; + nextTrack: string; + pause: string; + play: string; + playbackRate: string; + playFromBeginning: string; + previousTrack: string; + rewind: string; + seek: string; + stop: string; + timeSkipBack: string; + timeSkipForward: string; + volume: string; + zoom: string; + } + + /** + * The types of timeline markers supported by the MediaPlayer. + **/ + interface MarkerType { + advertisement: string; + chapter: string; + custom: string; + } + + /** + * A tab control that displays multiple items. + **/ class Pivot { //#region Constructors /** * Creates a new Pivot. - * @constructor + * @constructor * @param element The DOM element hosts the new Pivot. * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. Event names must begin with "on". For example, to provide a handler for the cancel event, add a property named "oncancel" to the options object and set its value to the event handler. **/ @@ -5689,6 +6297,12 @@ declare module WinJS.UI { **/ dispose(): void; + /** + * Forces the control to relayout its content. This function is expected to be called + * when the pivot element is manually resized. + **/ + forceLayout(): void; + /** * Removes an event handler that the addEventListener method registered. * @param eventName The name of the event that the event handler is registered for. @@ -5706,6 +6320,16 @@ declare module WinJS.UI { **/ element: HTMLElement; + /** + * Gets or sets the left custom header. + **/ + customLeftHeader: HTMLElement; + + /** + * Gets or sets the right custom header. + **/ + customRightHeader: HTMLElement; + /** * Gets or sets the Binding.List that contains the PivotItem objects that belong to this Pivot. **/ @@ -5726,6 +6350,11 @@ declare module WinJS.UI { **/ selectedItem: PivotItem; + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + /** * Gets or sets the title displayed above the PivotItem controls. **/ @@ -5742,7 +6371,7 @@ declare module WinJS.UI { /** * Creates a new PivotItem. - * @constructor + * @constructor * @param element The DOM element hosts the new PivotItem. * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. Event names must begin with "on". For example, to provide a handler for the cancel event, add a property named "oncancel" to the options object and set its value to the event handler. **/ @@ -5776,6 +6405,16 @@ declare module WinJS.UI { **/ header: string; + /** + * This object supports the WinJS infrastructure and is not intended to be used directly from your code. + **/ + static isDeclarativeControlContainer: any; + + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + //#endregion Properties } @@ -5787,7 +6426,7 @@ declare module WinJS.UI { /** * Creates a new Menu object. - * @constructor + * @constructor * @param element The DOM element that will host the control. * @param options The set of properties and values to apply to the new Menu. **/ @@ -5833,6 +6472,14 @@ declare module WinJS.UI { **/ addEventListener(type: string, listener: Function, useCapture?: boolean): void; + /** + * Raises an event of the specified type and with additional properties. + * @param type The type (name) of the event. + * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. + * @returns true if preventDefault was called on the event, otherwise false. + **/ + dispatchEvent(eventName: string, eventProperties: any): boolean; + /** * Releases resources held by this Menu. Call this method when the Menu is no longer needed. After calling this method, the Menu becomes unusable. **/ @@ -5855,7 +6502,7 @@ declare module WinJS.UI { * @param commands The commands to hide. The array elements may be MenuCommand objects, or the string identifiers (IDs) of commands. * @param immediate The parameter immediate is not supported and may be altered or unavailable in the future. true to hide the commands immediately, without animating them; otherwise, false. **/ - hideCommands(commands: any[], immediate: boolean): void; + hideCommands(commands: any[], immediate?: boolean): void; /** * Removes an event handler that the addEventListener method registered. @@ -5873,19 +6520,32 @@ declare module WinJS.UI { **/ show(anchor: HTMLElement, placement?: string, alignment?: string): void; + /** + * Shows the Menu, if hidden, regardless of other states, top and left aligned at the specified coordinates, + * @param coordinates Required. The point where the top left corner of the Menu will appear, relative to the top and left edge of the visual viewport. + **/ + showAt(coordinates: { x: number; y: number; }): void; + + /** + * Shows the Menu, if hidden, regardless of other states, top and left aligned at the location of the mouse event object, + * @param mouseEventObj Required. The MouseEvent Object specifying where to show the Menu. + **/ + showAt(mouseEventObj: MouseEvent): void; + + /** * Shows the specified commands of the Menu. * @param commands The commands to show. The array elements may be Menu objects, or the string identifiers (IDs) of commands. * @param immediate The parameter immediate is not supported and may be altered or unavailable in the future. true to show the commands immediately, without animating them; otherwise, false. **/ - showCommands(commands: any[], immediate: boolean): void; + showCommands(commands: any[], immediate?: boolean): void; /** * Shows the specified commands of the Menu while hiding all other commands. * @param commands The commands to show. The array elements may be MenuCommand objects, or the string identifiers (IDs) of commands. * @param immediate The parameter immediate is not supported and may be altered or unavailable in the future. true to show the specified commands (and hide the others) immediately, without animating them; otherwise, false. **/ - showOnlyCommands(commands: any[], immediate: boolean): void; + showOnlyCommands(commands: any[], immediate?: boolean): void; //#endregion Methods @@ -5906,13 +6566,18 @@ declare module WinJS.UI { **/ commands: MenuCommand[]; + /** + * Gets or sets a value that indicates whether the Menu is disabled. + **/ + disabled: boolean; + /** * Gets the DOM element that hosts the Menu. **/ element: HTMLElement; /** - * Gets a value that indicates whether the Menu is hidden or in the process of becoming hidden. + * Gets a value that indicates whether the Menu is hidden or in the process of becoming hidden, or sets the Menu to hide or show itself. **/ hidden: boolean; @@ -5921,6 +6586,11 @@ declare module WinJS.UI { **/ placement: string; + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + //#endregion Properties } @@ -5933,7 +6603,7 @@ declare module WinJS.UI { /** * Creates a new MenuCommand object. - * @constructor + * @constructor * @param element The DOM element that will host the control. * @param options The set of properties and values to apply to the new MenuCommand. **/ @@ -5945,7 +6615,7 @@ declare module WinJS.UI { /** * Registers an event handler for the specified event. - * @param type The event type to register. It must be beforeshow, beforehide, aftershow, or afterhide. + * @param type The event type to register. * @param listener The event handler function to associate with the event. * @param useCapture Set to true to register the event handler for the capturing phase; otherwise, set to false to register the event handler for the bubbling phase. **/ @@ -5958,7 +6628,7 @@ declare module WinJS.UI { /** * Removes an event handler that the addEventListener method registered. - * @param type The event type to unregister. It must be beforeshow, beforehide, aftershow, or afterhide. + * @param type The event type to unregister. * @param listener The event handler function to remove. * @param useCapture Set to true to remove the capturing phase event handler; set to false to remove the bubbling phase event handler. **/ @@ -6013,6 +6683,11 @@ declare module WinJS.UI { **/ selected: boolean; + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + /** * Gets the type of the command. **/ @@ -6023,14 +6698,14 @@ declare module WinJS.UI { } /** - * Displays navigation commands in a toolbar that the user can show or hide. + * Displays NavBarCommands in an overlayed navigation pane that opens and closes at the top or bottom of the main view. **/ class NavBar { //#region Constructors /** * Creates a new NavBar. - * @constructor + * @constructor * @param element The DOM element that will host the new NavBar. * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. **/ @@ -6041,28 +6716,28 @@ declare module WinJS.UI { //#region Events /** - * Occurs immediately after the NavBar is hidden. + * Occurs immediately after the NavBar is closed. * @param eventInfo An object that contains information about the event. **/ - onafterhide(eventInfo: Event): void; + onafterclose(eventInfo: Event): void; /** - * Raised after the NavBar is shown. + * Raised after the NavBar is opened. * @param eventInfo An object that contains information about the event. **/ - onaftershow(eventInfo: Event): void; + onafteropen(eventInfo: Event): void; /** - * Raised just before the NavBar is hidden. + * Raised just before the NavBar is closed. * @param eventInfo An object that contains information about the event. **/ - onbeforehide(eventInfo: Event): void; + onbeforeclose(eventInfo: Event): void; /** - * Occurs before a hidden NavBar is shown. + * Occurs before a closed NavBar is opened. * @param eventInfo An object that contains information about the event. **/ - onbeforeshow(eventInfo: Event): void; + onbeforeopen(eventInfo: Event): void; /** * Occurs after the NavBar has finished processing its child elements. @@ -6096,16 +6771,16 @@ declare module WinJS.UI { dispose(): void; /** - * Hides the NavBar. + * Closes the NavBar. **/ - hide(): void; + close(): void; /** * Hides the specified commands of the NavBar. * @param commands The commands to hide. The array elements may be NavBarCommand objects, or the string identifiers (IDs) of commands. * @param immediate The parameter immediate is not supported and may be altered or unavailable in the future. true to hide the commands immediately, without animating them; otherwise, false. **/ - hideCommands(commands: any[], immediate: boolean): void; + hideCommands(commands: any[], immediate?: boolean): void; /** * Removes an event handler that the addEventListener method registered. @@ -6116,52 +6791,59 @@ declare module WinJS.UI { removeEventListener(eventName: string, eventCallback: Function, useCapture?: boolean): void; /** - * Shows the NavBar if it is not disabled. + * Opens the NavBar **/ - show(): void; + open(): void; /** * Shows the specified commands of the NavBar. * @param commands The commands to show. The array elements may be NavBarCommand objects, or the string identifiers (IDs) of commands. * @param immediate The parameter immediate is not supported and may be altered or unavailable in the future. true to show the commands immediately, without animating them; otherwise, false. **/ - showCommands(commands: any[], immediate: boolean): void; + showCommands(commands: any[], immediate?: boolean): void; /** * Shows the specified commands of the NavBar while hiding all other commands. * @param commands The commands to show. The array elements may be NavBarCommand objects, or the string identifiers (IDs) of commands. * @param immediate The parameter immediate is not supported and may be altered or unavailable in the future. true to show the specified commands (and hide the others) immediately, without animating them; otherwise, false. **/ - showOnlyCommands(commands: any[], immediate: boolean): void; + showOnlyCommands(commands: any[], immediate?: boolean): void; //#endregion Methods //#region Properties + /** + * Gets/Sets how NavBar will display itself while closed. Values are "none" and "minimal". + **/ + closedDisplayMode: string; + /** * This API supports the WinJS infrastructure and is not intended to be used directly from your code. **/ commands: AppBarCommand; - /** - * Gets or sets a value that indicates whether the NavBar is disabled. - **/ - disabled: boolean; - /** * Gets the HTML element that hosts this NavBar. **/ element: HTMLElement; /** - * Gets a value that indicates whether the NavBar is hidden or in the process of becoming hidden. + * Returns the NavBarCommand object identified by id. + * @param id The element idenitifier (ID) of the NavBarCommand to be returned. + * @returns The NavBarCommand identified by id. If multiple commands have the same ID, returns the first command found. + **/ + getCommandById(id: string): NavBarCommand; + + /** + * This API supports the WinJS infrastructure and is not intended to be used directly from your code. Use NavBar.opened instead. **/ hidden: boolean; /** - * This API supports the WinJS infrastructure and is not intended to be used directly from your code. + * Gets a value that indicates whether the NavBar is opened or in the process of becoming opened, or sets the NavBar to open or close itself. **/ - layout: string; + opened: boolean; /** * Gets or sets a value that specifies whether the NavBar appears at the top or bottom of the main view. @@ -6169,9 +6851,14 @@ declare module WinJS.UI { placement: string; /** - * Gets or sets a value that indicates whether the NavBar is sticky (won't light dismiss). If not sticky, the NavBar dismisses normally when the user touches outside of the NavBar. + * This object supports the WinJS infrastructure and is not intended to be used directly from your code. **/ - sticky: boolean; + static isDeclarativeControlContainer: any; + + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; //#endregion Properties @@ -6185,7 +6872,7 @@ declare module WinJS.UI { /** * Creates a new NavBarCommand. - * @constructor + * @constructor * @param element The DOM element hosts the new NavBarCommand. * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. **/ @@ -6193,6 +6880,16 @@ declare module WinJS.UI { //#endregion Constructors + //#region Events + + /** + * This API supports the Windows Library for JavaScript infrastructure and is not intended to be used directly from your code. + * Use NavBarContainer.oninvoked instead. + **/ + oninvoked: any; + + //#endregion Events + //#region Methods /** @@ -6263,10 +6960,15 @@ declare module WinJS.UI { **/ state: any; + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + /** * Gets or sets the tooltip of the command. **/ - tooltip: any; + tooltip: string; //#endregion Properties @@ -6280,7 +6982,7 @@ declare module WinJS.UI { /** * Creates a new NavBarContainer. - * @constructor + * @constructor * @param element The DOM element hosts the new NavBarContainer. * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. **/ @@ -6374,6 +7076,11 @@ declare module WinJS.UI { **/ maxRows: number; + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + /** * Gets or sets the WinJS.Binding.Template or templating function that creates the DOM elements for each item in the data source. Each item can contain multiple elements, but it must have a single root element. **/ @@ -6391,7 +7098,7 @@ declare module WinJS.UI { /** * Creates a new Rating. - * @constructor + * @constructor * @param element The DOM element hosts the new Rating. * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. Event names must begin with "on". For example, to provide a handler for the cancel event, add a property named "oncancel" to the options object and set its value to the event handler. **/ @@ -6473,6 +7180,11 @@ declare module WinJS.UI { **/ maxRating: number; + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + /** * Gets or sets a set of descriptions to show for rating values in the tooltip. **/ @@ -6495,11 +7207,11 @@ declare module WinJS.UI { /** * Creates a new Repeater control. - * @constructor + * @constructor * @param elemnt The DOM element that will host the new control. The Repeater will create an element if this value is null. * @param options An object that contains one or more property/value pairs to apply to the new Repeater. Each property of the options object corresponds to one of the object's properties or events. Event names must begin with "on". **/ - constructor(element?:HTMLElement, options?: any); + constructor(element?: HTMLElement, options?: any); //#endregion Constructors @@ -6630,6 +7342,16 @@ declare module WinJS.UI { **/ length: number; + /** + * This object supports the WinJS infrastructure and is not intended to be used directly from your code. + **/ + static isDeclarativeControlContainer: any; + + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + /** * Gets or sets a WinJS.Binding.Template or custom rendering function that defines the HTML of each item within the Repeater. **/ @@ -6647,7 +7369,7 @@ declare module WinJS.UI { /** * Creates a new SearchBox. - * @constructor + * @constructor * @param element The DOM element hosts the new SearchBox. * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. **/ @@ -6669,17 +7391,11 @@ declare module WinJS.UI { **/ onquerysubmitted(eventInfo: CustomEvent): void; - /** - * Raised when the app automatically redirects focus to the search box. This event can only be raised when the focusOnKeyboardInput property is set to true. - * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.propertyName. - **/ - onreceivingfocusonkeyboardinput(eventInfo: CustomEvent): void; - /** * Raised when the user selects a suggested option for the search. * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.tag, detail.keyModifiers, detail.storageFile. **/ - onresultsuggestionschosen(eventInfo: CustomEvent): void; + onresultsuggestionchosen(eventInfo: CustomEvent): void; /** * Raised when the system requests search suggestions from this app. @@ -6770,6 +7486,11 @@ declare module WinJS.UI { **/ searchHistoryDisabled: boolean; + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + //#endregion Properties static createResultSuggestionImage(url: string): any; @@ -6784,7 +7505,7 @@ declare module WinJS.UI { /** * Creates a new SemanticZoom. - * @constructor + * @constructor * @param element The DOM element that hosts the SemanticZoom. * @param options An object that contains one or more property/value pairs to apply to the new control. This object can contain these properties: initiallyZoomedOut Boolean, zoomFactor 0.2–0.85. **/ @@ -6838,6 +7559,11 @@ declare module WinJS.UI { **/ removeEventListener(eventName: string, eventCallback: Function, useCapture?: boolean): void; + /** + * This API supports the WinJS infrastructure and is not intended to be used directly from your code. + **/ + setTimeoutAfterTTFF(callback: Function, delay: number): void + //#endregion Methods //#region Properties @@ -6852,16 +7578,16 @@ declare module WinJS.UI { **/ enableButton: boolean; - /** - * Determines whether any controls contained in a SemanticZoom should be processed separately. This property is always true, meaning that the SemanticZoom takes care of processing its own controls. - **/ - isDeclarativeControlContainer: boolean; - /** * Gets or sets a value that indicates whether SemanticZoom is locked and zooming between views is disabled. **/ locked: boolean; + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + /** * Gets or sets a value that indicates whether the control is zoomed out. **/ @@ -6872,6 +7598,16 @@ declare module WinJS.UI { **/ zoomFactor: number; + /** + * Gets or sets a mapping function which can be used to change the item that is targeted on zoom in. + **/ + zoomedInItem: (any) => any; + + /** + * Gets or sets a mapping function which can be used to change the item that is targeted on zoom out. + **/ + zoomedOutItem: (any) => any; + //#endregion Properties } @@ -6884,7 +7620,7 @@ declare module WinJS.UI { /** * Creates a new SettingsFlyout object. - * @constructor + * @constructor * @param element The DOM element that will host the control. * @param options The set of properties and values to apply to the new SettingsFlyout. **/ @@ -6979,10 +7715,20 @@ declare module WinJS.UI { **/ static showSettings(id: string, path: any): void; + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + //#endregion Methods //#region Properties + /** + * Specifies whether the SettingsFlyout is disabled. + **/ + disabled: boolean; + /** * Gets the DOM element the SettingsFlyout is attached to. **/ @@ -7006,6 +7752,325 @@ declare module WinJS.UI { //#endregion Properties } + /** + * Displays a SplitView which renders a collapsable pane next to arbitrary HTML content. + **/ + class SplitView { + /** + * Placement options for a SplitView's pane. + **/ + static PanePlacement: { + /** + * Pane is positioned left of the SplitView's content. + **/ + left: string; + /** + * Pane is positioned right of the SplitView's content. + **/ + right: string; + /** + * Pane is positioned above the SplitView's content. + **/ + top: string; + /** + * Pane is positioned below the SplitView's content. + **/ + bottom: string; + } + + /** + * Display options for a SplitView's pane when it is closed. + **/ + static ClosedDisplayMode: { + /** + * When the pane is closed, it is not visible and doesn't take up any space. + **/ + none: string; + /** + * When the pane is closed, it occupies space leaving less room for the SplitView's content. + **/ + inline: string; + } + + /** + * Display options for a SplitView's pane when it is open. + **/ + static OpenedDisplayMode: { + /** + * When the pane is open, it occupies space leaving less room for the SplitView's content. + **/ + inline: string; + /** + * When the pane is open, it doesn't take up any space and it is light dismissable. + **/ + overlay: string; + } + + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + + /** + * Creates a new SplitView. + * @constructor + * @param element The DOM element hosts the new SplitView. + * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. + **/ + constructor(element?: HTMLElement, options?: any); + + /** + * Gets the DOM element that hosts the SplitView control. + **/ + element: HTMLElement; + + /** + * Gets the DOM element that hosts the SplitView pane. + **/ + paneElement: HTMLElement; + + /** + * Gets the DOM element that hosts the SplitView's content. + **/ + contentElement: HTMLElement; + + /** + * Gets or sets the placement of the SplitView's pane. + **/ + panePlacement: string; + + /** + * Gets or sets the display mode of the SplitView's pane when it is closed. + **/ + closedDisplayMode: string; + + /** + * Gets or sets the display mode of the SplitView's pane when it is open. + **/ + openedDisplayMode: string; + + /** + * Gets or sets whether the SpitView's pane is currently open. + **/ + paneOpened: boolean; + + /** + * Opens the SplitView's pane. + **/ + openPane(): void; + + /** + * Closes the SplitView's pane. + **/ + closePane(): void; + + /** + * Disposes this control. + **/ + dispose(): void; + + /** + * Registers an event handler for the specified event. + * @param eventName The name of the event to handle. Note that you drop the "on" when specifying the event name. For example, instead of specifying "onclick", you specify "click". + * @param eventHandler The event handler function to associate with the event. + * @param useCapture Set to true to register the event handler for the capturing phase; otherwise, set to false to register the event handler for the bubbling phase. + **/ + addEventListener(eventName: string, eventHandler: Function, useCapture?: boolean): void; + + /** + * Removes an event handler that the addEventListener method registered. + * @param eventName The name of the event that the event handler is registered for. + * @param eventCallback The event handler function to remove. + * @param useCapture Set to true to remove the capturing phase event handler; set to false to remove the bubbling phase event handler. + **/ + removeEventListener(eventName: string, eventCallback: Function, useCapture?: boolean): void; + + /** + * Raises an event of the specified type and with additional properties. + * @param type The type (name) of the event. + * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. + * @returns true if preventDefault was called on the event, otherwise false. + **/ + dispatchEvent(type: string, eventProperties: any): boolean; + + /** + * Raised just before opening the pane. Call preventDefault on this event to stop the pane from opening. + * @param eventInfo An object that contains information about the event. + **/ + onbeforeopen(eventInfo: Event): void; + + /** + * Raised immediately after the pane is fully open. + * @param eventInfo An object that contains information about the event. + **/ + onafteropen(eventInfo: Event): void; + + /** + * Raised just before closing the pane. Call preventDefault on this event to stop the pane from closing. + * @param eventInfo An object that contains information about the event. + **/ + onbeforeclose(eventInfo: Event): void; + + /** + * Raised immediately after the pane is fully closed. + * @param eventInfo An object that contains information about the event. + **/ + onafterclose(eventInfo: Event): void; + } + + /** + * Displays a button which is used for opening and closing a SplitView's pane. + **/ + class SplitViewPaneToggle { + /** + * Creates a new SplitViewPaneToggle. + * @constructor + * @param element The DOM element hosts the new SplitViewPaneToggle. + * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. + **/ + constructor(element?: HTMLButtonElement, options?: any); + + /** + * Gets the DOM element that hosts the SplitViewPaneToggle control. + **/ + element: HTMLButtonElement; + + /** + * Gets or sets the DOM element of the SplitView that is associated with the SplitViewPaneToggle control. + * When the SplitViewPaneToggle is invoked, it'll toggle this SplitView's pane. + **/ + splitView: HTMLElement; + + /** + * Disposes this control. + **/ + dispose(): void; + + /** + * Registers an event handler for the specified event. + * @param eventName The name of the event to handle. Note that you drop the "on" when specifying the event name. For example, instead of specifying "onclick", you specify "click". + * @param eventHandler The event handler function to associate with the event. + * @param useCapture Set to true to register the event handler for the capturing phase; otherwise, set to false to register the event handler for the bubbling phase. + **/ + addEventListener(eventName: string, eventHandler: Function, useCapture?: boolean): void; + + /** + * Removes an event handler that the addEventListener method registered. + * @param eventName The name of the event that the event handler is registered for. + * @param eventCallback The event handler function to remove. + * @param useCapture Set to true to remove the capturing phase event handler; set to false to remove the bubbling phase event handler. + **/ + removeEventListener(eventName: string, eventCallback: Function, useCapture?: boolean): void; + + /** + * Raises an event of the specified type and with additional properties. + * @param type The type (name) of the event. + * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. + * @returns true if preventDefault was called on the event, otherwise false. + **/ + dispatchEvent(type: string, eventProperties: any): boolean; + + /** + * Raised when the SplitViewPaneToggle is invoked. + * @param eventInfo An object that contains information about the event. + **/ + oninvoked(eventInfo: Event): void; + + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + + } + + /** + * Represents a command in the SplitView Pane. + **/ + class SplitViewCommand { + //#region Constructors + + /** + * Creates a new SplitViewCommand. + * @constructor + * @param element The DOM element hosts the new SplitViewCommand. + * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. + **/ + constructor(element?: HTMLElement, options?: any); + + //#endregion Constructors + + //# region Events + + /** + * Raised when a SplitViewCommand has been invoked. + * @param eventInfo An object that contains information about the event. + **/ + oninvoked(eventInfo: CustomEvent): void; + + //#endregion Events + + //#region Methods + + /** + * Registers an event handler for the specified event. + * @param eventName The name of the event to handle. Note that you drop the "on" when specifying the event name. For example, instead of specifying "onclick", you specify "click". + * @param eventHandler The event handler function to associate with the event. + * @param useCapture Set to true to register the event handler for the capturing phase; otherwise, set to false to register the event handler for the bubbling phase. + **/ + addEventListener(eventName: string, eventHandler: Function, useCapture?: boolean): void; + + /** + * Raises an event of the specified type and with additional properties. + * @param type The type (name) of the event. + * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. + * @returns true if preventDefault was called on the event, otherwise false. + **/ + dispatchEvent(type: string, eventProperties: any): boolean; + + /** + * Releases resources held by this SplitViewCommand. Call this method when the SplitViewCommand is no longer needed. After calling this method, the SplitViewCommand becomes unusable. + **/ + dispose(): void; + + /** + * Removes an event handler that the addEventListener method registered. + * @param eventName The name of the event that the event handler is registered for. + * @param eventCallback The event handler function to remove. + * @param useCapture Set to true to remove the capturing phase event handler; set to false to remove the bubbling phase event handler. + **/ + removeEventListener(eventName: string, eventCallback: Function, useCapture?: boolean): void; + + //#endregion Methods + + //#region Properties + + /** + * Gets the HTML element that hosts this SplitViewCommand. + **/ + element: HTMLElement; + + /** + * Gets or sets the command's icon. + **/ + icon: string; + + /** + * Gets or sets the label of the command. + **/ + label: string; + + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + + /** + * Gets or sets the tooltip of the command. + **/ + tooltip: string; + + //#endregion Properties + } /** * A type of IListDataSource that provides read-access to an object that implements the IStorageQueryResultBase interface. A StorageDataSource enables you to query and bind to items in the data source. @@ -7033,8 +8098,37 @@ declare module WinJS.UI { **/ loadThumbnail(item: IItem, image: HTMLImageElement): Promise; + /** + * Registers an event handler for the specified event. + * @param type The name of the event for which to add a listener. + * @param eventHandler The event handler function to associate with the event. + * @param useCapture Set to true to register the event handler for the capturing phase; otherwise, set to false to register the event handler for the bubbling phase. + **/ + addEventListener(type: string, eventHandler: Function, useCapture?: boolean): void; + + /** + * Raises an event of the specified type and with additional properties. + * @param type The type (name) of the event. + * @param details The set of additional properties to be attached to the event object. + * @returns true if preventDefault was called on the event, otherwise false. + **/ + dispatchEvent(type: string, details: any): boolean; + + /** + * Removes a listener for the specified event. + * @param type The name of the event for which to remove a listener. + * @param eventHandler The event handler function to associate with the event. + * @param useCapture Optional. The same value that was passed to addEventListener for this listener. It may be omitted if it was omitted when calling addEventListener. + **/ + removeEventListener(type: string, eventHandler: Function, useCapture?: any): void; + //#endregion Methods + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + } /** @@ -7045,7 +8139,7 @@ declare module WinJS.UI { /** * Creates a new TabContainer. - * @constructor + * @constructor * @param element The DOM element that hosts the TabContainer control. * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties. **/ @@ -7069,6 +8163,11 @@ declare module WinJS.UI { **/ childFocus: HTMLElement; + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + /** * Gets or sets the tab index of this container. **/ @@ -7086,7 +8185,7 @@ declare module WinJS.UI { /** * Initializes a new instance of a TimePicker control. - * @constructor + * @constructor * @param element The DOM element associated with the TimePicker control. * @param options The set of options to be applied initially to the TimePicker control. The options are the following: clock. **/ @@ -7128,12 +8227,9 @@ declare module WinJS.UI { dispose(): void; /** - * Raises an event of the specified type and with additional properties. - * @param type The type (name) of the event. - * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. - * @returns true if preventDefault was called on the event, otherwise false. + * This API supports the WinJS infrastructure and is not intended to be used directly from your code. Use render instead. **/ - raiseEvent(type: string, eventProperties: any): boolean; + static getInformation(clock: any, minuteIncrement: any, timerPatterns?: any): any; /** * Removes a listener for the specified event. @@ -7187,6 +8283,11 @@ declare module WinJS.UI { **/ periodPattern: string; + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + //#endregion Properties } @@ -7199,7 +8300,7 @@ declare module WinJS.UI { /** * Creates a new ToggleSwitch. - * @constructor + * @constructor * @param element The DOM that hosts the control. * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. Event names must begin with "on". For example, to provide a handler for the change event, add a property named "onchange" to the options object and set its value to the event handler. **/ @@ -7240,20 +8341,6 @@ declare module WinJS.UI { **/ dispose(): void; - /** - * Handles the specified event. - * @param event The event. - **/ - handleEvent(event: any): void; - - /** - * Raises an event of the specified type and with additional properties. - * @param type The type (name) of the event. - * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. - * @returns true if preventDefault was called on the event, otherwise false. - **/ - raiseEvent(type: string, eventProperties: any): boolean; - /** * Removes an event handler that the addEventListener method registered. * @param eventName The name of the event that the event handler is registered for. @@ -7291,6 +8378,11 @@ declare module WinJS.UI { **/ labelOn: string; + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + /** * Gets or sets the main text for the ToggleSwitch control. This text is always displayed, regardless of whether the control is switched on or off. **/ @@ -7299,6 +8391,139 @@ declare module WinJS.UI { //#endregion Properties } + /** + * Displays ICommands within the flow of the app. Use the ToolBar around other statically positioned app content. + **/ + class ToolBar { + + /** + * Display options for the closed ToolBar. + **/ + public static ClosedDisplayMode: { + /** + * When the ToolBar is closed, the height of the ToolBar is reduced such that button commands are still visible, but their labels are hidden. + **/ + compact: string; + /** + * When the ToolBar is closed, the height of the ToolBar is always sized to content. + **/ + full: string; + }; + + /** + * Indicates that the object is compatibile with declarative processing. + **/ + public static supportedForProcessing: boolean; + + /** + * Gets the DOM element that hosts the ToolBar. + **/ + public element: HTMLElement; + + /** + * Gets or sets the Binding List of ICommand for the ToolBar. + **/ + public data: WinJS.Binding.List; + + /** + * Gets or sets the closedDisplayMode for the ToolBar. Values are "compact" and "full". + **/ + public closedDisplayMode: string; + + /** + * Creates a new ToolBar control. + * @param element The DOM element that will host the control. + * @param options The set of properties and values to apply to the new ToolBar. + **/ + constructor(element?: HTMLElement, options?: any); + + /** + * Disposes the ToolBar + **/ + public dispose(): void; + + /** + * Forces the ToolBar to update its layout. + * Use this function when the window did not change size, but the ToolBar itself did. + **/ + public forceLayout(): void; + + /** + * Opens the ToolBar + **/ + public open(): void; + + /** + * Closes the ToolBar + **/ + public close(): void; + + /** + * Returns the Command object identified by id. + * @param id The element idenitifier (ID) of the command to be returned. + * @returns The command identified by id. If multiple commands have the same ID, returns the first command found. + **/ + getCommandById(id: string): ICommand; + + /** + * Shows the specified commands of the ToolBar while hiding all other commands. + * @param commands The commands to show. The array elements may be ICommand objects, or the string identifiers (IDs) of commands. + **/ + showOnlyCommands(commands: Array): void; + + /** + * Gets or sets whether the ToolBar is currently opened. + **/ + public opened: boolean; + + /** + * Occurs immediately before the control is opened. Is cancelable. + * @param eventInfo An object that contains information about the event. + **/ + public onbeforeopen: (eventInfo: CustomEvent) => void; + + /** + * Occurs immediately after the control is opened. + * @param eventInfo An object that contains information about the event. + **/ + public onafteropen: (eventInfo: CustomEvent) => void; + + /** + * Occurs immediately before the control is closed. Is cancelable. + * @param eventInfo An object that contains information about the event. + **/ + public onbeforeclose: (eventInfo: CustomEvent) => void; + + /** + * Occurs immediately after the control is closed. + * @param eventInfo An object that contains information about the event. + **/ + public onafterclose: (eventInfo: CustomEvent) => void; + + /** + * Registers an event handler for the specified event. + * @param type The event type to register. It must be beforeopen, beforeclose, afteropen, or afterclose. + * @param listener The event handler function to associate with the event. + * @param useCapture Set to true to register the event handler for the capturing phase; otherwise, set to false to register the event handler for the bubbling phase. + **/ + addEventListener(eventName: string, eventHandler: Function, useCapture?: boolean): void; + + /** + * Removes an event handler that the addEventListener method registered. + * @param type The event type to unregister. It must be beforeopen, beforeclose, afteropen, or afterclose. + * @param listener The event handler function to remove. + * @param useCapture Set to true to remove the capturing phase event handler; set to false to remove the bubbling phase event handler. + **/ + removeEventListener(eventName: string, eventHandler: Function, useCapture?: boolean): void; + + /** + * Raises an event of the specified type and with additional properties. + * @param type The type (name) of the event. + * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. + * @returns true if preventDefault was called on the event, otherwise false. + **/ + dispatchEvent(eventName: string, eventProperties: any): boolean; + } /** * Displays a tooltip that can contain images and formatting. @@ -7412,6 +8637,11 @@ declare module WinJS.UI { **/ placement: string; + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + //#endregion Properties } @@ -7442,6 +8672,14 @@ declare module WinJS.UI { **/ addEventListener(eventName: string, eventHandler: Function, useCapture?: boolean): void; + /** + * Raises an event of the specified type and with additional properties. + * @param eventName The name of the event. + * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. + * @returns true if preventDefault was called on the event, otherwise false. + **/ + dispatchEvent(eventName: string, eventProperties: any): boolean; + /** * Releases resources held by this ViewBox. Call this method when the ViewBox is no longer needed. After calling this method, the ViewBox becomes unusable. **/ @@ -7469,6 +8707,11 @@ declare module WinJS.UI { **/ element: HTMLElement; + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + //#endregion Properties } @@ -7488,7 +8731,7 @@ declare module WinJS.UI { /** * Initializes the VirtualizedDataSource base class of a custom data source. - * @constructor + * @constructor * @param listDataAdapter The object that supplies data to the VirtualizedDataSource. * @param options An object that can contain properties that specify additional options for the VirtualizedDataSource. It supports these properties: cacheSize. **/ @@ -7498,12 +8741,6 @@ declare module WinJS.UI { //#region Events - /** - * Occurs when the status of the VirtualizedDataSource changes. - * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: status. - **/ - statuschanged(eventInfo: CustomEvent): void; - //#endregion Events //#region Methods @@ -7534,6 +8771,15 @@ declare module WinJS.UI { //#endregion Methods + //#region Properties + + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + + //#endregion Properties + } //#endregion Objects @@ -7597,6 +8843,11 @@ declare module WinJS.UI { **/ function isAnimationEnabled(): boolean; + /** + * * This API supports the WinJS infrastructure and is not intended to be used directly from your code. + **/ + function optionsParser(value: string, context?: any, functionContext?: any): any; + /** * Applies declarative control binding to all elements, starting at the specified root element. * @param rootElement The element at which to start applying the binding. If this parameter is not specified, the binding is applied to the entire document. @@ -7621,22 +8872,156 @@ declare module WinJS.UI { function scopedSelect(selector: string, element: HTMLElement): HTMLElement; /** - * Given a DOM element and a control, attaches the control to the element. - * @param element Element to associate with the control. - * @param control The control to attach to the element. - **/ - function setControl(element: HTMLElement, control: any): void; - - /** - * Adds the set of declaratively specified options (properties and events) to the specified control. If name of the options property begins with "on", the property value is a function and the control supports addEventListener. setControl calls addEventListener on the control. + * Adds the set of declaratively specified options (properties and events) to the specified control. If name of the options property begins with "on", the property value is a function and the control supports addEventListener, setOptions calls addEventListener on the control. * @param control The control on which the properties and events are to be applied. * @param options The set of options that are specified declaratively. **/ function setOptions(control: any, options?: any): void; + /** + * This API supports the WinJS infrastructure and is not intended to be used directly from your code. + **/ + function simpleItemRenderer(Function): Function; + //#endregion Functions } +/** + * Provides utility functions for generic directional focus movement +**/ +declare module WinJS.UI.XYFocus { + export interface XYFocusOptions { + /** + * The focus scope, only children of this element are considered in the calculation. + **/ + focusRoot?: HTMLElement; + + /** + * A rectangle indicating where focus came from before the current state. + **/ + historyRect?: IRect; + + /** + * The element from which to calculate the next focusable element; if specified, referenceRect is ignored. + **/ + referenceElement?: HTMLElement; + + /** + * The rectangle from which to calculate next focusable element; ignored if referenceElement is also specified. + **/ + referenceRect?: IRect; + } + + export interface IRect { + left: number; + right?: number; + top: number; + bottom?: number; + + height: number; + width: number; + } + + export interface XYFocusEvent extends CustomEvent { + detail: { nextFocusElement: HTMLElement; keyCode: number; previousFocusElement: HTMLElement }; + } + + /** + * Gets the mapping object that maps keycodes to XYFocus actions. + **/ + export var keyCodeMap: { + /** + * The array of keycodes that cause XYFocus to accept. + **/ + accept: Array; + /** + * The array of keycodes that cause XYFocus to cancel. + **/ + cancel: Array; + /** + * The array of keycodes that cause XYFocus to navigate down. + **/ + down: Array; + /** + * The array of keycodes that cause XYFocus to navigate left. + **/ + left: Array; + /** + * The array of keycodes that cause XYFocus to navigate right. + **/ + right: Array; + /** + * The array of keycodes that cause XYFocus to navigate up. + **/ + up: Array; + }; + + /** + * Gets or sets the focus root when invoking XYFocus APIs. + **/ + export var focusRoot: HTMLElement; + + /** + * Adds an event listener to XYFocus events. + * @param type The type (name) of the event. + * @param listener The listener to invoke when the event gets raised. + **/ + export function addEventListener(type: string, handler: EventListener): void; + + /** + * Raises an event of the specified type and with additional properties. + * @param type The type (name) of the event. + * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. + * @returns true if preventDefault was called on the event, otherwise false. + **/ + export function dispatchEvent(type: string, eventProperties: any): boolean; + + /** + * Removes an event listener to XYFocus events. + * @param type The type (name) of the event. + * @param listener The listener to remove. + **/ + export function removeEventListener(type: string, handler: EventListener): void; + + /** + * Returns the next focusable element from the current active element (or reference, if supplied) towards the specified direction. + * @param direction The direction to search. + * @param options An options object configuring the search. + **/ + export function findNextFocusElement(direction: string, options?: XYFocusOptions): HTMLElement; + export function findNextFocusElement(direction: "left", options?: XYFocusOptions): HTMLElement; + export function findNextFocusElement(direction: "right", options?: XYFocusOptions): HTMLElement; + export function findNextFocusElement(direction: "up", options?: XYFocusOptions): HTMLElement; + export function findNextFocusElement(direction: "down", options?: XYFocusOptions): HTMLElement; + + /** + * Moves focus to the next focusable element from the current active element (or reference, if supplied) towards the specific direction. + * @param direction The direction to move. + * @param options An options object configuring the focus move. + **/ + export function moveFocus(direction: string, options?: XYFocusOptions): HTMLElement; + export function moveFocus(direction: "left", options?: XYFocusOptions): HTMLElement; + export function moveFocus(direction: "right", options?: XYFocusOptions): HTMLElement; + export function moveFocus(direction: "up", options?: XYFocusOptions): HTMLElement; + export function moveFocus(direction: "down", options?: XYFocusOptions): HTMLElement; + + //#region Events + + /** + * Occurs immeidately after XYFocus has changed focus targets. + * @param eventInfo An object that contains information about the event. The detail property of this object includes the following subproperties: previousFocusElemewnt, keyCode. + **/ + export function onfocuschanged(eventInfo: CustomEvent): void; + + /** + * Occurs immeidately before XYFocus changes focus targets. Is cancelable. + * @param eventInfo An object that contains information about the event. The detail property of this object includes the following subproperties: nextFocusElement, keyCode. + **/ + export function onfocuschanging(eventInfo: CustomEvent): void; + + //#endregion Events +} + /** * Provides functions to load HTML content programmatically. **/ @@ -7792,7 +9177,7 @@ declare module WinJS.UI.TrackTabBehavior { * Removes the tab order information from the specified element. * @param element The element to remove tab information from. **/ - function detatch(element: HTMLElement): void; + function detach(element: HTMLElement): void; //#endregion Functions @@ -8151,6 +9536,38 @@ declare module WinJS.Utilities { * The F12 key. **/ F12, + /** + * The XBox One Remote navigation view button. + **/ + NavigationView, + /** + * The XBox One Remote navigation menu button. + **/ + NavigationMenu, + /** + * The XBox One Remote navigation up button. + **/ + NavigationUp, + /** + * The XBox One Remote navigation down button. + **/ + NavigationDown, + /** + * The XBox One Remote navigation left button. + **/ + NavigationLeft, + /** + * The XBox One Remote navigation right button. + **/ + NavigationRight, + /** + * The XBox One Remote navigation accept button. + **/ + NavigationAccept, + /** + * The XBox One Remote navigation cancel button. + **/ + NavigationCancel, /** * The NUMBER LOCK key. **/ @@ -8198,6 +9615,105 @@ declare module WinJS.Utilities { /** * The open bracket key ([). **/ + /** + * The XBox One gamepad A button. + **/ + GamepadA, + /** + * The XBox One gamepad B button. + **/ + GamepadB, + /** + * The XBox One gamepad X button. + **/ + GamepadX, + /** + * The XBox One gamepad Y button. + **/ + GamepadY, + /** + * The XBox One gamepad right shoulder. + **/ + GamepadRightShoulder, + /** + * The XBox One gamepad left shoulder. + **/ + GamepadLeftShoulder, + /** + * The XBox One gamepad left trigger. + **/ + GamepadLeftTrigger, + /** + * The XBox One gamepad right trigger. + **/ + GamepadRightTrigger, + /** + * The XBox One gamepad dpad up. + **/ + GamepadDPadUp, + /** + * The XBox One gamepad dpad down. + **/ + GamepadDPadDown, + /** + * The XBox One gamepad dpad left. + **/ + GamepadDPadLeft, + /** + * The XBox One gamepad dpad right. + **/ + GamepadDPadRight, + /** + * The XBox One gamepad menu button. + **/ + GamepadMenu, + /** + * The XBox One gamepad view button. + **/ + GamepadView, + /** + * The XBox One gamepad left thumbstick button. + **/ + GamepadLeftThumbstick, + /** + * The XBox One gamepad right thumbstick button. + **/ + GamepadRightThumbstick, + /** + * The XBox One gamepad left thumbstick's up. + **/ + GamepadLeftThumbstickUp, + /** + * The XBox One gamepad left thumbstick's down. + **/ + GamepadLeftThumbstickDown, + /** + * The XBox One gamepad left thumbstick's right. + **/ + GamepadLeftThumbstickRight, + /** + * The XBox One gamepad left thumbstick's left. + **/ + GamepadLeftThumbstickLeft, + /** + * The XBox One gamepad right thumbstick's up. + **/ + GamepadRightThumbstickUp, + /** + * The XBox One gamepad right thumbstick's down. + **/ + GamepadRightThumbstickDown, + /** + * The XBox One gamepad right thumbstick's right. + **/ + GamepadRightThumbstickRight, + /** + * The XBox One gamepad right thumbstick's left. + **/ + GamepadRightThumbstickLeft, + /** + * The open bracket key ([). + **/ openBracket, /** * The backslash key (\). @@ -8210,7 +9726,11 @@ declare module WinJS.Utilities { /** * The single quote key ('). **/ - singleQuote + singleQuote, + /** + * Any IME input. + **/ + IME, } //#endregion Enumerations @@ -8254,7 +9774,7 @@ declare module WinJS.Utilities { /** * Represents the result of a query selector, and provides various operations that perform actions over the elements of the collection. **/ - interface QueryCollection extends Array { + class QueryCollection implements Array { //#region Methods /** @@ -8264,13 +9784,6 @@ declare module WinJS.Utilities { **/ addClass(name: string): QueryCollection; - /** - * Creates a QueryCollection that contains the children of the specified parent element. - * @param element The parent element. - * @returns The QueryCollection that contains the children of the element. - **/ - children(element: HTMLElement): QueryCollection; - /** * Clears the specified style property for all the elements in the collection. * @param name The name of the style property to be cleared. @@ -8315,13 +9828,6 @@ declare module WinJS.Utilities { **/ hasClass(name: string): boolean; - /** - * Looks up an element by ID and wraps the result in a QueryCollection. - * @param id The ID of the element. - * @returns A QueryCollection that contains the element, if it is found. - **/ - id(id: string): QueryCollection; - /** * Adds a set of items to this QueryCollection. * @param items The items to add to the QueryCollection. This may be an array-like object, a document fragment, or a single item. @@ -8358,7 +9864,7 @@ declare module WinJS.Utilities { /** * Removes the specified class from all the elements in the collection. * @param name The name of the class to be removed. - * @returns his QueryCollection object. + * @returns This QueryCollection object. **/ removeClass(name: string): QueryCollection; @@ -8405,14 +9911,161 @@ declare module WinJS.Utilities { //#endregion Methods - } + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + + //#region Array.prototype + + /** + * Combines two or more arrays. + * @param items Additional items to add to the end of array1. + **/ + concat(...items: U[]): T[]; + /** + * Combines two or more arrays. + * @param items Additional items to add to the end of array1. + **/ + concat(...items: T[]): T[]; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma. + **/ + join(separator?: string): string; + + /** + * Removes the last element from an array and returns it. + **/ + pop(): T; + + /** + * Appends new elements to an array, and returns the new length of the array. + * @param items New elements of the Array. + **/ + push(...items: T[]): number; + + /** + * Reverses the elements in an Array. + **/ + reverse(): T[]; + + /** + * Removes the first element from an array and returns it. + **/ + shift(): T; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + **/ + slice(start?: number, end?: number): T[]; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If omitted, the elements are sorted in ascending, ASCII character order. + **/ + sort(compareFn?: (a: T, b: T) => number): T[]; + + /** + * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. + * @param start The zero-based location in the array from which to start removing elements. + **/ + splice(start: number): T[]; + + /** + * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. + * @param start The zero-based location in the array from which to start removing elements. + * @param deleteCount The number of elements to remove. + * @param items Elements to insert into the array in place of the deleted elements. + **/ + splice(start: number, deleteCount: number, ...items: T[]): T[]; + + /** + * Inserts new elements at the start of an array. + * @param items Elements to insert at the start of the Array. + **/ + unshift(...items: T[]): number; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0. + **/ + indexOf(searchElement: T, fromIndex?: number): number; + + /** + * Returns the index of the last occurrence of a specified value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the array. + **/ + lastIndexOf(searchElement: T, fromIndex?: number): number; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls the callbackfn function for each element in array1 until the callbackfn returns false, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + **/ + every(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the callbackfn function for each element in array1 until the callbackfn returns true, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + **/ + some(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; + + /** + * Calls a defined callback function on each element of an array, and returns an array that contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + **/ + map(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + **/ + filter(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): T[]; + + /** + * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + **/ + reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; + /** + * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + **/ + reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + **/ + reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; + /** + * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + **/ + reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; + + /** + * Gets or sets the length of the array. This is a number one higher than the highest element defined in an array. + **/ + length: number; + + [n: number]: T; + + //#endregion Array.prototype - /** - * Constructor support for QueryCollection interface - **/ - export var QueryCollection: { - new (items: T[]): QueryCollection; - prototype: QueryCollection; } //#endregion Objects @@ -8536,7 +10189,7 @@ declare module WinJS.Utilities { * @param element The element. * @returns An object with two properties: scrollLeft and scrollTop **/ - function getScrollPosition(element: HTMLElement): { scrollLeft: number; scrollTop: number}; + function getScrollPosition(element: HTMLElement): { scrollLeft: number; scrollTop: number }; /** * Gets the tab index of the specified element. @@ -8668,7 +10321,7 @@ declare module WinJS.Utilities { * @param element The element. * @param position An object describing the position to set. **/ - function setScrollPosition(element: HTMLElement, position: { scrollLeft: number; scrollTop: number}): void; + function setScrollPosition(element: HTMLElement, position: { scrollLeft: number; scrollTop: number }): void; /** * Configures a logger that writes messages containing the specified tags to the JavaScript console. @@ -8700,9 +10353,9 @@ declare module WinJS.Utilities { var hasWinRT: boolean; /** - * Indicates whether the app is running on Windows Phone. + * Determines if strict declarative processing is enabled in this script context. **/ - var isPhone: boolean; + var strictProcessing: boolean; //#endregion Properties From 62d8b030ef550d85fa4830146955a9d59dba5c1a Mon Sep 17 00:00:00 2001 From: jessesh Date: Mon, 5 Oct 2015 13:40:22 -0700 Subject: [PATCH 0030/1238] Fixes "implicit any" errors. --- winjs/winjs.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/winjs/winjs.d.ts b/winjs/winjs.d.ts index acf6802bfc..9030196983 100644 --- a/winjs/winjs.d.ts +++ b/winjs/winjs.d.ts @@ -1337,7 +1337,7 @@ declare module WinJS.Binding { /** * This API supports the WinJS infrastructure and is not intended to be used directly from your code. **/ - function getValue(obj: any, path?: any) + function getValue(obj: any, path?: any): any; /** * Marks a custom initializer function as being compatible with declarative data binding. @@ -7601,12 +7601,12 @@ declare module WinJS.UI { /** * Gets or sets a mapping function which can be used to change the item that is targeted on zoom in. **/ - zoomedInItem: (any) => any; + zoomedInItem: (any: any) => any; /** * Gets or sets a mapping function which can be used to change the item that is targeted on zoom out. **/ - zoomedOutItem: (any) => any; + zoomedOutItem: (any: any) => any; //#endregion Properties @@ -8881,7 +8881,7 @@ declare module WinJS.UI { /** * This API supports the WinJS infrastructure and is not intended to be used directly from your code. **/ - function simpleItemRenderer(Function): Function; + function simpleItemRenderer(fn: Function): Function; //#endregion Functions From 729ca9b124a7d4b4631b6295d9ce8f2d848ae4fe Mon Sep 17 00:00:00 2001 From: David Pertiller Date: Mon, 5 Oct 2015 23:23:24 +0200 Subject: [PATCH 0031/1238] included method definition for onrendered event which provides the rendered canvas element --- html2canvas/html2canvas.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/html2canvas/html2canvas.d.ts b/html2canvas/html2canvas.d.ts index 6894219715..61eba51fd2 100644 --- a/html2canvas/html2canvas.d.ts +++ b/html2canvas/html2canvas.d.ts @@ -37,6 +37,8 @@ declare module Html2Canvas { /** Whether to attempt to load cross-origin images as CORS served, before reverting back to proxy. */ useCORS?: boolean; + /** Callback providing the rendered canvas element after rendering */ + onrendered?(canvas: HTMLElement): void; } } From b9a7194092297ca857f96d971e290612bc2618d7 Mon Sep 17 00:00:00 2001 From: Per Kastman Date: Tue, 6 Oct 2015 18:56:29 +0200 Subject: [PATCH 0032/1238] Renamed according to naming convention --- .../jquery.cropbox.d.ts => jquery-cropbox/jquery-cropbox.d.ts | 4 ++-- .../jquery-cropbox.tests.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) rename jquery.cropbox/jquery.cropbox.d.ts => jquery-cropbox/jquery-cropbox.d.ts (96%) rename jquery.cropbox/jquery.cropbox.tests.ts => jquery-cropbox/jquery-cropbox.tests.ts (94%) diff --git a/jquery.cropbox/jquery.cropbox.d.ts b/jquery-cropbox/jquery-cropbox.d.ts similarity index 96% rename from jquery.cropbox/jquery.cropbox.d.ts rename to jquery-cropbox/jquery-cropbox.d.ts index 82b550bf30..fba9846bba 100644 --- a/jquery.cropbox/jquery.cropbox.d.ts +++ b/jquery-cropbox/jquery-cropbox.d.ts @@ -107,9 +107,9 @@ declare module jQueryCropBox { } interface JQuery { - cropbox(params?: jQueryCropBox.CropboxOptions): jQueryCropBox.Cropbox + cropbox(params?: jQueryCropBox.CropboxOptions): JQuery } interface JQueryStatic { - cropbox(params?: jQueryCropBox.CropboxOptions): jQueryCropBox.Cropbox + cropbox(params?: jQueryCropBox.CropboxOptions): JQueryStatic } diff --git a/jquery.cropbox/jquery.cropbox.tests.ts b/jquery-cropbox/jquery-cropbox.tests.ts similarity index 94% rename from jquery.cropbox/jquery.cropbox.tests.ts rename to jquery-cropbox/jquery-cropbox.tests.ts index cb8f0be5ac..e8db3847c6 100644 --- a/jquery.cropbox/jquery.cropbox.tests.ts +++ b/jquery-cropbox/jquery-cropbox.tests.ts @@ -1,5 +1,5 @@ /// -/// +/// var cropboxWithDefaultSettings = $("#element").cropbox(); From 68d3c81d8d635bd03136a19fd2d40d3dc500c7b9 Mon Sep 17 00:00:00 2001 From: Per Kastman Date: Tue, 6 Oct 2015 19:16:44 +0200 Subject: [PATCH 0033/1238] Fixed incorrect return type --- jquery-cropbox/jquery-cropbox.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jquery-cropbox/jquery-cropbox.d.ts b/jquery-cropbox/jquery-cropbox.d.ts index fba9846bba..82b550bf30 100644 --- a/jquery-cropbox/jquery-cropbox.d.ts +++ b/jquery-cropbox/jquery-cropbox.d.ts @@ -107,9 +107,9 @@ declare module jQueryCropBox { } interface JQuery { - cropbox(params?: jQueryCropBox.CropboxOptions): JQuery + cropbox(params?: jQueryCropBox.CropboxOptions): jQueryCropBox.Cropbox } interface JQueryStatic { - cropbox(params?: jQueryCropBox.CropboxOptions): JQueryStatic + cropbox(params?: jQueryCropBox.CropboxOptions): jQueryCropBox.Cropbox } From 1e9273d62eb6e2c2de01116c6446f006b47916b7 Mon Sep 17 00:00:00 2001 From: Per Kastman Date: Tue, 6 Oct 2015 19:29:47 +0200 Subject: [PATCH 0034/1238] Updated according to naming convention --- .../{jquery-cropbox.tests.ts => jquery-cropbox-tests.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename jquery-cropbox/{jquery-cropbox.tests.ts => jquery-cropbox-tests.ts} (100%) diff --git a/jquery-cropbox/jquery-cropbox.tests.ts b/jquery-cropbox/jquery-cropbox-tests.ts similarity index 100% rename from jquery-cropbox/jquery-cropbox.tests.ts rename to jquery-cropbox/jquery-cropbox-tests.ts From 282c4c28548911940f9bea3aeba34bdd59e20ce5 Mon Sep 17 00:00:00 2001 From: William Comartin Date: Tue, 6 Oct 2015 15:59:48 -0400 Subject: [PATCH 0035/1238] add angular-dialog-service typescript definitions --- .../angular-dialog-service.d.ts | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 angular-dialog-service/angular-dialog-service.d.ts diff --git a/angular-dialog-service/angular-dialog-service.d.ts b/angular-dialog-service/angular-dialog-service.d.ts new file mode 100644 index 0000000000..aa057642cd --- /dev/null +++ b/angular-dialog-service/angular-dialog-service.d.ts @@ -0,0 +1,82 @@ +// Type definitions for Angular Dialog Service 5.2.8 +// Project: https://github.com/m-e-conroy/angular-dialog-service +// Definitions by: William Comartin +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// +/// + +declare module angular.dialogservice { + + interface IDialogOptions { + /** + * Set to false to disable animations on new modal/backdrop. Does not toggle animations for modals/backdrops that are already displayed. + * + * @default false + */ + animation?: boolean; + + /** + * controls the presence of a backdrop + * Allowed values: + * - true (default) + * - false (no backdrop) + * - 'static' backdrop is present but modal window is not closed when clicking outside of the modal window + * + * @default true + */ + backdrop?: boolean | string; + + /** + * indicates whether the dialog should be closable by hitting the ESC key + * + * @default true + */ + keyboard?: boolean; + + /** + * additional CSS class(es) to be added to a modal backdrop template + * + * @default 'dialogs-backdrop-default' + */ + backdropClass?: string; + + /** + * additional CSS class(es) to be added to a modal window template + * + * @default 'dialogs-default' + */ + windowClass?: string; + + /** + * Optional suffix of modal window class. The value used is appended to the `modal-` class, i.e. a value of `sm` gives `modal-sm`. + * + * @default 'lg' + */ + size?: string; + } + + interface IDialogService { + /** + * Opens a new error modal instance. + */ + error(header: string, msg: string, progress: number, opts: IDialogOptions): ng.ui.bootstrap.IModalServiceInstance + /** + * Opens a new wait modal instance. + */ + wait(header: string, msg: string, opts: IDialogOptions): ng.ui.bootstrap.IModalServiceInstance + /** + * Opens a new notify modal instance. + */ + notify(header: string, msg: string, opts: IDialogOptions): ng.ui.bootstrap.IModalServiceInstance + /** + * Opens a new confirm modal instance. + */ + confirm(header: string, msg: string, opts: IDialogOptions): ng.ui.bootstrap.IModalServiceInstance + /** + * Opens a new custom modal instance. + */ + create(url: string, ctrlr: string, data: any, opts: IDialogOptions): ng.ui.bootstrap.IModalServiceInstance + } + +} From a20e020adc793a637d79ab39d3a47d2cab838109 Mon Sep 17 00:00:00 2001 From: Gabriel Mak Date: Wed, 7 Oct 2015 09:23:48 +0100 Subject: [PATCH 0036/1238] Add support for NavBrand construct Adding support for NavBrand construct in newer react-bootstrap --- react-bootstrap/react-bootstrap.d.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/react-bootstrap/react-bootstrap.d.ts b/react-bootstrap/react-bootstrap.d.ts index 0c05844742..fe6323aa42 100644 --- a/react-bootstrap/react-bootstrap.d.ts +++ b/react-bootstrap/react-bootstrap.d.ts @@ -459,6 +459,15 @@ declare module "react-bootstrap" { interface Navbar extends React.ReactElement { } interface NavbarClass extends React.ComponentClass { } var Navbar: NavbarClass; + + // + // ---------------------------------------- + interface NavBrandProps { + + } + interface NavBrand extends React.ReactElement { } + interface NavBrandClass extends React.ComponentClass { } + var NavBrand: NavBrandClass; // From 202d240a0a0c86661b30f3a97169e70f72484293 Mon Sep 17 00:00:00 2001 From: Joe Skeen Date: Wed, 7 Oct 2015 09:07:44 -0600 Subject: [PATCH 0037/1238] 'request': Added more tests from project page and fixed definitions accordingly --- request/request-tests.ts | 438 ++++++++++++++++++++++++++++++++++++++- request/request.d.ts | 146 ++++++++----- 2 files changed, 517 insertions(+), 67 deletions(-) diff --git a/request/request-tests.ts b/request/request-tests.ts index 9d7cbf3bc4..7f04be26ac 100644 --- a/request/request-tests.ts +++ b/request/request-tests.ts @@ -4,6 +4,7 @@ import request = require('request'); import http = require('http'); import stream = require('stream'); import formData = require('form-data'); +import fs = require('fs'); var value: any; var str: string; @@ -20,7 +21,7 @@ var headers: {[key: string]: string}; var agent: http.Agent; var write: stream.Writable; var req: request.Request; -var form: formData.FormData; +var form1: formData.FormData; var bodyArr: request.RequestPart[] = [{ body: value @@ -125,8 +126,6 @@ req.destroy(); // --- --- --- --- --- --- --- --- --- --- --- --- -var callback: (error: any, response: any, body: any) => void; - value = request.initParams; req = request(uri); @@ -136,13 +135,6 @@ req = request(uri, callback); req = request(options); req = request(options, callback); -req = request.request(uri); -req = request.request(uri, options); -req = request.request(uri, options, callback); -req = request.request(uri, callback); -req = request.request(options); -req = request.request(options, callback); - req = request.get(uri); req = request.get(uri, options); req = request.get(uri, options, callback); @@ -204,3 +196,429 @@ request // check response }) .pipe(request.put('http://another.com/another.png')); + +//The following examples from https://github.com/request/request +request('http://www.google.com', function (error, response, body) { + if (!error && response.statusCode == 200) { + console.log(body); // Show the HTML for the Google homepage. + } +}); + +request('http://google.com/doodle.png').pipe(fs.createWriteStream('doodle.png')); + +fs.createReadStream('file.json').pipe(request.put('http://mysite.com/obj.json')); + +request.get('http://google.com/img.png').pipe(request.put('http://mysite.com/img.png')); + +request + .get('http://google.com/img.png') + .on('response', function(response) { + console.log(response.statusCode); // 200 + console.log(response.headers['content-type']); // 'image/png' + }) + .pipe(request.put('http://mysite.com/img.png')); + +request + .get('http://mysite.com/doodle.png') + .on('error', function(err) { + console.log(err); + }) + .pipe(fs.createWriteStream('doodle.png')); + +http.createServer(function (req, resp) { + if (req.url === '/doodle.png') { + if (req.method === 'PUT') { + req.pipe(request.put('http://mysite.com/doodle.png')); + } else if (req.method === 'GET' || req.method === 'HEAD') { + request.get('http://mysite.com/doodle.png').pipe(resp); + } + } +}); + +http.createServer(function (req, resp) { + if (req.url === '/doodle.png') { + var x = request('http://mysite.com/doodle.png'); + req.pipe(x); + x.pipe(resp); + } +}); + +var resp: http.ServerResponse; +req.pipe(request('http://mysite.com/doodle.png')).pipe(resp); + +http.createServer(function (req, resp) { + if (req.url === '/doodle.png') { + r.get('http://google.com/doodle.png').pipe(resp); + } +}); + +request.post('http://service.com/upload', {form:{key:'value'}}); +// or +request.post('http://service.com/upload').form({key:'value'}); +// or +request.post({url:'http://service.com/upload', form: {key:'value'}}, function(err,httpResponse,body){ /* ... */ }); + +var data = { + // Pass a simple key-value pair + my_field: 'my_value', + // Pass data via Buffers + my_buffer: new Buffer([1, 2, 3]), + // Pass data via Streams + my_file: fs.createReadStream(__dirname + '/unicycle.jpg'), + // Pass multiple values /w an Array + attachments: [ + fs.createReadStream(__dirname + '/attachment1.jpg'), + fs.createReadStream(__dirname + '/attachment2.jpg') + ], + // Pass optional meta-data with an 'options' object with style: {value: DATA, options: OPTIONS} + // Use case: for some types of streams, you'll need to provide "file"-related information manually. + // See the `form-data` README for more information about options: https://github.com/felixge/node-form-data + custom_file: { + value: fs.createReadStream('/dev/urandom'), + options: { + filename: 'topsecret.jpg', + contentType: 'image/jpg' + } + } +}; +request.post({url:'http://service.com/upload', formData: data}, function optionalCallback(err, httpResponse, body) { + if (err) { + return console.error('upload failed:', err); + } + console.log('Upload successful! Server responded with:', body); +}); + +var requestMultipart = request.post('http://service.com/upload', function optionalCallback(err, httpResponse, body) {}); +var form = requestMultipart.form(); +form.append('my_field', 'my_value'); +form.append('my_buffer', new Buffer([1, 2, 3])); +form.append('custom_file', fs.createReadStream(__dirname + '/unicycle.jpg'), {filename: 'unicycle.jpg'}); + +request({ + method: 'PUT', + preambleCRLF: true, + postambleCRLF: true, + uri: 'http://service.com/upload', + multipart: { + chunked: false, + data: [ + { + 'content-type': 'application/json', + body: JSON.stringify({foo: 'bar', _attachments: {'message.txt': {follows: true, length: 18, 'content_type': 'text/plain' }}}) + }, + { body: 'I am an attachment' } + ] + } + }, + function (error, response, body) { + if (error) { + return console.error('upload failed:', error); + } + console.log('Upload successful! Server responded with:', body); + }); +request({ + method: 'PUT', + preambleCRLF: true, + postambleCRLF: true, + uri: 'http://service.com/upload', + multipart: [ + { + 'content-type': 'application/json', + body: JSON.stringify({foo: 'bar', _attachments: {'message.txt': {follows: true, length: 18, 'content_type': 'text/plain' }}}) + }, + { body: 'I am an attachment' }, + { body: fs.createReadStream('image.png') } + ] + }, + function (error, response, body) { + if (error) { + return console.error('upload failed:', error); + } + console.log('Upload successful! Server responded with:', body); + }); + +request.get('http://some.server.com/').auth('username', 'password', false); +// or +request.get('http://some.server.com/', { + 'auth': { + 'user': 'username', + 'pass': 'password', + 'sendImmediately': false + } +}); +// or +request.get('http://some.server.com/').auth(null, null, true, 'bearerToken'); +// or +request.get('http://some.server.com/', { + 'auth': { + 'bearer': 'bearerToken' + } +}); + +var username = 'username', + password = 'password', + url = 'http://' + username + ':' + password + '@some.server.com'; + +request({url: url}, function (error, response, body) { + // Do more stuff with 'body' here +}); + +options = { + url: 'https://api.github.com/repos/request/request', + headers: { + 'User-Agent': 'request' + } +}; + +function callback(error, response, body) { + if (!error && response.statusCode == 200) { + var info = JSON.parse(body); + console.log(info.stargazers_count + " Stars"); + console.log(info.forks_count + " Forks"); + } +} + +request(options, callback); + +// OAuth1.0 - 3-legged server side flow (Twitter example) +// step 1 +import qs = require('querystring'); +const CONSUMER_KEY = 'key'; +const CONSUMER_SECRET = 'secret'; +oauth = + { callback: 'http://mysite.com/callback/' + , consumer_key: CONSUMER_KEY + , consumer_secret: CONSUMER_SECRET + } + , url = 'https://api.twitter.com/oauth/request_token' + ; +request.post({url:url, oauth:oauth}, function (e, r, body) { + // Ideally, you would take the body in the response + // and construct a URL that a user clicks on (like a sign in button). + // The verifier is only available in the response after a user has + // verified with twitter that they are authorizing your app. + + // step 2 + var req_data = qs.parse(body); + var uri = 'https://api.twitter.com/oauth/authenticate' + + '?' + qs.stringify({oauth_token: req_data.oauth_token}); + // redirect the user to the authorize uri + + // step 3 + // after the user is redirected back to your server + var auth_data = qs.parse(body) + , oauth = + { consumer_key: CONSUMER_KEY + , consumer_secret: CONSUMER_SECRET + , token: auth_data.oauth_token + , token_secret: req_data.oauth_token_secret + , verifier: auth_data.oauth_verifier + } + , url = 'https://api.twitter.com/oauth/access_token' + ; + request.post({url:url, oauth:oauth}, function (e, r, body) { + // ready to make signed requests on behalf of the user + var perm_data = qs.parse(body) + , oauth = + { consumer_key: CONSUMER_KEY + , consumer_secret: CONSUMER_SECRET + , token: perm_data.oauth_token + , token_secret: perm_data.oauth_token_secret + } + , url = 'https://api.twitter.com/1.1/users/show.json' + , qs = + { screen_name: perm_data.screen_name + , user_id: perm_data.user_id + } + ; + request.get({url:url, oauth:oauth, qs:qs, json:true}, function (e, r, user) { + console.log(user); + }); + }); +}); + +var path = require('path') + , certFile = path.resolve(__dirname, 'ssl/client.crt') + , keyFile = path.resolve(__dirname, 'ssl/client.key') + , caFile = path.resolve(__dirname, 'ssl/ca.cert.pem'); + +options = { + url: 'https://api.some-server.com/', + cert: fs.readFileSync(certFile), + key: fs.readFileSync(keyFile), + passphrase: 'password', + ca: fs.readFileSync(caFile) +}; + +request.get(options); + +var path = require('path') + , certFile = path.resolve(__dirname, 'ssl/client.crt') + , keyFile = path.resolve(__dirname, 'ssl/client.key'); + +options = { + url: 'https://api.some-server.com/', + agentOptions: { + cert: fs.readFileSync(certFile), + key: fs.readFileSync(keyFile), + // Or use `pfx` property replacing `cert` and `key` when using private key, certificate and CA certs in PFX or PKCS12 format: + // pfx: fs.readFileSync(pfxFilePath), + passphrase: 'password', + securityOptions: 'SSL_OP_NO_SSLv3' + } +}; + +request.get(options); + +request.get({ + url: 'https://api.some-server.com/', + agentOptions: { + secureProtocol: 'SSLv3_method' + } +}); + +request.get({ + url: 'https://api.some-server.com/', + agentOptions: { + ca: fs.readFileSync('ca.cert.pem') + } +}); + + +request({ + // will be ignored + method: 'GET', + uri: 'http://www.google.com', + + // HTTP Archive Request Object + har: { + url: 'http://www.mockbin.com/har', + method: 'POST', + headers: [ + { + name: 'content-type', + value: 'application/x-www-form-urlencoded' + } + ], + postData: { + mimeType: 'application/x-www-form-urlencoded', + params: [ + { + name: 'foo', + value: 'bar' + }, + { + name: 'hello', + value: 'world' + } + ] + } + } + }); + +//requests using baseRequest() will set the 'x-token' header +var baseRequest = request.defaults({ + headers: {'x-token': 'my-token'} +}); + +//requests using specialRequest() will include the 'x-token' header set in +//baseRequest and will also include the 'special' header +var specialRequest = baseRequest.defaults({ + headers: {special: 'special value'} +}); + +request.put(url); +request.patch(url); +request.post(url); +request.head(url); +request.del(url); +request.get(url); +request.cookie('key1=value1'); +request.jar(); +request.debug = true; + +request.get('http://10.255.255.1', {timeout: 1500}, function(err) { + console.log(err.code === 'ETIMEDOUT'); + // Set to `true` if the timeout was a connection timeout, `false` or + // `undefined` otherwise. + console.log(err.connect === true); + process.exit(0); +}); + +var rand = Math.floor(Math.random()*100000000).toString(); + request( + { method: 'PUT' + , uri: 'http://mikeal.iriscouch.com/testjs/' + rand + , multipart: + [ { 'content-type': 'application/json' + , body: JSON.stringify({foo: 'bar', _attachments: {'message.txt': {follows: true, length: 18, 'content_type': 'text/plain' }}}) + } + , { body: 'I am an attachment' } + ] + } + , function (error, response, body) { + if(response.statusCode == 201){ + console.log('document saved as: http://mikeal.iriscouch.com/testjs/'+ rand) + } else { + console.log('error: '+ response.statusCode) + console.log(body) + } + } + ); + +request( + { method: 'GET' + , uri: 'http://www.google.com' + , gzip: true + } + , function (error, response, body) { + // body is the decompressed response body + console.log('server encoded the data as: ' + (response.headers['content-encoding'] || 'identity')) + console.log('the decoded data is: ' + body) + } + ).on('data', function(data) { + // decompressed data as it is received + console.log('decoded chunk: ' + data) + }) + .on('response', function(response) { + // unmodified http.IncomingMessage object + response.on('data', function(data) { + // compressed data as it is received + console.log('received ' + data.length + ' bytes of compressed data') + }) + }); + +var requestWithJar = request.defaults({jar: true}) +requestWithJar('http://www.google.com', function () { + requestWithJar('http://images.google.com'); +}); + +var j = request.jar() +requestWithJar = request.defaults({jar:j}) +requestWithJar('http://www.google.com', function () { + requestWithJar('http://images.google.com'); +}); + +var j = request.jar(); +cookie = request.cookie('key1=value1'); +var url = 'http://www.google.com'; +j.setCookie(cookie, url); +request({url: url, jar: j}, function () { + request('http://images.google.com'); +}); + +//TODO: add definitions for tough-cookie-filestore +//var FileCookieStore = require('tough-cookie-filestore'); +// NOTE - currently the 'cookies.json' file must already exist! +//var j = request.jar(new FileCookieStore('cookies.json')); +requestWithJar = request.defaults({ jar : j }) +request('http://www.google.com', function() { + request('http://images.google.com'); +}); + +var j = request.jar() +request({url: 'http://www.google.com', jar: j}, function () { + var cookie_string = j.getCookieString(url); // "key1=value1; key2=value2; ..." + var cookies = j.getCookies(url); + // [{key: 'key1', value: 'value1', domain: "www.google.com", ...}, ...] +}); diff --git a/request/request.d.ts b/request/request.d.ts index 4827bc7a66..f3a2741fb7 100644 --- a/request/request.d.ts +++ b/request/request.d.ts @@ -13,50 +13,50 @@ declare module 'request' { import http = require('http'); import FormData = require('form-data'); import url = require('url'); + import fs = require('fs'); - export = RequestAPI; - - function RequestAPI(uri: string, options?: RequestAPI.Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): RequestAPI.Request; - function RequestAPI(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): RequestAPI.Request; - function RequestAPI(options: RequestAPI.Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): RequestAPI.Request; - - module RequestAPI { - export function defaults(options: Options): typeof RequestAPI; - - export function request(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - export function request(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - export function request(options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - - export function get(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - export function get(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - export function get(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - - export function post(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - export function post(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - export function post(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - - export function put(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - export function put(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - export function put(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - - export function head(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - export function head(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - export function head(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - - export function patch(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - export function patch(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - export function patch(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - - export function del(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - export function del(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - export function del(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - - export function forever(agentOptions: any, optionsArg: any): Request; - export function jar(): CookieJar; - export function cookie(str: string): Cookie; - - export var initParams: any; - + namespace request { + export interface RequestAPI { + defaults(options: Options): RequestAPI; + (uri: string, + options?: Options, + callback?: (error: any, response: http.IncomingMessage, body: any) => void) + : Request; + (uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + (options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + + get(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + get(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + get(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + + post(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + post(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + post(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + + put(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + put(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + put(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + + head(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + head(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + head(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + + patch(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + patch(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + patch(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + + del(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + del(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + del(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + + forever(agentOptions: any, optionsArg: any): Request; + jar(): CookieJar; + cookie(str: string): Cookie; + + initParams: any; + debug: boolean; + } + export interface Options { url?: string; uri?: string; @@ -70,7 +70,7 @@ declare module 'request' { hawk ?: HawkOptions; qs?: any; json?: any; - multipart?: RequestPart[]; + multipart?: RequestPart[] | Multipart; agentOptions?: any; agentClass?: any; forever?: any; @@ -88,17 +88,47 @@ declare module 'request' { proxy?: any; strictSSL?: boolean; gzip?: boolean; + preambleCRLF?: boolean; + postambleCRLF?: boolean; + key?: Buffer; + cert?: Buffer; + passphrase?: string; + ca?: Buffer; + har?: HttpArchiveRequest; } + + export interface HttpArchiveRequest { + url?: string; + method?: string; + headers?: NameValuePair[]; + postData?: { + mimeType?: string; + params?: NameValuePair[]; + } + } + export interface NameValuePair { + name: string; + value: string; + } + + export interface Multipart { + chunked?: boolean; + data?: { + 'content-type'?: string, + body: string + }[]; + } + export interface RequestPart { headers?: Headers; body: any; } - + export interface Request extends stream.Stream { readable: boolean; writable: boolean; - + getAgent(): http.Agent; //start(): void; //abort(): void; @@ -114,9 +144,9 @@ declare module 'request' { auth(username: string, password: string, sendInmediately?: boolean, bearer?: string): Request; oauth(oauth: OAuthOptions): Request; jar(jar: CookieJar): Request; - + on(event: string, listener: Function): Request; - + write(buffer: Buffer, cb?: Function): boolean; write(str: string, cb?: Function): boolean; write(str: string, encoding: string, cb?: Function): boolean; @@ -131,11 +161,11 @@ declare module 'request' { destroy(): void; toJSON(): string; } - + export interface Headers { [key: string]: any; } - + export interface AuthOptions { user?: string; username?: string; @@ -144,7 +174,7 @@ declare module 'request' { sendImmediately?: boolean; bearer?: string; } - + export interface OAuthOptions { callback?: string; consumer_key?: string; @@ -153,28 +183,28 @@ declare module 'request' { token_secret?: string; verifier?: string; } - + export interface HawkOptions { credentials: any; } - + export interface AWSOptions { secret: string; bucket?: string; } - + export interface CookieJar { setCookie(cookie: Cookie, uri: string|url.Url, options?: any): void getCookieString(uri: string|url.Url): string getCookies(uri: string|url.Url): Cookie[] } - + export interface CookieValue { name: string; value: any; httpOnly: boolean; } - + export interface Cookie extends Array { constructor(name: string, req: Request): void; str: string; @@ -182,5 +212,7 @@ declare module 'request' { path: string; toString(): string; } - } + } + var request: request.RequestAPI; + export = request; } From c91de3cf9a015956bc5702a78fd04235ed677403 Mon Sep 17 00:00:00 2001 From: William Comartin Date: Wed, 7 Oct 2015 11:30:13 -0400 Subject: [PATCH 0038/1238] add angular-dialog-service-tests --- .../angular-dialog-service-tests.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 angular-dialog-service/angular-dialog-service-tests.ts diff --git a/angular-dialog-service/angular-dialog-service-tests.ts b/angular-dialog-service/angular-dialog-service-tests.ts new file mode 100644 index 0000000000..646b9b1cec --- /dev/null +++ b/angular-dialog-service/angular-dialog-service-tests.ts @@ -0,0 +1,16 @@ +/// + + +var options : angular.dialogservice.IDialogOptions = {}; +options.animation = true; +options.backdrop = true; +options.keyboard = true; +options.backdropClass = "some-css-class"; +options.windowClass = "some-css-class"; +options.size = 'md'; + +var dialogs : angular.dialogservice.IDialogService; +dialogs.error('Error','An unknown error occurred preventing the completion of the requested action.'); +dialogs.wait('Creating User','Please wait while we attempt to create user "Michael Conroy."

This should only take a moment.',50); +dialogs.notify('Something Happened','Something happened at this point in the application that I wish to let you know about'); +dialogs.create('url/to/a/template','ctrlrToUse',{data: topass,anotherVar: 'value'},{}); From 0078ccfafc5515a07abc501ebb93f7767855e35c Mon Sep 17 00:00:00 2001 From: William Comartin Date: Wed, 7 Oct 2015 11:33:40 -0400 Subject: [PATCH 0039/1238] Fix Tests for angular-dialog-service --- angular-dialog-service/angular-dialog-service-tests.ts | 2 +- angular-dialog-service/angular-dialog-service.d.ts | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/angular-dialog-service/angular-dialog-service-tests.ts b/angular-dialog-service/angular-dialog-service-tests.ts index 646b9b1cec..8142a3a713 100644 --- a/angular-dialog-service/angular-dialog-service-tests.ts +++ b/angular-dialog-service/angular-dialog-service-tests.ts @@ -13,4 +13,4 @@ var dialogs : angular.dialogservice.IDialogService; dialogs.error('Error','An unknown error occurred preventing the completion of the requested action.'); dialogs.wait('Creating User','Please wait while we attempt to create user "Michael Conroy."

This should only take a moment.',50); dialogs.notify('Something Happened','Something happened at this point in the application that I wish to let you know about'); -dialogs.create('url/to/a/template','ctrlrToUse',{data: topass,anotherVar: 'value'},{}); +dialogs.create('url/to/a/template','ctrlrToUse',{},{}); diff --git a/angular-dialog-service/angular-dialog-service.d.ts b/angular-dialog-service/angular-dialog-service.d.ts index aa057642cd..38ce8589e4 100644 --- a/angular-dialog-service/angular-dialog-service.d.ts +++ b/angular-dialog-service/angular-dialog-service.d.ts @@ -60,23 +60,23 @@ declare module angular.dialogservice { /** * Opens a new error modal instance. */ - error(header: string, msg: string, progress: number, opts: IDialogOptions): ng.ui.bootstrap.IModalServiceInstance + error(header: string, msg: string, opts?: IDialogOptions): ng.ui.bootstrap.IModalServiceInstance /** * Opens a new wait modal instance. */ - wait(header: string, msg: string, opts: IDialogOptions): ng.ui.bootstrap.IModalServiceInstance + wait(header: string, msg: string, progress: number, opts?: IDialogOptions): ng.ui.bootstrap.IModalServiceInstance /** * Opens a new notify modal instance. */ - notify(header: string, msg: string, opts: IDialogOptions): ng.ui.bootstrap.IModalServiceInstance + notify(header: string, msg: string, opts?: IDialogOptions): ng.ui.bootstrap.IModalServiceInstance /** * Opens a new confirm modal instance. */ - confirm(header: string, msg: string, opts: IDialogOptions): ng.ui.bootstrap.IModalServiceInstance + confirm(header: string, msg: string, opts?: IDialogOptions): ng.ui.bootstrap.IModalServiceInstance /** * Opens a new custom modal instance. */ - create(url: string, ctrlr: string, data: any, opts: IDialogOptions): ng.ui.bootstrap.IModalServiceInstance + create(url: string, ctrlr: string, data: any, opts?: IDialogOptions): ng.ui.bootstrap.IModalServiceInstance } } From 31d1cc43cd5f828fec19f35c286396f859fa47cc Mon Sep 17 00:00:00 2001 From: Joe Skeen Date: Wed, 7 Oct 2015 09:41:45 -0600 Subject: [PATCH 0040/1238] Change request-promise to use full 'request' API --- request-promise/request-promise-tests.ts | 453 ++++++++++++++++++++++- request-promise/request-promise.d.ts | 25 +- request/request-tests.ts | 2 +- request/request.d.ts | 54 +-- 4 files changed, 486 insertions(+), 48 deletions(-) diff --git a/request-promise/request-promise-tests.ts b/request-promise/request-promise-tests.ts index 41a5eb80d3..ad2f8f61f9 100644 --- a/request-promise/request-promise-tests.ts +++ b/request-promise/request-promise-tests.ts @@ -1,17 +1,466 @@ /// import rp = require('request-promise'); +import nodeRequest = require('request'); rp('http://www.google.com') .then(console.dir) .catch(console.error); -var options: rp.Options = { +var options: nodeRequest.Options = { uri : 'http://posttestserver.com/post.php', - method : 'POST' + method : 'POST', + json: true, + body: { some: 'payload' } }; rp(options) .then(console.dir) .catch(console.error); +// --> Displays length of response from server after post + +// Get full response after DELETE +options = { + method: 'DELETE', + uri: 'http://my-server/path/to/resource/1234' +}; + +rp(options) + .then(function (response) { + console.log("DELETE succeeded with status %d", response.statusCode); + }) + .catch(console.error); + +//The following examples from https://github.com/request/request +import fs = require('fs'); +import http = require('http'); +var request = rp; + +//The following examples from https://github.com/request/request +request('http://www.google.com', function (error, response, body) { + if (!error && response.statusCode == 200) { + console.log(body); // Show the HTML for the Google homepage. + } +}); + +request('http://google.com/doodle.png').pipe(fs.createWriteStream('doodle.png')); + +fs.createReadStream('file.json').pipe(request.put('http://mysite.com/obj.json')); + +request.get('http://google.com/img.png').pipe(request.put('http://mysite.com/img.png')); + +request + .get('http://google.com/img.png') + .on('response', function(response) { + console.log(response.statusCode); // 200 + console.log(response.headers['content-type']); // 'image/png' + }) + .pipe(request.put('http://mysite.com/img.png')); + +request + .get('http://mysite.com/doodle.png') + .on('error', function(err) { + console.log(err); + }) + .pipe(fs.createWriteStream('doodle.png')); + +http.createServer(function (req, resp) { + if (req.url === '/doodle.png') { + if (req.method === 'PUT') { + req.pipe(request.put('http://mysite.com/doodle.png')); + } else if (req.method === 'GET' || req.method === 'HEAD') { + request.get('http://mysite.com/doodle.png').pipe(resp); + } + } +}); + +http.createServer(function (req, resp) { + if (req.url === '/doodle.png') { + var x = request('http://mysite.com/doodle.png'); + req.pipe(x); + x.pipe(resp); + } +}); + +var resp: http.ServerResponse; +var req: nodeRequest.Request; +req.pipe(request('http://mysite.com/doodle.png')).pipe(resp); + +var r = request; +http.createServer(function (req, resp) { + if (req.url === '/doodle.png') { + r.get('http://google.com/doodle.png').pipe(resp); + } +}); + +request.post('http://service.com/upload', {form:{key:'value'}}); +// or +request.post('http://service.com/upload').form({key:'value'}); +// or +request.post({url:'http://service.com/upload', form: {key:'value'}}, function(err,httpResponse,body){ /* ... */ }); + +var data = { + // Pass a simple key-value pair + my_field: 'my_value', + // Pass data via Buffers + my_buffer: new Buffer([1, 2, 3]), + // Pass data via Streams + my_file: fs.createReadStream(__dirname + '/unicycle.jpg'), + // Pass multiple values /w an Array + attachments: [ + fs.createReadStream(__dirname + '/attachment1.jpg'), + fs.createReadStream(__dirname + '/attachment2.jpg') + ], + // Pass optional meta-data with an 'options' object with style: {value: DATA, options: OPTIONS} + // Use case: for some types of streams, you'll need to provide "file"-related information manually. + // See the `form-data` README for more information about options: https://github.com/felixge/node-form-data + custom_file: { + value: fs.createReadStream('/dev/urandom'), + options: { + filename: 'topsecret.jpg', + contentType: 'image/jpg' + } + } +}; +request.post({url:'http://service.com/upload', formData: data}, function optionalCallback(err, httpResponse, body) { + if (err) { + return console.error('upload failed:', err); + } + console.log('Upload successful! Server responded with:', body); +}); + +var requestMultipart = request.post('http://service.com/upload', function optionalCallback(err, httpResponse, body) {}); +var form = requestMultipart.form(); +form.append('my_field', 'my_value'); +form.append('my_buffer', new Buffer([1, 2, 3])); +form.append('custom_file', fs.createReadStream(__dirname + '/unicycle.jpg'), {filename: 'unicycle.jpg'}); + +request({ + method: 'PUT', + preambleCRLF: true, + postambleCRLF: true, + uri: 'http://service.com/upload', + multipart: { + chunked: false, + data: [ + { + 'content-type': 'application/json', + body: JSON.stringify({foo: 'bar', _attachments: {'message.txt': {follows: true, length: 18, 'content_type': 'text/plain' }}}) + }, + { body: 'I am an attachment' } + ] + } + }, + function (error, response, body) { + if (error) { + return console.error('upload failed:', error); + } + console.log('Upload successful! Server responded with:', body); + }); +request({ + method: 'PUT', + preambleCRLF: true, + postambleCRLF: true, + uri: 'http://service.com/upload', + multipart: [ + { + 'content-type': 'application/json', + body: JSON.stringify({foo: 'bar', _attachments: {'message.txt': {follows: true, length: 18, 'content_type': 'text/plain' }}}) + }, + { body: 'I am an attachment' }, + { body: fs.createReadStream('image.png') } + ] + }, + function (error, response, body) { + if (error) { + return console.error('upload failed:', error); + } + console.log('Upload successful! Server responded with:', body); + }); + +request.get('http://some.server.com/').auth('username', 'password', false); +// or +request.get('http://some.server.com/', { + 'auth': { + 'user': 'username', + 'pass': 'password', + 'sendImmediately': false + } +}); +// or +request.get('http://some.server.com/').auth(null, null, true, 'bearerToken'); +// or +request.get('http://some.server.com/', { + 'auth': { + 'bearer': 'bearerToken' + } +}); + +var username = 'username', + password = 'password', + url = 'http://' + username + ':' + password + '@some.server.com'; + +request({url: url}, function (error, response, body) { + // Do more stuff with 'body' here +}); + +options = { + url: 'https://api.github.com/repos/request/request', + headers: { + 'User-Agent': 'request' + } +}; + +function callback(error, response, body) { + if (!error && response.statusCode == 200) { + var info = JSON.parse(body); + console.log(info.stargazers_count + " Stars"); + console.log(info.forks_count + " Forks"); + } +} + +request(options, callback); + +// OAuth1.0 - 3-legged server side flow (Twitter example) +// step 1 +import qs = require('querystring'); +const CONSUMER_KEY = 'key'; +const CONSUMER_SECRET = 'secret'; +var oauth = + { callback: 'http://mysite.com/callback/' + , consumer_key: CONSUMER_KEY + , consumer_secret: CONSUMER_SECRET + } + , url = 'https://api.twitter.com/oauth/request_token' + ; +request.post({url:url, oauth:oauth}, function (e, r, body) { + // Ideally, you would take the body in the response + // and construct a URL that a user clicks on (like a sign in button). + // The verifier is only available in the response after a user has + // verified with twitter that they are authorizing your app. + + // step 2 + var req_data = qs.parse(body); + var uri = 'https://api.twitter.com/oauth/authenticate' + + '?' + qs.stringify({oauth_token: req_data.oauth_token}); + // redirect the user to the authorize uri + + // step 3 + // after the user is redirected back to your server + var auth_data = qs.parse(body) + , oauth = + { consumer_key: CONSUMER_KEY + , consumer_secret: CONSUMER_SECRET + , token: auth_data.oauth_token + , token_secret: req_data.oauth_token_secret + , verifier: auth_data.oauth_verifier + } + , url = 'https://api.twitter.com/oauth/access_token' + ; + request.post({url:url, oauth:oauth}, function (e, r, body) { + // ready to make signed requests on behalf of the user + var perm_data = qs.parse(body) + , oauth = + { consumer_key: CONSUMER_KEY + , consumer_secret: CONSUMER_SECRET + , token: perm_data.oauth_token + , token_secret: perm_data.oauth_token_secret + } + , url = 'https://api.twitter.com/1.1/users/show.json' + , qs = + { screen_name: perm_data.screen_name + , user_id: perm_data.user_id + } + ; + request.get({url:url, oauth:oauth, qs:qs, json:true}, function (e, r, user) { + console.log(user); + }); + }); +}); + +var path = require('path') + , certFile = path.resolve(__dirname, 'ssl/client.crt') + , keyFile = path.resolve(__dirname, 'ssl/client.key') + , caFile = path.resolve(__dirname, 'ssl/ca.cert.pem'); + +options = { + url: 'https://api.some-server.com/', + cert: fs.readFileSync(certFile), + key: fs.readFileSync(keyFile), + passphrase: 'password', + ca: fs.readFileSync(caFile) +}; + +request.get(options); + +var path = require('path') + , certFile = path.resolve(__dirname, 'ssl/client.crt') + , keyFile = path.resolve(__dirname, 'ssl/client.key'); + +options = { + url: 'https://api.some-server.com/', + agentOptions: { + cert: fs.readFileSync(certFile), + key: fs.readFileSync(keyFile), + // Or use `pfx` property replacing `cert` and `key` when using private key, certificate and CA certs in PFX or PKCS12 format: + // pfx: fs.readFileSync(pfxFilePath), + passphrase: 'password', + securityOptions: 'SSL_OP_NO_SSLv3' + } +}; + +request.get(options); + +request.get({ + url: 'https://api.some-server.com/', + agentOptions: { + secureProtocol: 'SSLv3_method' + } +}); + +request.get({ + url: 'https://api.some-server.com/', + agentOptions: { + ca: fs.readFileSync('ca.cert.pem') + } +}); + + +request({ + // will be ignored + method: 'GET', + uri: 'http://www.google.com', + + // HTTP Archive Request Object + har: { + url: 'http://www.mockbin.com/har', + method: 'POST', + headers: [ + { + name: 'content-type', + value: 'application/x-www-form-urlencoded' + } + ], + postData: { + mimeType: 'application/x-www-form-urlencoded', + params: [ + { + name: 'foo', + value: 'bar' + }, + { + name: 'hello', + value: 'world' + } + ] + } + } + }); + +//requests using baseRequest() will set the 'x-token' header +var baseRequest = request.defaults({ + headers: {'x-token': 'my-token'} +}); + +//requests using specialRequest() will include the 'x-token' header set in +//baseRequest and will also include the 'special' header +var specialRequest = baseRequest.defaults({ + headers: {special: 'special value'} +}); + +request.put(url); +request.patch(url); +request.post(url); +request.head(url); +request.del(url); +request.get(url); +request.cookie('key1=value1'); +request.jar(); +request.debug = true; + +request.get('http://10.255.255.1', {timeout: 1500}, function(err) { + console.log(err.code === 'ETIMEDOUT'); + // Set to `true` if the timeout was a connection timeout, `false` or + // `undefined` otherwise. + console.log(err.connect === true); + process.exit(0); +}); + +var rand = Math.floor(Math.random()*100000000).toString(); + request( + { method: 'PUT' + , uri: 'http://mikeal.iriscouch.com/testjs/' + rand + , multipart: + [ { 'content-type': 'application/json' + , body: JSON.stringify({foo: 'bar', _attachments: {'message.txt': {follows: true, length: 18, 'content_type': 'text/plain' }}}) + } + , { body: 'I am an attachment' } + ] + } + , function (error, response, body) { + if(response.statusCode == 201){ + console.log('document saved as: http://mikeal.iriscouch.com/testjs/'+ rand) + } else { + console.log('error: '+ response.statusCode) + console.log(body) + } + } + ); + +request( + { method: 'GET' + , uri: 'http://www.google.com' + , gzip: true + } + , function (error, response, body) { + // body is the decompressed response body + console.log('server encoded the data as: ' + (response.headers['content-encoding'] || 'identity')) + console.log('the decoded data is: ' + body) + } + ).on('data', function(data) { + // decompressed data as it is received + console.log('decoded chunk: ' + data) + }) + .on('response', function(response) { + // unmodified http.IncomingMessage object + response.on('data', function(data) { + // compressed data as it is received + console.log('received ' + data.length + ' bytes of compressed data') + }) + }); + +var requestWithJar = request.defaults({jar: true}) +requestWithJar('http://www.google.com', function () { + requestWithJar('http://images.google.com'); +}); + +var j = request.jar() +requestWithJar = request.defaults({jar:j}) +requestWithJar('http://www.google.com', function () { + requestWithJar('http://images.google.com'); +}); + +var j = request.jar(); +var cookie = request.cookie('key1=value1'); +var url = 'http://www.google.com'; +j.setCookie(cookie, url); +request({url: url, jar: j}, function () { + request('http://images.google.com'); +}); + +//TODO: add definitions for tough-cookie-filestore +//var FileCookieStore = require('tough-cookie-filestore'); +// NOTE - currently the 'cookies.json' file must already exist! +//var j = request.jar(new FileCookieStore('cookies.json')); +requestWithJar = request.defaults({ jar : j }) +request('http://www.google.com', function() { + request('http://images.google.com'); +}); + +var j = request.jar() +request({url: 'http://www.google.com', jar: j}, function () { + var cookie_string = j.getCookieString(url); // "key1=value1; key2=value2; ..." + var cookies = j.getCookies(url); + // [{key: 'key1', value: 'value1', domain: "www.google.com", ...}, ...] +}); diff --git a/request-promise/request-promise.d.ts b/request-promise/request-promise.d.ts index 246f1e5d9d..67b82ebd8e 100644 --- a/request-promise/request-promise.d.ts +++ b/request-promise/request-promise.d.ts @@ -1,31 +1,20 @@ // Type definitions for request-promise v0.4.2 // Project: https://www.npmjs.com/package/request-promise -// Definitions by: Christopher Glantschnig +// Definitions by: Christopher Glantschnig , Joe Skeen // Definitions: https://github.com/borisyankov/DefinitelyTyped // Change [0]: 2015/08/20 - Aya Morisawa -/// -/// /// /// declare module 'request-promise' { import request = require('request'); - import stream = require('stream'); - import http = require('http'); - import FormData = require('form-data'); - - export = RequestPromiseAPI; - - function RequestPromiseAPI(options: RequestPromiseAPI.Options): Promise; - function RequestPromiseAPI(uri: string): Promise; - - module RequestPromiseAPI { - export interface Options extends request.Options { - simple?: boolean; - transform?: (body: any, response: http.IncomingMessage) => any; - resolveWithFullResponse?: boolean; - } + import http = require('http'); + + interface RequestPromise extends request.Request, Promise { } + + var requestPromise: request.RequestAPI; + export = requestPromise; } diff --git a/request/request-tests.ts b/request/request-tests.ts index 7f04be26ac..99c7f566c2 100644 --- a/request/request-tests.ts +++ b/request/request-tests.ts @@ -33,7 +33,7 @@ var bodyArr: request.RequestPart[] = [{ // --- --- --- --- --- --- --- --- --- --- --- --- -str = req.toJSON(); +obj = req.toJSON(); var cookieValue: request.CookieValue; str = cookieValue.name; diff --git a/request/request.d.ts b/request/request.d.ts index f3a2741fb7..202adf9552 100644 --- a/request/request.d.ts +++ b/request/request.d.ts @@ -1,6 +1,6 @@ // Type definitions for request // Project: https://github.com/mikeal/request -// Definitions by: Carlos Ballesteros Velasco , bonnici , Bart van der Schoor +// Definitions by: Carlos Ballesteros Velasco , bonnici , Bart van der Schoor , Joe Skeen // Definitions: https://github.com/borisyankov/DefinitelyTyped // Imported from: https://github.com/soywiz/typescript-node-definitions/d.ts @@ -16,40 +16,40 @@ declare module 'request' { import fs = require('fs'); namespace request { - export interface RequestAPI { - defaults(options: Options): RequestAPI; + export interface RequestAPI { + defaults(options: Options): RequestAPI; (uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void) - : Request; - (uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - (options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + : TRequest; + (uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; + (options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; - get(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - get(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - get(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + get(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; + get(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; + get(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; - post(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - post(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - post(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + post(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; + post(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; + post(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; - put(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - put(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - put(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + put(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; + put(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; + put(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; - head(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - head(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - head(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + head(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; + head(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; + head(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; - patch(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - patch(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - patch(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + patch(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; + patch(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; + patch(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; - del(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - del(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - del(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + del(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; + del(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; + del(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; - forever(agentOptions: any, optionsArg: any): Request; + forever(agentOptions: any, optionsArg: any): TRequest; jar(): CookieJar; cookie(str: string): Cookie; @@ -159,7 +159,7 @@ declare module 'request' { resume(): void; abort(): void; destroy(): void; - toJSON(): string; + toJSON(): Object; } export interface Headers { @@ -213,6 +213,6 @@ declare module 'request' { toString(): string; } } - var request: request.RequestAPI; + var request: request.RequestAPI; export = request; } From b06d25ff7a01af49ca934962021de73f4d292818 Mon Sep 17 00:00:00 2001 From: Joe Skeen Date: Wed, 7 Oct 2015 10:01:23 -0600 Subject: [PATCH 0041/1238] Fix implicit any issues --- request-promise/request-promise-tests.ts | 34 ++++++++-------- request/request-tests.ts | 33 ++++++++-------- request/request.d.ts | 49 ++++++++++++------------ 3 files changed, 57 insertions(+), 59 deletions(-) diff --git a/request-promise/request-promise-tests.ts b/request-promise/request-promise-tests.ts index ad2f8f61f9..a4d28a8f44 100644 --- a/request-promise/request-promise-tests.ts +++ b/request-promise/request-promise-tests.ts @@ -37,7 +37,6 @@ import fs = require('fs'); import http = require('http'); var request = rp; -//The following examples from https://github.com/request/request request('http://www.google.com', function (error, response, body) { if (!error && response.statusCode == 200) { console.log(body); // Show the HTML for the Google homepage. @@ -52,7 +51,7 @@ request.get('http://google.com/img.png').pipe(request.put('http://mysite.com/img request .get('http://google.com/img.png') - .on('response', function(response) { + .on('response', function(response: any) { console.log(response.statusCode); // 200 console.log(response.headers['content-type']); // 'image/png' }) @@ -60,7 +59,7 @@ request request .get('http://mysite.com/doodle.png') - .on('error', function(err) { + .on('error', function(err: any) { console.log(err); }) .pipe(fs.createWriteStream('doodle.png')); @@ -212,7 +211,7 @@ options = { } }; -function callback(error, response, body) { +function callback(error: any, response: http.IncomingMessage, body: string) { if (!error && response.statusCode == 200) { var info = JSON.parse(body); console.log(info.stargazers_count + " Stars"); @@ -248,7 +247,7 @@ request.post({url:url, oauth:oauth}, function (e, r, body) { // step 3 // after the user is redirected back to your server - var auth_data = qs.parse(body) + var auth_data: any = qs.parse(body) , oauth = { consumer_key: CONSUMER_KEY , consumer_secret: CONSUMER_SECRET @@ -260,20 +259,19 @@ request.post({url:url, oauth:oauth}, function (e, r, body) { ; request.post({url:url, oauth:oauth}, function (e, r, body) { // ready to make signed requests on behalf of the user - var perm_data = qs.parse(body) - , oauth = + var perm_data: any = qs.parse(body); + var oauth = { consumer_key: CONSUMER_KEY , consumer_secret: CONSUMER_SECRET , token: perm_data.oauth_token , token_secret: perm_data.oauth_token_secret - } - , url = 'https://api.twitter.com/1.1/users/show.json' - , qs = - { screen_name: perm_data.screen_name - , user_id: perm_data.user_id - } - ; - request.get({url:url, oauth:oauth, qs:qs, json:true}, function (e, r, user) { + }; + var url = 'https://api.twitter.com/1.1/users/show.json'; + var query = { + screen_name: perm_data.screen_name, + user_id: perm_data.user_id + }; + request.get({url:url, oauth:oauth, qs:query, json:true}, function (e, r, user) { console.log(user); }); }); @@ -418,13 +416,13 @@ request( console.log('server encoded the data as: ' + (response.headers['content-encoding'] || 'identity')) console.log('the decoded data is: ' + body) } - ).on('data', function(data) { + ).on('data', function(data: any) { // decompressed data as it is received console.log('decoded chunk: ' + data) }) - .on('response', function(response) { + .on('response', function(response: http.IncomingMessage) { // unmodified http.IncomingMessage object - response.on('data', function(data) { + response.on('data', function(data: any[]) { // compressed data as it is received console.log('received ' + data.length + ' bytes of compressed data') }) diff --git a/request/request-tests.ts b/request/request-tests.ts index 99c7f566c2..2e878893b3 100644 --- a/request/request-tests.ts +++ b/request/request-tests.ts @@ -212,7 +212,7 @@ request.get('http://google.com/img.png').pipe(request.put('http://mysite.com/img request .get('http://google.com/img.png') - .on('response', function(response) { + .on('response', function(response: any) { console.log(response.statusCode); // 200 console.log(response.headers['content-type']); // 'image/png' }) @@ -220,7 +220,7 @@ request request .get('http://mysite.com/doodle.png') - .on('error', function(err) { + .on('error', function(err: any) { console.log(err); }) .pipe(fs.createWriteStream('doodle.png')); @@ -370,7 +370,7 @@ options = { } }; -function callback(error, response, body) { +function callback(error: any, response: http.IncomingMessage, body: string) { if (!error && response.statusCode == 200) { var info = JSON.parse(body); console.log(info.stargazers_count + " Stars"); @@ -406,7 +406,7 @@ request.post({url:url, oauth:oauth}, function (e, r, body) { // step 3 // after the user is redirected back to your server - var auth_data = qs.parse(body) + var auth_data: any = qs.parse(body) , oauth = { consumer_key: CONSUMER_KEY , consumer_secret: CONSUMER_SECRET @@ -418,20 +418,19 @@ request.post({url:url, oauth:oauth}, function (e, r, body) { ; request.post({url:url, oauth:oauth}, function (e, r, body) { // ready to make signed requests on behalf of the user - var perm_data = qs.parse(body) - , oauth = + var perm_data: any = qs.parse(body); + var oauth = { consumer_key: CONSUMER_KEY , consumer_secret: CONSUMER_SECRET , token: perm_data.oauth_token , token_secret: perm_data.oauth_token_secret - } - , url = 'https://api.twitter.com/1.1/users/show.json' - , qs = - { screen_name: perm_data.screen_name - , user_id: perm_data.user_id - } - ; - request.get({url:url, oauth:oauth, qs:qs, json:true}, function (e, r, user) { + }; + var url = 'https://api.twitter.com/1.1/users/show.json'; + var query = { + screen_name: perm_data.screen_name, + user_id: perm_data.user_id + }; + request.get({url:url, oauth:oauth, qs:query, json:true}, function (e, r, user) { console.log(user); }); }); @@ -576,13 +575,13 @@ request( console.log('server encoded the data as: ' + (response.headers['content-encoding'] || 'identity')) console.log('the decoded data is: ' + body) } - ).on('data', function(data) { + ).on('data', function(data: any) { // decompressed data as it is received console.log('decoded chunk: ' + data) }) - .on('response', function(response) { + .on('response', function(response: http.IncomingMessage) { // unmodified http.IncomingMessage object - response.on('data', function(data) { + response.on('data', function(data: any[]) { // compressed data as it is received console.log('received ' + data.length + ' bytes of compressed data') }) diff --git a/request/request.d.ts b/request/request.d.ts index 202adf9552..711b3d3c16 100644 --- a/request/request.d.ts +++ b/request/request.d.ts @@ -18,36 +18,33 @@ declare module 'request' { namespace request { export interface RequestAPI { defaults(options: Options): RequestAPI; - (uri: string, - options?: Options, - callback?: (error: any, response: http.IncomingMessage, body: any) => void) - : TRequest; - (uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; - (options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; + (uri: string, options?: Options, callback?: RequestCallback): TRequest; + (uri: string, callback?: RequestCallback): TRequest; + (options?: Options, callback?: RequestCallback): TRequest; - get(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; - get(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; - get(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; + get(uri: string, options?: Options, callback?: RequestCallback): TRequest; + get(uri: string, callback?: RequestCallback): TRequest; + get(options: Options, callback?: RequestCallback): TRequest; - post(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; - post(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; - post(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; + post(uri: string, options?: Options, callback?: RequestCallback): TRequest; + post(uri: string, callback?: RequestCallback): TRequest; + post(options: Options, callback?: RequestCallback): TRequest; - put(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; - put(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; - put(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; + put(uri: string, options?: Options, callback?: RequestCallback): TRequest; + put(uri: string, callback?: RequestCallback): TRequest; + put(options: Options, callback?: RequestCallback): TRequest; - head(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; - head(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; - head(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; + head(uri: string, options?: Options, callback?: RequestCallback): TRequest; + head(uri: string, callback?: RequestCallback): TRequest; + head(options: Options, callback?: RequestCallback): TRequest; - patch(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; - patch(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; - patch(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; + patch(uri: string, options?: Options, callback?: RequestCallback): TRequest; + patch(uri: string, callback?: RequestCallback): TRequest; + patch(options: Options, callback?: RequestCallback): TRequest; - del(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; - del(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; - del(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; + del(uri: string, options?: Options, callback?: RequestCallback): TRequest; + del(uri: string, callback?: RequestCallback): TRequest; + del(options: Options, callback?: RequestCallback): TRequest; forever(agentOptions: any, optionsArg: any): TRequest; jar(): CookieJar; @@ -97,6 +94,10 @@ declare module 'request' { har?: HttpArchiveRequest; } + export interface RequestCallback { + (error: any, response: http.IncomingMessage, body: any): void; + } + export interface HttpArchiveRequest { url?: string; method?: string; From 98184ee41d3848d537e04d0414323e73cb2dbe47 Mon Sep 17 00:00:00 2001 From: Joe Skeen Date: Wed, 7 Oct 2015 10:51:29 -0600 Subject: [PATCH 0042/1238] Added back missing options and fixed promise exposure --- request-promise/request-promise.d.ts | 14 ++++++++++++-- request/request.d.ts | 6 +++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/request-promise/request-promise.d.ts b/request-promise/request-promise.d.ts index 67b82ebd8e..7a94ce5967 100644 --- a/request-promise/request-promise.d.ts +++ b/request-promise/request-promise.d.ts @@ -12,9 +12,19 @@ declare module 'request-promise' { import request = require('request'); import http = require('http'); - interface RequestPromise extends request.Request, Promise { + interface RequestPromise extends request.Request { + then(onFulfilled: Function, onRejected: Function): Promise; + catch(onRejected: Function): Promise; + finally(onFinished: Function): Promise; + promise(): Promise; } - var requestPromise: request.RequestAPI; + interface RequestPromiseOptions extends request.Options { + simple?: boolean; + transform?: (body: any, response: http.IncomingMessage) => any; + resolveWithFullResponse?: boolean; + } + + var requestPromise: request.RequestAPI; export = requestPromise; } diff --git a/request/request.d.ts b/request/request.d.ts index 711b3d3c16..f0ec40f3bc 100644 --- a/request/request.d.ts +++ b/request/request.d.ts @@ -16,8 +16,8 @@ declare module 'request' { import fs = require('fs'); namespace request { - export interface RequestAPI { - defaults(options: Options): RequestAPI; + export interface RequestAPI { + defaults(options: Options): RequestAPI; (uri: string, options?: Options, callback?: RequestCallback): TRequest; (uri: string, callback?: RequestCallback): TRequest; (options?: Options, callback?: RequestCallback): TRequest; @@ -214,6 +214,6 @@ declare module 'request' { toString(): string; } } - var request: request.RequestAPI; + var request: request.RequestAPI; export = request; } From 1a9a1665fb7f72239ca3e3b0b5024ff7c0963c36 Mon Sep 17 00:00:00 2001 From: Joe Skeen Date: Wed, 7 Oct 2015 10:55:24 -0600 Subject: [PATCH 0043/1238] fix tests --- request-promise/request-promise.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/request-promise/request-promise.d.ts b/request-promise/request-promise.d.ts index 7a94ce5967..1832787be5 100644 --- a/request-promise/request-promise.d.ts +++ b/request-promise/request-promise.d.ts @@ -13,7 +13,7 @@ declare module 'request-promise' { import http = require('http'); interface RequestPromise extends request.Request { - then(onFulfilled: Function, onRejected: Function): Promise; + then(onFulfilled: Function, onRejected?: Function): Promise; catch(onRejected: Function): Promise; finally(onFinished: Function): Promise; promise(): Promise; From 6c9b4cf0248de82bc63dee6af72fe8dfb9d2501b Mon Sep 17 00:00:00 2001 From: Joe Skeen Date: Wed, 7 Oct 2015 10:58:20 -0600 Subject: [PATCH 0044/1238] fix implicit any --- request-promise/request-promise-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/request-promise/request-promise-tests.ts b/request-promise/request-promise-tests.ts index a4d28a8f44..347cca818d 100644 --- a/request-promise/request-promise-tests.ts +++ b/request-promise/request-promise-tests.ts @@ -27,7 +27,7 @@ options = { }; rp(options) - .then(function (response) { + .then(function (response: http.IncomingMessage) { console.log("DELETE succeeded with status %d", response.statusCode); }) .catch(console.error); From 2d23048aa0c96acfa7d2c667484029acdd446896 Mon Sep 17 00:00:00 2001 From: Joe Skeen Date: Wed, 7 Oct 2015 11:12:48 -0600 Subject: [PATCH 0045/1238] Use generic Options to allow for custom options from request-promise --- request/request.d.ts | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/request/request.d.ts b/request/request.d.ts index f0ec40f3bc..db8ca8c7d3 100644 --- a/request/request.d.ts +++ b/request/request.d.ts @@ -17,34 +17,34 @@ declare module 'request' { namespace request { export interface RequestAPI { - defaults(options: Options): RequestAPI; - (uri: string, options?: Options, callback?: RequestCallback): TRequest; + defaults(options: TOptions): RequestAPI; + (uri: string, options?: TOptions, callback?: RequestCallback): TRequest; (uri: string, callback?: RequestCallback): TRequest; - (options?: Options, callback?: RequestCallback): TRequest; + (options?: TOptions, callback?: RequestCallback): TRequest; - get(uri: string, options?: Options, callback?: RequestCallback): TRequest; + get(uri: string, options?: TOptions, callback?: RequestCallback): TRequest; get(uri: string, callback?: RequestCallback): TRequest; - get(options: Options, callback?: RequestCallback): TRequest; + get(options: TOptions, callback?: RequestCallback): TRequest; - post(uri: string, options?: Options, callback?: RequestCallback): TRequest; + post(uri: string, options?: TOptions, callback?: RequestCallback): TRequest; post(uri: string, callback?: RequestCallback): TRequest; - post(options: Options, callback?: RequestCallback): TRequest; + post(options: TOptions, callback?: RequestCallback): TRequest; - put(uri: string, options?: Options, callback?: RequestCallback): TRequest; + put(uri: string, options?: TOptions, callback?: RequestCallback): TRequest; put(uri: string, callback?: RequestCallback): TRequest; - put(options: Options, callback?: RequestCallback): TRequest; + put(options: TOptions, callback?: RequestCallback): TRequest; - head(uri: string, options?: Options, callback?: RequestCallback): TRequest; + head(uri: string, options?: TOptions, callback?: RequestCallback): TRequest; head(uri: string, callback?: RequestCallback): TRequest; - head(options: Options, callback?: RequestCallback): TRequest; + head(options: TOptions, callback?: RequestCallback): TRequest; - patch(uri: string, options?: Options, callback?: RequestCallback): TRequest; + patch(uri: string, options?: TOptions, callback?: RequestCallback): TRequest; patch(uri: string, callback?: RequestCallback): TRequest; - patch(options: Options, callback?: RequestCallback): TRequest; + patch(options: TOptions, callback?: RequestCallback): TRequest; - del(uri: string, options?: Options, callback?: RequestCallback): TRequest; + del(uri: string, options?: TOptions, callback?: RequestCallback): TRequest; del(uri: string, callback?: RequestCallback): TRequest; - del(options: Options, callback?: RequestCallback): TRequest; + del(options: TOptions, callback?: RequestCallback): TRequest; forever(agentOptions: any, optionsArg: any): TRequest; jar(): CookieJar; From 71b6e0f1fdbc2d43e0e2423505932a14b14081f1 Mon Sep 17 00:00:00 2001 From: ashwin027 Date: Wed, 7 Oct 2015 18:47:15 -0700 Subject: [PATCH 0046/1238] Added missing options to IGridoptions Added missing options enableGridMenu and useExternalFiltering. --- ui-grid/ui-grid.d.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ui-grid/ui-grid.d.ts b/ui-grid/ui-grid.d.ts index ece964280f..47a2452f8b 100644 --- a/ui-grid/ui-grid.d.ts +++ b/ui-grid/ui-grid.d.ts @@ -600,6 +600,13 @@ declare module uiGrid { * @default false */ enableFiltering?: boolean; + /** + * False by default. When enabled, this adds a settings icon in the top right of the grid, + * which floats above the column header. The menu by default gives access to show/hide columns, + * but can be customized to show additional actions. + * @default false + */ + enableGridMenu?: boolean; /** * uiGridConstants.scrollbars.ALWAYS by default. This settings controls the horizontal scrollbar for the grid. * Supported values: uiGridConstants.scrollbars.ALWAYS, uiGridConstants.scrollbars.NEVER @@ -791,6 +798,12 @@ declare module uiGrid { * @default 20 */ virtualizationThreshold?: number; + /** + * Disables client side filtering. When true, handle the filterChanged event and set data, + * defaults to false + * @default false + */ + useExternalFiltering?: boolean; /** * Default time in milliseconds to throttle scroll events to, defaults to 70ms * @default 70 From 16d09d28c0ee49edc10be758bbc2da35bdff4e71 Mon Sep 17 00:00:00 2001 From: ibrahimuludag Date: Fri, 9 Oct 2015 14:58:12 +0300 Subject: [PATCH 0047/1238] Update knockout.d.ts Added after? option to KnockoutBindingHandler --- knockout/knockout.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/knockout/knockout.d.ts b/knockout/knockout.d.ts index edb510b6db..c2020c418e 100644 --- a/knockout/knockout.d.ts +++ b/knockout/knockout.d.ts @@ -142,6 +142,7 @@ interface KnockoutAllBindingsAccessor { } interface KnockoutBindingHandler { + after?: Array; init?: (element: any, valueAccessor: () => any, allBindingsAccessor?: KnockoutAllBindingsAccessor, viewModel?: any, bindingContext?: KnockoutBindingContext) => void | { controlsDescendantBindings: boolean; }; update?: (element: any, valueAccessor: () => any, allBindingsAccessor?: KnockoutAllBindingsAccessor, viewModel?: any, bindingContext?: KnockoutBindingContext) => void; options?: any; From d1575654c1aa8929b1b5569c4d7c5b32477a27e4 Mon Sep 17 00:00:00 2001 From: Anton Fomin Date: Sat, 10 Oct 2015 09:25:54 +0200 Subject: [PATCH 0048/1238] Update react-dom.d.ts It wasn't usable. import React = require("react"); import ReactDOM = require("react-dom"); // console.log(form.ContactForm); ReactDOM.render(React.createElement(form.ContactForm), document.getElementById("four")); Compilation error error TS2339: Property 'render' does not exist on type 'typeof __ReactDom'. --- react-dom/react-dom.d.ts | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/react-dom/react-dom.d.ts b/react-dom/react-dom.d.ts index 16ded77d85..1351fa02ed 100644 --- a/react-dom/react-dom.d.ts +++ b/react-dom/react-dom.d.ts @@ -5,36 +5,36 @@ /// -declare class __ReactDom { - public render

( +declare namespace __ReactDom { + function render

( element: __React.DOMElement

, container: Element, callback?: () => any): __React.DOMComponent

; - public render( + function render( element: __React.ClassicElement

, container: Element, callback?: () => any): __React.ClassicComponent; - public render( + function render( element: __React.ReactElement

, container: Element, callback?: () => any): __React.Component; - public findDOMNode( + function findDOMNode( componentOrElement: __React.Component | Element): TElement; - public findDOMNode( + function findDOMNode( componentOrElement: __React.Component | Element): Element; - public unmountComponentAtNode(container: Element): boolean; + function unmountComponentAtNode(container: Element): boolean; } -declare class __ReactDomServer { - public renderToString(element: __React.ReactElement): string; - public renderToStaticMarkup(element: __React.ReactElement): string; +declare namespace __ReactDomServer { + function renderToString(element: __React.ReactElement): string; + function renderToStaticMarkup(element: __React.ReactElement): string; } declare module "react-dom" { - export = __ReactDom + export = __ReactDom } declare module "react-dom/server" { - export = __ReactDomServer -} \ No newline at end of file + export = __ReactDomServer +} From 05b17e447eea3f7ea6c3fcaca752b0316e7cd28d Mon Sep 17 00:00:00 2001 From: Jan Bevers Date: Mon, 12 Oct 2015 13:58:51 +0200 Subject: [PATCH 0049/1238] jQuery : updated "not" elements param to be an array (was incorrectly using a spread operator) --- jquery/jquery-tests.ts | 4 ++++ jquery/jquery.d.ts | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/jquery/jquery-tests.ts b/jquery/jquery-tests.ts index 0ba33c193d..62cd273f4d 100644 --- a/jquery/jquery-tests.ts +++ b/jquery/jquery-tests.ts @@ -3217,6 +3217,10 @@ function test_not() { $("p").not("#selected"); $("p").not($("div p.selected")); + + var el1 = $("

")[0]; + var el2 = $("
")[0]; + $("p").not([el1, el2]); } function test_EventIsNewable() { diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index 5beb4e4af6..aa89a8fe6c 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -3050,7 +3050,7 @@ interface JQuery { * * @param elements One or more DOM elements to remove from the matched set. */ - not(...elements: Element[]): JQuery; + not(elements: Element[]): JQuery; /** * Remove elements from the set of matched elements. * From a5e51041afe166d2a736f88a7f5d281b9649ba5e Mon Sep 17 00:00:00 2001 From: Jan Bevers Date: Mon, 12 Oct 2015 15:07:14 +0200 Subject: [PATCH 0050/1238] jQuery : updated "not" elements param to be an element or array of element --- jquery/jquery.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index aa89a8fe6c..8401753e35 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -3050,7 +3050,7 @@ interface JQuery { * * @param elements One or more DOM elements to remove from the matched set. */ - not(elements: Element[]): JQuery; + not(elements: Element|Element[]): JQuery; /** * Remove elements from the set of matched elements. * From de3b92a51fcf654881cab1f7e5409d685df09c01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Bourgeois?= Date: Wed, 7 Oct 2015 22:46:56 +0200 Subject: [PATCH 0051/1238] Knockout KnockoutUtils cleanup. Over the time bindings over properties not exposed inside minified versions of knockout have made their way into the definitions. --- knockout/knockout.d.ts | 146 +++++++++++++++++------------------------ 1 file changed, 60 insertions(+), 86 deletions(-) diff --git a/knockout/knockout.d.ts b/knockout/knockout.d.ts index f4ad8766e2..bee7041dee 100644 --- a/knockout/knockout.d.ts +++ b/knockout/knockout.d.ts @@ -6,7 +6,7 @@ interface KnockoutSubscribableFunctions { [key: string]: KnockoutBindingHandler; - + notifySubscribers(valueToWrite?: T, event?: string): void; } @@ -16,7 +16,7 @@ interface KnockoutComputedFunctions { interface KnockoutObservableFunctions { [key: string]: KnockoutBindingHandler; - + equalityComparer(a: any, b: any): boolean; } @@ -36,7 +36,7 @@ interface KnockoutObservableArrayFunctions { // Ko specific [key: string]: KnockoutBindingHandler; - + replace(oldItem: T, newItem: T): void; remove(item: T): T[]; @@ -77,7 +77,7 @@ interface KnockoutComputedStatic { interface KnockoutComputed extends KnockoutObservable, KnockoutComputedFunctions { fn: KnockoutComputedFunctions; - + dispose(): void; isActive(): boolean; getDependenciesCount(): number; @@ -216,22 +216,12 @@ interface KnockoutExtenders { trackArrayChanges(target: any): any; } +// +// NOTE TO MAINTAINERS AND CONTRIBUTORS : pay attention to only include symbols that are +// publicly exported in the minified version of ko, without that you can give the false +// impression that some functions will be available in production builds. +// interface KnockoutUtils { - - ////////////////////////////////// - // utils.domManipulation.js - ////////////////////////////////// - - simpleHtmlParse(html: string): any[]; - - jQueryHtmlParse(html: string): any[]; - - parseHtmlFragment(html: string): any[]; - - setHtml(node: Element, html: string): void; - - setHtml(node: Element, html: () => string): void; - ////////////////////////////////// // utils.domData.js ////////////////////////////////// @@ -260,93 +250,77 @@ interface KnockoutUtils { removeNode(node: Node): void; }; - ////////////////////////////////// - // utils.js - ////////////////////////////////// - - fieldsIncludedWithJsonPost: any[]; - - compareArrays(a: T[], b: T[]): Array>; - - arrayForEach(array: T[], action: (item: T, index: number) => void): void; - - arrayIndexOf(array: T[], item: T): number; - - arrayFirst(array: T[], predicate: (item: T) => boolean, predicateOwner?: any): T; - - arrayRemoveItem(array: any[], itemToRemove: any): void; - - arrayGetDistinctValues(array: T[]): T[]; - - arrayMap(array: T[], mapping: (item: T) => U): U[]; + addOrRemoveItem(array: T[] | KnockoutObservable, value: T, included: T): void; arrayFilter(array: T[], predicate: (item: T) => boolean): T[]; + arrayFirst(array: T[], predicate: (item: T) => boolean, predicateOwner?: any): T; + + arrayForEach(array: T[], action: (item: T, index: number) => void): void; + + arrayGetDistinctValues(array: T[]): T[]; + + arrayIndexOf(array: T[], item: T): number; + + arrayMap(array: T[], mapping: (item: T) => U): U[]; + arrayPushAll(array: T[] | KnockoutObservableArray, valuesToPush: T[]): T[]; + arrayRemoveItem(array: any[], itemToRemove: any): void; + + compareArrays(a: T[], b: T[]): Array>; + extend(target: Object, source: Object): Object; - moveCleanedNodesToContainerElement(nodes: any[]): HTMLElement; + fieldsIncludedWithJsonPost: any[]; - cloneNodes(nodesArray: any[], shouldCleanNodes: boolean): any[]; + getFormFields(form: any, fieldName: string): any[]; - setDomNodeChildren(domNode: any, childNodes: any[]): void; + objectForEach(obj: any, action: (key: any, value: any) => void): void; - replaceDomNodes(nodeToReplaceOrNodeArray: any, newNodesArray: any[]): void; + parseHtmlFragment(html: string): any[]; - setOptionNodeSelectionState(optionNode: any, isSelected: boolean): void; + parseJson(jsonString: string): any; - stringTrim(str: string): string; + postJson(urlOrForm: any, data: any, options: any): void; - stringTokenize(str: string, delimiter: string): string[]; + peekObservable(value: KnockoutObservable): T; - stringStartsWith(str: string, startsWith: string): boolean; - - domNodeIsContainedBy(node: any, containedByNode: any): boolean; - - domNodeIsAttachedToDocument(node: any): boolean; - - tagNameLower(element: any): string; + range(min: any, max: any): any; registerEventHandler(element: any, eventType: any, handler: Function): void; + setHtml(node: Element, html: () => string): void; + + setHtml(node: Element, html: string): void; + + setTextContent(element: any, textContent: string | KnockoutObservable): void; + + stringifyJson(data: any, replacer?: Function, space?: string): string; + + toggleDomNodeCssClass(node: any, className: string, shouldHaveClass: boolean): void; + triggerEvent(element: any, eventType: any): void; unwrapObservable(value: KnockoutObservable | T): T; - peekObservable(value: KnockoutObservable): T; - - toggleDomNodeCssClass(node: any, className: string, shouldHaveClass: boolean): void; - - setTextContent(element: any, textContent: string | KnockoutObservable): void; // IT's PART OF THE MINIFIED API SURFACE https://github.com/knockout/knockout/blob/master/src/utils.js#L599 - - setElementName(element: any, name: string): void; - - forceRefresh(node: any): void; - - ensureSelectElementIsRenderedCorrectly(selectElement: any): void; - - range(min: any, max: any): any; - - makeArray(arrayLikeObject: any): any[]; - - getFormFields(form: any, fieldName: string): any[]; - - parseJson(jsonString: string): any; - - stringifyJson(data: any, replacer?: Function, space?: string): string; - - postJson(urlOrForm: any, data: any, options: any): void; - - ieVersion: number; - - isIe6: boolean; - - isIe7: boolean; - - objectForEach(obj: any, action: (key: any, value: any) => void): void; - - addOrRemoveItem(array: T[] | KnockoutObservable, value: T, included: T): void; + // NOT PART OF THE MINIFIED API SURFACE (ONLY IN knockout-{version}.debug.js) https://github.com/SteveSanderson/knockout/issues/670 + // forceRefresh(node: any): void; + // ieVersion: number; + // isIe6: boolean; + // isIe7: boolean; + // jQueryHtmlParse(html: string): any[]; + // makeArray(arrayLikeObject: any): any[]; + // moveCleanedNodesToContainerElement(nodes: any[]): HTMLElement; + // replaceDomNodes(nodeToReplaceOrNodeArray: any, newNodesArray: any[]): void; + // setDomNodeChildren(domNode: any, childNodes: any[]): void; + // setElementName(element: any, name: string): void; + // setOptionNodeSelectionState(optionNode: any, isSelected: boolean): void; + // simpleHtmlParse(html: string): any[]; + // stringStartsWith(str: string, startsWith: string): boolean; + // stringTokenize(str: string, delimiter: string): string[]; + // stringTrim(str: string): string; + // tagNameLower(element: any): string; } interface KnockoutArrayChange { @@ -575,7 +549,7 @@ interface KnockoutComputedContext { } // -// refactored types into a namespace to reduce global pollution +// refactored types into a namespace to reduce global pollution // and used Union Types to simplify overloads (requires TypeScript 1.4) // declare module KnockoutComponentTypes { From 2ae4b96283a813e22f25c13a70f577866ec2de94 Mon Sep 17 00:00:00 2001 From: Roger Chen Date: Mon, 12 Oct 2015 15:27:34 -0700 Subject: [PATCH 0052/1238] Change autoComplete to a string typing in React --- react/react.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react/react.d.ts b/react/react.d.ts index de8ba67327..ba86c4690b 100644 --- a/react/react.d.ts +++ b/react/react.d.ts @@ -427,7 +427,7 @@ declare namespace __React { allowTransparency?: boolean; alt?: string; async?: boolean; - autoComplete?: boolean; + autoComplete?: string; autoFocus?: boolean; autoPlay?: boolean; cellPadding?: number | string; From 1efa53d0d2f6a9281d4c5fbe0d069cdc453fb53a Mon Sep 17 00:00:00 2001 From: Cherry Ng Date: Sat, 10 Oct 2015 23:29:12 +0800 Subject: [PATCH 0053/1238] Add defs + tests for Bounce.js --- bounce.js/bounce-tests.ts | 77 +++++++++++++++++++++++++++++++++++++++ bounce.js/bounce.d.ts | 66 +++++++++++++++++++++++++++++++++ 2 files changed, 143 insertions(+) create mode 100644 bounce.js/bounce-tests.ts create mode 100644 bounce.js/bounce.d.ts diff --git a/bounce.js/bounce-tests.ts b/bounce.js/bounce-tests.ts new file mode 100644 index 0000000000..bd90bfe4c1 --- /dev/null +++ b/bounce.js/bounce-tests.ts @@ -0,0 +1,77 @@ +/// +/// + +import Bounce from 'bounce.js'; +import * as $ from 'jquery'; + +function test_chaining_transformations() { + var bounce = new Bounce(); + bounce + .scale({ + from: { x: 0, y: 0 }, + to: { x: 2, y: 2 }, + duration: 1000 + }) + .rotate({ + from: 0, + to: 360, + delay: 500 + }) + .translate({ + from: { x: 0, y: -100 }, + to: { x: 0, y: 0 }, + stiffness: 1, + bounces: 4 + }) + .skew({ + from: { x: 1, y: 0.8 }, + to: { x: 0.8, y: 1 }, + easing: 'bounce' + }); +} + +function test_serialization() { + var b1 = new Bounce(); + var serialized = b1.serialize(); + var b2 = new Bounce(); + b2.deserialize(serialized); +} + +function test_apply () { + var bounce = new Bounce(); + var element = document.createElement('div'); + bounce.applyTo(element); + bounce.applyTo([element]); + bounce.applyTo($('div')); + + var options = { + loop: true, + remove: true, + onComplete: () => {} + }; + bounce.applyTo(element, options); + bounce.applyTo([element], options); + bounce.applyTo($('div'), options); +} + +function test_apply_promise () { + var bounce = new Bounce(); + var element = document.createElement('div'); + bounce.applyTo($('div')).then(() => {}); + + var options = { + loop: true, + remove: true + }; + bounce.applyTo($('div')).then(() => {}); +} + +function test_define() { + var bounce = new Bounce(); + bounce.define('named-animation'); +} + +function test_remove() { + var bounce = new Bounce(); + bounce.remove(); +} diff --git a/bounce.js/bounce.d.ts b/bounce.js/bounce.d.ts new file mode 100644 index 0000000000..9ff7c3a088 --- /dev/null +++ b/bounce.js/bounce.d.ts @@ -0,0 +1,66 @@ +// Type definitions for Bounce.js v0.8.2 +// Project: http://github.com/tictail/bounce.js +// Definitions by: Cherry +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module 'bounce.js' { + export default Bounce + + interface Point2D { + x: number + y: number + } + + interface BounceOptions { + from: T + to: T + duration?: number + delay?: number + easing?: string + bounces?: number + stiffness?: number + } + + interface AnimationOptions { + loop?: boolean + remove?: boolean + onComplete?: () => void + } + + interface SerailizedComponent { + type: string + from: T + to: T + duration: number + delay: number + easing: string + bounces: number + stiffness: number + } + + class Bounce { + static FPS: number + static counter: number + + static isSupported(): boolean + + constructor(); + + scale(options: BounceOptions): Bounce + rotate(options: BounceOptions): Bounce + translate(options: BounceOptions): Bounce + skew(options: BounceOptions): Bounce + + serialize(): SerailizedComponent[] + deserialize(serailized: SerailizedComponent[]): Bounce + + applyTo(element: Element, options?: AnimationOptions): void + applyTo(elements: Element[], options?: AnimationOptions): void + applyTo(elements: JQuery, options?: AnimationOptions): JQueryPromise + + define(name: string): Bounce + remove(): void + } +} From 5fc7b22967d562c19a7155ac7d3f744a714eb8d5 Mon Sep 17 00:00:00 2001 From: Cherry Ng Date: Tue, 13 Oct 2015 07:39:21 +0800 Subject: [PATCH 0054/1238] Rename bounce.js to bounce --- {bounce.js => bounce}/bounce-tests.ts | 2 +- {bounce.js => bounce}/bounce.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename {bounce.js => bounce}/bounce-tests.ts (98%) rename {bounce.js => bounce}/bounce.d.ts (98%) diff --git a/bounce.js/bounce-tests.ts b/bounce/bounce-tests.ts similarity index 98% rename from bounce.js/bounce-tests.ts rename to bounce/bounce-tests.ts index bd90bfe4c1..e8dd64d2b2 100644 --- a/bounce.js/bounce-tests.ts +++ b/bounce/bounce-tests.ts @@ -1,7 +1,7 @@ /// /// -import Bounce from 'bounce.js'; +import Bounce from 'bounce'; import * as $ from 'jquery'; function test_chaining_transformations() { diff --git a/bounce.js/bounce.d.ts b/bounce/bounce.d.ts similarity index 98% rename from bounce.js/bounce.d.ts rename to bounce/bounce.d.ts index 9ff7c3a088..562fa210f9 100644 --- a/bounce.js/bounce.d.ts +++ b/bounce/bounce.d.ts @@ -5,7 +5,7 @@ /// -declare module 'bounce.js' { +declare module 'bounce' { export default Bounce interface Point2D { From 7053dee09501ac08e2ba1c82dfdc60eacb8e7806 Mon Sep 17 00:00:00 2001 From: Cherry Ng Date: Tue, 13 Oct 2015 07:48:19 +0800 Subject: [PATCH 0055/1238] Fix module naming --- bounce/bounce-tests.ts | 2 +- bounce/bounce.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bounce/bounce-tests.ts b/bounce/bounce-tests.ts index e8dd64d2b2..bd90bfe4c1 100644 --- a/bounce/bounce-tests.ts +++ b/bounce/bounce-tests.ts @@ -1,7 +1,7 @@ /// /// -import Bounce from 'bounce'; +import Bounce from 'bounce.js'; import * as $ from 'jquery'; function test_chaining_transformations() { diff --git a/bounce/bounce.d.ts b/bounce/bounce.d.ts index 562fa210f9..9ff7c3a088 100644 --- a/bounce/bounce.d.ts +++ b/bounce/bounce.d.ts @@ -5,7 +5,7 @@ /// -declare module 'bounce' { +declare module 'bounce.js' { export default Bounce interface Point2D { From 4a18823cc7eb4b6b3f00a92129fce3268cc42f59 Mon Sep 17 00:00:00 2001 From: Dominic Alie Date: Tue, 13 Oct 2015 16:03:07 -0400 Subject: [PATCH 0056/1238] Leaflet.Editable type definitions --- leaflet-editable/leaflet-editable-tests.ts | 1 + leaflet-editable/leaflet-editable.d.ts | 256 +++++++++++++++++++++ 2 files changed, 257 insertions(+) create mode 100644 leaflet-editable/leaflet-editable-tests.ts create mode 100644 leaflet-editable/leaflet-editable.d.ts diff --git a/leaflet-editable/leaflet-editable-tests.ts b/leaflet-editable/leaflet-editable-tests.ts new file mode 100644 index 0000000000..ebb90cc972 --- /dev/null +++ b/leaflet-editable/leaflet-editable-tests.ts @@ -0,0 +1 @@ +/// \ No newline at end of file diff --git a/leaflet-editable/leaflet-editable.d.ts b/leaflet-editable/leaflet-editable.d.ts new file mode 100644 index 0000000000..663cd7573c --- /dev/null +++ b/leaflet-editable/leaflet-editable.d.ts @@ -0,0 +1,256 @@ +// Type definitions for Leaflet.Editable 0.7 +// Project: https://github.com/yohanboniface/Leaflet.Editable +// Definitions by: Dominic Alie +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module L { + /** + * Make geometries editable in Leaflet. + * + * This is not a plug and play UI, and will not. This is a minimal, lightweight, and fully extendable API to + * control editing of geometries. So you can easily build your own UI with your own needs and choices. + */ + export interface EditableStatic { + new (map: Map, options: EditOptions): Editable; + } + + /** + * Options to pass to L.Editable when instanciating. + */ + export interface EditOptions { + /** + * Class to be used when creating a new Polyline. + */ + polylineClass?: Object; + + /** + * Class to be used when creating a new Polygon. + */ + polygonClass?: Object; + + /** + * Class to be used when creating a new Marker. + */ + markerClass?: Object; + + /** + * CSS class to be added to the map container while drawing. + */ + drawingCSSClass?: string; + + /** + * Layer used to store edit tools (vertex, line guide…). + */ + editLayer?: L.LayerGroup; + + /** + * Default layer used to store drawn features (marker, polyline…). + */ + featuresLayer?: L.LayerGroup; + + /** + * Class to be used as vertex, for path editing. + */ + vertexMarkerClass?: Object; + + /** + * Class to be used as middle vertex, pulled by the user to create a new point in the middle of a path. + */ + middleMarkerClass?: Object; + + /** + * Class to be used as Polyline editor. + */ + polylineEditorClass?: Object; + + /** + * Class to be used as Polygon editor. + */ + polygonEditorClass?: Object; + + /** + * Class to be used as Marker editor. + */ + markerEditorClass?: Object; + + /** + * Options to be passed to the line guides. + */ + lineGuideOptions?: Object; + + /** + * Set this to true if you don't want middle markers. + */ + skipMiddleMarkers?: boolean; + } + + /** + * Make geometries editable in Leaflet. + * + * This is not a plug and play UI, and will not. This is a minimal, lightweight, and fully extendable API to + * control editing of geometries. So you can easily build your own UI with your own needs and choices. + */ + export interface Editable extends Mixin.LeafletMixinEvents { + /** + * Options to pass to L.Editable when instanciating. + */ + options: EditOptions; + + currentPolygon: Polyline|Polygon|Marker; + + /** + * Start drawing a polyline. If latlng is given, a first point will be added. In any case, continuing on user + * click. If options is given, it will be passed to the polyline class constructor. + */ + startPolyline(latLng?: LatLng, options?: L.PolylineOptions): L.Polyline; + + /** + * Start drawing a polygon. If latlng is given, a first point will be added. In any case, continuing on user + * click. If options is given, it will be passed to the polygon class constructor. + */ + startPolygon(latLng?: LatLng, options?: L.PolylineOptions): L.Polygon; + + /** + * Start adding a marker. If latlng is given, the marker will be shown first at this point. In any case, it + * will follow the user mouse, and will have a final latlng on next click (or touch). If options is given, + * it will be passed to the marker class constructor. + */ + startMarker(latLng?: LatLng, options?: L.MarkerOptions): L.Marker; + + /** + * When you need to stop any ongoing drawing, without needing to know which editor is active. + */ + stopDrawing(): void; + } + + export var Editable: EditableStatic; + + /** + * EditableMixin is included to L.Polyline, L.Polygon and L.Marker. It adds the following methods to them. + * + * When editing is enabled, the editor is accessible on the instance with the editor property. + */ + export interface EditableMixin { + /** + * Enable editing, by creating an editor if not existing, and then calling enable on it. + */ + enableEdit(): any; + + /** + * Disable editing, also remove the editor property reference. + */ + disableEdit(): void; + + /** + * Enable or disable editing, according to current status. + */ + toggleEdit(): void; + + /** + * Return true if current instance has an editor attached, and this editor is enabled. + */ + editEnabled(): boolean; + } + + export interface Map { + /** + * Whether to create a L.Editable instance at map init or not. + */ + editable: boolean; + + /** + * Options to pass to L.Editable when instanciating. + */ + editOptions: EditOptions; + + /** + * L.Editable plugin instance. + */ + editTools: Editable; + } + + export interface Polyline extends EditableMixin { + } + + export interface MapOptions { + /** + * Whether to create a L.Editable instance at map init or not. + */ + editable?: boolean; + + /** + * Options to pass to L.Editable when instanciating. + */ + editOptions?: EditOptions; + } + + /** + * When editing a feature (marker, polyline…), an editor is attached to it. This editor basically knows + * how to handle the edition. + */ + export interface BaseEditor { + /** + * Set up the drawing tools for the feature to be editable. + */ + enable(): MarkerEditor|PolylineEditor|PolygonEditor; + + /** + * Remove editing tools. + */ + disable(): MarkerEditor|PolylineEditor|PolygonEditor; + } + + /** + * Inherit from L.Editable.BaseEditor. + * Inherited by L.Editable.PolylineEditor and L.Editable.PolygonEditor. + */ + export interface PathEditor extends BaseEditor { + /** + * Rebuild edit elements (vertex, middlemarker, etc.). + */ + reset(): void; + } + + /** + * Inherit from L.Editable.PathEditor. + */ + export interface PolylineEditor extends PathEditor { + /** + * Set up drawing tools to continue the line forward. + */ + continueForward(): void; + + /** + * Set up drawing tools to continue the line backward. + */ + continueBackward(): void; + } + + /** + * Inherit from L.Editable.PathEditor. + */ + export interface PolygonEditor extends PathEditor { + /** + * Set up drawing tools for creating a new hole on the polygon. If the latlng param is given, a first + * point is created. + */ + newHole(latlng: LatLng): void; + } + + /** + * Inherit from L.Editable.BaseEditor. + */ + export interface MarkerEditor extends BaseEditor { + } + + export interface Marker extends EditableMixin, MarkerEditor { + } + + export interface Polyline extends EditableMixin, PolylineEditor { + } + + export interface Polygon extends EditableMixin, PolygonEditor { + } +} \ No newline at end of file From 8be1e783befd89f43cf62907dab718a9a33a18d9 Mon Sep 17 00:00:00 2001 From: Jared Klopper Date: Wed, 14 Oct 2015 13:39:09 +1300 Subject: [PATCH 0057/1238] Add object parsing overload to moment setter --- moment/moment-node.d.ts | 3 ++- moment/moment-tests.ts | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/moment/moment-node.d.ts b/moment/moment-node.d.ts index 93be9f6d44..9490d0320c 100644 --- a/moment/moment-node.d.ts +++ b/moment/moment-node.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Moment.js 2.8.0 +// Type definitions for Moment.js 2.10.6 // Project: https://github.com/timrwood/moment // Definitions by: Michael Lakerveld , Aaron King , Hiroki Horiuchi , Dick van den Brink , Adi Dahiya , Matt Brooks // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -303,6 +303,7 @@ declare module moment { get(unit: string): number; set(unit: string, value: number): Moment; + set(input: MomentInput): Moment; } type formatFunction = () => string; diff --git a/moment/moment-tests.ts b/moment/moment-tests.ts index 29712c1156..28fedc65e2 100644 --- a/moment/moment-tests.ts +++ b/moment/moment-tests.ts @@ -127,6 +127,15 @@ moment().isoWeeks(45); moment().dayOfYear(); moment().dayOfYear(45); +moment().set('year', 2013); +moment().set('month', 3); // April +moment().set('date', 1); +moment().set('hour', 13); +moment().set('minute', 20); +moment().set('second', 30); +moment().set('millisecond', 123); +moment().set({'year': 2013, 'month': 3}); + var getMilliseconds: number = moment().milliseconds(); var getSeconds: number = moment().seconds(); var getMinutes: number = moment().minutes(); From 3e7df0c95a5136d899c977d019744d3e5efbfe97 Mon Sep 17 00:00:00 2001 From: hamza zia Date: Wed, 14 Oct 2015 13:48:59 +0800 Subject: [PATCH 0058/1238] added rethink promise API --- rethinkdb/rethinkdb-tests.ts | 24 +++++++++++++++++++++--- rethinkdb/rethinkdb.d.ts | 15 ++++++++------- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/rethinkdb/rethinkdb-tests.ts b/rethinkdb/rethinkdb-tests.ts index e94e5271cf..a6911e3021 100644 --- a/rethinkdb/rethinkdb-tests.ts +++ b/rethinkdb/rethinkdb-tests.ts @@ -7,9 +7,9 @@ r.connect({host:"localhost", port: 28015}, function(err, conn) { var testDb = r.db('test') testDb.tableCreate('users').run(conn, function(err, stuff) { var users = testDb.table('users') - + users.insert({name: "bob"}).run(conn, function() {}) - + users.filter(function(doc?) { return doc("henry").eq("bob") }) @@ -19,6 +19,24 @@ r.connect({host:"localhost", port: 28015}, function(err, conn) { }) + }) +}) + +// use promises instead of callbacks +r.connect({host:"localhost", port: 28015}).then(function(conn) { + console.log("HI", conn) + var testDb = r.db('test') + testDb.tableCreate('users').run(conn).then(function(stuff) { + var users = testDb.table('users') + + users.insert({name: "bob"}).run(conn, function() {}) + + users.filter(function(doc?) { + return doc("henry").eq("bob") + }) + .between("james", "beth") + .limit(4) + .run(conn); }) -}) \ No newline at end of file +}) diff --git a/rethinkdb/rethinkdb.d.ts b/rethinkdb/rethinkdb.d.ts index 2c65a7cf4d..22b721b9a1 100644 --- a/rethinkdb/rethinkdb.d.ts +++ b/rethinkdb/rethinkdb.d.ts @@ -4,10 +4,11 @@ // Definitions: https://github.com/borisyankov/DefinitelyTyped // Reference: http://www.rethinkdb.com/api/#js // TODO: Document manipulation and below +/// declare module "rethinkdb" { - export function connect(host:ConnectionOptions, cb:(err:Error, conn:Connection)=>void); + export function connect(host:ConnectionOptions, cb?:(err:Error, conn:Connection)=>void):Promise; export function dbCreate(name:string):Operation; export function dbDrop(name:string):Operation; @@ -50,7 +51,7 @@ declare module "rethinkdb" { interface Connection { close(); - reconnect(cb:(err:Error, conn:Connection)=>void); + reconnect(cb?:(err:Error, conn:Connection)=>void):Promise; use(dbName:string); addListener(event:string, cb:Function); on(event:string, cb:Function); @@ -139,11 +140,11 @@ declare module "rethinkdb" { } interface ExpressionFunction { - (doc:Expression):Expression; + (doc:Expression):Expression; } interface JoinFunction { - (left:Expression, right:Expression):Expression; + (left:Expression, right:Expression):Expression; } interface ReduceFunction { @@ -159,7 +160,7 @@ declare module "rethinkdb" { interface UpdateOptions { non_atomic: boolean; durability: string; // 'soft' - return_vals: boolean; // false + return_vals: boolean; // false } interface WriteResult { @@ -193,7 +194,7 @@ declare module "rethinkdb" { } interface Expression extends Writeable, Operation { - (prop:string):Expression; + (prop:string):Expression; merge(query:Expression):Expression; append(prop:string):Expression; contains(prop:string):Expression; @@ -221,7 +222,7 @@ declare module "rethinkdb" { } interface Operation { - run(conn:Connection, cb:(err:Error, result:T)=>void); + run(conn:Connection, cb?:(err:Error, result:T)=>void):Promise; } interface Aggregator {} From d5e0dcb4c74fb6bef454898238c68fb96e53ddc3 Mon Sep 17 00:00:00 2001 From: Kopleman Date: Wed, 14 Oct 2015 09:45:23 +0300 Subject: [PATCH 0059/1238] Updating angilar-ui-router.d.ts. Adding missed cache?:boolean to IState interaface --- angular-ui-router/angular-ui-router.d.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/angular-ui-router/angular-ui-router.d.ts b/angular-ui-router/angular-ui-router.d.ts index 3ec31968cd..1164079e7d 100644 --- a/angular-ui-router/angular-ui-router.d.ts +++ b/angular-ui-router/angular-ui-router.d.ts @@ -71,10 +71,16 @@ declare module angular.ui { * Arbitrary data object, useful for custom configuration. */ data?: any; + /** * Boolean (default true). If false will not re-trigger the same state just because a search/query parameter has changed. Useful for when you'd like to modify $location.search() without triggering a reload. */ reloadOnSearch?: boolean; + + /** + * Boolean (default true). If false will reload state on everytransitions. Useful for when you'd like to restore all data to its initial state. + */ + cache?: boolean; } interface IStateProvider extends angular.IServiceProvider { From f13c1b1248ebeee0f8ac239e5478a076803d6444 Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Wed, 14 Oct 2015 10:45:11 +0200 Subject: [PATCH 0060/1238] denodeify --- denodeify/denodeify-tests.ts | 10 ++++++++++ denodeify/denodeify.d.ts | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 denodeify/denodeify-tests.ts create mode 100644 denodeify/denodeify.d.ts diff --git a/denodeify/denodeify-tests.ts b/denodeify/denodeify-tests.ts new file mode 100644 index 0000000000..0cd6a0c988 --- /dev/null +++ b/denodeify/denodeify-tests.ts @@ -0,0 +1,10 @@ +/// +/// +/// + +import denodeify = require("denodeify"); +import fs = require('fs'); +import cp = require('child_process'); + +const readFile = denodeify(fs.readFile); +const exec = denodeify(cp.exec, (err, stdout, stderr) => [err, stdout]); \ No newline at end of file diff --git a/denodeify/denodeify.d.ts b/denodeify/denodeify.d.ts new file mode 100644 index 0000000000..fec2fbf3cc --- /dev/null +++ b/denodeify/denodeify.d.ts @@ -0,0 +1,36 @@ +// Type definitions for denodeify 1.2.1 +// Project: https://github.com/matthew-andrews/denodeify +// Definitions by: joaomoreno +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "denodeify" { + function _(fn: _.F0, transformer?: _.M): () => Promise; + function _(fn: _.F1, transformer?: _.M): (a:A) => Promise; + function _(fn: _.F2, transformer?: _.M): (a:A, b:B) => Promise; + function _(fn: _.F3, transformer?: _.M): (a:A, b:B, c:C) => Promise; + function _(fn: _.F4, transformer?: _.M): (a:A, b:B, c:C, d:D) => Promise; + function _(fn: _.F5, transformer?: _.M): (a:A, b:B, c:C, d:D, e:E) => Promise; + function _(fn: _.F6, transformer?: _.M): (a:A, b:B, c:C, d:D, e:E, f:F) => Promise; + function _(fn: _.F7, transformer?: _.M): (a:A, b:B, c:C, d:D, e:E, f:F, g:G) => Promise; + function _(fn: _.F8, transformer?: _.M): (a:A, b:B, c:C, d:D, e:E, f:F, g:G, h:H) => Promise; + function _(fn: _.F, transformer?: _.M): (...args: any[]) => Promise; + + module _ { + type Callback = (err: Error, result: R) => any; + type F0 = (cb: Callback) => any; + type F1 = (a:A, cb: Callback) => any; + type F2 = (a:A, b:B, cb: Callback) => any; + type F3 = (a:A, b:B, c:C, cb: Callback) => any; + type F4 = (a:A, b:B, c:C, d:D, cb: Callback) => any; + type F5 = (a:A, b:B, c:C, d:D, e:E, cb: Callback) => any; + type F6 = (a:A, b:B, c:C, d:D, e:E, f:F, cb: Callback) => any; + type F7 = (a:A, b:B, c:C, d:D, e:E, f:F, g:G, cb: Callback) => any; + type F8 = (a:A, b:B, c:C, d:D, e:E, f:F, g:G, h:H, cb: Callback) => any; + type F = (...args: any[]) => any; + type M = (err: Error, ...args: any[]) => any[]; + } + + export = _; +} \ No newline at end of file From 96d71628078c65c92d1ed4b782b723919678d91f Mon Sep 17 00:00:00 2001 From: Abubaker Bashir Date: Wed, 14 Oct 2015 12:33:11 +0100 Subject: [PATCH 0061/1238] Added config singleton and missing properties Added - CKEDITOR.config : singleton ([doc link](http://docs.ckeditor.com/#!/api/CKEDITOR.config)) - config.contentsCss - string or string array ([doc link](http://docs.ckeditor.com/#!/api/CKEDITOR.config)) - customConfig - string ([doc link](http://docs.ckeditor.com/#!/api/CKEDITOR.config)) --- ckeditor/ckeditor.d.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ckeditor/ckeditor.d.ts b/ckeditor/ckeditor.d.ts index a8f2680742..cab51f72c0 100644 --- a/ckeditor/ckeditor.d.ts +++ b/ckeditor/ckeditor.d.ts @@ -64,6 +64,7 @@ declare module CKEDITOR { var status: string; var timestamp: string; var version: string; + var config: config; // Methods @@ -556,6 +557,7 @@ declare module CKEDITOR { } interface config { + contentsCss?: string | string[]; startupMode?: string; removeButtons?: string; removePlugins?: string; @@ -576,6 +578,7 @@ declare module CKEDITOR { height?: string | number; toolbarLocation?: string; readOnly?: boolean; + customConfig?: string; } From 7283a45802e9f7d79c88c571ec013a9d982f7202 Mon Sep 17 00:00:00 2001 From: vvakame Date: Wed, 14 Oct 2015 21:11:50 +0900 Subject: [PATCH 0062/1238] add glob-expand --- glob-expand/glob-expand-tests.ts | 22 ++++++++++++++++++++++ glob-expand/glob-expand.d.ts | 27 +++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 glob-expand/glob-expand-tests.ts create mode 100644 glob-expand/glob-expand.d.ts diff --git a/glob-expand/glob-expand-tests.ts b/glob-expand/glob-expand-tests.ts new file mode 100644 index 0000000000..fc17e5fea9 --- /dev/null +++ b/glob-expand/glob-expand-tests.ts @@ -0,0 +1,22 @@ +/// + +import * as expand from "glob-expand"; + +expand({ filter: 'isFile', cwd: '../' }, ['**/*.*', '!exclude/these/**/*.*']); +// returns all files in cwd ['file1', 'file2',...] but excluding +// those under directory 'exclude/these' + +// These are the same +expand({ cwd: '../..' }, ['**/*.*', '!node_modules/**/*.*']); +expand({ cwd: '../..' }, '**/*.*', '!node_modules/**/*.*'); + +// These are the same too: +expand({}, ['**/*.*', '!**/*.js']); +expand({}, '**/*.*', '!**/*.js'); +expand(['**/*.*', '!**/*.js']); +expand('**/*.*', '!**/*.js'); + +// Using Regular Expressions: +expand('**/*.js', /.*\.(coffee\.md|litcoffee|coffee)$/i, '!DRAFT*.*'); +// -> returns all `.js`, `.coffee`, `.coffee.md` & `.litcoffee` files, +// excluding those starting with 'DRAFT' diff --git a/glob-expand/glob-expand.d.ts b/glob-expand/glob-expand.d.ts new file mode 100644 index 0000000000..0e12582799 --- /dev/null +++ b/glob-expand/glob-expand.d.ts @@ -0,0 +1,27 @@ +// Type definitions for glob-expand +// Project: https://github.com/anodynos/node-glob-expand +// Definitions by: vvakame +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "glob-expand" { + import * as _glob from "glob"; + + interface Option { + filter?: string | ((filePath: string) => boolean); + cwd?: string; + } + + module expand { + var glob: typeof _glob; + var VERSION: string; + } + + function expand(opts: Option, patterns: (string | RegExp)[]): string[]; + function expand(opts: Option, ...patterns: (string | RegExp)[]): string[]; + function expand(patterns: (string | RegExp)[]): string[]; + function expand(...patterns: (string | RegExp)[]): string[]; + + export = expand; +} From 8dfd709683480bf87b3fa9ab92b0e2894cb70a3f Mon Sep 17 00:00:00 2001 From: abreits Date: Wed, 14 Oct 2015 14:33:16 +0200 Subject: [PATCH 0063/1238] amqplib: callback api definition and tests added --- amqplib/amqplib-tests.ts | 28 ++++++++ amqplib/amqplib.d.ts | 149 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 177 insertions(+) diff --git a/amqplib/amqplib-tests.ts b/amqplib/amqplib-tests.ts index 7a1f512002..cfb9adbe13 100644 --- a/amqplib/amqplib-tests.ts +++ b/amqplib/amqplib-tests.ts @@ -1,5 +1,6 @@ /// +// promise api tests import amqp = require("amqplib"); var msg = "Hello World"; @@ -19,3 +20,30 @@ amqp.connect("amqp://localhost") .then(channel => channel.consume("myQueue", newMsg => console.log("New Message: " + newMsg.content.toString()))) .ensure(() => connection.close()); }); + +// callback api tests +import amqpcb = require("amqplib/callback_api"); + +amqpcb.connect("amqp://localhost", (err, connection) => { + if(!err) { + connection.createChannel((err, channel) => { + if (!err) { + channel.assertQueue("myQueue", (err, ok) => { + channel.sendToQueue("myQueue", new Buffer(msg)); + }); + } + }); + } +}); + +amqpcb.connect("amqp://localhost", (err, connection) => { + if(!err) { + connection.createChannel((err, channel) => { + if (!err) { + channel.assertQueue("myQueue", (err, ok) => { + channel.consume("myQueue", newMsg => console.log("New Message: " + newMsg.content.toString())); + }); + } + }); + } +}); diff --git a/amqplib/amqplib.d.ts b/amqplib/amqplib.d.ts index 0c7f0720a6..c6f73feefe 100644 --- a/amqplib/amqplib.d.ts +++ b/amqplib/amqplib.d.ts @@ -1,6 +1,7 @@ // Type definitions for amqplib 0.3.x // Project: https://github.com/squaremo/amqp.node // Definitions by: Michael Nahkies +// Definitions for callback api added by: Ab Reitsma // Definitions: https://github.com/borisyankov/DefinitelyTyped /// @@ -142,3 +143,151 @@ declare module "amqplib" { function connect(url: string, socketOptions?: any): when.Promise; } + +declare module "amqplib/callback_api" { + + import events = require("events"); + + interface Connection extends events.EventEmitter { + close(callback?: (err: any) => void); + createChannel(callback: (err: any, channel: Channel) => void); + createConfirmChannel(callback: (err: any, confirmChannel: ConfirmChannel) => void); + } + + module Replies { + interface Empty { + } + interface AssertQueue { + queue: string; + messageCount: number; + consumerCount: number; + } + interface DeleteQueue { + messageCount: number; + } + interface PurgeQueue { + messageCount: number; + } + interface AssertExchange { + exchange: string; + } + interface Consume { + consumerTag: string; + } + } + + module Options { + interface AssertQueue { + exclusive?: boolean; + durable?: boolean; + autoDelete?: boolean; + arguments?: any; + messageTtl?: number; + expires?: number; + deadLetterExchange?: string; + maxLength?: number; + } + interface DeleteQueue { + ifUnused?: boolean; + ifEmpty?: boolean; + } + interface AssertExchange { + durable?: boolean; + internal?: boolean; + autoDelete?: boolean; + alternateExchange?: string; + arguments?: any; + } + interface DeleteExchange { + ifUnused?: boolean; + } + interface Publish { + expiration?: string; + userId?: string; + CC?: string | string[]; + + mandatory?: boolean; + persistent?: boolean; + deliveryMode?: boolean | number; + BCC?: string | string[]; + + contentType?: string; + contentEncoding?: string; + headers?: Object; + priority?: number; + correlationId?: string; + replyTo?: string; + messageId?: string; + timestamp?: number; + type?: string; + appId?: string; + } + interface Consume { + consumerTag?: string; + noLocal?: boolean; + noAck?: boolean; + exclusive?: boolean; + priority?: number; + arguments?: Object; + } + interface Get { + noAck?: boolean; + } + } + + interface Message { + content: Buffer; + fields: any; + properties: any; + } + + interface Channel extends events.EventEmitter { + close(callback: (err: any) => void); + + assertQueue(queue?: string, options?: Options.AssertQueue, callback?: (err:any, ok: Replies.AssertQueue) => void); + checkQueue(queue: string, callback?: (err: any, ok: Replies.AssertQueue) => void); + + deleteQueue(queue: string, options?: Options.DeleteQueue, callback?: (err:any, ok: Replies.DeleteQueue) => void); + purgeQueue(queue: string, callback?: (err:any, ok: Replies.PurgeQueue) => void); + + bindQueue(queue: string, source: string, pattern: string, args?: any, callback?: (err: any, ok: Replies.Empty) => void); + unbindQueue(queue: string, source: string, pattern: string, args?: any, callback?: (err: any, ok: Replies.Empty) => void); + + assertExchange(exchange: string, type: string, options?: Options.AssertExchange, callback?: (err: any, ok: Replies.AssertExchange) => void); + checkExchange(exchange: string, callback?: (err: any, ok: Replies.Empty) => void); + + deleteExchange(exchange: string, options?: Options.DeleteExchange, callback?: (err: any, ok: Replies.Empty) => void); + + bindExchange(destination: string, source: string, pattern: string, args?: any, callback?: (err: any, ok: Replies.Empty) => void); + unbindExchange(destination: string, source: string, pattern: string, args?: any, callback?: (err: any, ok: Replies.Empty) => void); + + publish(exchange: string, routingKey: string, content: Buffer, options?: Options.Publish): boolean; + sendToQueue(queue: string, content: Buffer, options?: Options.Publish): boolean; + + consume(queue: string, onMessage: (msg: Message) => any, options?: Options.Consume, callback?: (err: any, ok: Replies.Consume) => void); + + cancel(consumerTag: string, callback?: (err: any, ok: Replies.Empty) => void); + get(queue: string, options?: Options.Get, callback?: (err: any, ok: Message | boolean) => void); + + ack(message: Message, allUpTo?: boolean): void; + ackAll(): void; + + nack(message: Message, allUpTo?: boolean, requeue?: boolean): void; + nackAll(requeue?: boolean): void; + reject(message: Message, requeue?: boolean): void; + + prefetch(count: number, global?: boolean); + recover(callback?: (err: any, ok: Replies.Empty) => void); + } + + interface ConfirmChannel extends Channel { + publish(exchange: string, routingKey: string, content: Buffer, options?: Options.Publish, callback?: (err: any, ok: Replies.Empty) => void): boolean; + sendToQueue(queue: string, content: Buffer, options?: Options.Publish, callback?: (err: any, ok: Replies.Empty) => void): boolean; + + waitForConfirms(callback?: (err: any) => void); + } + + function connect(callback: (err: any, connection: Connection) => void); + function connect(url: string, callback: (err: any, connection: Connection) => void); + function connect(url: string, socketOptions: any, callback: (err: any, connection: Connection) => void); +} From da4f02bd35aaac24b62debfac86e054520191af4 Mon Sep 17 00:00:00 2001 From: Luigi Trabacchin Date: Wed, 14 Oct 2015 14:42:17 +0200 Subject: [PATCH 0064/1238] Typeahead: added missing options, and missing parameters, normalized some comments and code style --- typeahead/typeahead-tests.ts | 64 +++-- typeahead/typeahead.d.ts | 507 +++++++++++++++++------------------ 2 files changed, 281 insertions(+), 290 deletions(-) diff --git a/typeahead/typeahead-tests.ts b/typeahead/typeahead-tests.ts index 2bcb016c08..3864865c9f 100644 --- a/typeahead/typeahead-tests.ts +++ b/typeahead/typeahead-tests.ts @@ -6,14 +6,10 @@ // var substringMatcher = function (strs: any) { - return function findMatches(q: any, cb: any) { - var matches: any, substrRegex: any; - - // an array that will be populated with substring matches - matches = []; - + return function findMatches(q: string, syncResults: (x: any) => void) { + var matches: Array<{ value: string }> = []; // regex used to determine if a string contains the substring `q` - substrRegex = new RegExp(q, 'i'); + var substrRegex = new RegExp(q, 'i'); // iterate through the pool of strings and for any string that // contains the substring `q`, add it to the `matches` array @@ -25,7 +21,7 @@ var substringMatcher = function (strs: any) { } }); - cb(matches); + syncResults(matches); } } @@ -46,14 +42,14 @@ function test_method_names() { $('#the-basics .typeahead').typeahead('open'); $('#the-basics .typeahead').typeahead('close'); $('#the-basics .typeahead').typeahead('val'); - $('#the-basics .typeahead').typeahead('val', 'test value'); + $('#the-basics .typeahead').typeahead('val', 'test value'); } function test_options() { var dataSets: Twitter.Typeahead.Dataset[] = []; - + function with_empty_options() { $('#the-basics .typeahead').typeahead({}, dataSets); } @@ -72,10 +68,10 @@ function test_options() { function with_all_options() { $('#the-basics .typeahead').typeahead({ - hint: true, - highlight: true, - minLength: 1 - }, + hint: true, + highlight: true, + minLength: 1 + }, dataSets ); } @@ -101,33 +97,33 @@ function test_datasets_array() { function with_displayKey_option() { $('#the-basics .typeahead').typeahead(options, [{ - displayKey: 'value', - source: substringMatcher(states) - }] + displayKey: 'value', + source: substringMatcher(states) + }] ); } function with_templates_option() { $('#the-basics .typeahead').typeahead(options, [{ - templates: {}, - source: substringMatcher(states) - }] + templates: {}, + source: substringMatcher(states) + }] ); } function with_all_options() { $('#the-basics .typeahead').typeahead(options, [{ - name: 'states', - displayKey: 'value', - templates: {}, - source: substringMatcher(states) - }] + name: 'states', + displayKey: 'value', + templates: {}, + source: substringMatcher(states) + }] ); } function with_multiple_datasets() { $('#the-basics .typeahead').typeahead(options, [ - { + { name: 'states', displayKey: 'value', templates: {}, @@ -192,7 +188,7 @@ function test_datasets_objects() { } function with_multiple_objects() { - $('#the-basics .typeahead').typeahead(options, + $('#the-basics .typeahead').typeahead(options, { name: 'states', displayKey: 'value', @@ -231,7 +227,7 @@ function test_dataset_templates() { $('#the-basics .typeahead').typeahead(options, { source: substringMatcher(states), templates: { - empty: function(context: any) { + empty: function (context: any) { return context.name; } } @@ -249,7 +245,7 @@ function test_dataset_templates() { $('#the-basics .typeahead').typeahead(options, { source: substringMatcher(states), templates: { - footer: function(context: any) { + footer: function (context: any) { return context.name; } } @@ -267,7 +263,7 @@ function test_dataset_templates() { $('#the-basics .typeahead').typeahead(options, { source: substringMatcher(states), templates: { - header: function(context: any) { + header: function (context: any) { return context.name; } } @@ -277,8 +273,8 @@ function test_dataset_templates() { function with_suggestion_option() { $('#the-basics .typeahead').typeahead(options, { source: substringMatcher(states), - templates: { - suggestion: function(context) { + templates: { + suggestion: function (context) { return context.name; } } @@ -289,10 +285,10 @@ function test_dataset_templates() { $('#the-basics .typeahead').typeahead(options, { source: substringMatcher(states), templates: { - empty: 'no results', + empty: 'no results', footer: 'custom footer', header: 'custom header', - suggestion: function(context) { + suggestion: function (context) { return context.name; } } diff --git a/typeahead/typeahead.d.ts b/typeahead/typeahead.d.ts index a8b139937c..cde3a92771 100644 --- a/typeahead/typeahead.d.ts +++ b/typeahead/typeahead.d.ts @@ -10,19 +10,19 @@ interface JQuery { /** * Destroys previously initialized typeaheads. This entails reverting * DOM modifications and removing event handlers. - * - * @constructor + * + * @constructor * @param methodName Method 'destroy' - */ + */ typeahead(methodName: 'destroy'): JQuery; /** * Opens the dropdown menu of typeahead. Note that being open does not mean that the menu is visible. * The menu is only visible when it is open and has content. - * - * @constructor + * + * @constructor * @param methodName Method 'open' - */ + */ typeahead(methodName: 'open'): JQuery; /** @@ -36,10 +36,10 @@ interface JQuery { /** * Returns the current value of the typeahead. * The value is the text the user has entered into the input element. - * - * @constructor + * + * @constructor * @param methodName Method 'val' - */ + */ typeahead(methodName: 'val'): string; /** @@ -87,7 +87,7 @@ interface JQuery { * @param options ('hint' or 'highlight' or 'minLength' all of which are optional) * @param datasets One or more datasets passed in as arguments. */ - typeahead(options: Twitter.Typeahead.Options, ... datasets: Twitter.Typeahead.Dataset[]): JQuery; + typeahead(options: Twitter.Typeahead.Options, ...datasets: Twitter.Typeahead.Dataset[]): JQuery; } declare module Twitter.Typeahead { @@ -104,8 +104,8 @@ declare module Twitter.Typeahead { * It is expected that the function will compute the suggestion set (i.e. an array of JavaScript objects) for query and then invoke cb with said set. * cb can be invoked synchronously or asynchronously. * - */ - source: (query: string, cb: (result: any) => void) => void; + */ + source: ((query: string, syncResults: (result: any) => void, asyncResults?: (result: any) => void) => void); /** * The name of the dataset. @@ -125,32 +125,33 @@ declare module Twitter.Typeahead { /** * A hash of templates to be used when rendering the dataset. * Note a precompiled template is a function that takes a JavaScript object as its first argument and returns a HTML string. - */ + */ templates?: Templates; + async?: boolean; + display?: boolean | ((x: any) => boolean); } interface Templates { - /** * Rendered when 0 suggestions are available for the given query. * Can be either a HTML string or a precompiled template. * If it's a precompiled template, the passed in context will contain query - */ + */ empty?: any; /** * Rendered at the bottom of the dataset. * Can be either a HTML string or a precompiled template. * If it's a precompiled template, the passed in context will contain query and isEmpty. - */ + */ footer?: any; /** * Rendered at the top of the dataset. * Can be either a HTML string or a precompiled template. * If it's a precompiled template, the passed in context will contain query and isEmpty. - */ + */ header?: any; /** @@ -158,273 +159,267 @@ declare module Twitter.Typeahead { * If set, this has to be a precompiled template. * The associated suggestion object will serve as the context. * Defaults to the value of displayKey wrapped in a p tag i.e.

{{value}}

. - */ + */ suggestion?: (datum: any) => string; } - /** - * When initializing a typeahead, there are a number of options you can configure. - */ + /** + * When initializing a typeahead, there are a number of options you can configure. + */ interface Options { - /** - * highlight: If true, when suggestions are rendered, - * pattern matches for the current query in text nodes will be wrapped in a strong element. - * Defaults to false. - */ - highlight?: boolean; + /** + * highlight: If true, when suggestions are rendered, + * pattern matches for the current query in text nodes will be wrapped in a strong element. + * Defaults to false. + */ + highlight?: boolean; - /** - * If false, the typeahead will not show a hint. Defaults to true. - */ - hint?: boolean; + /** + * If false, the typeahead will not show a hint. Defaults to true. + */ + hint?: boolean; - /** - * The minimum character length needed before suggestions start getting rendered. Defaults to 1. - */ - minLength?: number; + /** + * The minimum character length needed before suggestions start getting rendered. Defaults to 1. + */ + minLength?: number; } } -declare module Bloodhound -{ - interface BloodhoundOptions - { - /** - * Transforms a datum into an array of string tokens - * - * @constructor - * @param datum individual units that compose the dataset - */ - datumTokenizer?: any; - /** - * Transforms a query into an array of string tokens - * - * @constructor - * @param query tokenizer query - */ - queryTokenizer?: any; - /** - * The max number of suggestions to return from Bloodhound#get. - * If not reached, the data source will attempt to backfill the suggestions from remote. Defaults to 5 - */ - limit?: number; - /** - * If set, this is expected to be a function with the signature (remoteMatch, localMatch) that returns true if the datums are duplicates or false otherwise. - * If not set, duplicate detection will not be performed. - */ - dupDetector?: (remoteMatch: T, localMatch: T) => boolean; - /** - * A compare function used to sort matched datums for a given query. - */ - sorter?: (a: T, b: T) => number; - /** - *An array of datums or a function that returns an array of datums. - */ - local?: () => T[]; - /** - * Can be a URL to a JSON file containing an array of datums or, if more configurability is needed, a prefetch options hash. - */ - prefetch?: PrefetchOptions; - /** - * Can be a URL to fetch suggestions from when the data provided by local and prefetch is insufficient or, if more configurability is needed, a remote options hash. - */ - remote?: RemoteOptions; - } - - /** - * Prefetched data is fetched and processed on initialization. - * If the browser supports localStorage, the processed data will be cached - * there to prevent additional network requests on subsequent page loads. - */ - interface PrefetchOptions - { - /** - * A URL to a JSON file containing an array of datums. Required. - */ - url: string; - /** - * The time (in milliseconds) the prefetched data should be cached - * in localStorage. Defaults to 86400000 (1 day). - */ - ttl?: number; - /** - * A function that transforms the response body into an array of datums. - * - * @param parsedResponse Response body - */ - filter?: (parsedResponse: any) => T[]; - /** The key that data will be stored in local storage under. Defaults to value of url. - * - */ - cacheKey?: string; - /** - * A string used for thumbprinting prefetched data. If this doesn't match what's stored in local storage, the data will be refetched. - */ - thumbprint?: string; - /** - * The ajax settings object passed to jQuery.ajax. - */ - ajax?: JQueryAjaxSettings; - } - - /** - * Remote data is only used when the data provided by local and prefetch - * is insufficient. In order to prevent an obscene number of requests - * being made to remote endpoint, typeahead.js rate-limits remote requests. - */ - interface RemoteOptions - { - /** - * A URL to make requests to when the data provided by local and - * prefetch is insufficient. Required. - */ - url: string; - /** - * The pattern in url that will be replaced with the user's query - * when a request is made. Defaults to %QUERY. - */ - wildcard?: string; - /** - * Overrides the request URL. If set, no wildcard substitution will - * be performed on url. - * - * @param url Replacement URL - * @param uriEncodedQuery Encoded query - * @returns A valid URL - */ - replace?: (url: string, uriEncodedQuery: string) => string; - /** - * The function used for rate-limiting network requests. - * Can be either 'debounce' or 'throttle'. Defaults to 'debounce'. - */ - rateLimitby?: string; - /** - * The time interval in milliseconds that will be used by rateLimitFn. - * Defaults to 300. - */ - rateLimitWait?: number; +declare module Bloodhound { + interface BloodhoundOptions { + /** + * Transforms a datum into an array of string tokens + * + * @constructor + * @param datum individual units that compose the dataset + */ + datumTokenizer?: any; + /** + * Transforms a query into an array of string tokens + * + * @constructor + * @param query tokenizer query + */ + queryTokenizer?: any; + /** + * The max number of suggestions to return from Bloodhound#get. + * If not reached, the data source will attempt to backfill the suggestions from remote. Defaults to 5 + */ + limit?: number; + /** + * If set, this is expected to be a function with the signature (remoteMatch, localMatch) that returns true if the datums are duplicates or false otherwise. + * If not set, duplicate detection will not be performed. + */ + dupDetector?: (remoteMatch: T, localMatch: T) => boolean; + /** + * A compare function used to sort matched datums for a given query. + */ + sorter?: (a: T, b: T) => number; + /** + * An array of datums or a function that returns an array of datums. + */ + local?: () => T[]; + /** + * Can be a URL to a JSON file containing an array of datums or, if more configurability is needed, a prefetch options hash. + */ + prefetch?: PrefetchOptions; + /** + * Can be a URL to fetch suggestions from when the data provided by local and prefetch is insufficient or, if more configurability is needed, a remote options hash. + */ + remote?: RemoteOptions; + } /** - * Transforms the response body into an array of datums. - * - * @param parsedResponse Response body + * Prefetched data is fetched and processed on initialization. + * If the browser supports localStorage, the processed data will be cached + * there to prevent additional network requests on subsequent page loads. */ - filter?: (parsedResponse: any) => T[]; + interface PrefetchOptions { + /** + * A URL to a JSON file containing an array of datums. Required. + */ + url: string; + /** + * The time (in milliseconds) the prefetched data should be cached + * in localStorage. Defaults to 86400000 (1 day). + */ + ttl?: number; + /** + * A function that transforms the response body into an array of datums. + * + * @param parsedResponse Response body + */ + filter?: (parsedResponse: any) => T[]; + /** The key that data will be stored in local storage under. Defaults to value of url. + * + */ + cacheKey?: string; + /** + * A string used for thumbprinting prefetched data. If this doesn't match what's stored in local storage, the data will be refetched. + */ + thumbprint?: string; + /** + * The ajax settings object passed to jQuery.ajax. + */ + ajax?: JQueryAjaxSettings; + } + /** - * The ajax settings object passed to jQuery.ajax. + * Remote data is only used when the data provided by local and prefetch + * is insufficient. In order to prevent an obscene number of requests + * being made to remote endpoint, typeahead.js rate-limits remote requests. */ - ajax?: JQueryAjaxSettings; + interface RemoteOptions { + /** + * A URL to make requests to when the data provided by local and + * prefetch is insufficient. Required. + */ + url: string; + /** + * The pattern in url that will be replaced with the user's query + * when a request is made. Defaults to %QUERY. + */ + wildcard?: string; + /** + * Overrides the request URL. If set, no wildcard substitution will + * be performed on url. + * + * @param url Replacement URL + * @param uriEncodedQuery Encoded query + * @returns A valid URL + */ + replace?: (url: string, uriEncodedQuery: string) => string; + /** + * The function used for rate-limiting network requests. + * Can be either 'debounce' or 'throttle'. Defaults to 'debounce'. + */ + rateLimitby?: string; + /** + * The time interval in milliseconds that will be used by rateLimitFn. + * Defaults to 300. + */ + rateLimitWait?: number; + + /** + * Transforms the response body into an array of datums. + * + * @param parsedResponse Response body + */ + filter?: (parsedResponse: any) => T[]; + /** + * The ajax settings object passed to jQuery.ajax. + */ + ajax?: JQueryAjaxSettings; - /** - * A function that provides a hook to allow you to prepare the settings object passed to transport - * when a request is about to be made. The function signature should be prepare(query, settings), - * where query is the query #search was called with and settings is the default settings object - * created internally by the Bloodhound instance. The prepare function should return a settings object. - * [Note: Added in 0.11.1] - * - * @param query The query #search was called with. - * @param settings The default settings object created internally by Bloodhound. - * @returns A JqueryAjaxSettings object. - */ - prepare?: (query: string, settings: JQueryAjaxSettings) => JQueryAjaxSettings; - } + /** + * A function that provides a hook to allow you to prepare the settings object passed to transport + * when a request is about to be made. The function signature should be prepare(query, settings), + * where query is the query #search was called with and settings is the default settings object + * created internally by the Bloodhound instance. The prepare function should return a settings object. + * [Note: Added in 0.11.1] + * + * @param query The query #search was called with. + * @param settings The default settings object created internally by Bloodhound. + * @returns A JqueryAjaxSettings object. + */ + prepare?: (query: string, settings: JQueryAjaxSettings) => JQueryAjaxSettings; + } - /** - * The most common tokenization methods. - */ - interface Tokenizers - { /** - * Split a given string on whitespace characters. + * The most common tokenization methods. */ - whitespace(query: string): string[]; - /** - * Split a given string on non-word characters. - */ - nonword(query: string): string[]; + interface Tokenizers { + /** + * Split a given string on whitespace characters. + */ + whitespace(query: string): string[]; + /** + * Split a given string on non-word characters. + */ + nonword(query: string): string[]; - /** - * Instances of the most common tokenization methods. - */ - obj: ObjTokenizer; - } + /** + * Instances of the most common tokenization methods. + */ + obj: ObjTokenizer; + } - interface ObjTokenizer - { - /** - * Split a given string on whitespace characters. - */ - whitespace(query: string): string[]; - /** - * Split a given string on non-word characters. - */ - nonword(query: string): string[]; - } + interface ObjTokenizer { + /** + * Split a given string on whitespace characters. + */ + whitespace(query: string): string[]; + /** + * Split a given string on non-word characters. + */ + nonword(query: string): string[]; + } } declare class Bloodhound { - constructor(options: Bloodhound.BloodhoundOptions); - /** - * wraps the suggestion engine in an adapter that is compatible with the typeahead jQuery plugin - */ - public ttAdapter(): any; - /** - * Kicks off the initialization of the suggestion engine. This includes processing the data provided through local and fetching/processing the data provided through prefetch. - * Until initialized, all other methods will behave as no-ops. - * Returns a jQuery promise which is resolved when engine has been initialized. - * - * After the initial call of initialize, how subsequent invocations of the method behave depends on the reinitialize argument. - * If reinitialize is falsy, the method will not execute the initialization logic and will just return the same jQuery promise returned by the initial invocation. - * If reinitialize is truthy, the method will behave as if it were being called for the first time. - * - * var promise1 = engine.initialize(); - * var promise2 = engine.initialize(); - * var promise3 = engine.initialize(true); - * - * promise1 === promise2; - * promise3 !== promise1 && promise3 !== promise2; - */ - public initialize(reinitialize?: boolean): JQueryPromise; - /** - * Takes one argument, datums, which is expected to be an array of datums. - * The passed in datums will get added to the search index that powers the suggestion engine. - */ - public add(datums: T[]): void; - /** - * Removes all suggestions from the search index. - */ - public clear(): void; - /** - * If you're using prefetch, data gets cached in local storage in an effort to cut down on unnecessary network requests. - * clearPrefetchCache offers a way to programmatically clear said cache. - */ - public clearPrefetchCache(): void; - /** - * If you're using remote, Bloodhound will cache the 10 most recent responses in an effort to provide a better user experience. - * clearRemoteCache offers a way to programmatically clear said cache. - */ - public clearRemoteCache(): void; - /** - * Returns a reference to the Bloodhound constructor and reverts window.Bloodhound to its previous value. Can be used to avoid naming collisions. - */ - public noConflict(): any; + constructor(options: Bloodhound.BloodhoundOptions); + /** + * wraps the suggestion engine in an adapter that is compatible with the typeahead jQuery plugin + */ + public ttAdapter(): any; + /** + * Kicks off the initialization of the suggestion engine. This includes processing the data provided through local and fetching/processing the data provided through prefetch. + * Until initialized, all other methods will behave as no-ops. + * Returns a jQuery promise which is resolved when engine has been initialized. + * + * After the initial call of initialize, how subsequent invocations of the method behave depends on the reinitialize argument. + * If reinitialize is falsy, the method will not execute the initialization logic and will just return the same jQuery promise returned by the initial invocation. + * If reinitialize is truthy, the method will behave as if it were being called for the first time. + * + * var promise1 = engine.initialize(); + * var promise2 = engine.initialize(); + * var promise3 = engine.initialize(true); + * + * promise1 === promise2; + * promise3 !== promise1 && promise3 !== promise2; + */ + public initialize(reinitialize?: boolean): JQueryPromise; + /** + * Takes one argument, datums, which is expected to be an array of datums. + * The passed in datums will get added to the search index that powers the suggestion engine. + */ + public add(datums: T[]): void; + /** + * Removes all suggestions from the search index. + */ + public clear(): void; + /** + * If you're using prefetch, data gets cached in local storage in an effort to cut down on unnecessary network requests. + * clearPrefetchCache offers a way to programmatically clear said cache. + */ + public clearPrefetchCache(): void; + /** + * If you're using remote, Bloodhound will cache the 10 most recent responses in an effort to provide a better user experience. + * clearRemoteCache offers a way to programmatically clear said cache. + */ + public clearRemoteCache(): void; + /** + * Returns a reference to the Bloodhound constructor and reverts window.Bloodhound to its previous value. Can be used to avoid naming collisions. + */ + public noConflict(): any; - /** - * Computes a set of suggestions for query. cb will be invoked with an array of datums that represent said set. - * cb will always be invoked once synchronously with suggestions that were available on the client. - * If those suggestions are insufficient (# of suggestions is less than limit) and remote was configured, cb may also be invoked asynchronously with the suggestions available on the client mixed with suggestions from the remote source. - */ - public get(query: string, cb: (datums: T[]) => void): void; + /** + * Computes a set of suggestions for query. cb will be invoked with an array of datums that represent said set. + * cb will always be invoked once synchronously with suggestions that were available on the client. + * If those suggestions are insufficient (# of suggestions is less than limit) and remote was configured, cb may also be invoked asynchronously with the suggestions available on the client mixed with suggestions from the remote source. + */ + public get(query: string, cb: (datums: T[]) => void): void; - /** - * The Bloodhound suggestion engine is token-based, so how datums and queries are tokenized plays a vital role in the quality of search results. - * Specify how you want datums and queries tokenized. - */ - public static tokenizers: Bloodhound.Tokenizers; + /** + * The Bloodhound suggestion engine is token-based, so how datums and queries are tokenized plays a vital role in the quality of search results. + * Specify how you want datums and queries tokenized. + */ + public static tokenizers: Bloodhound.Tokenizers; } declare module "bloodhound" { - export = Bloodhound; + export = Bloodhound; } From 7d715446377a65c491337c88efec1116507c2436 Mon Sep 17 00:00:00 2001 From: Luigi Trabacchin Date: Wed, 14 Oct 2015 14:45:35 +0200 Subject: [PATCH 0065/1238] Bootstrap.v3.datetimepicker: referenced moment.js less generic type parameters, updated some functions, added some missing parameters --- .../bootstrap.v3.datetimepicker-tests.ts | 14 +++---- .../bootstrap.v3.datetimepicker.d.ts | 39 ++++++++++++------- 2 files changed, 32 insertions(+), 21 deletions(-) diff --git a/bootstrap.v3.datetimepicker/bootstrap.v3.datetimepicker-tests.ts b/bootstrap.v3.datetimepicker/bootstrap.v3.datetimepicker-tests.ts index 6abf38f946..056c76dd6b 100644 --- a/bootstrap.v3.datetimepicker/bootstrap.v3.datetimepicker-tests.ts +++ b/bootstrap.v3.datetimepicker/bootstrap.v3.datetimepicker-tests.ts @@ -6,17 +6,17 @@ function test_cases() { $('#datetimepicker').datetimepicker({ pickDate: false }); - $('#datetimepicker').datetimepicker({ + $('#datetimepicker').datetimepicker({ pickTime: false }); - $('#datetimepicker').datetimepicker({ + $('#datetimepicker').datetimepicker({ minDate: '2012-12-31' }); - - $('#datetimepicker').data("DateTimePicker").setMaxDate('2012-12-31'); - - var startDate = new Date(2012, 1, 20); - var endDate = new Date(2012, 1, 25); + + $('#datetimepicker').data("DateTimePicker").setMaxDate('2012-12-31'); + + var startDate = moment(new Date(2012, 1, 20)); + var endDate = moment(new Date(2012, 1, 25)); $('#datetimepicker2') .datetimepicker() .on("dp.change", function (ev) { diff --git a/bootstrap.v3.datetimepicker/bootstrap.v3.datetimepicker.d.ts b/bootstrap.v3.datetimepicker/bootstrap.v3.datetimepicker.d.ts index 228b7537f7..0db3f7b3fb 100644 --- a/bootstrap.v3.datetimepicker/bootstrap.v3.datetimepicker.d.ts +++ b/bootstrap.v3.datetimepicker/bootstrap.v3.datetimepicker.d.ts @@ -10,15 +10,22 @@ */ /// +/// declare module BootstrapV3DatetimePicker { - interface DatetimepickerChangeEventObject extends JQueryEventObject { - date: any; - oldDate: any; + enum ViewMode { + 'days', + 'months', + 'years', + 'decades' + } + + interface DatetimepickerChangeEventObject extends DatetimepickerEventObject { + oldDate: moment.Moment; } interface DatetimepickerEventObject extends JQueryEventObject { - date: any; + date: moment.Moment; } interface DatetimepickerIcons { @@ -35,33 +42,37 @@ declare module BootstrapV3DatetimePicker { useSeconds?: boolean; useCurrent?: boolean; minuteStepping?: number; - minDate?: any; - maxDate?: any; + minDate?: moment.Moment | Date | string; + maxDate?: moment.Moment | Date | string; showToday?: boolean; collapse?: boolean; language?: string; - defaultDate?: string; - disabledDates?: Array; - enabledDates?: Array; + defaultDate?: moment.Moment | Date | string; + disabledDates?: Array; + enabledDates?: Array; icons?: DatetimepickerIcons; useStrict?: boolean; direction?: string; sideBySide?: boolean; - daysOfWeekDisabled?: Array; + daysOfWeekDisabled?: Array; calendarWeeks?: boolean; format?: string | boolean; locale?: string; showTodayButton?: boolean; + viewMode?: string; + inline?: boolean; } interface Datetimepicker { - setDate(date: any): void; - setMinDate(date: any): void; - setMaxDate(date: any): void; + date(date: moment.Moment | Date | string): void; + date(): moment.Moment; + minDate(date: moment.Moment | Date | string): void; + minDate(): moment.Moment | boolean; + maxDate(date: moment.Moment | Date | string): void; + maxDate(): moment.Moment | boolean; show(): void; disable(): void; enable(): void; - getDate(): void; } } From fd6b794520e5258ff59c7501d7d155fad3dad21a Mon Sep 17 00:00:00 2001 From: Luigi Trabacchin Date: Wed, 14 Oct 2015 14:49:50 +0200 Subject: [PATCH 0066/1238] FullCalendar: updated to last version, updated some interfaces names to fit documentation, less generic arguments and options, referenced moment.js --- fullCalendar/fullCalendar-tests.ts | 43 ++++----- fullCalendar/fullCalendar.d.ts | 146 +++++++++++++++++------------ 2 files changed, 107 insertions(+), 82 deletions(-) diff --git a/fullCalendar/fullCalendar-tests.ts b/fullCalendar/fullCalendar-tests.ts index 6890cbe422..b3ec7973c5 100644 --- a/fullCalendar/fullCalendar-tests.ts +++ b/fullCalendar/fullCalendar-tests.ts @@ -4,11 +4,10 @@ // All examples from http://arshaw.com/fullcalendar/docs/ -$('#calendar').fullCalendar({ -}) +$('#calendar').fullCalendar({}); $('#calendar').fullCalendar({ - weekends: false + weekends: false }); $('#calendar').fullCalendar({ @@ -67,7 +66,7 @@ $('#calendar').fullCalendar({ $('#calendar').fullCalendar('option', 'aspectRatio', 1.8); $('#calendar').fullCalendar({ - viewRender: function(view) { + viewRender: function (view) { alert('The new title of the view is ' + view.title); } }); @@ -81,22 +80,19 @@ $('#calendar').fullCalendar({ $('#calendar').fullCalendar('render'); $('#calendar').fullCalendar({ - dragOpacity: { - month: .2, - '': .5 - } + dragOpacity: .5 }); var view = $('#calendar').fullCalendar('getView'); alert("The view's title is " + view.title); $(document).ready(function () { - + var date = new Date(); var d = date.getDate(); var m = date.getMonth(); var y = date.getFullYear(); - + $('#calendar').fullCalendar({ header: { left: 'prev,next today', @@ -155,12 +151,12 @@ $(document).ready(function () { }); $(document).ready(function () { - + var date = new Date(); var d = date.getDate(); var m = date.getMonth(); var y = date.getFullYear(); - + $('#calendar').fullCalendar({ header: { left: 'prev,next today', @@ -220,12 +216,12 @@ $(document).ready(function () { }); $(document).ready(function () { - + var date = new Date(); var d = date.getDate(); var m = date.getMonth(); var y = date.getFullYear(); - + $('#calendar').fullCalendar({ header: { left: 'prev,next today', @@ -274,12 +270,12 @@ $(document).ready(function () { }); $(document).ready(function () { - + var date = new Date(); var d = date.getDate(); var m = date.getMonth(); var y = date.getFullYear(); - + $('#calendar').fullCalendar({ editable: true, header: { @@ -339,12 +335,12 @@ $(document).ready(function () { }); $(document).ready(function () { - + var date = new Date(); var d = date.getDate(); var m = date.getMonth(); var y = date.getFullYear(); - + $('#calendar').fullCalendar({ header: { left: 'prev,next today', @@ -715,12 +711,12 @@ $('#draggable1').draggable(); $('#draggable2').draggable(); $(document).ready(function () { - + var date = new Date(); var d = date.getDate(); var m = date.getMonth(); var y = date.getFullYear(); - + $('#calendar').fullCalendar({ theme: true, header: { @@ -799,11 +795,11 @@ $(document).ready(function () { revert: true, // will cause the event to go back to its revertDuration: 0 // original position after the drag }); - + }); /* initialize the calendar -----------------------------------------------------------------*/ - + $('#calendar').fullCalendar({ header: { left: 'prev,next today', @@ -833,9 +829,8 @@ $(document).ready(function () { // if so, remove the element from the "Draggable Events" list $(this).remove(); } - } }); }); -$('#calendar').fullCalendar('refetchEvents') \ No newline at end of file +$('#calendar').fullCalendar('refetchEvents'); diff --git a/fullCalendar/fullCalendar.d.ts b/fullCalendar/fullCalendar.d.ts index f73dc2d8bf..7552d5bfd9 100644 --- a/fullCalendar/fullCalendar.d.ts +++ b/fullCalendar/fullCalendar.d.ts @@ -4,6 +4,7 @@ // Definitions: https://github.com/borisyankov/DefinitelyTyped /// +/// declare module FullCalendar { export interface Calendar { @@ -34,7 +35,18 @@ declare module FullCalendar { version: string; } - export interface Options { + export interface BusinessHours { + start: moment.Duration; + end: moment.Duration; + dow: Array; + } + + export interface Timespan { + start: moment.Moment; + end: moment.Moment; + } + + export interface Options extends AgendaOptions, EventDraggingResizingOptions, DroppingExternalElementsOptions, SelectionOptions { // General display - http://arshaw.com/fullcalendar/docs/display/ @@ -55,14 +67,19 @@ declare module FullCalendar { weekMode?: string; weekNumbers?: boolean; weekNumberCalculation?: any; // String/Function + businessHours?: boolean | BusinessHours; height?: number; contentHeight?: number; aspectRatio?: number; handleWindowResize?: boolean; - viewRender?: (view: View, element: JQuery) => void; - viewDestroy?: (view: View, element: JQuery) => void; + viewRender?: (view: ViewObject, element: JQuery) => void; + viewDestroy?: (view: ViewObject, element: JQuery) => void; dayRender?: (date: Date, cell: HTMLTableDataCellElement) => void; - windowResize?: (view: View) => void; + windowResize?: (view: ViewObject) => void; + + // Timezone + timezone?: string | boolean; + now?: moment.Moment | Date | string | (() => moment.Moment) // Views - http://arshaw.com/fullcalendar/docs/views/ @@ -70,6 +87,7 @@ declare module FullCalendar { // Current Date - http://arshaw.com/fullcalendar/docs/current_date/ + defaultDate?: moment.Moment | Date | string; year?: number; month?: number; date?: number; @@ -79,6 +97,7 @@ declare module FullCalendar { timeFormat?: any; // String/ViewOptionHash columnFormat?: any; // String/ViewOptionHash titleFormat?: any; // String/ViewOptionHash + buttonText?: ButtonTextObject; monthNames?: Array; monthNamesShort?: Array; @@ -88,19 +107,10 @@ declare module FullCalendar { // Clicking & Hovering - http://arshaw.com/fullcalendar/docs/mouse/ - dayClick?: (date: Date, allDay: boolean, jsEvent: MouseEvent, view: View) => void; - eventClick?: (event: EventObject, jsEvent: MouseEvent, view: View) => any; // return type boolean or void - eventMouseover?: (event: EventObject, jsEvent: MouseEvent, view: View) => void; - eventMouseout?: (event: EventObject, jsEvent: MouseEvent, view: View) => void; - - // Selection - http://arshaw.com/fullcalendar/docs/selection/ - - selectable?: any; // Boolean/ViewOptionHash - selectHelper?: any; // Boolean/Function - unselectAuto?: boolean; - unselectCancel?: string; - select?: (startDate: Date | string, endDate: Date | string, allDay: boolean, jsEvent: MouseEvent, view: View) => void; - unselect?: (view: View, jsEvent: Event) => void; + dayClick?: (date: Date, allDay: boolean, jsEvent: MouseEvent, view: ViewObject) => void; + eventClick?: (event: EventObject, jsEvent: MouseEvent, view: ViewObject) => any; // return type boolean or void + eventMouseover?: (event: EventObject, jsEvent: MouseEvent, view: ViewObject) => void; + eventMouseout?: (event: EventObject, jsEvent: MouseEvent, view: ViewObject) => void; // Event Data - http://arshaw.com/fullcalendar/docs/event_data/ @@ -129,7 +139,7 @@ declare module FullCalendar { endParam?: string lazyFetching?: boolean; eventDataTransform?: (eventData: any) => EventObject; - loading?: (isLoading: boolean, view: View) => void; + loading?: (isLoading: boolean, view: ViewObject) => void; // Event Rendering - http://arshaw.com/fullcalendar/docs/event_rendering/ @@ -137,37 +147,12 @@ declare module FullCalendar { eventBackgroundColor?: string; eventBorderColor?: string; eventTextColor?: string; - eventRender?: (event: EventObject, element: HTMLDivElement, view: View) => void; - eventAfterRender?: (event: EventObject, element: HTMLDivElement, view: View) => void; - eventAfterAllRender?: (view: View) => void; - eventDestroy?: (event: EventObject, element: JQuery, view: View) => void; + eventRender?: (event: EventObject, element: HTMLDivElement, view: ViewObject) => void; + eventAfterRender?: (event: EventObject, element: HTMLDivElement, view: ViewObject) => void; + eventAfterAllRender?: (view: ViewObject) => void; + eventDestroy?: (event: EventObject, element: JQuery, view: ViewObject) => void; - // Event Dragging & Resizing - editable?: boolean; - eventStartEditable?: boolean; - eventDurationEditable?: boolean; - dragRevertDuration?: number; - dragOpacity?: any; // Float/ViewOptionHash - eventDragStart?: (event: EventObject, jsEvent: MouseEvent, ui: any, view: View) => void; - eventDragStop?: (event: EventObject, jsEvent: MouseEvent, ui: any, view: View) => void; - eventDrop?: (event: EventObject, dayDelta: number, minuteDelta: number, revertFunc: Function, jsEvent: Event, ui: any, view: View) => void; - eventResizeStart?: (event: EventObject, jsEvent: MouseEvent, ui: any, view: View) => void; - eventResizeStop?: (event: EventObject, jsEvent: MouseEvent, ui: any, view: View) => void; - eventResize?: (event: EventObject, dayDelta: number, minuteDelta: number, revertFunc: Function, jsEvent: Event, ui: any, view: View) => void; - - droppable?: boolean; - dropAccept?: any; // String/Function - drop?: (date: Date, allDay: boolean, jsEvent: MouseEvent, ui: any) => void; - } - - export interface View { - name: string; - title: string; - start: Date | string; - end: Date | string; - visStart: Date; - visEnd: Date; } export interface ViewOptionHash { @@ -189,16 +174,56 @@ declare module FullCalendar { export interface AgendaOptions { allDaySlot?: boolean; allDayText?: string; - axisFormat?: string; - slotMinutes?: number; - snapMinutes?: number; - defaultEventMinutes?: number; - firstHour?: number; - minTime?: any; // Integer/String - maxTime?: any; // Integer/String + slotDuration?: moment.Duration; + slotLabelFormat?: string; + slotLabelInterval?: moment.Duration; + snapDuration?: moment.Duration; + scrollTime?: moment.Duration; + minTime?: moment.Duration; // Integer/String + maxTime?: moment.Duration; // Integer/String slotEventOverlap?: boolean; } + /* + * Event Dragging & Resizing + */ + export interface EventDraggingResizingOptions { + editable?: boolean; + eventStartEditable?: boolean; + eventDurationEditable?: boolean; + dragRevertDuration?: number; // integer, milliseconds + dragOpacity?: number; // float + dragScroll?: boolean; + eventOverlap?: boolean | ((stillEvent: EventObject, movingEvent: EventObject) => boolean); + eventConstraint?: BusinessHours | Timespan; + eventDragStart?: (event: EventObject, jsEvent: MouseEvent, ui: any, view: ViewObject) => void; + eventDragStop?: (event: EventObject, jsEvent: MouseEvent, ui: any, view: ViewObject) => void; + eventDrop?: (event: EventObject, dayDelta: number, minuteDelta: number, revertFunc: Function, jsEvent: Event, ui: any, view: ViewObject) => void; + eventResizeStart?: (event: EventObject, jsEvent: MouseEvent, ui: any, view: ViewObject) => void; + eventResizeStop?: (event: EventObject, jsEvent: MouseEvent, ui: any, view: ViewObject) => void; + eventResize?: (event: EventObject, dayDelta: number, minuteDelta: number, revertFunc: Function, jsEvent: Event, ui: any, view: ViewObject) => void; + } + /* + * Selection - http://arshaw.com/fullcalendar/docs/selection/ + */ + export interface SelectionOptions { + selectable?: boolean; + selectHelper?: boolean | ((start: moment.Moment, end: moment.Moment) => HTMLElement); + unselectAuto?: boolean; + unselectCancel?: string; + selectOverlap?: boolean | ((event: EventObject) => boolean); + selectConstraint?: Timespan | BusinessHours; + select?: (start: moment.Moment, end: moment.Moment, jsEvent: MouseEvent, view: ViewObject, resource?: any) => void; + unselect?: (view: ViewObject, jsEvent: Event) => void; + } + + export interface DroppingExternalElementsOptions { + droppable?: boolean; + dropAccept?: string | ((draggable: any) => boolean); + drop?: (date: moment.Moment, jsEvent: MouseEvent, ui: any) => void; + eventReceive?: (event: EventObject) => void + } + export interface ButtonTextObject { prev?: string; next?: string; @@ -210,12 +235,10 @@ declare module FullCalendar { day?: string; } - export interface EventObject { + export interface EventObject extends Timespan { id?: any // String/number title: string; allDay?: boolean; - start: Date | string; - end?: Date | string; url?: string; className?: any; // string/Array editable?: boolean; @@ -226,6 +249,13 @@ declare module FullCalendar { textColor?: string; } + export interface ViewObject extends Timespan { + name: string; + title: string; + intervalStart: moment.Moment; + intervalEnd: moment.Moment; + } + export interface EventSource extends JQueryAjaxSettings { /** @@ -272,7 +302,7 @@ interface JQuery { /** * Returns the View Object for the current view. */ - fullCalendar(method: 'getView'): FullCalendar.View; + fullCalendar(method: 'getView'): FullCalendar.ViewObject; /** * Immediately switches to a different view. From 93bcd768f07af500f68c26abfba8ed2827c81eac Mon Sep 17 00:00:00 2001 From: abreits Date: Wed, 14 Oct 2015 14:58:55 +0200 Subject: [PATCH 0067/1238] amqplib: callback-api added (second try) --- amqplib/amqplib-tests.ts | 8 +++++-- amqplib/amqplib.d.ts | 51 ++++++++++++++++++++-------------------- 2 files changed, 31 insertions(+), 28 deletions(-) diff --git a/amqplib/amqplib-tests.ts b/amqplib/amqplib-tests.ts index cfb9adbe13..c22bc7ac96 100644 --- a/amqplib/amqplib-tests.ts +++ b/amqplib/amqplib-tests.ts @@ -29,7 +29,9 @@ amqpcb.connect("amqp://localhost", (err, connection) => { connection.createChannel((err, channel) => { if (!err) { channel.assertQueue("myQueue", (err, ok) => { - channel.sendToQueue("myQueue", new Buffer(msg)); + if(!err) { + channel.sendToQueue("myQueue", new Buffer(msg)); + } }); } }); @@ -41,7 +43,9 @@ amqpcb.connect("amqp://localhost", (err, connection) => { connection.createChannel((err, channel) => { if (!err) { channel.assertQueue("myQueue", (err, ok) => { - channel.consume("myQueue", newMsg => console.log("New Message: " + newMsg.content.toString())); + if(!err) { + channel.consume("myQueue", newMsg => console.log("New Message: " + newMsg.content.toString())); + } }); } }); diff --git a/amqplib/amqplib.d.ts b/amqplib/amqplib.d.ts index c6f73feefe..a6e6e7a055 100644 --- a/amqplib/amqplib.d.ts +++ b/amqplib/amqplib.d.ts @@ -1,7 +1,6 @@ // Type definitions for amqplib 0.3.x // Project: https://github.com/squaremo/amqp.node -// Definitions by: Michael Nahkies -// Definitions for callback api added by: Ab Reitsma +// Definitions by: Michael Nahkies , Ab Reitsma // Definitions: https://github.com/borisyankov/DefinitelyTyped /// @@ -149,9 +148,9 @@ declare module "amqplib/callback_api" { import events = require("events"); interface Connection extends events.EventEmitter { - close(callback?: (err: any) => void); - createChannel(callback: (err: any, channel: Channel) => void); - createConfirmChannel(callback: (err: any, confirmChannel: ConfirmChannel) => void); + close(callback?: (err: any) => void): void; + createChannel(callback: (err: any, channel: Channel) => void): void; + createConfirmChannel(callback: (err: any, confirmChannel: ConfirmChannel) => void): void; } module Replies { @@ -242,32 +241,32 @@ declare module "amqplib/callback_api" { } interface Channel extends events.EventEmitter { - close(callback: (err: any) => void); + close(callback: (err: any) => void): void; - assertQueue(queue?: string, options?: Options.AssertQueue, callback?: (err:any, ok: Replies.AssertQueue) => void); - checkQueue(queue: string, callback?: (err: any, ok: Replies.AssertQueue) => void); + assertQueue(queue?: string, options?: Options.AssertQueue, callback?: (err:any, ok: Replies.AssertQueue) => void): void; + checkQueue(queue: string, callback?: (err: any, ok: Replies.AssertQueue) => void): void; - deleteQueue(queue: string, options?: Options.DeleteQueue, callback?: (err:any, ok: Replies.DeleteQueue) => void); - purgeQueue(queue: string, callback?: (err:any, ok: Replies.PurgeQueue) => void); + deleteQueue(queue: string, options?: Options.DeleteQueue, callback?: (err:any, ok: Replies.DeleteQueue) => void): void; + purgeQueue(queue: string, callback?: (err:any, ok: Replies.PurgeQueue) => void): void; - bindQueue(queue: string, source: string, pattern: string, args?: any, callback?: (err: any, ok: Replies.Empty) => void); - unbindQueue(queue: string, source: string, pattern: string, args?: any, callback?: (err: any, ok: Replies.Empty) => void); + bindQueue(queue: string, source: string, pattern: string, args?: any, callback?: (err: any, ok: Replies.Empty) => void): void; + unbindQueue(queue: string, source: string, pattern: string, args?: any, callback?: (err: any, ok: Replies.Empty) => void): void; - assertExchange(exchange: string, type: string, options?: Options.AssertExchange, callback?: (err: any, ok: Replies.AssertExchange) => void); - checkExchange(exchange: string, callback?: (err: any, ok: Replies.Empty) => void); + assertExchange(exchange: string, type: string, options?: Options.AssertExchange, callback?: (err: any, ok: Replies.AssertExchange) => void): void; + checkExchange(exchange: string, callback?: (err: any, ok: Replies.Empty) => void): void; - deleteExchange(exchange: string, options?: Options.DeleteExchange, callback?: (err: any, ok: Replies.Empty) => void); + deleteExchange(exchange: string, options?: Options.DeleteExchange, callback?: (err: any, ok: Replies.Empty) => void): void; - bindExchange(destination: string, source: string, pattern: string, args?: any, callback?: (err: any, ok: Replies.Empty) => void); - unbindExchange(destination: string, source: string, pattern: string, args?: any, callback?: (err: any, ok: Replies.Empty) => void); + bindExchange(destination: string, source: string, pattern: string, args?: any, callback?: (err: any, ok: Replies.Empty) => void): void; + unbindExchange(destination: string, source: string, pattern: string, args?: any, callback?: (err: any, ok: Replies.Empty) => void): void; publish(exchange: string, routingKey: string, content: Buffer, options?: Options.Publish): boolean; sendToQueue(queue: string, content: Buffer, options?: Options.Publish): boolean; - consume(queue: string, onMessage: (msg: Message) => any, options?: Options.Consume, callback?: (err: any, ok: Replies.Consume) => void); + consume(queue: string, onMessage: (msg: Message) => any, options?: Options.Consume, callback?: (err: any, ok: Replies.Consume) => void): void; - cancel(consumerTag: string, callback?: (err: any, ok: Replies.Empty) => void); - get(queue: string, options?: Options.Get, callback?: (err: any, ok: Message | boolean) => void); + cancel(consumerTag: string, callback?: (err: any, ok: Replies.Empty) => void): void; + get(queue: string, options?: Options.Get, callback?: (err: any, ok: Message | boolean) => void): void; ack(message: Message, allUpTo?: boolean): void; ackAll(): void; @@ -276,18 +275,18 @@ declare module "amqplib/callback_api" { nackAll(requeue?: boolean): void; reject(message: Message, requeue?: boolean): void; - prefetch(count: number, global?: boolean); - recover(callback?: (err: any, ok: Replies.Empty) => void); + prefetch(count: number, global?: boolean): void; + recover(callback?: (err: any, ok: Replies.Empty) => void): void; } interface ConfirmChannel extends Channel { publish(exchange: string, routingKey: string, content: Buffer, options?: Options.Publish, callback?: (err: any, ok: Replies.Empty) => void): boolean; sendToQueue(queue: string, content: Buffer, options?: Options.Publish, callback?: (err: any, ok: Replies.Empty) => void): boolean; - waitForConfirms(callback?: (err: any) => void); + waitForConfirms(callback?: (err: any) => void): void; } - function connect(callback: (err: any, connection: Connection) => void); - function connect(url: string, callback: (err: any, connection: Connection) => void); - function connect(url: string, socketOptions: any, callback: (err: any, connection: Connection) => void); + function connect(callback: (err: any, connection: Connection) => void): void; + function connect(url: string, callback: (err: any, connection: Connection) => void): void; + function connect(url: string, socketOptions: any, callback: (err: any, connection: Connection) => void): void; } From 3eed85776e25068f0234c0827230d05d1bd412bc Mon Sep 17 00:00:00 2001 From: Luigi Trabacchin Date: Wed, 14 Oct 2015 14:59:22 +0200 Subject: [PATCH 0068/1238] setMaxDate has been changed to getter and setters so it is now maxDate https://github.com/Eonasdan/bootstrap-datetimepicker/blob/master/docs/Functions.md#minmaxdate --- .../bootstrap.v3.datetimepicker-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bootstrap.v3.datetimepicker/bootstrap.v3.datetimepicker-tests.ts b/bootstrap.v3.datetimepicker/bootstrap.v3.datetimepicker-tests.ts index 056c76dd6b..e17b7b10cf 100644 --- a/bootstrap.v3.datetimepicker/bootstrap.v3.datetimepicker-tests.ts +++ b/bootstrap.v3.datetimepicker/bootstrap.v3.datetimepicker-tests.ts @@ -13,7 +13,7 @@ function test_cases() { minDate: '2012-12-31' }); - $('#datetimepicker').data("DateTimePicker").setMaxDate('2012-12-31'); + $('#datetimepicker').data("DateTimePicker").maxDate('2012-12-31'); var startDate = moment(new Date(2012, 1, 20)); var endDate = moment(new Date(2012, 1, 25)); From 9e7d9453a136e98970eeae042706680d0e974c67 Mon Sep 17 00:00:00 2001 From: abreits Date: Wed, 14 Oct 2015 15:09:10 +0200 Subject: [PATCH 0069/1238] amqplib: callback-api definition and tests added --- amqplib/amqplib-tests.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/amqplib/amqplib-tests.ts b/amqplib/amqplib-tests.ts index c22bc7ac96..f99a3bde1a 100644 --- a/amqplib/amqplib-tests.ts +++ b/amqplib/amqplib-tests.ts @@ -28,7 +28,7 @@ amqpcb.connect("amqp://localhost", (err, connection) => { if(!err) { connection.createChannel((err, channel) => { if (!err) { - channel.assertQueue("myQueue", (err, ok) => { + channel.assertQueue("myQueue", {}, (err, ok) => { if(!err) { channel.sendToQueue("myQueue", new Buffer(msg)); } @@ -42,7 +42,7 @@ amqpcb.connect("amqp://localhost", (err, connection) => { if(!err) { connection.createChannel((err, channel) => { if (!err) { - channel.assertQueue("myQueue", (err, ok) => { + channel.assertQueue("myQueue", {}, (err, ok) => { if(!err) { channel.consume("myQueue", newMsg => console.log("New Message: " + newMsg.content.toString())); } From d7b3d781a82a3a19fcc9eb7916e247156ab432ee Mon Sep 17 00:00:00 2001 From: Luigi Trabacchin Date: Wed, 14 Oct 2015 15:36:34 +0200 Subject: [PATCH 0070/1238] Typeahead : DisplayKey is now Display --- typeahead/typeahead-tests.ts | 20 ++++++++++---------- typeahead/typeahead.d.ts | 5 ++--- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/typeahead/typeahead-tests.ts b/typeahead/typeahead-tests.ts index 3864865c9f..ec2b2e2f3d 100644 --- a/typeahead/typeahead-tests.ts +++ b/typeahead/typeahead-tests.ts @@ -6,7 +6,7 @@ // var substringMatcher = function (strs: any) { - return function findMatches(q: string, syncResults: (x: any) => void) { + return function findMatches(q: string, syncResults: (x: Array) => void) { var matches: Array<{ value: string }> = []; // regex used to determine if a string contains the substring `q` var substrRegex = new RegExp(q, 'i'); @@ -97,7 +97,7 @@ function test_datasets_array() { function with_displayKey_option() { $('#the-basics .typeahead').typeahead(options, [{ - displayKey: 'value', + display: 'value', source: substringMatcher(states) }] ); @@ -114,7 +114,7 @@ function test_datasets_array() { function with_all_options() { $('#the-basics .typeahead').typeahead(options, [{ name: 'states', - displayKey: 'value', + display: 'value', templates: {}, source: substringMatcher(states) }] @@ -125,13 +125,13 @@ function test_datasets_array() { $('#the-basics .typeahead').typeahead(options, [ { name: 'states', - displayKey: 'value', + display: 'value', templates: {}, source: substringMatcher(states) }, { name: 'states alternative', - displayKey: 'value', + display: 'value', templates: {}, source: substringMatcher(states) } @@ -161,7 +161,7 @@ function test_datasets_objects() { function with_displayKey_option() { $('#the-basics .typeahead').typeahead(options, { - displayKey: 'value', + display: 'value', source: substringMatcher(states) } ); @@ -180,7 +180,7 @@ function test_datasets_objects() { $('#the-basics .typeahead').typeahead(options, { name: 'states', - displayKey: 'value', + display: x => x.value, templates: {}, source: substringMatcher(states) } @@ -191,13 +191,13 @@ function test_datasets_objects() { $('#the-basics .typeahead').typeahead(options, { name: 'states', - displayKey: 'value', + display: 'value', templates: {}, source: substringMatcher(states) }, { name: 'states alternative', - displayKey: 'value', + display: 'value', templates: {}, source: substringMatcher(states) } @@ -291,7 +291,7 @@ function test_dataset_templates() { suggestion: function (context) { return context.name; } - } + }, }); } } diff --git a/typeahead/typeahead.d.ts b/typeahead/typeahead.d.ts index cde3a92771..7ffbe5b509 100644 --- a/typeahead/typeahead.d.ts +++ b/typeahead/typeahead.d.ts @@ -105,7 +105,7 @@ declare module Twitter.Typeahead { * cb can be invoked synchronously or asynchronously. * */ - source: ((query: string, syncResults: (result: any) => void, asyncResults?: (result: any) => void) => void); + source: ((query: string, syncResults: (result: Array) => void, asyncResults?: (result: Array) => void) => void); /** * The name of the dataset. @@ -120,7 +120,7 @@ declare module Twitter.Typeahead { * This will be used when setting the value of the input control after a suggestion is selected. Can be either a key string or a function that transforms a suggestion object into a string. * Defaults to value. */ - displayKey?: string | ((obj: any) => string); + display?: string | ((obj: any) => string); /** * A hash of templates to be used when rendering the dataset. @@ -128,7 +128,6 @@ declare module Twitter.Typeahead { */ templates?: Templates; async?: boolean; - display?: boolean | ((x: any) => boolean); } From cbd5556169709445e7b577e1888515f49eb5f47c Mon Sep 17 00:00:00 2001 From: James Alexander Date: Wed, 14 Oct 2015 10:49:05 -0400 Subject: [PATCH 0071/1238] Added additional IOptions properties Properties addSuffix, removeTags, and empty were all missing from the type definition for gulp-inject --- gulp-inject/gulp-inject.d.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gulp-inject/gulp-inject.d.ts b/gulp-inject/gulp-inject.d.ts index 42f5fb3480..fb2668a1f7 100644 --- a/gulp-inject/gulp-inject.d.ts +++ b/gulp-inject/gulp-inject.d.ts @@ -22,8 +22,11 @@ declare module "gulp-inject" { ignorePath?: string | string[]; relative?: boolean; addPrefix?: string; + addSuffix?: string; addRootSlash?: boolean; name?: string; + removeTags?: boolean; + empty?: boolean; starttag?: string | ITagFunction; endtag?: string | ITagFunction; transform?: ITransformFunction; From abd8bf27637b962f572cc5d6e622ed2f7ed21a6b Mon Sep 17 00:00:00 2001 From: Dominic Alie Date: Wed, 14 Oct 2015 11:05:27 -0400 Subject: [PATCH 0072/1238] Add tests --- leaflet-editable/leaflet-editable-tests.ts | 58 +++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/leaflet-editable/leaflet-editable-tests.ts b/leaflet-editable/leaflet-editable-tests.ts index ebb90cc972..fa904f6713 100644 --- a/leaflet-editable/leaflet-editable-tests.ts +++ b/leaflet-editable/leaflet-editable-tests.ts @@ -1 +1,57 @@ -/// \ No newline at end of file +/// + +var map: L.Map = L.map('div', { + editable: true, + editOptions: { + drawingCSSClass: 'css-class', + editLayer: L.layerGroup(), + featuresLayer: L.layerGroup(), + lineGuideOptions: {}, + markerClass: MarkerClass, + markerEditorClass: MarkerEditorClass, + middleMarkerClass: MiddleMarkerClass, + polygonClass: PolygonClass, + polygonEditorClass: PolygonEditorClass, + polylineClass: PolylineClass, + polylineEditorClass: PolylineEditorClass, + skipMiddleMarkers: true, + vertexMarkerClass: VertexMarkerClass + } +}); + +var currentPoly: L.Polygon|L.Polyline| L.Marker = map.editTools.currentPolygon; +map.editTools.stopDrawing(); + +var marker: L.Marker = map.editTools.startMarker(L.latLng(0, 0), { draggable: true }); +marker.disable(); +marker.enable(); +marker.toggleEdit(); +var enabled: boolean = marker.editEnabled(); + +var polyline: L.Polyline = map.editTools.startPolyline(L.latLng(0, 0), { noClip: true }); +polyline.continueBackward(); +polyline.continueForward(); +polyline.disable(); +polyline.enable(); +enabled = polyline.editEnabled(); +polyline.reset(); +polyline.toggleEdit(); + +var polygon: L.Polygon = map.editTools.startPolygon(L.latLng(0, 0), { noClip: true }); +polygon.continueBackward(); +polygon.continueForward(); +polygon.disable(); +polygon.enable(); +enabled = polygon.editEnabled(); +polygon.newHole(L.latLng(0, 0)); +polygon.reset(); +polygon.toggleEdit(); + +class MarkerClass { } +class MarkerEditorClass { } +class MiddleMarkerClass { } +class PolygonClass { } +class PolygonEditorClass { } +class PolylineClass { } +class PolylineEditorClass { } +class VertexMarkerClass { } \ No newline at end of file From bf24ad882812478d35937c70782624bfe2ac95eb Mon Sep 17 00:00:00 2001 From: Luigi Trabacchin Date: Wed, 14 Oct 2015 20:13:45 +0200 Subject: [PATCH 0073/1238] typeahead: Added support for some of the custom events --- typeahead/typeahead.d.ts | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/typeahead/typeahead.d.ts b/typeahead/typeahead.d.ts index 7ffbe5b509..136f9650bf 100644 --- a/typeahead/typeahead.d.ts +++ b/typeahead/typeahead.d.ts @@ -88,6 +88,41 @@ interface JQuery { * @param datasets One or more datasets passed in as arguments. */ typeahead(options: Twitter.Typeahead.Options, ...datasets: Twitter.Typeahead.Dataset[]): JQuery; + + on(events: "typeahead:active", selector: string, data: any, handler: (ev: JQueryEventObject) => any): JQuery; + on(events: "typeahead:active", selector: string, handler: (ev: JQueryEventObject) => any): JQuery; + on(events: "typeahead:active", handler: (ev: JQueryEventObject) => any): JQuery; + off(events: "typeahead:active", handler: (ev: JQueryEventObject) => any): JQuery; + + on(events: "typeahead:idle", selector: string, data: any, handler: (ev: JQueryEventObject) => any): JQuery; + on(events: "typeahead:idle", selector: string, handler: (ev: JQueryEventObject) => any): JQuery; + on(events: "typeahead:idle", handler: (ev: JQueryEventObject) => any): JQuery; + off(events: "typeahead:idle", handler: (ev: JQueryEventObject) => any): JQuery; + + on(events: "typeahead:open", selector: string, data: any, handler: (ev: JQueryEventObject) => any): JQuery; + on(events: "typeahead:open", selector: string, handler: (ev: JQueryEventObject) => any): JQuery; + on(events: "typeahead:open", handler: (ev: JQueryEventObject) => any): JQuery; + off(events: "typeahead:open", handler: (ev: JQueryEventObject) => any): JQuery; + + on(events: "typeahead:close", selector: string, data: any, handler: (ev: JQueryEventObject) => any): JQuery; + on(events: "typeahead:close", selector: string, handler: (ev: JQueryEventObject) => any): JQuery; + on(events: "typeahead:close", handler: (ev: JQueryEventObject) => any): JQuery; + off(events: "typeahead:close", handler: (ev: JQueryEventObject) => any): JQuery; + + on(events: "typeahead:change", selector: string, data: any, handler: (ev: JQueryEventObject) => any): JQuery; + on(events: "typeahead:change", selector: string, handler: (ev: JQueryEventObject) => any): JQuery; + on(events: "typeahead:change", handler: (ev: JQueryEventObject) => any): JQuery; + off(events: "typeahead:change", handler: (ev: JQueryEventObject) => any): JQuery; + + on(events: "typeahead:render", selector: string, data: any, handler: (ev: JQueryEventObject, suggestions: Array, async: boolean, datasetName: string) => any): JQuery; + on(events: "typeahead:render", selector: string, handler: (ev: JQueryEventObject, suggestions: Array, async: boolean, datasetName: string) => any): JQuery; + on(events: "typeahead:render", handler: (ev: JQueryEventObject, suggestions: Array, async: boolean, datasetName: string) => any): JQuery; + off(events: "typeahead:render", handler: (ev: JQueryEventObject, suggestions: Array, async: boolean, datasetName: string) => any): JQuery; + + on(events: "typeahead:select", selector: string, data: any, handler: (ev: JQueryEventObject, suggestion: any) => any): JQuery; + on(events: "typeahead:select", selector: string, handler: (ev: JQueryEventObject, suggestion: any) => any): JQuery; + on(events: "typeahead:select", handler: (ev: JQueryEventObject, suggestion: any) => any): JQuery; + off(events: "typeahead:select", handler: (ev: JQueryEventObject, suggestion: any) => any): JQuery; } declare module Twitter.Typeahead { From b7257e1d4c9eec50396df8d9759123060e5c8d7c Mon Sep 17 00:00:00 2001 From: Luigi Trabacchin Date: Wed, 14 Oct 2015 20:54:29 +0200 Subject: [PATCH 0074/1238] typeahead: added all the events, tests coming soon --- typeahead/typeahead.d.ts | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/typeahead/typeahead.d.ts b/typeahead/typeahead.d.ts index 136f9650bf..ce401c213b 100644 --- a/typeahead/typeahead.d.ts +++ b/typeahead/typeahead.d.ts @@ -123,6 +123,31 @@ interface JQuery { on(events: "typeahead:select", selector: string, handler: (ev: JQueryEventObject, suggestion: any) => any): JQuery; on(events: "typeahead:select", handler: (ev: JQueryEventObject, suggestion: any) => any): JQuery; off(events: "typeahead:select", handler: (ev: JQueryEventObject, suggestion: any) => any): JQuery; + + on(events: "typeahead:autocomplete", selector: string, data: any, handler: (ev: JQueryEventObject, suggestion: any) => any): JQuery; + on(events: "typeahead:autocomplete", selector: string, handler: (ev: JQueryEventObject, suggestion: any) => any): JQuery; + on(events: "typeahead:autocomplete", handler: (ev: JQueryEventObject, suggestion: any) => any): JQuery; + off(events: "typeahead:autocomplete", handler: (ev: JQueryEventObject, suggestion: any) => any): JQuery; + + on(events: "typeahead:cursorchange", selector: string, data: any, handler: (ev: JQueryEventObject, suggestion: any) => any): JQuery; + on(events: "typeahead:cursorchange", selector: string, handler: (ev: JQueryEventObject, suggestion: any) => any): JQuery; + on(events: "typeahead:cursorchange", handler: (ev: JQueryEventObject, suggestion: any) => any): JQuery; + off(events: "typeahead:cursorchange", handler: (ev: JQueryEventObject, suggestion: any) => any): JQuery; + + on(events: "typeahead:asyncrequest", selector: string, data: any, handler: (ev: JQueryEventObject, query: string, datasetName: string) => any): JQuery; + on(events: "typeahead:asyncrequest", selector: string, handler: (ev: JQueryEventObject, query: string, datasetName: string) => any): JQuery; + on(events: "typeahead:asyncrequest", handler: (ev: JQueryEventObject, query: string, datasetName: string) => any): JQuery; + off(events: "typeahead:asyncrequest", handler: (ev: JQueryEventObject, query: string, datasetName: string) => any): JQuery; + + on(events: "typeahead:asynccancel", selector: string, data: any, handler: (ev: JQueryEventObject, query: string, datasetName: string) => any): JQuery; + on(events: "typeahead:asynccancel", selector: string, handler: (ev: JQueryEventObject, query: string, datasetName: string) => any): JQuery; + on(events: "typeahead:asynccancel", handler: (ev: JQueryEventObject, query: string, datasetName: string) => any): JQuery; + off(events: "typeahead:asynccancel", handler: (ev: JQueryEventObject, query: string, datasetName: string) => any): JQuery; + + on(events: "typeahead:asyncreceive", selector: string, data: any, handler: (ev: JQueryEventObject, query: string, datasetName: string) => any): JQuery; + on(events: "typeahead:asyncreceive", selector: string, handler: (ev: JQueryEventObject, query: string, datasetName: string) => any): JQuery; + on(events: "typeahead:asyncreceive", handler: (ev: JQueryEventObject, query: string, datasetName: string) => any): JQuery; + off(events: "typeahead:asyncreceive", handler: (ev: JQueryEventObject, query: string, datasetName: string) => any): JQuery; } declare module Twitter.Typeahead { From 710bfe47992af4f1a81d7c8b07082c72e750c1b0 Mon Sep 17 00:00:00 2001 From: soycode Date: Wed, 14 Oct 2015 14:20:25 -0700 Subject: [PATCH 0075/1238] update freedom.js pgp interface --- freedom/freedom.d.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/freedom/freedom.d.ts b/freedom/freedom.d.ts index f012c9deab..fa80a530c3 100644 --- a/freedom/freedom.d.ts +++ b/freedom/freedom.d.ts @@ -406,6 +406,12 @@ declare module freedom.PgpProvider { interface PublicKey { key: string; fingerprint: string; + words: string[]; + } + + interface KeyFingerprint { + fingerprint: string; + words: string[]; } interface VerifyDecryptResult { @@ -418,6 +424,7 @@ declare module freedom.PgpProvider { setup(passphrase: string, userid: string): Promise; clear(): Promise; exportKey(): Promise; + getFingerprint(publicKey: string): Promise; signEncrypt(data: ArrayBuffer, encryptKey?: string, sign?: boolean): Promise; verifyDecrypt(data: ArrayBuffer, From c04af9e6ad6aafd0dc041fb0125a1fb8d714ad4d Mon Sep 17 00:00:00 2001 From: Phips Peter Date: Mon, 28 Sep 2015 21:42:20 -0700 Subject: [PATCH 0076/1238] Add benchmark.js This adds the benchmark tests. --- benchmark/benchmark-tests.ts | 237 +++++++++++++++++++++++++++++++++++ benchmark/benchmark.d.ts | 192 ++++++++++++++++++++++++++++ 2 files changed, 429 insertions(+) create mode 100644 benchmark/benchmark-tests.ts create mode 100644 benchmark/benchmark.d.ts diff --git a/benchmark/benchmark-tests.ts b/benchmark/benchmark-tests.ts new file mode 100644 index 0000000000..363e522b0b --- /dev/null +++ b/benchmark/benchmark-tests.ts @@ -0,0 +1,237 @@ +/// +import Benchmark = require("benchmark"); + +var suite = new Benchmark.Suite; + +// add tests +suite.add('RegExp#test', function() { + /o/.test('Hello World!'); +}) +.add('String#indexOf', function() { + 'Hello World!'.indexOf('o') > -1; +}) +.add('String#match', function() { + !!'Hello World!'.match(/o/); +}) +// add listeners +.on('cycle', function(event: {target: any}) { + console.log(String(event.target)); +}) +.on('complete', function() { + console.log('Fastest is ' + this.filter('fastest').pluck('name')); +}) +// run async +.run({ 'async': true }); + +var fn: Function; +var onStart: Function; +var onCycle: Function; +var onAbort: Function; +var onError: Function; +var onReset: Function; +var onComplete: Function; +var setup: Function; +var teardown: Function; +var benches: Benchmark[]; +var listener: Function; +var count: number; + +// basic usage (the `new` operator is optional) +var bench = new Benchmark(fn); + +// or using a name first +var bench = new Benchmark('foo', fn); + +// or with options +var bench = new Benchmark('foo', fn, { + + // displayed by Benchmark#toString if `name` is not available + 'id': 'xyz', + + // called when the benchmark starts running + 'onStart': onStart, + + // called after each run cycle + 'onCycle': onCycle, + + // called when aborted + 'onAbort': onAbort, + + // called when a test errors + 'onError': onError, + + // called when reset + 'onReset': onReset, + + // called when the benchmark completes running + 'onComplete': onComplete, + + // compiled/called before the test loop + 'setup': setup, + + // compiled/called after the test loop + 'teardown': teardown +}); + +// or name and options +var bench = new Benchmark('foo', { + + // a flag to indicate the benchmark is deferred + 'defer': true, + + // benchmark test function + 'fn': function(deferred: {resolve(): void}) { + // call resolve() when the deferred test is finished + deferred.resolve(); + } +}); + +// or options only +var bench = new Benchmark({ + + // benchmark name + 'name': 'foo', + + // benchmark test as a string + 'fn': '[1,2,3,4].sort()' +}); + +// a test’s `this` binding is set to the benchmark instance +var bench = new Benchmark('foo', function() { + 'My name is '.concat(this.name); // My name is foo +}); + +// get odd numbers +Benchmark.filter([1, 2, 3, 4, 5], function(n) { + return n % 2; +}); // -> [1, 3, 5]; + +// get fastest benchmarks +Benchmark.filter(benches, 'fastest'); + +// get slowest benchmarks +Benchmark.filter(benches, 'slowest'); + +// get benchmarks that completed without erroring +Benchmark.filter(benches, 'successful'); + +// invoke `reset` on all benchmarks +Benchmark.invoke(benches, 'reset'); + +// invoke `emit` with arguments +Benchmark.invoke(benches, 'emit', 'complete', listener); + +// invoke `run(true)`, treat benchmarks as a queue, and register invoke callbacks +Benchmark.invoke(benches, { + + // invoke the `run` method + 'name': 'run', + + // pass a single argument + 'args': true, + + // treat as queue, removing benchmarks from front of `benches` until empty + 'queued': true, + + // called before any benchmarks have been invoked. + 'onStart': onStart, + + // called between invoking benchmarks + 'onCycle': onCycle, + + // called after all benchmarks have been invoked. + 'onComplete': onComplete +}); + +var element: HTMLElement; +// basic usage +var bench = new Benchmark({ + 'setup': function() { + var c = this.count, + element = document.getElementById('container'); + while (c--) { + element.appendChild(document.createElement('div')); + } + }, + 'fn': function() { + element.removeChild(element.lastChild); + } +}); + +// or using strings +var bench = new Benchmark({ + 'setup': '\ + var a = 0;\n\ + (function() {\n\ + (function() {\n\ + (function() {', + 'fn': 'a += 1;', + 'teardown': '\ + }())\n\ + }())\n\ + }())' +}); + +var bizarro = bench.clone({ + 'name': 'doppelganger' +}); + +// unregister a listener for an event type +bench.off('cycle', listener); + +// unregister a listener for multiple event types +bench.off('start cycle', listener); + +// unregister all listeners for an event type +bench.off('cycle'); + +// unregister all listeners for multiple event types +bench.off('start cycle complete'); + +// unregister all listeners for all event types +bench.off(); + +// register a listener for an event type +bench.on('cycle', listener); + +// register a listener for multiple event types +bench.on('start cycle', listener); + +// basic usage +bench.run(); + +// or with options +bench.run({ 'async': true }); + +// basic usage +suite.add(fn); + +// or using a name first +suite.add('foo', fn); + +// or with options +suite.add('foo', fn, { + 'onCycle': onCycle, + 'onComplete': onComplete +}); + +// or name and options +suite.add('foo', { + 'fn': fn, + 'onCycle': onCycle, + 'onComplete': onComplete +}); + +// or options only +suite.add({ + 'name': 'foo', + 'fn': fn, + 'onCycle': onCycle, + 'onComplete': onComplete +}); + +// basic usage +suite.run(); + +// or with options +suite.run({ 'async': true, 'queued': true }); diff --git a/benchmark/benchmark.d.ts b/benchmark/benchmark.d.ts new file mode 100644 index 0000000000..3365f335c1 --- /dev/null +++ b/benchmark/benchmark.d.ts @@ -0,0 +1,192 @@ +// Type definitions for Benchmark v1.0.0 +// Project: http://benchmarkjs.com +// Definitions by: Asana +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module "benchmark" { + class Benchmark { + static deepClone(value: T): T; + static each(obj: Object | any[], callback: Function, thisArg?: any): void; + static extend(destination: Object, ...sources: Object[]): Object; + static filter(arr: T[], callback: (value: T) => any, thisArg?: any): T[]; + static filter(arr: T[], filter: string, thisArg?: any): T[]; + static forEach(arr: T[], callback: (value: T) => any, thisArg?: any): void; + static formatNumber(num: number): string; + static forOwn(obj: Object, callback: Function, thisArg?: any): void; + static hasKey(obj: Object, key: string): boolean; + static indexOf(arr: T[], value: T, fromIndex?: number): number; + static interpolate(template: string, values: Object): string; + static invoke(benches: Benchmark[], name: string | Object, ...args: any[]): any[]; + static join(obj: Object, separator1?: string, separator2?: string): string; + static map(arr: T[], callback: (value: T) => K, thisArg?: any): K[]; + static pluck(arr: T[], key: string): K[]; + static reduce(arr: T[], callback: (accumulator: K, value: T) => K, thisArg?: any): K; + + static options: Benchmark.Options; + static platform: Benchmark.Platform; + static support: Benchmark.Support; + static version: string; + + constructor(fn: Function | string, options?: Benchmark.Options); + constructor(name: string, fn: Function | string, options?: Benchmark.Options); + constructor(name: string, options?: Benchmark.Options); + constructor(options: Benchmark.Options); + + aborted: boolean; + compiled: Function | string; + count: number; + cycles: number; + error: Error; + fn: Function | string; + hz: number; + running: boolean; + setup: Function | string; + teardown: Function | string; + + stats: Benchmark.Stats; + times: Benchmark.Times; + + abort(): Benchmark; + clone(options: Benchmark.Options): Benchmark; + compare(benchmark: Benchmark): number; + emit(type: string | Object): any; + listeners(type: string): Function[]; + off(type?: string, listener?: Function): Benchmark; + off(types: string[]): Benchmark; + on(type?: string, listener?: Function): Benchmark; + on(types: string[]): Benchmark; + reset(): Benchmark; + run(options?: Benchmark.Options): Benchmark; + toString(): string; + } + + module Benchmark { + export interface Options { + async?: boolean; + defer?: boolean; + delay?: number; + id?: string; + initCount?: number; + maxTime?: number; + minSamples?: number; + minTime?: number; + name?: string; + onAbort?: Function; + onComplete?: Function; + onCycle?: Function; + onError?: Function; + onReset?: Function; + onStart?: Function; + setup?: Function | string; + teardown?: Function | string; + fn?: Function | string; + queued?: boolean; + } + + export interface Platform { + description: string; + layout: string; + manufacturer: string; + name: string; + os: string; + prerelease: string; + product: string; + version: string; + toString(): string; + } + + export interface Support { + air: boolean; + argumentsClass: boolean; + browser: boolean; + charByIndex: boolean; + charByOwnIndex: boolean; + decompilation: boolean; + descriptors: boolean; + getAllKeys: boolean; + iteratesOwnFirst: boolean; + java: boolean; + nodeClass: boolean; + timeout: boolean; + } + + export interface Stats { + deviation: number; + mean: number; + moe: number; + rme: number; + sample: any[]; + sem: number; + variance: number; + } + + export interface Times { + cycle: number; + elapsed: number; + period: number; + timeStamp: number; + } + + export class Deferred { + constructor(clone: Benchmark); + + benchmark: Benchmark; + cycles: number; + elapsed: number; + timeStamp: number; + } + + export class Event { + constructor(type: string | Object); + + aborted: boolean; + cancelled: boolean; + currentTarget: Object; + result: any; + target: Object; + timeStamp: number; + type: string; + } + + export class Suite { + static options: { name: string }; + + constructor(name?: string, options?: Options); + + aborted: boolean; + length: number; + running: boolean; + abort(): Suite; + add(name: string, fn: Function | string, options?: Options): Suite; + add(fn: Function | string, options?: Options): Suite; + add(name: string, options?: Options): Suite; + add(options: Options): Suite; + clone(options: Options): Suite; + emit(type: string | Object): any; + filter(callback: Function | string): Suite; + forEach(callback: Function): Suite; + indexOf(value: any): number; + invoke(name: string, ...args: any[]): any[]; + join(separator?: string): string; + listeners(type: string): Function[]; + map(callback: Function): any[]; + off(type?: string, callback?: Function): Benchmark; + off(types: string[]): Benchmark; + on(type?: string, callback?: Function): Benchmark; + on(types: string[]): Benchmark; + pluck(property: string): any[]; + pop(): Function; + push(benchmark: Benchmark): number; + reduce(callback: Function, accumulator: T): T; + reset(): Suite; + reverse(): any[]; + run(options?: Options): Suite; + shift(): Benchmark; + slice(start: number, end: number): any[]; + slice(start: number, deleteCount: number, ...values: any[]): any[]; + unshift(benchmark: Benchmark): number; + } + } + + export = Benchmark; +} From 77b2f7e8d49399d29f751a066ae13da17f46facc Mon Sep 17 00:00:00 2001 From: James Brantly Date: Thu, 8 Oct 2015 00:31:51 -0400 Subject: [PATCH 0077/1238] Initial React v0.14 definitions --- react/README.md | 8 +- react/react-addons-clone-with-props.d.ts | 18 + react/react-addons-create-fragment.d.ts | 16 + react/react-addons-css-transition-group.d.ts | 25 + react/react-addons-linked-state-mixin.d.ts | 24 + react/react-addons-perf.d.ts | 46 + react/react-addons-pure-render-mixin.d.ts | 17 + react/react-addons-test-utils.d.ts | 154 +++ react/react-addons-transition-group.d.ts | 22 + react/react-addons-update.d.ts | 35 + react/react-dom.d.ts | 71 ++ react/react-global.d.ts | 325 +---- react/react.d.ts | 1107 +----------------- 13 files changed, 486 insertions(+), 1382 deletions(-) create mode 100644 react/react-addons-clone-with-props.d.ts create mode 100644 react/react-addons-create-fragment.d.ts create mode 100644 react/react-addons-css-transition-group.d.ts create mode 100644 react/react-addons-linked-state-mixin.d.ts create mode 100644 react/react-addons-perf.d.ts create mode 100644 react/react-addons-pure-render-mixin.d.ts create mode 100644 react/react-addons-test-utils.d.ts create mode 100644 react/react-addons-transition-group.d.ts create mode 100644 react/react-addons-update.d.ts create mode 100644 react/react-dom.d.ts diff --git a/react/README.md b/react/README.md index b7ff4b55e6..eed63fcb32 100644 --- a/react/README.md +++ b/react/README.md @@ -1,5 +1,5 @@ -# React v0.13.3 Type Definitions +# React v0.14 Type Definitions -This folder contains the following `.d.ts` files: -* `react.d.ts` declares the module `"react"` and `"react/addons"` -* `react-global.d.ts` declares the global namespace `React` (only include this if you are actually using the global `React`) +If you are using modules you should use `react.d.ts`, `react-dom.d.ts` and any of the `react-addon-*.d.ts` definition files. + +If you are using the global `React` variable, you should use `react-global.d.ts`. diff --git a/react/react-addons-clone-with-props.d.ts b/react/react-addons-clone-with-props.d.ts new file mode 100644 index 0000000000..137c6650c7 --- /dev/null +++ b/react/react-addons-clone-with-props.d.ts @@ -0,0 +1,18 @@ +// Type definitions for React v0.14 (react-addons-clone-with-props) +// Project: http://facebook.github.io/react/ +// Definitions by: Asana , AssureSign , Microsoft +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare namespace __React { + namespace __Addons { + export function cloneWithProps

(element: __React.DOMElement

, props: P): __React.DOMElement

; + export function cloneWithProps

(element: __React.ClassicElement

, props: P): __React.ClassicElement

; + export function cloneWithProps

(element: __React.ReactElement

, props: P): __React.ReactElement

; + } +} + +declare module "react-addons-clone-with-props" { + export = __React.__Addons.cloneWithProps; +} diff --git a/react/react-addons-create-fragment.d.ts b/react/react-addons-create-fragment.d.ts new file mode 100644 index 0000000000..b2332eae1e --- /dev/null +++ b/react/react-addons-create-fragment.d.ts @@ -0,0 +1,16 @@ +// Type definitions for React v0.14 (react-addons-create-fragment) +// Project: http://facebook.github.io/react/ +// Definitions by: Asana , AssureSign , Microsoft +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare namespace __React { + namespace __Addons { + export function createFragment(object: { [key: string]: ReactNode }): ReactFragment; + } +} + +declare module "react-addons-create-fragment" { + export = __React.__Addons.createFragment; +} diff --git a/react/react-addons-css-transition-group.d.ts b/react/react-addons-css-transition-group.d.ts new file mode 100644 index 0000000000..99db1f4f46 --- /dev/null +++ b/react/react-addons-css-transition-group.d.ts @@ -0,0 +1,25 @@ +// Type definitions for React v0.14 (react-addons-css-transition-group) +// Project: http://facebook.github.io/react/ +// Definitions by: Asana , AssureSign , Microsoft +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// +/// + +declare namespace __React { + namespace __Addons { + interface CSSTransitionGroupProps extends TransitionGroupProps { + transitionName: string; + transitionAppear?: boolean; + transitionEnter?: boolean; + transitionLeave?: boolean; + } + + type CSSTransitionGroup = ComponentClass; + } +} + +declare module "react-addons-css-transition-group" { + var CSSTransitionGroup: __React.__Addons.CSSTransitionGroup; + export = CSSTransitionGroup; +} diff --git a/react/react-addons-linked-state-mixin.d.ts b/react/react-addons-linked-state-mixin.d.ts new file mode 100644 index 0000000000..a98caa3847 --- /dev/null +++ b/react/react-addons-linked-state-mixin.d.ts @@ -0,0 +1,24 @@ +// Type definitions for React v0.14 (react-addons-linked-state-mixin) +// Project: http://facebook.github.io/react/ +// Definitions by: Asana , AssureSign , Microsoft +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare namespace __React { + namespace __Addons { + interface ReactLink { + value: T; + requestChange(newValue: T): void; + } + + interface LinkedStateMixin extends Mixin { + linkState(key: string): ReactLink; + } + } +} + +declare module "react-addons-linked-state-mixin" { + var LinkedStateMixin: __React.__Addons.LinkedStateMixin; + export = LinkedStateMixin; +} diff --git a/react/react-addons-perf.d.ts b/react/react-addons-perf.d.ts new file mode 100644 index 0000000000..7ca369db8b --- /dev/null +++ b/react/react-addons-perf.d.ts @@ -0,0 +1,46 @@ +// Type definitions for React v0.14 (react-addons-perf) +// Project: http://facebook.github.io/react/ +// Definitions by: Asana , AssureSign , Microsoft +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare namespace __React { + namespace __Addons { + interface ComponentPerfContext { + current: string; + owner: string; + } + + interface NumericPerfContext { + [key: string]: number; + } + + interface Measurements { + exclusive: NumericPerfContext; + inclusive: NumericPerfContext; + render: NumericPerfContext; + counts: NumericPerfContext; + writes: NumericPerfContext; + displayNames: { + [key: string]: ComponentPerfContext; + }; + totalTime: number; + } + + namespace Perf { + export function start(): void; + export function stop(): void; + export function printInclusive(measurements: Measurements[]): void; + export function printExclusive(measurements: Measurements[]): void; + export function printWasted(measurements: Measurements[]): void; + export function printDOM(measurements: Measurements[]): void; + export function getLastMeasurements(): Measurements[]; + } + } +} + +declare module "react-addons-perf" { + import Perf = __React.__Addons.Perf; + export = Perf; +} diff --git a/react/react-addons-pure-render-mixin.d.ts b/react/react-addons-pure-render-mixin.d.ts new file mode 100644 index 0000000000..741046d907 --- /dev/null +++ b/react/react-addons-pure-render-mixin.d.ts @@ -0,0 +1,17 @@ +// Type definitions for React v0.14 (react-addons-pure-render-mixin) +// Project: http://facebook.github.io/react/ +// Definitions by: Asana , AssureSign , Microsoft +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare namespace __React { + namespace __Addons { + interface PureRenderMixin extends Mixin {} + } +} + +declare module "react-addons-pure-render-mixin" { + var PureRenderMixin: __React.__Addons.PureRenderMixin; + export = PureRenderMixin; +} diff --git a/react/react-addons-test-utils.d.ts b/react/react-addons-test-utils.d.ts new file mode 100644 index 0000000000..13f4336573 --- /dev/null +++ b/react/react-addons-test-utils.d.ts @@ -0,0 +1,154 @@ +// Type definitions for React v0.14 (react-addons-test-utils) +// Project: http://facebook.github.io/react/ +// Definitions by: Asana , AssureSign , Microsoft +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare namespace __React { + namespace __Addons { + interface SyntheticEventData { + altKey?: boolean; + button?: number; + buttons?: number; + clientX?: number; + clientY?: number; + changedTouches?: TouchList; + charCode?: boolean; + clipboardData?: DataTransfer; + ctrlKey?: boolean; + deltaMode?: number; + deltaX?: number; + deltaY?: number; + deltaZ?: number; + detail?: number; + getModifierState?(key: string): boolean; + key?: string; + keyCode?: number; + locale?: string; + location?: number; + metaKey?: boolean; + pageX?: number; + pageY?: number; + relatedTarget?: EventTarget; + repeat?: boolean; + screenX?: number; + screenY?: number; + shiftKey?: boolean; + targetTouches?: TouchList; + touches?: TouchList; + view?: AbstractView; + which?: number; + } + + interface EventSimulator { + (element: Element, eventData?: SyntheticEventData): void; + (component: Component, eventData?: SyntheticEventData): void; + } + + interface MockedComponentClass { + new(): any; + } + + class ShallowRenderer { + getRenderOutput>(): E; + getRenderOutput(): ReactElement; + render(element: ReactElement, context?: any): void; + unmount(): void; + } + + namespace TestUtils { + namespace Simulate { + export var blur: EventSimulator; + export var change: EventSimulator; + export var click: EventSimulator; + export var cut: EventSimulator; + export var doubleClick: EventSimulator; + export var drag: EventSimulator; + export var dragEnd: EventSimulator; + export var dragEnter: EventSimulator; + export var dragExit: EventSimulator; + export var dragLeave: EventSimulator; + export var dragOver: EventSimulator; + export var dragStart: EventSimulator; + export var drop: EventSimulator; + export var focus: EventSimulator; + export var input: EventSimulator; + export var keyDown: EventSimulator; + export var keyPress: EventSimulator; + export var keyUp: EventSimulator; + export var mouseDown: EventSimulator; + export var mouseEnter: EventSimulator; + export var mouseLeave: EventSimulator; + export var mouseMove: EventSimulator; + export var mouseOut: EventSimulator; + export var mouseOver: EventSimulator; + export var mouseUp: EventSimulator; + export var paste: EventSimulator; + export var scroll: EventSimulator; + export var submit: EventSimulator; + export var touchCancel: EventSimulator; + export var touchEnd: EventSimulator; + export var touchMove: EventSimulator; + export var touchStart: EventSimulator; + export var wheel: EventSimulator; + } + + export function renderIntoDocument

( + element: ReactElement

): Component; + export function renderIntoDocument>( + element: ReactElement): C; + + export function mockComponent( + mocked: MockedComponentClass, mockTagName?: string): typeof TestUtils; + + export function isElementOfType( + element: ReactElement, type: ReactType): boolean; + export function isTextComponent(instance: Component): boolean; + export function isDOMComponent(instance: Component): boolean; + export function isCompositeComponent(instance: Component): boolean; + export function isCompositeComponentWithType( + instance: Component, + type: ComponentClass): boolean; + + export function findAllInRenderedTree( + tree: Component, + fn: (i: Component) => boolean): Component; + + export function scryRenderedDOMComponentsWithClass( + tree: Component, + className: string): DOMComponent[]; + export function findRenderedDOMComponentWithClass( + tree: Component, + className: string): DOMComponent; + + export function scryRenderedDOMComponentsWithTag( + tree: Component, + tagName: string): DOMComponent[]; + export function findRenderedDOMComponentWithTag( + tree: Component, + tagName: string): DOMComponent; + + export function scryRenderedComponentsWithType

( + tree: Component, + type: ComponentClass

): Component[]; + export function scryRenderedComponentsWithType>( + tree: Component, + type: ComponentClass): C[]; + + export function findRenderedComponentWithType

( + tree: Component, + type: ComponentClass

): Component; + export function findRenderedComponentWithType>( + tree: Component, + type: ComponentClass): C; + + export function createRenderer(): ShallowRenderer; + } + } +} + +declare module "react-addons-test-utils" { + import TestUtils = __React.__Addons.TestUtils; + export = TestUtils; +} diff --git a/react/react-addons-transition-group.d.ts b/react/react-addons-transition-group.d.ts new file mode 100644 index 0000000000..376bebd51b --- /dev/null +++ b/react/react-addons-transition-group.d.ts @@ -0,0 +1,22 @@ +// Type definitions for React v0.14 (react-addons-transition-group) +// Project: http://facebook.github.io/react/ +// Definitions by: Asana , AssureSign , Microsoft +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare namespace __React { + namespace __Addons { + interface TransitionGroupProps { + component?: ReactType; + childFactory?: (child: ReactElement) => ReactElement; + } + + type TransitionGroup = ComponentClass; + } +} + +declare module "react-addons-transition-group" { + var TransitionGroup: __React.__Addons.TransitionGroup; + export = TransitionGroup; +} \ No newline at end of file diff --git a/react/react-addons-update.d.ts b/react/react-addons-update.d.ts new file mode 100644 index 0000000000..ece9e87c7a --- /dev/null +++ b/react/react-addons-update.d.ts @@ -0,0 +1,35 @@ +// Type definitions for React v0.14 (react-addons-update) +// Project: http://facebook.github.io/react/ +// Definitions by: Asana , AssureSign , Microsoft +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare namespace __React { + namespace __Addons { + interface UpdateSpecCommand { + $set?: any; + $merge?: {}; + $apply?(value: any): any; + } + + interface UpdateSpecPath { + [key: string]: UpdateSpec; + } + + type UpdateSpec = UpdateSpecCommand | UpdateSpecPath; + + interface UpdateArraySpec extends UpdateSpecCommand { + $push?: any[]; + $unshift?: any[]; + $splice?: any[][]; + } + + export function update(value: any[], spec: UpdateArraySpec): any[]; + export function update(value: {}, spec: UpdateSpec): any; + } +} + +declare module "react-addons-update" { + export = __React.__Addons.update; +} diff --git a/react/react-dom.d.ts b/react/react-dom.d.ts new file mode 100644 index 0000000000..e0d88e04ba --- /dev/null +++ b/react/react-dom.d.ts @@ -0,0 +1,71 @@ +// Type definitions for React v0.14 (react-dom) +// Project: http://facebook.github.io/react/ +// Definitions by: Asana , AssureSign , Microsoft +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare namespace __React { + + module __DOM { + function findDOMNode( + componentOrElement: __React.Component | Element): TElement; + function findDOMNode( + componentOrElement: __React.Component | Element): Element; + + function render

( + element: DOMElement

, + container: Element, + callback?: () => any): DOMComponent

; + function render( + element: ClassicElement

, + container: Element, + callback?: () => any): ClassicComponent; + function render( + element: ReactElement

, + container: Element, + callback?: () => any): Component; + + function unmountComponentAtNode(container: Element): boolean; + + var version: string; + + function unstable_batchedUpdates(callback: (a: A, b: B) => any, a: A, b: B): void; + function unstable_batchedUpdates(callback: (a: A) => any, a: A): void; + function unstable_batchedUpdates(callback: () => any): void; + + function unstable_renderSubtreeIntoContainer

( + parentComponent: Component, + nextElement: DOMElement

, + container: Element, + callback?: (component: DOMComponent

) => any): DOMComponent

; + function unstable_renderSubtreeIntoContainer( + parentComponent: Component, + nextElement: ClassicElement

, + container: Element, + callback?: (component: ClassicComponent) => any): ClassicComponent; + function unstable_renderSubtreeIntoContainer( + parentComponent: Component, + nextElement: ReactElement

, + container: Element, + callback?: (component: Component) => any): Component; + + + } + + namespace __DOMServer { + function renderToString(element: ReactElement): string; + function renderToStaticMarkup(element: ReactElement): string; + var version: string; + } +} + +declare module "react-dom" { + import DOM = __React.__DOM; + export = DOM; +} + +declare module "react-dom/server" { + import DOMServer = __React.__DOMServer; + export = DOMServer; +} diff --git a/react/react-global.d.ts b/react/react-global.d.ts index 1728ba2fc8..4de0a8eed2 100644 --- a/react/react-global.d.ts +++ b/react/react-global.d.ts @@ -1,285 +1,66 @@ -// Type definitions for React v0.13.3 (namespace) +// Type definitions for React v0.14 (namespace) // Project: http://facebook.github.io/react/ // Definitions by: Asana , AssureSign , Microsoft // Definitions: https://github.com/borisyankov/DefinitelyTyped /// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// import React = __React; +import ReactDOM = __React.__DOM; declare namespace __React { - // - // React.addons - // ---------------------------------------------------------------------- - - export module addons { - export var CSSTransitionGroup: CSSTransitionGroup; - export var TransitionGroup: TransitionGroup; - - export var LinkedStateMixin: LinkedStateMixin; - export var PureRenderMixin: PureRenderMixin; - - export function batchedUpdates( - callback: (a: A, b: B) => any, a: A, b: B): void; - export function batchedUpdates(callback: (a: A) => any, a: A): void; - export function batchedUpdates(callback: () => any): void; - - // deprecated: use petehunt/react-classset or JedWatson/classnames - export function classSet(cx: { [key: string]: boolean }): string; - export function classSet(...classList: string[]): string; - - export function cloneWithProps

( - element: DOMElement

, props: P): DOMElement

; - export function cloneWithProps

( - element: ClassicElement

, props: P): ClassicElement

; - export function cloneWithProps

( - element: ReactElement

, props: P): ReactElement

; - - export function createFragment( - object: { [key: string]: ReactNode }): ReactFragment; - - export function update(value: any[], spec: UpdateArraySpec): any[]; - export function update(value: {}, spec: UpdateSpec): any; - - // Development tools - export import Perf = ReactPerf; - export import TestUtils = ReactTestUtils; + namespace addons { + export var TransitionGroup: __React.__Addons.TransitionGroup; + export var CSSTransitionGroup: __React.__Addons.CSSTransitionGroup; + + export var LinkedStateMixin: __React.__Addons.LinkedStateMixin; + export var PureRenderMixin: __React.__Addons.PureRenderMixin; + + export import cloneWithProps = __React.__Addons.cloneWithProps; + export import createFragment = __React.__Addons.createFragment; + export import update = __React.__Addons.update; + + export import Perf = __React.__Addons.Perf; + export import TestUtils = __React.__Addons.TestUtils; } - // - // React.addons (Transitions) - // ---------------------------------------------------------------------- + // TransitionGroup types + export import TransitionGroupProps = __React.__Addons.TransitionGroupProps; + export import TransitionGroup = __React.__Addons.TransitionGroup; + export import CSSTransitionGroupProps = __React.__Addons.CSSTransitionGroupProps; + export import CSSTransitionGroup = __React.__Addons.CSSTransitionGroup; + + // LinkedStateMixin types + export import ReactLink = __React.__Addons.ReactLink; + export import LinkedStateMixin = __React.__Addons.LinkedStateMixin; + + // PureRenderMixin types + export import PureRenderMixin = __React.__Addons.PureRenderMixin; + + // update types + export import UpdateSpecCommand = __React.__Addons.UpdateSpecCommand; + export import UpdateSpecPath = __React.__Addons.UpdateSpecPath; + export import UpdateSpec = __React.__Addons.UpdateSpec; + export import UpdateArraySpec = __React.__Addons.UpdateArraySpec; - interface TransitionGroupProps { - component?: ReactType; - childFactory?: (child: ReactElement) => ReactElement; - } - - interface CSSTransitionGroupProps extends TransitionGroupProps { - transitionName: string; - transitionAppear?: boolean; - transitionEnter?: boolean; - transitionLeave?: boolean; - } - - type CSSTransitionGroup = ComponentClass; - type TransitionGroup = ComponentClass; - - // - // React.addons (Mixins) - // ---------------------------------------------------------------------- - - interface ReactLink { - value: T; - requestChange(newValue: T): void; - } - - interface LinkedStateMixin extends Mixin { - linkState(key: string): ReactLink; - } - - interface PureRenderMixin extends Mixin { - } - - // - // Reat.addons.update - // ---------------------------------------------------------------------- - - interface UpdateSpecCommand { - $set?: any; - $merge?: {}; - $apply?(value: any): any; - } - - interface UpdateSpecPath { - [key: string]: UpdateSpec; - } - - type UpdateSpec = UpdateSpecCommand | UpdateSpecPath; - - interface UpdateArraySpec extends UpdateSpecCommand { - $push?: any[]; - $unshift?: any[]; - $splice?: any[][]; - } - - // - // React.addons.Perf - // ---------------------------------------------------------------------- - - interface ComponentPerfContext { - current: string; - owner: string; - } - - interface NumericPerfContext { - [key: string]: number; - } - - interface Measurements { - exclusive: NumericPerfContext; - inclusive: NumericPerfContext; - render: NumericPerfContext; - counts: NumericPerfContext; - writes: NumericPerfContext; - displayNames: { - [key: string]: ComponentPerfContext; - }; - totalTime: number; - } - - module ReactPerf { - export function start(): void; - export function stop(): void; - export function printInclusive(measurements: Measurements[]): void; - export function printExclusive(measurements: Measurements[]): void; - export function printWasted(measurements: Measurements[]): void; - export function printDOM(measurements: Measurements[]): void; - export function getLastMeasurements(): Measurements[]; - } - - // - // React.addons.TestUtils - // ---------------------------------------------------------------------- - - interface MockedComponentClass { - new(): any; - } - - module ReactTestUtils { - export import Simulate = ReactSimulate; - - export function renderIntoDocument

( - element: ReactElement

): Component; - export function renderIntoDocument>( - element: ReactElement): C; - - export function mockComponent( - mocked: MockedComponentClass, mockTagName?: string): typeof ReactTestUtils; - - export function isElementOfType( - element: ReactElement, type: ReactType): boolean; - export function isTextComponent(instance: Component): boolean; - export function isDOMComponent(instance: Component): boolean; - export function isCompositeComponent(instance: Component): boolean; - export function isCompositeComponentWithType( - instance: Component, - type: ComponentClass): boolean; - - export function findAllInRenderedTree( - tree: Component, - fn: (i: Component) => boolean): Component; - - export function scryRenderedDOMComponentsWithClass( - tree: Component, - className: string): DOMComponent[]; - export function findRenderedDOMComponentWithClass( - tree: Component, - className: string): DOMComponent; - - export function scryRenderedDOMComponentsWithTag( - tree: Component, - tagName: string): DOMComponent[]; - export function findRenderedDOMComponentWithTag( - tree: Component, - tagName: string): DOMComponent; - - export function scryRenderedComponentsWithType

( - tree: Component, - type: ComponentClass

): Component[]; - export function scryRenderedComponentsWithType>( - tree: Component, - type: ComponentClass): C[]; - - export function findRenderedComponentWithType

( - tree: Component, - type: ComponentClass

): Component; - export function findRenderedComponentWithType>( - tree: Component, - type: ComponentClass): C; - - export function createRenderer(): ShallowRenderer; - } - - interface SyntheticEventData { - altKey?: boolean; - button?: number; - buttons?: number; - clientX?: number; - clientY?: number; - changedTouches?: TouchList; - charCode?: boolean; - clipboardData?: DataTransfer; - ctrlKey?: boolean; - deltaMode?: number; - deltaX?: number; - deltaY?: number; - deltaZ?: number; - detail?: number; - getModifierState?(key: string): boolean; - key?: string; - keyCode?: number; - locale?: string; - location?: number; - metaKey?: boolean; - pageX?: number; - pageY?: number; - relatedTarget?: EventTarget; - repeat?: boolean; - screenX?: number; - screenY?: number; - shiftKey?: boolean; - targetTouches?: TouchList; - touches?: TouchList; - view?: AbstractView; - which?: number; - } - - interface EventSimulator { - (element: Element, eventData?: SyntheticEventData): void; - (component: Component, eventData?: SyntheticEventData): void; - } - - module ReactSimulate { - export var blur: EventSimulator; - export var change: EventSimulator; - export var click: EventSimulator; - export var cut: EventSimulator; - export var doubleClick: EventSimulator; - export var drag: EventSimulator; - export var dragEnd: EventSimulator; - export var dragEnter: EventSimulator; - export var dragExit: EventSimulator; - export var dragLeave: EventSimulator; - export var dragOver: EventSimulator; - export var dragStart: EventSimulator; - export var drop: EventSimulator; - export var focus: EventSimulator; - export var input: EventSimulator; - export var keyDown: EventSimulator; - export var keyPress: EventSimulator; - export var keyUp: EventSimulator; - export var mouseDown: EventSimulator; - export var mouseEnter: EventSimulator; - export var mouseLeave: EventSimulator; - export var mouseMove: EventSimulator; - export var mouseOut: EventSimulator; - export var mouseOver: EventSimulator; - export var mouseUp: EventSimulator; - export var paste: EventSimulator; - export var scroll: EventSimulator; - export var submit: EventSimulator; - export var touchCancel: EventSimulator; - export var touchEnd: EventSimulator; - export var touchMove: EventSimulator; - export var touchStart: EventSimulator; - export var wheel: EventSimulator; - } - - class ShallowRenderer { - getRenderOutput>(): E; - getRenderOutput(): ReactElement; - render(element: ReactElement, context?: any): void; - unmount(): void; - } + // Perf types + export import ComponentPerfContext = __React.__Addons.ComponentPerfContext; + export import NumericPerfContext = __React.__Addons.NumericPerfContext; + export import Measurements = __React.__Addons.Measurements; + + // TestUtil types + export import SyntheticEventData = __React.__Addons.SyntheticEventData; + export import EventSimulator = __React.__Addons.EventSimulator; + export import MockedComponentClass = __React.__Addons.MockedComponentClass; + export import ShallowRenderer = __React.__Addons.ShallowRenderer; } diff --git a/react/react.d.ts b/react/react.d.ts index de8ba67327..b096028382 100644 --- a/react/react.d.ts +++ b/react/react.d.ts @@ -1,4 +1,4 @@ -// Type definitions for React v0.13.3 +// Type definitions for React v0.14 // Project: http://facebook.github.io/react/ // Definitions by: Asana , AssureSign , Microsoft // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -98,29 +98,7 @@ declare namespace __React { props?: P, ...children: ReactNode[]): ReactElement

; - function render

( - element: DOMElement

, - container: Element, - callback?: () => any): DOMComponent

; - function render( - element: ClassicElement

, - container: Element, - callback?: () => any): ClassicComponent; - function render( - element: ReactElement

, - container: Element, - callback?: () => any): Component; - - function unmountComponentAtNode(container: Element): boolean; - function renderToString(element: ReactElement): string; - function renderToStaticMarkup(element: ReactElement): string; function isValidElement(object: {}): boolean; - function initializeTouchEvents(shouldUseTouch: boolean): void; - - function findDOMNode( - componentOrElement: Component | Element): TElement; - function findDOMNode( - componentOrElement: Component | Element): Element; var DOM: ReactDOM; var PropTypes: ReactPropTypes; @@ -152,12 +130,8 @@ declare namespace __React { interface ClassicComponent extends Component { replaceState(nextState: S, callback?: () => any): void; - getDOMNode(): TElement; - getDOMNode(): Element; isMounted(): boolean; getInitialState?(): S; - setProps(nextProps: P, callback?: () => any): void; - replaceProps(nextProps: P, callback?: () => any): void; } interface DOMComponent

extends ClassicComponent { @@ -812,1085 +786,6 @@ declare module "react" { export = __React; } -declare module "react/addons" { - // - // React Elements - // ---------------------------------------------------------------------- - - type ReactType = ComponentClass | string; - - interface ReactElement

{ - type: string | ComponentClass

; - props: P; - key: string | number; - ref: string | ((component: Component) => any); - } - - interface ClassicElement

extends ReactElement

{ - type: string | ClassicComponentClass

; - ref: string | ((component: ClassicComponent) => any); - } - - interface DOMElement

extends ClassicElement

{ - type: string; - ref: string | ((component: DOMComponent

) => any); - } - - type HTMLElement = DOMElement; - type SVGElement = DOMElement; - - // - // Factories - // ---------------------------------------------------------------------- - - interface Factory

{ - (props?: P, ...children: ReactNode[]): ReactElement

; - } - - interface ClassicFactory

extends Factory

{ - (props?: P, ...children: ReactNode[]): ClassicElement

; - } - - interface DOMFactory

extends ClassicFactory

{ - (props?: P, ...children: ReactNode[]): DOMElement

; - } - - type HTMLFactory = DOMFactory; - type SVGFactory = DOMFactory; - type SVGElementFactory = DOMFactory; - - // - // React Nodes - // http://facebook.github.io/react/docs/glossary.html - // ---------------------------------------------------------------------- - - type ReactText = string | number; - type ReactChild = ReactElement | ReactText; - - // Should be Array but type aliases cannot be recursive - type ReactFragment = {} | Array; - type ReactNode = ReactChild | ReactFragment | boolean; - - // - // Top Level API - // ---------------------------------------------------------------------- - - function createClass(spec: ComponentSpec): ClassicComponentClass

; - - function createFactory

(type: string): DOMFactory

; - function createFactory

(type: ClassicComponentClass

| string): ClassicFactory

; - function createFactory

(type: ComponentClass

): Factory

; - - function createElement

( - type: string, - props?: P, - ...children: ReactNode[]): DOMElement

; - function createElement

( - type: ClassicComponentClass

| string, - props?: P, - ...children: ReactNode[]): ClassicElement

; - function createElement

( - type: ComponentClass

, - props?: P, - ...children: ReactNode[]): ReactElement

; - - function cloneElement

( - element: DOMElement

, - props?: P, - ...children: ReactNode[]): DOMElement

; - function cloneElement

( - element: ClassicElement

, - props?: P, - ...children: ReactNode[]): ClassicElement

; - function cloneElement

( - element: ReactElement

, - props?: P, - ...children: ReactNode[]): ReactElement

; - - function render

( - element: DOMElement

, - container: Element, - callback?: () => any): DOMComponent

; - function render( - element: ClassicElement

, - container: Element, - callback?: () => any): ClassicComponent; - function render( - element: ReactElement

, - container: Element, - callback?: () => any): Component; - - function unmountComponentAtNode(container: Element): boolean; - function renderToString(element: ReactElement): string; - function renderToStaticMarkup(element: ReactElement): string; - function isValidElement(object: {}): boolean; - function initializeTouchEvents(shouldUseTouch: boolean): void; - - function findDOMNode( - componentOrElement: Component | Element): TElement; - function findDOMNode( - componentOrElement: Component | Element): Element; - - var DOM: ReactDOM; - var PropTypes: ReactPropTypes; - var Children: ReactChildren; - - // - // Component API - // ---------------------------------------------------------------------- - - // 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; - forceUpdate(callBack?: () => any): void; - render(): JSX.Element; - props: P; - state: S; - context: {}; - refs: { - [key: string]: Component - }; - } - - interface ClassicComponent extends Component { - replaceState(nextState: S, callback?: () => any): void; - getDOMNode(): TElement; - getDOMNode(): Element; - isMounted(): boolean; - getInitialState?(): S; - setProps(nextProps: P, callback?: () => any): void; - replaceProps(nextProps: P, callback?: () => any): void; - } - - interface DOMComponent

extends ClassicComponent { - tagName: string; - } - - type HTMLComponent = DOMComponent; - type SVGComponent = DOMComponent; - - interface ChildContextProvider { - getChildContext(): CC; - } - - // - // Class Interfaces - // ---------------------------------------------------------------------- - - interface ComponentClass

{ - new(props?: P, context?: any): Component; - propTypes?: ValidationMap

; - contextTypes?: ValidationMap; - childContextTypes?: ValidationMap; - defaultProps?: P; - } - - interface ClassicComponentClass

extends ComponentClass

{ - new(props?: P, context?: any): ClassicComponent; - getDefaultProps?(): P; - displayName?: string; - } - - // - // Component Specs and Lifecycle - // ---------------------------------------------------------------------- - - interface ComponentLifecycle { - componentWillMount?(): void; - componentDidMount?(): void; - componentWillReceiveProps?(nextProps: P, nextContext: any): void; - shouldComponentUpdate?(nextProps: P, nextState: S, nextContext: any): boolean; - componentWillUpdate?(nextProps: P, nextState: S, nextContext: any): void; - componentDidUpdate?(prevProps: P, prevState: S, prevContext: any): void; - componentWillUnmount?(): void; - } - - interface Mixin extends ComponentLifecycle { - mixins?: Mixin; - statics?: { - [key: string]: any; - }; - - displayName?: string; - propTypes?: ValidationMap; - contextTypes?: ValidationMap; - childContextTypes?: ValidationMap - - getDefaultProps?(): P; - getInitialState?(): S; - } - - interface ComponentSpec extends Mixin { - render(): ReactElement; - - [propertyName: string]: any; - } - - // - // Event System - // ---------------------------------------------------------------------- - - interface SyntheticEvent { - bubbles: boolean; - cancelable: boolean; - currentTarget: EventTarget; - defaultPrevented: boolean; - eventPhase: number; - isTrusted: boolean; - nativeEvent: Event; - preventDefault(): void; - stopPropagation(): void; - target: EventTarget; - timeStamp: Date; - type: string; - } - - interface DragEvent extends SyntheticEvent { - dataTransfer: DataTransfer; - } - - interface ClipboardEvent extends SyntheticEvent { - clipboardData: DataTransfer; - } - - interface KeyboardEvent extends SyntheticEvent { - altKey: boolean; - charCode: number; - ctrlKey: boolean; - getModifierState(key: string): boolean; - key: string; - keyCode: number; - locale: string; - location: number; - metaKey: boolean; - repeat: boolean; - shiftKey: boolean; - which: number; - } - - interface FocusEvent extends SyntheticEvent { - relatedTarget: EventTarget; - } - - interface FormEvent extends SyntheticEvent { - } - - interface MouseEvent extends SyntheticEvent { - altKey: boolean; - button: number; - buttons: number; - clientX: number; - clientY: number; - ctrlKey: boolean; - getModifierState(key: string): boolean; - metaKey: boolean; - pageX: number; - pageY: number; - relatedTarget: EventTarget; - screenX: number; - screenY: number; - shiftKey: boolean; - } - - interface TouchEvent extends SyntheticEvent { - altKey: boolean; - changedTouches: TouchList; - ctrlKey: boolean; - getModifierState(key: string): boolean; - metaKey: boolean; - shiftKey: boolean; - targetTouches: TouchList; - touches: TouchList; - } - - interface UIEvent extends SyntheticEvent { - detail: number; - view: AbstractView; - } - - interface WheelEvent extends SyntheticEvent { - deltaMode: number; - deltaX: number; - deltaY: number; - deltaZ: number; - } - - // - // Event Handler Types - // ---------------------------------------------------------------------- - - interface EventHandler { - (event: E): void; - } - - interface DragEventHandler extends EventHandler {} - interface ClipboardEventHandler extends EventHandler {} - interface KeyboardEventHandler extends EventHandler {} - interface FocusEventHandler extends EventHandler {} - interface FormEventHandler extends EventHandler {} - interface MouseEventHandler extends EventHandler {} - interface TouchEventHandler extends EventHandler {} - interface UIEventHandler extends EventHandler {} - interface WheelEventHandler extends EventHandler {} - - // - // Props / DOM Attributes - // ---------------------------------------------------------------------- - - interface Props { - children?: ReactNode; - key?: string | number; - ref?: string | ((component: T) => any); - } - - interface DOMAttributesBase extends Props { - onCopy?: ClipboardEventHandler; - onCut?: ClipboardEventHandler; - onPaste?: ClipboardEventHandler; - onKeyDown?: KeyboardEventHandler; - onKeyPress?: KeyboardEventHandler; - onKeyUp?: KeyboardEventHandler; - onFocus?: FocusEventHandler; - onBlur?: FocusEventHandler; - onChange?: FormEventHandler; - onInput?: FormEventHandler; - onSubmit?: FormEventHandler; - onClick?: MouseEventHandler; - onDoubleClick?: MouseEventHandler; - onDrag?: DragEventHandler; - onDragEnd?: DragEventHandler; - onDragEnter?: DragEventHandler; - onDragExit?: DragEventHandler; - onDragLeave?: DragEventHandler; - onDragOver?: DragEventHandler; - onDragStart?: DragEventHandler; - onDrop?: DragEventHandler; - onMouseDown?: MouseEventHandler; - onMouseEnter?: MouseEventHandler; - onMouseLeave?: MouseEventHandler; - onMouseMove?: MouseEventHandler; - onMouseOut?: MouseEventHandler; - onMouseOver?: MouseEventHandler; - onMouseUp?: MouseEventHandler; - onTouchCancel?: TouchEventHandler; - onTouchEnd?: TouchEventHandler; - onTouchMove?: TouchEventHandler; - onTouchStart?: TouchEventHandler; - onScroll?: UIEventHandler; - onWheel?: WheelEventHandler; - - className?: string; - id?: string; - - dangerouslySetInnerHTML?: { - __html: string; - }; - } - - interface DOMAttributes extends DOMAttributesBase> { - } - - // This interface is not complete. Only properties accepting - // unitless numbers are listed here (see CSSProperty.js in React) - interface CSSProperties { - boxFlex?: number; - boxFlexGroup?: number; - columnCount?: number; - flex?: number | string; - flexGrow?: number; - flexShrink?: number; - fontWeight?: number | string; - lineClamp?: number; - lineHeight?: number | string; - opacity?: number; - order?: number; - orphans?: number; - widows?: number; - zIndex?: number; - zoom?: number; - - fontSize?: number | string; - - // SVG-related properties - fillOpacity?: number; - strokeOpacity?: number; - strokeWidth?: number; - - [propertyName: string]: any; - } - - interface HTMLAttributesBase extends DOMAttributesBase { - accept?: string; - acceptCharset?: string; - accessKey?: string; - action?: string; - allowFullScreen?: boolean; - allowTransparency?: boolean; - alt?: string; - async?: boolean; - autoComplete?: boolean; - autoFocus?: boolean; - autoPlay?: boolean; - cellPadding?: number | string; - cellSpacing?: number | string; - charSet?: string; - checked?: boolean; - classID?: string; - cols?: number; - colSpan?: number; - content?: string; - contentEditable?: boolean; - contextMenu?: string; - controls?: any; - coords?: string; - crossOrigin?: string; - data?: string; - dateTime?: string; - defaultChecked?: boolean; - defaultValue?: string; - defer?: boolean; - dir?: string; - disabled?: boolean; - download?: any; - draggable?: boolean; - encType?: string; - form?: string; - formAction?: string; - formEncType?: string; - formMethod?: string; - formNoValidate?: boolean; - formTarget?: string; - frameBorder?: number | string; - headers?: string; - height?: number | string; - hidden?: boolean; - high?: number; - href?: string; - hrefLang?: string; - htmlFor?: string; - httpEquiv?: string; - icon?: string; - label?: string; - lang?: string; - list?: string; - loop?: boolean; - low?: number; - manifest?: string; - marginHeight?: number; - marginWidth?: number; - max?: number | string; - maxLength?: number; - media?: string; - mediaGroup?: string; - method?: string; - min?: number | string; - multiple?: boolean; - muted?: boolean; - name?: string; - noValidate?: boolean; - open?: boolean; - optimum?: number; - pattern?: string; - placeholder?: string; - poster?: string; - preload?: string; - radioGroup?: string; - readOnly?: boolean; - rel?: string; - required?: boolean; - role?: string; - rows?: number; - rowSpan?: number; - sandbox?: string; - scope?: string; - scoped?: boolean; - scrolling?: string; - seamless?: boolean; - selected?: boolean; - shape?: string; - size?: number; - sizes?: string; - span?: number; - spellCheck?: boolean; - src?: string; - srcDoc?: string; - srcSet?: string; - start?: number; - step?: number | string; - style?: CSSProperties; - tabIndex?: number; - target?: string; - title?: string; - type?: string; - useMap?: string; - value?: string; - width?: number | string; - wmode?: string; - - // Non-standard Attributes - autoCapitalize?: boolean; - autoCorrect?: boolean; - property?: string; - itemProp?: string; - itemScope?: boolean; - itemType?: string; - unselectable?: boolean; - } - - interface HTMLAttributes extends HTMLAttributesBase { - } - - interface SVGElementAttributes extends HTMLAttributes { - viewBox?: string; - preserveAspectRatio?: string; - } - - interface SVGAttributes extends DOMAttributes { - ref?: string | ((component: SVGComponent) => void); - - cx?: number | string; - cy?: number | string; - d?: string; - dx?: number | string; - dy?: number | string; - fill?: string; - fillOpacity?: number | string; - fontFamily?: string; - fontSize?: number | string; - fx?: number | string; - fy?: number | string; - gradientTransform?: string; - gradientUnits?: string; - height?: number | string; - markerEnd?: string; - markerMid?: string; - markerStart?: string; - offset?: number | string; - opacity?: number | string; - patternContentUnits?: string; - patternUnits?: string; - points?: string; - preserveAspectRatio?: string; - r?: number | string; - rx?: number | string; - ry?: number | string; - spreadMethod?: string; - stopColor?: string; - stopOpacity?: number | string; - stroke?: string; - strokeDasharray?: string; - strokeLinecap?: string; - strokeMiterlimit?: string; - strokeOpacity?: number | string; - strokeWidth?: number | string; - textAnchor?: string; - transform?: string; - version?: string; - viewBox?: string; - width?: number | string; - x1?: number | string; - x2?: number | string; - x?: number | string; - y1?: number | string; - y2?: number | string - y?: number | string; - } - - // - // React.DOM - // ---------------------------------------------------------------------- - - interface ReactDOM { - // HTML - a: HTMLFactory; - abbr: HTMLFactory; - address: HTMLFactory; - area: HTMLFactory; - article: HTMLFactory; - aside: HTMLFactory; - audio: HTMLFactory; - b: HTMLFactory; - base: HTMLFactory; - bdi: HTMLFactory; - bdo: HTMLFactory; - big: HTMLFactory; - blockquote: HTMLFactory; - body: HTMLFactory; - br: HTMLFactory; - button: HTMLFactory; - canvas: HTMLFactory; - caption: HTMLFactory; - cite: HTMLFactory; - code: HTMLFactory; - col: HTMLFactory; - colgroup: HTMLFactory; - data: HTMLFactory; - datalist: HTMLFactory; - dd: HTMLFactory; - del: HTMLFactory; - details: HTMLFactory; - dfn: HTMLFactory; - dialog: HTMLFactory; - div: HTMLFactory; - dl: HTMLFactory; - dt: HTMLFactory; - em: HTMLFactory; - embed: HTMLFactory; - fieldset: HTMLFactory; - figcaption: HTMLFactory; - figure: HTMLFactory; - footer: HTMLFactory; - form: HTMLFactory; - h1: HTMLFactory; - h2: HTMLFactory; - h3: HTMLFactory; - h4: HTMLFactory; - h5: HTMLFactory; - h6: HTMLFactory; - head: HTMLFactory; - header: HTMLFactory; - hr: HTMLFactory; - html: HTMLFactory; - i: HTMLFactory; - iframe: HTMLFactory; - img: HTMLFactory; - input: HTMLFactory; - ins: HTMLFactory; - kbd: HTMLFactory; - keygen: HTMLFactory; - label: HTMLFactory; - legend: HTMLFactory; - li: HTMLFactory; - link: HTMLFactory; - main: HTMLFactory; - map: HTMLFactory; - mark: HTMLFactory; - menu: HTMLFactory; - menuitem: HTMLFactory; - meta: HTMLFactory; - meter: HTMLFactory; - nav: HTMLFactory; - noscript: HTMLFactory; - object: HTMLFactory; - ol: HTMLFactory; - optgroup: HTMLFactory; - option: HTMLFactory; - output: HTMLFactory; - p: HTMLFactory; - param: HTMLFactory; - picture: HTMLFactory; - pre: HTMLFactory; - progress: HTMLFactory; - q: HTMLFactory; - rp: HTMLFactory; - rt: HTMLFactory; - ruby: HTMLFactory; - s: HTMLFactory; - samp: HTMLFactory; - script: HTMLFactory; - section: HTMLFactory; - select: HTMLFactory; - small: HTMLFactory; - source: HTMLFactory; - span: HTMLFactory; - strong: HTMLFactory; - style: HTMLFactory; - sub: HTMLFactory; - summary: HTMLFactory; - sup: HTMLFactory; - table: HTMLFactory; - tbody: HTMLFactory; - td: HTMLFactory; - textarea: HTMLFactory; - tfoot: HTMLFactory; - th: HTMLFactory; - thead: HTMLFactory; - time: HTMLFactory; - title: HTMLFactory; - tr: HTMLFactory; - track: HTMLFactory; - u: HTMLFactory; - ul: HTMLFactory; - "var": HTMLFactory; - video: HTMLFactory; - wbr: HTMLFactory; - - // SVG - svg: SVGElementFactory; - circle: SVGFactory; - defs: SVGFactory; - ellipse: SVGFactory; - g: SVGFactory; - line: SVGFactory; - linearGradient: SVGFactory; - mask: SVGFactory; - path: SVGFactory; - pattern: SVGFactory; - polygon: SVGFactory; - polyline: SVGFactory; - radialGradient: SVGFactory; - rect: SVGFactory; - stop: SVGFactory; - text: SVGFactory; - tspan: SVGFactory; - } - - // - // React.PropTypes - // ---------------------------------------------------------------------- - - interface Validator { - (object: T, key: string, componentName: string): Error; - } - - interface Requireable extends Validator { - isRequired: Validator; - } - - interface ValidationMap { - [key: string]: Validator; - } - - interface ReactPropTypes { - any: Requireable; - array: Requireable; - bool: Requireable; - func: Requireable; - number: Requireable; - object: Requireable; - string: Requireable; - node: Requireable; - element: Requireable; - instanceOf(expectedClass: {}): Requireable; - oneOf(types: any[]): Requireable; - oneOfType(types: Validator[]): Requireable; - arrayOf(type: Validator): Requireable; - objectOf(type: Validator): Requireable; - shape(type: ValidationMap): Requireable; - } - - // - // React.Children - // ---------------------------------------------------------------------- - - interface ReactChildren { - map(children: ReactNode, fn: (child: ReactChild, index: number) => T): { [key:string]: T }; - forEach(children: ReactNode, fn: (child: ReactChild, index: number) => any): void; - count(children: ReactNode): number; - only(children: ReactNode): ReactChild; - } - - // - // Browser Interfaces - // https://github.com/nikeee/2048-typescript/blob/master/2048/js/touch.d.ts - // ---------------------------------------------------------------------- - - interface AbstractView { - styleMedia: StyleMedia; - document: Document; - } - - interface Touch { - identifier: number; - target: EventTarget; - screenX: number; - screenY: number; - clientX: number; - clientY: number; - pageX: number; - pageY: number; - } - - interface TouchList { - [index: number]: Touch; - length: number; - item(index: number): Touch; - identifiedTouch(identifier: number): Touch; - } - - // - // React.addons - // ---------------------------------------------------------------------- - - export module addons { - export var CSSTransitionGroup: CSSTransitionGroup; - export var TransitionGroup: TransitionGroup; - - export var LinkedStateMixin: LinkedStateMixin; - export var PureRenderMixin: PureRenderMixin; - - export function batchedUpdates( - callback: (a: A, b: B) => any, a: A, b: B): void; - export function batchedUpdates(callback: (a: A) => any, a: A): void; - export function batchedUpdates(callback: () => any): void; - - // deprecated: use petehunt/react-classset or JedWatson/classnames - export function classSet(cx: { [key: string]: boolean }): string; - export function classSet(...classList: string[]): string; - - export function cloneWithProps

( - element: DOMElement

, props: P): DOMElement

; - export function cloneWithProps

( - element: ClassicElement

, props: P): ClassicElement

; - export function cloneWithProps

( - element: ReactElement

, props: P): ReactElement

; - - export function createFragment( - object: { [key: string]: ReactNode }): ReactFragment; - - export function update(value: any[], spec: UpdateArraySpec): any[]; - export function update(value: {}, spec: UpdateSpec): any; - - // Development tools - export import Perf = ReactPerf; - export import TestUtils = ReactTestUtils; - } - - // - // React.addons (Transitions) - // ---------------------------------------------------------------------- - - interface TransitionGroupProps { - component?: ReactType; - childFactory?: (child: ReactElement) => ReactElement; - } - - interface CSSTransitionGroupProps extends TransitionGroupProps { - transitionName: string; - transitionAppear?: boolean; - transitionEnter?: boolean; - transitionLeave?: boolean; - } - - type CSSTransitionGroup = ComponentClass; - type TransitionGroup = ComponentClass; - - // - // React.addons (Mixins) - // ---------------------------------------------------------------------- - - interface ReactLink { - value: T; - requestChange(newValue: T): void; - } - - interface LinkedStateMixin extends Mixin { - linkState(key: string): ReactLink; - } - - interface PureRenderMixin extends Mixin { - } - - // - // Reat.addons.update - // ---------------------------------------------------------------------- - - interface UpdateSpecCommand { - $set?: any; - $merge?: {}; - $apply?(value: any): any; - } - - interface UpdateSpecPath { - [key: string]: UpdateSpec; - } - - type UpdateSpec = UpdateSpecCommand | UpdateSpecPath; - - interface UpdateArraySpec extends UpdateSpecCommand { - $push?: any[]; - $unshift?: any[]; - $splice?: any[][]; - } - - // - // React.addons.Perf - // ---------------------------------------------------------------------- - - interface ComponentPerfContext { - current: string; - owner: string; - } - - interface NumericPerfContext { - [key: string]: number; - } - - interface Measurements { - exclusive: NumericPerfContext; - inclusive: NumericPerfContext; - render: NumericPerfContext; - counts: NumericPerfContext; - writes: NumericPerfContext; - displayNames: { - [key: string]: ComponentPerfContext; - }; - totalTime: number; - } - - module ReactPerf { - export function start(): void; - export function stop(): void; - export function printInclusive(measurements: Measurements[]): void; - export function printExclusive(measurements: Measurements[]): void; - export function printWasted(measurements: Measurements[]): void; - export function printDOM(measurements: Measurements[]): void; - export function getLastMeasurements(): Measurements[]; - } - - // - // React.addons.TestUtils - // ---------------------------------------------------------------------- - - interface MockedComponentClass { - new(): any; - } - - module ReactTestUtils { - export import Simulate = ReactSimulate; - - export function renderIntoDocument

( - element: ReactElement

): Component; - export function renderIntoDocument>( - element: ReactElement): C; - - export function mockComponent( - mocked: MockedComponentClass, mockTagName?: string): typeof ReactTestUtils; - - export function isElementOfType( - element: ReactElement, type: ReactType): boolean; - export function isTextComponent(instance: Component): boolean; - export function isDOMComponent(instance: Component): boolean; - export function isCompositeComponent(instance: Component): boolean; - export function isCompositeComponentWithType( - instance: Component, - type: ComponentClass): boolean; - - export function findAllInRenderedTree( - tree: Component, - fn: (i: Component) => boolean): Component; - - export function scryRenderedDOMComponentsWithClass( - tree: Component, - className: string): DOMComponent[]; - export function findRenderedDOMComponentWithClass( - tree: Component, - className: string): DOMComponent; - - export function scryRenderedDOMComponentsWithTag( - tree: Component, - tagName: string): DOMComponent[]; - export function findRenderedDOMComponentWithTag( - tree: Component, - tagName: string): DOMComponent; - - export function scryRenderedComponentsWithType

( - tree: Component, - type: ComponentClass

): Component[]; - export function scryRenderedComponentsWithType>( - tree: Component, - type: ComponentClass): C[]; - - export function findRenderedComponentWithType

( - tree: Component, - type: ComponentClass

): Component; - export function findRenderedComponentWithType>( - tree: Component, - type: ComponentClass): C; - - export function createRenderer(): ShallowRenderer; - } - - interface SyntheticEventData { - altKey?: boolean; - button?: number; - buttons?: number; - clientX?: number; - clientY?: number; - changedTouches?: TouchList; - charCode?: boolean; - clipboardData?: DataTransfer; - ctrlKey?: boolean; - deltaMode?: number; - deltaX?: number; - deltaY?: number; - deltaZ?: number; - detail?: number; - getModifierState?(key: string): boolean; - key?: string; - keyCode?: number; - locale?: string; - location?: number; - metaKey?: boolean; - pageX?: number; - pageY?: number; - relatedTarget?: EventTarget; - repeat?: boolean; - screenX?: number; - screenY?: number; - shiftKey?: boolean; - targetTouches?: TouchList; - touches?: TouchList; - view?: AbstractView; - which?: number; - } - - interface EventSimulator { - (element: Element, eventData?: SyntheticEventData): void; - (component: Component, eventData?: SyntheticEventData): void; - } - - module ReactSimulate { - export var blur: EventSimulator; - export var change: EventSimulator; - export var click: EventSimulator; - export var cut: EventSimulator; - export var doubleClick: EventSimulator; - export var drag: EventSimulator; - export var dragEnd: EventSimulator; - export var dragEnter: EventSimulator; - export var dragExit: EventSimulator; - export var dragLeave: EventSimulator; - export var dragOver: EventSimulator; - export var dragStart: EventSimulator; - export var drop: EventSimulator; - export var focus: EventSimulator; - export var input: EventSimulator; - export var keyDown: EventSimulator; - export var keyPress: EventSimulator; - export var keyUp: EventSimulator; - export var mouseDown: EventSimulator; - export var mouseEnter: EventSimulator; - export var mouseLeave: EventSimulator; - export var mouseMove: EventSimulator; - export var mouseOut: EventSimulator; - export var mouseOver: EventSimulator; - export var mouseUp: EventSimulator; - export var paste: EventSimulator; - export var scroll: EventSimulator; - export var submit: EventSimulator; - export var touchCancel: EventSimulator; - export var touchEnd: EventSimulator; - export var touchMove: EventSimulator; - export var touchStart: EventSimulator; - export var wheel: EventSimulator; - } - - class ShallowRenderer { - getRenderOutput>(): E; - getRenderOutput(): ReactElement; - render(element: ReactElement, context?: any): void; - unmount(): void; - } -} - declare namespace JSX { import React = __React; From f2ff7464b5cd7f6dc41228f7950f55ece27d1c07 Mon Sep 17 00:00:00 2001 From: James Brantly Date: Wed, 14 Oct 2015 19:41:57 -0400 Subject: [PATCH 0078/1238] Remove cloneWithProps since it's deprecated --- react/react-addons-clone-with-props.d.ts | 18 ------------------ react/react-global.d.ts | 2 -- 2 files changed, 20 deletions(-) delete mode 100644 react/react-addons-clone-with-props.d.ts diff --git a/react/react-addons-clone-with-props.d.ts b/react/react-addons-clone-with-props.d.ts deleted file mode 100644 index 137c6650c7..0000000000 --- a/react/react-addons-clone-with-props.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -// Type definitions for React v0.14 (react-addons-clone-with-props) -// Project: http://facebook.github.io/react/ -// Definitions by: Asana , AssureSign , Microsoft -// Definitions: https://github.com/borisyankov/DefinitelyTyped - -/// - -declare namespace __React { - namespace __Addons { - export function cloneWithProps

(element: __React.DOMElement

, props: P): __React.DOMElement

; - export function cloneWithProps

(element: __React.ClassicElement

, props: P): __React.ClassicElement

; - export function cloneWithProps

(element: __React.ReactElement

, props: P): __React.ReactElement

; - } -} - -declare module "react-addons-clone-with-props" { - export = __React.__Addons.cloneWithProps; -} diff --git a/react/react-global.d.ts b/react/react-global.d.ts index 4de0a8eed2..3ed029240b 100644 --- a/react/react-global.d.ts +++ b/react/react-global.d.ts @@ -4,7 +4,6 @@ // Definitions: https://github.com/borisyankov/DefinitelyTyped /// -/// /// /// /// @@ -26,7 +25,6 @@ declare namespace __React { export var LinkedStateMixin: __React.__Addons.LinkedStateMixin; export var PureRenderMixin: __React.__Addons.PureRenderMixin; - export import cloneWithProps = __React.__Addons.cloneWithProps; export import createFragment = __React.__Addons.createFragment; export import update = __React.__Addons.update; From aa15031dcc8596d08543bbd7648496472bd54c11 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Thu, 15 Oct 2015 05:33:36 +0500 Subject: [PATCH 0079/1238] lodash: signatures of the method _.toArray have been changed --- lodash/lodash-tests.ts | 47 ++++++++++++++++++++--- lodash/lodash.d.ts | 86 +++++++++++++++++++++++++----------------- 2 files changed, 93 insertions(+), 40 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index adf86e9a61..b0dffe01ee 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -1850,12 +1850,6 @@ result = _([1, 2, 3]).sortBy(function (num) { return this.sin(num); }, result = _(['banana', 'strawberry', 'apple']).sortBy('length').value(); result = _(foodsOrganic).sortByAll('organic', (food) => food.name, { organic: true }).value(); -(function (a: number, b: number, c: number, d: number): Array { return _.toArray(arguments).slice(1); })(1, 2, 3, 4); -result = _.toArray([1, 2, 3, 4]); -(function (a: number, b: number, c: number, d: number): Array { return _(arguments).toArray().slice(1).value(); })(1, 2, 3, 4); -result = _([1,2,3,4]).toArray().value(); - - result = _.where(stoogesCombined, { 'age': 40 }); result = _.where(stoogesCombined, { 'quotes': ['Poifect!'] }); @@ -2418,6 +2412,47 @@ result = _(1).lte(2); result = _([]).lte(2); result = _({}).lte(2); +// _.toArray +module TestToArray { + let array: TResult[]; + let list: _.List; + let dictionary: _.Dictionary; + + { + let result: string[]; + + result = _.toArray(''); + + result = (function (a: string) {return _.toArray(arguments);})(''); + + result = _((function (a: string) {return arguments;})('')).toArray().value(); + } + + { + let result: TResult[]; + + result = _.toArray(array); + result = _.toArray(list); + result = _.toArray(dictionary); + + result = _(array).toArray().value(); + result = _(list).toArray().value(); + result = _(dictionary).toArray().value(); + } + + { + let result: any[]; + + result = _.toArray(); + result = _.toArray(42); + result = _.toArray(true); + + result = _('').toArray().value(); + result = _(42).toArray().value(); + result = _(true).toArray().value(); + } +} + // _.toPlainObject module TestToPlainObject { let result: TResult; diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index d5463ffc00..c77ff2f17f 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -5649,40 +5649,6 @@ declare module _ { orders?: string[]): LoDashArrayWrapper; } - //_.toArray - interface LoDashStatic { - /** - * Converts the collection to an array. - * @param collection The collection to convert. - * @return The new converted array. - **/ - toArray(collection: Array): T[]; - - /** - * @see _.toArray - **/ - toArray(collection: List): T[]; - - /** - * @see _.toArray - **/ - toArray(collection: Dictionary): T[]; - } - - interface LoDashArrayWrapper { - /** - * @see _.toArray - **/ - toArray(): LoDashArrayWrapper; - } - - interface LoDashObjectWrapper { - /** - * @see _.toArray - **/ - toArray(): LoDashArrayWrapper; - } - //_.where interface LoDashStatic { /** @@ -7068,6 +7034,58 @@ declare module _ { lte(other: any): boolean; } + //_.toArray + interface LoDashStatic { + /** + * Converts value to an array. + * + * @param value The value to convert. + * @return Returns the converted array. + */ + toArray(value: string): string[]; + + /** + * @see _.toArray + */ + toArray(value: List|Dictionary): T[]; + + /** + * @see _.toArray + */ + toArray(value: TValue): TResult[]; + + /** + * @see _.toArray + */ + toArray(value: TValue): any[]; + + /** + * @see _.toArray + */ + toArray(value?: any): any[]; + } + + interface LoDashWrapper { + /** + * @see _.toArray + */ + toArray(): LoDashArrayWrapper; + } + + interface LoDashArrayWrapper { + /** + * @see _.toArray + */ + toArray(): LoDashArrayWrapper; + } + + interface LoDashObjectWrapper { + /** + * @see _.toArray + */ + toArray(): LoDashArrayWrapper; + } + //_.toPlainObject interface LoDashStatic { /** From 6186be126ad03fc0c767a962833edfa98239ced7 Mon Sep 17 00:00:00 2001 From: James Brantly Date: Wed, 14 Oct 2015 20:47:57 -0400 Subject: [PATCH 0080/1238] Export types as well as variables for certain addons --- react/react-addons-css-transition-group.d.ts | 1 + react/react-addons-linked-state-mixin.d.ts | 1 + react/react-addons-pure-render-mixin.d.ts | 1 + react/react-addons-transition-group.d.ts | 1 + 4 files changed, 4 insertions(+) diff --git a/react/react-addons-css-transition-group.d.ts b/react/react-addons-css-transition-group.d.ts index 99db1f4f46..bcc3471243 100644 --- a/react/react-addons-css-transition-group.d.ts +++ b/react/react-addons-css-transition-group.d.ts @@ -21,5 +21,6 @@ declare namespace __React { declare module "react-addons-css-transition-group" { var CSSTransitionGroup: __React.__Addons.CSSTransitionGroup; + type CSSTransitionGroup = __React.__Addons.CSSTransitionGroup; export = CSSTransitionGroup; } diff --git a/react/react-addons-linked-state-mixin.d.ts b/react/react-addons-linked-state-mixin.d.ts index a98caa3847..ce1022cd8a 100644 --- a/react/react-addons-linked-state-mixin.d.ts +++ b/react/react-addons-linked-state-mixin.d.ts @@ -20,5 +20,6 @@ declare namespace __React { declare module "react-addons-linked-state-mixin" { var LinkedStateMixin: __React.__Addons.LinkedStateMixin; + type LinkedStateMixin = __React.__Addons.LinkedStateMixin; export = LinkedStateMixin; } diff --git a/react/react-addons-pure-render-mixin.d.ts b/react/react-addons-pure-render-mixin.d.ts index 741046d907..cc73a714dd 100644 --- a/react/react-addons-pure-render-mixin.d.ts +++ b/react/react-addons-pure-render-mixin.d.ts @@ -13,5 +13,6 @@ declare namespace __React { declare module "react-addons-pure-render-mixin" { var PureRenderMixin: __React.__Addons.PureRenderMixin; + type PureRenderMixin = __React.__Addons.PureRenderMixin; export = PureRenderMixin; } diff --git a/react/react-addons-transition-group.d.ts b/react/react-addons-transition-group.d.ts index 376bebd51b..fac2d76bca 100644 --- a/react/react-addons-transition-group.d.ts +++ b/react/react-addons-transition-group.d.ts @@ -18,5 +18,6 @@ declare namespace __React { declare module "react-addons-transition-group" { var TransitionGroup: __React.__Addons.TransitionGroup; + type TransitionGroup = __React.__Addons.TransitionGroup; export = TransitionGroup; } \ No newline at end of file From e43b2a00c08db45e1ac52d806f7e7f402bda6627 Mon Sep 17 00:00:00 2001 From: Giovanni Bassi Date: Wed, 14 Oct 2015 21:42:05 -0300 Subject: [PATCH 0081/1238] Add docopt See more about docopt at http://docopt.org/ This is specific for the library at https://www.npmjs.com/package/docopt --- docopt/docopt-tests.ts | 11 +++++++++++ docopt/docopt.d.ts | 23 +++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 docopt/docopt-tests.ts create mode 100644 docopt/docopt.d.ts diff --git a/docopt/docopt-tests.ts b/docopt/docopt-tests.ts new file mode 100644 index 0000000000..b8c1a2c25b --- /dev/null +++ b/docopt/docopt-tests.ts @@ -0,0 +1,11 @@ +/// +/// + +var doc = ` +Usage: + quick_example.coffee tcp [--timeout=] + quick_example.coffee serial [--baud=9600] [--timeout=] + quick_example.coffee -h | --help | --version +`; +var {docopt} = require('docopt'); +console.log(docopt(doc, { version: '0.1.1rc' })); diff --git a/docopt/docopt.d.ts b/docopt/docopt.d.ts new file mode 100644 index 0000000000..ea2330a193 --- /dev/null +++ b/docopt/docopt.d.ts @@ -0,0 +1,23 @@ +// Type definitions for Docopt v0.6.2 +// Project: http://docopt.org/ +// Definitions by: Giovanni Bassi +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +interface DocoptOption { + /** is an optional argument vector. It defaults to the arguments passed to your program (process.argv[2..]). You can also supply it with an array of strings, as with process.argv. For example: ['--verbose', '-o', 'hai.txt'] */ + argv?: Array, + /** (default:true) specifies whether the parser should automatically print the help message (supplied as doc) in case -h or --help options are encountered. After showing the usage-message, the program will terminate. If you want to handle -h or --help options manually (the same as other options), set help=false. */ + help?: boolean, + /** (default:null) is an optional argument that specifies the version of your program. If supplied, then, if the parser encounters --version option, it will print the supplied version and terminate. version could be any printable object, but most likely a string, e.g. '2.1.0rc1'. */ + version?: any, + /** (default false) If set to true will disallow mixing options and positional argument. I.e. after first positional argument, all arguments will be interpreted as positional even if the look like options. This can be used for strict compatibility with POSIX, or if you want to dispatch your arguments to other programs. */ + options_first?: boolean, + /** (default true) If set to false will cause docopt to throw exceptions instead of printing the error to console and terminating the application. This flag is mainly for testing purposes. */ + exit?: boolean +} +declare module "docopt" { + /** + * @param doc should be a string with the help message, written according to rules of the docopt language. + */ + export function docopt(doc: string, options: DocoptOption): any; +} From 8eb584e9cf92d0457ecbbc9980ce6d634a69cba2 Mon Sep 17 00:00:00 2001 From: James Brantly Date: Wed, 14 Oct 2015 20:52:17 -0400 Subject: [PATCH 0082/1238] Add legacy files for v0.13 --- react/react-0.13.3.d.ts | 2038 ++++++++++++++++++++++++++++++++ react/react-global-0.13.3.d.ts | 285 +++++ 2 files changed, 2323 insertions(+) create mode 100644 react/react-0.13.3.d.ts create mode 100644 react/react-global-0.13.3.d.ts diff --git a/react/react-0.13.3.d.ts b/react/react-0.13.3.d.ts new file mode 100644 index 0000000000..de8ba67327 --- /dev/null +++ b/react/react-0.13.3.d.ts @@ -0,0 +1,2038 @@ +// Type definitions for React v0.13.3 +// Project: http://facebook.github.io/react/ +// Definitions by: Asana , AssureSign , Microsoft +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare namespace __React { + // + // React Elements + // ---------------------------------------------------------------------- + + type ReactType = ComponentClass | string; + + interface ReactElement

{ + type: string | ComponentClass

; + props: P; + key: string | number; + ref: string | ((component: Component) => any); + } + + interface ClassicElement

extends ReactElement

{ + type: string | ClassicComponentClass

; + ref: string | ((component: ClassicComponent) => any); + } + + interface DOMElement

extends ClassicElement

{ + type: string; + ref: string | ((component: DOMComponent

) => any); + } + + type HTMLElement = DOMElement; + type SVGElement = DOMElement; + + // + // Factories + // ---------------------------------------------------------------------- + + interface Factory

{ + (props?: P, ...children: ReactNode[]): ReactElement

; + } + + interface ClassicFactory

extends Factory

{ + (props?: P, ...children: ReactNode[]): ClassicElement

; + } + + interface DOMFactory

extends ClassicFactory

{ + (props?: P, ...children: ReactNode[]): DOMElement

; + } + + type HTMLFactory = DOMFactory; + type SVGFactory = DOMFactory; + type SVGElementFactory = DOMFactory; + + // + // React Nodes + // http://facebook.github.io/react/docs/glossary.html + // ---------------------------------------------------------------------- + + type ReactText = string | number; + type ReactChild = ReactElement | ReactText; + + // Should be Array but type aliases cannot be recursive + type ReactFragment = {} | Array; + type ReactNode = ReactChild | ReactFragment | boolean; + + // + // Top Level API + // ---------------------------------------------------------------------- + + function createClass(spec: ComponentSpec): ClassicComponentClass

; + + function createFactory

(type: string): DOMFactory

; + function createFactory

(type: ClassicComponentClass

| string): ClassicFactory

; + function createFactory

(type: ComponentClass

): Factory

; + + function createElement

( + type: string, + props?: P, + ...children: ReactNode[]): DOMElement

; + function createElement

( + type: ClassicComponentClass

| string, + props?: P, + ...children: ReactNode[]): ClassicElement

; + function createElement

( + type: ComponentClass

, + props?: P, + ...children: ReactNode[]): ReactElement

; + + function cloneElement

( + element: DOMElement

, + props?: P, + ...children: ReactNode[]): DOMElement

; + function cloneElement

( + element: ClassicElement

, + props?: P, + ...children: ReactNode[]): ClassicElement

; + function cloneElement

( + element: ReactElement

, + props?: P, + ...children: ReactNode[]): ReactElement

; + + function render

( + element: DOMElement

, + container: Element, + callback?: () => any): DOMComponent

; + function render( + element: ClassicElement

, + container: Element, + callback?: () => any): ClassicComponent; + function render( + element: ReactElement

, + container: Element, + callback?: () => any): Component; + + function unmountComponentAtNode(container: Element): boolean; + function renderToString(element: ReactElement): string; + function renderToStaticMarkup(element: ReactElement): string; + function isValidElement(object: {}): boolean; + function initializeTouchEvents(shouldUseTouch: boolean): void; + + function findDOMNode( + componentOrElement: Component | Element): TElement; + function findDOMNode( + componentOrElement: Component | Element): Element; + + var DOM: ReactDOM; + var PropTypes: ReactPropTypes; + var Children: ReactChildren; + + // + // Component API + // ---------------------------------------------------------------------- + + // 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; + forceUpdate(callBack?: () => any): void; + render(): JSX.Element; + props: P; + state: S; + context: {}; + refs: { + [key: string]: Component + }; + } + + interface ClassicComponent extends Component { + replaceState(nextState: S, callback?: () => any): void; + getDOMNode(): TElement; + getDOMNode(): Element; + isMounted(): boolean; + getInitialState?(): S; + setProps(nextProps: P, callback?: () => any): void; + replaceProps(nextProps: P, callback?: () => any): void; + } + + interface DOMComponent

extends ClassicComponent { + tagName: string; + } + + type HTMLComponent = DOMComponent; + type SVGComponent = DOMComponent; + + interface ChildContextProvider { + getChildContext(): CC; + } + + // + // Class Interfaces + // ---------------------------------------------------------------------- + + interface ComponentClass

{ + new(props?: P, context?: any): Component; + propTypes?: ValidationMap

; + contextTypes?: ValidationMap; + childContextTypes?: ValidationMap; + defaultProps?: P; + } + + interface ClassicComponentClass

extends ComponentClass

{ + new(props?: P, context?: any): ClassicComponent; + getDefaultProps?(): P; + displayName?: string; + } + + // + // Component Specs and Lifecycle + // ---------------------------------------------------------------------- + + interface ComponentLifecycle { + componentWillMount?(): void; + componentDidMount?(): void; + componentWillReceiveProps?(nextProps: P, nextContext: any): void; + shouldComponentUpdate?(nextProps: P, nextState: S, nextContext: any): boolean; + componentWillUpdate?(nextProps: P, nextState: S, nextContext: any): void; + componentDidUpdate?(prevProps: P, prevState: S, prevContext: any): void; + componentWillUnmount?(): void; + } + + interface Mixin extends ComponentLifecycle { + mixins?: Mixin; + statics?: { + [key: string]: any; + }; + + displayName?: string; + propTypes?: ValidationMap; + contextTypes?: ValidationMap; + childContextTypes?: ValidationMap + + getDefaultProps?(): P; + getInitialState?(): S; + } + + interface ComponentSpec extends Mixin { + render(): ReactElement; + + [propertyName: string]: any; + } + + // + // Event System + // ---------------------------------------------------------------------- + + interface SyntheticEvent { + bubbles: boolean; + cancelable: boolean; + currentTarget: EventTarget; + defaultPrevented: boolean; + eventPhase: number; + isTrusted: boolean; + nativeEvent: Event; + preventDefault(): void; + stopPropagation(): void; + target: EventTarget; + timeStamp: Date; + type: string; + } + + interface DragEvent extends SyntheticEvent { + dataTransfer: DataTransfer; + } + + interface ClipboardEvent extends SyntheticEvent { + clipboardData: DataTransfer; + } + + interface KeyboardEvent extends SyntheticEvent { + altKey: boolean; + charCode: number; + ctrlKey: boolean; + getModifierState(key: string): boolean; + key: string; + keyCode: number; + locale: string; + location: number; + metaKey: boolean; + repeat: boolean; + shiftKey: boolean; + which: number; + } + + interface FocusEvent extends SyntheticEvent { + relatedTarget: EventTarget; + } + + interface FormEvent extends SyntheticEvent { + } + + interface MouseEvent extends SyntheticEvent { + altKey: boolean; + button: number; + buttons: number; + clientX: number; + clientY: number; + ctrlKey: boolean; + getModifierState(key: string): boolean; + metaKey: boolean; + pageX: number; + pageY: number; + relatedTarget: EventTarget; + screenX: number; + screenY: number; + shiftKey: boolean; + } + + interface TouchEvent extends SyntheticEvent { + altKey: boolean; + changedTouches: TouchList; + ctrlKey: boolean; + getModifierState(key: string): boolean; + metaKey: boolean; + shiftKey: boolean; + targetTouches: TouchList; + touches: TouchList; + } + + interface UIEvent extends SyntheticEvent { + detail: number; + view: AbstractView; + } + + interface WheelEvent extends SyntheticEvent { + deltaMode: number; + deltaX: number; + deltaY: number; + deltaZ: number; + } + + // + // Event Handler Types + // ---------------------------------------------------------------------- + + interface EventHandler { + (event: E): void; + } + + interface DragEventHandler extends EventHandler {} + interface ClipboardEventHandler extends EventHandler {} + interface KeyboardEventHandler extends EventHandler {} + interface FocusEventHandler extends EventHandler {} + interface FormEventHandler extends EventHandler {} + interface MouseEventHandler extends EventHandler {} + interface TouchEventHandler extends EventHandler {} + interface UIEventHandler extends EventHandler {} + interface WheelEventHandler extends EventHandler {} + + // + // Props / DOM Attributes + // ---------------------------------------------------------------------- + + interface Props { + children?: ReactNode; + key?: string | number; + ref?: string | ((component: T) => any); + } + + interface DOMAttributesBase extends Props { + onCopy?: ClipboardEventHandler; + onCut?: ClipboardEventHandler; + onPaste?: ClipboardEventHandler; + onKeyDown?: KeyboardEventHandler; + onKeyPress?: KeyboardEventHandler; + onKeyUp?: KeyboardEventHandler; + onFocus?: FocusEventHandler; + onBlur?: FocusEventHandler; + onChange?: FormEventHandler; + onInput?: FormEventHandler; + onSubmit?: FormEventHandler; + onClick?: MouseEventHandler; + onContextMenu?: MouseEventHandler; + onDoubleClick?: MouseEventHandler; + onDrag?: DragEventHandler; + onDragEnd?: DragEventHandler; + onDragEnter?: DragEventHandler; + onDragExit?: DragEventHandler; + onDragLeave?: DragEventHandler; + onDragOver?: DragEventHandler; + onDragStart?: DragEventHandler; + onDrop?: DragEventHandler; + onMouseDown?: MouseEventHandler; + onMouseEnter?: MouseEventHandler; + onMouseLeave?: MouseEventHandler; + onMouseMove?: MouseEventHandler; + onMouseOut?: MouseEventHandler; + onMouseOver?: MouseEventHandler; + onMouseUp?: MouseEventHandler; + onTouchCancel?: TouchEventHandler; + onTouchEnd?: TouchEventHandler; + onTouchMove?: TouchEventHandler; + onTouchStart?: TouchEventHandler; + onScroll?: UIEventHandler; + onWheel?: WheelEventHandler; + + className?: string; + id?: string; + + dangerouslySetInnerHTML?: { + __html: string; + }; + } + + interface DOMAttributes extends DOMAttributesBase> { + } + + // This interface is not complete. Only properties accepting + // unitless numbers are listed here (see CSSProperty.js in React) + interface CSSProperties { + boxFlex?: number; + boxFlexGroup?: number; + columnCount?: number; + flex?: number | string; + flexGrow?: number; + flexShrink?: number; + fontWeight?: number | string; + lineClamp?: number; + lineHeight?: number | string; + opacity?: number; + order?: number; + orphans?: number; + widows?: number; + zIndex?: number; + zoom?: number; + + fontSize?: number | string; + + // SVG-related properties + fillOpacity?: number; + strokeOpacity?: number; + strokeWidth?: number; + + [propertyName: string]: any; + } + + interface HTMLAttributesBase extends DOMAttributesBase { + accept?: string; + acceptCharset?: string; + accessKey?: string; + action?: string; + allowFullScreen?: boolean; + allowTransparency?: boolean; + alt?: string; + async?: boolean; + autoComplete?: boolean; + autoFocus?: boolean; + autoPlay?: boolean; + cellPadding?: number | string; + cellSpacing?: number | string; + charSet?: string; + checked?: boolean; + classID?: string; + cols?: number; + colSpan?: number; + content?: string; + contentEditable?: boolean; + contextMenu?: string; + controls?: any; + coords?: string; + crossOrigin?: string; + data?: string; + dateTime?: string; + defaultChecked?: boolean; + defaultValue?: string; + defer?: boolean; + dir?: string; + disabled?: boolean; + download?: any; + draggable?: boolean; + encType?: string; + form?: string; + formAction?: string; + formEncType?: string; + formMethod?: string; + formNoValidate?: boolean; + formTarget?: string; + frameBorder?: number | string; + headers?: string; + height?: number | string; + hidden?: boolean; + high?: number; + href?: string; + hrefLang?: string; + htmlFor?: string; + httpEquiv?: string; + icon?: string; + label?: string; + lang?: string; + list?: string; + loop?: boolean; + low?: number; + manifest?: string; + marginHeight?: number; + marginWidth?: number; + max?: number | string; + maxLength?: number; + media?: string; + mediaGroup?: string; + method?: string; + min?: number | string; + multiple?: boolean; + muted?: boolean; + name?: string; + noValidate?: boolean; + open?: boolean; + optimum?: number; + pattern?: string; + placeholder?: string; + poster?: string; + preload?: string; + radioGroup?: string; + readOnly?: boolean; + rel?: string; + required?: boolean; + role?: string; + rows?: number; + rowSpan?: number; + sandbox?: string; + scope?: string; + scoped?: boolean; + scrolling?: string; + seamless?: boolean; + selected?: boolean; + shape?: string; + size?: number; + sizes?: string; + span?: number; + spellCheck?: boolean; + src?: string; + srcDoc?: string; + srcSet?: string; + start?: number; + step?: number | string; + style?: CSSProperties; + tabIndex?: number; + target?: string; + title?: string; + type?: string; + useMap?: string; + value?: string; + width?: number | string; + wmode?: string; + + // Non-standard Attributes + autoCapitalize?: boolean; + autoCorrect?: boolean; + property?: string; + itemProp?: string; + itemScope?: boolean; + itemType?: string; + unselectable?: boolean; + } + + interface HTMLAttributes extends HTMLAttributesBase { + } + + interface SVGElementAttributes extends HTMLAttributes { + viewBox?: string; + preserveAspectRatio?: string; + } + + interface SVGAttributes extends DOMAttributes { + ref?: string | ((component: SVGComponent) => void); + + cx?: number | string; + cy?: number | string; + d?: string; + dx?: number | string; + dy?: number | string; + fill?: string; + fillOpacity?: number | string; + fontFamily?: string; + fontSize?: number | string; + fx?: number | string; + fy?: number | string; + gradientTransform?: string; + gradientUnits?: string; + height?: number | string; + markerEnd?: string; + markerMid?: string; + markerStart?: string; + offset?: number | string; + opacity?: number | string; + patternContentUnits?: string; + patternUnits?: string; + points?: string; + preserveAspectRatio?: string; + r?: number | string; + rx?: number | string; + ry?: number | string; + spreadMethod?: string; + stopColor?: string; + stopOpacity?: number | string; + stroke?: string; + strokeDasharray?: string; + strokeLinecap?: string; + strokeMiterlimit?: string; + strokeOpacity?: number | string; + strokeWidth?: number | string; + textAnchor?: string; + transform?: string; + version?: string; + viewBox?: string; + width?: number | string; + x1?: number | string; + x2?: number | string; + x?: number | string; + y1?: number | string; + y2?: number | string + y?: number | string; + } + + // + // React.DOM + // ---------------------------------------------------------------------- + + interface ReactDOM { + // HTML + a: HTMLFactory; + abbr: HTMLFactory; + address: HTMLFactory; + area: HTMLFactory; + article: HTMLFactory; + aside: HTMLFactory; + audio: HTMLFactory; + b: HTMLFactory; + base: HTMLFactory; + bdi: HTMLFactory; + bdo: HTMLFactory; + big: HTMLFactory; + blockquote: HTMLFactory; + body: HTMLFactory; + br: HTMLFactory; + button: HTMLFactory; + canvas: HTMLFactory; + caption: HTMLFactory; + cite: HTMLFactory; + code: HTMLFactory; + col: HTMLFactory; + colgroup: HTMLFactory; + data: HTMLFactory; + datalist: HTMLFactory; + dd: HTMLFactory; + del: HTMLFactory; + details: HTMLFactory; + dfn: HTMLFactory; + dialog: HTMLFactory; + div: HTMLFactory; + dl: HTMLFactory; + dt: HTMLFactory; + em: HTMLFactory; + embed: HTMLFactory; + fieldset: HTMLFactory; + figcaption: HTMLFactory; + figure: HTMLFactory; + footer: HTMLFactory; + form: HTMLFactory; + h1: HTMLFactory; + h2: HTMLFactory; + h3: HTMLFactory; + h4: HTMLFactory; + h5: HTMLFactory; + h6: HTMLFactory; + head: HTMLFactory; + header: HTMLFactory; + hr: HTMLFactory; + html: HTMLFactory; + i: HTMLFactory; + iframe: HTMLFactory; + img: HTMLFactory; + input: HTMLFactory; + ins: HTMLFactory; + kbd: HTMLFactory; + keygen: HTMLFactory; + label: HTMLFactory; + legend: HTMLFactory; + li: HTMLFactory; + link: HTMLFactory; + main: HTMLFactory; + map: HTMLFactory; + mark: HTMLFactory; + menu: HTMLFactory; + menuitem: HTMLFactory; + meta: HTMLFactory; + meter: HTMLFactory; + nav: HTMLFactory; + noscript: HTMLFactory; + object: HTMLFactory; + ol: HTMLFactory; + optgroup: HTMLFactory; + option: HTMLFactory; + output: HTMLFactory; + p: HTMLFactory; + param: HTMLFactory; + picture: HTMLFactory; + pre: HTMLFactory; + progress: HTMLFactory; + q: HTMLFactory; + rp: HTMLFactory; + rt: HTMLFactory; + ruby: HTMLFactory; + s: HTMLFactory; + samp: HTMLFactory; + script: HTMLFactory; + section: HTMLFactory; + select: HTMLFactory; + small: HTMLFactory; + source: HTMLFactory; + span: HTMLFactory; + strong: HTMLFactory; + style: HTMLFactory; + sub: HTMLFactory; + summary: HTMLFactory; + sup: HTMLFactory; + table: HTMLFactory; + tbody: HTMLFactory; + td: HTMLFactory; + textarea: HTMLFactory; + tfoot: HTMLFactory; + th: HTMLFactory; + thead: HTMLFactory; + time: HTMLFactory; + title: HTMLFactory; + tr: HTMLFactory; + track: HTMLFactory; + u: HTMLFactory; + ul: HTMLFactory; + "var": HTMLFactory; + video: HTMLFactory; + wbr: HTMLFactory; + + // SVG + svg: SVGElementFactory; + circle: SVGFactory; + defs: SVGFactory; + ellipse: SVGFactory; + g: SVGFactory; + line: SVGFactory; + linearGradient: SVGFactory; + mask: SVGFactory; + path: SVGFactory; + pattern: SVGFactory; + polygon: SVGFactory; + polyline: SVGFactory; + radialGradient: SVGFactory; + rect: SVGFactory; + stop: SVGFactory; + text: SVGFactory; + tspan: SVGFactory; + } + + // + // React.PropTypes + // ---------------------------------------------------------------------- + + interface Validator { + (object: T, key: string, componentName: string): Error; + } + + interface Requireable extends Validator { + isRequired: Validator; + } + + interface ValidationMap { + [key: string]: Validator; + } + + interface ReactPropTypes { + any: Requireable; + array: Requireable; + bool: Requireable; + func: Requireable; + number: Requireable; + object: Requireable; + string: Requireable; + node: Requireable; + element: Requireable; + instanceOf(expectedClass: {}): Requireable; + oneOf(types: any[]): Requireable; + oneOfType(types: Validator[]): Requireable; + arrayOf(type: Validator): Requireable; + objectOf(type: Validator): Requireable; + shape(type: ValidationMap): Requireable; + } + + // + // React.Children + // ---------------------------------------------------------------------- + + interface ReactChildren { + map(children: ReactNode, fn: (child: ReactChild, index: number) => T): { [key:string]: T }; + forEach(children: ReactNode, fn: (child: ReactChild, index: number) => any): void; + count(children: ReactNode): number; + only(children: ReactNode): ReactChild; + } + + // + // Browser Interfaces + // https://github.com/nikeee/2048-typescript/blob/master/2048/js/touch.d.ts + // ---------------------------------------------------------------------- + + interface AbstractView { + styleMedia: StyleMedia; + document: Document; + } + + interface Touch { + identifier: number; + target: EventTarget; + screenX: number; + screenY: number; + clientX: number; + clientY: number; + pageX: number; + pageY: number; + } + + interface TouchList { + [index: number]: Touch; + length: number; + item(index: number): Touch; + identifiedTouch(identifier: number): Touch; + } +} + +declare module "react" { + export = __React; +} + +declare module "react/addons" { + // + // React Elements + // ---------------------------------------------------------------------- + + type ReactType = ComponentClass | string; + + interface ReactElement

{ + type: string | ComponentClass

; + props: P; + key: string | number; + ref: string | ((component: Component) => any); + } + + interface ClassicElement

extends ReactElement

{ + type: string | ClassicComponentClass

; + ref: string | ((component: ClassicComponent) => any); + } + + interface DOMElement

extends ClassicElement

{ + type: string; + ref: string | ((component: DOMComponent

) => any); + } + + type HTMLElement = DOMElement; + type SVGElement = DOMElement; + + // + // Factories + // ---------------------------------------------------------------------- + + interface Factory

{ + (props?: P, ...children: ReactNode[]): ReactElement

; + } + + interface ClassicFactory

extends Factory

{ + (props?: P, ...children: ReactNode[]): ClassicElement

; + } + + interface DOMFactory

extends ClassicFactory

{ + (props?: P, ...children: ReactNode[]): DOMElement

; + } + + type HTMLFactory = DOMFactory; + type SVGFactory = DOMFactory; + type SVGElementFactory = DOMFactory; + + // + // React Nodes + // http://facebook.github.io/react/docs/glossary.html + // ---------------------------------------------------------------------- + + type ReactText = string | number; + type ReactChild = ReactElement | ReactText; + + // Should be Array but type aliases cannot be recursive + type ReactFragment = {} | Array; + type ReactNode = ReactChild | ReactFragment | boolean; + + // + // Top Level API + // ---------------------------------------------------------------------- + + function createClass(spec: ComponentSpec): ClassicComponentClass

; + + function createFactory

(type: string): DOMFactory

; + function createFactory

(type: ClassicComponentClass

| string): ClassicFactory

; + function createFactory

(type: ComponentClass

): Factory

; + + function createElement

( + type: string, + props?: P, + ...children: ReactNode[]): DOMElement

; + function createElement

( + type: ClassicComponentClass

| string, + props?: P, + ...children: ReactNode[]): ClassicElement

; + function createElement

( + type: ComponentClass

, + props?: P, + ...children: ReactNode[]): ReactElement

; + + function cloneElement

( + element: DOMElement

, + props?: P, + ...children: ReactNode[]): DOMElement

; + function cloneElement

( + element: ClassicElement

, + props?: P, + ...children: ReactNode[]): ClassicElement

; + function cloneElement

( + element: ReactElement

, + props?: P, + ...children: ReactNode[]): ReactElement

; + + function render

( + element: DOMElement

, + container: Element, + callback?: () => any): DOMComponent

; + function render( + element: ClassicElement

, + container: Element, + callback?: () => any): ClassicComponent; + function render( + element: ReactElement

, + container: Element, + callback?: () => any): Component; + + function unmountComponentAtNode(container: Element): boolean; + function renderToString(element: ReactElement): string; + function renderToStaticMarkup(element: ReactElement): string; + function isValidElement(object: {}): boolean; + function initializeTouchEvents(shouldUseTouch: boolean): void; + + function findDOMNode( + componentOrElement: Component | Element): TElement; + function findDOMNode( + componentOrElement: Component | Element): Element; + + var DOM: ReactDOM; + var PropTypes: ReactPropTypes; + var Children: ReactChildren; + + // + // Component API + // ---------------------------------------------------------------------- + + // 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; + forceUpdate(callBack?: () => any): void; + render(): JSX.Element; + props: P; + state: S; + context: {}; + refs: { + [key: string]: Component + }; + } + + interface ClassicComponent extends Component { + replaceState(nextState: S, callback?: () => any): void; + getDOMNode(): TElement; + getDOMNode(): Element; + isMounted(): boolean; + getInitialState?(): S; + setProps(nextProps: P, callback?: () => any): void; + replaceProps(nextProps: P, callback?: () => any): void; + } + + interface DOMComponent

extends ClassicComponent { + tagName: string; + } + + type HTMLComponent = DOMComponent; + type SVGComponent = DOMComponent; + + interface ChildContextProvider { + getChildContext(): CC; + } + + // + // Class Interfaces + // ---------------------------------------------------------------------- + + interface ComponentClass

{ + new(props?: P, context?: any): Component; + propTypes?: ValidationMap

; + contextTypes?: ValidationMap; + childContextTypes?: ValidationMap; + defaultProps?: P; + } + + interface ClassicComponentClass

extends ComponentClass

{ + new(props?: P, context?: any): ClassicComponent; + getDefaultProps?(): P; + displayName?: string; + } + + // + // Component Specs and Lifecycle + // ---------------------------------------------------------------------- + + interface ComponentLifecycle { + componentWillMount?(): void; + componentDidMount?(): void; + componentWillReceiveProps?(nextProps: P, nextContext: any): void; + shouldComponentUpdate?(nextProps: P, nextState: S, nextContext: any): boolean; + componentWillUpdate?(nextProps: P, nextState: S, nextContext: any): void; + componentDidUpdate?(prevProps: P, prevState: S, prevContext: any): void; + componentWillUnmount?(): void; + } + + interface Mixin extends ComponentLifecycle { + mixins?: Mixin; + statics?: { + [key: string]: any; + }; + + displayName?: string; + propTypes?: ValidationMap; + contextTypes?: ValidationMap; + childContextTypes?: ValidationMap + + getDefaultProps?(): P; + getInitialState?(): S; + } + + interface ComponentSpec extends Mixin { + render(): ReactElement; + + [propertyName: string]: any; + } + + // + // Event System + // ---------------------------------------------------------------------- + + interface SyntheticEvent { + bubbles: boolean; + cancelable: boolean; + currentTarget: EventTarget; + defaultPrevented: boolean; + eventPhase: number; + isTrusted: boolean; + nativeEvent: Event; + preventDefault(): void; + stopPropagation(): void; + target: EventTarget; + timeStamp: Date; + type: string; + } + + interface DragEvent extends SyntheticEvent { + dataTransfer: DataTransfer; + } + + interface ClipboardEvent extends SyntheticEvent { + clipboardData: DataTransfer; + } + + interface KeyboardEvent extends SyntheticEvent { + altKey: boolean; + charCode: number; + ctrlKey: boolean; + getModifierState(key: string): boolean; + key: string; + keyCode: number; + locale: string; + location: number; + metaKey: boolean; + repeat: boolean; + shiftKey: boolean; + which: number; + } + + interface FocusEvent extends SyntheticEvent { + relatedTarget: EventTarget; + } + + interface FormEvent extends SyntheticEvent { + } + + interface MouseEvent extends SyntheticEvent { + altKey: boolean; + button: number; + buttons: number; + clientX: number; + clientY: number; + ctrlKey: boolean; + getModifierState(key: string): boolean; + metaKey: boolean; + pageX: number; + pageY: number; + relatedTarget: EventTarget; + screenX: number; + screenY: number; + shiftKey: boolean; + } + + interface TouchEvent extends SyntheticEvent { + altKey: boolean; + changedTouches: TouchList; + ctrlKey: boolean; + getModifierState(key: string): boolean; + metaKey: boolean; + shiftKey: boolean; + targetTouches: TouchList; + touches: TouchList; + } + + interface UIEvent extends SyntheticEvent { + detail: number; + view: AbstractView; + } + + interface WheelEvent extends SyntheticEvent { + deltaMode: number; + deltaX: number; + deltaY: number; + deltaZ: number; + } + + // + // Event Handler Types + // ---------------------------------------------------------------------- + + interface EventHandler { + (event: E): void; + } + + interface DragEventHandler extends EventHandler {} + interface ClipboardEventHandler extends EventHandler {} + interface KeyboardEventHandler extends EventHandler {} + interface FocusEventHandler extends EventHandler {} + interface FormEventHandler extends EventHandler {} + interface MouseEventHandler extends EventHandler {} + interface TouchEventHandler extends EventHandler {} + interface UIEventHandler extends EventHandler {} + interface WheelEventHandler extends EventHandler {} + + // + // Props / DOM Attributes + // ---------------------------------------------------------------------- + + interface Props { + children?: ReactNode; + key?: string | number; + ref?: string | ((component: T) => any); + } + + interface DOMAttributesBase extends Props { + onCopy?: ClipboardEventHandler; + onCut?: ClipboardEventHandler; + onPaste?: ClipboardEventHandler; + onKeyDown?: KeyboardEventHandler; + onKeyPress?: KeyboardEventHandler; + onKeyUp?: KeyboardEventHandler; + onFocus?: FocusEventHandler; + onBlur?: FocusEventHandler; + onChange?: FormEventHandler; + onInput?: FormEventHandler; + onSubmit?: FormEventHandler; + onClick?: MouseEventHandler; + onDoubleClick?: MouseEventHandler; + onDrag?: DragEventHandler; + onDragEnd?: DragEventHandler; + onDragEnter?: DragEventHandler; + onDragExit?: DragEventHandler; + onDragLeave?: DragEventHandler; + onDragOver?: DragEventHandler; + onDragStart?: DragEventHandler; + onDrop?: DragEventHandler; + onMouseDown?: MouseEventHandler; + onMouseEnter?: MouseEventHandler; + onMouseLeave?: MouseEventHandler; + onMouseMove?: MouseEventHandler; + onMouseOut?: MouseEventHandler; + onMouseOver?: MouseEventHandler; + onMouseUp?: MouseEventHandler; + onTouchCancel?: TouchEventHandler; + onTouchEnd?: TouchEventHandler; + onTouchMove?: TouchEventHandler; + onTouchStart?: TouchEventHandler; + onScroll?: UIEventHandler; + onWheel?: WheelEventHandler; + + className?: string; + id?: string; + + dangerouslySetInnerHTML?: { + __html: string; + }; + } + + interface DOMAttributes extends DOMAttributesBase> { + } + + // This interface is not complete. Only properties accepting + // unitless numbers are listed here (see CSSProperty.js in React) + interface CSSProperties { + boxFlex?: number; + boxFlexGroup?: number; + columnCount?: number; + flex?: number | string; + flexGrow?: number; + flexShrink?: number; + fontWeight?: number | string; + lineClamp?: number; + lineHeight?: number | string; + opacity?: number; + order?: number; + orphans?: number; + widows?: number; + zIndex?: number; + zoom?: number; + + fontSize?: number | string; + + // SVG-related properties + fillOpacity?: number; + strokeOpacity?: number; + strokeWidth?: number; + + [propertyName: string]: any; + } + + interface HTMLAttributesBase extends DOMAttributesBase { + accept?: string; + acceptCharset?: string; + accessKey?: string; + action?: string; + allowFullScreen?: boolean; + allowTransparency?: boolean; + alt?: string; + async?: boolean; + autoComplete?: boolean; + autoFocus?: boolean; + autoPlay?: boolean; + cellPadding?: number | string; + cellSpacing?: number | string; + charSet?: string; + checked?: boolean; + classID?: string; + cols?: number; + colSpan?: number; + content?: string; + contentEditable?: boolean; + contextMenu?: string; + controls?: any; + coords?: string; + crossOrigin?: string; + data?: string; + dateTime?: string; + defaultChecked?: boolean; + defaultValue?: string; + defer?: boolean; + dir?: string; + disabled?: boolean; + download?: any; + draggable?: boolean; + encType?: string; + form?: string; + formAction?: string; + formEncType?: string; + formMethod?: string; + formNoValidate?: boolean; + formTarget?: string; + frameBorder?: number | string; + headers?: string; + height?: number | string; + hidden?: boolean; + high?: number; + href?: string; + hrefLang?: string; + htmlFor?: string; + httpEquiv?: string; + icon?: string; + label?: string; + lang?: string; + list?: string; + loop?: boolean; + low?: number; + manifest?: string; + marginHeight?: number; + marginWidth?: number; + max?: number | string; + maxLength?: number; + media?: string; + mediaGroup?: string; + method?: string; + min?: number | string; + multiple?: boolean; + muted?: boolean; + name?: string; + noValidate?: boolean; + open?: boolean; + optimum?: number; + pattern?: string; + placeholder?: string; + poster?: string; + preload?: string; + radioGroup?: string; + readOnly?: boolean; + rel?: string; + required?: boolean; + role?: string; + rows?: number; + rowSpan?: number; + sandbox?: string; + scope?: string; + scoped?: boolean; + scrolling?: string; + seamless?: boolean; + selected?: boolean; + shape?: string; + size?: number; + sizes?: string; + span?: number; + spellCheck?: boolean; + src?: string; + srcDoc?: string; + srcSet?: string; + start?: number; + step?: number | string; + style?: CSSProperties; + tabIndex?: number; + target?: string; + title?: string; + type?: string; + useMap?: string; + value?: string; + width?: number | string; + wmode?: string; + + // Non-standard Attributes + autoCapitalize?: boolean; + autoCorrect?: boolean; + property?: string; + itemProp?: string; + itemScope?: boolean; + itemType?: string; + unselectable?: boolean; + } + + interface HTMLAttributes extends HTMLAttributesBase { + } + + interface SVGElementAttributes extends HTMLAttributes { + viewBox?: string; + preserveAspectRatio?: string; + } + + interface SVGAttributes extends DOMAttributes { + ref?: string | ((component: SVGComponent) => void); + + cx?: number | string; + cy?: number | string; + d?: string; + dx?: number | string; + dy?: number | string; + fill?: string; + fillOpacity?: number | string; + fontFamily?: string; + fontSize?: number | string; + fx?: number | string; + fy?: number | string; + gradientTransform?: string; + gradientUnits?: string; + height?: number | string; + markerEnd?: string; + markerMid?: string; + markerStart?: string; + offset?: number | string; + opacity?: number | string; + patternContentUnits?: string; + patternUnits?: string; + points?: string; + preserveAspectRatio?: string; + r?: number | string; + rx?: number | string; + ry?: number | string; + spreadMethod?: string; + stopColor?: string; + stopOpacity?: number | string; + stroke?: string; + strokeDasharray?: string; + strokeLinecap?: string; + strokeMiterlimit?: string; + strokeOpacity?: number | string; + strokeWidth?: number | string; + textAnchor?: string; + transform?: string; + version?: string; + viewBox?: string; + width?: number | string; + x1?: number | string; + x2?: number | string; + x?: number | string; + y1?: number | string; + y2?: number | string + y?: number | string; + } + + // + // React.DOM + // ---------------------------------------------------------------------- + + interface ReactDOM { + // HTML + a: HTMLFactory; + abbr: HTMLFactory; + address: HTMLFactory; + area: HTMLFactory; + article: HTMLFactory; + aside: HTMLFactory; + audio: HTMLFactory; + b: HTMLFactory; + base: HTMLFactory; + bdi: HTMLFactory; + bdo: HTMLFactory; + big: HTMLFactory; + blockquote: HTMLFactory; + body: HTMLFactory; + br: HTMLFactory; + button: HTMLFactory; + canvas: HTMLFactory; + caption: HTMLFactory; + cite: HTMLFactory; + code: HTMLFactory; + col: HTMLFactory; + colgroup: HTMLFactory; + data: HTMLFactory; + datalist: HTMLFactory; + dd: HTMLFactory; + del: HTMLFactory; + details: HTMLFactory; + dfn: HTMLFactory; + dialog: HTMLFactory; + div: HTMLFactory; + dl: HTMLFactory; + dt: HTMLFactory; + em: HTMLFactory; + embed: HTMLFactory; + fieldset: HTMLFactory; + figcaption: HTMLFactory; + figure: HTMLFactory; + footer: HTMLFactory; + form: HTMLFactory; + h1: HTMLFactory; + h2: HTMLFactory; + h3: HTMLFactory; + h4: HTMLFactory; + h5: HTMLFactory; + h6: HTMLFactory; + head: HTMLFactory; + header: HTMLFactory; + hr: HTMLFactory; + html: HTMLFactory; + i: HTMLFactory; + iframe: HTMLFactory; + img: HTMLFactory; + input: HTMLFactory; + ins: HTMLFactory; + kbd: HTMLFactory; + keygen: HTMLFactory; + label: HTMLFactory; + legend: HTMLFactory; + li: HTMLFactory; + link: HTMLFactory; + main: HTMLFactory; + map: HTMLFactory; + mark: HTMLFactory; + menu: HTMLFactory; + menuitem: HTMLFactory; + meta: HTMLFactory; + meter: HTMLFactory; + nav: HTMLFactory; + noscript: HTMLFactory; + object: HTMLFactory; + ol: HTMLFactory; + optgroup: HTMLFactory; + option: HTMLFactory; + output: HTMLFactory; + p: HTMLFactory; + param: HTMLFactory; + picture: HTMLFactory; + pre: HTMLFactory; + progress: HTMLFactory; + q: HTMLFactory; + rp: HTMLFactory; + rt: HTMLFactory; + ruby: HTMLFactory; + s: HTMLFactory; + samp: HTMLFactory; + script: HTMLFactory; + section: HTMLFactory; + select: HTMLFactory; + small: HTMLFactory; + source: HTMLFactory; + span: HTMLFactory; + strong: HTMLFactory; + style: HTMLFactory; + sub: HTMLFactory; + summary: HTMLFactory; + sup: HTMLFactory; + table: HTMLFactory; + tbody: HTMLFactory; + td: HTMLFactory; + textarea: HTMLFactory; + tfoot: HTMLFactory; + th: HTMLFactory; + thead: HTMLFactory; + time: HTMLFactory; + title: HTMLFactory; + tr: HTMLFactory; + track: HTMLFactory; + u: HTMLFactory; + ul: HTMLFactory; + "var": HTMLFactory; + video: HTMLFactory; + wbr: HTMLFactory; + + // SVG + svg: SVGElementFactory; + circle: SVGFactory; + defs: SVGFactory; + ellipse: SVGFactory; + g: SVGFactory; + line: SVGFactory; + linearGradient: SVGFactory; + mask: SVGFactory; + path: SVGFactory; + pattern: SVGFactory; + polygon: SVGFactory; + polyline: SVGFactory; + radialGradient: SVGFactory; + rect: SVGFactory; + stop: SVGFactory; + text: SVGFactory; + tspan: SVGFactory; + } + + // + // React.PropTypes + // ---------------------------------------------------------------------- + + interface Validator { + (object: T, key: string, componentName: string): Error; + } + + interface Requireable extends Validator { + isRequired: Validator; + } + + interface ValidationMap { + [key: string]: Validator; + } + + interface ReactPropTypes { + any: Requireable; + array: Requireable; + bool: Requireable; + func: Requireable; + number: Requireable; + object: Requireable; + string: Requireable; + node: Requireable; + element: Requireable; + instanceOf(expectedClass: {}): Requireable; + oneOf(types: any[]): Requireable; + oneOfType(types: Validator[]): Requireable; + arrayOf(type: Validator): Requireable; + objectOf(type: Validator): Requireable; + shape(type: ValidationMap): Requireable; + } + + // + // React.Children + // ---------------------------------------------------------------------- + + interface ReactChildren { + map(children: ReactNode, fn: (child: ReactChild, index: number) => T): { [key:string]: T }; + forEach(children: ReactNode, fn: (child: ReactChild, index: number) => any): void; + count(children: ReactNode): number; + only(children: ReactNode): ReactChild; + } + + // + // Browser Interfaces + // https://github.com/nikeee/2048-typescript/blob/master/2048/js/touch.d.ts + // ---------------------------------------------------------------------- + + interface AbstractView { + styleMedia: StyleMedia; + document: Document; + } + + interface Touch { + identifier: number; + target: EventTarget; + screenX: number; + screenY: number; + clientX: number; + clientY: number; + pageX: number; + pageY: number; + } + + interface TouchList { + [index: number]: Touch; + length: number; + item(index: number): Touch; + identifiedTouch(identifier: number): Touch; + } + + // + // React.addons + // ---------------------------------------------------------------------- + + export module addons { + export var CSSTransitionGroup: CSSTransitionGroup; + export var TransitionGroup: TransitionGroup; + + export var LinkedStateMixin: LinkedStateMixin; + export var PureRenderMixin: PureRenderMixin; + + export function batchedUpdates( + callback: (a: A, b: B) => any, a: A, b: B): void; + export function batchedUpdates(callback: (a: A) => any, a: A): void; + export function batchedUpdates(callback: () => any): void; + + // deprecated: use petehunt/react-classset or JedWatson/classnames + export function classSet(cx: { [key: string]: boolean }): string; + export function classSet(...classList: string[]): string; + + export function cloneWithProps

( + element: DOMElement

, props: P): DOMElement

; + export function cloneWithProps

( + element: ClassicElement

, props: P): ClassicElement

; + export function cloneWithProps

( + element: ReactElement

, props: P): ReactElement

; + + export function createFragment( + object: { [key: string]: ReactNode }): ReactFragment; + + export function update(value: any[], spec: UpdateArraySpec): any[]; + export function update(value: {}, spec: UpdateSpec): any; + + // Development tools + export import Perf = ReactPerf; + export import TestUtils = ReactTestUtils; + } + + // + // React.addons (Transitions) + // ---------------------------------------------------------------------- + + interface TransitionGroupProps { + component?: ReactType; + childFactory?: (child: ReactElement) => ReactElement; + } + + interface CSSTransitionGroupProps extends TransitionGroupProps { + transitionName: string; + transitionAppear?: boolean; + transitionEnter?: boolean; + transitionLeave?: boolean; + } + + type CSSTransitionGroup = ComponentClass; + type TransitionGroup = ComponentClass; + + // + // React.addons (Mixins) + // ---------------------------------------------------------------------- + + interface ReactLink { + value: T; + requestChange(newValue: T): void; + } + + interface LinkedStateMixin extends Mixin { + linkState(key: string): ReactLink; + } + + interface PureRenderMixin extends Mixin { + } + + // + // Reat.addons.update + // ---------------------------------------------------------------------- + + interface UpdateSpecCommand { + $set?: any; + $merge?: {}; + $apply?(value: any): any; + } + + interface UpdateSpecPath { + [key: string]: UpdateSpec; + } + + type UpdateSpec = UpdateSpecCommand | UpdateSpecPath; + + interface UpdateArraySpec extends UpdateSpecCommand { + $push?: any[]; + $unshift?: any[]; + $splice?: any[][]; + } + + // + // React.addons.Perf + // ---------------------------------------------------------------------- + + interface ComponentPerfContext { + current: string; + owner: string; + } + + interface NumericPerfContext { + [key: string]: number; + } + + interface Measurements { + exclusive: NumericPerfContext; + inclusive: NumericPerfContext; + render: NumericPerfContext; + counts: NumericPerfContext; + writes: NumericPerfContext; + displayNames: { + [key: string]: ComponentPerfContext; + }; + totalTime: number; + } + + module ReactPerf { + export function start(): void; + export function stop(): void; + export function printInclusive(measurements: Measurements[]): void; + export function printExclusive(measurements: Measurements[]): void; + export function printWasted(measurements: Measurements[]): void; + export function printDOM(measurements: Measurements[]): void; + export function getLastMeasurements(): Measurements[]; + } + + // + // React.addons.TestUtils + // ---------------------------------------------------------------------- + + interface MockedComponentClass { + new(): any; + } + + module ReactTestUtils { + export import Simulate = ReactSimulate; + + export function renderIntoDocument

( + element: ReactElement

): Component; + export function renderIntoDocument>( + element: ReactElement): C; + + export function mockComponent( + mocked: MockedComponentClass, mockTagName?: string): typeof ReactTestUtils; + + export function isElementOfType( + element: ReactElement, type: ReactType): boolean; + export function isTextComponent(instance: Component): boolean; + export function isDOMComponent(instance: Component): boolean; + export function isCompositeComponent(instance: Component): boolean; + export function isCompositeComponentWithType( + instance: Component, + type: ComponentClass): boolean; + + export function findAllInRenderedTree( + tree: Component, + fn: (i: Component) => boolean): Component; + + export function scryRenderedDOMComponentsWithClass( + tree: Component, + className: string): DOMComponent[]; + export function findRenderedDOMComponentWithClass( + tree: Component, + className: string): DOMComponent; + + export function scryRenderedDOMComponentsWithTag( + tree: Component, + tagName: string): DOMComponent[]; + export function findRenderedDOMComponentWithTag( + tree: Component, + tagName: string): DOMComponent; + + export function scryRenderedComponentsWithType

( + tree: Component, + type: ComponentClass

): Component[]; + export function scryRenderedComponentsWithType>( + tree: Component, + type: ComponentClass): C[]; + + export function findRenderedComponentWithType

( + tree: Component, + type: ComponentClass

): Component; + export function findRenderedComponentWithType>( + tree: Component, + type: ComponentClass): C; + + export function createRenderer(): ShallowRenderer; + } + + interface SyntheticEventData { + altKey?: boolean; + button?: number; + buttons?: number; + clientX?: number; + clientY?: number; + changedTouches?: TouchList; + charCode?: boolean; + clipboardData?: DataTransfer; + ctrlKey?: boolean; + deltaMode?: number; + deltaX?: number; + deltaY?: number; + deltaZ?: number; + detail?: number; + getModifierState?(key: string): boolean; + key?: string; + keyCode?: number; + locale?: string; + location?: number; + metaKey?: boolean; + pageX?: number; + pageY?: number; + relatedTarget?: EventTarget; + repeat?: boolean; + screenX?: number; + screenY?: number; + shiftKey?: boolean; + targetTouches?: TouchList; + touches?: TouchList; + view?: AbstractView; + which?: number; + } + + interface EventSimulator { + (element: Element, eventData?: SyntheticEventData): void; + (component: Component, eventData?: SyntheticEventData): void; + } + + module ReactSimulate { + export var blur: EventSimulator; + export var change: EventSimulator; + export var click: EventSimulator; + export var cut: EventSimulator; + export var doubleClick: EventSimulator; + export var drag: EventSimulator; + export var dragEnd: EventSimulator; + export var dragEnter: EventSimulator; + export var dragExit: EventSimulator; + export var dragLeave: EventSimulator; + export var dragOver: EventSimulator; + export var dragStart: EventSimulator; + export var drop: EventSimulator; + export var focus: EventSimulator; + export var input: EventSimulator; + export var keyDown: EventSimulator; + export var keyPress: EventSimulator; + export var keyUp: EventSimulator; + export var mouseDown: EventSimulator; + export var mouseEnter: EventSimulator; + export var mouseLeave: EventSimulator; + export var mouseMove: EventSimulator; + export var mouseOut: EventSimulator; + export var mouseOver: EventSimulator; + export var mouseUp: EventSimulator; + export var paste: EventSimulator; + export var scroll: EventSimulator; + export var submit: EventSimulator; + export var touchCancel: EventSimulator; + export var touchEnd: EventSimulator; + export var touchMove: EventSimulator; + export var touchStart: EventSimulator; + export var wheel: EventSimulator; + } + + class ShallowRenderer { + getRenderOutput>(): E; + getRenderOutput(): ReactElement; + render(element: ReactElement, context?: any): void; + unmount(): void; + } +} + +declare namespace JSX { + import React = __React; + + interface Element extends React.ReactElement { } + interface ElementClass extends React.Component { + render(): JSX.Element; + } + interface ElementAttributesProperty { props: {}; } + + interface IntrinsicElements { + // HTML + a: React.HTMLAttributes; + abbr: React.HTMLAttributes; + address: React.HTMLAttributes; + area: React.HTMLAttributes; + article: React.HTMLAttributes; + aside: React.HTMLAttributes; + audio: React.HTMLAttributes; + b: React.HTMLAttributes; + base: React.HTMLAttributes; + bdi: React.HTMLAttributes; + bdo: React.HTMLAttributes; + big: React.HTMLAttributes; + blockquote: React.HTMLAttributes; + body: React.HTMLAttributes; + br: React.HTMLAttributes; + button: React.HTMLAttributes; + canvas: React.HTMLAttributes; + caption: React.HTMLAttributes; + cite: React.HTMLAttributes; + code: React.HTMLAttributes; + col: React.HTMLAttributes; + colgroup: React.HTMLAttributes; + data: React.HTMLAttributes; + datalist: React.HTMLAttributes; + dd: React.HTMLAttributes; + del: React.HTMLAttributes; + details: React.HTMLAttributes; + dfn: React.HTMLAttributes; + dialog: React.HTMLAttributes; + div: React.HTMLAttributes; + dl: React.HTMLAttributes; + dt: React.HTMLAttributes; + em: React.HTMLAttributes; + embed: React.HTMLAttributes; + fieldset: React.HTMLAttributes; + figcaption: React.HTMLAttributes; + figure: React.HTMLAttributes; + footer: React.HTMLAttributes; + form: React.HTMLAttributes; + h1: React.HTMLAttributes; + h2: React.HTMLAttributes; + h3: React.HTMLAttributes; + h4: React.HTMLAttributes; + h5: React.HTMLAttributes; + h6: React.HTMLAttributes; + head: React.HTMLAttributes; + header: React.HTMLAttributes; + hr: React.HTMLAttributes; + html: React.HTMLAttributes; + i: React.HTMLAttributes; + iframe: React.HTMLAttributes; + img: React.HTMLAttributes; + input: React.HTMLAttributes; + ins: React.HTMLAttributes; + kbd: React.HTMLAttributes; + keygen: React.HTMLAttributes; + label: React.HTMLAttributes; + legend: React.HTMLAttributes; + li: React.HTMLAttributes; + link: React.HTMLAttributes; + main: React.HTMLAttributes; + map: React.HTMLAttributes; + mark: React.HTMLAttributes; + menu: React.HTMLAttributes; + menuitem: React.HTMLAttributes; + meta: React.HTMLAttributes; + meter: React.HTMLAttributes; + nav: React.HTMLAttributes; + noscript: React.HTMLAttributes; + object: React.HTMLAttributes; + ol: React.HTMLAttributes; + optgroup: React.HTMLAttributes; + option: React.HTMLAttributes; + output: React.HTMLAttributes; + p: React.HTMLAttributes; + param: React.HTMLAttributes; + picture: React.HTMLAttributes; + pre: React.HTMLAttributes; + progress: React.HTMLAttributes; + q: React.HTMLAttributes; + rp: React.HTMLAttributes; + rt: React.HTMLAttributes; + ruby: React.HTMLAttributes; + s: React.HTMLAttributes; + samp: React.HTMLAttributes; + script: React.HTMLAttributes; + section: React.HTMLAttributes; + select: React.HTMLAttributes; + small: React.HTMLAttributes; + source: React.HTMLAttributes; + span: React.HTMLAttributes; + strong: React.HTMLAttributes; + style: React.HTMLAttributes; + sub: React.HTMLAttributes; + summary: React.HTMLAttributes; + sup: React.HTMLAttributes; + table: React.HTMLAttributes; + tbody: React.HTMLAttributes; + td: React.HTMLAttributes; + textarea: React.HTMLAttributes; + tfoot: React.HTMLAttributes; + th: React.HTMLAttributes; + thead: React.HTMLAttributes; + time: React.HTMLAttributes; + title: React.HTMLAttributes; + tr: React.HTMLAttributes; + track: React.HTMLAttributes; + u: React.HTMLAttributes; + ul: React.HTMLAttributes; + "var": React.HTMLAttributes; + video: React.HTMLAttributes; + wbr: React.HTMLAttributes; + + // SVG + svg: React.SVGElementAttributes; + + circle: React.SVGAttributes; + defs: React.SVGAttributes; + ellipse: React.SVGAttributes; + g: React.SVGAttributes; + line: React.SVGAttributes; + linearGradient: React.SVGAttributes; + mask: React.SVGAttributes; + path: React.SVGAttributes; + pattern: React.SVGAttributes; + polygon: React.SVGAttributes; + polyline: React.SVGAttributes; + radialGradient: React.SVGAttributes; + rect: React.SVGAttributes; + stop: React.SVGAttributes; + text: React.SVGAttributes; + tspan: React.SVGAttributes; + } +} diff --git a/react/react-global-0.13.3.d.ts b/react/react-global-0.13.3.d.ts new file mode 100644 index 0000000000..1728ba2fc8 --- /dev/null +++ b/react/react-global-0.13.3.d.ts @@ -0,0 +1,285 @@ +// Type definitions for React v0.13.3 (namespace) +// Project: http://facebook.github.io/react/ +// Definitions by: Asana , AssureSign , Microsoft +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +import React = __React; + +declare namespace __React { + // + // React.addons + // ---------------------------------------------------------------------- + + export module addons { + export var CSSTransitionGroup: CSSTransitionGroup; + export var TransitionGroup: TransitionGroup; + + export var LinkedStateMixin: LinkedStateMixin; + export var PureRenderMixin: PureRenderMixin; + + export function batchedUpdates( + callback: (a: A, b: B) => any, a: A, b: B): void; + export function batchedUpdates(callback: (a: A) => any, a: A): void; + export function batchedUpdates(callback: () => any): void; + + // deprecated: use petehunt/react-classset or JedWatson/classnames + export function classSet(cx: { [key: string]: boolean }): string; + export function classSet(...classList: string[]): string; + + export function cloneWithProps

( + element: DOMElement

, props: P): DOMElement

; + export function cloneWithProps

( + element: ClassicElement

, props: P): ClassicElement

; + export function cloneWithProps

( + element: ReactElement

, props: P): ReactElement

; + + export function createFragment( + object: { [key: string]: ReactNode }): ReactFragment; + + export function update(value: any[], spec: UpdateArraySpec): any[]; + export function update(value: {}, spec: UpdateSpec): any; + + // Development tools + export import Perf = ReactPerf; + export import TestUtils = ReactTestUtils; + } + + // + // React.addons (Transitions) + // ---------------------------------------------------------------------- + + interface TransitionGroupProps { + component?: ReactType; + childFactory?: (child: ReactElement) => ReactElement; + } + + interface CSSTransitionGroupProps extends TransitionGroupProps { + transitionName: string; + transitionAppear?: boolean; + transitionEnter?: boolean; + transitionLeave?: boolean; + } + + type CSSTransitionGroup = ComponentClass; + type TransitionGroup = ComponentClass; + + // + // React.addons (Mixins) + // ---------------------------------------------------------------------- + + interface ReactLink { + value: T; + requestChange(newValue: T): void; + } + + interface LinkedStateMixin extends Mixin { + linkState(key: string): ReactLink; + } + + interface PureRenderMixin extends Mixin { + } + + // + // Reat.addons.update + // ---------------------------------------------------------------------- + + interface UpdateSpecCommand { + $set?: any; + $merge?: {}; + $apply?(value: any): any; + } + + interface UpdateSpecPath { + [key: string]: UpdateSpec; + } + + type UpdateSpec = UpdateSpecCommand | UpdateSpecPath; + + interface UpdateArraySpec extends UpdateSpecCommand { + $push?: any[]; + $unshift?: any[]; + $splice?: any[][]; + } + + // + // React.addons.Perf + // ---------------------------------------------------------------------- + + interface ComponentPerfContext { + current: string; + owner: string; + } + + interface NumericPerfContext { + [key: string]: number; + } + + interface Measurements { + exclusive: NumericPerfContext; + inclusive: NumericPerfContext; + render: NumericPerfContext; + counts: NumericPerfContext; + writes: NumericPerfContext; + displayNames: { + [key: string]: ComponentPerfContext; + }; + totalTime: number; + } + + module ReactPerf { + export function start(): void; + export function stop(): void; + export function printInclusive(measurements: Measurements[]): void; + export function printExclusive(measurements: Measurements[]): void; + export function printWasted(measurements: Measurements[]): void; + export function printDOM(measurements: Measurements[]): void; + export function getLastMeasurements(): Measurements[]; + } + + // + // React.addons.TestUtils + // ---------------------------------------------------------------------- + + interface MockedComponentClass { + new(): any; + } + + module ReactTestUtils { + export import Simulate = ReactSimulate; + + export function renderIntoDocument

( + element: ReactElement

): Component; + export function renderIntoDocument>( + element: ReactElement): C; + + export function mockComponent( + mocked: MockedComponentClass, mockTagName?: string): typeof ReactTestUtils; + + export function isElementOfType( + element: ReactElement, type: ReactType): boolean; + export function isTextComponent(instance: Component): boolean; + export function isDOMComponent(instance: Component): boolean; + export function isCompositeComponent(instance: Component): boolean; + export function isCompositeComponentWithType( + instance: Component, + type: ComponentClass): boolean; + + export function findAllInRenderedTree( + tree: Component, + fn: (i: Component) => boolean): Component; + + export function scryRenderedDOMComponentsWithClass( + tree: Component, + className: string): DOMComponent[]; + export function findRenderedDOMComponentWithClass( + tree: Component, + className: string): DOMComponent; + + export function scryRenderedDOMComponentsWithTag( + tree: Component, + tagName: string): DOMComponent[]; + export function findRenderedDOMComponentWithTag( + tree: Component, + tagName: string): DOMComponent; + + export function scryRenderedComponentsWithType

( + tree: Component, + type: ComponentClass

): Component[]; + export function scryRenderedComponentsWithType>( + tree: Component, + type: ComponentClass): C[]; + + export function findRenderedComponentWithType

( + tree: Component, + type: ComponentClass

): Component; + export function findRenderedComponentWithType>( + tree: Component, + type: ComponentClass): C; + + export function createRenderer(): ShallowRenderer; + } + + interface SyntheticEventData { + altKey?: boolean; + button?: number; + buttons?: number; + clientX?: number; + clientY?: number; + changedTouches?: TouchList; + charCode?: boolean; + clipboardData?: DataTransfer; + ctrlKey?: boolean; + deltaMode?: number; + deltaX?: number; + deltaY?: number; + deltaZ?: number; + detail?: number; + getModifierState?(key: string): boolean; + key?: string; + keyCode?: number; + locale?: string; + location?: number; + metaKey?: boolean; + pageX?: number; + pageY?: number; + relatedTarget?: EventTarget; + repeat?: boolean; + screenX?: number; + screenY?: number; + shiftKey?: boolean; + targetTouches?: TouchList; + touches?: TouchList; + view?: AbstractView; + which?: number; + } + + interface EventSimulator { + (element: Element, eventData?: SyntheticEventData): void; + (component: Component, eventData?: SyntheticEventData): void; + } + + module ReactSimulate { + export var blur: EventSimulator; + export var change: EventSimulator; + export var click: EventSimulator; + export var cut: EventSimulator; + export var doubleClick: EventSimulator; + export var drag: EventSimulator; + export var dragEnd: EventSimulator; + export var dragEnter: EventSimulator; + export var dragExit: EventSimulator; + export var dragLeave: EventSimulator; + export var dragOver: EventSimulator; + export var dragStart: EventSimulator; + export var drop: EventSimulator; + export var focus: EventSimulator; + export var input: EventSimulator; + export var keyDown: EventSimulator; + export var keyPress: EventSimulator; + export var keyUp: EventSimulator; + export var mouseDown: EventSimulator; + export var mouseEnter: EventSimulator; + export var mouseLeave: EventSimulator; + export var mouseMove: EventSimulator; + export var mouseOut: EventSimulator; + export var mouseOver: EventSimulator; + export var mouseUp: EventSimulator; + export var paste: EventSimulator; + export var scroll: EventSimulator; + export var submit: EventSimulator; + export var touchCancel: EventSimulator; + export var touchEnd: EventSimulator; + export var touchMove: EventSimulator; + export var touchStart: EventSimulator; + export var wheel: EventSimulator; + } + + class ShallowRenderer { + getRenderOutput>(): E; + getRenderOutput(): ReactElement; + render(element: ReactElement, context?: any): void; + unmount(): void; + } +} From f9e6e567f4da28108dd99317203251565eb325e3 Mon Sep 17 00:00:00 2001 From: James Brantly Date: Wed, 14 Oct 2015 20:55:48 -0400 Subject: [PATCH 0083/1238] Fix `module` => `namespace` --- react/react-dom.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react/react-dom.d.ts b/react/react-dom.d.ts index e0d88e04ba..a2183b7eab 100644 --- a/react/react-dom.d.ts +++ b/react/react-dom.d.ts @@ -7,7 +7,7 @@ declare namespace __React { - module __DOM { + namespace __DOM { function findDOMNode( componentOrElement: __React.Component | Element): TElement; function findDOMNode( From 99fe3fa43b31bea4a9a3137b748e6474cc936e63 Mon Sep 17 00:00:00 2001 From: Luigi Trabacchin Date: Thu, 15 Oct 2015 11:56:18 +0200 Subject: [PATCH 0084/1238] Fullcalendar: Fixed callback parameters on eventDrop and eventResize --- fullCalendar/fullCalendar.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fullCalendar/fullCalendar.d.ts b/fullCalendar/fullCalendar.d.ts index 7552d5bfd9..6400dba7e0 100644 --- a/fullCalendar/fullCalendar.d.ts +++ b/fullCalendar/fullCalendar.d.ts @@ -198,10 +198,10 @@ declare module FullCalendar { eventConstraint?: BusinessHours | Timespan; eventDragStart?: (event: EventObject, jsEvent: MouseEvent, ui: any, view: ViewObject) => void; eventDragStop?: (event: EventObject, jsEvent: MouseEvent, ui: any, view: ViewObject) => void; - eventDrop?: (event: EventObject, dayDelta: number, minuteDelta: number, revertFunc: Function, jsEvent: Event, ui: any, view: ViewObject) => void; + eventDrop?: (event: EventObject, delta: moment.Duration, revertFunc: Function, jsEvent: Event, ui: any, view: ViewObject) => void; eventResizeStart?: (event: EventObject, jsEvent: MouseEvent, ui: any, view: ViewObject) => void; eventResizeStop?: (event: EventObject, jsEvent: MouseEvent, ui: any, view: ViewObject) => void; - eventResize?: (event: EventObject, dayDelta: number, minuteDelta: number, revertFunc: Function, jsEvent: Event, ui: any, view: ViewObject) => void; + eventResize?: (event: EventObject, delta: moment.Duration, revertFunc: Function, jsEvent: Event, ui: any, view: ViewObject) => void; } /* * Selection - http://arshaw.com/fullcalendar/docs/selection/ From 161890155f7c9b7e036be50d1ab7869971aaa716 Mon Sep 17 00:00:00 2001 From: Michel Weststrate Date: Thu, 15 Oct 2015 12:34:37 +0200 Subject: [PATCH 0085/1238] fixed typings issue as reported in #6225 --- mobservable-react/mobservable-react.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mobservable-react/mobservable-react.d.ts b/mobservable-react/mobservable-react.d.ts index f42627a857..e95fc69f5d 100644 --- a/mobservable-react/mobservable-react.d.ts +++ b/mobservable-react/mobservable-react.d.ts @@ -10,7 +10,7 @@ declare module "mobservable-react" { * Turns a React component or stateless render function into a reactive component. */ export function reactiveComponent

(clazz: React.ClassicComponentClass

): React.ClassicComponentClass

; + export function reactiveComponent>(target: TFunction): void; // decorator signature export function reactiveComponent

(clazz: React.ComponentClass

): React.ComponentClass

; - export function reactiveComponent>(target: TFunction): TFunction | void; // decorator signature export function reactiveComponent

(renderFunction: (props: P) => React.ReactElement): React.ClassicComponentClass

; } \ No newline at end of file From 640536586ae4f3a7db43b041a44caf64021c7610 Mon Sep 17 00:00:00 2001 From: Giedrius Grabauskas Date: Thu, 15 Oct 2015 15:17:03 +0300 Subject: [PATCH 0086/1238] flux-utils definitions added. --- flux/flux-utils.d.ts | 130 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 flux/flux-utils.d.ts diff --git a/flux/flux-utils.d.ts b/flux/flux-utils.d.ts new file mode 100644 index 0000000000..8437f9d4b5 --- /dev/null +++ b/flux/flux-utils.d.ts @@ -0,0 +1,130 @@ +// Type definitions for Flux/utils +// Project: http://facebook.github.io/flux/ +// Definitions by: Giedrius Grabauskas +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module FluxUtils { + + export class Container { + /** + * Create is used to transform a react class into a container + * that updates its state when relevant stores change. + * The provided base class must have static methods getStores() and calculateState(). + */ + static create(base: React.ComponentClass, options?: Object): React.ComponentClass; + } + + /** + * This class extends ReduceStore and defines the state as an immutable map. + */ + export class MapStore extends ReduceStore> { + + /** + * Access the value at the given key. + * Throws an error if the key does not exist in the cache. + */ + at(key: K): V; + + /** + * Check if the cache has a particular key + */ + has(key: K): boolean; + + /** + * Get the value of a particular key. + * Returns undefined if the key does not exist in the cache. + */ + get(key: K): V; + + /** + * Gets an array of keys and puts the values in a map if they exist, + * it allows providing a previous result to update instead of generating a new map. + * Providing a previous result allows the possibility of keeping the same reference if the keys did not change. + */ + getAll(keys: Iterable, prev?: Immutable.Map): Immutable.Map; + } + + export class ReduceStore extends Store { + /** + * Getter that exposes the entire state of this store. + * If your state is not immutable you should override this and not expose state directly. + */ + getState(): T; + + /** + * Constructs the initial state for this store. + * This is called once during construction of the store. + */ + getInitialState(): T; + + /** + * Reduces the current state, and an action to the new state of this store. + * All subclasses must implement this method. + * This method should be pure and have no side-effects. + */ + reduce(state: T, action: Object): T; + + /** + * Checks if two versions of state are the same. + * You do not need to override this if your state is immutable. + */ + areEqual(one: T, two: T): boolean; + + } + + export class Store { + + /** + * Constructs and registers an instance of this store with the given dispatcher. + */ + constructor(dispatcher: Flux.Dispatcher); + + /** + * Adds a listener to the store, when the store changes the given callback will be called. + * A token is returned that can be used to remove the listener. + * Calling the remove() function on the returned token will remove the listener. + */ + addListener(callback: Function): { remove: Function }; + + /** + * Returns the dispatcher this store is registered with. + */ + getDispatcher(): Flux.Dispatcher; + + /** + * Returns the dispatch token that the dispatcher recognizes this store by. + * Can be used to waitFor() this store. + */ + getDispatchToken(): string; + + /** + * Ask if a store has changed during the current dispatch. + * Can only be invoked while dispatching. + * This can be used for constructing derived stores that depend on data from other stores. + */ + hasChanged(): boolean; + + /** + *Emit an event notifying all listeners that this store has changed. + * This can only be invoked when dispatching. + * Changes are de-duplicated and resolved at the end of this store's __onDispatch function. + */ + __emitChange(): void; + + /** + * Subclasses must override this method. + * This is how the store receives actions from the dispatcher. + * All state mutation logic must be done during this method. + */ + __onDispatch(payload: Object): void; + } + + + +} + +declare module 'flux/utils' { + export = FluxUtils; +} From 8f7a76d23067e6bdf6e177ace30f9972ea55a88b Mon Sep 17 00:00:00 2001 From: bgrieder Date: Thu, 15 Oct 2015 15:36:21 +0200 Subject: [PATCH 0087/1238] Definitions for react-intl 1.2.0 --- react-intl/react-intl-tests.tsx | 137 ++++++++++++++++++++++++++++++++ react-intl/react-intl.d.ts | 97 ++++++++++++++++++++++ 2 files changed, 234 insertions(+) create mode 100644 react-intl/react-intl-tests.tsx create mode 100644 react-intl/react-intl.d.ts diff --git a/react-intl/react-intl-tests.tsx b/react-intl/react-intl-tests.tsx new file mode 100644 index 0000000000..648142a25d --- /dev/null +++ b/react-intl/react-intl-tests.tsx @@ -0,0 +1,137 @@ +/** + * Created by Bruno Grieder + */ +import * as React from 'react' + +import * as reactMixin from 'react-mixin' +import {IntlMixin, IntlComponent, FormattedNumber, FormattedMessage, FormattedDate} from 'react-intl' + + +/////////////////////////////////////////////////////////////////////////// +// +// This class does not use the mixin and react-mixin is not required +// The MESSQGES are maintained in the file +// To use it call +// +//////////////////////////////////////////////////////////////////////////// + + +const MESSAGES = { + + Sorry: { + 'en-US': 'Sorry {name}', + 'fr-FR': 'Désolé {name}' + } +} + + +module I18nDirect { + + export interface Props extends IntlComponent.Props {} +} + +@reactMixin.decorate( IntlMixin ) +class I18nDirect extends React.Component { //implements IntlComponent { + + private _currentLocale: string + private _messages: {[key: string]: string} + + constructor( props: I18nDirect.Props ) { + super( props ) + } + + //Mixin + //getIntlMessage: (key: string) => string = this['getIntlMessage'] + + + render() { + + return ( + +
    +
  • FormattedNumber:  + +
  • +
  • FormattedMessage:  + +
  • +
  • FormattedDate:  + +
  • +
+ + ) + } + + componentWillReceiveProps( nextProps: I18nDirect.Props ) { + this.compileMessages(nextProps) + } + + componentWillMount() { + this.compileMessages(this.props) + } + + + private compileMessages = (props: I18nDirect.Props): void => { + + let locale = ( props.locales && props.locales[ 0 ] ) || 'en-US' + + if (this._currentLocale !== locale) { + + this._messages = Object.keys( MESSAGES ).reduce( + ( dic, key ) => { + dic[ key ] = MESSAGES[ key ][ locale ] + return dic + }, + {} as { [key: string]: string; } + ) + } + } + +} + +/////////////////////////////////////////////////////////////////////////// +// +// This class uses the mixin and react-mixin is +// The MESSAGES are passed from messages property of the props +// To use it call +// +//////////////////////////////////////////////////////////////////////////// + + +module I18nMixin { + + export interface Props extends IntlComponent.Props {} +} + +@reactMixin.decorate( IntlMixin ) +class I18nMixin extends React.Component implements IntlComponent { + + private _currentLocale: string + + constructor( props: I18nMixin.Props ) { + super( props ) + } + + //Expose the method provided by the Mixin + getIntlMessage: (key: string) => string = this['getIntlMessage'] + + + render() { + + return ( + +
    +
  • FormattedNumber: + +
  • +
  • FormattedMessage: + {/* this uses the mixin */} +
  • +
+ + ) + } +} + +export { I18nDirect, I18nMixin } diff --git a/react-intl/react-intl.d.ts b/react-intl/react-intl.d.ts new file mode 100644 index 0000000000..d1ee2772b8 --- /dev/null +++ b/react-intl/react-intl.d.ts @@ -0,0 +1,97 @@ +// Type definitions for react-intl 1.2.0 +// Project: http://formatjs.io/react/ +// Definitions by: Bruno Grieder +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module "react-intl" { + + import * as React from 'react' + + module ReactIntl { + + + interface IIntlMixin extends React.Mixin { + getIntlMessage(key: string): string + } + + var IntlMixin: IIntlMixin + + module IntlComponent { + interface Props { + locales?: string[] + messages?: {[key: string]: any} + formats?: string[] + } + } + interface IntlComponent { + getIntlMessage(key: string): string; + } + + + module FormattedDate { + export interface Props extends IntlComponent.Props { + value: Date + day?: string + month?: string + year?: string + } + } + class FormattedDate extends React.Component {} + + + module FormattedTime { + export interface Props extends IntlComponent.Props { + value: Date + day?: string + month?: string + year?: string + format?: string + } + } + class FormattedTime extends React.Component {} + + + module FormattedRelative { + export interface Props extends IntlComponent.Props { + value: number + units?: string //"second", "minute", "hour", "day", "month" or "year" + style?: string //"best fit" (default) or "numeric" + format?: string + } + } + class FormattedRelative extends React.Component {} + + + module FormattedMessage { + export interface Props extends IntlComponent.Props { + message: string; + [prop: string]: any + } + } + class FormattedMessage extends React.Component {} + + + module FormattedHTMLMessage { + export interface Props extends IntlComponent.Props { + message: string; + [prop: string]: any + } + } + class FormattedHTMLMessage extends React.Component {} + + + module FormattedNumber { + export interface Props extends IntlComponent.Props { + value: number + style?: string + currency?: string + format?: string + } + } + class FormattedNumber extends React.Component {} + + } + + export = ReactIntl + +} \ No newline at end of file From 977932ec0fe59cde82112441fc7afbf83a6908c5 Mon Sep 17 00:00:00 2001 From: bgrieder Date: Thu, 15 Oct 2015 16:00:09 +0200 Subject: [PATCH 0088/1238] clean-up of test file --- react-intl/react-intl-tests.tsx | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/react-intl/react-intl-tests.tsx b/react-intl/react-intl-tests.tsx index 648142a25d..1a5aba9b31 100644 --- a/react-intl/react-intl-tests.tsx +++ b/react-intl/react-intl-tests.tsx @@ -30,8 +30,7 @@ module I18nDirect { export interface Props extends IntlComponent.Props {} } -@reactMixin.decorate( IntlMixin ) -class I18nDirect extends React.Component { //implements IntlComponent { +class I18nDirect extends React.Component { private _currentLocale: string private _messages: {[key: string]: string} @@ -40,9 +39,6 @@ class I18nDirect extends React.Component { //implements I super( props ) } - //Mixin - //getIntlMessage: (key: string) => string = this['getIntlMessage'] - render() { From b5956f2bef11b743b05366023f619039f2ba3c1a Mon Sep 17 00:00:00 2001 From: tkqubo Date: Thu, 15 Oct 2015 23:54:55 +0900 Subject: [PATCH 0089/1238] Revert "Merge webpack-env.* into webpack.*" This reverts commit b123aa5469db5e5a56f8517eca31c1cdaf569ed4. --- webpack/webpack-env-tests.ts | 15 +++++ webpack/webpack-env.d.ts | 103 +++++++++++++++++++++++++++++++++++ webpack/webpack-tests.ts | 19 ------- webpack/webpack.d.ts | 98 --------------------------------- 4 files changed, 118 insertions(+), 117 deletions(-) create mode 100644 webpack/webpack-env-tests.ts create mode 100644 webpack/webpack-env.d.ts diff --git a/webpack/webpack-env-tests.ts b/webpack/webpack-env-tests.ts new file mode 100644 index 0000000000..b4a9693ecf --- /dev/null +++ b/webpack/webpack-env-tests.ts @@ -0,0 +1,15 @@ +/// + +interface SomeModule { + someMethod(): void; +} + +let someModule = require('./someModule'); +someModule.someMethod(); + +let context = require.context('./somePath', true); +let contextModule = context('./someModule'); + +require(['./someModule', './otherModule'], (someModule: SomeModule, otherModule: any) => { + +}); diff --git a/webpack/webpack-env.d.ts b/webpack/webpack-env.d.ts new file mode 100644 index 0000000000..01ea6e404c --- /dev/null +++ b/webpack/webpack-env.d.ts @@ -0,0 +1,103 @@ +// Type definitions for webpack 1.12.2 (module API) +// Project: https://github.com/webpack/webpack +// Definitions by: use-strict +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/** + * Webpack module API - variables and global functions available inside modules + */ + +declare namespace __WebpackModuleApi { + interface RequireContext { + keys(): string[]; + (id: string): T; + resolve(id: string): string; + } + + interface RequireFunction { + /** + * Returns the exports from a dependency. The call is sync. No request to the server is fired. The compiler ensures that the dependency is available. + */ + (path: string): T; + /** + * Behaves similar to require.ensure, but the callback is called with the exports of each dependency in the paths array. There is no option to provide a chunk name. + */ + (paths: string[], callback: (...modules: any[]) => void): void; + /** + * Download additional dependencies on demand. The paths array lists modules that should be available. When they are, callback is called. If the callback is a function expression, dependencies in that source part are extracted and also loaded on demand. A single request is fired to the server, except if all modules are already available. + * + * This creates a chunk. The chunk can be named. If a chunk with this name already exists, the dependencies are merged into that chunk and that chunk is used. + */ + ensure: (paths: string[], callback: (require: (path: string) => T) => void) => void; + context: (path: string, deep?: boolean, filter?: RegExp) => RequireContext; + /** + * Returns the module id of a dependency. The call is sync. No request to the server is fired. The compiler ensures that the dependency is available. + * + * The module id is a number in webpack (in contrast to node.js where it is a string, the filename). + */ + resolve(path: string): number; + /** + * Like require.resolve, but doesn’t include the module into the bundle. It’s a weak dependency. + */ + resolveWeak(path: string): number; + /** + * Ensures that the dependency is available, but don’t execute it. This can be use for optimizing the position of a module in the chunks. + */ + include(path: string): void; + /** + * Multiple requires to the same module result in only one module execution and only one export. Therefore a cache in the runtime exists. Removing values from this cache cause new module execution and a new export. This is only needed in rare cases (for compatibility!). + */ + cache: { + [id: string]: any; + } + } +} + +declare var require: __WebpackModuleApi.RequireFunction; + +/** + * The resource query of the current module. + * + * e.g. __resourceQuery === "?test" // Inside "file.js?test" + */ +declare var __resourceQuery: string; + +/** + * Equals the config options output.publicPath. + */ +declare var __webpack_public_path__: string; + +/** + * The raw require function. This expression isn’t parsed by the Parser for dependencies. + */ +declare var __webpack_require__: any; + +/** + * The internal chunk loading function + * + * @param chunkId The id for the chunk to load. + * @param callback A callback function called once the chunk is loaded. + */ +declare var __webpack_chunk_load__: (chunkId: any, callback: (require: (id: string) => any) => void) => void; + +/** + * Access to the internal object of all modules. + */ +declare var __webpack_modules__: any[]; + +/** + * Access to the hash of the compilation. + * + * Only available with the HotModuleReplacementPlugin or the ExtendedAPIPlugin + */ +declare var __webpack_hash__: any; + +/** + * Generates a require function that is not parsed by webpack. Can be used to do cool stuff with a global require function if available. + */ +declare var __non_webpack_require__: any; + +/** + * Equals the config option debug + */ +declare var DEBUG: boolean; \ No newline at end of file diff --git a/webpack/webpack-tests.ts b/webpack/webpack-tests.ts index 5a70c2e102..27a4a53854 100644 --- a/webpack/webpack-tests.ts +++ b/webpack/webpack-tests.ts @@ -386,22 +386,3 @@ plugin = new webpack.ExtendedAPIPlugin(); plugin = new webpack.NoErrorsPlugin(); plugin = new webpack.WatchIgnorePlugin(paths); -// -// http://webpack.github.io/docs/api-in-modules.html -// - -interface SomeModule { - someMethod(): void; -} - -let someModule: SomeModule = require('./someModule'); -someModule.someMethod(); - -let context2 = require.context('./somePath', true); -let contextModule: SomeModule = context2('./someModule'); - -require(['./someModule', './otherModule'], (someModule: SomeModule, otherModule: any) => { - -}); - - diff --git a/webpack/webpack.d.ts b/webpack/webpack.d.ts index 82cf564585..f2049bbc94 100644 --- a/webpack/webpack.d.ts +++ b/webpack/webpack.d.ts @@ -259,101 +259,3 @@ declare module "webpack" { export = webpack; } -/** - * Webpack module API - variables and global functions available inside modules - */ - -declare namespace __WebpackModuleApi { - interface RequireContext { - keys(): string[]; - (id: string): T; - resolve(id: string): string; - } - - interface RequireFunction { - /** - * Returns the exports from a dependency. The call is sync. No request to the server is fired. The compiler ensures that the dependency is available. - */ - (path: string): T; - /** - * Behaves similar to require.ensure, but the callback is called with the exports of each dependency in the paths array. There is no option to provide a chunk name. - */ - (paths: string[], callback: (...modules: any[]) => void): void; - /** - * Download additional dependencies on demand. The paths array lists modules that should be available. When they are, callback is called. If the callback is a function expression, dependencies in that source part are extracted and also loaded on demand. A single request is fired to the server, except if all modules are already available. - * - * This creates a chunk. The chunk can be named. If a chunk with this name already exists, the dependencies are merged into that chunk and that chunk is used. - */ - ensure: (paths: string[], callback: (require: (path: string) => T) => void) => void; - context: (path: string, deep?: boolean, filter?: RegExp) => RequireContext; - /** - * Returns the module id of a dependency. The call is sync. No request to the server is fired. The compiler ensures that the dependency is available. - * - * The module id is a number in webpack (in contrast to node.js where it is a string, the filename). - */ - resolve(path: string): number; - /** - * Like require.resolve, but doesn’t include the module into the bundle. It’s a weak dependency. - */ - resolveWeak(path: string): number; - /** - * Ensures that the dependency is available, but don’t execute it. This can be use for optimizing the position of a module in the chunks. - */ - include(path: string): void; - /** - * Multiple requires to the same module result in only one module execution and only one export. Therefore a cache in the runtime exists. Removing values from this cache cause new module execution and a new export. This is only needed in rare cases (for compatibility!). - */ - cache: { - [id: string]: any; - } - } -} - -declare var require: __WebpackModuleApi.RequireFunction; - -/** - * The resource query of the current module. - * - * e.g. __resourceQuery === "?test" // Inside "file.js?test" - */ -declare var __resourceQuery: string; - -/** - * Equals the config options output.publicPath. - */ -declare var __webpack_public_path__: string; - -/** - * The raw require function. This expression isn’t parsed by the Parser for dependencies. - */ -declare var __webpack_require__: any; - -/** - * The internal chunk loading function - * - * @param chunkId The id for the chunk to load. - * @param callback A callback function called once the chunk is loaded. - */ -declare var __webpack_chunk_load__: (chunkId: any, callback: (require: (id: string) => any) => void) => void; - -/** - * Access to the internal object of all modules. - */ -declare var __webpack_modules__: any[]; - -/** - * Access to the hash of the compilation. - * - * Only available with the HotModuleReplacementPlugin or the ExtendedAPIPlugin - */ -declare var __webpack_hash__: any; - -/** - * Generates a require function that is not parsed by webpack. Can be used to do cool stuff with a global require function if available. - */ -declare var __non_webpack_require__: any; - -/** - * Equals the config option debug - */ -declare var DEBUG: boolean; From cf0a8f5d7054f667eb8549edd50ca7f1d18b8ca3 Mon Sep 17 00:00:00 2001 From: Cyril Schumacher Date: Thu, 15 Oct 2015 16:58:53 +0200 Subject: [PATCH 0090/1238] Update FileSaver: add the parameter: "disableAutoBOM". --- FileSaver/FileSaver-tests.ts | 5 +++-- FileSaver/FileSaver.d.ts | 10 ++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/FileSaver/FileSaver-tests.ts b/FileSaver/FileSaver-tests.ts index 6a5426a6a2..4cfae373e3 100644 --- a/FileSaver/FileSaver-tests.ts +++ b/FileSaver/FileSaver-tests.ts @@ -6,6 +6,7 @@ function testSaveAs() { var data: Blob = new Blob(["Hello, world!"], {type: "text/plain;charset=utf-8"}); var filename: string = 'hello world.txt'; - - saveAs(data, filename); + var disableAutoBOM = true; + + saveAs(data, filename, disableAutoBOM); } diff --git a/FileSaver/FileSaver.d.ts b/FileSaver/FileSaver.d.ts index 0b6cc75d60..fa5f31947e 100644 --- a/FileSaver/FileSaver.d.ts +++ b/FileSaver/FileSaver.d.ts @@ -20,8 +20,14 @@ interface FileSaver { * @summary File name. * @type {DOMString} */ - filename: string + filename: string, + + /** + * @summary Disable Unicode text encoding hints or not. + * @type {boolean} + */ + disableAutoBOM?: boolean ): void } -declare var saveAs: FileSaver; \ No newline at end of file +declare var saveAs: FileSaver; From 14d66bda05b1996ac36137e1d38334bc6095f165 Mon Sep 17 00:00:00 2001 From: Rob Howard Date: Thu, 15 Oct 2015 08:28:29 -0700 Subject: [PATCH 0091/1238] Initial commit of office-js.d.ts Includes basic tests for Word and Excel objects --- office-js/office-js-tests.ts | 175 ++ office-js/office-js.d.ts | 5300 ++++++++++++++++++++++++++++++++++ 2 files changed, 5475 insertions(+) create mode 100644 office-js/office-js-tests.ts create mode 100644 office-js/office-js.d.ts diff --git a/office-js/office-js-tests.ts b/office-js/office-js-tests.ts new file mode 100644 index 0000000000..cd568d0e6f --- /dev/null +++ b/office-js/office-js-tests.ts @@ -0,0 +1,175 @@ +/* +------------------------------------------ START OF LICENSE ----------------------------------------- +office-js +Copyright (c) Microsoft Corporation +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +----------------------------------------------- END OF LICENSE ------------------------------------------ +*/ + +/// + +function test_excel() { + + // Range + Excel.run(function(ctx) { + var range = ctx.workbook.getSelectedRange().load("values"); + return ctx.sync() + .then(function() { + var vals = range.values; + for (var i = 0; i < vals.length; i++){ + for (var j = 0; j < vals[i].length; j++){ + vals[i][j] = vals[i][j].toUpperCase(); + } + } + range.values = vals; + }) + .then(ctx.sync); + }).catch(function (error) { + console.log(error); + }); + + + // Chart + Excel.run(function (ctx) { + var sheet = ctx.workbook.worksheets.getItem("Sheet1"); + + var range = sheet.getRange("A1:B3"); + range.values = [ + ["", "Gender"], + ["Male", 12], + ["Female", 14] + ]; + + var chart = sheet.charts.add("pie", range, "auto"); + + chart.format.fill.setSolidColor("F8F8FF"); + + chart.title.text = "Class Demographics"; + chart.title.format.font.bold = true; + chart.title.format.font.size = 18; + chart.title.format.font.color = "568568"; + + chart.legend.position = "right"; + chart.legend.format.font.name = "Algerian"; + chart.legend.format.font.size = 13; + + chart.dataLabels.showPercentage = true; + chart.dataLabels.format.font.size = 15; + chart.dataLabels.format.font.color = "444444"; + + var points = chart.series.getItemAt(0).points; + points.getItemAt(0).format.fill.setSolidColor("8FBC8F"); + points.getItemAt(1).format.fill.setSolidColor("D87093"); + + return ctx.sync(); + }).catch(function (error) { + console.log(error); + }); + + + // Table + Excel.run(function (ctx) { + var rows = ctx.workbook.tables.getItem("Table1").rows.load("values"); + return ctx.sync() + .then(function () { + var largestRow = 0; + var largestValue = 0; + + for (var i = 0; i < rows.items.length; i++){ + if (rows.items[i].values[0][1] > largestValue){ + largestRow = i; + largestValue = rows.items[i].values[0][1]; + } + } + + var largestRowRng = rows.getItemAt(largestRow).getRange(); + largestRowRng.format.fill.color = "#ff0000"; + + }) + .then(ctx.sync); + }).catch(function (error) { + console.log(error); + }); + +} + +function test_word() { + + // Search + Word.run(function (context) { + + // Create a proxy object for the document body. + var body = context.document.body; + + // Setup the search options. + var options = Word.SearchOptions.newObject(context); + options.matchCase = false + + // Queue a commmand to search the document. + var searchResults = context.document.body.search('video', options); + + // Queue a commmand to load the results. + context.load(searchResults, 'text, font'); + + // Synchronize the document state by executing the queued-up commands, + // and return a promise to indicate task completion. + return context.sync().then(function () { + var results = 'Found count: ' + searchResults.items.length + + '; we highlighted the results.'; + + // Queue a command to change the font for each found item. + for (var i = 0; i < searchResults.items.length; i++) { + searchResults.items[i].font.color = '#FF0000' // Change color to Red + searchResults.items[i].font.highlightColor = '#FFFF00'; + searchResults.items[i].font.bold = true; + } + + // Synchronize the document state by executing the queued-up commands, + // and return a promise to indicate task completion. + return context.sync().then(function () { + console.log(results); + }); + }); + }) + .catch(function (error) { + console.log('Error: ' + JSON.stringify(error)); + if (error instanceof OfficeExtension.Error) { + console.log('Debug info: ' + JSON.stringify(error.debugInfo)); + } + }); + + + // Content control + Word.run(function (context) { + + // Create a proxy range object for the current selection. + var range = context.document.getSelection(); + + // Queue a commmand to create the content control. + var myContentControl = range.insertContentControl(); + myContentControl.tag = 'Customer-Address'; + myContentControl.title = 'Enter Customer Address Here:'; + myContentControl.style = 'Heading 2'; + myContentControl.insertText('One Microsoft Way, Redmond, WA 98052', 'replace'); + myContentControl.cannotEdit = true; + myContentControl.appearance = 'tags'; + + // Queue a command to load the id property for the content control you created. + context.load(myContentControl, 'id'); + + // Synchronize the document state by executing the queued-up commands, + // and return a promise to indicate task completion. + return context.sync().then(function () { + console.log('Created content control with id: ' + myContentControl.id); + }); + }) + .catch(function (error) { + console.log('Error: ' + JSON.stringify(error)); + if (error instanceof OfficeExtension.Error) { + console.log('Debug info: ' + JSON.stringify(error.debugInfo)); + } + }); + +} diff --git a/office-js/office-js.d.ts b/office-js/office-js.d.ts new file mode 100644 index 0000000000..cb146fae1f --- /dev/null +++ b/office-js/office-js.d.ts @@ -0,0 +1,5300 @@ +/* +------------------------------------------ START OF LICENSE ----------------------------------------- +office-js +Copyright (c) Microsoft Corporation +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +----------------------------------------------- END OF LICENSE ------------------------------------------ +*/ + +// Type definitions for Office.js +// Project: http://dev.office.com +// Definitions by: OfficeDev +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +declare module Office { + export var context: Context; + /** + * This method is called after the Office API was loaded. + * @param reason Indicates how the app was initialized + */ + export function initialize(reason: InitializationReason): void; + /** + * Indicates if the large namespace for objects will be used or not. + * @param useShortNamespace Indicates if 'true' that the short namespace will be used + */ + export function useShortNamespace(useShortNamespace: boolean): void; + // Enumerations + export enum AsyncResultStatus { + /** + * Operation succeeded + */ + Succeeded, + /** + * Operation failed, check error object + */ + Failed + } + export enum InitializationReason { + /** + * Indicates the app was just inserted in the document + */ + Inserted, + /** + * Indicates if the extension already existed in the document + */ + DocumentOpened + } + // Objects + export interface AsyncResult { + asyncContext: any; + status: AsyncResultStatus; + error: Error; + value: any; + } + export interface Context { + contentLanguage: string; + displayLanguage: string; + license: string; + touchEnabled: boolean; + requirements: { + /** + * Check if the specified requirement set is supported by the host Office application. + * @param name - Set name. e.g.: "MatrixBindings". + * @param minVersion - The minimum required version. + */ + isSetSupported(name: string, minVersion?: number): boolean; + } + } + export interface Error { + message: string; + name: string; + } +} +declare module OfficeExtension { + /** An abstract proxy object that represents an object in an Office document. You create proxy objects from the context (or from other proxy objects), add commands to a queue to act on the object, and then synchronize the proxy object state with the document by calling "context.sync()". */ + class ClientObject { + /** The request context associated with the object */ + context: ClientRequestContext; + } +} +declare module OfficeExtension { + interface LoadOption { + select?: string | string[]; + expand?: string | string[]; + top?: number; + skip?: number; + } + /** An abstract RequestContext object that facilitates requests to the host Office application. The "Excel.run" and "Word.run" methods provide a request context. */ + class ClientRequestContext { + constructor(url?: string); + /** Collection of objects that are tracked for automatic adjustments based on surrounding changes in the document. */ + trackedObjects: TrackedObjects; + /** Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. */ + load(object: ClientObject, option?: string | string[] | LoadOption): void; + /** Adds a trace message to the queue. If the promise returned by "context.sync()" is rejected due to an error, this adds a ".traceMessages" array to the OfficeExtension.Error object, containing all trace messages that were executed. These messages can help you monitor the program execution sequence and detect the cause of the error. */ + trace(message: string): void; + /** Synchronizes the state between JavaScript proxy objects and the Office document, by executing instructions queued on the request context and retrieving properties of loaded Office objects for use in your code.�This method returns a promise, which is resolved when the synchronization is complete. */ + sync(passThroughValue?: T): IPromise; + } +} +declare module OfficeExtension { + /** Contains the result for methods that return primitive types. The object's value property is retrieved from the document after "context.sync()" is invoked. */ + class ClientResult { + /** The value of the result that is retrieved from the document after "context.sync()" is invoked. */ + value: T; + } +} +declare module OfficeExtension { + /** The error object returned by "context.sync()", if a promise is rejected due to an error while processing the request. */ + class Error { + /** Error name: "OfficeExtension.Error".*/ + name: string; + /** The error message passed through from the host Office application. */ + message: string; + /** Stack trace, if applicable. */ + stack: string; + /** Error code string, such as "InvalidArgument". */ + code: string; + /** Trace messages (if any) that were added via a "context.trace()" invocation before calling "context.sync()". If there was an error, this contains all trace messages that were executed before the error occurred. These messages can help you monitor the program execution sequence and detect the case of the error. */ + traceMessages: Array; + /** Debug info, if applicable. The ".errorLocation" property can describe the object and method or property that caused the error. */ + debugInfo: { + /** If applicable, will return the object type and the name of the method or property that caused the error. */ + errorLocation?: string; + }; + } +} +declare module OfficeExtension { + class ErrorCodes { + static accessDenied: string; + static generalException: string; + static activityLimitReached: string; + } +} +declare module OfficeExtension { + /** A Promise object that represents a deferred interaction with the host Office application. Promises can be chained via ".then", and errors can be caught via ".catch". Remember to always use a ".catch" on the outer promise, and to return intermediary promises so as not to break the promise chain. */ + interface IPromise { + /** + * This method will be called once the previous promise has been resolved. + * Both the onFulfilled on onRejected callbacks are optional. + * If either or both are omitted, the next onFulfilled/onRejected in the chain will be called called. + * @returns A new promise for the value or error that was returned from onFulfilled/onRejected. + */ + then(onFulfilled?: (value: R) => IPromise, onRejected?: (error: any) => IPromise): IPromise; + /** + * This method will be called once the previous promise has been resolved. + * Both the onFulfilled on onRejected callbacks are optional. + * If either or both are omitted, the next onFulfilled/onRejected in the chain will be called called. + * @returns A new promise for the value or error that was returned from onFulfilled/onRejected. + */ + then(onFulfilled?: (value: R) => IPromise, onRejected?: (error: any) => U): IPromise; + /** + * This method will be called once the previous promise has been resolved. + * Both the onFulfilled on onRejected callbacks are optional. + * If either or both are omitted, the next onFulfilled/onRejected in the chain will be called called. + * @returns A new promise for the value or error that was returned from onFulfilled/onRejected. + */ + then(onFulfilled?: (value: R) => IPromise, onRejected?: (error: any) => void): IPromise; + /** + * This method will be called once the previous promise has been resolved. + * Both the onFulfilled on onRejected callbacks are optional. + * If either or both are omitted, the next onFulfilled/onRejected in the chain will be called called. + * @returns A new promise for the value or error that was returned from onFulfilled/onRejected. + */ + then(onFulfilled?: (value: R) => U, onRejected?: (error: any) => IPromise): IPromise; + /** + * This method will be called once the previous promise has been resolved. + * Both the onFulfilled on onRejected callbacks are optional. + * If either or both are omitted, the next onFulfilled/onRejected in the chain will be called called. + * @returns A new promise for the value or error that was returned from onFulfilled/onRejected. + */ + then(onFulfilled?: (value: R) => U, onRejected?: (error: any) => U): IPromise; + /** + * This method will be called once the previous promise has been resolved. + * Both the onFulfilled on onRejected callbacks are optional. + * If either or both are omitted, the next onFulfilled/onRejected in the chain will be called called. + * @returns A new promise for the value or error that was returned from onFulfilled/onRejected. + */ + then(onFulfilled?: (value: R) => U, onRejected?: (error: any) => void): IPromise; + /** + * Catches failures or exceptions from actions within the promise, or from an unhandled exception earlier in the call stack. + * @param onRejected function to be called if or when the promise rejects. + */ + catch(onRejected?: (error: any) => IPromise): IPromise; + /** + * Catches failures or exceptions from actions within the promise, or from an unhandled exception earlier in the call stack. + * @param onRejected function to be called if or when the promise rejects. + */ + catch(onRejected?: (error: any) => U): IPromise; + /** + * Catches failures or exceptions from actions within the promise, or from an unhandled exception earlier in the call stack. + * @param onRejected function to be called if or when the promise rejects. + */ + catch(onRejected?: (error: any) => void): IPromise; + } +} +declare module OfficeExtension { + /** Collection of tracked objects, contained within a request context. See "context.trackedObjects" for more information. */ + class TrackedObjects { + /** Track a new object for automatic adjustment based on surrounding changes in the document. Only some object types require this. If you are using an object across ".sync" calls and outside the sequential execution of a ".run" batch, and get an "InvalidObjectPath" error when setting a property or invoking a method on the object, you needed to have added the object to the tracked object collection when the object was first created. */ + add(object: ClientObject): void; + /** Track a new object for automatic adjustment based on surrounding changes in the document. Only some object types require this. If you are using an object across ".sync" calls and outside the sequential execution of a ".run" batch, and get an "InvalidObjectPath" error when setting a property or invoking a method on the object, you needed to have added the object to the tracked object collection when the object was first created. */ + add(objects: ClientObject[]): void; + /** Release the memory associated with an object that was previously added to this collection. Having many tracked objects slows down the host application, so please remember to free any objects you add, once you're done using them. You will need to call "context.sync()" before the memory release takes effect. */ + remove(object: ClientObject): void; + /** Release the memory associated with an object that was previously added to this collection. Having many tracked objects slows down the host application, so please remember to free any objects you add, once you're done using them. You will need to call "context.sync()" before the memory release takes effect. */ + remove(objects: ClientObject[]): void; + } +} + +declare module Office { + /** + * Returns a promise of an object described in the expression. Callback is invoked only if method fails. + * @param expression The object to be retrieved. Example "bindings#BindingName", retrieves a binding promise for a binding named 'BindingName' + * @param callback The optional callback method + */ + export function select(expression: string, callback?: (result: AsyncResult) => void): Binding; + // Enumerations + export enum ActiveView { + Read, + Edit + } + export enum BindingType { + /** + * Text based Binding + */ + Text, + /** + * Matrix based Binding + */ + Matrix, + /** + * Table based Binding + */ + Table + } + export enum CoercionType { + /** + * Coerce as Text + */ + Text, + /** + * Coerce as Matrix + */ + Matrix, + /** + * Coerce as Table + */ + Table, + /** + * Coerce as HTML + */ + Html, + /** + * Coerce as Office Open XML + */ + Ooxml, + /** + * Coerce as JSON object containing an array of the ids, titles, and indexes of the selected slides. + */ + SlideRange + } + export enum DocumentMode { + /** + * Document in Read Only Mode + */ + ReadOnly, + /** + * Document in Read/Write Mode + */ + ReadWrite + } + export enum EventType { + /** + * Occurs when the user changes the current view of the document. + */ + ActiveViewChanged, + /** + * Triggers when a binding level data change happens + */ + BindingDataChanged, + /** + * Triggers when a binding level selection happens + */ + BindingSelectionChanged, + /** + * Triggers when a document level selection happens + */ + DocumentSelectionChanged, + /** + * Triggers when a customXmlPart node was deleted + */ + NodeDeleted, + /** + * Triggers when a customXmlPart node was inserted + */ + NodeInserted, + /** + * Triggers when a customXmlPart node was replaced + */ + NodeReplaced, + /** + * Triggers when settings change in a co-Auth session. + */ + SettingsChanged, + /** + * Triggers when a Task selection happens in Project. + */ + TaskSelectionChanged, + /** + * Triggers when a Resource selection happens in Project. + */ + ResourceSelectionChanged, + /** + * Triggers when a View selection happens in Project. + */ + ViewSelectionChanged + } + export enum FileType { + /** + * Returns the file as plain text + */ + Text, + /** + * Returns the file as a byte array + */ + Compressed, + /** + * Returns the file in PDF format as a byte array + */ + Pdf + } + export enum FilterType { + /** + * Returns all items + */ + All, + /** + * Returns only visible items + */ + OnlyVisible + } + export enum GoToType { + /** + * Goes to a binding object using the specified binding id. + */ + Binding, + /** + * Goes to a named item using that item's name. + * In Excel, you can use any structured reference for a named range or table: "Worksheet2!Table1" + */ + NamedItem, + /** + * Goes to a slide using the specified id. + */ + Slide, + /** + * Goes to the specified index by slide number or enum Office.Index + */ + Index + } + export enum Index { + First, + Last, + Next, + Previous + } + export enum SelectionMode { + Default, + Selected, + None + } + export enum ValueFormat { + /** + * Returns items without format + */ + Unformatted, + /** + * Returns items with format + */ + Formatted + } + // Objects + export interface Binding { + document: Document; + /** + * Id of the Binding + */ + id: string; + type: BindingType; + /** + * Adds an event handler to the object using the specified event type. + * @param eventType The event type. For binding it can be 'bindingDataChanged' and 'bindingSelectionChanged' + * @param handler The name of the handler + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + addHandlerAsync(eventType: EventType, handler: any, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Returns the current selection. + * @param options Syntax example: {coercionType: 'matrix,'valueFormat: 'formatted', filterType:'all'} + * coercionType: The expected shape of the selection. If not specified returns the bindingType shape. Use Office.CoercionType or text value. + * valueFormat: Get data with or without format. Use Office.ValueFormat or text value. + * startRow: Used in partial get for table/matrix. Indicates the start row. + * startColumn: Used in partial get for table/matrix. Indicates the start column. + * rowCount: Used in partial get for table/matrix. Indicates the number of rows from the start row. + * columnCount: Used in partial get for table/matrix. Indicates the number of columns from the start column. + * filterType: Get the visible or all the data. Useful when filtering data. Use Office.FilterType or text value. + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + getDataAsync(options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Removes an event handler from the object using the specified event type. + * @param eventType The event type. For binding can be 'bindingDataChanged' and 'bindingSelectionChanged' + * @param options Syntax example: {handler:eventHandler} + * handler: Indicates a specific handler to be removed, if not specified all handlers are removed + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + removeHandlerAsync(eventType: EventType, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Writes the specified data into the current selection. + * @param data The data to be set. Either a string or value, 2d array or TableData object + * @param options Syntax example: {coercionType:Office.CoercionType.Matrix} or {coercionType: 'matrix'} + * coercionType: Explicitly sets the shape of the data object. Use Office.CoercionType or text value. If not supplied is inferred from the data type. + * startRow: Used in partial set for table/matrix. Indicates the start row. + * startColumn: Used in partial set for table/matrix. Indicates the start column. + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + setDataAsync(data: any, options?: any, callback?: (result: AsyncResult) => void): void; + } + export interface Bindings { + document: Document; + /** + * Creates a binding against a named object in the document + * @param itemName Name of the bindable object in the document. For Example 'MyExpenses' table in Excel." + * @param bindingType The Office BindingType for the data + * @param options Syntax example: {id: "BindingID"} + * id: Name of the binding, autogenerated if not supplied. + * asyncContext: Object keeping state for the callback + * columns: The string[] of the columns involved in the binding + * @param callback The optional callback method + */ + addFromNamedItemAsync(itemName: string, bindingType: BindingType, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Create a binding by prompting the user to make a selection on the document. + * @param bindingType The Office BindingType for the data + * @param options addFromPromptAsyncOptions- e.g. {promptText: "Please select data", id: "mySales"} + * promptText: Greet your users with a friendly word. + * asyncContext: Object keeping state for the callback + * id: Identifier. + * sampleData: A TableData that gives sample table in the Dialog.TableData.Headers is [][] of string. + * @param callback The optional callback method + */ + addFromPromptAsync(bindingType: BindingType, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Create a binding based on what the user's current selection. + * @param bindingType The Office BindingType for the data + * @param options addFromSelectionAsyncOptions- e.g. {id: "BindingID"} + * id: Identifier. + * asyncContext: Object keeping state for the callback + * columns: The string[] of the columns involved in the binding + * sampleData: A TableData that gives sample table in the Dialog.TableData.Headers is [][] of string. + * @param callback The optional callback method + */ + addFromSelectionAsync(bindingType: BindingType, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Gets an array with all the binding objects in the document. + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + getAllAsync(options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Retrieves a binding based on its Name + * @param id The binding id + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + getByIdAsync(id: string, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Removes the binding from the document + * @param id The binding id + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + releaseByIdAsync(id: string, options?: any, callback?: (result: AsyncResult) => void): void; + } + export interface Bindings { + /** + * Gets a value that indicates whether the content is in HTML or text format. + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + getTypeAsync(options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Adds the specified content to the beginning of the item body + * @param data The string to be inserted at the beginning of the body + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + prependAsync(data: string, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Replaces the selection in the body with the specified text + * @param data The string to be inserted at the beginning of the body + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + setSelectedDataAsync(data: string, options?: any, callback?: (result: AsyncResult) => void): void; + } + export interface Context { + document: Document; + } + export interface CustomXmlNode { + baseName: string; + namespaceUri: string; + nodeType: string; + /** + * Gets the nodes associated with the xPath expression. + * @param xPath The xPath expression + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + getNodesAsync(xPath: string, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Gets the node value. + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + getNodeValueAsync(options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Gets the node's XML. + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + getXmlAsync(options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Sets the node value. + * @param value The value to be set on the node + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + setNodeValueAsync(value: string, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Sets the node XML. + * @param xml The XML to be set on the node + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + setXmlAsync(xml: string, options?: any, callback?: (result: AsyncResult) => void): void; + } + export interface CustomXmlPart { + builtIn: boolean; + id: string; + namespaceManager: CustomXmlPrefixMappings; + /** + * Adds an event handler to the object using the specified event type. + * @param eventType The event type. For CustomXmlPartNode it can be 'nodeDeleted', 'nodeInserted' or 'nodeReplaced' + * @param handler The name of the handler + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + addHandlerAsync(eventType: EventType, handler?: (result: any) => void, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Deletes the Custom XML Part. + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + deleteAsync(options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Gets the nodes associated with the xPath expression. + * @param xPath The xPath expression + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + getNodesAsync(xPath: string, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Gets the XML for the Custom XML Part. + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + getXmlAsync(options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Removes an event handler from the object using the specified event type. + * @param eventType The event type. For CustomXmlPartNode it can be 'nodeDeleted', 'nodeInserted' or 'nodeReplaced' + * @param options Syntax example: {handler:eventHandler} + * handler: Indicates a specific handler to be removed, if not specified all handlers are removed + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + removeHandlerAsync(eventType: EventType, options?: any, callback?: (result: AsyncResult) => void): void; + } + export interface CustomXmlParts { + /** + * Asynchronously adds a new custom XML part to a file. + * @param xml The XML to add to the newly created custom XML part. + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback A function that is invoked when the callback returns, whose only parameter is of type AsyncResult. + */ + addAsync(xml: string, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Asynchronously gets the specified custom XML part by its id. + * @param id The id of the custom XML part. + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback A function that is invoked when the callback returns, whose only parameter is of type AsyncResult. + */ + getByIdAsync(id: string, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Asynchronously gets the specified custom XML part(s) by its namespace. + * @param ns The namespace to search. + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback A function that is invoked when the callback returns, whose only parameter is of type AsyncResult. + */ + getByNamespaceAsync(ns: string, options?: any, callback?: (result: AsyncResult) => void): void; + } + export interface CustomXmlPrefixMappings { + /** + * Adds a namespace. + * @param prefix The namespace prefix + * @param ns The namespace URI + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + addNamespaceAsync(prefix: string, ns: string, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Gets a namespace with the specified prefix + * @param prefix The namespace prefix + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + getNamespaceAsync(prefix: string, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Gets a prefix for the specified URI + * @param ns The namespace URI + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + getPrefixAsync(ns: string, options?: any, callback?: (result: AsyncResult) => void): void; + } + export interface Document { + bindings: Bindings; + customXmlParts: CustomXmlParts; + mode: DocumentMode; + settings: Settings; + url: string; + /** + * Adds an event handler for the specified event type. + * @param eventType The event type. For document can be 'DocumentSelectionChanged' + * @param handler The name of the handler + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + addHandlerAsync(eventType: EventType, handler: any, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Returns the current view of the presentation. + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + getActiveViewAsync(options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Gets the entire file in slices of up to 4MB. + * @param fileType The format in which the file will be returned + * @param options Syntax example: {sliceSize:1024} + * sliceSize: Specifies the desired slice size (in bytes) up to 4MB. If not specified a default slice size of 4MB will be used. + * @param callback The optional callback method + */ + getFileAsync(fileType: FileType, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Gets file properties of the current document. + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + getFilePropertiesAsync(options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Returns the current selection. + * @param coercionType The expected shape of the selection. + * @param options Syntax example: {valueFormat: 'formatted', filterType:'all'} + * valueFormat: Get data with or without format. Use Office.ValueFormat or text value. + * filterType: Get the visible or all the data. Useful when filtering data. Use Office.FilterType or text value. + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + getSelectedDataAsync(coercionType: CoercionType, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Goes to the specified object or location in the document. + * @param id The identifier of the object or location to go to. + * @param goToType The type of the location to go to. + * @param options Syntax example: {asyncContext:context} + * selectionMode: Use Office.SelectionMode or text value. + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + goToByIdAsync(id: string, goToType: GoToType, options?: any, callback?: (result: AsyncResult) => void): void; + goToByIdAsync(id: number, goToType: GoToType, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Removes an event handler for the specified event type. + * @param eventType The event type. For document can be 'DocumentSelectionChanged' + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * handler: The name of the handler. If not specified all handlers are removed + * @param callback The optional callback method + */ + removeHandlerAsync(eventType: EventType, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Writes the specified data into the current selection. + * @param data The data to be set. Either a string or value, 2d array or TableData object + * @param options Syntax example: {coercionType:Office.CoercionType.Matrix} or {coercionType: 'matrix'} + * coercionType: Explicitly sets the shape of the data object. Use Office.CoercionType or text value. If not supplied is inferred from the data type. + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + setSelectedDataAsync(data: string, options?: any, callback?: (result: AsyncResult) => void): void; + } + export interface File { + size: number; + sliceCount: number; + /** + * Closes the File. + * @param callback The optional callback method + */ + closeAsync(callback?: (result: AsyncResult) => void): void; + /** + * Gets the specified slice. + * @param sliceIndex The index of the slice to be retrieved + * @param callback The optional callback method + */ + getSliceAsync(sliceIndex: number, callback?: (result: AsyncResult) => void): void; + } + export interface FileProperties { + /** + * File's URL + */ + url: string + } + export interface MatrixBinding extends Binding { + columnCount: number; + rowCount: number; + } + export interface Settings { + /** + * Adds an event handler for the object using the specified event type. + * @param eventType The event type. For settings can be 'settingsChanged' + * @param handler The name of the handler + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + addHandlerAsync(eventType: EventType, handler: any, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Retrieves the setting with the specified name. + * @param settingName The name of the setting + */ + get(name: string): any; + /** + * Gets the latest version of the settings object. + * @param callback The optional callback method + */ + refreshAsync(callback?: (result: AsyncResult) => void): void; + /** + * Removes the setting with the specified name. + * @param settingName The name of the setting + */ + remove(name: string): void; + /** + * Removes an event handler for the specified event type. + * @param eventType The event type. For settings can be 'settingsChanged' + * @param options Syntax example: {handler:eventHandler} + * handler: Indicates a specific handler to be removed, if not specified all handlers are removed + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + removeHandlerAsync(eventType: EventType, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Saves all settings. + * @param options Syntax example: {overwriteIfStale:false} + * overwriteIfStale: Indicates whether the setting will be replaced if stale. + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + saveAsync(callback?: (result: AsyncResult) => void): void; + /** + * Sets a value for the setting with the specified name. + * @param settingName The name of the setting + * @param value The value for the setting + */ + set(name: string, value: any): void; + } + export interface Slice { + data: any; + index: number; + size: number; + } + export interface TableBinding extends Binding { + columnCount: number; + hasHeaders: boolean; + rowCount: number; + /** + * Adds the specified columns to the table + * @param tableData A TableData object with the headers and rows + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + addColumnsAsync(tableData: TableData, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Adds the specified rows to the table + * @param rows A 2D array with the rows to add + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + addRowsAsync(rows: any[][], options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Clears the table + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + deleteAllDataValuesAsync(options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Clears formatting on the bound table. + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + clearFormatsAsync(options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Gets the formatting on specified items in the table. + * @param cellReference An object literal containing name-value pairs that specify the range of cells to get formatting from. + * @param formats An array specifying the format properties to get. + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + getFormatsAsync(cellReference?: any, formats?: any[], options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Sets formatting on specified items and data in the table. + * @param formatsInfo Array elements are themselves three-element arrays:[target, type, formats] + * target: The identifier of the item to format. String. + * type: The kind of item to format. String. + * formats: An object literal containing a list of property name-value pairs that define the formatting to apply. + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + setFormatsAsync(formatsInfo?: any[][], options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Updates table formatting options on the bound table. + * @param tableOptions An object literal containing a list of property name-value pairs that define the table options to apply. + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + setTableOptionsAsync(tableOptions: any, options?: any, callback?: (result: AsyncResult) => void): void; + } + export class TableData { + constructor(rows: any[][], headers: any[][]); + headers: any[][]; + rows: any[][]; + } + export interface TextBinding extends Binding { } + export enum ProjectProjectFields { + CurrencyDigits, + CurrencySymbol, + CurrencySymbolPosition, + DurationUnits, + GUID, + Finish, + Start, + ReadOnly, + VERSION, + WorkUnits, + ProjectServerUrl, + WSSUrl, + WSSList + } + export enum ProjectResourceFields { + Accrual, + ActualCost, + ActualOvertimeCost, + ActualOvertimeWork, + ActualOvertimeWorkProtected, + ActualWork, + ActualWorkProtected, + BaseCalendar, + Baseline10BudgetCost, + Baseline10BudgetWork, + Baseline10Cost, + Baseline10Work, + Baseline1BudgetCost, + Baseline1BudgetWork, + Baseline1Cost, + Baseline1Work, + Baseline2BudgetCost, + Baseline2BudgetWork, + Baseline2Cost, + Baseline2Work, + Baseline3BudgetCost, + Baseline3BudgetWork, + Baseline3Cost, + Baseline3Work, + Baseline4BudgetCost, + Baseline4BudgetWork, + Baseline4Cost, + Baseline4Work, + Baseline5BudgetCost, + Baseline5BudgetWork, + Baseline5Cost, + Baseline5Work, + Baseline6BudgetCost, + Baseline6BudgetWork, + Baseline6Cost, + Baseline6Work, + Baseline7BudgetCost, + Baseline7BudgetWork, + Baseline7Cost, + Baseline7Work, + Baseline8BudgetCost, + Baseline8BudgetWork, + Baseline8Cost, + Baseline8Work, + Baseline9BudgetCost, + Baseline9BudgetWork, + Baseline9Cost, + Baseline9Work, + BaselineBudgetCost, + BaselineBudgetWork, + BaselineCost, + BaselineWork, + BudgetCost, + BudgetWork, + ResourceCalendarGUID, + Code, + Cost1, + Cost10, + Cost2, + Cost3, + Cost4, + Cost5, + Cost6, + Cost7, + Cost8, + Cost9, + ResourceCreationDate, + Date1, + Date10, + Date2, + Date3, + Date4, + Date5, + Date6, + Date7, + Date8, + Date9, + Duration1, + Duration10, + Duration2, + Duration3, + Duration4, + Duration5, + Duration6, + Duration7, + Duration8, + Duration9, + Email, + End, + Finish1, + Finish10, + Finish2, + Finish3, + Finish4, + Finish5, + Finish6, + Finish7, + Finish8, + Finish9, + Flag10, + Flag1, + Flag11, + Flag12, + Flag13, + Flag14, + Flag15, + Flag16, + Flag17, + Flag18, + Flag19, + Flag2, + Flag20, + Flag3, + Flag4, + Flag5, + Flag6, + Flag7, + Flag8, + Flag9, + Group, + Units, + Name, + Notes, + Number1, + Number10, + Number11, + Number12, + Number13, + Number14, + Number15, + Number16, + Number17, + Number18, + Number19, + Number2, + Number20, + Number3, + Number4, + Number5, + Number6, + Number7, + Number8, + Number9, + OvertimeCost, + OvertimeRate, + OvertimeWork, + PercentWorkComplete, + CostPerUse, + Generic, + OverAllocated, + RegularWork, + RemainingCost, + RemainingOvertimeCost, + RemainingOvertimeWork, + RemainingWork, + ResourceGUID, + Cost, + Work, + Start, + Start1, + Start10, + Start2, + Start3, + Start4, + Start5, + Start6, + Start7, + Start8, + Start9, + StandardRate, + Text1, + Text10, + Text11, + Text12, + Text13, + Text14, + Text15, + Text16, + Text17, + Text18, + Text19, + Text2, + Text20, + Text21, + Text22, + Text23, + Text24, + Text25, + Text26, + Text27, + Text28, + Text29, + Text3, + Text30, + Text4, + Text5, + Text6, + Text7, + Text8, + Text9 + } + export enum ProjectTaskFields { + ActualCost, + ActualDuration, + ActualFinish, + ActualOvertimeCost, + ActualOvertimeWork, + ActualStart, + ActualWork, + Text1, + Text10, + Finish10, + Start10, + Text11, + Text12, + Text13, + Text14, + Text15, + Text16, + Text17, + Text18, + Text19, + Finish1, + Start1, + Text2, + Text20, + Text21, + Text22, + Text23, + Text24, + Text25, + Text26, + Text27, + Text28, + Text29, + Finish2, + Start2, + Text3, + Text30, + Finish3, + Start3, + Text4, + Finish4, + Start4, + Text5, + Finish5, + Start5, + Text6, + Finish6, + Start6, + Text7, + Finish7, + Start7, + Text8, + Finish8, + Start8, + Text9, + Finish9, + Start9, + Baseline10BudgetCost, + Baseline10BudgetWork, + Baseline10Cost, + Baseline10Duration, + Baseline10Finish, + Baseline10FixedCost, + Baseline10FixedCostAccrual, + Baseline10Start, + Baseline10Work, + Baseline1BudgetCost, + Baseline1BudgetWork, + Baseline1Cost, + Baseline1Duration, + Baseline1Finish, + Baseline1FixedCost, + Baseline1FixedCostAccrual, + Baseline1Start, + Baseline1Work, + Baseline2BudgetCost, + Baseline2BudgetWork, + Baseline2Cost, + Baseline2Duration, + Baseline2Finish, + Baseline2FixedCost, + Baseline2FixedCostAccrual, + Baseline2Start, + Baseline2Work, + Baseline3BudgetCost, + Baseline3BudgetWork, + Baseline3Cost, + Baseline3Duration, + Baseline3Finish, + Baseline3FixedCost, + Baseline3FixedCostAccrual, + Basline3Start, + Baseline3Work, + Baseline4BudgetCost, + Baseline4BudgetWork, + Baseline4Cost, + Baseline4Duration, + Baseline4Finish, + Baseline4FixedCost, + Baseline4FixedCostAccrual, + Baseline4Start, + Baseline4Work, + Baseline5BudgetCost, + Baseline5BudgetWork, + Baseline5Cost, + Baseline5Duration, + Baseline5Finish, + Baseline5FixedCost, + Baseline5FixedCostAccrual, + Baseline5Start, + Baseline5Work, + Baseline6BudgetCost, + Baseline6BudgetWork, + Baseline6Cost, + Baseline6Duration, + Baseline6Finish, + Baseline6FixedCost, + Baseline6FixedCostAccrual, + Baseline6Start, + Baseline6Work, + Baseline7BudgetCost, + Baseline7BudgetWork, + Baseline7Cost, + Baseline7Duration, + Baseline7Finish, + Baseline7FixedCost, + Baseline7FixedCostAccrual, + Baseline7Start, + Baseline7Work, + Baseline8BudgetCost, + Baseline8BudgetWork, + Baseline8Cost, + Baseline8Duration, + Baseline8Finish, + Baseline8FixedCost, + Baseline8FixedCostAccrual, + Baseline8Start, + Baseline8Work, + Baseline9BudgetCost, + Baseline9BudgetWork, + Baseline9Cost, + Baseline9Duration, + Baseline9Finish, + Baseline9FixedCost, + Baseline9FixedCostAccrual, + Baseline9Start, + Baseline9Work, + BaselineBudgetCost, + BaselineBudgetWork, + BaselineCost, + BaselineDuration, + BaselineFinish, + BaselineFixedCost, + BaselineFixedCostAccrual, + BaselineStart, + BaselineWork, + BudgetCost, + BudgetFixedCost, + BudgetFixedWork, + BudgetWork, + TaskCalendarGUID, + ConstraintDate, + ConstraintType, + Cost1, + Cost10, + Cost2, + Cost3, + Cost4, + Cost5, + Cost6, + Cost7, + Cost8, + Cost9, + Date1, + Date10, + Date2, + Date3, + Date4, + Date5, + Date6, + Date7, + Date8, + Date9, + Deadline, + Duration1, + Duration10, + Duration2, + Duration3, + Duration4, + Duration5, + Duration6, + Duration7, + Duration8, + Duration9, + Duration, + EarnedValueMethod, + FinishSlack, + FixedCost, + FixedCostAccrual, + Flag10, + Flag1, + Flag11, + Flag12, + Flag13, + Flag14, + Flag15, + Flag16, + Flag17, + Flag18, + Flag19, + Flag2, + Flag20, + Flag3, + Flag4, + Flag5, + Flag6, + Flag7, + Flag8, + Flag9, + FreeSlack, + HasRollupSubTasks, + ID, + Name, + Notes, + Number1, + Number10, + Number11, + Number12, + Number13, + Number14, + Number15, + Number16, + Number17, + Number18, + Number19, + Number2, + Number20, + Number3, + Number4, + Number5, + Number6, + Number7, + Number8, + Number9, + ScheduledDuration, + ScheduledFinish, + ScheduledStart, + OutlineLevel, + OvertimeCost, + OvertimeWork, + PercentComplete, + PercentWorkComplete, + Predecessors, + PreleveledFinish, + PreleveledStart, + Priority, + Active, + Critical, + Milestone, + Overallocated, + IsRollup, + Summary, + RegularWork, + RemainingCost, + RemainingDuration, + RemainingOvertimeCost, + RemainingWork, + ResourceNames, + Cost, + Finish, + Start, + Work, + StartSlack, + Status, + Successors, + StatusManager, + TotalSlack, + TaskGUID, + Type, + WBS, + WBSPREDECESSORS, + WBSSUCCESSORS, + WSSID + } + export enum ProjectViewTypes { + Gantt, + NetworkDiagram, + TaskDiagram, + TaskForm, + TaskSheet, + ResourceForm, + ResourceSheet, + ResourceGraph, + TeamPlanner, + TaskDetails, + TaskNameForm, + ResourceNames, + Calendar, + TaskUsage, + ResourceUsage, + Timeline + } + // Objects + export interface Document { + /** + * Get Project field (Ex. ProjectWebAccessURL). + * @param fieldId Project level fields. + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + getProjectFieldAsync(fieldId: number, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Get resource field for provided resource Id. (Ex.ResourceName) + * @param resourceId Either a string or value of the Resource Id. + * @param fieldId Resource Fields. + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + getResourceFieldAsync(resourceId: string, fieldId: number, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Get the current selected Resource's Id. + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + getSelectedResourceAsync(options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Get the current selected Task's Id. + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + getSelectedTaskAsync(options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Get the current selected View Type (Ex. Gantt) and View Name. + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + getSelectedViewAsync(options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Get the Task Name, WSS Task Id, and ResourceNames for given taskId. + * @param taskId Either a string or value of the Task Id. + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + getTaskAsync(taskId: string, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Get task field for provided task Id. (Ex. StartDate). + * @param taskId Either a string or value of the Task Id. + * @param fieldId Task Fields. + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + getTaskFieldAsync(taskId: string, fieldId: number, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Get the WSS Url and list name for the Tasks List, the MPP is synced too. + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + getWSSUrlAsync(options?: any, callback?: (result: AsyncResult) => void): void; + } +} + + +declare module Excel { + /** + * + * Represents the Excel application that manages the workbook. + */ + class Application extends OfficeExtension.ClientObject { + private m_calculationMode; + /** + * + * Returns the calculation mode used in the workbook. See Excel.CalculationMode for details. Read-only. + */ + calculationMode: string; + /** + * + * Recalculate all currently opened workbooks in Excel. + * + * @param calculationType Specifies the calculation type to use. See Excel.CalculationType for details. + */ + calculate(calculationType: string): void; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.Application; + } + /** + * + * Workbook is the top level object which contains related workbook objects such as worksheets, tables, ranges, etc. + */ + class Workbook extends OfficeExtension.ClientObject { + private m_application; + private m_bindings; + private m_names; + private m_tables; + private m_worksheets; + /** + * + * Represents Excel application instance that contains this workbook. Read-only. + */ + application: Excel.Application; + /** + * + * Represents a collection of bindings that are part of the workbook. Read-only. + */ + bindings: Excel.BindingCollection; + /** + * + * Represents a collection of workbook scoped named items (named ranges and constants). Read-only. + */ + names: Excel.NamedItemCollection; + /** + * + * Represents a collection of tables associated with the workbook. Read-only. + */ + tables: Excel.TableCollection; + /** + * + * Represents a collection of worksheets associated with the workbook. Read-only. + */ + worksheets: Excel.WorksheetCollection; + /** + * + * Gets the currently selected range from the workbook. + * + */ + getSelectedRange(): Excel.Range; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.Workbook; + } + /** + * + * An Excel worksheet is a grid of cells. It can contain data, tables, charts, etc. + */ + class Worksheet extends OfficeExtension.ClientObject { + private m_charts; + private m_id; + private m_name; + private m_position; + private m_tables; + private m_visibility; + /** + * + * Returns collection of charts that are part of the worksheet. Read-only. + */ + charts: Excel.ChartCollection; + /** + * + * Collection of tables that are part of the worksheet. Read-only. + */ + tables: Excel.TableCollection; + /** + * + * Returns a value that uniquely identifies the worksheet in a given workbook. The value of the identifier remains the same even when the worksheet is renamed or moved. Read-only. + */ + id: string; + /** + * + * The display name of the worksheet. + */ + name: string; + /** + * + * The zero-based position of the worksheet within the workbook. + */ + position: number; + /** + * + * The Visibility of the worksheet, Read-only. + */ + visibility: string; + /** + * + * Activate the worksheet in the Excel UI. + * + */ + activate(): void; + /** + * + * Deletes the worksheet from the workbook. + * + */ + delete(): void; + /** + * + * Gets the range object containing the single cell based on row and column numbers. The cell can be outside the bounds of its parent range, so long as it's stays within the worksheet grid. + * + * @param row The row number of the cell to be retrieved. Zero-indexed. + * @param column the column number of the cell to be retrieved. Zero-indexed. + */ + getCell(row: number, column: number): Excel.Range; + /** + * + * Gets the range object specified by the address or name. + * + * @param address The address or the name of the range. If not specified, the entire worksheet range is returned. + */ + getRange(address?: string): Excel.Range; + /** + * + * The used range is the smallest range than encompasses any cells that have a value or formatting assigned to them. If the worksheet is blank, this function will return the top left cell. + * + */ + getUsedRange(): Excel.Range; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.Worksheet; + } + /** + * + * Represents a collection of worksheet objects that are part of the workbook. + */ + class WorksheetCollection extends OfficeExtension.ClientObject { + private m__items; + /** Gets the loaded child items in this collection. */ + items: Array; + /** + * + * Adds a new worksheet to the workbook. The worksheet will be added at the end of existing worksheets. If you wish to activate the newly added worksheet, call ".activate() on it. + * + * @param name The name of the worksheet to be added. If specified, name should be unqiue. If not specified, Excel determines the name of the new worksheet. + */ + add(name?: string): Excel.Worksheet; + /** + * + * Gets the currently active worksheet in the workbook. + * + */ + getActiveWorksheet(): Excel.Worksheet; + /** + * + * Gets a worksheet object using its Name or ID. + * + * @param key The Name or ID of the worksheet. + */ + getItem(key: string): Excel.Worksheet; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.WorksheetCollection; + } + /** + * + * Range represents a set of one or more contiguous cells such as a cell, a row, a column, block of cells, etc. + */ + class Range extends OfficeExtension.ClientObject { + private m_address; + private m_addressLocal; + private m_cellCount; + private m_columnCount; + private m_columnIndex; + private m_format; + private m_formulas; + private m_formulasLocal; + private m_numberFormat; + private m_rowCount; + private m_rowIndex; + private m_text; + private m_valueTypes; + private m_values; + private m_worksheet; + private m__ReferenceId; + /** + * + * Returns a format object, encapsulating the range's font, fill, borders, alignment, and other properties. Read-only. + */ + format: Excel.RangeFormat; + /** + * + * The worksheet containing the current range. Read-only. + */ + worksheet: Excel.Worksheet; + /** + * + * Represents the range reference in A1-style. Address value will contain the Sheet reference (e.g. Sheet1!A1:B4). Read-only. + */ + address: string; + /** + * + * Represents range reference for the specified range in the language of the user. Read-only. + */ + addressLocal: string; + /** + * + * Number of cells in the range. Read-only. + */ + cellCount: number; + /** + * + * Represents the total number of columns in the range. Read-only. + */ + columnCount: number; + /** + * + * Represents the column number of the first cell in the range. Zero-indexed. Read-only. + */ + columnIndex: number; + /** + * + * Represents the formula in A1-style notation. + */ + formulas: Array>; + /** + * + * Represents the formula in A1-style notation, in the user's language and number-formatting locale. For example, the English "=SUM(A1, 1.5)" formula would become "=SUMME(A1; 1,5)" in German. + */ + formulasLocal: Array>; + /** + * + * Represents Excel's number format code for the given cell. + */ + numberFormat: Array>; + /** + * + * Returns the total number of rows in the range. Read-only. + */ + rowCount: number; + /** + * + * Returns the row number of the first cell in the range. Zero-indexed. Read-only. + */ + rowIndex: number; + /** + * + * Text values of the specified range. The Text value will not depend on the cell width. The # sign substitution that happens in Excel UI will not affect the text value returned by the API. Read-only. + */ + text: Array>; + /** + * + * Represents the type of data of each cell. Read-only. + */ + valueTypes: Array>; + /** + * + * Represents the raw values of the specified range. The data returned could be of type string, number, or a boolean. Cell that contain an error will return the error string. + */ + values: Array>; + /** + * + * Clear range values, format, fill, border, etc. + * + * @param applyTo Determines the type of clear action. See Excel.ClearApplyTo for details. + */ + clear(applyTo?: string): void; + /** + * + * Deletes the cells associated with the range. + * + * @param shift Specifies which way to shift the cells. See Excel.DeleteShiftDirection for details. + */ + delete(shift: string): void; + /** + * + * Gets the smallest range object that encompasses the given ranges. For example, the GetBoundingRect of "B2:C5" and "D10:E15" is "B2:E16". + * + * @param anotherRange The range object or address or range name. + */ + getBoundingRect(anotherRange: Excel.Range | string): Excel.Range; + /** + * + * Gets the range object containing the single cell based on row and column numbers. The cell can be outside the bounds of its parent range, so long as it's stays within the worksheet grid. The returned cell is located relative to the top left cell of the range. + * + * @param row Row number of the cell to be retrieved. Zero-indexed. + * @param column Column number of the cell to be retrieved. Zero-indexed. + */ + getCell(row: number, column: number): Excel.Range; + /** + * + * Gets a column contained in the range. + * + * @param column Column number of the range to be retrieved. Zero-indexed. + */ + getColumn(column: number): Excel.Range; + /** + * + * Gets an object that represents the entire column of the range. + * + */ + getEntireColumn(): Excel.Range; + /** + * + * Gets an object that represents the entire row of the range. + * + */ + getEntireRow(): Excel.Range; + /** + * + * Gets the range object that represents the rectangular intersection of the given ranges. + * + * @param anotherRange The range object or range address that will be used to determine the intersection of ranges. + */ + getIntersection(anotherRange: Excel.Range | string): Excel.Range; + /** + * + * Gets the last cell within the range. For example, the last cell of "B2:D5" is "D5". + * + */ + getLastCell(): Excel.Range; + /** + * + * Gets the last column within the range. For example, the last column of "B2:D5" is "D2:D5". + * + */ + getLastColumn(): Excel.Range; + /** + * + * Gets the last row within the range. For example, the last row of "B2:D5" is "B5:D5". + * + */ + getLastRow(): Excel.Range; + /** + * + * Gets an object which represents a range that's offset from the specified range. The dimension of the returned range will match this range. If the resulting range is forced outside the bounds of the worksheet grid, an exception will be thrown. + * + * @param rowOffset The number of rows (positive, negative, or 0) by which the range is to be offset. Positive values are offset downward, and negative values are offset upward. + * @param columnOffset The number of columns (positive, negative, or 0) by which the range is to be offset. Positive values are offset to the right, and negative values are offset to the left. + */ + getOffsetRange(rowOffset: number, columnOffset: number): Excel.Range; + /** + * + * Gets a row contained in the range. + * + * @param row Row number of the range to be retrieved. Zero-indexed. + */ + getRow(row: number): Excel.Range; + /** + * + * Returns the used range of the given range object. + * + */ + getUsedRange(): Excel.Range; + /** + * + * Inserts a cell or a range of cells into the worksheet in place of this range, and shifts the other cells to make space. Returns a new Range object at the now blank space. + * + * @param shift Specifies which way to shift the cells. See Excel.InsertShiftDirection for details. + */ + insert(shift: string): Excel.Range; + /** + * + * Selects the specified range in the Excel UI. + * + */ + select(): void; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.Range; + } + /** + * + * A collection of all the nameditem objects that are part of the workbook. + */ + class NamedItemCollection extends OfficeExtension.ClientObject { + private m__items; + /** Gets the loaded child items in this collection. */ + items: Array; + /** + * + * Gets a nameditem object using its name + * + * @param name nameditem name. + */ + getItem(name: string): Excel.NamedItem; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.NamedItemCollection; + } + /** + * + * Represents a defined name for a range of cells or value. Names can be primitive named objects (as seen in the type below), range object, reference to a range. This object can be used to obtain range object associated with names. + */ + class NamedItem extends OfficeExtension.ClientObject { + private m_name; + private m_type; + private m_value; + private m_visible; + private m__Id; + /** + * + * The name of the object. Read-only. + */ + name: string; + /** + * + * Indicates what type of reference is associated with the name. See Excel.NamedItemType for details. Read-only. + */ + type: string; + /** + * + * Represents the formula that the name is defined to refer to. E.g. =Sheet14!$B$2:$H$12, =4.75, etc. Read-only. + */ + value: any; + /** + * + * Specifies whether the object is visible or not. + */ + visible: boolean; + /** + * + * Returns the range object that is associated with the name. Throws an exception if the named item's type is not a range. + * + */ + getRange(): Excel.Range; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.NamedItem; + } + /** + * + * Represents an Office.js binding that is defined in the workbook. + */ + class Binding extends OfficeExtension.ClientObject { + private m_id; + private m_type; + /** + * + * Represents binding identifier. Read-only. + */ + id: string; + /** + * + * Returns the type of the binding. See Excel.BindingType for details. Read-only. + */ + type: string; + /** + * + * Returns the range represented by the binding. Will throw an error if binding is not of the correct type. + * + */ + getRange(): Excel.Range; + /** + * + * Returns the table represented by the binding. Will throw an error if binding is not of the correct type. + * + */ + getTable(): Excel.Table; + /** + * + * Returns the text represented by the binding. Will throw an error if binding is not of the correct type. + * + */ + getText(): OfficeExtension.ClientResult; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.Binding; + } + /** + * + * Represents the collection of all the binding objects that are part of the workbook. + */ + class BindingCollection extends OfficeExtension.ClientObject { + private m_count; + private m__items; + /** Gets the loaded child items in this collection. */ + items: Array; + /** + * + * Returns the number of bindings in the collection. Read-only. + */ + count: number; + /** + * + * Gets a binding object by ID. + * + * @param id Id of the binding object to be retrieved. + */ + getItem(id: string): Excel.Binding; + /** + * + * Gets a binding object based on its position in the items array. + * + * @param index Index value of the object to be retrieved. Zero-indexed. + */ + getItemAt(index: number): Excel.Binding; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.BindingCollection; + } + /** + * + * Represents a collection of all the tables that are part of the workbook. + */ + class TableCollection extends OfficeExtension.ClientObject { + private m_count; + private m__items; + /** Gets the loaded child items in this collection. */ + items: Array; + /** + * + * Returns the number of tables in the workbook. Read-only. + */ + count: number; + /** + * + * Create a new table. The range source address determines the worksheet under which the table will be added. If the table cannot be added (e.g., because the address is invalid, or the table would overlap with another table), an error will be thrown. + * + * @param address Address or name of the range object representing the data source. If the address does not contain a sheet name, the currently-active sheet is used. + * @param hasHeaders Boolean value that indicates whether the data being imported has column labels. If the source does not contain headers (i.e,. when this property set to false), Excel will automatically generate header shifting the data down by one row. + */ + add(address: string, hasHeaders: boolean): Excel.Table; + /** + * + * Gets a table by Name or ID. + * + * @param key Name or ID of the table to be retrieved. + */ + getItem(key: number | string): Excel.Table; + /** + * + * Gets a table based on its position in the collection. + * + * @param index Index value of the object to be retrieved. Zero-indexed. + */ + getItemAt(index: number): Excel.Table; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.TableCollection; + } + /** + * + * Represents an Excel table. + */ + class Table extends OfficeExtension.ClientObject { + private m_columns; + private m_id; + private m_name; + private m_rows; + private m_showHeaders; + private m_showTotals; + private m_style; + /** + * + * Represents a collection of all the columns in the table. Read-only. + */ + columns: Excel.TableColumnCollection; + /** + * + * Represents a collection of all the rows in the table. Read-only. + */ + rows: Excel.TableRowCollection; + /** + * + * Returns a value that uniquely identifies the table in a given workbook. The value of the identifier remains the same even when the table is renamed. Read-only. + */ + id: number; + /** + * + * Name of the table. + */ + name: string; + /** + * + * Indicates whether the header row is visible or not. This value can be set to show or remove the header row. + */ + showHeaders: boolean; + /** + * + * Indicates whether the total row is visible or not. This value can be set to show or remove the total row. + */ + showTotals: boolean; + /** + * + * Constant value that represents the Table style. Possible values are: TableStyleLight1 thru TableStyleLight21, TableStyleMedium1 thru TableStyleMedium28, TableStyleStyleDark1 thru TableStyleStyleDark11. A custom user-defined style present in the workbook can also be specified. + */ + style: string; + /** + * + * Deletes the table. + * + */ + delete(): void; + /** + * + * Gets the range object associated with the data body of the table. + * + */ + getDataBodyRange(): Excel.Range; + /** + * + * Gets the range object associated with header row of the table. + * + */ + getHeaderRowRange(): Excel.Range; + /** + * + * Gets the range object associated with the entire table. + * + */ + getRange(): Excel.Range; + /** + * + * Gets the range object associated with totals row of the table. + * + */ + getTotalRowRange(): Excel.Range; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.Table; + } + /** + * + * Represents a collection of all the columns that are part of the table. + */ + class TableColumnCollection extends OfficeExtension.ClientObject { + private m_count; + private m__items; + /** Gets the loaded child items in this collection. */ + items: Array; + /** + * + * Returns the number of columns in the table. Read-only. + */ + count: number; + /** + * + * Adds a new column to the table. + * + * @param index Specifies the relative position of the new column. The previous column at this position is shifted to the right. The index value should be equal to or less than the last column's index value, so it cannot be used to append a column at the end of the table. Zero-indexed. + * @param values A 2-dimensional array of unformatted values of the table column. + */ + add(index: number, values?: Array> | boolean | string | number): Excel.TableColumn; + /** + * + * Gets a column object by Name or ID. + * + * @param key Column Name or ID. + */ + getItem(key: number | string): Excel.TableColumn; + /** + * + * Gets a column based on its position in the collection. + * + * @param index Index value of the object to be retrieved. Zero-indexed. + */ + getItemAt(index: number): Excel.TableColumn; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.TableColumnCollection; + } + /** + * + * Represents a column in a table. + */ + class TableColumn extends OfficeExtension.ClientObject { + private m_id; + private m_index; + private m_name; + private m_values; + /** + * + * Returns a unique key that identifies the column within the table. Read-only. + */ + id: number; + /** + * + * Returns the index number of the column within the columns collection of the table. Zero-indexed. Read-only. + */ + index: number; + /** + * + * Returns the name of the table column. Read-only. + */ + name: string; + /** + * + * Represents the raw values of the specified range. The data returned could be of type string, number, or a boolean. Cell that contain an error will return the error string. + */ + values: Array>; + /** + * + * Deletes the column from the table. + * + */ + delete(): void; + /** + * + * Gets the range object associated with the data body of the column. + * + */ + getDataBodyRange(): Excel.Range; + /** + * + * Gets the range object associated with the header row of the column. + * + */ + getHeaderRowRange(): Excel.Range; + /** + * + * Gets the range object associated with the entire column. + * + */ + getRange(): Excel.Range; + /** + * + * Gets the range object associated with the totals row of the column. + * + */ + getTotalRowRange(): Excel.Range; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.TableColumn; + } + /** + * + * Represents a collection of all the rows that are part of the table. + */ + class TableRowCollection extends OfficeExtension.ClientObject { + private m_count; + private m__items; + /** Gets the loaded child items in this collection. */ + items: Array; + /** + * + * Returns the number of rows in the table. Read-only. + */ + count: number; + /** + * + * Adds a new row to the table. + * + * @param index Specifies the relative position of the new row. If null, the addition happens at the end. Any rows below the inserted row are shifted downwards. Zero-indexed. + * @param values A 2-dimensional array of unformatted values of the table row. + */ + add(index?: number, values?: Array> | boolean | string | number): Excel.TableRow; + /** + * + * Gets a row based on its position in the collection. + * + * @param index Index value of the object to be retrieved. Zero-indexed. + */ + getItemAt(index: number): Excel.TableRow; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.TableRowCollection; + } + /** + * + * Represents a row in a table. + */ + class TableRow extends OfficeExtension.ClientObject { + private m_index; + private m_values; + /** + * + * Returns the index number of the row within the rows collection of the table. Zero-indexed. Read-only. + */ + index: number; + /** + * + * Represents the raw values of the specified range. The data returned could be of type string, number, or a boolean. Cell that contain an error will return the error string. + */ + values: Array>; + /** + * + * Deletes the row from the table. + * + */ + delete(): void; + /** + * + * Returns the range object associated with the entire row. + * + */ + getRange(): Excel.Range; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.TableRow; + } + /** + * + * A format object encapsulating the range's font, fill, borders, alignment, and other properties. + */ + class RangeFormat extends OfficeExtension.ClientObject { + private m_borders; + private m_fill; + private m_font; + private m_horizontalAlignment; + private m_verticalAlignment; + private m_wrapText; + /** + * + * Collection of border objects that apply to the overall range selected Read-only. + */ + borders: Excel.RangeBorderCollection; + /** + * + * Returns the fill object defined on the overall range. Read-only. + */ + fill: Excel.RangeFill; + /** + * + * Returns the font object defined on the overall range selected Read-only. + */ + font: Excel.RangeFont; + /** + * + * Represents the horizontal alignment for the specified object. See Excel.HorizontalAlignment for details. + */ + horizontalAlignment: string; + /** + * + * Represents the vertical alignment for the specified object. See Excel.VerticalAlignment for details. + */ + verticalAlignment: string; + /** + * + * Indicates if Excel wraps the text in the object. A null value indicates that the entire range doesn't have uniform wrap setting + */ + wrapText: boolean; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.RangeFormat; + } + /** + * + * Represents the background of a range object. + */ + class RangeFill extends OfficeExtension.ClientObject { + private m_color; + /** + * + * HTML color code representing the color of the border line, of the form #RRGGBB (e.g. "FFA500") or as a named HTML color (e.g. "orange") + */ + color: string; + /** + * + * Resets the range background. + * + */ + clear(): void; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.RangeFill; + } + /** + * + * Represents the border of an object. + */ + class RangeBorder extends OfficeExtension.ClientObject { + private m_color; + private m_sideIndex; + private m_style; + private m_weight; + /** + * + * HTML color code representing the color of the border line, of the form #RRGGBB (e.g. "FFA500") or as a named HTML color (e.g. "orange"). + */ + color: string; + /** + * + * Constant value that indicates the specific side of the border. See Excel.BorderIndex for details. Read-only. + */ + sideIndex: string; + /** + * + * One of the constants of line style specifying the line style for the border. See Excel.BorderLineStyle for details. + */ + style: string; + /** + * + * Specifies the weight of the border around a range. See Excel.BorderWeight for details. + */ + weight: string; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.RangeBorder; + } + /** + * + * Represents the border objects that make up range border. + */ + class RangeBorderCollection extends OfficeExtension.ClientObject { + private m_count; + private m__items; + /** Gets the loaded child items in this collection. */ + items: Array; + /** + * + * Number of border objects in the collection. Read-only. + */ + count: number; + /** + * + * Gets a border object using its name + * + * @param index Index value of the border object to be retrieved. See Excel.BorderIndex for details. + */ + getItem(index: string): Excel.RangeBorder; + /** + * + * Gets a border object using its index + * + * @param index Index value of the object to be retrieved. Zero-indexed. + */ + getItemAt(index: number): Excel.RangeBorder; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.RangeBorderCollection; + } + /** + * + * This object represents the font attributes (font name, font size, color, etc.) for an object. + */ + class RangeFont extends OfficeExtension.ClientObject { + private m_bold; + private m_color; + private m_italic; + private m_name; + private m_size; + private m_underline; + /** + * + * Represents the bold status of font. + */ + bold: boolean; + /** + * + * HTML color code representation of the text color. E.g. #FF0000 represents Red. + */ + color: string; + /** + * + * Represents the italic status of the font. + */ + italic: boolean; + /** + * + * Font name (e.g. "Calibri") + */ + name: string; + /** + * + * Font size. + */ + size: number; + /** + * + * Type of underline applied to the font. See Excel.RangeUnderlineStyle for details. + */ + underline: string; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.RangeFont; + } + /** + * + * A collection of all the chart objects on a worksheet. + */ + class ChartCollection extends OfficeExtension.ClientObject { + private m_count; + private m__items; + /** Gets the loaded child items in this collection. */ + items: Array; + /** + * + * Returns the number of charts in the worksheet. Read-only. + */ + count: number; + /** + * + * Creates a new chart. + * + * @param type Represents the type of a chart. See Excel.ChartType for details. + * @param sourceData The Range object corresponding to the source data. + * @param seriesBy Specifies the way columns or rows are used as data series on the chart. See Excel.ChartSeriesBy for details. + */ + add(type: string, sourceData: Excel.Range, seriesBy?: string): Excel.Chart; + /** + * + * Gets a chart using its name. If there are multiple charts with the same name, the first one will be returned. + * + * @param name Name of the chart to be retrieved. + */ + getItem(name: string): Excel.Chart; + /** + * + * Gets a chart based on its position in the collection. + * + * @param index Index value of the object to be retrieved. Zero-indexed. + */ + getItemAt(index: number): Excel.Chart; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartCollection; + } + /** + * + * Represents a chart object in a workbook. + */ + class Chart extends OfficeExtension.ClientObject { + private m_axes; + private m_dataLabels; + private m_format; + private m_height; + private m_left; + private m_legend; + private m_name; + private m_series; + private m_title; + private m_top; + private m_width; + private m__Id; + /** + * + * Represents chart axes. Read-only. + */ + axes: Excel.ChartAxes; + /** + * + * Represents the datalabels on the chart. Read-only. + */ + dataLabels: Excel.ChartDataLabels; + /** + * + * Encapsulates the format properties for the chart area. Read-only. + */ + format: Excel.ChartAreaFormat; + /** + * + * Represents the legend for the chart. Read-only. + */ + legend: Excel.ChartLegend; + /** + * + * Represents either a single series or collection of series in the chart. Read-only. + */ + series: Excel.ChartSeriesCollection; + /** + * + * Represents the title of the specified chart, including the text, visibility, position and formating of the title. Read-only. + */ + title: Excel.ChartTitle; + /** + * + * Represents the height, in points, of the chart object. + */ + height: number; + /** + * + * The distance, in points, from the left side of the chart to the worksheet origin. + */ + left: number; + /** + * + * Represents the name of a chart object. + */ + name: string; + /** + * + * Represents the distance, in points, from the top edge of the object to the top of row 1 (on a worksheet) or the top of the chart area (on a chart). + */ + top: number; + /** + * + * Represents the width, in points, of the chart object. + */ + width: number; + /** + * + * Deletes the chart object. + * + */ + delete(): void; + /** + * + * Resets the source data for the chart. + * + * @param sourceData The Range object corresponding to the source data. + * @param seriesBy Specifies the way columns or rows are used as data series on the chart. Can be one of the following: Auto (default), Rows, Columns. See Excel.ChartSeriesBy for details. + */ + setData(sourceData: Excel.Range, seriesBy?: string): void; + /** + * + * Positions the chart relative to cells on the worksheet. + * + * @param startCell The start cell. This is where the chart will be moved to. The start cell is the top-left or top-right cell, depending on the user's right-to-left display settings. + * @param endCell (Optional) The end cell. If specified, the chart's width and height will be set to fully cover up this cell/range. + */ + setPosition(startCell: Excel.Range | string, endCell?: Excel.Range | string): void; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.Chart; + } + /** + * + * Encapsulates the format properties for the overall chart area. + */ + class ChartAreaFormat extends OfficeExtension.ClientObject { + private m_fill; + private m_font; + /** + * + * Represents the fill format of an object, which includes background formatting information. Read-only. + */ + fill: Excel.ChartFill; + /** + * + * Represents the font attributes (font name, font size, color, etc.) for the current object. Read-only. + */ + font: Excel.ChartFont; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartAreaFormat; + } + /** + * + * Represents a collection of chart series. + */ + class ChartSeriesCollection extends OfficeExtension.ClientObject { + private m_count; + private m__items; + /** Gets the loaded child items in this collection. */ + items: Array; + /** + * + * Returns the number of series in the collection. Read-only. + */ + count: number; + /** + * + * Retrieves a series based on its position in the collection + * + * @param index Index value of the object to be retrieved. Zero-indexed. + */ + getItemAt(index: number): Excel.ChartSeries; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartSeriesCollection; + } + /** + * + * Represents a series in a chart. + */ + class ChartSeries extends OfficeExtension.ClientObject { + private m_format; + private m_name; + private m_points; + /** + * + * Represents the formatting of a chart series, which includes fill and line formatting. Read-only. + */ + format: Excel.ChartSeriesFormat; + /** + * + * Represents a collection of all points in the series. Read-only. + */ + points: Excel.ChartPointsCollection; + /** + * + * Represents the name of a series in a chart. + */ + name: string; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartSeries; + } + /** + * + * encapsulates the format properties for the chart series + */ + class ChartSeriesFormat extends OfficeExtension.ClientObject { + private m_fill; + private m_line; + /** + * + * Represents the fill format of a chart series, which includes background formating information. Read-only. + */ + fill: Excel.ChartFill; + /** + * + * Represents line formatting. Read-only. + */ + line: Excel.ChartLineFormat; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartSeriesFormat; + } + /** + * + * A collection of all the chart points within a series inside a chart. + */ + class ChartPointsCollection extends OfficeExtension.ClientObject { + private m_count; + private m__items; + /** Gets the loaded child items in this collection. */ + items: Array; + /** + * + * Returns the number of chart points in the collection. Read-only. + */ + count: number; + /** + * + * Retrieve a point based on its position within the series. + * + * @param index Index value of the object to be retrieved. Zero-indexed. + */ + getItemAt(index: number): Excel.ChartPoint; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartPointsCollection; + } + /** + * + * Represents a point of a series in a chart. + */ + class ChartPoint extends OfficeExtension.ClientObject { + private m_format; + private m_value; + /** + * + * Encapsulates the format properties chart point. Read-only. + */ + format: Excel.ChartPointFormat; + /** + * + * Returns the value of a chart point. Read-only. + */ + value: any; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartPoint; + } + /** + * + * Represents formatting object for chart points. + */ + class ChartPointFormat extends OfficeExtension.ClientObject { + private m_fill; + /** + * + * Represents the fill format of a chart, which includes background formating information. Read-only. + */ + fill: Excel.ChartFill; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartPointFormat; + } + /** + * + * Represents the chart axes. + */ + class ChartAxes extends OfficeExtension.ClientObject { + private m_categoryAxis; + private m_seriesAxis; + private m_valueAxis; + /** + * + * Represents the category axis in a chart. Read-only. + */ + categoryAxis: Excel.ChartAxis; + /** + * + * Represents the series axis of a 3-dimensional chart. Read-only. + */ + seriesAxis: Excel.ChartAxis; + /** + * + * Represents the value axis in an axis. Read-only. + */ + valueAxis: Excel.ChartAxis; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartAxes; + } + /** + * + * Represents a single axis in a chart. + */ + class ChartAxis extends OfficeExtension.ClientObject { + private m_format; + private m_majorGridlines; + private m_majorUnit; + private m_maximum; + private m_minimum; + private m_minorGridlines; + private m_minorUnit; + private m_title; + /** + * + * Represents the formatting of a chart object, which includes line and font formatting. Read-only. + */ + format: Excel.ChartAxisFormat; + /** + * + * Returns a gridlines object that represents the major gridlines for the specified axis. Read-only. + */ + majorGridlines: Excel.ChartGridlines; + /** + * + * Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only. + */ + minorGridlines: Excel.ChartGridlines; + /** + * + * Represents the axis title. Read-only. + */ + title: Excel.ChartAxisTitle; + /** + * + * Represents the interval between two major tick marks. Can be set to a numeric value or an empty string. The returned value is always a number. + */ + majorUnit: any; + /** + * + * Represents the maximum value on the value axis. Can be set to a numeric value or an empty string (for automatic axis values). The returned value is always a number. + */ + maximum: any; + /** + * + * Represents the minimum value on the value axis. Can be set to a numeric value or an empty string (for automatic axis values). The returned value is always a number. + */ + minimum: any; + /** + * + * Represents the interval between two minor tick marks. "Can be set to a numeric value or an empty string (for automatic axis values). The returned value is always a number. + */ + minorUnit: any; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartAxis; + } + /** + * + * Encapsulates the format properties for the chart axis. + */ + class ChartAxisFormat extends OfficeExtension.ClientObject { + private m_font; + private m_line; + /** + * + * Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only. + */ + font: Excel.ChartFont; + /** + * + * Represents chart line formatting. Read-only. + */ + line: Excel.ChartLineFormat; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartAxisFormat; + } + /** + * + * Represents the title of a chart axis. + */ + class ChartAxisTitle extends OfficeExtension.ClientObject { + private m_format; + private m_text; + private m_visible; + /** + * + * Represents the formatting of chart axis title. Read-only. + */ + format: Excel.ChartAxisTitleFormat; + /** + * + * Represents the axis title. + */ + text: string; + /** + * + * A boolean that specifies the visibility of an axis title. + */ + visible: boolean; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartAxisTitle; + } + /** + * + * Represents the chart axis title formatting. + */ + class ChartAxisTitleFormat extends OfficeExtension.ClientObject { + private m_font; + /** + * + * Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only. + */ + font: Excel.ChartFont; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartAxisTitleFormat; + } + /** + * + * Represents a collection of all the data labels on a chart point. + */ + class ChartDataLabels extends OfficeExtension.ClientObject { + private m_format; + private m_position; + private m_separator; + private m_showBubbleSize; + private m_showCategoryName; + private m_showLegendKey; + private m_showPercentage; + private m_showSeriesName; + private m_showValue; + /** + * + * Represents the format of chart data labels, which includes fill and font formatting. Read-only. + */ + format: Excel.ChartDataLabelFormat; + /** + * + * DataLabelPosition value that represents the position of the data label. See Excel.ChartDataLabelPosition for details. + */ + position: string; + /** + * + * String representing the separator used for the data labels on a chart. + */ + separator: string; + /** + * + * Boolean value representing if the data label bubble size is visible or not. + */ + showBubbleSize: boolean; + /** + * + * Boolean value representing if the data label category name is visible or not. + */ + showCategoryName: boolean; + /** + * + * Boolean value representing if the data label legend key is visible or not. + */ + showLegendKey: boolean; + /** + * + * Boolean value representing if the data label percentage is visible or not. + */ + showPercentage: boolean; + /** + * + * Boolean value representing if the data label series name is visible or not. + */ + showSeriesName: boolean; + /** + * + * Boolean value representing if the data label value is visible or not. + */ + showValue: boolean; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartDataLabels; + } + /** + * + * Encapsulates the format properties for the chart data labels. + */ + class ChartDataLabelFormat extends OfficeExtension.ClientObject { + private m_fill; + private m_font; + /** + * + * Represents the fill format of the current chart data label. Read-only. + */ + fill: Excel.ChartFill; + /** + * + * Represents the font attributes (font name, font size, color, etc.) for a chart data label. Read-only. + */ + font: Excel.ChartFont; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartDataLabelFormat; + } + /** + * + * Represents major or minor gridlines on a chart axis. + */ + class ChartGridlines extends OfficeExtension.ClientObject { + private m_format; + private m_visible; + /** + * + * Represents the formatting of chart gridlines. Read-only. + */ + format: Excel.ChartGridlinesFormat; + /** + * + * Boolean value representing if the axis gridlines are visible or not. + */ + visible: boolean; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartGridlines; + } + /** + * + * Encapsulates the format properties for chart gridlines. + */ + class ChartGridlinesFormat extends OfficeExtension.ClientObject { + private m_line; + /** + * + * Represents chart line formatting. Read-only. + */ + line: Excel.ChartLineFormat; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartGridlinesFormat; + } + /** + * + * Represents the legend in a chart. + */ + class ChartLegend extends OfficeExtension.ClientObject { + private m_format; + private m_overlay; + private m_position; + private m_visible; + /** + * + * Represents the formatting of a chart legend, which includes fill and font formatting. Read-only. + */ + format: Excel.ChartLegendFormat; + /** + * + * Boolean value for whether the chart legend should overlap with the main body of the chart. + */ + overlay: boolean; + /** + * + * Represents the position of the legend on the chart. See Excel.ChartLegendPosition for details. + */ + position: string; + /** + * + * A boolean value the represents the visibility of a ChartLegend object. + */ + visible: boolean; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartLegend; + } + /** + * + * Encapsulates the format properties of a chart legend. + */ + class ChartLegendFormat extends OfficeExtension.ClientObject { + private m_fill; + private m_font; + /** + * + * Represents the fill format of an object, which includes background formating information. Read-only. + */ + fill: Excel.ChartFill; + /** + * + * Represents the font attributes such as font name, font size, color, etc. of a chart legend. Read-only. + */ + font: Excel.ChartFont; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartLegendFormat; + } + /** + * + * Represents a chart title object of a chart. + */ + class ChartTitle extends OfficeExtension.ClientObject { + private m_format; + private m_overlay; + private m_text; + private m_visible; + /** + * + * Represents the formatting of a chart title, which includes fill and font formatting. Read-only. + */ + format: Excel.ChartTitleFormat; + /** + * + * Boolean value representing if the chart title will overlay the chart or not. + */ + overlay: boolean; + /** + * + * Represents the title text of a chart. + */ + text: string; + /** + * + * A boolean value the represents the visibility of a chart title object. + */ + visible: boolean; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartTitle; + } + /** + * + * Provides access to the office art formatting for chart title. + */ + class ChartTitleFormat extends OfficeExtension.ClientObject { + private m_fill; + private m_font; + /** + * + * Represents the fill format of an object, which includes background formating information. Read-only. + */ + fill: Excel.ChartFill; + /** + * + * Represents the font attributes (font name, font size, color, etc.) for an object. Read-only. + */ + font: Excel.ChartFont; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartTitleFormat; + } + /** + * + * Represents the fill formatting for a chart element. + */ + class ChartFill extends OfficeExtension.ClientObject { + /** + * + * Clear the fill color of a chart element. + * + */ + clear(): void; + /** + * + * Sets the fill formatting of a chart element to a uniform color. + * + * @param color HTML color code representing the color of the border line, of the form #RRGGBB (e.g. "FFA500") or as a named HTML color (e.g. "orange"). + */ + setSolidColor(color: string): void; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartFill; + } + /** + * + * Enapsulates the formatting options for line elements. + */ + class ChartLineFormat extends OfficeExtension.ClientObject { + private m_color; + /** + * + * HTML color code representing the color of lines in the chart. + */ + color: string; + /** + * + * Clear the line format of a chart element. + * + */ + clear(): void; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartLineFormat; + } + /** + * + * This object represents the font attributes (font name, font size, color, etc.) for a chart object. + */ + class ChartFont extends OfficeExtension.ClientObject { + private m_bold; + private m_color; + private m_italic; + private m_name; + private m_size; + private m_underline; + /** + * + * Represents the bold status of font. + */ + bold: boolean; + /** + * + * HTML color code representation of the text color. E.g. #FF0000 represents Red. + */ + color: string; + /** + * + * Represents the italic status of the font. + */ + italic: boolean; + /** + * + * Font name (e.g. "Calibri") + */ + name: string; + /** + * + * Size of the font (e.g. 11) + */ + size: number; + /** + * + * Type of underline applied to the font. See Excel.ChartUnderlineStyle for details. + */ + underline: string; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartFont; + } + module BindingType { + var range: string; + var table: string; + var text: string; + } + module BorderIndex { + var edgeTop: string; + var edgeBottom: string; + var edgeLeft: string; + var edgeRight: string; + var insideVertical: string; + var insideHorizontal: string; + var diagonalDown: string; + var diagonalUp: string; + } + module BorderLineStyle { + var none: string; + var continuous: string; + var dash: string; + var dashDot: string; + var dashDotDot: string; + var dot: string; + var double: string; + var slantDashDot: string; + } + module BorderWeight { + var hairline: string; + var thin: string; + var medium: string; + var thick: string; + } + module CalculationMode { + var automatic: string; + var automaticExceptTables: string; + var manual: string; + } + module CalculationType { + var recalculate: string; + var full: string; + var fullRebuild: string; + } + module ClearApplyTo { + var all: string; + var formats: string; + var contents: string; + } + module ChartDataLabelPosition { + var invalid: string; + var none: string; + var center: string; + var insideEnd: string; + var insideBase: string; + var outsideEnd: string; + var left: string; + var right: string; + var top: string; + var bottom: string; + var bestFit: string; + var callout: string; + } + module ChartLegendPosition { + var invalid: string; + var top: string; + var bottom: string; + var left: string; + var right: string; + var corner: string; + var custom: string; + } + module ChartSeriesBy { + var auto: string; + var columns: string; + var rows: string; + } + module ChartType { + var invalid: string; + var columnClustered: string; + var columnStacked: string; + var columnStacked100: string; + var _3DColumnClustered: string; + var _3DColumnStacked: string; + var _3DColumnStacked100: string; + var barClustered: string; + var barStacked: string; + var barStacked100: string; + var _3DBarClustered: string; + var _3DBarStacked: string; + var _3DBarStacked100: string; + var lineStacked: string; + var lineStacked100: string; + var lineMarkers: string; + var lineMarkersStacked: string; + var lineMarkersStacked100: string; + var pieOfPie: string; + var pieExploded: string; + var _3DPieExploded: string; + var barOfPie: string; + var xyscatterSmooth: string; + var xyscatterSmoothNoMarkers: string; + var xyscatterLines: string; + var xyscatterLinesNoMarkers: string; + var areaStacked: string; + var areaStacked100: string; + var _3DAreaStacked: string; + var _3DAreaStacked100: string; + var doughnutExploded: string; + var radarMarkers: string; + var radarFilled: string; + var surface: string; + var surfaceWireframe: string; + var surfaceTopView: string; + var surfaceTopViewWireframe: string; + var bubble: string; + var bubble3DEffect: string; + var stockHLC: string; + var stockOHLC: string; + var stockVHLC: string; + var stockVOHLC: string; + var cylinderColClustered: string; + var cylinderColStacked: string; + var cylinderColStacked100: string; + var cylinderBarClustered: string; + var cylinderBarStacked: string; + var cylinderBarStacked100: string; + var cylinderCol: string; + var coneColClustered: string; + var coneColStacked: string; + var coneColStacked100: string; + var coneBarClustered: string; + var coneBarStacked: string; + var coneBarStacked100: string; + var coneCol: string; + var pyramidColClustered: string; + var pyramidColStacked: string; + var pyramidColStacked100: string; + var pyramidBarClustered: string; + var pyramidBarStacked: string; + var pyramidBarStacked100: string; + var pyramidCol: string; + var _3DColumn: string; + var line: string; + var _3DLine: string; + var _3DPie: string; + var pie: string; + var xyscatter: string; + var _3DArea: string; + var area: string; + var doughnut: string; + var radar: string; + } + module ChartUnderlineStyle { + var none: string; + var single: string; + } + module DeleteShiftDirection { + var up: string; + var left: string; + } + module HorizontalAlignment { + var general: string; + var left: string; + var center: string; + var right: string; + var fill: string; + var justify: string; + var centerAcrossSelection: string; + var distributed: string; + } + module InsertShiftDirection { + var down: string; + var right: string; + } + module NamedItemType { + var string: string; + var integer: string; + var double: string; + var boolean: string; + var range: string; + } + module RangeUnderlineStyle { + var none: string; + var single: string; + var double: string; + var singleAccountant: string; + var doubleAccountant: string; + } + module SheetVisibility { + var visible: string; + var hidden: string; + var veryHidden: string; + } + module RangeValueType { + var unknown: string; + var empty: string; + var string: string; + var integer: string; + var double: string; + var boolean: string; + var error: string; + } + module VerticalAlignment { + var top: string; + var center: string; + var bottom: string; + var justify: string; + var distributed: string; + } + module ErrorCodes { + var accessDenied: string; + var generalException: string; + var insertDeleteConflict: string; + var invalidArgument: string; + var invalidBinding: string; + var invalidOperation: string; + var invalidReference: string; + var invalidSelection: string; + var itemAlreadyExists: string; + var itemNotFound: string; + var notImplemented: string; + var unsupportedOperation: string; + } +} +declare module Excel { + /** + * The RequestContext object facilitates requests to the Excel application. Since the Office add-in and the Excel application run in two different processes, the request context is required to get access to the Excel object model from the add-in. + */ + class RequestContext extends OfficeExtension.ClientRequestContext { + private m_workbook; + constructor(url?: string); + workbook: Workbook; + } + /** + * Executes a batch script that performs actions on the Excel object model. When the promise is resolved, any tracked objects that were automatically allocated during execution will be released. + * @param batch - A function that takes in an Excel.RequestContext and returns a promise (typically, just the result of "context.sync()"). The context parameter facilitates requests to the Excel application. Since the Office add-in and the Excel application run in two different processes, the request context is required to get access to the Excel object model from the add-in. + */ + function run(batch: (context: Excel.RequestContext) => OfficeExtension.IPromise): OfficeExtension.IPromise; +} + +declare module Word { + /** + * + * Represents the body of a document or a section. + */ + class Body extends OfficeExtension.ClientObject { + private m_contentControls; + private m_font; + private m_inlinePictures; + private m_paragraphs; + private m_parentContentControl; + private m_style; + private m_text; + private m__ReferenceId; + /** + * + * Gets the collection of rich text content control objects that are in the body. Read-only. + */ + contentControls: Word.ContentControlCollection; + /** + * + * Gets the text format of the body. Use this to get and set font name, size, color, and other properties. Read-only. + */ + font: Word.Font; + /** + * + * Gets the collection of inlinePicture objects that are in the body. The collection does not include floating images. Read-only. + */ + inlinePictures: Word.InlinePictureCollection; + /** + * + * Gets the collection of paragraph objects that are in the body. Read-only. + */ + paragraphs: Word.ParagraphCollection; + /** + * + * Gets the content control that contains the body. Returns null if there isn't a parent content control. Read-only. + */ + parentContentControl: Word.ContentControl; + /** + * + * Gets or sets the style used for the body. This is the name of the pre-installed or custom style. + */ + style: string; + /** + * + * Gets the text of the body. Use the insertText method to insert text. Read-only. + */ + text: string; + /** + * + * Clears the contents of the body object. The user can perform the undo operation on the cleared content. + * + */ + clear(): void; + /** + * + * Gets the HTML representation of the body object. + * + */ + getHtml(): OfficeExtension.ClientResult; + /** + * + * Gets the OOXML (Office Open XML) representation of the body object. + * + */ + getOoxml(): OfficeExtension.ClientResult; + /** + * + * Inserts a break at the specified location. The insertLocation value can be 'Start' or 'End'. + * + * @param breakType Required. The break type to add to the body. + * @param insertLocation Required. The value can be 'Start' or 'End'. + */ + insertBreak(breakType: string, insertLocation: string): void; + /** + * + * Wraps the body object with a Rich Text content control. + * + */ + insertContentControl(): Word.ContentControl; + /** + * + * Inserts a document into the body at the specified location. The insertLocation value can be 'Replace', 'Start' or 'End'. + * + * @param base64File Required. The base64 encoded file contents to be inserted. + * @param insertLocation Required. The value can be 'Replace', 'Start' or 'End'. + */ + insertFileFromBase64(base64File: string, insertLocation: string): Word.Range; + /** + * + * Inserts HTML at the specified location. The insertLocation value can be 'Replace', 'Start' or 'End'. + * + * @param html Required. The HTML to be inserted in the document. + * @param insertLocation Required. The value can be 'Replace', 'Start' or 'End'. + */ + insertHtml(html: string, insertLocation: string): Word.Range; + /** + * + * Inserts OOXML at the specified location. The insertLocation value can be 'Replace', 'Start' or 'End'. + * + * @param ooxml Required. The OOXML to be inserted. + * @param insertLocation Required. The value can be 'Replace', 'Start' or 'End'. + */ + insertOoxml(ooxml: string, insertLocation: string): Word.Range; + /** + * + * Inserts a paragraph at the specified location. The insertLocation value can be 'Start' or 'End'. + * + * @param paragraphText Required. The paragraph text to be inserted. + * @param insertLocation Required. The value can be 'Start' or 'End'. + */ + insertParagraph(paragraphText: string, insertLocation: string): Word.Paragraph; + /** + * + * Inserts text into the body at the specified location. The insertLocation value can be 'Replace', 'Start' or 'End'. + * + * @param text Required. Text to be inserted. + * @param insertLocation Required. The value can be 'Replace', 'Start' or 'End'. + */ + insertText(text: string, insertLocation: string): Word.Range; + /** + * + * Performs a search with the specified searchOptions on the scope of the body object. The search results are a collection of range objects. + * + * @param searchText Required. The search text. + * @param searchOptions Optional. Options for the search. + */ + search(searchText: string, searchOptions?: Word.SearchOptions | { + ignorePunct?: boolean; + ignoreSpace?: boolean; + matchCase?: boolean; + matchPrefix?: boolean; + matchSoundsLike?: boolean; + matchSuffix?: boolean; + matchWholeWord?: boolean; + matchWildCards?: boolean; + }): Word.SearchResultCollection; + /** + * + * Selects the body and navigates the Word UI to it. + * + */ + select(): void; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Word.Body; + } + /** + * + * Represents a content control. Content controls are bounded and potentially labeled regions in a document that serve as containers for specific types of content. Individual content controls may contain contents such as images, tables, or paragraphs of formatted text. Currently, only rich text content controls are supported. + */ + class ContentControl extends OfficeExtension.ClientObject { + private m_appearance; + private m_cannotDelete; + private m_cannotEdit; + private m_color; + private m_contentControls; + private m_font; + private m_id; + private m_inlinePictures; + private m_paragraphs; + private m_parentContentControl; + private m_placeholderText; + private m_removeWhenEdited; + private m_style; + private m_tag; + private m_text; + private m_title; + private m_type; + private m__ReferenceId; + /** + * + * Gets the collection of content control objects in the content control. Read-only. + */ + contentControls: Word.ContentControlCollection; + /** + * + * Gets the text format of the content control. Use this to get and set font name, size, color, and other properties. Read-only. + */ + font: Word.Font; + /** + * + * Gets the collection of inlinePicture objects in the content control. The collection does not include floating images. Read-only. + */ + inlinePictures: Word.InlinePictureCollection; + /** + * + * Get the collection of paragraph objects in the content control. Read-only. + */ + paragraphs: Word.ParagraphCollection; + /** + * + * Gets the content control that contains the content control. Returns null if there isn't a parent content control. Read-only. + */ + parentContentControl: Word.ContentControl; + /** + * + * Gets or sets the appearance of the content control. The value can be 'boundingBox', 'tags' or 'hidden'. + */ + appearance: string; + /** + * + * Gets or sets a value that indicates whether the user can delete the content control. Mutually exclusive with removeWhenEdited. + */ + cannotDelete: boolean; + /** + * + * Gets or sets a value that indicates whether the user can edit the contents of the content control. + */ + cannotEdit: boolean; + /** + * + * Gets or sets the color of the content control. Color is set in "#RRGGBB" format or by using the color name. + */ + color: string; + /** + * + * Gets an integer that represents the content control identifier. Read-only. + */ + id: number; + /** + * + * Gets or sets the placeholder text of the content control. Dimmed text will be displayed when the content control is empty. + */ + placeholderText: string; + /** + * + * Gets or sets a value that indicates whether the content control is removed after it is edited. Mutually exclusive with cannotDelete. + */ + removeWhenEdited: boolean; + /** + * + * Gets or sets the style used for the content control. This is the name of the pre-installed or custom style. + */ + style: string; + /** + * + * Gets or sets a tag to identify a content control. + */ + tag: string; + /** + * + * Gets the text of the content control. Read-only. + */ + text: string; + /** + * + * Gets or sets the title for a content control. + */ + title: string; + /** + * + * Gets the content control type. Only rich text content controls are supported currently. Read-only. + */ + type: string; + /** + * + * Clears the contents of the content control. The user can perform the undo operation on the cleared content. + * + */ + clear(): void; + /** + * + * Deletes the content control and its content. If keepContent is set to true, the content is not deleted. + * + * @param keepContent Required. Indicates whether the content should be deleted with the content control. If keepContent is set to true, the content is not deleted. + */ + delete(keepContent: boolean): void; + /** + * + * Gets the HTML representation of the content control object. + * + */ + getHtml(): OfficeExtension.ClientResult; + /** + * + * Gets the Office Open XML (OOXML) representation of the content control object. + * + */ + getOoxml(): OfficeExtension.ClientResult; + /** + * + * Inserts a break at the specified location. The insertLocation value can be 'Before', 'After', 'Start' or 'End'. + * + * @param breakType Required. Type of break (breakType.md) + * @param insertLocation Required. The value can be 'Before', 'After', 'Start' or 'End'. + */ + insertBreak(breakType: string, insertLocation: string): void; + /** + * + * Inserts a document into the current content control at the specified location. The insertLocation value can be 'Replace', 'Start' or 'End'. + * + * @param base64File Required. Base64 encoded contents of the file to be inserted. + * @param insertLocation Required. The value can be 'Replace', 'Start' or 'End'. + */ + insertFileFromBase64(base64File: string, insertLocation: string): Word.Range; + /** + * + * Inserts HTML into the content control at the specified location. The insertLocation value can be 'Replace', 'Start' or 'End'. + * + * @param html Required. The HTML to be inserted in to the content control. + * @param insertLocation Required. The value can be 'Replace', 'Start' or 'End'. + */ + insertHtml(html: string, insertLocation: string): Word.Range; + /** + * + * Inserts OOXML into the content control at the specified location. The insertLocation value can be 'Replace', 'Start' or 'End'. + * + * @param ooxml Required. The OOXML to be inserted in to the content control. + * @param insertLocation Required. The value can be 'Replace', 'Start' or 'End'. + */ + insertOoxml(ooxml: string, insertLocation: string): Word.Range; + /** + * + * Inserts a paragraph at the specified location. The insertLocation value can be 'Before', 'After', 'Start' or 'End'. + * + * @param paragraphText Required. The paragrph text to be inserted. + * @param insertLocation Required. The value can be 'Before', 'After', 'Start' or 'End'. + */ + insertParagraph(paragraphText: string, insertLocation: string): Word.Paragraph; + /** + * + * Inserts text into the content control at the specified location. The insertLocation value can be 'Replace', 'Start' or 'End'. + * + * @param text Required. The text to be inserted in to the content control. + * @param insertLocation Required. The value can be 'Replace', 'Start' or 'End'. + */ + insertText(text: string, insertLocation: string): Word.Range; + /** + * + * Performs a search with the specified searchOptions on the scope of the content control object. The search results are a collection of range objects. + * + * @param searchText Required. The search text. + * @param searchOptions Optional. Options for the search. + */ + search(searchText: string, searchOptions?: Word.SearchOptions | { + ignorePunct?: boolean; + ignoreSpace?: boolean; + matchCase?: boolean; + matchPrefix?: boolean; + matchSoundsLike?: boolean; + matchSuffix?: boolean; + matchWholeWord?: boolean; + matchWildCards?: boolean; + }): Word.SearchResultCollection; + /** + * + * Selects the content control. This causes Word to scroll to the selection. + * + */ + select(): void; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Word.ContentControl; + } + /** + * + * Contains a collection of ContentControl objects. Content controls are bounded and potentially labeled regions in a document that serve as containers for specific types of content. Individual content controls may contain contents such as images, tables, or paragraphs of formatted text. Currently, only rich text content controls are supported. + */ + class ContentControlCollection extends OfficeExtension.ClientObject { + private m__ReferenceId; + private m__items; + /** Gets the loaded child items in this collection. */ + items: Array; + /** + * + * Gets a content control by its identifier. + * + * @param id Required. A content control identifier. + */ + getById(id: number): Word.ContentControl; + /** + * + * Gets the content controls that have the specified tag. + * + * @param tag Required. A tag set on a content control. + */ + getByTag(tag: string): Word.ContentControlCollection; + /** + * + * Gets the content controls that have the specified title. + * + * @param title Required. The title of a content control. + */ + getByTitle(title: string): Word.ContentControlCollection; + /** + * + * Gets a content control by its index in the collection. + * + * @param index The index + */ + getItem(index: number): Word.ContentControl; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Word.ContentControlCollection; + } + /** + * + * The Document object is the top level object. A Document object contains one or more sections, content controls, and the body that contains the contents of the document. + */ + class Document extends OfficeExtension.ClientObject { + private m_body; + private m_contentControls; + private m_saved; + private m_sections; + /** + * + * Gets the body of the document. The body is the text that excludes headers, footers, footnotes, textboxes, etc.. Read-only. + */ + body: Word.Body; + /** + * + * Gets the collection of content control objects that are in the current document. This includes content controls in the body of the document, headers, footers, textboxes, etc.. Read-only. + */ + contentControls: Word.ContentControlCollection; + /** + * + * Gets the collection of section objects that are in the document. Read-only. + */ + sections: Word.SectionCollection; + /** + * + * Indicates whether the changes in the document have been saved. A value of true indicates that the document hasn't changed since it was saved. Read-only. + */ + saved: boolean; + /** + * + * Gets the current selection of the document. Multiple selections are not supported. + * + */ + getSelection(): Word.Range; + /** + * + * Saves the document. This will use the Word default file naming convention if the document has not been saved before. + * + */ + save(): void; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Word.Document; + } + /** + * + * Represents a font. + */ + class Font extends OfficeExtension.ClientObject { + private m_bold; + private m_color; + private m_doubleStrikeThrough; + private m_highlightColor; + private m_italic; + private m_name; + private m_size; + private m_strikeThrough; + private m_subscript; + private m_superscript; + private m_underline; + private m__ReferenceId; + /** + * + * Gets or sets a value that indicates whether the font is bold. True if the font is formatted as bold, otherwise, false. + */ + bold: boolean; + /** + * + * Gets or sets the color for the specified font. You can provide the value in the "#RRGGBB" format or the color name. + */ + color: string; + /** + * + * Gets or sets a value that indicates whether the font has a double strike through. True if the font is formatted as double strikethrough text, otherwise, false. + */ + doubleStrikeThrough: boolean; + /** + * + * Gets or sets the highlight color for the specified font. You can provide the value as either in the "#RRGGBB" format or the color name. + */ + highlightColor: string; + /** + * + * Gets or sets a value that indicates whether the font is italicized. True if the font is italicized, otherwise, false. + */ + italic: boolean; + /** + * + * Gets or sets a value that represents the name of the font. + */ + name: string; + /** + * + * Gets or sets a value that represents the font size in points. + */ + size: number; + /** + * + * Gets or sets a value that indicates whether the font has a strike through. True if the font is formatted as strikethrough text, otherwise, false. + */ + strikeThrough: boolean; + /** + * + * Gets or sets a value that indicates whether the font is a subscript. True if the font is formatted as subscript, otherwise, false. + */ + subscript: boolean; + /** + * + * Gets or sets a value that indicates whether the font is a superscript. True if the font is formatted as superscript, otherwise, false. + */ + superscript: boolean; + /** + * + * Gets or sets a value that indicates the font's underline type. 'None' if the font is not underlined. + */ + underline: string; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Word.Font; + } + /** + * + * Represents an inline picture. + */ + class InlinePicture extends OfficeExtension.ClientObject { + private m_altTextDescription; + private m_altTextTitle; + private m_height; + private m_hyperlink; + private m_lockAspectRatio; + private m_parentContentControl; + private m_width; + private m__Id; + private m__ReferenceId; + /** + * + * Gets the content control that contains the inline image. Returns null if there isn't a parent content control. Read-only. + */ + parentContentControl: Word.ContentControl; + /** + * + * Gets or sets a string that represents the alternative text associated with the inline image + */ + altTextDescription: string; + /** + * + * Gets or sets a string that contains the title for the inline image. + */ + altTextTitle: string; + /** + * + * Gets or sets a number that describes the height of the inline image. + */ + height: number; + /** + * + * Gets or sets the hyperlink associated with the inline image. + */ + hyperlink: string; + /** + * + * Gets or sets a value that indicates whether the inline image retains its original proportions when you resize it. + */ + lockAspectRatio: boolean; + /** + * + * Gets or sets a number that describes the width of the inline image. + */ + width: number; + /** + * + * Gets the base64 encoded string representation of the inline image. + * + */ + getBase64ImageSrc(): OfficeExtension.ClientResult; + /** + * + * Wraps the inline picture with a rich text content control. + * + */ + insertContentControl(): Word.ContentControl; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Word.InlinePicture; + } + /** + * + * Contains a collection of [inlinePicture](inlinePicture.md) objects. + */ + class InlinePictureCollection extends OfficeExtension.ClientObject { + private m__ReferenceId; + private m__items; + /** Gets the loaded child items in this collection. */ + items: Array; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Word.InlinePictureCollection; + } + /** + * + * Represents a single paragraph in a selection, range, content control, or document body. + */ + class Paragraph extends OfficeExtension.ClientObject { + private m_alignment; + private m_contentControls; + private m_firstLineIndent; + private m_font; + private m_inlinePictures; + private m_leftIndent; + private m_lineSpacing; + private m_lineUnitAfter; + private m_lineUnitBefore; + private m_outlineLevel; + private m_parentContentControl; + private m_rightIndent; + private m_spaceAfter; + private m_spaceBefore; + private m_style; + private m_text; + private m__Id; + private m__ReferenceId; + /** + * + * Gets the collection of content control objects that are in the paragraph. Read-only. + */ + contentControls: Word.ContentControlCollection; + /** + * + * Gets the text format of the paragraph. Use this to get and set font name, size, color, and other properties. Read-only. + */ + font: Word.Font; + /** + * + * Gets the collection of inlinePicture objects that are in the paragraph. The collection does not include floating images. Read-only. + */ + inlinePictures: Word.InlinePictureCollection; + /** + * + * Gets the content control that contains the paragraph. Returns null if there isn't a parent content control. Read-only. + */ + parentContentControl: Word.ContentControl; + /** + * + * Gets or sets the alignment for a paragraph. The value can be "left", "centered", "right", or "justified". + */ + alignment: string; + /** + * + * Gets or sets the value, in points, for a first line or hanging indent. Use a positive value to set a first-line indent, and use a negative value to set a hanging indent. + */ + firstLineIndent: number; + /** + * + * Gets or sets the left indent value, in points, for the paragraph. + */ + leftIndent: number; + /** + * + * Gets or sets the line spacing, in points, for the specified paragraph. In the Word UI, this value is divided by 12. + */ + lineSpacing: number; + /** + * + * Gets or sets the amount of spacing, in grid lines. after the paragraph. + */ + lineUnitAfter: number; + /** + * + * Gets or sets the amount of spacing, in grid lines, before the paragraph. + */ + lineUnitBefore: number; + /** + * + * Gets or sets the outline level for the paragraph. + */ + outlineLevel: number; + /** + * + * Gets or sets the right indent value, in points, for the paragraph. + */ + rightIndent: number; + /** + * + * Gets or sets the spacing, in points, after the paragraph. + */ + spaceAfter: number; + /** + * + * Gets or sets the spacing, in points, before the paragraph. + */ + spaceBefore: number; + /** + * + * Gets or sets the style used for the paragraph. This is the name of the pre-installed or custom style. + */ + style: string; + /** + * + * Gets the text of the paragraph. Read-only. + */ + text: string; + /** + * + * Clears the contents of the paragraph object. The user can perform the undo operation on the cleared content. + * + */ + clear(): void; + /** + * + * Deletes the paragraph and its content from the document. + * + */ + delete(): void; + /** + * + * Gets the HTML representation of the paragraph object. + * + */ + getHtml(): OfficeExtension.ClientResult; + /** + * + * Gets the Office Open XML (OOXML) representation of the paragraph object. + * + */ + getOoxml(): OfficeExtension.ClientResult; + /** + * + * Inserts a break at the specified location. The insertLocation value can be 'Start' or 'End'. + * + * @param breakType Required. The break type to add to the document. + * @param insertLocation Required. The value can be 'Before' or 'After'. + */ + insertBreak(breakType: string, insertLocation: string): void; + /** + * + * Wraps the paragraph object with a rich text content control. + * + */ + insertContentControl(): Word.ContentControl; + /** + * + * Inserts a document into the current paragraph at the specified location. The insertLocation value can be 'Start' or 'End'. + * + * @param base64File Required. The file base64 encoded file contents to be inserted. + * @param insertLocation Required. The value can be 'Start' or 'End'. + */ + insertFileFromBase64(base64File: string, insertLocation: string): Word.Range; + /** + * + * Inserts HTML into the paragraph at the specified location. The insertLocation value can be 'Replace', 'Start' or 'End'. + * + * @param html Required. The HTML to be inserted in the paragraph. + * @param insertLocation Required. The value can be 'Replace', 'Start' or 'End'. + */ + insertHtml(html: string, insertLocation: string): Word.Range; + /** + * + * Inserts a picture into the paragraph at the specified location. The insertLocation value can be 'Before', 'After', 'Start' or 'End'. + * + * @param base64EncodedImage Required. The HTML to be inserted in the paragraph. + * @param insertLocation Required. The value can be 'Before', 'After', 'Start' or 'End'. + */ + insertInlinePictureFromBase64(base64EncodedImage: string, insertLocation: string): Word.InlinePicture; + /** + * + * Inserts OOXML into the paragraph at the specified location. The insertLocation value can be 'Replace', 'Start' or 'End'. + * + * @param ooxml Required. The OOXML to be inserted in the paragraph. + * @param insertLocation Required. The value can be 'Replace', 'Start' or 'End'. + */ + insertOoxml(ooxml: string, insertLocation: string): Word.Range; + /** + * + * Inserts a paragraph at the specified location. The insertLocation value can be 'Before' or 'After'. + * + * @param paragraphText Required. The paragraph text to be inserted. + * @param insertLocation Required. The value can be 'Before' or 'After'. + */ + insertParagraph(paragraphText: string, insertLocation: string): Word.Paragraph; + /** + * + * Inserts text into the paragraph at the specified location. The insertLocation value can be 'Replace', 'Start' or 'End'. + * + * @param text Required. Text to be inserted. + * @param insertLocation Required. The value can be 'Replace', 'Start' or 'End'. + */ + insertText(text: string, insertLocation: string): Word.Range; + /** + * + * Performs a search with the specified searchOptions on the scope of the paragraph object. The search results are a collection of range objects. + * + * @param searchText Required. The search text. + * @param searchOptions Optional. Options for the search. + */ + search(searchText: string, searchOptions?: Word.SearchOptions | { + ignorePunct?: boolean; + ignoreSpace?: boolean; + matchCase?: boolean; + matchPrefix?: boolean; + matchSoundsLike?: boolean; + matchSuffix?: boolean; + matchWholeWord?: boolean; + matchWildCards?: boolean; + }): Word.SearchResultCollection; + /** + * + * Selects and navigates the Word UI to the paragraph. + * + */ + select(): void; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Word.Paragraph; + } + /** + * + * Contains a collection of [paragraph](paragraph.md) objects. + */ + class ParagraphCollection extends OfficeExtension.ClientObject { + private m__ReferenceId; + private m__items; + /** Gets the loaded child items in this collection. */ + items: Array; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Word.ParagraphCollection; + } + /** + * + * Represents a contiguous area in a document. + */ + class Range extends OfficeExtension.ClientObject { + private m_contentControls; + private m_font; + private m_paragraphs; + private m_parentContentControl; + private m_style; + private m_text; + private m__Id; + private m__ReferenceId; + /** + * + * Gets the collection of content control objects that are in the range. Read-only. + */ + contentControls: Word.ContentControlCollection; + /** + * + * Gets the text format of the range. Use this to get and set font name, size, color, and other properties. Read-only. + */ + font: Word.Font; + /** + * + * Gets the collection of paragraph objects that are in the range. Read-only. + */ + paragraphs: Word.ParagraphCollection; + /** + * + * Gets the content control that contains the range. Returns null if there isn't a parent content control. Read-only. + */ + parentContentControl: Word.ContentControl; + /** + * + * Gets or sets the style used for the range. This is the name of the pre-installed or custom style. + */ + style: string; + /** + * + * Gets the text of the range. Read-only. + */ + text: string; + /** + * + * Clears the contents of the range object. The user can perform the undo operation on the cleared content. + * + */ + clear(): void; + /** + * + * Deletes the range and its content from the document. + * + */ + delete(): void; + /** + * + * Gets the HTML representation of the range object. + * + */ + getHtml(): OfficeExtension.ClientResult; + /** + * + * Gets the OOXML representation of the range object. + * + */ + getOoxml(): OfficeExtension.ClientResult; + /** + * + * Inserts a break at the specified location. The insertLocation value can be 'Replace', 'Before' or 'After'. + * + * @param breakType Required. The break type to add to the range. + * @param insertLocation Required. The value can be 'Replace', 'Before' or 'After'. + */ + insertBreak(breakType: string, insertLocation: string): void; + /** + * + * Wraps the range object with a rich text content control. + * + */ + insertContentControl(): Word.ContentControl; + /** + * + * Inserts a document into the range at the specified location. The insertLocation value can be 'Replace', 'Start' or 'End'. + * + * @param base64File Required. The file base64 encoded file contents to be inserted. + * @param insertLocation Required. The value can be 'Replace', 'Start' or 'End'. + */ + insertFileFromBase64(base64File: string, insertLocation: string): Word.Range; + /** + * + * Inserts HTML into the range at the specified location. The insertLocation value can be 'Replace', 'Start' or 'End'. + * + * @param html Required. The HTML to be inserted in the range. + * @param insertLocation Required. The value can be 'Replace', 'Start' or 'End'. + */ + insertHtml(html: string, insertLocation: string): Word.Range; + /** + * + * Inserts OOXML into the range at the specified location. The insertLocation value can be 'Replace', 'Start' or 'End'. + * + * @param ooxml Required. The OOXML to be inserted in the range. + * @param insertLocation Required. The value can be 'Replace', 'Start' or 'End'. + */ + insertOoxml(ooxml: string, insertLocation: string): Word.Range; + /** + * + * Inserts a paragraph into the range at the specified location. The insertLocation value can be 'Before' or 'After'. + * + * @param paragraphText Required. The paragraph text to be inserted. + * @param insertLocation Required. The value can be 'Before' or 'After'. + */ + insertParagraph(paragraphText: string, insertLocation: string): Word.Paragraph; + /** + * + * Inserts text into the range at the specified location. The insertLocation value can be 'Replace', 'Start' or 'End'. + * + * @param text Required. Text to be inserted. + * @param insertLocation Required. The value can be 'Replace', 'Start' or 'End'. + */ + insertText(text: string, insertLocation: string): Word.Range; + /** + * + * Performs a search with the specified searchOptions on the scope of the range object. The search results are a collection of range objects. + * + * @param searchText Required. The search text. + * @param searchOptions Optional. Options for the search. + */ + search(searchText: string, searchOptions?: Word.SearchOptions | { + ignorePunct?: boolean; + ignoreSpace?: boolean; + matchCase?: boolean; + matchPrefix?: boolean; + matchSoundsLike?: boolean; + matchSuffix?: boolean; + matchWholeWord?: boolean; + matchWildCards?: boolean; + }): Word.SearchResultCollection; + /** + * + * Selects and navigates the Word UI to the range. + * + */ + select(): void; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Word.Range; + } + /** + * + * Specifies the options to be included in a search operation. + */ + class SearchOptions extends OfficeExtension.ClientObject { + private m_ignorePunct; + private m_ignoreSpace; + private m_matchCase; + private m_matchPrefix; + private m_matchSoundsLike; + private m_matchSuffix; + private m_matchWholeWord; + private m_matchWildCards; + /** + * + * Gets or sets a value that indicates whether to ignore all punctuation characters between words. Corresponds to the Ignore punctuation check box in the Find and Replace dialog box. + */ + ignorePunct: boolean; + /** + * + * Gets or sets a value that indicates whether to ignore all white space between words. Corresponds to the Ignore white-space characters check box in the Find and Replace dialog box. + */ + ignoreSpace: boolean; + /** + * + * Gets or sets a value that indicates whether to perform a case sensitive search. Corresponds to the Match case check box in the Find and Replace dialog box (Edit menu). + */ + matchCase: boolean; + /** + * + * Gets or sets a value that indicates whether to match words that begin with the search string. Corresponds to the Match prefix check box in the Find and Replace dialog box. + */ + matchPrefix: boolean; + /** + * + * Gets or sets a value that indicates whether to find words that sound similar to the search string. Corresponds to the Sounds like check box in the Find and Replace dialog box + */ + matchSoundsLike: boolean; + /** + * + * Gets or sets a value that indicates whether to match words that end with the search string. Corresponds to the Match suffix check box in the Find and Replace dialog box. + */ + matchSuffix: boolean; + /** + * + * Gets or sets a value that indicates whether to find operation only entire words, not text that is part of a larger word. Corresponds to the Find whole words only check box in the Find and Replace dialog box. + */ + matchWholeWord: boolean; + /** + * + * Gets or sets a value that indicates whether the search will be performed using special search operators. Corresponds to the Use wildcards check box in the Find and Replace dialog box. + */ + matchWildCards: boolean; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Word.SearchOptions; + /** + * Create a new instance of Word.SearchOptions object + */ + static newObject(context: OfficeExtension.ClientRequestContext): Word.SearchOptions; + } + /** + * + * Contains a collection of [range](range.md) objects as a result of a search operation. + */ + class SearchResultCollection extends OfficeExtension.ClientObject { + private m__ReferenceId; + private m__items; + /** Gets the loaded child items in this collection. */ + items: Array; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Word.SearchResultCollection; + } + /** + * + * Represents a section in a Word document. + */ + class Section extends OfficeExtension.ClientObject { + private m_body; + private m__Id; + private m__ReferenceId; + /** + * + * Gets the body of the section. This does not include the header/footer and other section metadata. Read-only. + */ + body: Word.Body; + /** + * + * Gets one of the section's footers. + * + * @param type Required. The type of footer to return. This value can be: 'primary', 'firstPage' or 'evenPages'. + */ + getFooter(type: string): Word.Body; + /** + * + * Gets one of the section's headers. + * + * @param type Required. The type of header to return. This value can be: 'primary', 'firstPage' or 'evenPages'. + */ + getHeader(type: string): Word.Body; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Word.Section; + } + /** + * + * Contains the collection of the document's [section](section.md) objects. + */ + class SectionCollection extends OfficeExtension.ClientObject { + private m__ReferenceId; + private m__items; + /** Gets the loaded child items in this collection. */ + items: Array; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Word.SectionCollection; + } + /** + * + * ContentControl types + */ + module ContentControlType { + var richText: string; + } + /** + * + * ContentControl appearance + */ + module ContentControlAppearance { + var boundingBox: string; + var tags: string; + var hidden: string; + } + /** + * + * Underline types + */ + module UnderlineType { + var none: string; + var single: string; + var word: string; + var double: string; + var dotted: string; + var hidden: string; + var thick: string; + var dashLine: string; + var dotLine: string; + var dotDashLine: string; + var twoDotDashLine: string; + var wave: string; + } + module BreakType { + var page: string; + var column: string; + var next: string; + var sectionContinuous: string; + var sectionEven: string; + var sectionOdd: string; + var line: string; + var lineClearLeft: string; + var lineClearRight: string; + var textWrapping: string; + } + module InsertLocation { + var before: string; + var after: string; + var start: string; + var end: string; + var replace: string; + } + module Alignment { + var unknown: string; + var left: string; + var centered: string; + var right: string; + var justified: string; + } + module HeaderFooterType { + var primary: string; + var firstPage: string; + var evenPages: string; + } + module ErrorCodes { + var accessDenied: string; + var generalException: string; + var invalidArgument: string; + var itemNotFound: string; + var notImplemented: string; + } +} +declare module Word { + /** + * The RequestContext object facilitates requests to the Word application. Since the Office add-in and the Word application run in two different processes, the request context is required to get access to the Word object model from the add-in. + */ + class RequestContext extends OfficeExtension.ClientRequestContext { + private m_document; + constructor(url?: string); + document: Document; + } + /** + * Executes a batch script that performs actions on the Word object model. When the promise is resolved, any tracked objects that were automatically allocated during execution will be released. + * @param batch - A function that takes in a RequestContext and returns a promise (typically, just the result of "context.sync()"). The context parameter facilitates requests to the Word application. Since the Office add-in and the Word application run in two different processes, the request context is required to get access to the Word object model from the add-in. + */ + function run(batch: (context: Word.RequestContext) => OfficeExtension.IPromise): OfficeExtension.IPromise; +} + +declare module Office.MailboxEnums { + export enum BodyType { + /** + * The body is in HTML format + */ + HTML, + /** + * The body is in text format + */ + text + } + export enum EntityType { + /** + * Specifies that the entity is a meeting suggestion + */ + MeetingSuggestion, + /** + * Specifies that the entity is a task suggestion + */ + TaskSuggestion, + /** + * Specifies that the entity is a postal address + */ + Address, + /** + * Specifies that the entity is SMTP email address + */ + EmailAddress, + /** + * Specifies that the entity is an Internet URL + */ + Url, + /** + * Specifies that the entity is US phone number + */ + PhoneNumber, + /** + * Specifies that the entity is a contact + */ + Contact + } + export enum ItemType { + /** + * A meeting request, response, or cancellation + */ + Message, + /** + * Specifies an appointment item + */ + Appointment + } + export enum ResponseType { + /** + * There has been no response from the attendee + */ + None, + /** + * The attendee is the meeting organizer + */ + Organizer, + /** + * The meeting request was tentatively accepted by the attendee + */ + Tentative, + /** + * The meeting request was accepted by the attendee + */ + Accepted, + /** + * The meeting request was declined by the attendee + */ + Declined + } + export enum RecipientType { + /** + * Specifies that the recipient is not one of the other recipient types + */ + Other, + /** + * Specifies that the recipient is a distribution list containing a list of email addresses + */ + DistributionList, + /** + * Specifies that the recipient is an SMTP email address that is on the Exchange server + */ + User, + /** + * Specifies that the recipient is an SMTP email address that is not on the Exchange server + */ + ExternalUser + } + export enum AttachmentType { + /** + * The attachment is a file + */ + File, + /** + * The attachment is an Exchange item + */ + Item + } +} +declare module Office { + export module Types { + export interface ItemRead extends Office.Item { + subject: any; + /** + * Displays a reply form that includes the sender and all the recipients of the selected message + * @param htmlBody A string that contains text and HTML and that represents the body of the reply form. The string is limited to 32 KB + */ + displayReplyAllForm(htmlBody: string): void; + /** + * Displays a reply form that includes only the sender of the selected message + * @param htmlBody A string that contains text and HTML and that represents the body of the reply form. The string is limited to 32 KB + */ + displayReplyForm(htmlBody: string): void; + /** + * Gets an array of entities found in an message + */ + getEntities(): Office.Entities; + /** + * Gets an array of entities of the specified entity type found in an message + * @param entityType One of the EntityType enumeration values + */ + getEntitiesByType(entityType: Office.MailboxEnums.EntityType): Office.Entities; + /** + * Returns well-known entities that pass the named filter defined in the manifest XML file + * @param name A TableData object with the headers and rows + */ + getFilteredEntitiesByName(name: string): Office.Entities; + /** + * Returns string values in the currently selected message object that match the regular expressions defined in the manifest XML file + */ + getRegExMatches(): string[]; + /** + * Returns string values that match the named regular expression defined in the manifest XML file + */ + getRegExMatchesByName(name: string): string[]; + } + export interface ItemCompose extends Office.Item { + body: Office.Body; + subject: any; + /** + * Adds a file to a message as an attachment + * @param uri The URI that provides the location of the file to attach to the message. The maximum length is 2048 characters + * @param attachmentName The name of the attachment that is shown while the attachment is uploading. The maximum length is 255 characters + * @param options Any optional parameters or state data passed to the method + * @param callback The optional callback method + */ + addFileAttachmentAsync(uri: string, attachmentName: string, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Adds an Exchange item, such as a message, as an attachment to the message + * @param itemId The Exchange identifier of the item to attach. The maximum length is 100 characters + * @param attachmentName The name of the attachment that is shown while the attachment is uploading. The maximum length is 255 characters + * @param options Any optional parameters or state data passed to the method + * @param callback The optional callback method + */ + addItemAttachmentAsync(itemId: any, attachmentName: string, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Removes an attachment from a message + * @param attachmentIndex The index of the attachment to remove. The maximum length of the string is 100 characters + * @param options Any optional parameters or state data passed to the method + * @param callback The optional callback method + */ + removeAttachmentAsync(attachmentIndex: string, option?: any, callback?: (result: AsyncResult) => void): void; + } + export interface MessageCompose extends Office.Message { + attachments: Office.AttachmentDetails[]; + body: Office.Body; + bcc: Office.Recipients; + cc: Office.Recipients; + subject: Office.Subject; + to: Office.Recipients; + /** + * Adds a file to a message as an attachment + * @param uri The URI that provides the location of the file to attach to the message. The maximum length is 2048 characters + * @param attachmentName The name of the attachment that is shown while the attachment is uploading. The maximum length is 255 characters + * @param options Any optional parameters or state data passed to the method + * @param callback The optional callback method + */ + addFileAttachmentAsync(uri: string, attachmentName: string, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Adds an Exchange item, such as a message, as an attachment to the message + * @param itemId The Exchange identifier of the item to attach. The maximum length is 100 characters + * @param attachmentName The name of the attachment that is shown while the attachment is uploading. The maximum length is 255 characters + * @param options Any optional parameters or state data passed to the method + * @param callback The optional callback method + */ + addItemAttachmentAsync(itemId: any, attachmentName: string, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Removes an attachment from a message + * @param attachmentIndex The index of the attachment to remove. The maximum length of the string is 100 characters + * @param options Any optional parameters or state data passed to the method + * @param callback The optional callback method + */ + removeAttachmentAsync(attachmentIndex: string, option?: any, callback?: (result: AsyncResult) => void): void; + } + export interface MessageRead extends Office.Message { + cc: Office.EmailAddressDetails[]; + from: Office.EmailAddressDetails; + internetMessageId: string; + normalizedSubject: string; + sender: Office.EmailAddressDetails; + subject: string; + to: Office.EmailAddressDetails; + /** + * Displays a reply form that includes the sender and all the recipients of the selected message + * @param htmlBody A string that contains text and HTML and that represents the body of the reply form. The string is limited to 32 KB + */ + displayReplyAllForm(htmlBody: string): void; + /** + * Displays a reply form that includes only the sender of the selected message + * @param htmlBody A string that contains text and HTML and that represents the body of the reply form. The string is limited to 32 KB + */ + displayReplyForm(htmlBody: string): void; + /** + * Gets an array of entities found in an message + */ + getEntities(): Office.Entities; + /** + * Gets an array of entities of the specified entity type found in an message + * @param entityType One of the EntityType enumeration values + */ + getEntitiesByType(entityType: Office.MailboxEnums.EntityType): Office.Entities; + /** + * Returns well-known entities that pass the named filter defined in the manifest XML file + * @param name A TableData object with the headers and rows + */ + getFilteredEntitiesByName(name: string): Office.Entities; + /** + * Returns string values in the currently selected message object that match the regular expressions defined in the manifest XML file + */ + getRegExMatches(): string[]; + /** + * Returns string values that match the named regular expression defined in the manifest XML file + */ + getRegExMatchesByName(name: string): string[]; + } + export interface AppointmentCompose extends Office.Appointment { + body: Office.Body; + end: Office.Time; + location: Office.Location; + optionalAttendees: Office.Recipients; + requiredAttendees: Office.Recipients; + start: Office.Time; + subject: Office.Subject; + /** + * Adds a file to an appointment as an attachment + * @param uri The URI that provides the location of the file to attach to the appointment. The maximum length is 2048 characters + * @param attachmentName The name of the attachment that is shown while the attachment is uploading. The maximum length is 255 characters + * @param options Any optional parameters or state data passed to the method + * @param callback The optional callback method + */ + addFileAttachmentAsync(uri: string, attachmentName: string, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Adds an Exchange item, such as a message, as an attachment to the appointment + * @param itemId The Exchange identifier of the item to attach. The maximum length is 100 characters + * @param attachmentName The name of the attachment that is shown while the attachment is uploading. The maximum length is 255 characters + * @param options Any optional parameters or state data passed to the method + * @param callback The optional callback method + */ + addItemAttachmentAsync(itemId: any, attachmentName: string, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Removes an attachment from a appointment + * @param attachmentIndex The index of the attachment to remove. The maximum length of the string is 100 characters + * @param options Any optional parameters or state data passed to the method + * @param callback The optional callback method + */ + removeAttachmentAsync(attachmentIndex: string, option?: any, callback?: (result: AsyncResult) => void): void; + } + export interface AppointmentRead extends Office.Appointment { + attachments: Office.AttachmentDetails[]; + end: Date; + location: string; + normalizedSubject: string; + optionalAttendees: Office.EmailAddressDetails; + organizer: Office.EmailAddressDetails; + requiredAttendees: Office.EmailAddressDetails; + resources: string[]; + start: Date; + subject: string; + /** + * Displays a reply form that includes the organizer and all the attendees of the selected appointment item + * @param htmlBody A string that contains text and HTML and that represents the body of the reply form. The string is limited to 32 KB + */ + displayReplyAllForm(htmlBody: string): void; + /** + * Displays a reply form that includes only the organizer of the selected appointment item + * @param htmlBody A string that contains text and HTML and that represents the body of the reply form. The string is limited to 32 KB + */ + displayReplyForm(htmlBody: string): void; + /** + * Gets an array of entities found in an appointment + */ + getEntities(): Office.Entities; + /** + * Gets an array of entities of the specified entity type found in an appointment + * @param entityType One of the EntityType enumeration values + */ + getEntitiesByType(entityType: Office.MailboxEnums.EntityType): Office.Entities; + /** + * Returns well-known entities that pass the named filter defined in the manifest XML file + * @param name A TableData object with the headers and rows + */ + getFilteredEntitiesByName(name: string): Office.Entities; + /** + * Returns string values in the currently selected appointment object that match the regular expressions defined in the manifest XML file + */ + getRegExMatches(): string[]; + /** + * Returns string values that match the named regular expression defined in the manifest XML file + */ + getRegExMatchesByName(name: string): string[]; + } + } + export module cast { + export module item { + function toAppointmentCompose(item: Office.Item): Office.Types.AppointmentCompose; + function toAppointmentRead(item: Office.Item): Office.Types.AppointmentRead; + function toAppointment(item: Office.Item): Office.Appointment; + function toMessageCompose(item: Office.Item): Office.Types.MessageCompose; + function toMessageRead(item: Office.Item): Office.Types.MessageRead; + function toMessage(item: Office.Item): Office.Message; + function toItemCompose(item: Office.Item): Office.Types.ItemCompose; + function toItemRead(item: Office.Item): Office.Types.ItemRead; + } + } + export interface AttachmentDetails { + attachmentType: Office.MailboxEnums.AttachmentType; + contentType: string; + id: string; + isInline: boolean; + name: string; + size: number; + } + export interface Contact { + personName: string; + businessName: string; + phoneNumbers: PhoneNumber[]; + emailAddresses: string[]; + urls: string[]; + addresses: string[]; + contactString: string; + } + + export interface Context { + mailbox: Mailbox; + roamingSettings: RoamingSettings; + } + export interface CustomProperties { + /** + * Returns the value of the specified custom property + * @param name The name of the property to be returned + */ + get(name: string): any; + /** + * Sets the specified property to the specified value + * @param name The name of the property to be set + * @param value The value of the property to be set + */ + set(name: string, value: string): void; + /** + * Removes the specified property from the custom property collection. + * @param name The name of the property to be removed + */ + remove(name: string): void; + /** + * Saves the custom property collection to the server + * @param callback The optional callback method + * @param userContext Optional variable for any state data that is passed to the saveAsync method + */ + saveAsync(callback?: (result: AsyncResult) => void, userContext?: any): void; + } + export interface EmailAddressDetails { + emailAddress: string; + displayName: string; + appointmentResponse: Office.MailboxEnums.ResponseType; + recipientType: Office.MailboxEnums.RecipientType; + } + export interface EmailUser { + name: string; + userId: string; + } + export interface Entities { + addresses: string[]; + taskSuggestions: string[]; + meetingSuggestions: MeetingSuggestion[]; + emailAddresses: string[]; + urls: string[]; + phoneNumbers: PhoneNumber[]; + contacts: Contact[]; + } + export interface Item { + dateTimeCreated: Date; + dateTimeModified: Date; + itemClass: string; + itemId: string; + itemType: Office.MailboxEnums.ItemType; + /** + * Asynchronously loads custom properties that are specific to the item and a app for Office + * @param callback The optional callback method + * @param userContext Optional variable for any state data that is passed to the asynchronous method + */ + loadCustomPropertiesAsync(callback?: (result: AsyncResult) => void, userContext?: any): void; + } + export interface Appointment extends Item { + } + export interface Body { + /** + * Gets a value that indicates whether the content is in HTML or text format + * @param tableData A TableData object with the headers and rows + * @param options Any optional parameters or state data passed to the method + * @param callback The optional method to call when the getTypeAsync method returns + */ + getTypeAsync(options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Adds the specified content to the beginning of the item body + * @param data The string to be inserted at the beginning of the body. The string is limited to 1,000,000 characters + * @param options Any optional parameters or state data passed to the method + * @param callback The optional method to call when the string is inserted + */ + prependAsync(data: string, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Replaces the selection in the body with the specified text + * @param data The string to be inserted at the beginning of the body. The string is limited to 1,000,000 characters + * @param options Any optional parameters or state data passed to the method + * @param callback The optional method to call when the string is inserted + */ + setSelectedDataAsync(data: string, options?: any, callback?: (result: AsyncResult) => void): void; + } + export interface Location { + /** + * Begins an asynchronous request for the location of an appointment + * @param options Any optional parameters or state data passed to the method + * @param callback The optional method to call when the string is inserted + */ + getAsync(options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Begins an asynchronous request to set the location of an appointment + * @param data The location of the appointment. The string is limited to 255 characters + * @param options Any optional parameters or state data passed to the method + * @param callback The optional method to call when the location is set + */ + setAsync(location: string, options?: any, callback?: (result: AsyncResult) => void): void; + } + export interface Mailbox { + item: Item; + userProfile: UserProfile; + /** + * Gets a Date object from a dictionary containing time information + * @param timeValue A Date object + */ + convertToLocalClientTime(timeValue: Date): any; + /** + * Gets a dictionary containing time information in local client time + * @param input A dictionary containing a date. The dictionary should contain the following fields: year, month, date, hours, minutes, seconds, time zone, time zone offset + */ + convertToUtcClientTime(input: any): Date; + /** + * Displays an existing calendar appointment + * @param itemId The Exchange Web Services (EWS) identifier for an existing calendar appointment + */ + displayAppointmentForm(itemId: any): void; + /** + * Displays an existing message + * @param itemId The Exchange Web Services (EWS) identifier for an existing message + */ + displayMessageForm(itemId: any): void; + /** + * Displays a form for creating a new calendar appointment + * @param requiredAttendees An array of strings containing the email addresses or an array containing an EmailAddressDetails object for each of the required attendees for the appointment. The array is limited to a maximum of 100 entries + * @param optionalAttendees An array of strings containing the email addresses or an array containing an EmailAddressDetails object for each of the optional attendees for the appointment. The array is limited to a maximum of 100 entries + * @param start A Date object specifying the start date and time of the appointment + * @param end A Date object specifying the end date and time of the appointment + * @param location A string containing the location of the appointment. The string is limited to a maximum of 255 characters + * @param resources An array of strings containing the resources required for the appointment. The array is limited to a maximum of 100 entries + * @param subject A string containing the subject of the appointment. The string is limited to a maximum of 255 characters + * @param body The body of the appointment message. The body content is limited to a maximum size of 32 KB + */ + displayNewAppointmentForm(requiredAttendees: any, optionalAttendees: any, start: Date, end: Date, location: string, resources: string[], subject: string, body: string): void; + /** + * Gets a string that contains a token used to get an attachment or item from an Exchange Server + * @param callback The optional method to call when the string is inserted + * @param userContext Optional variable for any state data that is passed to the asynchronous method + */ + getCallbackTokenAsync(callback?: (result: AsyncResult) => void, userContext?: any): void; + /** + * Gets a token identifying the user and the app for Office + * @param callback The optional method to call when the string is inserted + * @param userContext Optional variable for any state data that is passed to the asynchronous method + */ + getUserIdentityTokenAsync(callback?: (result: AsyncResult) => void, userContext?: any): void; + /** + * Makes an asynchronous request to an Exchange Web Services (EWS) service on the Exchange server that hosts the user’s mailbox + * @param data The EWS request + * @param callback The optional method to call when the string is inserted + * @param userContext Optional variable for any state data that is passed to the asynchronous method + */ + makeEwsRequestAsync(data: any, callback?: (result: AsyncResult) => void, userContext?: any): void; + } + export interface Message extends Item { + conversationId: string; + } + export interface MeetingRequest extends Message { + start: Date; + end: Date; + location: string; + optionalAttendees: EmailAddressDetails[]; + requiredAttendees: EmailAddressDetails[]; + } + export interface MeetingSuggestion { + meetingString: string; + attendees: EmailAddressDetails[]; + location: string; + subject: string; + start: Date; + end: Date; + } + export interface PhoneNumber { + phoneString: string; + originalPhoneString: string; + type: string; + } + export interface Recipients { + /** + * Begins an asynchronous request to add a recipient list to an appointment or message + * @param recipients The recipients to add to the recipients list + * @param options Any optional parameters or state data passed to the method + * @param callback The optional method to call when the string is inserted + */ + addAsync(recipients: any, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Begins an asynchronous request to get the recipient list for an appointment or message + * @param options Any optional parameters or state data passed to the method + * @param callback The optional method to call when the string is inserted + */ + getAsync(options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Begins an asynchronous request to set the recipient list for an appointment or message + * @param recipients The recipients to add to the recipients list + * @param options Any optional parameters or state data passed to the method + * @param callback The optional method to call when the string is inserted + */ + setAsync(recipients: any, options?: any, callback?: (result: AsyncResult) => void): void; + } + export interface RoamingSettings { + /** + * Retrieves the specified setting + * @param name The case-sensitive name of the setting to retrieve + */ + get(name: string): any; + /** + * Removes the specified setting + * @param name The case-sensitive name of the setting to remove + */ + remove(name: string): void; + /** + * Saves the settings + * @param callback A function that is invoked when the callback returns, whose only parameter is of type AsyncResult + */ + saveAsync(callback?: (result: AsyncResult) => void): void; + /** + * Sets or creates the specified setting + * @param name The case-sensitive name of the setting to set or create + * @param value Specifies the value to be stored + */ + set(name: string, value: any): void; + } + export interface Subject { + /** + * Begins an asynchronous request to get the subject of an appointment or message + * @param options Any optional parameters or state data passed to the method + * @param callback The optional method to call when the string is inserted + */ + getAsync(options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Begins an asynchronous call to set the subject of an appointment or message + * @param data The subject of the appointment. The string is limited to 255 characters + * @param options Any optional parameters or state data passed to the method + * @param callback The optional method to call when the string is inserted + */ + setAsync(data: string, options?: any, callback?: (result: AsyncResult) => void): void; + } + export interface TaskSuggestion { + assignees: EmailUser[]; + taskString: string; + } + export interface Time { + /** + * Begins an asynchronous request to get the start or end time + * @param options Any optional parameters or state data passed to the method + * @param callback The optional method to call when the string is inserted + */ + getAsync(options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Begins an asynchronous request to set the start or end time + * @param dateTime A date-time object in Coordinated Universal Time (UTC) + * @param options Any optional parameters or state data passed to the method + * @param callback The optional method to call when the string is inserted + */ + setAsync(dateTime: Date, options?: any, callback?: (result: AsyncResult) => void): void; + } + export interface UserProfile { + displayName: string; + emailAddress: string; + timeZone: string; + } +} From 372689cd4334e5e1ad2779ca3ade9b1e2cfd757a Mon Sep 17 00:00:00 2001 From: laco0416 Date: Fri, 16 Oct 2015 00:55:16 +0900 Subject: [PATCH 0092/1238] Update polymer.d.ts: fix es6 class syntax --- polymer/polymer-tests.ts | 4 ++-- polymer/polymer.d.ts | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/polymer/polymer-tests.ts b/polymer/polymer-tests.ts index 311fda9676..8a44ed285a 100644 --- a/polymer/polymer-tests.ts +++ b/polymer/polymer-tests.ts @@ -63,7 +63,7 @@ var el2 = document.createElement('my-element'); class MyElement2 { is: string; - registered() { + beforeRegister() { this.is = "my-element2"; } } @@ -74,7 +74,7 @@ Polymer(MyElement2); class MyElement3 implements polymer.Base { is: string; - registered() { + beforeRegister() { this.is = "my-element3"; } } diff --git a/polymer/polymer.d.ts b/polymer/polymer.d.ts index b764aeb2a8..9117301afd 100644 --- a/polymer/polymer.d.ts +++ b/polymer/polymer.d.ts @@ -201,6 +201,8 @@ declare module polymer { observers?: string[]; + beforeRegister?(): void; + registered?(): void; created?(): void; From 45fc24faad7d693ea87d914ae2c3d162c93c51e7 Mon Sep 17 00:00:00 2001 From: Dmytro Nemoga Date: Thu, 15 Oct 2015 19:00:14 +0300 Subject: [PATCH 0093/1238] Update `IActionDescriptor` accordingly to official documentation --- angularjs/angular-resource-tests.ts | 23 ++++++++++++++++++----- angularjs/angular-resource.d.ts | 11 +++++++++-- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/angularjs/angular-resource-tests.ts b/angularjs/angular-resource-tests.ts index f7f248ea8a..cfa7712cc2 100644 --- a/angularjs/angular-resource-tests.ts +++ b/angularjs/angular-resource-tests.ts @@ -8,11 +8,24 @@ interface IMyResourceClass extends angular.resource.IResourceClass /////////////////////////////////////// var actionDescriptor: angular.resource.IActionDescriptor; -actionDescriptor.url = '/api/test-url/' -actionDescriptor.headers = { header: 'value' }; -actionDescriptor.isArray = true; -actionDescriptor.method = 'method action'; -actionDescriptor.params = { key: 'value' }; +angular.injector(['ng']).invoke(function ($cacheFactory: angular.ICacheFactoryService, $timeout: angular.ITimeoutService) { + actionDescriptor.method = 'method action'; + actionDescriptor.params = { key: 'value' }; + actionDescriptor.url = '/api/test-url/'; + actionDescriptor.isArray = true; + actionDescriptor.transformRequest = function () { }; + actionDescriptor.transformRequest = [function () { }]; + actionDescriptor.transformResponse = function () { }; + actionDescriptor.transformResponse = [function () { }]; + actionDescriptor.headers = { header: 'value' }; + actionDescriptor.cache = true; + actionDescriptor.cache = $cacheFactory('cacheId'); + actionDescriptor.timeout = 1000; + actionDescriptor.timeout = $timeout(function () { }); + actionDescriptor.withCredentials = true; + actionDescriptor.responseType = 'response type'; + actionDescriptor.interceptor = { key: 'value' }; +}); /////////////////////////////////////// diff --git a/angularjs/angular-resource.d.ts b/angularjs/angular-resource.d.ts index 4688a9c6f5..5c86370595 100644 --- a/angularjs/angular-resource.d.ts +++ b/angularjs/angular-resource.d.ts @@ -46,11 +46,18 @@ declare module angular.resource { // Just a reference to facilitate describing new actions interface IActionDescriptor { - url?: string; method: string; - isArray?: boolean; params?: any; + url?: string; + isArray?: boolean; + transformRequest?: angular.IHttpResquestTransformer | angular.IHttpResquestTransformer[]; + transformResponse?: angular.IHttpResponseTransformer | angular.IHttpResponseTransformer[]; headers?: any; + cache?: boolean | angular.ICacheObject; + timeout?: number | angular.IPromise; + withCredentials?: boolean; + responseType?: string; + interceptor?: any; } // Baseclass for everyresource with default actions. From 93662fbe0a3392b19c0f297605e5295643e895f1 Mon Sep 17 00:00:00 2001 From: Blake Doss Date: Thu, 15 Oct 2015 13:49:47 -0400 Subject: [PATCH 0094/1238] Added additional template methods. --- typeahead/typeahead.d.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/typeahead/typeahead.d.ts b/typeahead/typeahead.d.ts index a8b139937c..49538fbd9a 100644 --- a/typeahead/typeahead.d.ts +++ b/typeahead/typeahead.d.ts @@ -152,6 +152,20 @@ declare module Twitter.Typeahead { * If it's a precompiled template, the passed in context will contain query and isEmpty. */ header?: any; + + /** + * Rendered when 0 suggestions are available for the given query. + * Can be either a HTML string or a precompiled template. + * If it's a precompiled template, the passed in context will contain query. + */ + notFound?: (query: string) => string; + + /** + * Rendered when 0 synchronous suggestions are available but asynchronous suggestions are expected. + * Can be either a HTML string or a precompiled template. + * If it's a precompiled template, the passed in context will contain query. + */ + pending?: (query: string) => string; /** * Used to render a single suggestion. From ff9d48a65907c052541cf17fe582c8eab84e42e4 Mon Sep 17 00:00:00 2001 From: John Vilk Date: Thu, 15 Oct 2015 16:03:27 -0400 Subject: [PATCH 0095/1238] Adding definition of mocha.throwError, with test to cover it. See implementation in Mocha's source code here: https://github.com/mochajs/mocha/blob/c4393c456839d6bf2cbb4abb1cd177010ee06458/support/browser-entry.js#L98 --- mocha/mocha-tests.ts | 4 ++++ mocha/mocha.d.ts | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/mocha/mocha-tests.ts b/mocha/mocha-tests.ts index f90fefaf96..c50f5feab3 100644 --- a/mocha/mocha-tests.ts +++ b/mocha/mocha-tests.ts @@ -249,3 +249,7 @@ function test_run_withOnComplete() { console.log(failures); }); } + +function test_throwError() { + mocha.throwError(new Error("I'm an error!")); +} diff --git a/mocha/mocha.d.ts b/mocha/mocha.d.ts index 88dc359fcc..b4f182aabd 100644 --- a/mocha/mocha.d.ts +++ b/mocha/mocha.d.ts @@ -100,6 +100,12 @@ declare class Mocha { invert(): Mocha; ignoreLeaks(value: boolean): Mocha; checkLeaks(): Mocha; + /** + * Function to allow assertion libraries to throw errors directly into mocha. + * This is useful when running tests in a browser because window.onerror will + * only receive the 'message' attribute of the Error. + */ + throwError(error: Error): void; /** Enables growl support. */ growl(): Mocha; globals(value: string): Mocha; From 741c1c4b53914d4cac5e6bef3beb68b202eada46 Mon Sep 17 00:00:00 2001 From: Andrew Fong Date: Thu, 15 Oct 2015 23:14:04 +0000 Subject: [PATCH 0096/1238] Flush for analytics-node --- analytics-node/analytics-node-tests.ts | 9 +++++++++ analytics-node/analytics-node.d.ts | 10 ++++++++++ 2 files changed, 19 insertions(+) diff --git a/analytics-node/analytics-node-tests.ts b/analytics-node/analytics-node-tests.ts index 66a4b4995e..57c48252ff 100644 --- a/analytics-node/analytics-node-tests.ts +++ b/analytics-node/analytics-node-tests.ts @@ -80,3 +80,12 @@ function testIntegrations(): void { } }); } + +function testFlush(): void { + analytics.flush(); + analytics.flush(function(err, batch) { + if (err) { alert("Oh nos!"); } + else { console.log(batch.batch[0].type); } + }); +} + diff --git a/analytics-node/analytics-node.d.ts b/analytics-node/analytics-node.d.ts index 981e754e59..d4376d83ea 100644 --- a/analytics-node/analytics-node.d.ts +++ b/analytics-node/analytics-node.d.ts @@ -65,6 +65,16 @@ declare module AnalyticsNode { anonymous_id?: string | number; integrations?: Integrations; }): Analytics; + + /* Flush batched calls to make sure nothing is left in the queue */ + flush(fn?: (err: Error, batch: { + batch: Array<{ + type: string; + }>; + messageId: string; + sentAt: Date; + timestamp: Date; + }) => void): Analytics; } } From b2e6fc12fcc9f9f8793c0d6da01441d4d46b17d2 Mon Sep 17 00:00:00 2001 From: Rob Howard Date: Thu, 15 Oct 2015 16:30:42 -0700 Subject: [PATCH 0097/1238] Moving header above license Travis failed due to headers appearing below license information. Moved it up. --- office-js/office-js.d.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/office-js/office-js.d.ts b/office-js/office-js.d.ts index cb146fae1f..a89525adb5 100644 --- a/office-js/office-js.d.ts +++ b/office-js/office-js.d.ts @@ -1,3 +1,8 @@ +// Type definitions for Office.js +// Project: http://dev.office.com +// Definitions by: OfficeDev +// Definitions: https://github.com/borisyankov/DefinitelyTyped + /* ------------------------------------------ START OF LICENSE ----------------------------------------- office-js @@ -8,12 +13,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI ----------------------------------------------- END OF LICENSE ------------------------------------------ */ -// Type definitions for Office.js -// Project: http://dev.office.com -// Definitions by: OfficeDev -// Definitions: https://github.com/borisyankov/DefinitelyTyped - - declare module Office { export var context: Context; /** From d4f3ed0cc7f7aba3b47dc6dbc68ead8a97052fe4 Mon Sep 17 00:00:00 2001 From: Yuki Kodama Date: Fri, 16 Oct 2015 02:43:41 +0000 Subject: [PATCH 0098/1238] Fix param name --- redux/redux.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redux/redux.d.ts b/redux/redux.d.ts index 1bcbedc63b..669ab6b99a 100644 --- a/redux/redux.d.ts +++ b/redux/redux.d.ts @@ -43,7 +43,7 @@ declare module Redux { function createStore(reducer: Reducer, initialState?: any): Store; function bindActionCreators(actionCreators: T, dispatch: Dispatch): T; function combineReducers(reducers: any): Reducer; - function applyMiddleware(...middleware: Middleware[]): Function; + function applyMiddleware(...middlewares: Middleware[]): Function; function compose(...functions: Function[]): T; } From cbe4869fdacd9d3adc9b6652bfc50ac500f181fa Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Fri, 16 Oct 2015 09:43:59 +0500 Subject: [PATCH 0099/1238] lodash: signatures of a method _.isEqual (and of an alias _.eq) have been changed --- lodash/lodash-tests.ts | 53 ++++++++------- lodash/lodash.d.ts | 147 +++++++++++++++++++---------------------- 2 files changed, 95 insertions(+), 105 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index adf86e9a61..b4678f1533 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -2271,6 +2271,20 @@ var testCloneDeepCustomizerFn: TestCloneDeepCustomizerFn; result = _({a: {b: 2}}).cloneDeep(testCloneDeepCustomizerFn, any); } +// _.eq +module TestEq { + let customizer: (value: any, other: any, indexOrKey?: number|string) => boolean; + let result: boolean; + + result = _.eq(any, any); + result = _.eq(any, any, customizer); + result = _.eq(any, any, customizer, any); + + result = _(any).eq(any); + result = _(any).eq(any, customizer); + result = _(any).eq(any, customizer, any) +} + // _.gt result = _.gt(1, 2); result = _(1).gt(2); @@ -2321,6 +2335,20 @@ result = _([1, 2, 3]).isEmpty(); result = _({}).isEmpty(); result = _('').isEmpty(); +// _.isEqual +module TestIsEqual { + let customizer: (value: any, other: any, indexOrKey?: number|string) => boolean; + let result: boolean; + + result = _.isEqual(any, any); + result = _.isEqual(any, any, customizer); + result = _.isEqual(any, any, customizer, any); + + result = _(any).isEqual(any); + result = _(any).isEqual(any, customizer); + result = _(any).isEqual(any, customizer, any) +} + // _.isError result = _.isError(any); result = _(1).isError(); @@ -2758,31 +2786,6 @@ result = _({}).has(['', 42, true]); result = _({}).invert(true).value(); } -// _.isEqual (alias: _.eq) -result = _.isEqual(1, 1); -result = _(1).isEqual(1); -result = _.eq(1, 1); -result = _(1).eq(1); - -var testEqObject = { 'user': 'fred' }; -var testEqOtherObject = { 'user': 'fred' }; -result = _.isEqual(testEqObject, testEqOtherObject); -result = _(testEqObject).isEqual(testEqOtherObject); -result = _.eq(testEqObject, testEqOtherObject); -result = _(testEqObject).eq(testEqOtherObject); - -var testEqArray = ['hello', 'goodbye']; -var testEqOtherArray = ['hi', 'goodbye']; -var testEqCustomizerFn = (value: any, other: any): boolean => { - if (_.every([value, other], RegExp.prototype.test, /^h(?:i|ello)$/)) { - return true; - } -}; -result = _.isEqual(testEqArray, testEqOtherArray, testEqCustomizerFn); -result = _(testEqArray).isEqual(testEqOtherArray, testEqCustomizerFn); -result = _.eq(testEqArray, testEqOtherArray, testEqCustomizerFn); -result = _(testEqArray).eq(testEqOtherArray, testEqCustomizerFn); - class Stooge { constructor( public name: string, diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index d5463ffc00..a574e10c3e 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -6636,6 +6636,30 @@ declare module _ { thisArg?: any): T; } + //_.eq + interface LoDashStatic { + /** + * @see _.isEqual + */ + eq( + value: any, + other: any, + customizer?: IsEqualCustomizer, + thisArg?: any + ): boolean; + } + + interface LoDashWrapperBase { + /** + * @see _.isEqual + */ + eq( + other: any, + customizer?: IsEqualCustomizer, + thisArg?: any + ): boolean; + } + //_.gt interface LoDashStatic { /** @@ -6775,6 +6799,49 @@ declare module _ { isEmpty(): boolean; } + //_.isEqual + interface IsEqualCustomizer { + (value: any, other: any, indexOrKey?: number|string): boolean; + } + + interface LoDashStatic { + /** + * Performs a deep comparison between two values to determine if they are equivalent. If customizer is + * provided it’s invoked to compare values. If customizer returns undefined comparisons are handled by the + * method instead. The customizer is bound to thisArg and invoked with up to three arguments: (value, other + * [, index|key]). + * + * 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. Functions and DOM + * nodes are not supported. Provide a customizer function to extend support for comparing other values. + * + * @alias _.eq + * + * @param value The value to compare. + * @param other The other value to compare. + * @param customizer The function to customize value comparisons. + * @param thisArg The this binding of customizer. + * @return Returns true if the values are equivalent, else false. + */ + isEqual( + value: any, + other: any, + customizer?: IsEqualCustomizer, + thisArg?: any + ): boolean; + } + + interface LoDashWrapperBase { + /** + * @see _.isEqual + */ + isEqual( + other: any, + customizer?: IsEqualCustomizer, + thisArg?: any + ): boolean; + } + //_.isError interface LoDashStatic { /** @@ -7998,86 +8065,6 @@ declare module _ { invert(multiValue?: boolean): LoDashObjectWrapper; } - //_.isEqual - interface EqCustomizer { - (value: any, other: any, indexOrKey?: number|string): boolean; - } - - interface LoDashStatic { - /** - * Performs a deep comparison between two values to determine if they are equivalent. If customizer is - * provided it is invoked to compare values. If customizer returns undefined comparisons are handled - * by the method instead. The customizer is bound to thisArg and invoked with three - * arguments: (value, other [, index|key]). - * @param value The value to compare. - * @param other The other value to compare. - * @param callback The function to customize value comparisons. - * @param thisArg The this binding of customizer. - * @return True if the values are equivalent, else false. - */ - isEqual(value?: any, - other?: any, - callback?: EqCustomizer, - thisArg?: any): boolean; - - /** - * @see _.isEqual - */ - eq(value?: any, - other?: any, - callback?: EqCustomizer, - thisArg?: any): boolean; - } - - interface LoDashWrapper { - /** - * @see _.isEqual - */ - isEqual(other?: any, - callback?: EqCustomizer, - thisArg?: any): boolean; - - /** - * @see _.isEqual - */ - eq(other?: any, - callback?: EqCustomizer, - thisArg?: any): boolean; - - } - - interface LoDashArrayWrapper { - /** - * @see _.isEqual - */ - isEqual(other?: any, - callback?: EqCustomizer, - thisArg?: any): boolean; - - /** - * @see _.isEqual - */ - eq(other?: any, - callback?: EqCustomizer, - thisArg?: any): boolean; - } - - interface LoDashObjectWrapper { - /** - * @see _.isEqual - */ - isEqual(other?: any, - callback?: EqCustomizer, - thisArg?: any): boolean; - - /** - * @see _.isEqual - */ - eq(other?: any, - callback?: EqCustomizer, - thisArg?: any): boolean; - } - //_.keys interface LoDashStatic { /** From 5e3a73a24bcb05b96491692bc522f9bff7cc0e6c Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Fri, 16 Oct 2015 10:03:05 +0500 Subject: [PATCH 0100/1238] lodash: signatures of the method _.findLastKey have been changed --- lodash/lodash-tests.ts | 43 ++++++++++++++++-- lodash/lodash.d.ts | 98 ++++++++++++++++++++++++++++++++---------- 2 files changed, 116 insertions(+), 25 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index adf86e9a61..ba0f5e1309 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -2676,9 +2676,46 @@ module TestFindKey { } } -result = _.findLastKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function (num) { - return num % 2 == 1; -}); +// _.findLastKey +module TestFindLastKey { + let result: string; + + { + let predicateFn: (value: any, key?: string, object?: {}) => boolean; + + result = _.findLastKey<{a: string;}>({a: ''}); + + result = _.findLastKey<{a: string;}>({a: ''}, predicateFn); + result = _.findLastKey<{a: string;}>({a: ''}, predicateFn, any); + + + result = _.findLastKey<{a: string;}>({a: ''}, ''); + result = _.findLastKey<{a: string;}>({a: ''}, '', any); + + result = _.findLastKey<{a: number;}, {a: string;}>({a: ''}, {a: 42}); + + result = _<{a: string;}>({a: ''}).findLastKey(); + + result = _<{a: string;}>({a: ''}).findLastKey(predicateFn); + result = _<{a: string;}>({a: ''}).findLastKey(predicateFn, any); + + + result = _<{a: string;}>({a: ''}).findLastKey(''); + result = _<{a: string;}>({a: ''}).findLastKey('', any); + + result = _<{a: string;}>({a: ''}).findLastKey<{a: number;}>({a: 42}); + } + + { + let predicateFn: (value: string, key?: string, collection?: _.Dictionary) => boolean; + + result = _.findLastKey({a: ''}, predicateFn); + result = _.findLastKey({a: ''}, predicateFn, any); + + result = _<{a: string;}>({a: ''}).findLastKey(predicateFn); + result = _<{a: string;}>({a: ''}).findLastKey(predicateFn, any); + } +} result = _.forIn(new Dog('Dagny'), function (value, key) { console.log(key); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index d5463ffc00..9ff00c49f6 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -7745,32 +7745,86 @@ declare module _ { //_.findLastKey interface LoDashStatic { /** - * This method is like _.findKey except that it iterates over elements of a collection in the opposite order. - * @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. - **/ - findLastKey( - object: any, - callback: (value: any) => boolean, - thisArg?: any): string; + * This method is like _.findKey except that it iterates over elements of a collection in the opposite order. + * + * 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. + */ + findLastKey( + object: TObject, + predicate?: DictionaryIterator, + thisArg?: any + ): string; /** - * @see _.findLastKey - * @param pluckValue _.pluck style callback - **/ - findLastKey( - object: any, - pluckValue: string): string; + * @see _.findLastKey + */ + findLastKey( + object: TObject, + predicate?: ObjectIterator, + thisArg?: any + ): string; /** - * @see _.findLastKey - * @param whereValue _.where style callback - **/ - findLastKey, T>( - object: T, - whereValue: W): string; + * @see _.findLastKey + */ + findLastKey( + object: TObject, + predicate?: string, + thisArg?: any + ): string; + + /** + * @see _.findLastKey + */ + findLastKey, TObject>( + object: TObject, + predicate?: TWhere + ): string; + } + + interface LoDashObjectWrapper { + /** + * @see _.findLastKey + */ + findLastKey( + predicate?: DictionaryIterator, + thisArg?: any + ): string; + + /** + * @see _.findLastKey + */ + findLastKey( + predicate?: ObjectIterator, + thisArg?: any + ): string; + + /** + * @see _.findLastKey + */ + findLastKey( + predicate?: string, + thisArg?: any + ): string; + + /** + * @see _.findLastKey + */ + findLastKey>( + predicate?: TWhere + ): string; } //_.forIn From 1d2b45ff7326c96d2c956449619799d375bf4c21 Mon Sep 17 00:00:00 2001 From: Basarat Ali Syed Date: Fri, 16 Oct 2015 16:15:04 +1100 Subject: [PATCH 0101/1238] licence -> license for consistency :rose: --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5cc7045d76..82833752d7 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ Please see the [contribution guide](http://definitelytyped.org/guides/contributi Here is are the [currently requested definitions](https://github.com/borisyankov/DefinitelyTyped/labels/Definition%3ARequest). -## Licence +## License This project is licensed under the MIT license. From 720460e0e66dcfc95110dd2f28dfd88c192fce1f Mon Sep 17 00:00:00 2001 From: Mark Bouwman Date: Fri, 16 Oct 2015 11:51:23 +0200 Subject: [PATCH 0102/1238] transitionTo() and reload() should return promises http://angular-ui.github.io/ui-router/site/#/api/ui.router.state.$state --- angular-ui-router/angular-ui-router.d.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/angular-ui-router/angular-ui-router.d.ts b/angular-ui-router/angular-ui-router.d.ts index 3ec31968cd..2162b02200 100644 --- a/angular-ui-router/angular-ui-router.d.ts +++ b/angular-ui-router/angular-ui-router.d.ts @@ -229,10 +229,10 @@ declare module angular.ui { */ go(to: string, params?: {}, options?: IStateOptions): angular.IPromise; go(to: IState, params?: {}, options?: IStateOptions): angular.IPromise; - transitionTo(state: string, params?: {}, updateLocation?: boolean): void; - transitionTo(state: IState, params?: {}, updateLocation?: boolean): void; - transitionTo(state: string, params?: {}, options?: IStateOptions): void; - transitionTo(state: IState, params?: {}, options?: IStateOptions): void; + transitionTo(state: string, params?: {}, updateLocation?: boolean): ng.IPromise; + transitionTo(state: IState, params?: {}, updateLocation?: boolean): ng.IPromise; + transitionTo(state: string, params?: {}, options?: IStateOptions): ng.IPromise; + transitionTo(state: IState, params?: {}, options?: IStateOptions): ng.IPromise; includes(state: string, params?: {}): boolean; is(state:string, params?: {}): boolean; is(state: IState, params?: {}): boolean; @@ -244,7 +244,7 @@ declare module angular.ui { current: IState; /** A param object, e.g. {sectionId: section.id)}, that you'd like to test against the current active state. */ params: IStateParamsService; - reload(): void; + reload(): ng.IPromise; /** Currently pending transition. A promise that'll resolve or reject. */ transition: ng.IPromise<{}>; From 4442fe3853c09c39dbb94fa11a1443c0284971c9 Mon Sep 17 00:00:00 2001 From: Vincent de Lagabbe Date: Fri, 16 Oct 2015 13:29:48 +0200 Subject: [PATCH 0103/1238] Fix async.forEachFor signature "key" should not be an array --- async/async.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/async/async.d.ts b/async/async.d.ts index 6054e9a478..966d5abaa8 100644 --- a/async/async.d.ts +++ b/async/async.d.ts @@ -76,9 +76,9 @@ interface Async { each(arr: T[], iterator: AsyncIterator, callback?: ErrorCallback): void; eachSeries(arr: T[], iterator: AsyncIterator, callback?: ErrorCallback): void; eachLimit(arr: T[], limit: number, iterator: AsyncIterator, callback?: ErrorCallback): void; - forEachOf(obj: any, iterator: (item: any, key: [string|number], callback?: ErrorCallback) => void, callback: ErrorCallback): void; + forEachOf(obj: any, iterator: (item: any, key: string|number, callback?: ErrorCallback) => void, callback: ErrorCallback): void; forEachOf(obj: T[], iterator: AsyncForEachOfIterator, callback?: ErrorCallback): void; - forEachOfSeries(obj: any, iterator: (item: any, key: [string|number], callback?: ErrorCallback) => void, callback: ErrorCallback): void; + forEachOfSeries(obj: any, iterator: (item: any, key: string|number, callback?: ErrorCallback) => void, callback: ErrorCallback): void; forEachOfSeries(obj: T[], iterator: AsyncForEachOfIterator, callback?: ErrorCallback): void; forEachOfLimit(obj: any, limit: number, iterator: (item: any, key: [string|number], callback?: ErrorCallback) => void, callback: ErrorCallback): void; forEachOfLimit(obj: T[], limit: number, iterator: AsyncForEachOfIterator, callback?: ErrorCallback): void; From 91e1c3f3fcdae9d1b0c32a0b0f95e13b32f21d51 Mon Sep 17 00:00:00 2001 From: vvakame Date: Fri, 16 Oct 2015 22:03:39 +0900 Subject: [PATCH 0104/1238] remove unused reference at hammerjs/hammerjs.d.ts --- hammerjs/hammerjs.d.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/hammerjs/hammerjs.d.ts b/hammerjs/hammerjs.d.ts index 5ea8165b00..0df86dfc67 100644 --- a/hammerjs/hammerjs.d.ts +++ b/hammerjs/hammerjs.d.ts @@ -3,8 +3,6 @@ // Definitions by: Philip Bulley , Han Lin Yap // Definitions: https://github.com/borisyankov/DefinitelyTyped -/// - declare var Hammer:HammerStatic; declare module "hammerjs" { From eee4f2b199639b598f87535e62deb39c9baabdc2 Mon Sep 17 00:00:00 2001 From: Artur Wasilewski Date: Fri, 16 Oct 2015 15:06:18 +0200 Subject: [PATCH 0105/1238] Fixed syntax in .d.ts file --- ui-grid/ui-grid.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui-grid/ui-grid.d.ts b/ui-grid/ui-grid.d.ts index 8b67f649bf..ef013fdf18 100644 --- a/ui-grid/ui-grid.d.ts +++ b/ui-grid/ui-grid.d.ts @@ -734,13 +734,13 @@ declare module uiGrid { * to load when scrolling up * @default false */ - infiniteScrollUp?: boolean, + infiniteScrollUp?: boolean; /** * Inform the grid of whether there are rows * to load scrolling down * @default true */ - infiniteScrollDown?: boolean, + infiniteScrollDown?: boolean; /** * Defaults to 200 * @default 200 From ee35457a50c7d47aa540597d7fdf850b57f79420 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Castre?= Date: Fri, 16 Oct 2015 15:55:22 +0200 Subject: [PATCH 0106/1238] Improve durandal.d.ts if you use Q instead of jQuery MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Durandal supports injection/configuration to use a different library for Deferred/Promises (ref http://durandaljs.com/documentation/Q.html) When using a different Deferred/Promise implementation, you might want to use a different Promise interface in the durandal.d.ts file. Added some type annotations to ensure that durandal.d.ts won’t make compilation fail when the compiling with the noImplicitAny option set to true. Note that I'm not the author of these changes but was asked to review it, and then publish it for the benefits of the community. --- durandal/durandal.d.ts | 132 ++++++++++++++++++++++------------------- 1 file changed, 72 insertions(+), 60 deletions(-) diff --git a/durandal/durandal.d.ts b/durandal/durandal.d.ts index 86f988cbe7..612e85c646 100644 --- a/durandal/durandal.d.ts +++ b/durandal/durandal.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Durandal 2.1.0 +// Type definitions for Durandal 2.1.0 // Project: http://durandaljs.com // Definitions by: Blue Spire // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -12,6 +12,18 @@ /// /// +// By default, Durandal uses JQuery's Defer/Promise implementation, but durandal supports injecting/configuring +// usage of different JavaScript Defer/Promise libraries (f.ex. Q or ES6 Promise polyfills). +// You might therefore want to use a different interface from a community typings file or your custom unified interface. +// When using f.ex. Q as Defer/Promise library replace the lines below with: + +// +// interface DurandalPromise extends Q.Promise +// interface DurandalDeferred extends Q.Deferred + +interface DurandalPromise extends JQueryPromise { } +interface DurandalDeferred extends JQueryDeferred { } + /** * The system module encapsulates the most basic features used by other modules. * @requires require @@ -45,7 +57,7 @@ interface DurandalSystemModule { * @param {object} obj The object whose module id you wish to set. * @param {string} id The id to set for the specified object. */ - setModuleId(obj, id: string): void; + setModuleId(obj: any, id: string): void; /** * Resolves the default object instance for a module. If the module is an object, the module is returned. If the module is a function, that function is called with `new` and it's result is returned. @@ -89,9 +101,9 @@ interface DurandalSystemModule { /** * Creates a deferred object which can be used to create a promise. Optionally pass a function action to perform which will be passed an object used in resolving the promise. * @param {function} [action] The action to defer. You will be passed the deferred object as a paramter. - * @returns {JQueryDeferred} The deferred object. + * @returns {Deferred} The deferred object. */ - defer(action?: (dfd: JQueryDeferred) => void): JQueryDeferred; + defer(action?: (dfd: DurandalDeferred) => void): DurandalDeferred; /** * Creates a simple V4 UUID. This should not be used as a PK in your database. It can be used to generate internal, unique ids. For a more robust solution see [node-uuid](https://github.com/broofa/node-uuid). @@ -102,23 +114,23 @@ interface DurandalSystemModule { /** * Uses require.js to obtain a module. This function returns a promise which resolves with the module instance. * @param {string} moduleId The id of the module to load. - * @returns {JQueryPromise} A promise for the loaded module. + * @returns {Promise} A promise for the loaded module. */ - acquire(moduleId: string): JQueryPromise; + acquire(moduleId: string): DurandalPromise; /** * Uses require.js to obtain an array of modules. This function returns a promise which resolves with the modules instances in an array. * @param {string[]} moduleIds The ids of the modules to load. - * @returns {JQueryPromise} A promise for the loaded module. + * @returns {Promise} A promise for the loaded module. */ - acquire(modules: string[]): JQueryPromise; + acquire(modules: string[]): DurandalPromise; /** * Uses require.js to obtain multiple modules. This function returns a promise which resolves with the module instances in an array. * @param {string} moduleIds* The ids of the modules to load. - * @returns {JQueryPromise} A promise for the loaded module. + * @returns {Promise} A promise for the loaded module. */ - acquire(...moduleIds: string[]): JQueryPromise; + acquire(...moduleIds: string[]): DurandalPromise; /** * Extends the first object with the properties of the following objects. @@ -130,9 +142,9 @@ interface DurandalSystemModule { /** * Uses a setTimeout to wait the specified milliseconds. * @param {number} milliseconds The number of milliseconds to wait. - * @returns {JQueryPromise} + * @returns {Promise} */ - wait(milliseconds: number): JQueryPromise; + wait(milliseconds: number): DurandalPromise; /** * Gets all the owned keys of the specified object. @@ -295,14 +307,14 @@ interface DurandalViewEngineModule { * @param {string} id The view id whose view should be cached. * @param {DOMElement} view The view to cache. */ - putViewInCache(id: string, view: HTMLElement); + putViewInCache(id: string, view: HTMLElement): void; /** * Creates the view associated with the view id. * @param {string} viewId The view id whose view should be created. - * @returns {JQueryPromise} A promise of the view. + * @returns {DurandalPromise} A promise of the view. */ - createView(viewId: string): JQueryPromise; + createView(viewId: string): DurandalPromise; /** * Called when a view cannot be found to provide the opportunity to locate or generate a fallback view. Mainly used to ease development. @@ -311,7 +323,7 @@ interface DurandalViewEngineModule { * @param {Error} requirePath The error that was returned from the attempt to locate the default view. * @returns {Promise} A promise for the fallback view. */ - createFallbackView(viewId: string, requirePath: string, err: Error): JQueryPromise; + createFallbackView(viewId: string, requirePath: string, err: Error): DurandalPromise; } /** @@ -439,7 +451,7 @@ interface DurandalViewLocatorModule { * @param {DOMElement[]} [elementsToSearch] An existing set of elements to search first. * @returns {Promise} A promise of the view. */ - locateViewForObject(obj: any, area: string, elementsToSearch?: HTMLElement[]): JQueryPromise; + locateViewForObject(obj: any, area: string, elementsToSearch?: HTMLElement[]): DurandalPromise; /** * Converts a module id into a view id. By default the ids are the same. @@ -470,7 +482,7 @@ interface DurandalViewLocatorModule { * @param {DOMElement[]} [elementsToSearch] An existing set of elements to search first. * @returns {Promise} A promise of the view. */ - locateView(view: HTMLElement, area?: string, elementsToSearch?: HTMLElement[]): JQueryPromise; + locateView(view: HTMLElement, area?: string, elementsToSearch?: HTMLElement[]): DurandalPromise; /** * Locates the specified view. @@ -479,7 +491,7 @@ interface DurandalViewLocatorModule { * @param {DOMElement[]} [elementsToSearch] An existing set of elements to search first. * @returns {Promise} A promise of the view. */ - locateView(viewUrlOrId: string, area?: string, elementsToSearch?: HTMLElement[]): JQueryPromise; + locateView(viewUrlOrId: string, area?: string, elementsToSearch?: HTMLElement[]): DurandalPromise; } /** @@ -514,7 +526,7 @@ declare module 'durandal/composition' { area?: string; preserveContext?: boolean; activate?: boolean; - strategy?: (context: CompositionContext) => JQueryPromise; + strategy?: (context: CompositionContext) => DurandalPromise; composingNewView: boolean; child: HTMLElement; binding?: (child: HTMLElement, parent: HTMLElement, context: CompositionContext) => void; @@ -547,7 +559,7 @@ declare module 'durandal/composition' { * @param {object} [config] The binding handler instance. If none is provided, the name will be used to look up an existing handler which will then be converted to a composition handler. * @param {function} [initOptionsFactory] If the registered binding needs to return options from its init call back to knockout, this function will server as a factory for those options. It will receive the same parameters that the init function does. */ - export function addBindingHandler(name, config?: KnockoutBindingHandler, initOptionsFactory?: (element?: HTMLElement, valueAccessor?: any, allBindingsAccessor?: any, viewModel?: any, bindingContext?: KnockoutBindingContext) => any); + export function addBindingHandler(name: string, config?: KnockoutBindingHandler, initOptionsFactory?: (element?: HTMLElement, valueAccessor?: any, allBindingsAccessor?: any, viewModel?: any, bindingContext?: KnockoutBindingContext) => any): void; /** * Gets an object keyed with all the elements that are replacable parts, found within the supplied elements. The key will be the part name and the value will be the element itself. @@ -568,7 +580,7 @@ declare module 'durandal/composition' { * @param {object} context The composition context containing the model and possibly existing viewElements. * @returns {promise} A promise for the view. */ - export var defaultStrategy: (context: CompositionContext) => JQueryPromise; + export var defaultStrategy: (context: CompositionContext) => DurandalPromise; /** * Initiates a composition. @@ -663,13 +675,13 @@ declare module 'plugins/dialog' { * In this function, you are expected to add a DOM element to the tree which will serve as the "host" for the modal's composed view. You must add a property called host to the modalWindow object which references the dom element. It is this host which is passed to the composition module. * @param {Dialog} theDialog The dialog model. */ - addHost(theDialog: Dialog); + addHost(theDialog: Dialog): void; /** * This function is expected to remove any DOM machinery associated with the specified dialog and do any other necessary cleanup. * @param {Dialog} theDialog The dialog model. */ - removeHost(theDialog: Dialog); + removeHost(theDialog: Dialog): void; /** * This function is called after the modal is fully composed into the DOM, allowing your implementation to do any final modifications, such as positioning or animation. You can obtain the original dialog object by using `getDialog` on context.model. @@ -677,14 +689,14 @@ declare module 'plugins/dialog' { * @param {DOMElement} parent The parent view. * @param {object} context The composition context. */ - compositionComplete(child: HTMLElement, parent: HTMLElement, context: composition.CompositionContext); + compositionComplete(child: HTMLElement, parent: HTMLElement, context: composition.CompositionContext): void; } interface Dialog { owner: any; context: DialogContext; activator: DurandalActivator; - close(): JQueryPromise; + close(): DurandalPromise; settings: composition.CompositionContext; } @@ -745,7 +757,7 @@ declare module 'plugins/dialog' { * @param {string} [context] The name of the dialog context to use. Uses the default context if none is specified. * @returns {Promise} A promise that resolves when the dialog is closed and returns any data passed at the time of closing. */ - export function show(obj: any, activationData?: any, context?: string): JQueryPromise; + export function show(obj: any, activationData?: any, context?: string): DurandalPromise; /** * Shows a message box. @@ -756,7 +768,7 @@ declare module 'plugins/dialog' { * @param {Object} [settings] Custom settings for this instance of the messsage box, used to change classes and styles. * @returns {Promise} A promise that resolves when the message box is closed and returns the selected option. */ - export function showMessage(message: string, title?: string, options?: string[], autoclose?: boolean, settings?: Object): JQueryPromise; + export function showMessage(message: string, title?: string, options?: string[], autoclose?: boolean, settings?: Object): DurandalPromise; /** * Shows a message box. @@ -767,7 +779,7 @@ declare module 'plugins/dialog' { * @param {Object} [settings] Custom settings for this instance of the messsage box, used to change classes and styles. * @returns {Promise} A promise that resolves when the message box is closed and returns the selected option. */ - export function showMessage(message: string, title?: string, options?: DialogButton[], autoclose?: boolean, settings?: Object): JQueryPromise; + export function showMessage(message: string, title?: string, options?: DialogButton[], autoclose?: boolean, settings?: Object): DurandalPromise; /** * Installs this module into Durandal; called by the framework. Adds `app.showDialog` and `app.showMessage` convenience methods. @@ -890,7 +902,7 @@ declare module 'plugins/http' { * @param {object} [headers] The data to add to the request header. It will be converted to JSON. If the data contains Knockout observables, they will be converted into normal properties before serialization. * @returns {Promise} A promise of the get response data. */ - export function get(url: string, query?: Object, headers?: Object): JQueryPromise; + export function get(url: string, query?: Object, headers?: Object): DurandalPromise; /** * Makes an JSONP request. @@ -900,7 +912,7 @@ declare module 'plugins/http' { * @param {object} [headers] The data to add to the request header. It will be converted to JSON. If the data contains Knockout observables, they will be converted into normal properties before serialization. * @returns {Promise} A promise of the response data. */ - export function jsonp(url: string, query?: Object, callbackParam?: string, headers?: Object): JQueryPromise; + export function jsonp(url: string, query?: Object, callbackParam?: string, headers?: Object): DurandalPromise; /** * Makes an HTTP POST request. @@ -909,7 +921,7 @@ declare module 'plugins/http' { * @param {object} [headers] The data to add to the request header. It will be converted to JSON. If the data contains Knockout observables, they will be converted into normal properties before serialization. * @returns {Promise} A promise of the response data. */ - export function post(url: string, data: Object, headers?: Object): JQueryPromise; + export function post(url: string, data: Object, headers?: Object): DurandalPromise; /** * Makes an HTTP PUT request. @@ -919,7 +931,7 @@ declare module 'plugins/http' { * @param {object} [headers] The data to add to the request header. It will be converted to JSON. If the data contains Knockout observables, they will be converted into normal properties before serialization. * @return {Promise} A promise of the response data. */ - export function put(url: string, data: Object, headers?: Object): JQueryPromise; + export function put(url: string, data: Object, headers?: Object): DurandalPromise; /** * Makes an HTTP DELETE request. @@ -929,7 +941,7 @@ declare module 'plugins/http' { * @param {object} [headers] The data to add to the request header. It will be converted to JSON. If the data contains Knockout observables, they will be converted into normal properties before serialization. * @return {Promise} A promise of the get response data. */ - export function remove(url: string, query?: Object, headers?: Object): JQueryPromise; + export function remove(url: string, query?: Object, headers?: Object): DurandalPromise; } /** @@ -964,7 +976,7 @@ declare module 'plugins/observable' { * @param {function|object} evaluatorOrOptions The Knockout computed function or computed options object. * @returns {KnockoutComputed} The underlying computed observable. */ - export function defineProperty(obj: any, propertyName: string, evaluatorOrOptions?: KnockoutComputedDefine); + export function defineProperty(obj: any, propertyName: string, evaluatorOrOptions?: KnockoutComputedDefine): KnockoutComputed; /** * Installs the plugin into the view model binder's `beforeBind` hook so that objects are automatically converted before being bound. @@ -1046,7 +1058,7 @@ declare module 'plugins/serializer' { * @param {object} [settings] Settings can specify a replacer or space to override the serializer defaults. * @returns {string} The JSON string. */ - export function serialize(object: any, settings?: string); + export function serialize(object: any, settings?: string): string; /** * Serializes the object. @@ -1054,7 +1066,7 @@ declare module 'plugins/serializer' { * @param {object} [settings] Settings can specify a replacer or space to override the serializer defaults. * @returns {string} The JSON string. */ - export function serialize(object: any, settings?: number); + export function serialize(object: any, settings?: number): string; /** * Serializes the object. @@ -1062,7 +1074,7 @@ declare module 'plugins/serializer' { * @param {object} [settings] Settings can specify a replacer or space to override the serializer defaults. * @returns {string} The JSON string. */ - export function serialize(object: any, settings?: SerializerOptions); + export function serialize(object: any, settings?: SerializerOptions): string; /** * Gets the type id for an object instance, using the configured `typeAttribute`. @@ -1081,7 +1093,7 @@ declare module 'plugins/serializer' { * @param {string} typeId The type id. * @param {function} constructor The constructor. */ - export function registerType(typeId: string, constructor: () => any); + export function registerType(typeId: string, constructor: () => any): void; /** * The default reviver function used during deserialization. By default is detects type properties on objects and uses them to re-construct the correct object using the provided constructor mapping. @@ -1091,7 +1103,7 @@ declare module 'plugins/serializer' { * @param {object} getConstructor A custom function used to get the constructor function associated with a type id. * @returns {object} The value. */ - export function reviver(key: string, value: any, getTypeId: (value: any) => string, getConstructor: (string) => () => any): any; + export function reviver(key: string, value: any, getTypeId: (value: any) => string, getConstructor: (id: string) => () => any): any; /** * Deserialize the JSON. @@ -1128,7 +1140,7 @@ declare module 'plugins/widget' { * Creates a ko binding handler for the specified kind. * @param {string} kind The kind to create a custom binding handler for. */ - export function registerKind(kind: string); + export function registerKind(kind: string): void; /** * Maps views and module to the kind identifier if a non-standard pattern is desired. @@ -1136,7 +1148,7 @@ declare module 'plugins/widget' { * @param {string} [viewId] The unconventional view id to map the kind to. * @param {string} [moduleId] The unconventional module id to map the kind to. */ - export function mapKind(kind: string, viewId?: string, moduleId?: string); + export function mapKind(kind: string, viewId?: string, moduleId?: string): void; /** * Maps a kind name to it's module id. First it looks up a custom mapped kind, then falls back to `convertKindToModulePath`. @@ -1172,7 +1184,7 @@ declare module 'plugins/widget' { * @param {object} settings The widget settings. * @param {object} [bindingContext] The current binding context. */ - export function create(element: HTMLElement, settings: WidgetSettings, bindingContext?: KnockoutBindingContext); + export function create(element: HTMLElement, settings: WidgetSettings, bindingContext?: KnockoutBindingContext): void; } /** @@ -1279,14 +1291,14 @@ interface DurandalAppModule extends DurandalEventSupport { * @param {string} [context] The name of the dialog context to use. Uses the default context if none is specified. * @returns {Promise} A promise that resolves when the dialog is closed and returns any data passed at the time of closing. */ - showDialog(obj: any, activationData?: any, context?: string): JQueryPromise; + showDialog(obj: any, activationData?: any, context?: string): DurandalPromise; /** * Closes the dialog associated with the specified object. via the dialog plugin. * @param {object} obj The object whose dialog should be closed. * @param {object} results* The results to return back to the dialog caller after closing. */ - closeDialog(obj: any, ...results); + closeDialog(obj: any, ...results: any[]): void; /** * Shows a message box via the dialog plugin. @@ -1297,7 +1309,7 @@ interface DurandalAppModule extends DurandalEventSupport { * @param {Object} [settings] Custom settings for this instance of the messsage box, used to change classes and styles. * @returns {Promise} A promise that resolves when the message box is closed and returns the selected option. */ - showMessage(message: string, title?: string, options?: string[], autoclose?: boolean, settings?: Object): JQueryPromise; + showMessage(message: string, title?: string, options?: string[], autoclose?: boolean, settings?: Object): DurandalPromise; /** * Shows a message box. @@ -1308,7 +1320,7 @@ interface DurandalAppModule extends DurandalEventSupport { * @param {Object} [settings] Custom settings for this instance of the messsage box, used to change classes and styles. * @returns {Promise} A promise that resolves when the message box is closed and returns the selected option. */ - showMessage(message: string, title?: string, options?: DialogButton[], autoclose?: boolean, settings?: Object): JQueryPromise; + showMessage(message: string, title?: string, options?: DialogButton[], autoclose?: boolean, settings?: Object): DurandalPromise; /** * Configures one or more plugins to be loaded and installed into the application. @@ -1322,7 +1334,7 @@ interface DurandalAppModule extends DurandalEventSupport { * Starts the application. * @returns {promise} */ - start(): JQueryPromise; + start(): DurandalPromise; /** * Sets the root module/view for the application. @@ -1404,7 +1416,7 @@ interface DurandalActivator extends KnockoutComputed { * @param {boolean} close Whether or not to check if close is possible. * @returns {promise} */ - canDeactivateItem(item: T, close: boolean): JQueryPromise; + canDeactivateItem(item: T, close: boolean): DurandalPromise; /** * Deactivates the specified item. @@ -1412,7 +1424,7 @@ interface DurandalActivator extends KnockoutComputed { * @param {boolean} close Whether or not to close the item. * @returns {promise} */ - deactivateItem(item: T, close: boolean): JQueryPromise; + deactivateItem(item: T, close: boolean): DurandalPromise; /** * Determines whether or not the specified item can be activated. @@ -1420,7 +1432,7 @@ interface DurandalActivator extends KnockoutComputed { * @param {object} activationData Data associated with the activation. * @returns {promise} */ - canActivateItem(newItem: T, activationData?: any): JQueryPromise; + canActivateItem(newItem: T, activationData?: any): DurandalPromise; /** * Activates the specified item. @@ -1428,31 +1440,31 @@ interface DurandalActivator extends KnockoutComputed { * @param {object} newActivationData Data associated with the activation. * @returns {promise} */ - activateItem(newItem: T, activationData?: any): JQueryPromise; + activateItem(newItem: T, activationData?: any): DurandalPromise; /** * Determines whether or not the activator, in its current state, can be activated. * @returns {promise} */ - canActivate(): JQueryPromise; + canActivate(): DurandalPromise; /** * Activates the activator, in its current state. * @returns {promise} */ - activate(): JQueryPromise; + activate(): DurandalPromise; /** * Determines whether or not the activator, in its current state, can be deactivated. * @returns {promise} */ - canDeactivate(close: boolean): JQueryPromise; + canDeactivate(close: boolean): DurandalPromise; /** * Deactivates the activator, in its current state. * @returns {promise} */ - deactivate(close: boolean): JQueryPromise; + deactivate(close: boolean): DurandalPromise; /** * Adds canActivate, activate, canDeactivate and deactivate functions to the provided model which pass through to the corresponding functions on the activator. @@ -1462,7 +1474,7 @@ interface DurandalActivator extends KnockoutComputed { /** * Sets up a collection representing a pool of objects which the activator will activate. See below for details. Activators without an item bool always close their values on deactivate. Activators with an items pool only deactivate, but do not close them. */ - forItems(items): DurandalActivator; + forItems(items: any[]): DurandalActivator; } interface DurandalHistoryOptions { @@ -1509,7 +1521,7 @@ interface DurandalRouteConfiguration { title?: any; moduleId?: string; hash?: string; - route?: string|string[]; + route?: string | string[]; routePattern?: RegExp; isActive?: KnockoutComputed; nav?: any; @@ -1765,7 +1777,7 @@ interface DurandalRouterBase extends DurandalEventSupport { * @param {object} instruction The route instruction. The instruction object has config, fragment, queryString, params and queryParams properties. * @returns {Promise|Boolean|String} If a boolean, determines whether or not the route should activate or be cancelled. If a string, causes a redirect to the specified route. Can also be a promise for either of these value types. */ - guardRoute?: (instance: Object, instruction: DurandalRouteInstruction) => JQueryPromise|boolean|string; + guardRoute?: (instance: Object, instruction: DurandalRouteInstruction) => DurandalPromise | boolean | string; /** * Parent router of the current child router. @@ -1785,7 +1797,7 @@ interface DurandalRootRouter extends DurandalRouterBase { * Activates the router and the underlying history tracking mechanism. * @returns {Promise} A promise that resolves when the router is ready. */ - activate(options?: DurandalHistoryOptions): JQueryPromise; + activate(options?: DurandalHistoryOptions): DurandalPromise; /** * Disable history, perhaps temporarily. Not useful in a real app, but possibly useful for unit testing Routers. From bb4692f5d2bba524eb9b810cf7c83a1ec671d547 Mon Sep 17 00:00:00 2001 From: Stefan Profanter Date: Fri, 16 Oct 2015 17:07:49 +0200 Subject: [PATCH 0107/1238] Extended definition for roslib to match library functions --- roslib/roslib.d.ts | 361 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 356 insertions(+), 5 deletions(-) diff --git a/roslib/roslib.d.ts b/roslib/roslib.d.ts index 667a379830..9bab4a49f6 100644 --- a/roslib/roslib.d.ts +++ b/roslib/roslib.d.ts @@ -3,22 +3,373 @@ // Definitions by: Stefan Profanter // Definitions: https://github.com/borisyankov/DefinitelyTyped + +/* ---------------------------------- + + NOTE: This typescript definition is not yet complete. I should be extended if definitions are missing. + + ---------------------------------- */ + declare module ROSLIB { export class Ros { - constructor(data: { - url: string + /** + * Manages connection to the server and all interactions with ROS. + * + * Emits the following events: + * * 'error' - there was an error with ROS + * * 'connection' - connected to the WebSocket server + * * 'close' - disconnected to the WebSocket server + * * - a message came from rosbridge with the given topic name + * * - a service response came from rosbridge with the given ID + * + * @constructor + * @param options - possible keys include: + * * url (optional) - the WebSocket URL for rosbridge (can be specified later with `connect`) + */ + constructor(options:{ + url?: string }); - on(eventName: string, callback: (event: any) => void) : void; - connect(url: string) : void; + on(eventName:string, callback:(event:any) => void):void; + + /** + * Connect to the specified WebSocket. + * + * @param url - WebSocket URL for Rosbridge + */ + connect(url:string):void; + + /** + * Disconnect from the WebSocket server. + */ + close():void; + + /** + * Sends an authorization request to the server. + * + * @param mac - MAC (hash) string given by the trusted source. + * @param client - IP of the client. + * @param dest - IP of the destination. + * @param rand - Random string given by the trusted source. + * @param t - Time of the authorization request. + * @param level - User level as a string given by the client. + * @param end - End time of the client's session. + */ + authenticate(mac:string, client:string, dest:string, rand:string, t:number, level:string, end:string): void; + + + /** + * Sends the message over the WebSocket, but queues the message up if not yet + * connected. + */ + callOnConnection(message:any): void; + + /** + * Retrieves list of topics in ROS as an array. + * + * @param callback function with params: + * * topics - Array of topic names + */ + getTopics(callback:(topics:string[]) => void, failedCallback:(error:any)=>void): void; + + /** + * Retrieves Topics in ROS as an array as specific type + * + * @param topicType topic type to find: + * @param callback function with params: + * * topics - Array of topic names + */ + getTopicsForType(topicType:string, callback:(topics:string[]) => void, failedCallback:(error:any)=>void): void; + + /** + * Retrieves list of active service names in ROS. + * + * @param callback - function with the following params: + * * services - array of service names + */ + getServices(callback:(services:string[]) => void, failedCallback:(error:any)=>void): void; + + /** + * Retrieves list of services in ROS as an array as specific type + * + * @param serviceType service type to find: + * @param callback function with params: + * * topics - Array of service names + */ + getServicesForType(serviceType: string, callback:(services:string[]) => void, failedCallback:(error:any)=>void): void; + + /** + * Retrieves list of active node names in ROS. + * + * @param callback - function with the following params: + * * nodes - array of node names + */ + getNodes(callback:(nodes:string[]) => void, failedCallback:(error:any)=>void): void; + + /** + * Retrieves list of param names from the ROS Parameter Server. + * + * @param callback function with params: + * * params - array of param names. + */ + getParams(callback:(params:string[]) => void, failedCallback:(error:any)=>void): void; + + /** + * Retrieves a type of ROS topic. + * + * @param topic name of the topic: + * @param callback - function with params: + * * type - String of the topic type + */ + getTopicType(topic: string, callback:(type:string) => void, failedCallback:(error:any)=>void): void; + + /** + * Retrieves a type of ROS service. + * + * @param service name of service: + * @param callback - function with params: + * * type - String of the service type + */ + getServiceType(service: string, callback:(type:string) => void, failedCallback:(error:any)=>void): void; + + /** + * Retrieves a detail of ROS message. + * + * @param callback - function with params: + * * details - Array of the message detail + * @param message - String of a topic type + */ + getMessageDetails(message: Message, callback:(detail:any) => void, failedCallback:(error:any)=>void): void; + + /** + * Decode a typedefs into a dictionary like `rosmsg show foo/bar` + * + * @param defs - array of type_def dictionary + */ + decodeTypeDefs(defs: any): void; + } + + export class Message { + /** + * Message objects are used for publishing and subscribing to and from topics. + * + * @constructor + * @param values - object matching the fields defined in the .msg definition file + */ + constructor(values:any); + } + + export class Param { + /** + * A ROS parameter. + * + * @constructor + * @param options - possible keys include: + * * ros - the ROSLIB.Ros connection handle + * * name - the param name, like max_vel_x + */ + constructor(options:{ + ros: Ros, + name: string + }); + + /** + * Fetches the value of the param. + * + * @param callback - function with the following params: + * * value - the value of the param from ROS. + */ + get(callback:(response:any) => void): void; + + /** + * Sets the value of the param in ROS. + * + * @param value - value to set param to. + */ + set(value:any, callback:(response:any) => void): void; + + /** + * Delete this parameter on the ROS server. + */ + delete(callback:(response:any) => void): void; + } export class Service { - constructor(data: { + /** + * A ROS service client. + * + * @constructor + * @params options - possible keys include: + * * ros - the ROSLIB.Ros connection handle + * * name - the service name, like /add_two_ints + * * serviceType - the service type, like 'rospy_tutorials/AddTwoInts' + */ + constructor(data:{ ros: Ros, name: string, serviceType: string }); + + /** + * Calls the service. Returns the service response in the callback. + * + * @param request - the ROSLIB.ServiceRequest to send + * @param callback - function with params: + * * response - the response from the service request + * @param failedCallback - the callback function when the service call failed (optional). Params: + * * error - the error message reported by ROS + */ + callService(request:ServiceRequest, callback:(response:any) => void, failedCallback?:(error:any) => void): void; + } + + export class ServiceRequest { + /** + * A ServiceRequest is passed into the service call. + * + * @constructor + * @param values - object matching the fields defined in the .srv definition file + */ + constructor(values: any); + } + + export class ServiceResponse { + /** + * A ServiceResponse is returned from the service call. + * + * @constructor + * @param values - object matching the fields defined in the .srv definition file + */ + constructor(values: any); + } + + export class Topic { + /** + * Publish and/or subscribe to a topic in ROS. + * + * Emits the following events: + * * 'warning' - if there are any warning during the Topic creation + * * 'message' - the message data from rosbridge + * + * @constructor + * @param options - object with following keys: + * * ros - the ROSLIB.Ros connection handle + * * name - the topic name, like /cmd_vel + * * messageType - the message type, like 'std_msgs/String' + * * compression - the type of compression to use, like 'png' + * * throttle_rate - the rate (in ms in between messages) at which to throttle the topics + * * queue_size - the queue created at bridge side for re-publishing webtopics (defaults to 100) + * * latch - latch the topic when publishing + * * queue_length - the queue length at bridge side used when subscribing (defaults to 0, no queueing). + */ + constructor(options: { + ros: Ros, + name: string, + messageType: string, + compression: string, + throttle_rate: number, + queue_size: number, + latch: number, + queue_length: number + }); + + /** + * Every time a message is published for the given topic, the callback + * will be called with the message object. + * + * @param callback - function with the following params: + * * message - the published message + */ + subscribe(callback: (message: Message) => void): void; + + /** + * Unregisters as a subscriber for the topic. Unsubscribing stop remove + * all subscribe callbacks. To remove a call back, you must explicitly + * pass the callback function in. + * + * @param callback - the optional callback to unregister, if + * * provided and other listeners are registered the topic won't + * * unsubscribe, just stop emitting to the passed listener + */ + unsubscribe(callback?: () => void): void; + + /** + * Registers as a publisher for the topic. + */ + advertise(): void; + + /** + * Unregisters as a publisher for the topic. + */ + unadvertise(): void; + + /** + * Publish the message. + * + * @param message - A ROSLIB.Message object. + */ + publish(message: Message): void; + } + + class ActionClient { + /** + * An actionlib action client. + * + * Emits the following events: + * * 'timeout' - if a timeout occurred while sending a goal + * * 'status' - the status messages received from the action server + * * 'feedback' - the feedback messages received from the action server + * * 'result' - the result returned from the action server + * + * @constructor + * @param options - object with following keys: + * * ros - the ROSLIB.Ros connection handle + * * serverName - the action server name, like /fibonacci + * * actionName - the action message name, like 'actionlib_tutorials/FibonacciAction' + * * timeout - the timeout length when connecting to the action server + */ + constructor(options: { + ros: Ros, + serverName: string, + actionName: string, + timeout: number + }); + + /** + * Cancel all goals associated with this ActionClient. + */ + cancel(): void; + } + + class Goal { + /** + * An actionlib goal goal is associated with an action server. + * + * Emits the following events: + * * 'timeout' - if a timeout occurred while sending a goal + * + * @constructor + * @param object with following keys: + * * actionClient - the ROSLIB.ActionClient to use with this goal + * * goalMessage - The JSON object containing the goal for the action server + */ + constructor(options: { + actionClient: ActionClient, + goalMessage: any + }); + + /** + * Send the goal to the action server. + * + * @param timeout (optional) - a timeout length for the goal's result + */ + send(timeout?: number): void; + + /** + * Cancel the current goal. + */ + cancel(): void; } } + From 70dc7d5bd011694a5f0a3abccd53780629273342 Mon Sep 17 00:00:00 2001 From: haizz Date: Fri, 16 Oct 2015 18:30:14 +0300 Subject: [PATCH 0108/1238] react-bootstrap: added 'show' property to ModalProps --- react-bootstrap/react-bootstrap.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/react-bootstrap/react-bootstrap.d.ts b/react-bootstrap/react-bootstrap.d.ts index 8f3803a6bc..5e3532c648 100644 --- a/react-bootstrap/react-bootstrap.d.ts +++ b/react-bootstrap/react-bootstrap.d.ts @@ -249,6 +249,7 @@ declare module "react-bootstrap" { dialogComponent?: any; // TODO: Add more specific type enforceFocus?: boolean; keyboard?: boolean; + show?: boolean; } interface Modal extends React.ReactElement { } interface ModalClass extends React.ComponentClass { From 39c221338d56e953b745bfdd761f8c594d8f92da Mon Sep 17 00:00:00 2001 From: Dominic Alie Date: Fri, 16 Oct 2015 11:33:55 -0400 Subject: [PATCH 0109/1238] JSTS type definitions --- jsts/jsts-tests.ts | 145 ++++ jsts/jsts.d.ts | 1666 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 1811 insertions(+) create mode 100644 jsts/jsts-tests.ts create mode 100644 jsts/jsts.d.ts diff --git a/jsts/jsts-tests.ts b/jsts/jsts-tests.ts new file mode 100644 index 0000000000..3b37d0f185 --- /dev/null +++ b/jsts/jsts-tests.ts @@ -0,0 +1,145 @@ +/// +var str: string; +var n: number; +var bool: boolean; +var obj: any; + +var c: jsts.geom.Coordinate = new jsts.geom.Coordinate(n, n); +var e: jsts.geom.Envelope = new jsts.geom.Envelope(n, n, n, n); +var g: jsts.geom.Geometry = new jsts.geom.Geometry(); +var lr: jsts.geom.LinearRing = new jsts.geom.LinearRing([c]); +var ls: jsts.geom.LineString = new jsts.geom.LineString([c]); +var p: jsts.geom.Point = new jsts.geom.Point(c); +var poly: jsts.geom.Polygon = new jsts.geom.Polygon(lr); + +str = jsts.version; + +c = new jsts.geom.Coordinate(c); +c = c.clone(); +n = c.compareTo(c); +n = c.distance(c); +bool = c.equals(c); +bool = c.equals2D(c); +c.setCoordinate(c); +n = c.x; +n = c.y; +n = c.z; + +e = new jsts.geom.Envelope(c); +e = new jsts.geom.Envelope(e); +e = new jsts.geom.Envelope(c, c); +c = e.centre(); +e = e.clone(); +bool = e.contains(e); +bool = e.contains(c); +bool = e.contains(n, n); +bool = e.covers(c); +bool = e.covers(e); +bool = e.covers(n, n); +n = e.distance(e); +bool = e.equals(e); +e.expandBy(n); +e.expandToInclude(c); +e.expandToInclude(e); +e.expandToInclude(n, n); +n = e.getArea(); +n = e.getHeight(); +n = e.getMaxX(); +n = e.getMaxY(); +n = e.getMinX(); +n = e.getMinY(); +n = e.getWidth(); +e = e.intersection(e); +bool = e.intersects(e); +bool = e.intersects(c); +bool = e.intersects(n, n); +bool = e.isNull(); +n = e.maxx; +n = e.maxy; +n = e.minx; +n = e.miny; +e.setToNull(); +str = e.toString(); +e.translate(n, n); + +g.apply({}); +g = g.buffer(n, n, n); +g.checkNotGeometryCollection(g); +g = g.clone(); +n = g.compare([{}], [{}]); +n = g.compareTo(g); +n = g.compareToSameClass(g); +e = g.computeEnvelopeInternal(); +bool = g.contains(g); +g = g.convexHull(); +bool = g.coveredBy(g); +bool = g.covers(g); +bool = g.crosses(g); +g = g.difference(g); +bool = g.disjoint(g); +n = g.distance(g); +e = g.envelope; +bool = g.equal(c, c, n); +bool = g.equals(g); +bool = g.equalsExact(g, n); +bool = g.equalsNorm(g); +bool = g.equalsTopo(g); +n = g.getArea(); +g = g.getBoundary(); +n = g.getBoundaryDimension(); +p = g.getCentroid(); +c = g.getCoordinate(); +var coords: jsts.geom.Coordinate[] = g.getCoordinates(); +n = g.getDimension(); +g = g.getEnvelope(); +e = g.getEnvelopeInternal(); +obj = g.getFactory(); +g = g.getGeometryN(n); +str = g.getGeometryType(); +p = g.getInteriorPoint(); +n = g.getLength(); +n = g.getNumGeometries(); +n = g.getNumPoints(); +obj = g.getPrecisionModel(); +g = g.intersection(g); +bool = g.intersects(g); +bool = g.isEmpty(); +bool = g.isEquivalentClass(g); +bool = g.isGeometryCollection(); +bool = g.isGeometryCollectionBase(); +bool = g.isRectangle(); +bool = g.isSimple(); +bool = g.isValid(); +bool = g.isWithinDistance(g, n); +g = g.norm(); +g.normalize(); +bool = g.overlaps(g); +bool = g.relate(g, str); +obj = g.relate2(g); +g = g.symDifference(g); +str = g.toString(); +bool = g.touches(g); +g = g.union(g); +bool = g.within(g); + +c = ls.getCoordinateN(n); +p = ls.getEndPoint(); +p = ls.getPointN(n); +p = ls.getStartPoint(); +bool = ls.isClosed(); +bool = ls.isRing(); + +n = p.getX(); +n = p.getY(); +p = p.reverse(); + +lr = poly.getExteriorRing(); +lr = poly.getInteriorRingN(n); +n = poly.getNumInteriorRing(); + +var gjw: jsts.io.GeoJSONWriter = new jsts.io.GeoJSONWriter(); +obj = gjw.write(g); + +var wr: jsts.io.WKTReader = new jsts.io.WKTReader(); +g = wr.read(str); +wr.reducePrecision(g); \ No newline at end of file diff --git a/jsts/jsts.d.ts b/jsts/jsts.d.ts new file mode 100644 index 0000000000..2eac4d5a48 --- /dev/null +++ b/jsts/jsts.d.ts @@ -0,0 +1,1666 @@ +// Type definitions for jsts 0.16.0 +// Project: https://github.com/bjornharrtell/jsts +// Definitions by: Stephane Alie +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module jsts { + export var version: string; + + module geom { + /** + * A lightweight class used to store coordinates on the 2-dimensional + * Cartesian plane. It is distinct from {@link Point}, which is a subclass of + * {@link Geometry}. Unlike objects of type {@link Point} (which contain + * additional information such as an envelope, a precision model, and spatial + * reference system information), a Coordinate only contains + * coordinate values and accessor methods. + */ + export class Coordinate { + /** + * @constructor + */ + constructor(x: number, y: number); + + /** + * @constructor + */ + constructor(c: Coordinate); + + /** + * Gets or sets the x value. + */ + x: number; + + /** + * Gets or sets the y value. + */ + y: number; + + /** + * Gets or sets the z value. + */ + z: number; + + /** + * Sets this Coordinates (x,y,z) values to that of + * other. + * + * @param {Coordinate} + * other the Coordinate to copy. + */ + setCoordinate(other: Coordinate): void; + + /** + * Clones this instance. + * + * @return {Coordinate} A point instance cloned from this. + */ + clone(): Coordinate; + + /** + * Computes the 2-dimensional Euclidean distance to another location. The + * Z-ordinate is ignored. + * + * @param {Coordinate} + * p a point. + * @return {number} the 2-dimensional Euclidean distance between the + * locations. + */ + distance(p: Coordinate): number; + + /** + * Returns whether the planar projections of the two Coordinates + * are equal. + * + * @param {Coordinate} + * other a Coordinate with which to do the 2D + * comparison. + * @return {boolean} true if the x- and y-coordinates are + * equal; the z-coordinates do not have to be equal. + */ + equals2D(other: Coordinate): boolean; + + /** + * Returns true if other has the same values for + * the x and y ordinates. Since Coordinates are 2.5D, this routine ignores the + * z value when making the comparison. + * + * @param {Coordinate} + * other a Coordinate with which to do the comparison. + * @return {boolean} true if other is a + * Coordinate with the same values for the x and y + * ordinates. + */ + equals(other: Coordinate): boolean; + + /** + * Compares this {@link Coordinate} with the specified {@link Coordinate} for + * order. This method ignores the z value when making the comparison. Returns: + *
    + *
  • -1 : this.x < other.x || ((this.x == other.x) && (this.y < other.y)) + *
  • 0 : this.x == other.x && this.y = other.y + *
  • 1 : this.x > other.x || ((this.x == other.x) && (this.y > other.y)) + * + *
+ * Note: This method assumes that ordinate values are valid numbers. NaN + * values are not handled correctly. + * + * @param {Coordinate} + * other the Coordinate with which this + * Coordinate is being compared. + * @return {number} -1, zero, or 1 as explained above. + */ + compareTo(other: Coordinate): number; + } + + /** + * Defines a rectangular region of the 2D coordinate plane. It is often used to + * represent the bounding box of a {@link Geometry}, e.g. the minimum and + * maximum x and y values of the {@link Coordinate}s. + *

+ * Note that Envelopes support infinite or half-infinite regions, by using the + * values of Double.POSITIVE_INFINITY and + * Double.NEGATIVE_INFINITY. + *

+ * When Envelope objects are created or initialized, the supplies extent values + * are automatically sorted into the correct order. + */ + export class Envelope { + /** + * Test the point q to see whether it intersects the Envelope defined by p1-p2 + * + * NOTE: calls intersectsEnvelope if four arguments are given to simulate + * overloaded function + * + * @param {jsts.geom.Coordinate} + * p1 one extremal point of the envelope. + * @param {jsts.geom.Coordinate} + * p2 another extremal point of the envelope. + * @param {jsts.geom.Coordinate} + * q the point to test for intersection. + * @return {boolean} true if q intersects the envelope p1-p2. + */ + static intersects(p1: Coordinate, p2: Coordinate, q: Coordinate): boolean; + + /** + * Test the envelope defined by p1-p2 for intersection with the envelope defined + * by q1-q2 + * + * @param {jsts.geom.Coordinate} + * p1 one extremal point of the envelope P. + * @param {jsts.geom.Coordinate} + * p2 another extremal point of the envelope P. + * @param {jsts.geom.Coordinate} + * q1 one extremal point of the envelope Q. + * @param {jsts.geom.Coordinate} + * q2 another extremal point of the envelope Q. + * @return {boolean} true if Q intersects P. + */ + static intersectsEnvelope(p1: Coordinate, p2: Coordinate, q1: Coordinate, q2: Coordinate): boolean; + + /** + * Creates an Envelope for a region defined by maximum and + * minimum values. + * + * @param {number} x1 the first x-value. + * @param {number} x2 the second x-value. + * @param {number} y1 the first y-value. + * @param {number} y2 the second y-value. + */ + constructor(x1: number, x2: number, y1: number, y2: number); + + /** + * Initialize an Envelope to a region defined by two Coordinates. + * + * @param {jsts.geom.Coordinate} p1 the first Coordinate. + * @param {jsts.geom.Coordinate} p2 the second Coordinate. + */ + constructor(p1: Coordinate, p2: Coordinate); + + /** + * Initialize an Envelope to a region defined by a single + * Coordinate. + * + * @param {jsts.geom.Coordinate} p the Coordinate. + */ + constructor(p: Coordinate); + + /** + * Initialize an Envelope from an existing Envelope. + * + * @param {jsts.geom.Envelope} env the Envelope to initialize from. + */ + constructor(env: Envelope); + + /** + * the minimum x-coordinate. + */ + minx: number; + + /** + * the maximum x-coordinate. + */ + maxx: number; + + /** + * the minimum y-coordinate. + */ + miny: number; + + /** + * the maximum y-coordinate. + */ + maxy: number; + + /** + * Makes this Envelope a "null" envelope, that is, the envelope + * of the empty geometry. + */ + setToNull(): void; + + /** + * Returns true if this Envelope is a "null" + * envelope. + * + * @return {boolean} true if this Envelope is + * uninitialized or is the envelope of the empty geometry. + */ + isNull(): boolean; + + /** + * Returns the difference between the maximum and minimum y values. + * + * @return {number} max y - min y, or 0 if this is a null Envelope. + */ + getHeight(): number; + + /** + * Returns the difference between the maximum and minimum x values. + * + * @return {number} max x - min x, or 0 if this is a null Envelope. + */ + getWidth(): number; + + /** + * Returns the Envelopes minimum x-value. min x > max x + * indicates that this is a null Envelope. + * + * @return {number} the minimum x-coordinate. + */ + getMinX(): number; + + /** + * Returns the Envelopes maximum x-value. min x > max x + * indicates that this is a null Envelope. + * + * @return {number} the maximum x-coordinate. + */ + getMaxX(): number; + + /** + * Returns the Envelopes minimum y-value. min y > max y + * indicates that this is a null Envelope. + * + * @return {number} the minimum y-coordinate. + */ + getMinY(): number; + + /** + * Returns the Envelopes maximum y-value. min y > max y + * indicates that this is a null Envelope. + * + * @return {number} the maximum y-coordinate. + */ + getMaxY(): number; + + /** + * Gets the area of this envelope. + * + * @return {number} the area of the envelope, 0.0 if the envelope is null. + */ + getArea(): number; + + /** + * Enlarges this Envelope so that it contains the given + * {@link Coordinate}. Has no effect if the point is already on or within the + * envelope. + * + * @param {jsts.geom.Coordinate} p the Coordinate to expand to include. + */ + expandToInclude(p: Coordinate): void; + + /** + * Enlarges this Envelope so that it contains the given point. + * Has no effect if the point is already on or within the envelope. + * + * @param {number} x the value to lower the minimum x to or to raise the maximum x to. + * @param {number} y the value to lower the minimum y to or to raise the maximum y to. + */ + expandToInclude(x: number, y: number): void; + + /** + * Enlarges this Envelope so that it contains the + * other Envelope. Has no effect if other is + * wholly on or within the envelope. + * + * @param {jsts.geom.Envelope} other the Envelope to expand to include. + */ + expandToInclude(other: Envelope): void; + + /** + * Expands this envelope by a given distance in all directions. Both positive + * and negative distances are supported. + * + * @param {number} distance the distance to expand the envelope. + */ + expandBy(distance: number): void; + + /** + * Expands this envelope by a given distance in all directions. Both positive + * and negative distances are supported. + * + * @param {number} + * deltaX the distance to expand the envelope along the the X axis. + * @param {number} + * deltaY the distance to expand the envelope along the the Y axis. + */ + expandBy(deltaX: number, deltaY: number): void; + + /** + * Translates this envelope by given amounts in the X and Y direction. + * + * @param {number} + * transX the amount to translate along the X axis. + * @param {number} + * transY the amount to translate along the Y axis. + */ + translate(transX: number, transY: number): void; + + /** + * Computes the coordinate of the centre of this envelope (as long as it is + * non-null + * + * @return {jsts.geom.Coordinate} the centre coordinate of this envelope null + * if the envelope is null. + */ + centre(): Coordinate; + + /** + * Computes the intersection of two {@link Envelopes} + * + * @param {jsts.geom.Envelope} + * env the envelope to intersect with. + * @return {jsts.geom.Envelope} a new Envelope representing the intersection of + * the envelopes (this will be the null envelope if either argument is + * null, or they do not intersect. + */ + intersection(env: Envelope): Envelope; + + /** + * Check if the region defined by other overlaps (intersects) the + * region of this Envelope. + * + * @param {jsts.geom.Envelope} + * other the Envelope which this Envelope + * is being checked for overlapping. + * @return {boolean} true if the Envelopes + * overlap. + */ + intersects(other: Envelope): boolean; + + /** + * Check if the point p overlaps (lies inside) the region of this + * Envelope. + * + * @param {jsts.geom.Coordinate} + * p the Coordinate to be tested. + * @return {boolean} true if the point overlaps this + * Envelope. + */ + intersects(p: Coordinate): boolean; + + /** + * Check if the point (x, y) overlaps (lies inside) the region of + * this Envelope. + * + * @param {number} + * x the x-ordinate of the point. + * @param {number} + * y the y-ordinate of the point. + * @return {boolean} true if the point overlaps this + * Envelope. + */ + intersects(x: number, y: number): boolean; + + /** + * Tests if the Envelope other lies wholely inside this + * Envelope (inclusive of the boundary). + *

+ * Note that this is not the same definition as the SFS + * contains, which would exclude the envelope boundary. + * + * @param {jsts.geom.Envelope} + * other the Envelope to check. + * @return {boolean} true if other is contained in this + * Envelope. + * + * @see covers(Envelope) + */ + contains(other: Envelope): boolean; + + /** + * Tests if the given point lies in or on the envelope. + *

+ * Note that this is not the same definition as the SFS + * contains, which would exclude the envelope boundary. + * + * @param {jsts.geom.Coordinate} + * p the point which this Envelope is being checked for + * containing. + * @return {boolean} true if the point lies in the interior or on + * the boundary of this Envelope. + * + * @see covers(Coordinate) + */ + contains(p: Coordinate): boolean; + + /** + * Tests if the given point lies in or on the envelope. + *

+ * Note that this is not the same definition as the SFS + * contains, which would exclude the envelope boundary. + * + * @param {number} + * x the x-coordinate of the point which this Envelope + * is being checked for containing. + * @param {number} + * y the y-coordinate of the point which this Envelope + * is being checked for containing. + * @return {boolean} true if (x, y) lies in the + * interior or on the boundary of this Envelope. + * + * @see covers(double, double) + */ + contains(x: number, y: number): boolean; + + /** + * Tests if the given point lies in or on the envelope. + * + * @param {number} + * x the x-coordinate of the point which this Envelope + * is being checked for containing. + * @param {number} + * y the y-coordinate of the point which this Envelope + * is being checked for containing. + * @return {boolean} true if (x, y) lies in the + * interior or on the boundary of this Envelope. + */ + covers(x: number, y: number): boolean; + + /** + * Tests if the given point lies in or on the envelope. + * + * @param {jsts.geom.Coordinate} + * p the point which this Envelope is being checked for + * containing. + * @return {boolean} true if the point lies in the interior or on + * the boundary of this Envelope. + */ + covers(p: Coordinate): boolean; + + /** + * Tests if the Envelope other lies wholely inside this + * Envelope (inclusive of the boundary). + * + * @param {jsts.geom.Envelope} + * other the Envelope to check. + * @return {boolean} true if this Envelope covers the + * other. + */ + covers(other: Envelope): boolean; + + /** + * Computes the distance between this and another Envelope. + * + * @param {jsts.geom.Envelope} + * env The Envelope to test this Envelope + * against. + * @return {number} The distance between overlapping Envelopes is 0. Otherwise, + * the distance is the Euclidean distance between the closest points. + */ + distance(env: Envelope): number; + + /** + * @param {jsts.geom.Envelope} + * other the Envelope to check against. + * @return {boolean} true if envelopes are equal. + */ + equals(other: Envelope): boolean; + + /** + * @return {string} String representation of this Envelope. + */ + toString(): string; + + /** + * @return {jsts.geom.Envelope} A new instance copied from this. + */ + clone(): Envelope; + } + + /** + * The base class for all geometric objects. + */ + export class Geometry { + /** + * Creates a new Geometry via the specified GeometryFactory. + */ + constructor(factory?: any); + + /** + * The bounding box of this Geometry. + */ + envelope: Envelope; + + /** + * Gets the factory which contains the context in which this geometry was created. + * + * @return {jsts.geom.GeometryFactory} the factory for this geometry. + */ + getFactory(): any; + + /** + * Returns the name of this object's com.vivid.jts.geom interface. + * + * @return {string} The name of this Geometrys most specific jsts.geom interface. + */ + getGeometryType(): string; + + /** + *Returns the number of {@link Geometry}s in a {@link GeometryCollection} + * (or 1, if the geometry is not a collection). + * + * @return {number} the number of geometries contained in this geometry. + */ + getNumGeometries(): number; + + /** + * Returns an element {@link Geometry} from a {@link GeometryCollection} (or + * this, if the geometry is not a collection). + * + * @param {number} n The index of the geometry element. + * + * @return {Geometry} the n'th geometry contained in this geometry. + */ + getGeometryN(n: number): Geometry; + + /** + * Returns the PrecisionModel used by the Geometry. + * + * @return {PrecisionModel} the specification of the grid of allowable points, for this + * Geometry and all other Geometrys. + */ + getPrecisionModel(): any; + + /** + * Returns a vertex of this Geometry (usually, but not + * necessarily, the first one). The returned coordinate should not be assumed to + * be an actual Coordinate object used in the internal representation. + * + * @return {Coordinate} a {@link Coordinate} which is a vertex of this + * Geometry. null if this Geometry is empty. + */ + getCoordinate(): Coordinate; + + /** + * Returns an array containing the values of all the vertices for this geometry. + * If the geometry is a composite, the array will contain all the vertices for + * the components, in the order in which the components occur in the geometry. + *

+ * In general, the array cannot be assumed to be the actual internal storage for + * the vertices. Thus modifying the array may not modify the geometry itself. + * Use the {@link CoordinateSequence#setOrdinate} method (possibly on the + * components) to modify the underlying data. If the coordinates are modified, + * {@link #geometryChanged} must be called afterwards. + * + * @return {Coordinate[]} the vertices of this Geometry. + * @see geometryChanged + * @see CoordinateSequence#setOrdinate + */ + getCoordinates(): Coordinate[]; + + /** + * Returns the count of this Geometrys vertices. The + * Geometry s contained by composite Geometrys + * must be Geometry's; that is, they must implement getNumPoints + * + * @return {number} the number of vertices in this Geometry. + */ + getNumPoints(): number; + + /** + * Tests whether this {@link Geometry} is simple. In general, the SFS + * specification of simplicity follows the rule: + *

    + *
  • A Geometry is simple iff the only self-intersections are at boundary + * points. + *
+ * Simplicity is defined for each {@link Geometry} subclass as follows: + *
    + *
  • Valid polygonal geometries are simple by definition, so + * isSimple trivially returns true. + *
  • Linear geometries are simple iff they do not self-intersect at points + * other than boundary points. + *
  • Zero-dimensional geometries (points) are simple iff they have no + * repeated points. + *
  • Empty Geometrys are always simple + *
      + * + * @return {boolean} true if this Geometry has any + * points of self-tangency, self-intersection or other anomalous points. + * @see #isValid + */ + isSimple(): boolean; + + /** + * Tests the validity of this Geometry. Subclasses provide their + * own definition of "valid". + * + * @return {boolean} true if this Geometry is + * valid. + * + * @see IsValidOp + */ + isValid(): boolean; + + /** + * Returns whether or not the set of points in this Geometry is + * empty. + * + * @return {boolean} true if this Geometry equals + * the empty geometry. + */ + isEmpty(): boolean; + + /** + * Returns the minimum distance between this Geometry and the + * Geometry g + * + * @param {Geometry} + * g the Geometry from which to compute the distance. + * @return {number} the distance between the geometries. 0 if either input + * geometry is empty. + * @throws IllegalArgumentException + * if g is null + */ + distance(g: Geometry): number; + + /** + * Tests whether the distance from this Geometry to another is + * less than or equal to a specified value. + * + * @param {Geometry} + * geom the Geometry to check the distance to. + * @param {number} + * distance the distance value to compare. + * @return {boolean} true if the geometries are less than + * distance apart. + */ + isWithinDistance(geom: Geometry, distance: number): boolean; + + isRectangle(): boolean; + + /** + * Returns the area of this Geometry. Areal Geometries have a + * non-zero area. They override this function to compute the area. Others return + * 0.0 + * + * @return the area of the Geometry. + */ + getArea(): number; + + /** + * Returns the length of this Geometry. Linear geometries return + * their length. Areal geometries return their perimeter. They override this + * function to compute the area. Others return 0.0 + * + * @return the length of the Geometry. + */ + getLength(): number; + + /** + * Computes the centroid of this Geometry. The centroid is equal + * to the centroid of the set of component Geometries of highest dimension + * (since the lower-dimension geometries contribute zero "weight" to the + * centroid) + * + * @return a {@link Point} which is the centroid of this Geometry. + */ + getCentroid(): Point; + + /** + * Computes an interior point of this Geometry. An interior + * point is guaranteed to lie in the interior of the Geometry, if it possible to + * calculate such a point exactly. Otherwise, the point may lie on the boundary + * of the geometry. + * + * @return {Point} a {@link Point} which is in the interior of this Geometry. + */ + getInteriorPoint(): Point; + + /** + * Returns the dimension of this geometry. The dimension of a geometry is is the + * topological dimension of its embedding in the 2-D Euclidean plane. In the JTS + * spatial model, dimension values are in the set {0,1,2}. + *

      + * Note that this is a different concept to the dimension of the vertex + * {@link Coordinate}s. The geometry dimension can never be greater than the + * coordinate dimension. For example, a 0-dimensional geometry (e.g. a Point) + * may have a coordinate dimension of 3 (X,Y,Z). + * + * @return {number} the topological dimension of this geometry. + */ + getDimension(): number; + + /** + * Returns the boundary, or an empty geometry of appropriate dimension if this + * Geometry is empty. (In the case of zero-dimensional + * geometries, ' an empty GeometryCollection is returned.) For a discussion of + * this function, see the OpenGIS Simple Features Specification. As stated in + * SFS Section 2.1.13.1, "the boundary of a Geometry is a set of Geometries of + * the next lower dimension." + * + * @return {Geometry} the closure of the combinatorial boundary of this + * Geometry. + */ + getBoundary(): Geometry; + + /** + * Returns the dimension of this Geometrys inherent boundary. + * + * @return {number} the dimension of the boundary of the class implementing this + * interface, whether or not this object is the empty geometry. Returns + * Dimension.FALSE if the boundary is the empty geometry. + */ + getBoundaryDimension(): number; + + /** + * Returns this Geometrys bounding box. If this + * Geometry is the empty geometry, returns an empty + * Point. If the Geometry is a point, returns a + * non-empty Point. Otherwise, returns a Polygon + * whose points are (minx, miny), (maxx, miny), (maxx, maxy), (minx, maxy), + * (minx, miny). + * + * @return {Geometry} an empty Point (for empty + * Geometrys), a Point (for + * Points) or a Polygon (in all other + * cases). + */ + getEnvelope(): Geometry; + + /** + * Returns the minimum and maximum x and y values in this Geometry, + * or a null Envelope if this Geometry is empty. + * + * @return {Envelope} this Geometrys bounding box; if the + * Geometry is empty, Envelope#isNull will + * return true. + */ + getEnvelopeInternal(): Envelope; + + /** + * Tests whether this geometry is disjoint from the specified geometry. + *

      + * The disjoint predicate has the following equivalent + * definitions: + *

        + *
      • The two geometries have no point in common + *
      • The DE-9IM Intersection Matrix for the two geometries matches + * [FF*FF****] + *
      • ! g.intersects(this) (disjoint is the + * inverse of intersects) + *
      + * + * @param {Geometry} + * g the Geometry with which to compare this + * Geometry. + * @return {boolean} true if the two Geometrys + * are disjoint. + * + * @see Geometry#intersects + */ + disjoint(g: Geometry): boolean; + + /** + * Tests whether this geometry touches the specified geometry. + *

      + * The touches predicate has the following equivalent + * definitions: + *

        + *
      • The geometries have at least one point in common, but their interiors do + * not intersect. + *
      • The DE-9IM Intersection Matrix for the two geometries matches + * [FT*******] or [F**T*****] or + * [F***T****] + *
      + * If both geometries have dimension 0, this predicate returns + * false + * + * @param {Geometry} + * g the Geometry with which to compare this + * Geometry. + * @return {boolean} true if the two Geometrys + * touch; Returns false if both Geometrys + * are points. + */ + touches(g: Geometry): boolean; + + /** + * Tests whether this geometry intersects the specified geometry. + *

      + * The intersects predicate has the following equivalent + * definitions: + *

        + *
      • The two geometries have at least one point in common + *
      • The DE-9IM Intersection Matrix for the two geometries matches + * [T********] or [*T*******] or + * [***T*****] or [****T****] + *
      • ! g.disjoint(this) (intersects is the + * inverse of disjoint) + *
      + * + * @param {Geometry} + * g the Geometry with which to compare this + * Geometry. + * @return {boolean} true if the two Geometrys + * intersect. + * + * @see Geometry#disjoint + */ + intersects(g: Geometry): boolean; + + /** + * Tests whether this geometry crosses the specified geometry. + *

      + * The crosses predicate has the following equivalent + * definitions: + *

        + *
      • The geometries have some but not all interior points in common. + *
      • The DE-9IM Intersection Matrix for the two geometries matches + *
          + *
        • [T*T******] (for P/L, P/A, and L/A situations) + *
        • [T*****T**] (for L/P, A/P, and A/L situations) + *
        • [0********] (for L/L situations) + *
        + *
      + * For any other combination of dimensions this predicate returns + * false. + *

      + * The SFS defined this predicate only for P/L, P/A, L/L, and L/A situations. + * JTS extends the definition to apply to L/P, A/P and A/L situations as well, + * in order to make the relation symmetric. + * + * @param {Geometry} + * g the Geometry with which to compare this + * Geometry. + * @return {boolean} true if the two Geometrys + * cross. + */ + crosses(g: Geometry): boolean; + + /** + * Tests whether this geometry is within the specified geometry. + *

      + * The within predicate has the following equivalent definitions: + *

        + *
      • Every point of this geometry is a point of the other geometry, and the + * interiors of the two geometries have at least one point in common. + *
      • The DE-9IM Intersection Matrix for the two geometries matches + * [T*F**F***] + *
      • g.contains(this) (within is the converse + * of contains) + *
      + * An implication of the definition is that "The boundary of a Geometry is not + * within the Geometry". In other words, if a geometry A is a subset of the + * points in the boundary of a geomtry B, A.within(B) = false + * + * @param {Geometry} + * g the Geometry with which to compare this + * Geometry. + * @return {boolean} true if this Geometry is + * within other. + * + * @see Geometry#contains + */ + within(g: Geometry): boolean; + + /** + * Tests whether this geometry contains the specified geometry. + *

      + * The contains predicate has the following equivalent + * definitions: + *

        + *
      • Every point of the other geometry is a point of this geometry, and the + * interiors of the two geometries have at least one point in common. + *
      • The DE-9IM Intersection Matrix for the two geometries matches + * [T*****FF*] + *
      • g.within(this) (contains is the converse + * of within) + *
      + * An implication of the definition is that "Geometries do not contain their + * boundary". In other words, if a geometry A is a subset of the points in the + * boundary of a geometry B, B.contains(A) = false + * + * @param {Geometry} + * g the Geometry with which to compare this + * Geometry. + * @return {boolean} true if this Geometry + * contains g. + * + * @see Geometry#within + */ + contains(g: Geometry): boolean; + + /** + * Tests whether this geometry overlaps the specified geometry. + *

      + * The overlaps predicate has the following equivalent + * definitions: + *

        + *
      • The geometries have at least one point each not shared by the other (or + * equivalently neither covers the other), they have the same dimension, and the + * intersection of the interiors of the two geometries has the same dimension as + * the geometries themselves. + *
      • The DE-9IM Intersection Matrix for the two geometries matches + * [T*T***T**] (for two points or two surfaces) or + * [1*T***T**] (for two curves) + *
      + * If the geometries are of different dimension this predicate returns + * false. + * + * @param {Geometry} + * g the Geometry with which to compare this + * Geometry. + * @return {boolean} true if the two Geometrys + * overlap. + */ + overlaps(g: Geometry): boolean; + + /** + * Tests whether this geometry covers the specified geometry. + *

      + * The covers predicate has the following equivalent definitions: + *

        + *
      • Every point of the other geometry is a point of this geometry. + *
      • The DE-9IM Intersection Matrix for the two geometries matches + * [T*****FF*] or [*T****FF*] or + * [***T**FF*] or [****T*FF*] + *
      • g.coveredBy(this) (covers is the converse + * of coveredBy) + *
      + * If either geometry is empty, the value of this predicate is false. + *

      + * This predicate is similar to {@link #contains}, but is more inclusive (i.e. + * returns true for more cases). In particular, unlike + * contains it does not distinguish between points in the + * boundary and in the interior of geometries. For most situations, + * covers should be used in preference to contains. + * As an added benefit, covers is more amenable to optimization, + * and hence should be more performant. + * + * @param {Geometry} + * g the Geometry with which to compare this + * Geometry. + * @return {boolean} true if this Geometry covers + * g. + * + * @see Geometry#contains + * @see Geometry#coveredBy + */ + covers(g: Geometry): boolean; + + /** + * Tests whether this geometry is covered by the specified geometry. + *

      + * The coveredBy predicate has the following equivalent + * definitions: + *

        + *
      • Every point of this geometry is a point of the other geometry. + *
      • The DE-9IM Intersection Matrix for the two geometries matches + * [T*F**F***] or [*TF**F***] or + * [**FT*F***] or [**F*TF***] + *
      • g.covers(this) (coveredBy is the converse + * of covers) + *
      + * If either geometry is empty, the value of this predicate is false. + *

      + * This predicate is similar to {@link #within}, but is more inclusive (i.e. + * returns true for more cases). + * + * @param {Geometry} + * g the Geometry with which to compare this + * Geometry. + * @return {boolean} true if this Geometry is + * covered by g. + * + * @see Geometry#within + * @see Geometry#covers + */ + coveredBy(g: Geometry): boolean; + + /** + * Tests whether the elements in the DE-9IM {@link IntersectionMatrix} for the + * two Geometrys match the elements in + * intersectionPattern. The pattern is a 9-character string, + * with symbols drawn from the following set: + *

        + *
      • 0 (dimension 0) + *
      • 1 (dimension 1) + *
      • 2 (dimension 2) + *
      • T ( matches 0, 1 or 2) + *
      • F ( matches FALSE) + *
      • * ( matches any value) + *
      + * For more information on the DE-9IM, see the OpenGIS Simple Features + * Specification. + * + * @param {Geometry} + * other the Geometry with which to compare this + * Geometry. + * @param {string} + * intersectionPattern the pattern against which to check the + * intersection matrix for the two Geometrys. + * @return {boolean} true if the DE-9IM intersection matrix for + * the two Geometrys match + * intersectionPattern. + * @see IntersectionMatrix + */ + relate(g: Geometry, intersectionPattern: string): boolean; + + /** + * Returns the DE-9IM {@link IntersectionMatrix} for the two + * Geometrys. + * + * @param {Geometry} + * g the Geometry with which to compare this + * Geometry. + * @return {IntersectionMatrix} an {@link IntersectionMatrix} describing the + * intersections of the interiors, boundaries and exteriors of the two + * Geometrys. + */ + relate2(g: Geometry): any; + + /** + * Tests whether this geometry is topologically equal to the argument geometry + * as defined by the SFS equals predicate. + *

      + * The SFS equals predicate has the following equivalent + * definitions: + *

        + *
      • The two geometries have at least one point in common, and no point of + * either geometry lies in the exterior of the other geometry. + *
      • The DE-9IM Intersection Matrix for the two geometries matches the + * pattern T*F**FFF* + *
        +             * T*F
        +             * **F
        +             * FF*
        +             * 
        + * + *
      + * Note that this method computes topologically equality. For + * structural equality, see {@link #equalsExact(Geometry)}. + * + * @param {Geometry} + * g the Geometry with which to compare this + * Geometry. + * @return {boolean} true if the two Geometrys + * are topologically equal. + * + * @see #equalsExact(Geometry) + */ + equalsTopo(g: Geometry): boolean; + + /** + * Tests whether this geometry is structurally and numerically equal to a given + * Object. If the argument Object is not a + * Geometry, the result is false. Otherwise, the result + * is computed using {@link #equalsExact(Geometry)}. + *

      + * This method is provided to fulfill the Java contract for value-based object + * equality. In conjunction with {@link #hashCode()} it provides semantics which + * are most useful for using Geometrys as keys and values in Java + * collections. + *

      + * Note that to produce the expected result the input geometries should be in + * normal form. It is the caller's responsibility to perform this where required + * (using {@link Geometry#norm() or {@link #normalize()} as appropriate). + * + * @param {Object} + * o the Object to compare. + * @return {boolean} true if this geometry is exactly equal to the argument. + * + * @see #equalsExact(Geometry) + * @see #hashCode() + * @see #norm() + * @see #normalize() + */ + equals(o: Object): boolean; + + /** + * Computes a buffer area around this geometry having the given width and with a + * specified accuracy of approximation for circular arcs, and using a specified + * end cap style. + *

      + * Mathematically-exact buffer area boundaries can contain circular arcs. To + * represent these arcs using linear geometry they must be approximated with + * line segments. The quadrantSegments argument allows + * controlling the accuracy of the approximation by specifying the number of + * line segments used to represent a quadrant of a circle + *

      + * The end cap style specifies the buffer geometry that will be created at the + * ends of linestrings. The styles provided are: + *

        + *
      • BufferOp.CAP_ROUND - (default) a semi-circle + *
      • BufferOp.CAP_BUTT - a straight line perpendicular to the end + * segment + *
      • BufferOp.CAP_SQUARE - a half-square + *
      + *

      + * The buffer operation always returns a polygonal result. The negative or + * zero-distance buffer of lines and points is always an empty {@link Polygon}. + * This is also the result for the buffers of degenerate (zero-area) polygons. + * + * @param {number} + * distance the width of the buffer (may be positive, negative or 0). + * @param {number} + * quadrantSegments the number of line segments used to represent a + * quadrant of a circle. + * @param {number} + * endCapStyle the end cap style to use. + * @return {Geometry} a polygonal geometry representing the buffer region (which + * may be empty). + * + * @throws TopologyException + * if a robustness error occurs + * + * @see #buffer(double) + * @see #buffer(double, int) + * @see BufferOp + */ + buffer(distance: number, quadrantSegments: number, endCapStyle: number): Geometry; + + /** + * Computes the smallest convex Polygon that contains all the + * points in the Geometry. This obviously applies only to + * Geometry s which contain 3 or more points; the results for + * degenerate cases are specified as follows: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
      Number of Points in argument Geometry + * Geometry class of result
      0 empty GeometryCollection
      1 Point
      2 LineString
      3 or more Polygon
      + * + * @return {Geometry} the minimum-area convex polygon containing this + * Geometry' s points. + */ + convexHull(): Geometry; + + /** + * Computes a Geometry representing the points shared by this + * Geometry and other. {@link GeometryCollection}s + * support intersection with homogeneous collection types, with the semantics + * that the result is a {@link GeometryCollection} of the intersection of each + * element of the target with the argument. + * + * @param {Geometry} + * other the Geometry with which to compute the + * intersection. + * @return {Geometry} the points common to the two Geometrys. + * @throws TopologyException + * if a robustness error occurs + * @throws IllegalArgumentException + * if the argument is a non-empty GeometryCollection + */ + intersection(other: Geometry): Geometry; + + /** + * Computes a Geometry representing all the points in this + * Geometry and other. + * + * Or without arguments: + * + * Computes the union of all the elements of this geometry. Heterogeneous + * {@link GeometryCollection}s are fully supported. + * + * The result obeys the following contract: + *

        + *
      • Unioning a set of {@link LineString}s has the effect of fully noding + * and dissolving the linework. + *
      • Unioning a set of {@link Polygon}s will always return a + * {@link Polygonal} geometry (unlike {link #union(Geometry)}, which may return + * geometrys of lower dimension if a topology collapse occurred. + *
      + * + * @param {Geometry} + * other the Geometry with which to compute the union. + * @return {Geometry} a set combining the points of this Geometry + * and the points of other. + * @throws TopologyException + * if a robustness error occurs + * @throws IllegalArgumentException + * if either input is a non-empty GeometryCollection + */ + union(other: Geometry): Geometry; + + /** + * Computes a Geometry representing the points making up this + * Geometry that do not make up other. This + * method returns the closure of the resultant Geometry. + * + * @param {Geometry} + * other the Geometry with which to compute the + * difference. + * @return {Geometry} the point set difference of this Geometry + * with other. + * @throws TopologyException + * if a robustness error occurs + * @throws IllegalArgumentException + * if either input is a non-empty GeometryCollection + */ + difference(other: Geometry): Geometry; + + /** + * Returns a set combining the points in this Geometry not in + * other, and the points in other not in this + * Geometry. This method returns the closure of the resultant + * Geometry. + * + * @param {Geometry} + * other the Geometry with which to compute the + * symmetric difference. + * @return {Geometry} the point set symmetric difference of this + * Geometry with other. + * @throws TopologyException + * if a robustness error occurs + * @throws IllegalArgumentException + * if either input is a non-empty GeometryCollection + */ + symDifference(other: Geometry): Geometry; + + /** + * Returns true if the two Geometrys are exactly equal, up to a + * specified distance tolerance. Two Geometries are exactly equal within a + * distance tolerance if and only if: + *
        + *
      • they have the same class + *
      • they have the same values for their vertices, within the given tolerance + * distance, in exactly the same order. + *
      + * If this and the other Geometrys are composites and any + * children are not Geometrys, returns false. + * + * @param {Geometry} + * other the Geometry with which to compare this + * Geometry. + * @param {number} + * tolerance distance at or below which two Coordinates + * are considered equal. + * @return {boolean} + */ + equalsExact(other: Geometry, tolerance: number): boolean; + + /** + * Tests whether two geometries are exactly equal in their normalized forms. + * This is a convenience method which creates normalized versions of both + * geometries before computing {@link #equalsExact(Geometry)}. This method is + * relatively expensive to compute. For maximum performance, the client should + * instead perform normalization itself at an appropriate point during + * execution. + * + * @param {Geometry} + * g a Geometry. + * @return {boolean} true if the input geometries are exactly equal in their + * normalized form. + */ + equalsNorm(g: Geometry): boolean; + + /** + * Performs an operation with or on this Geometry and its + * subelement Geometrys (if any). Only GeometryCollections and + * subclasses have subelement Geometry's. + * + * @param filter + * the filter to apply to this Geometry (and its + * children, if it is a GeometryCollection). + */ + apply(filter: any): void; + + /** + * Creates and returns a full copy of this {@link Geometry} object (including + * all coordinates contained by it). Subclasses are responsible for overriding + * this method and copying their internal data. Overrides should call this + * method first. + * + * @return a clone of this instance. + */ + clone(): Geometry; + + /** + * Converts this Geometry to normal form (or + * canonical form ). Normal form is a unique representation for + * Geometry s. It can be used to test whether two + * Geometrys are equal in a way that is independent of the + * ordering of the coordinates within them. Normal form equality is a stronger + * condition than topological equality, but weaker than pointwise equality. The + * definitions for normal form use the standard lexicographical ordering for + * coordinates. "Sorted in order of coordinates" means the obvious extension of + * this ordering to sequences of coordinates. + */ + normalize(): void; + + /** + * Creates a new Geometry which is a normalized copy of this Geometry. + * + * @return a normalized copy of this geometry. + * @see #normalize() + */ + norm(): Geometry; + + /** + * Returns whether this Geometry is greater than, equal to, or + * less than another Geometry. + *

      + * + * If their classes are different, they are compared using the following + * ordering: + *

        + *
      • Point (lowest) + *
      • MultiPoint + *
      • LineString + *
      • LinearRing + *
      • MultiLineString + *
      • Polygon + *
      • MultiPolygon + *
      • GeometryCollection (highest) + *
      + * If the two Geometrys have the same class, their first + * elements are compared. If those are the same, the second elements are + * compared, etc. + * + * @param {Geometry} + * other a Geometry with which to compare this + * Geometry. + * @return {number} a positive number, 0, or a negative number, depending on + * whether this object is greater than, equal to, or less than + * o, as defined in "Normal Form For Geometry" in the + * JTS Technical Specifications. + */ + compareTo(o: Geometry): number; + + /** + * Returns whether the two Geometrys are equal, from the point + * of view of the equalsExact method. Called by + * equalsExact . In general, two Geometry classes + * are considered to be "equivalent" only if they are the same class. An + * exception is LineString , which is considered to be equivalent + * to its subclasses. + * + * @param {Geometry} + * other the Geometry with which to compare this + * Geometry for equality. + * @return {boolean} true if the classes of the two + * Geometry s are considered to be equal by the + * equalsExact method. + */ + isEquivalentClass(other: Geometry): boolean; + + /** + * Throws an exception if g's class is + * GeometryCollection . (Its subclasses do not trigger an + * exception). + * + * @param {Geometry} + * g the Geometry to check. + * @throws Error + * if g is a GeometryCollection but not + * one of its subclasses + */ + checkNotGeometryCollection(g: Geometry): void; + + /** + * + * @return {boolean} true if this is a GeometryCollection. + */ + isGeometryCollection(): boolean; + + /** + * + * @return {boolean} true if this is a GeometryCollection but not subclass. + */ + isGeometryCollectionBase(): boolean; + + /** + * Returns the minimum and maximum x and y values in this Geometry, + * or a null Envelope if this Geometry is empty. + * Unlike getEnvelopeInternal, this method calculates the + * Envelope each time it is called; + * getEnvelopeInternal caches the result of this method. + * + * @return {Envelope} this Geometrys bounding box; if the + * Geometry is empty, Envelope#isNull will + * return true. + */ + computeEnvelopeInternal(): Envelope; + + /** + * Returns whether this Geometry is greater than, equal to, or + * less than another Geometry having the same class. + * + * @param o + * a Geometry having the same class as this + * Geometry. + * @return a positive number, 0, or a negative number, depending on whether this + * object is greater than, equal to, or less than o, as + * defined in "Normal Form For Geometry" in the JTS Technical + * Specifications. + */ + compareToSameClass(o: Geometry): number; + + /** + * Returns the first non-zero result of compareTo encountered as + * the two Collections are iterated over. If, by the time one of + * the iterations is complete, no non-zero result has been encountered, returns + * 0 if the other iteration is also complete. If b completes + * before a, a positive number is returned; if a before b, a + * negative number. + * + * @param {Array} + * a a Collection of Comparables. + * @param {Array} + * b a Collection of Comparables. + * @return {number} the first non-zero compareTo result, if any; + * otherwise, zero. + */ + compare(a: Array, b: Array): number; + + /** + * @param {jsts.geom.Coordinate} + * a first Coordinate to compare. + * @param {jsts.geom.Coordinate} + * b second Coordinate to compare. + * @param {number} + * tolerance tolerance when comparing. + * @return {boolean} true if equal. + */ + equal(a: Coordinate, b: Coordinate, tolerance: number): boolean; + + /** + * Returns a WKT representation of this geometry. + */ + toString(): string; + } + + /** + * Models an OGC SFS LinearRing. A LinearRing is a LineString + * which is both closed and simple. In other words, the first and last + * coordinate in the ring must be equal, and the interior of the ring must not + * self-intersect. Either orientation of the ring is allowed. + *

      + * A ring must have either 0 or 4 or more points. The first and last points + * must be equal (in 2D). If these conditions are not met, the constructors + * throw an {@link IllegalArgumentException} + */ + export class LinearRing extends LineString { + } + + export class LineString extends Geometry { + /** + * @constructor + */ + constructor(points: Array, factory?: any); + + /** + * @return {jsts.geom.Coordinate} The n'th coordinate of this + * jsts.geom.LineString. + * @param {int} + * n index. + */ + getCoordinateN(n: number): Coordinate; + + /** + * @return {jsts.geom.Point} The n'th point of this + * jsts.geom.LineString. + * @param {int} + * n index. + */ + getPointN(n: number): Point; + + /** + * @return {jsts.geom.Point} The first point of this + * jsts.geom.LineString. + */ + getStartPoint(): Point; + + /** + * @return {jsts.geom.Point} The last point of this + * jsts.geom.LineString. + */ + getEndPoint(): Point; + + /** + * @return {Boolean} true if LineString is Closed. + */ + isClosed(): boolean; + + /** + * @return {Boolean} true if LineString is a Ring. + */ + isRing(): boolean; + } + + export class Point extends Geometry { + /** + * @constructor + */ + constructor(coordinate: Coordinate, factory?: any); + + /** + * @return {number} x-axis value of this Point. + */ + getX(): number; + + /** + * @return {number} y-axis value of this Point. + */ + getY(): number; + + /** + * @return {Point} Reversed point is a cloned point. + */ + reverse(): Point; + } + + /** + * Represents a linear polygon, which may include holes. The shell and holes + * of the polygon are represented by {@link LinearRing}s. In a valid polygon, + * holes may touch the shell or other holes at a single point. However, no + * sequence of touching holes may split the polygon into two pieces. The + * orientation of the rings in the polygon does not matter. + * + * The shell and holes must conform to the assertions specified in the OpenGIS Simple Features + * Specification for SQL. + */ + export class Polygon extends Geometry { + /** + * @constructor + */ + constructor(shell: LinearRing, holes?: Array, factory?: any); + + /** + * Gets the exterior ring. + * + * @return {LinearRing} The exterior ring. + */ + getExteriorRing(): LinearRing; + + /** + * Gets the interior ring at the specified index. + * + * @param {number} n The interior ring index. + * + * @returns {LinearRing} The interior ring at the specified index. + */ + getInteriorRingN(n: number): LinearRing; + + /** + * Gets the number of interior rings. + * + * @return {number} The number of interior rings. + */ + getNumInteriorRing(): number; + } + } + + module io { + export class GeoJSONWriter { + /** + * Writes the GeoJSON representation of a {@link Geometry}. The + * The GeoJSON format is defined here. + *

      + * The GeoJSONWriter outputs coordinates rounded to the precision + * model. Only the maximum number of decimal places necessary to represent the + * ordinates to the required precision will be output. + *

      + * + * @see WKTReader + * @constructor + */ + constructor(); + + /** + * Converts a Geometry to its GeoJSON representation. + * + * @param {jsts.geom.Geometry} + * geometry a Geometry to process. + * @return {Object} The GeoJSON representation of the Geometry. + */ + write(geometry: geom.Geometry): Object; + } + + /** + * Converts a geometry in Well-Known Text format to a {@link Geometry}. + *

      + * WKTReader supports extracting Geometry objects + * from either {@link Reader}s or {@link String}s. This allows it to function + * as a parser to read Geometry objects from text blocks embedded + * in other data formats (e.g. XML). + *

      + *

      + * A WKTReader is parameterized by a GeometryFactory, + * to allow it to create Geometry objects of the appropriate + * implementation. In particular, the GeometryFactory determines + * the PrecisionModel and SRID that is used. + *

      + */ + export class WKTReader { + /** + * @constructor + */ + constructor(geometryFactory?: any); + + /** + * Reads a Well-Known Text representation of a {@link Geometry} + * + * @param {string} + * wkt a string (see the OpenGIS Simple Features + * Specification). + * @return {jsts.geom.Geometry} a Geometry read from + * string. + */ + read(wkt: string): geom.Geometry; + + reducePrecision(geometry: geom.Geometry): void; + } + } +} \ No newline at end of file From aa3f2581c70867f64f02ef15adc6ce86367af103 Mon Sep 17 00:00:00 2001 From: Aleksei Barbarosh Date: Fri, 16 Oct 2015 21:03:08 +0300 Subject: [PATCH 0110/1238] Update function scope. Add missed function toBeDefined. --- jest/jest.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/jest/jest.d.ts b/jest/jest.d.ts index d500525b63..2ee7657283 100644 --- a/jest/jest.d.ts +++ b/jest/jest.d.ts @@ -40,6 +40,7 @@ declare module jest { toBeFalsy(): boolean; toBeTruthy(): boolean; toBeNull(): boolean; + toBeDefined(): boolean; toBeUndefined(): boolean; toMatch(expected: RegExp): boolean; toContain(expected: string): boolean; From cdd23d1c610cc97f38bcd6e402b6da5edeea1bae Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Fri, 16 Oct 2015 13:21:46 -0700 Subject: [PATCH 0111/1238] Angular 2 typings are now distributed via NPM --- angular2/angular2-tests.ts | 42 +- angular2/angular2-tests.ts.tscparams | 1 - angular2/angular2.d.ts | 17110 +------------------------ angular2/http.d.ts | 1310 -- angular2/router.d.ts | 1330 -- angular2/test_lib.d.ts | 408 - 6 files changed, 10 insertions(+), 20191 deletions(-) delete mode 100644 angular2/angular2-tests.ts.tscparams delete mode 100644 angular2/http.d.ts delete mode 100644 angular2/router.d.ts delete mode 100644 angular2/test_lib.d.ts diff --git a/angular2/angular2-tests.ts b/angular2/angular2-tests.ts index a39cdcf79f..1c64de9d74 100644 --- a/angular2/angular2-tests.ts +++ b/angular2/angular2-tests.ts @@ -1,43 +1,3 @@ /// -/// -import {Component, View, Directive, bootstrap, bind, NgFor, NgIf} from "angular2/angular2"; - -class Service { - -} -class Service2 { - -} - -class Cmp { - static annotations: any[]; -} -Cmp.annotations = [ - Component({ - selector: 'cmp', - bindings: [Service, bind(Service2).toValue(null)] - }), - View({ - template: '{{greeting}} world!', - directives: [NgFor, NgIf] - }), - Directive({ - selector: '[tooltip]', - inputs: [ - 'text: tooltip' - ], - outputs: [ - '(mouseenter):onMouseEnter()', - '(mouseleave):onMouseLeave()' - ] - }) -]; - -@Component({selector: 'cmp2'}) -@View({templateUrl: '/index.html'}) -class Cmp2 { - -} - -bootstrap(Cmp); +// No tests, because angular 2 typings are not in DefinitelyTyped. \ No newline at end of file diff --git a/angular2/angular2-tests.ts.tscparams b/angular2/angular2-tests.ts.tscparams deleted file mode 100644 index 3f0863ac67..0000000000 --- a/angular2/angular2-tests.ts.tscparams +++ /dev/null @@ -1 +0,0 @@ ---experimentalDecorators --noImplicitAny --target ES5 diff --git a/angular2/angular2.d.ts b/angular2/angular2.d.ts index 616157aaf6..3560809982 100644 --- a/angular2/angular2.d.ts +++ b/angular2/angular2.d.ts @@ -1,17105 +1,13 @@ -// Type definitions for Angular v2.0.0-39 +// Type definitions for Angular 2 // Project: http://angular.io/ // Definitions by: angular team // Definitions: https://github.com/borisyankov/DefinitelyTyped -// *********************************************************** -// This file is generated by the Angular build process. -// Please do not create manual edits or send pull requests -// modifying this file. -// *********************************************************** - -// angular2/angular2 depends transitively on these libraries. -// If you don't have them installed you can install them using TSD -// https://github.com/DefinitelyTyped/tsd - -/// -// angular2/web_worker/worker depends transitively on these libraries. -// If you don't have them installed you can install them using TSD -// https://github.com/DefinitelyTyped/tsd - -/// -// angular2/web_worker/ui depends transitively on these libraries. -// If you don't have them installed you can install them using TSD -// https://github.com/DefinitelyTyped/tsd - -/// - - -interface Map {} - - -declare module ng { - // See https://github.com/Microsoft/TypeScript/issues/1168 - class BaseException /* extends Error */ { - message: string; - stack: string; - toString(): string; - } - interface InjectableReference {} -} - -declare module ngWorker { - // See https://github.com/Microsoft/TypeScript/issues/1168 - class BaseException /* extends Error */ { - message: string; - stack: string; - toString(): string; - } - interface InjectableReference {} -} - -declare module ngUi { - // See https://github.com/Microsoft/TypeScript/issues/1168 - class BaseException /* extends Error */ { - message: string; - stack: string; - toString(): string; - } - interface InjectableReference {} -} - - - - -declare module ng { - /** - * Declares an injectable parameter to be a live list of directives or variable - * bindings from the content children of a directive. - * - * ### Example ([live demo](http://plnkr.co/edit/lY9m8HLy7z06vDoUaSN2?p=preview)) - * - * Assume that `` component would like to get a list its children `` - * components as shown in this example: - * - * ```html - * - * ... - * {{o.text}} - * - * ``` - * - * The preferred solution is to query for `Pane` directives using this decorator. - * - * ```javascript - * @Component({ - * selector: 'pane', - * inputs: ['title'] - * }) - * @View(...) - * class Pane { - * title:string; - * } - * - * @Component({ - * selector: 'tabs' - * }) - * @View({ - * template: ` - *

        - *
      • {{pane.title}}
      • - *
      - * - * ` - * }) - * class Tabs { - * panes: QueryList; - * constructor(@Query(Pane) panes:QueryList) { - * this.panes = panes; - * } - * } - * ``` - * - * A query can look for variable bindings by passing in a string with desired binding symbol. - * - * ### Example ([live demo](http://plnkr.co/edit/sT2j25cH1dURAyBRCKx1?p=preview)) - * ```html - * - *
      ...
      - *
      - * - * @Component({ - * selector: 'foo' - * }) - * @View(...) - * class seeker { - * constructor(@Query('findme') elList: QueryList) {...} - * } - * ``` - * - * In this case the object that is injected depend on the type of the variable - * binding. It can be an ElementRef, a directive or a component. - * - * Passing in a comma separated list of variable bindings will query for all of them. - * - * ```html - * - *
      ...
      - *
      ...
      - *
      - * - * @Component({ - * selector: 'foo' - * }) - * @View(...) - * class Seeker { - * constructor(@Query('findMe, findMeToo') elList: QueryList) {...} - * } - * ``` - * - * Configure whether query looks for direct children or all descendants - * of the querying element, by using the `descendants` parameter. - * It is set to `false` by default. - * - * ### Example ([live demo](http://plnkr.co/edit/wtGeB977bv7qvA5FTYl9?p=preview)) - * ```html - * - * a - * b - * - * c - * - * - * ``` - * - * When querying for items, the first container will see only `a` and `b` by default, - * but with `Query(TextDirective, {descendants: true})` it will see `c` too. - * - * The queried directives are kept in a depth-first pre-order with respect to their - * positions in the DOM. - * - * Query does not look deep into any subcomponent views. - * - * Query is updated as part of the change-detection cycle. Since change detection - * happens after construction of a directive, QueryList will always be empty when observed in the - * constructor. - * - * The injected object is an unmodifiable live list. - * See {@link QueryList} for more details. - */ - class QueryMetadata extends DependencyMetadata { - - constructor(_selector: Type | string, {descendants, first}?: {descendants?: boolean, first?: boolean}); - - /** - * whether we want to query only direct children (false) or all - * children (true). - */ - descendants: boolean; - - first: boolean; - - /** - * always `false` to differentiate it with {@link ViewQueryMetadata}. - */ - isViewQuery: boolean; - - /** - * what this is querying for. - */ - selector: any; - - /** - * whether this is querying for a variable binding or a directive. - */ - isVarBindingQuery: boolean; - - /** - * returns a list of variable bindings this is querying for. - * Only applicable if this is a variable bindings query. - */ - varBindings: string[]; - - toString(): string; - - } - - - /** - * Configures a content query. - * - * Content queries are set before the `afterContentInit` callback is called. - * - * ### Example - * - * ``` - * @Directive({ - * selector: 'someDir' - * }) - * class SomeDir { - * @ContentChildren(ChildDirective) contentChildren: QueryList; - * - * afterContentInit() { - * // contentChildren is set - * } - * } - * ``` - */ - class ContentChildrenMetadata extends QueryMetadata { - - constructor(_selector: Type | string, {descendants}?: {descendants?: boolean}); - - } - - - /** - * Configures a content query. - * - * Content queries are set before the `afterContentInit` callback is called. - * - * ### Example - * - * ``` - * @Directive({ - * selector: 'someDir' - * }) - * class SomeDir { - * @ContentChild(ChildDirective) contentChild; - * - * afterContentInit() { - * // contentChild is set - * } - * } - * ``` - */ - class ContentChildMetadata extends QueryMetadata { - - constructor(_selector: Type | string); - - } - - - /** - * Configures a view query. - * - * View queries are set before the `afterViewInit` callback is called. - * - * ### Example - * - * ``` - * @Component({ - * selector: 'someDir' - * }) - * @View({templateUrl: 'someTemplate', directives: [ItemDirective]}) - * class SomeDir { - * @ViewChildren(ItemDirective) viewChildren: QueryList; - * - * afterViewInit() { - * // viewChildren is set - * } - * } - * ``` - */ - class ViewChildrenMetadata extends ViewQueryMetadata { - - constructor(_selector: Type | string); - - } - - - /** - * Similar to {@link QueryMetadata}, but querying the component view, instead of - * the content children. - * - * ### Example ([live demo](http://plnkr.co/edit/eNsFHDf7YjyM6IzKxM1j?p=preview)) - * - * ```javascript - * @Component({...}) - * @View({ - * template: ` - * a - * b - * c - * ` - * }) - * class MyComponent { - * shown: boolean; - * - * constructor(private @Query(Item) items:QueryList) { - * items.onChange(() => console.log(items.length)); - * } - * } - * ``` - * - * Supports the same querying parameters as {@link QueryMetadata}, except - * `descendants`. This always queries the whole view. - * - * As `shown` is flipped between true and false, items will contain zero of one - * items. - * - * Specifies that a {@link QueryList} should be injected. - * - * The injected object is an iterable and observable live list. - * See {@link QueryList} for more details. - */ - class ViewQueryMetadata extends QueryMetadata { - - constructor(_selector: Type | string, {descendants, first}?: {descendants?: boolean, first?: boolean}); - - /** - * always `true` to differentiate it with {@link QueryMetadata}. - */ - isViewQuery: any; - - toString(): string; - - } - - - /** - * Configures a view query. - * - * View queries are set before the `afterViewInit` callback is called. - * - * ### Example - * - * ``` - * @Component({ - * selector: 'someDir' - * }) - * @View({templateUrl: 'someTemplate', directives: [ItemDirective]}) - * class SomeDir { - * @ViewChild(ItemDirective) viewChild:ItemDirective; - * - * afterViewInit() { - * // viewChild is set - * } - * } - * ``` - */ - class ViewChildMetadata extends ViewQueryMetadata { - - constructor(_selector: Type | string); - - } - - - /** - * Specifies that a constant attribute value should be injected. - * - * The directive can inject constant string literals of host element attributes. - * - * ## Example - * - * Suppose we have an `` element and want to know its `type`. - * - * ```html - * - * ``` - * - * A decorator can inject string literal `text` like so: - * - * ```javascript - * @Directive({ - * selector: `input' - * }) - * class InputDirective { - * constructor(@Attribute('type') type) { - * // type would be `text` in this example - * } - * } - * ``` - */ - class AttributeMetadata extends DependencyMetadata { - - constructor(attributeName: string); - - attributeName: string; - - token: any; - - toString(): string; - - } - - - /** - * Declare reusable UI building blocks for an application. - * - * Each Angular component requires a single `@Component` and at least one `@View` annotation. The - * `@Component` - * annotation specifies when a component is instantiated, and which properties and hostListeners it - * binds to. - * - * When a component is instantiated, Angular - * - creates a shadow DOM for the component. - * - loads the selected template into the shadow DOM. - * - creates all the injectable objects configured with `bindings` and `viewBindings`. - * - * All template expressions and statements are then evaluated against the component instance. - * - * For details on the `@View` annotation, see {@link ViewMetadata}. - * - * ## Lifecycle hooks - * - * When the component class implements some {@link angular2/lifecycle_hooks} the callbacks are - * called by the change detection at defined points in time during the life of the component. - * - * ## Example - * - * ``` - * @Component({ - * selector: 'greet' - * }) - * @View({ - * template: 'Hello {{name}}!' - * }) - * class Greet { - * name: string; - * - * constructor() { - * this.name = 'World'; - * } - * } - * ``` - */ - class ComponentMetadata extends DirectiveMetadata { - - constructor({selector, inputs, outputs, properties, events, host, exportAs, moduleId, bindings, - viewBindings, changeDetection, queries}?: { - selector?: string, - inputs?: string[], - outputs?: string[], - properties?: string[], - events?: string[], - host?: {[key: string]: string}, - bindings?: any[], - exportAs?: string, - moduleId?: string, - viewBindings?: any[], - queries?: {[key: string]: any}, - changeDetection?: ChangeDetectionStrategy, - }); - - /** - * Defines the used change detection strategy. - * - * When a component is instantiated, Angular creates a change detector, which is responsible for - * propagating the component's bindings. - * - * The `changeDetection` property defines, whether the change detection will be checked every time - * or only when the component tells it to do so. - */ - changeDetection: ChangeDetectionStrategy; - - /** - * Defines the set of injectable objects that are visible to its view DOM children. - * - * ## Simple Example - * - * Here is an example of a class that can be injected: - * - * ``` - * class Greeter { - * greet(name:string) { - * return 'Hello ' + name + '!'; - * } - * } - * - * @Directive({ - * selector: 'needs-greeter' - * }) - * class NeedsGreeter { - * greeter:Greeter; - * - * constructor(greeter:Greeter) { - * this.greeter = greeter; - * } - * } - * - * @Component({ - * selector: 'greet', - * viewBindings: [ - * Greeter - * ] - * }) - * @View({ - * template: ``, - * directives: [NeedsGreeter] - * }) - * class HelloWorld { - * } - * - * ``` - */ - viewBindings: any[]; - - } - - - /** - * Directives allow you to attach behavior to elements in the DOM. - * - * {@link DirectiveMetadata}s with an embedded view are called {@link ComponentMetadata}s. - * - * A directive consists of a single directive annotation and a controller class. When the - * directive's `selector` matches - * elements in the DOM, the following steps occur: - * - * 1. For each directive, the `ElementInjector` attempts to resolve the directive's constructor - * arguments. - * 2. Angular instantiates directives for each matched element using `ElementInjector` in a - * depth-first order, - * as declared in the HTML. - * - * ## Understanding How Injection Works - * - * There are three stages of injection resolution. - * - *Pre-existing Injectors*: - * - The terminal {@link Injector} cannot resolve dependencies. It either throws an error or, if - * the dependency was - * specified as `@Optional`, returns `null`. - * - The platform injector resolves browser singleton resources, such as: cookies, title, - * location, and others. - * - *Component Injectors*: Each component instance has its own {@link Injector}, and they follow - * the same parent-child hierarchy - * as the component instances in the DOM. - * - *Element Injectors*: Each component instance has a Shadow DOM. Within the Shadow DOM each - * element has an `ElementInjector` - * which follow the same parent-child hierarchy as the DOM elements themselves. - * - * When a template is instantiated, it also must instantiate the corresponding directives in a - * depth-first order. The - * current `ElementInjector` resolves the constructor dependencies for each directive. - * - * Angular then resolves dependencies as follows, according to the order in which they appear in the - * {@link ViewMetadata}: - * - * 1. Dependencies on the current element - * 2. Dependencies on element injectors and their parents until it encounters a Shadow DOM boundary - * 3. Dependencies on component injectors and their parents until it encounters the root component - * 4. Dependencies on pre-existing injectors - * - * - * The `ElementInjector` can inject other directives, element-specific special objects, or it can - * delegate to the parent - * injector. - * - * To inject other directives, declare the constructor parameter as: - * - `directive:DirectiveType`: a directive on the current element only - * - `@Host() directive:DirectiveType`: any directive that matches the type between the current - * element and the - * Shadow DOM root. - * - `@Query(DirectiveType) query:QueryList`: A live collection of direct child - * directives. - * - `@QueryDescendants(DirectiveType) query:QueryList`: A live collection of any - * child directives. - * - * To inject element-specific special objects, declare the constructor parameter as: - * - `element: ElementRef` to obtain a reference to logical element in the view. - * - `viewContainer: ViewContainerRef` to control child template instantiation, for - * {@link DirectiveMetadata} directives only - * - `bindingPropagation: BindingPropagation` to control change detection in a more granular way. - * - * ## Example - * - * The following example demonstrates how dependency injection resolves constructor arguments in - * practice. - * - * - * Assume this HTML template: - * - * ``` - *
      - *
      - *
      - *
      - *
      - *
      - *
      - *
      - *
      - *
      - * ``` - * - * With the following `dependency` decorator and `SomeService` injectable class. - * - * ``` - * @Injectable() - * class SomeService { - * } - * - * @Directive({ - * selector: '[dependency]', - * inputs: [ - * 'id: dependency' - * ] - * }) - * class Dependency { - * id:string; - * } - * ``` - * - * Let's step through the different ways in which `MyDirective` could be declared... - * - * - * ### No injection - * - * Here the constructor is declared with no arguments, therefore nothing is injected into - * `MyDirective`. - * - * ``` - * @Directive({ selector: '[my-directive]' }) - * class MyDirective { - * constructor() { - * } - * } - * ``` - * - * This directive would be instantiated with no dependencies. - * - * - * ### Component-level injection - * - * Directives can inject any injectable instance from the closest component injector or any of its - * parents. - * - * Here, the constructor declares a parameter, `someService`, and injects the `SomeService` type - * from the parent - * component's injector. - * ``` - * @Directive({ selector: '[my-directive]' }) - * class MyDirective { - * constructor(someService: SomeService) { - * } - * } - * ``` - * - * This directive would be instantiated with a dependency on `SomeService`. - * - * - * ### Injecting a directive from the current element - * - * Directives can inject other directives declared on the current element. - * - * ``` - * @Directive({ selector: '[my-directive]' }) - * class MyDirective { - * constructor(dependency: Dependency) { - * expect(dependency.id).toEqual(3); - * } - * } - * ``` - * This directive would be instantiated with `Dependency` declared at the same element, in this case - * `dependency="3"`. - * - * ### Injecting a directive from any ancestor elements - * - * Directives can inject other directives declared on any ancestor element (in the current Shadow - * DOM), i.e. on the current element, the - * parent element, or its parents. - * ``` - * @Directive({ selector: '[my-directive]' }) - * class MyDirective { - * constructor(@Host() dependency: Dependency) { - * expect(dependency.id).toEqual(2); - * } - * } - * ``` - * - * `@Host` checks the current element, the parent, as well as its parents recursively. If - * `dependency="2"` didn't - * exist on the direct parent, this injection would - * have returned - * `dependency="1"`. - * - * - * ### Injecting a live collection of direct child directives - * - * - * A directive can also query for other child directives. Since parent directives are instantiated - * before child directives, a directive can't simply inject the list of child directives. Instead, - * the directive injects a {@link QueryList}, which updates its contents as children are added, - * removed, or moved by a directive that uses a {@link ViewContainerRef} such as a `ng-for`, an - * `ng-if`, or an `ng-switch`. - * - * ``` - * @Directive({ selector: '[my-directive]' }) - * class MyDirective { - * constructor(@Query(Dependency) dependencies:QueryList) { - * } - * } - * ``` - * - * This directive would be instantiated with a {@link QueryList} which contains `Dependency` 4 and - * 6. Here, `Dependency` 5 would not be included, because it is not a direct child. - * - * ### Injecting a live collection of descendant directives - * - * By passing the descendant flag to `@Query` above, we can include the children of the child - * elements. - * - * ``` - * @Directive({ selector: '[my-directive]' }) - * class MyDirective { - * constructor(@Query(Dependency, {descendants: true}) dependencies:QueryList) { - * } - * } - * ``` - * - * This directive would be instantiated with a Query which would contain `Dependency` 4, 5 and 6. - * - * ### Optional injection - * - * The normal behavior of directives is to return an error when a specified dependency cannot be - * resolved. If you - * would like to inject `null` on unresolved dependency instead, you can annotate that dependency - * with `@Optional()`. - * This explicitly permits the author of a template to treat some of the surrounding directives as - * optional. - * - * ``` - * @Directive({ selector: '[my-directive]' }) - * class MyDirective { - * constructor(@Optional() dependency:Dependency) { - * } - * } - * ``` - * - * This directive would be instantiated with a `Dependency` directive found on the current element. - * If none can be - * found, the injector supplies `null` instead of throwing an error. - * - * ## Example - * - * Here we use a decorator directive to simply define basic tool-tip behavior. - * - * ``` - * @Directive({ - * selector: '[tooltip]', - * inputs: [ - * 'text: tooltip' - * ], - * host: { - * '(mouseenter)': 'onMouseEnter()', - * '(mouseleave)': 'onMouseLeave()' - * } - * }) - * class Tooltip{ - * text:string; - * overlay:Overlay; // NOT YET IMPLEMENTED - * overlayManager:OverlayManager; // NOT YET IMPLEMENTED - * - * constructor(overlayManager:OverlayManager) { - * this.overlay = overlay; - * } - * - * onMouseEnter() { - * // exact signature to be determined - * this.overlay = this.overlayManager.open(text, ...); - * } - * - * onMouseLeave() { - * this.overlay.close(); - * this.overlay = null; - * } - * } - * ``` - * In our HTML template, we can then add this behavior to a `
      ` or any other element with the - * `tooltip` selector, - * like so: - * - * ``` - *
      - * ``` - * - * Directives can also control the instantiation, destruction, and positioning of inline template - * elements: - * - * A directive uses a {@link ViewContainerRef} to instantiate, insert, move, and destroy views at - * runtime. - * The {@link ViewContainerRef} is created as a result of `