From 6a02cedcf0a68b7d46c45f588427a6a4965f4ba4 Mon Sep 17 00:00:00 2001 From: Alvaro Dias Date: Sun, 13 Sep 2015 04:49:18 -0700 Subject: [PATCH 01/87] 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 58fb4f6f1..113ead635 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 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 02/87] 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 d4a3000cb..0b6c2f714 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 000000000..52c4f27ee --- /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 03/87] 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 000000000..9ffcd1853 --- /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 da423b45597264225413158966ac1278e5ec62f8 Mon Sep 17 00:00:00 2001 From: Brandon Luong Date: Fri, 2 Oct 2015 16:45:49 -0700 Subject: [PATCH 04/87] 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 b109893a3..da60a5c53 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 29712c115..67724068f 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 05/87] 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 ed3e1e2a8..c8108d1b9 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 67724068f..26b2f1d0f 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 0be6de745e7ed0374ad64299bc5afbc1b3ceb800 Mon Sep 17 00:00:00 2001 From: jessesh Date: Mon, 5 Oct 2015 13:24:59 -0700 Subject: [PATCH 06/87] 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 195ecb66e..acf6802bf 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 07/87] 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 acf6802bf..903019698 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 2ae4b96283a813e22f25c13a70f577866ec2de94 Mon Sep 17 00:00:00 2001 From: Roger Chen Date: Mon, 12 Oct 2015 15:27:34 -0700 Subject: [PATCH 08/87] 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 de8ba6732..ba86c4690 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 09/87] 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 000000000..bd90bfe4c --- /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 000000000..9ff7c3a08 --- /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 10/87] 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 bd90bfe4c..e8dd64d2b 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 9ff7c3a08..562fa210f 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 11/87] 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 e8dd64d2b..bd90bfe4c 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 562fa210f..9ff7c3a08 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 8be1e783befd89f43cf62907dab718a9a33a18d9 Mon Sep 17 00:00:00 2001 From: Jared Klopper Date: Wed, 14 Oct 2015 13:39:09 +1300 Subject: [PATCH 12/87] 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 93be9f6d4..9490d0320 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 29712c115..28fedc65e 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 13/87] 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 e94e5271c..a6911e302 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 2c65a7cf4..22b721b9a 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 14/87] 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 3ec31968c..1164079e7 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 15/87] 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 000000000..0cd6a0c98 --- /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 000000000..fec2fbf3c --- /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 16/87] 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 a8f268074..cab51f72c 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 0159e32ca7e4b549ba0c962189680d7c833b3e5d Mon Sep 17 00:00:00 2001 From: voximplant Date: Wed, 14 Oct 2015 14:57:55 +0300 Subject: [PATCH 17/87] Initial commit --- voximplant-websdk/voximplant-websdk-tests.ts | 85 ++ voximplant-websdk/voximplant-websdk.d.ts | 1165 ++++++++++++++++++ 2 files changed, 1250 insertions(+) create mode 100644 voximplant-websdk/voximplant-websdk-tests.ts create mode 100644 voximplant-websdk/voximplant-websdk.d.ts diff --git a/voximplant-websdk/voximplant-websdk-tests.ts b/voximplant-websdk/voximplant-websdk-tests.ts new file mode 100644 index 000000000..2a9363c37 --- /dev/null +++ b/voximplant-websdk/voximplant-websdk-tests.ts @@ -0,0 +1,85 @@ +/// + +var vox: VoxImplant.Client = VoxImplant.getInstance(), + call: VoxImplant.Call; + +vox.init({ + micRequired: true +}); + +vox.addEventListener("SDKReady", function(event: VoxImplant.Events.SDKReady) { + console.log("VoxImplant SDK ver. " + event.version + " initialized"); + vox.connect(); +}); + +vox.addEventListener("ConnectionEstablished", function(event: VoxImplant.Events.ConnectionEstablished) { + console.log("Connection established"); + vox.login("username", "password"); +}); + +vox.addEventListener("ConnectionClosed", function(event: VoxImplant.Events.ConnectionClosed) { + console.log("Connection closed"); +}); + +vox.addEventListener("ConnectionFailed", function(event: VoxImplant.Events.ConnectionFailed) { + console.log("Connection failed. Reason: " + event.message); +}); + +vox.addEventListener("AuthEvent", function(event: VoxImplant.Events.AuthEvent) { + if (event.result === true) { + // Authorized successfully + console.log("Logged in as " + event.displayName); + + call = vox.call("some_number", false); + call.addEventListener("Connected", function(callevent: VoxImplant.CallEvents.Connected) { + console.log("Call connected"); + }); + call.addEventListener("Failed", function(callevent: VoxImplant.CallEvents.Failed) { + console.log("Call failed, reason: " + callevent.reason); + }); + call.addEventListener("Disconnected", function(callevent: VoxImplant.CallEvents.Disconnected) { + console.log("Call disconnected"); + }); + + var msg_id:String = vox.sendInstantMessage("other_user", "Hello World!"); + + } else { + console.log("Authorization failed. Code: " + event.code); + } +}); + +vox.addEventListener("MicAccessResult", function(event: VoxImplant.Events.MicAccessResult) { + console.log("Microphone access allowed: " + event.result); +}); + +vox.addEventListener("IncomingCall", function(event: VoxImplant.Events.IncomingCall) { + call = event.call; + call.addEventListener("Connected", function(callevent: VoxImplant.CallEvents.Connected) { + console.log("Inbound Call Connected"); + setTimeout(function() { + vox.disconnect(); + }, 5000); + }); + call.answer(); +}); + +vox.addEventListener("MessageReceived", function(event: VoxImplant.IMEvents.MessageReceived) { + console.log("Message received: " + event.content + " from " + event.id + " id " + event.message_id); +}); + +vox.addEventListener("SourcesInfoUpdated", function(event: VoxImplant.Events.SourcesInfoUpdated) { + var audioSources: VoxImplant.AudioSourceInfo[] = vox.audioSources(), + videoSources: VoxImplant.VideoSourceInfo[] = vox.videoSources(); + console.log("Received recording sources data:"); + console.log("Audio: " + audioSources); + console.log("Video: " + videoSources); + + vox.useAudioSource(audioSources[0].id, function() { console.log('OK'); }, function() { console.log('Failed'); }); + vox.useVideoSource(videoSources[0].id, function() { console.log('OK'); }, function() { console.log('Failed'); }); +}); + +vox.addEventListener("RosterReceived", function(event: VoxImplant.IMEvents.RosterReceived) { + var roster: VoxImplant.RosterItem[] = event.roster; + console.log("Roster received: " + roster); +}); + diff --git a/voximplant-websdk/voximplant-websdk.d.ts b/voximplant-websdk/voximplant-websdk.d.ts new file mode 100644 index 000000000..1609b6e70 --- /dev/null +++ b/voximplant-websdk/voximplant-websdk.d.ts @@ -0,0 +1,1165 @@ +// Type definitions for VoxImplant Web SDK 3.0.x +// Project: http://voximplant.com/ +// Definitions by: Alexey Aylarov +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module VoxImplant { + + module Events { + + /** + * Event dispatched after login , loginWithOneTimeKey, requestOneTimeLoginKey or loginWithCode function call + */ + interface AuthEvent { + /** + * Auth error code, possible values are: 301 - code for 'code' auth type was sent, 302 - key for 'onetimekey' auth type received, 401 - invalid password, 404 - invalid username, 403 - user account is frozen, 500 - internal error + */ + code? : number; + /** + * Authorized user's display name + */ + displayName?: string; + /** + * This parameter is used to calculate hash parameter for loginWithOneTimeKey method. AuthEvent with the key dispatched after requestOneTimeLoginKey method was called + */ + key?: string; + /** + * Application options + */ + options?: Object; + /** + * True in case of successful authorization, false - otherwise + */ + result: boolean; + } + + /** + * Event dispatched if connection to VoxImplant Cloud was closed because of network problems. See connect function + */ + interface ConnectionClosed {} + + /** + * Event dispatched after connection to VoxImplant Cloud was established successfully. See connect function + */ + interface ConnectionEstablished {} + + /** + * Event dispatched if connection to VoxImplant Cloud couldn't be established. See connect function + */ + interface ConnectionFailed { + /** + * Failure reason description + */ + message: string; + } + + /** + * Event dispatched in case of instant messaging subsystem error + */ + interface IMError { + /** + * Error data object, contains the error details + */ + errorData: Object; + /** + * Error type + */ + errorType: IMErrorType; + } + + /** + * Event dispatched when there is a new incoming call to current user + */ + interface IncomingCall { + /** + * Incoming call instance. See VoxImplant.Call for details + */ + call: Call; + /** + * Optional SIP headers received with the message + */ + headers?: Object; + } + + /** + * Event dispatched after user interaction with the mic access dialog. + */ + interface MicAccessResult { + /** + * True is access was allowed, false - otherwise + */ + result: boolean; + } + + /** + * Event dispatched when packet loss data received from VoxImplant servers + */ + interface NetStatsReceived { + /** + * Network info object + */ + stats: NetworkInfo; + } + + /** + * Event dispatched after sound playback was stopped. See playToneScript and stopPlayback functions + */ + interface PlaybackFinished {} + + /** + * Event dispatched after SDK was successfully initialized after init function call + */ + interface SDKReady { + /** + * SDK version + */ + version: string; + } + + /** + * Event dispatched when audio and video sources information was updated. See audioSources and videoSources for details + */ + interface SourcesInfoUpdated {} + + } + + module CallEvents { + + /** + * Event dispatched after call was connected + */ + interface Connected { + /** + * Call that dispatched the event + */ + call: Call; + /** + * Optional SIP headers received with the message + */ + headers?: Object; + } + + /** + * Event dispatched after call was disconnected + */ + interface Disconnected { + /** + * Call that dispatched the event + */ + call: Call; + /** + * Optional SIP headers received with the message + */ + headers?: Object; + } + + /** + * Event dispatched after if call failed + */ + interface Failed { + /** + * Call that dispatched the event + */ + call: Call; + /** + * Status code of the call (i.e. 486) + */ + code: number; + /** + * Optional SIP headers received with the message + */ + headers?: Object; + /** + * Status message of call failure (i.e. Busy Here) + */ + reason: string; + } + + /** + * Event dispatched when INFO message is received + */ + interface InfoReceived { + /** + * Content of the message + */ + body: string; + /** + * Call that dispatched the event + */ + call: Call; + /** + * Optional SIP headers received with the message + */ + headers?: Object; + /** + * MIME type of INFO message + */ + mimeType: string; + } + + /** + * Event dispatched when text message is received + */ + interface MessageReceived { + /** + * Call that dispatched the event + */ + call: Call; + /** + * Content of the message + */ + text: string; + } + + /** + * Event dispatched when progress tone playback starts + */ + interface ProgressToneStart { + /** + * Call that dispatched the event + */ + call: Call; + } + + /** + * Event dispatched when progress tone playback stops + */ + interface ProgressToneStop { + /** + * Call that dispatched the event + */ + call: Call; + } + + /** + * Event dispatched when call has been transferred successfully + */ + interface TransferComplete { + /** + * Call that dispatched the event + */ + call: Call; + } + + /** + * Event dispatched when call transfer failed + */ + interface TransferFailed { + /** + * Call that dispatched the event + */ + call: Call; + } + } + + module IMEvents { + + /** + * Event dispatched when chat session state updated + */ + interface ChatStateUpdate { + /** + * User id + */ + id: string, + /** + * Resource name + */ + resource?: string, + /** + * Current chat session state. See VoxImplant.ChatStateType enum + */ + state: ChatStateType + } + + /** + * Event dispatched when instant message received + */ + interface MessageReceived { + /** + * Message content + */ + content: string, + /** + * User id + */ + id: string, + /** + * Message id + */ + message_id: string, + /** + * Resource name + */ + resource?: string + } + + /** + * Event dispatched when sent message status changed + */ + interface MessageStatus { + /** + * User id + */ + id: string, + /** + * Message id + */ + message_id: string, + /** + * Resource name + */ + resource?: string, + /** + * Message event type. See VoxImplant.MessageEventType enum + */ + type: MessageEventType + } + + /** + * Event dispatched when self presence updated + */ + interface PresenceUpdate { + /** + * User id + */ + id: string, + /** + * Status message + */ + message: string, + /** + * Current presence status + */ + presence: UserStatuses, + /** + * Resource name + */ + resource?: string + } + + /** + * Event dispatched when roster item changed + */ + interface RosterItemChange { + /** + * User display name + */ + displayName: string, + /** + * User id + */ + id: string, + /** + * Resource name + */ + resource?: string, + /** + * Roster item event type. See VoxImplant.RosterItemEvent enum + */ + type: RosterItemEvent + } + + /** + * Event dispatched when roster item presence update happened + */ + interface RosterPresenceUpdate { + /** + * User id + */ + id: string, + /** + * Status message + */ + message?: string, + /** + * Current presence status + */ + presence: UserStatuses, + /** + * Resource name + */ + resource?: string + } + + /** + * Event dispatched when roster data received + */ + interface RosterReceived { + /** + * User id + */ + id: string, + /** + * Array contains VoxImplant.RosterItem elements + */ + roster: RosterItem[] + } + + /** + * Event dispatched when some user tries to add current user into his roster. Current user can confirm or reject the subscription, then VoxImplant.IMEvents.RosterItemChange will be dispatched on for user that made the request + */ + interface SubscriptionRequest { + /** + * User id + */ + id: string, + /** + * Optional message + */ + message?: string, + /** + * Resource name + */ + resource?: string, + /** + * Message event type. See VoxImplant.SubscriptionRequestType enum + */ + type: SubscriptionRequestType + } + + } + + type VoxImplantEvent = Events.AuthEvent | Events.ConnectionClosed | Events.ConnectionEstablished | + Events.ConnectionFailed | Events.IMError | Events.IncomingCall | Events.MicAccessResult | + Events.NetStatsReceived | Events.PlaybackFinished | Events.SDKReady | Events.SourcesInfoUpdated; + + + type VoxImplantCallEvent = CallEvents.Connected | CallEvents.Disconnected | CallEvents.Failed | + CallEvents.InfoReceived | CallEvents.MessageReceived | CallEvents.ProgressToneStart | + CallEvents.ProgressToneStop | CallEvents.TransferComplete | CallEvents.TransferFailed; + + type VoxImplantIMEvent = IMEvents.ChatStateUpdate | IMEvents.MessageReceived | IMEvents.MessageStatus | + IMEvents.PresenceUpdate | IMEvents.RosterItemChange | IMEvents.RosterPresenceUpdate | + IMEvents.RosterReceived | IMEvents.SubscriptionRequest; + + /** + * VoxImplant SDK Configuration + */ + interface Config { + /** + * XSS protection for inbound instant messages that can contain HTML content + */ + imXSSprotection?: boolean; + /** + * If set to true microphone access dialog will be shown and all functions will become available only after user allowed access + */ + micRequired?: boolean; + /** + * Automatically plays progress tone by means of SDK according to specified progressToneCountry + */ + progressTone?: boolean; + /** + * Country code for progress tone generated automatically if progressTone set to true + */ + progressToneCountry?: string; + /** + * Show debug info in console + */ + showDebugInfo?: boolean; + /** + * Show Flash Settings panel instead of standard Allow/Deny dialog (in Flash mode) + */ + showFlashSettings?: boolean; + /** + * Id of HTMLElement that will be used as container for Flash component of SDK (Mic/cam access dialog will appear in the container). If micRequired set to true element should have size not less than 215x138 (px) for access dialog to be shown + */ + swfContainer?: string; + /** + * Force VoxImplant to use Flash (WebRTC is used if available by default) + */ + useFlashOnly?: boolean; + /** + * Force VoxImplant to use WebRTC (WebRTC is used if available by default). Error will be thrown if WebRTC in unavailable + */ + useRTCOnly?: boolean; + /** + * Default constraints that will be applied while the next attachRecordingDevice function call or if micRequired set to true + */ + videoConstraints?: VideoSettings; + /** + * Video support + */ + videoSupport?: boolean; + } + + /** + * VoxImplant login options + */ + interface LoginOptions { + /** + * If set to false Web SDK can be used only for ACD status management + */ + receiveCalls?: boolean; + /** + * If set to true user presence will be changed automatically while a call + */ + serverPresenceControl?: boolean; + } + + /** + * Audio recording device info + */ + interface AudioSourceInfo { + /** + * Device id that can be used to choose audio recording device + */ + id: number | string; + /** + * Device name , in WebRTC mode populated with real data only when app has been opened using HTTPS protocol + */ + name: string; + } + + /** + * Video recording device info + */ + interface VideoSourceInfo { + /** + * Device id that can be used to choose video recording device + */ + id: number | string; + /** + * Device name , in WebRTC mode populated with real data only when app has been opened using HTTPS protocol + */ + name: string; + } + + enum ChatStateType { + /** + * User is actively participating in the chat session + */ + Active, + /** + * User is composing a message + */ + Composing, + /** + * User has effectively ended their participation in the chat session + */ + Gone, + /** + * User has not been actively participating in the chat session + */ + Inactive, + /** + * Invalid type + */ + Invalid, + /** + * User had been composing but now has stopped + */ + Paused + } + + enum IMErrorType { + RemoteFunctionError, + Error, + RosterError + } + + enum MessageEventType { + /** + * Cancels the 'Composing' event + */ + Cancel, + /** + * Indicates that a reply is being composed + */ + Composing, + /** + * Indicates that the message has been delivered to the recipient + */ + Delivered, + /** + * Indicates that the message has been displayed + */ + Displayed, + /** + * Invalid type + */ + Invalid, + /** + * Indicates that the message has been stored offline by the intended recipient's server + */ + Offline + } + + enum OperatorACDStatuses { + AfterService, + DND, + InService, + Offline, + Online, + Ready, + Timeout + } + + enum RosterItemEvent { + /** + * Roster item added + */ + Added, + /** + * Roster item removed + */ + Removed, + /** + * User subscribed on your status updates (authorized the request) + */ + Subscribed, + /** + * User unsubscribed from your status updates (didn't authorize the request) + */ + Unsubscribed, + /** + * Roster item updated + */ + Updated + } + + enum SubscriptionRequestType { + /** + * User is asking for permission to add you into his roster + */ + Subscribe, + /** + * User removed you from his roster + */ + Unsubscribe + } + + enum UserStatuses { + /** + * User is away + */ + Away, + /** + * User is available for chat + */ + Chat, + /** + * User is in DND state (Do Not Disturbed) + */ + DND, + /** + * User is offline + */ + Offline, + /** + * User is online + */ + Online, + /** + * User is in XA state (eXtended Away) + */ + XA + } + + /** + * Client class used to control platform functions. Can't be instantiatied directly (singleton), please use VoxImplant.getInstance to get the class instance + */ + interface Client { + /** + * Register handler for specified event + * + * @param eventName Event name + * @param eventHandler Handler function. A single parameter is passed - object with the event information + */ + addEventListener(eventName: string, eventHandler: (eventObject: VoxImplantEvent | VoxImplantIMEvent) => any): void; + /** + * Add roster item (IM) + * + * @param user_id User id + * @param name Display name + * @param group User group + */ + addRosterItem(user_id: string, name: string, group?: string): void; + /** + * Add roster item group (IM) + * + * @param user_id User id + * @param group Group name + */ + addRosterItemGroup(user_id: string, group: string): void; + /** + * Enable microphone/camera if micRequired in VoxImplant.Config was set to false (WebRTC mode only) + * + * @param successCallback A function called in case of successful audio recording device change + * @param failedCallback A function called in case of problems while changing audio recording device + */ + attachRecordingDevice(successCallback?: () => any, failedCallback?: () => any): void; + /** + * Get a list of all currently available audio sources / microphones + */ + audioSources(): AudioSourceInfo[]; + /** + * Create call + * + * @param number The number to call + * @param useVideo Tells if video should be supported for the call + * @param customData Custom string associated with the call session. It can be later obtained from Call History using HTTP API + * @param extraHeaders Optional custom parameters (SIP headers) that should be passed with call (INVITE) message. Parameter names must start with "X-" to be processed by application. IMPORTANT: Headers size limit is 200 bytes + */ + call(number: string, useVideo?: boolean, customData?: string, extraHeaders?: Object): Call; + /** + * Get current config + */ + config(): Config; + /** + * Connect to VoxImplant Cloud + */ + connect(): void; + /** + * Check if connected to VoxImplant Cloud + */ + connected(): boolean; + /** + * Disable microphone/camera if micRequired in VoxImplant.Config was set to false (WebRTC mode only) + */ + detachRecordingDevice(): void; + /** + * Disconnect from VoxImplant Cloud + */ + disconnect(): void; + /** + * Initialize SDK. SDKReady event will be dispatched after succesful SDK initialization. SDK can't be used until it's initialized + * + * @param config Client configuration options + */ + init(config: Config): void; + /** + * Check if WebRTC support is available + */ + isRTCsupported(): boolean; + /** + * Login into application + * + * @param username + * @param password + * @param options Login options + */ + login(username: string, password: string, options?: LoginOptions): void; + /** + * Login into application using 'code' auth method + * + * @param username + * @param code + * @param options Login options + */ + loginWithCode(username: string, code: string, options?: LoginOptions): void; + /** + * Login into application using 'onetimekey' auth method + * + * @param username + * @param hash + * @param options Login options + */ + loginWithOneTimeKey(username: string, hash: string, options?: LoginOptions): void; + /** + * Move roster item group (IM) + * + * @param user_id User id + * @param groupSrc Group name (source) + * @param groupDst Group name (destination) + */ + moveRosterItemGroup(user_id: string, groupSrc: string, groupDst: string): void; + /** + * Play ToneScript using WebAudio API + * + * @param script Tonescript string + * @param loop Loop playback if true + */ + playToneScript(script: string, loop?: boolean): void; + /** + * Remove handler for specified event + * + * @param eventName Event name + * @param eventHandler Handler function + */ + removeEventListener(eventName: string, eventHandler: () => any): void; + /** + * Remove roster item (IM) + * + * @param user_id User id + */ + removeRosterItem(user_id: string): void; + /** + * Remove roster item group (IM) + * + * @param user_id User id + * @param group Group name + */ + remoteRosterItemGroup(user_id: string, group: string): void; + /** + * Rename roster item (IM) + * + * @param user_id User id + * @param name New display name + */ + renameRosterItem(user_id: string, name: string): void; + /** + * Request a key for 'onetimekey' auth method. Server will send the key in AuthResult event with code 302 + * + * @param username + */ + requestOneTimeLoginKey(username: string): void; + /** + * Send message to user (IM) + * + * @param user_id User id + * @param content Message content + */ + sendInstantMessage(user_id: string, content: string): string; + /** + * Start/stop sending local video to remote party/parties + * + * @param flag Start/stop - true/false + */ + sendVideo(flag: boolean): void; + /** + * Set active call + * + * @param call VoxImplant call instance + * @param active If true make call active, otherwise make call inactive + */ + setCallActive(call: Call, active: boolean): void; + /** + * Set chat session state info + * + * @param user_id User id + * @param status Chat session status. See VoxImplant.ChatStateType enum + */ + setChatState(user_id: string, status: ChatStateType): void; + /** + * Set local video position + * + * @param x Horizontal position (px) + * @param y Vertical position (px) + */ + setLocalVideoPosition(x: number, y: number): void; + /** + * Set local video size + * + * @param width Width in pixels + * @param height Height in pixels + */ + setLocalVideoSize(width: number, height: number): void; + /** + * Set local video size + * + * @param user_id User id + * @param type Message event type: VoxImplant.MessageEventType.Delivered or VoxImplant.MessageEventType.Displayed. See VoxImplant.MessageEventType enum + * @param message_id Message id(s) + */ + setMessageStatus(user_id: string, type: MessageEventType, message_id: string[]): void; + /** + * Set ACD status + * + * @param status Presence status string, see VoxImplant.OperatorACDStatuses + */ + setOperatorACDStatus(status: OperatorACDStatuses): void; + /** + * Set presence + * + * @param status Presence status from VoxImplant.UserStatuses + * @param msg Presence text message + */ + setPresenceStatus(status: UserStatuses, msg: string): void; + /** + * Set background color of flash app (only for Flash mode) + * + * @param color Color in web format (i.e. #000000 for black) + */ + setSwfColor(color: string): void; + /** + * Set bandwidth limit for video calls. Currently supported by Chrome/Chromium. The limit will be applied for the next call. (WebRTC mode only) + * + * @param bandwidth Bandwidth limit in kilobits per second (kbps) + */ + setVideoBandwidth(bandwidth: number): void; + /** + * Set video settings globally. This settings will be used for the next call. + * + * @param settings Video settings + * @param successCallback Success callback function + * @param failedCallback Failed callback function + */ + setVideoSettings(settings: VideoSettings | FlashVideoSettings, successCallback?: () => any, failedCallback?: () => any): void; + /** + * Show flash settings panel + * + * @param panel Settings type - default/microphone/camera/etc as described in SecurityPanel class + */ + showFlashSettingsPanel(panel?: string): void; + /** + * Show/hide local video + * + * @param flag Show/hide - true/false + */ + showLocalVideo(flag: boolean): void; + /** + * Stop playing ToneScript using WebAudio API + */ + stopPlayback(): void; + /** + * Transfer call, depending on the result VoxImplant.CallEvents.TransferComplete or VoxImplant.CallEvents.TransferFailed event will be dispatched + * + * @param call1 Call which will be transferred + * @param call2 Call where call1 will be transferred + */ + transferCall(call1: Call, call2: Call): void; + /** + * Use specified audio source , use audioSources to get the list of available audio sources + * + * @param id Id of the audio source + * @param successCallback Called in WebRTC mode if audio source changed successfully + * @param failedCallback Called in WebRTC mode if audio source couldn't be changed successfully + */ + useAudioSource(id: number | string, successCallback?: () => any, failedCallback?: () => any): void; + /** + * Use specified audio source , use audioSources to get the list of available audio sources + * + * @param id Id of the video source + * @param successCallback Called in WebRTC mode if video source changed successfully + * @param failedCallback Called in WebRTC mode if video source couldn't be changed successfully + */ + useVideoSource(id: number | string, successCallback?: () => any, failedCallback?: () => any): void; + /** + * Get a list of all currently available video sources / cameras + */ + videoSources(): VideoSourceInfo[]; + } + + interface Call { + /** + * Returns information about the call's media state (active/inactive) + */ + active(): boolean; + /** + * Register handler for specified event + * + * @param eventName Event name + * @param eventHandler Handler function. A single parameter is passed - object with the event information + */ + addEventListener(eventName: string, eventHandler: (eventObject: VoxImplantCallEvent) => any): void; + /** + * Answer on incoming call + * + * @param customData Set custom string associated with call session. It can be later obtained from Call History using HTTP API + * @param extraHeaders Optional custom parameters (SIP headers) that should be sent after accepting incoming call. Parameter names must start with "X-" to be processed by application + */ + answer(customData?: string, extraHeaders?: Object): void; + /** + * Reject incoming call + * + * @param extraHeaders Optional custom parameters (SIP headers) that should be sent after accepting incoming call. Parameter names must start with "X-" to be processed by application + */ + decline(extraHeaders?: Object): void; + /** + * Returns display name + */ + displayName(): string; + /** + * Returns HTML video element's id for the call (WebRTC mode) + */ + getVideoElementId(): string; + /** + * Hangup call + * + * @param extraHeaders Optional custom parameters (SIP headers) that should be sent after disconnecting/cancelling call. Parameter names must start with "X-" to be processed by application + */ + hangup(extraHeaders?: Object): void; + /** + * Returns headers object + */ + headers(): Object; + /** + * Returns call id + */ + id(): string; + /** + * Mute microphone + */ + muteMicrophone(): void; + /** + * Mute sound + */ + mutePlayback(): void; + /** + * Returns dialed number or caller id + */ + number(): string; + /** + * Reject incoming call + * + * @param extraHeaders Optional custom parameters (SIP headers) that should be sent after disconnecting/cancelling call. Parameter names must start with "X-" to be processed by application + */ + reject(extraHeaders?: Object): void; + /** + * Remove handler for specified event + * + * @param eventName Event name + * @param eventHandler Handler function + */ + removeEventListener(eventName: string, eventHandler: () => any): void; + /** + * Send Info (SIP INFO) message inside the call + * + * @param mimeType MIME type of the message + * @param body Message content + * @param extraHeaders Optional headers to be passed with the message + */ + sendInfo(mimeType: string, body: string, extraHeaders?: Object): void; + /** + * Send text message + * + * @param msg Message text + */ + sendMessage(msg: string): void; + /** + * Send tone (DTMF) + * + * @param key Send tone according to pressed key: 0-9 , * , # + */ + sendTone(key: string): void; + /** + * Set remote video position + * + * @param x Horizontal position (px) + * @param y Vertical position (px) + */ + setRemoteVideoPosition(x: number, y: number): void; + /** + * Set remote video size + * + * @param width Width in pixels + * @param height Height in pixels + */ + setRemoteVideoSize(width: number, height: number): void; + /** + * Set video settings + * + * @param settings Video settings for current call + * @param successCallback Called in WebRTC mode if video settings were applied successfully + * @param failedCallback Called in WebRTC mode if video settings couldn't be applied + */ + setVideoSettings(settings: VideoSettings | FlashVideoSettings, successCallback?: () => any, failedCallback?: () => any): void; + /** + * Show/hide remote party video + * + * @param flag Show/hide - true/false + */ + showRemoteVideo(flag: boolean): void; + /** + * Get call's current state + */ + state(): string; + /** + * Unmute microphone + */ + unmuteMicrophone(): void; + /** + * Unmute sound + */ + unmutePlayback(): void; + } + + /** + * WebRTC Video Settings (aka Constraints) + */ + interface VideoSettings { + /** + * Mandatory constraints object + */ + mandatory: Object; + /** + * Optional constraints object + */ + optional: Object; + } + + /** + * Flash Video Settings + */ + interface FlashVideoSettings { + /** + * The maximum amount of bandwidth the current outgoing video feed can use, in bytes + */ + bandwidth?: number; + /** + * The maximum rate at which the camera can capture data, in frames per second + */ + fps?: number; + /** + * Height in pixels (should be set together with width) + */ + height?: number; + /** + * Width in pixels (should be set together with height) + */ + width?: number; + /** + * Keyframe interval (seconds) + */ + keyframeInterval?: number; + /** + * H.264 video codec level + */ + level?: string; + /** + * H.264 video codec profile + */ + profile?: string; + /** + * The required level of picture quality, as determined by the amount of compression being applied to each video frame. Acceptable quality values range from 1 (lowest quality, maximum compression) to 100 (highest quality, no compression). The default value is 0, which means that picture quality can vary as needed to avoid exceeding available bandwidth + */ + quality?: number; + } + + /** + * Network information + */ + interface NetworkInfo { + /** + * Packet loss percentage + */ + packetLoss: number; + } + + /** + * VoxImplant roster item + */ + interface RosterItem { + /** + * Groups this roster item belongs to + */ + groups: string[], + /** + * User id + */ + id: string, + /** + * User display name + */ + name: string, + /** + * Resources + */ + resources: string[], + /** + * Subscription type + */ + subscription_type: number + } + + /** + * Get Client instance to use platform functions + */ + function getInstance(): Client; + /** + * VoxImplant Web SDK lib version + */ + function version(): String; + +} From 8dfd709683480bf87b3fa9ab92b0e2894cb70a3f Mon Sep 17 00:00:00 2001 From: abreits Date: Wed, 14 Oct 2015 14:33:16 +0200 Subject: [PATCH 18/87] 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 7a1f51200..cfb9adbe1 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 0c7f0720a..c6f73feef 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 93bcd768f07af500f68c26abfba8ed2827c81eac Mon Sep 17 00:00:00 2001 From: abreits Date: Wed, 14 Oct 2015 14:58:55 +0200 Subject: [PATCH 19/87] 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 cfb9adbe1..c22bc7ac9 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 c6f73feef..a6e6e7a05 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 9e7d9453a136e98970eeae042706680d0e974c67 Mon Sep 17 00:00:00 2001 From: abreits Date: Wed, 14 Oct 2015 15:09:10 +0200 Subject: [PATCH 20/87] 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 c22bc7ac9..f99a3bde1 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 cbd5556169709445e7b577e1888515f49eb5f47c Mon Sep 17 00:00:00 2001 From: James Alexander Date: Wed, 14 Oct 2015 10:49:05 -0400 Subject: [PATCH 21/87] 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 42f5fb348..fb2668a1f 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 710bfe47992af4f1a81d7c8b07082c72e750c1b0 Mon Sep 17 00:00:00 2001 From: soycode Date: Wed, 14 Oct 2015 14:20:25 -0700 Subject: [PATCH 22/87] 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 f012c9dea..fa80a530c 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 23/87] 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 000000000..363e522b0 --- /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 000000000..3365f335c --- /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 aa15031dcc8596d08543bbd7648496472bd54c11 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Thu, 15 Oct 2015 05:33:36 +0500 Subject: [PATCH 24/87] 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 adf86e9a6..b0dffe01e 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 d5463ffc0..c77ff2f17 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 e43b2a00c08db45e1ac52d806f7e7f402bda6627 Mon Sep 17 00:00:00 2001 From: Giovanni Bassi Date: Wed, 14 Oct 2015 21:42:05 -0300 Subject: [PATCH 25/87] 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 000000000..b8c1a2c25 --- /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 000000000..ea2330a19 --- /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 161890155f7c9b7e036be50d1ab7869971aaa716 Mon Sep 17 00:00:00 2001 From: Michel Weststrate Date: Thu, 15 Oct 2015 12:34:37 +0200 Subject: [PATCH 26/87] 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 f42627a85..e95fc69f5 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 b5956f2bef11b743b05366023f619039f2ba3c1a Mon Sep 17 00:00:00 2001 From: tkqubo Date: Thu, 15 Oct 2015 23:54:55 +0900 Subject: [PATCH 27/87] 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 000000000..b4a9693ec --- /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 000000000..01ea6e404 --- /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 5a70c2e10..27a4a5385 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 82cf56458..f2049bbc9 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 28/87] 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 6a5426a6a..4cfae373e 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 0b6cc75d6..fa5f31947 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 372689cd4334e5e1ad2779ca3ade9b1e2cfd757a Mon Sep 17 00:00:00 2001 From: laco0416 Date: Fri, 16 Oct 2015 00:55:16 +0900 Subject: [PATCH 29/87] 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 311fda967..8a44ed285 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 b764aeb2a..9117301af 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 93662fbe0a3392b19c0f297605e5295643e895f1 Mon Sep 17 00:00:00 2001 From: Blake Doss Date: Thu, 15 Oct 2015 13:49:47 -0400 Subject: [PATCH 30/87] 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 a8b139937..49538fbd9 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 31/87] 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 f90fefaf9..c50f5feab 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 88dc359fc..b4f182aab 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 32/87] 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 66a4b4995..57c48252f 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 981e754e5..d4376d83e 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 d4f3ed0cc7f7aba3b47dc6dbc68ead8a97052fe4 Mon Sep 17 00:00:00 2001 From: Yuki Kodama Date: Fri, 16 Oct 2015 02:43:41 +0000 Subject: [PATCH 33/87] 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 1bcbedc63..669ab6b99 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 34/87] 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 adf86e9a6..b4678f153 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 d5463ffc0..a574e10c3 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 35/87] 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 adf86e9a6..ba0f5e130 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 d5463ffc0..9ff00c49f 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 36/87] licence -> license for consistency :rose: --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5cc7045d7..82833752d 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 37/87] 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 3ec31968c..2162b0220 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 38/87] 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 6054e9a47..966d5abaa 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 39/87] 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 5ea8165b0..0df86dfc6 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 40/87] 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 8b67f649b..ef013fdf1 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 bb4692f5d2bba524eb9b810cf7c83a1ec671d547 Mon Sep 17 00:00:00 2001 From: Stefan Profanter Date: Fri, 16 Oct 2015 17:07:49 +0200 Subject: [PATCH 41/87] 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 667a37983..9bab4a49f 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 aa3f2581c70867f64f02ef15adc6ce86367af103 Mon Sep 17 00:00:00 2001 From: Aleksei Barbarosh Date: Fri, 16 Oct 2015 21:03:08 +0300 Subject: [PATCH 42/87] 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 d500525b6..2ee765728 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 43/87] 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 a39cdcf79..1c64de9d7 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 3f0863ac6..000000000 --- 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 616157aaf..356080998 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 `