Big update of WinJS definitions.

Went through and did a large number of fixes as part of converting the WinJS test tree to TypeScript.

Full list of changes:

Fix small issue with WinJS.Promise.timeout. (The first argument should be optional.)

Remove an unnecessary comment about winControl.

Fix WinJS Promise types

Make addEventListener and removeEventListener static.

markDisposable's second argument is optional.

WinJS.UI.Fragments.clearCache had a missing overload.

Add missing overload for WinJS.UI.Fragments.renderCopy.

WinJS.Class.define constructor parameter is optional.

Add override for WinJS.log

Message can also be a function that returns a string.

Also add override for WinJS.Utilities.startLog

All ILogOptions properties are optional.

Make WinJS.log arguments optional.

WinJS.Resources.processAll returns a Promise.

Add WinJS.Utilities.Scheduler.currentPriority

Make WinJS.Promise.wrap()'s argument optional.

Make IXHROptions data property optional.

Add CustomRequestInitializer to IXHROptions.

Correct doc comment for WinJS.Application.*.writeText

Fix declaration for static render on WinJS.Binding.Template.

Add WinJS.Utilities.getTabIndex.

Add overload for WinJS.Utilities.QueryCollection.include

Fix WinJS.Utilities.getRelativeTop and getRelativeLeft parameters.

Add getScrollPosition and setScrollPosition.

Make BindingList.createGrouped last argument optional.

Fix return type of WinJS.UI.computeDataSourceGroups()

Add missing static createResultSuggestionImage to WinJS.UI.SearchBox.

Add missing overload for WinJS.Binding.List.push()

Add generic overload for IItemPromise.then()

Fix the return value of IItemPromise.then to be correct.

Promise.dispatchEvent should be static.

Fix IItemPromise.retain return value.

Create IPromise interface.

This helps type coercion with custom promise types (such as IItemPromise).

Add missing animations to latest d.ts.

Update optional parameters on animations.

Add BindingList.unshift overload

Fix BindingList.sort() to have argument be optional.

Fix arguments for BindingList.splice and BindingList.join

Fix BindingList.lastIndexOf optional second argument.

Fix return time of items in GroupedSortedListProjections.

Make last argument of QueryCollection.template optional.

Fix WinJS.UI.Repeater constructor.

Fix the type of the second parameter of the WinJS.Binding.Template constructor

Update WinJS.UI.ListLayout so that it implements ILayout2.

Update WinJS.UI.GridLayout.

Add static Promise.cancel property.

Add type property to IListViewItem

Make argument to Promise.as optional.

Add AppBar.closedDisplayMode

Make some arguments optional on Flyout.show()

Make arguments optional on Menu.show();

Fix generic type of Hub.zoomableView.

Add missing Promise.then overloads.

Update author information

Fix IPageControlMembers to reflect the real contract.

TypeScript doesn't allow overrides to vary only by return type, so we have to use any as both void and returning a Promise are allowed.

WinJS.UI.Pages.render()'s second argument is optional.

WinJS.UI.Pages.render() returns a promise to the page itself.

Fix return values of WinJS.UI.Pages.get/define.

Add Pivot and PivotItem to latest d.ts.

Fix PivotItem.header type
This commit is contained in:
Jeff Fisher
2014-08-22 14:12:30 -07:00
parent 807ba77ee6
commit 6370ba5a78
4 changed files with 1138 additions and 474 deletions

298
winjs/winjs-1.0.d.ts vendored
View File

@@ -1,6 +1,6 @@
// Type definitions for WinJS
// Project: http://msdn.microsoft.com/en-us/library/windows/apps/br229773.aspx
// Definitions by: TypeScript samples <https://www.typescriptlang.org/>, Adam Hewitt <https://github.com/adamhewitt627>, Craig Treasure <https://github.com/craigktreasure>
// Project: http://try.buildwinjs.com/
// Definitions by: TypeScript samples <https://www.typescriptlang.org/>, Adam Hewitt <https://github.com/adamhewitt627>, Craig Treasure <https://github.com/craigktreasure>, Jeff Fisher <https://github.com/xirzec>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/* *****************************************************************************
@@ -22,7 +22,7 @@ and limitations under the License.
* Defines an Element object.
**/
interface Element {
winControl: any; // TODO: This should be control?
winControl: any;
}
/**
@@ -55,7 +55,7 @@ interface IOHelper {
* Writes the specified text to the specified file.
* @param fileName The name of the file.
* @param text The content to be written to the file.
* @returns A promise that completes with a value that is the number of characters written.
* @returns A promise that is completed when the file has been written.
**/
writeText(fileName: string, text: string): WinJS.Promise<number>;
}
@@ -362,6 +362,12 @@ declare module WinJS.Binding {
//#endregion Properties
/**
* Returns a key/data pair for the specified index.
* @param index The index of the value to retrieve.
* @returns An object that has two properties: key and data.
**/
getItem(index: number): IGroupKeyDataPair<T>;
}
/**
@@ -432,7 +438,7 @@ declare module WinJS.Binding {
* 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;
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.
@@ -539,7 +545,7 @@ 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<T>;
createGrouped(groupKey: (x: T) => string, groupData: (x: T) => any, groupSorter?: (left: string, right: string) => number): GroupedSortedListProjection<T>;
/**
* Creates a live sorted projection over this list. As the list changes, the sorted projection reacts to those changes and may also change.
@@ -599,7 +605,7 @@ declare module WinJS.Binding {
* @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;
join(separator?: string): string;
/**
* Gets the index of the last occurrence of the specified value in a list.
@@ -607,7 +613,7 @@ declare module WinJS.Binding {
* @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;
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.
@@ -661,7 +667,7 @@ declare module WinJS.Binding {
* @param end The index that specifies the end of the section.
* @returns Returns a section of list.
**/
slice(begin: number, end: number): T[];
slice(begin: number, end?: number): T[];
/**
* Checks whether the specified callback function returns true for any element of a list.
@@ -714,6 +720,7 @@ declare module WinJS.Binding {
* @returns The new length of the list.
**/
push(value: T): number;
push(...values: T[]): number;
/**
* Removes the first element from a list and returns it.
@@ -727,6 +734,7 @@ declare module WinJS.Binding {
* @returns The new length of the list.
**/
unshift(value: T): number;
unshift(...values: T[]): number;
//#endregion Methods
}
@@ -934,30 +942,28 @@ declare module WinJS.Binding {
* @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?: string);
constructor(element: HTMLElement, options?: any);
//#endregion Constructors
//#region Methods
render: {
/**
* 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.
**/
(dataContext: any, container?: HTMLElement): Promise<HTMLElement>;
/**
* 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<HTMLElement>;
/**
* 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.
**/
value(href: string, dataContext: any, container?: HTMLElement): Promise<HTMLElement>;
};
/**
* 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<HTMLElement>;
//#endregion Methods
@@ -1085,6 +1091,12 @@ declare module WinJS.Binding {
data: T;
}
interface IGroupKeyDataPair<T> extends IKeyDataPair<T> {
groupSize: number;
firstItemIndexHint: number;
firstItemKey: string;
}
//#endregion Interfaces
}
@@ -1101,7 +1113,7 @@ declare module WinJS.Class {
* @param staticMembers The set of static fields, properties, and methods made available on the type.
* @returns The newly-defined type.
**/
function define(constructor: Function, instanceMembers?: any, staticMembers?: any): any;
function define(constructor?: Function, instanceMembers?: any, staticMembers?: any): any;
/**
* Creates a sub-class based on the specified baseClass parameter, using prototype inheritance.
@@ -1157,10 +1169,24 @@ declare module WinJS {
}
interface IPromise<T> {
cancel(): void;
done<U>(onComplete?: (value: T) => any, onError?: (error: any) => any, onProgress?: (progress: any) => void): void;
then<U>(onComplete?: (value: T) => IPromise<U>, onError?: (error: any) => IPromise<U>, onProgress?: (progress: any) => void): IPromise<U>;
then<U>(onComplete?: (value: T) => IPromise<U>, onError?: (error: any) => U, onProgress?: (progress: any) => void): IPromise<U>;
then<U>(onComplete?: (value: T) => IPromise<U>, onError?: (error: any) => void, onProgress?: (progress: any) => void): IPromise<U>;
then<U>(onComplete?: (value: T) => U, onError?: (error: any) => IPromise<U>, onProgress?: (progress: any) => void): IPromise<U>;
then<U>(onComplete?: (value: T) => U, onError?: (error: any) => U, onProgress?: (progress: any) => void): IPromise<U>;
then<U>(onComplete?: (value: T) => U, onError?: (error: any) => void, onProgress?: (progress: any) => void): IPromise<U>;
then<U>(onComplete?: (value: T) => void, onError?: (error: any) => IPromise<U>, onProgress?: (progress: any) => void): IPromise<U>;
then<U>(onComplete?: (value: T) => void, onError?: (error: any) => U, onProgress?: (progress: any) => void): IPromise<U>;
then<U>(onComplete?: (value: T) => void, onError?: (error: any) => void, onProgress?: (progress: any) => void): IPromise<U>;
}
/**
* Provides a mechanism to schedule work to be done on a value that has not yet been computed. It is an 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.
**/
class Promise<T> {
class Promise<T> implements IPromise<T> {
//#region Constructors
/**
@@ -1179,7 +1205,7 @@ declare module WinJS {
* Occurs when there is an error in processing a promise.
* @param eventInfo An object that contains information about the event.
**/
onerror(eventInfo: CustomEvent): void;
static onerror(eventInfo: CustomEvent): void;
//#endregion Events
@@ -1191,34 +1217,40 @@ declare module WinJS {
* @param listener The listener to invoke when the event is raised.
* @param capture true to initiate capture, otherwise false.
**/
addEventListener(type: string, listener: Function, capture?: boolean): void;
static addEventListener(type: string, listener: Function, capture?: boolean): void;
/**
* Returns a promise that is fulfilled when one of the input promises has been fulfilled.
* @param value An array that contains Promise objects or objects whose property values include Promise objects.
* @returns A promise that on fulfillment yields the value of the input (complete or error).
**/
static any(value: Promise<any>[]): Promise<any>;
static any(value: IPromise<any>[]): IPromise<any>;
static any(value: any): IPromise<any>;
/**
* Returns a promise. If the object is already a Promise it is returned; otherwise the object is wrapped in a Promise. You can use this function when you need to treat a non-Promise object like a Promise, for example when you are calling a function that expects a promise, but already have the value needed rather than needing to get it asynchronously.
* @param value The value to be treated as a Promise.
* @returns The promise.
**/
static as<U>(value: U): Promise<U>;
static as<U>(value?: U): IPromise<U>;
/**
* Attempts to cancel the fulfillment of a promised value. If the promise hasn't already been fulfilled and cancellation is supported, the promise enters the error state with a value of Error("Canceled").
**/
cancel(): void;
/**
* Canceled promise value, can be returned from a promise completion handler to indicate cancelation of the promise chain.
*/
static cancel: IPromise<any>;
/**
* Raises an event of the specified type and 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;
static dispatchEvent(type: string, details: any): boolean;
/**
* Allows you to specify the work to be done on the fulfillment of the promised value, the error handling to be performed if the promise fails to fulfill a value, and the handling of progress notifications along the way. After the handlers have finished executing, this function throws any error that would have been returned from then as a promise in the error state. For more information about the differences between then and done, see the following topics: Quickstart: using promises in JavaScript How to handle errors when using promises in JavaScript Chaining promises in JavaScript.
@@ -1240,7 +1272,7 @@ declare module WinJS {
* @param values An object whose members contain values, some of which may be promises.
* @returns A Promise whose value is an object with the same field names as those of the object in the values parameter, where each field value is the fulfilled value of a promise.
**/
static join(values: any): Promise<any>;
static join(values: any): IPromise<any>;
/**
* Removes an event listener from the control.
@@ -1248,7 +1280,7 @@ declare module WinJS {
* @param listener The listener to remove.
* @param capture Specifies whether or not to initiate capture.
**/
removeEventListener(eventType: string, listener: Function, capture?: boolean): void;
static removeEventListener(eventType: string, listener: Function, capture?: boolean): void;
/**
* Allows you to specify the work to be done on the fulfillment of the promised value, the error handling to be performed if the promise fails to fulfill a value, and the handling of progress notifications along the way. For more information about the differences between then and done, see the following topics: Quickstart: using promises in JavaScript How to handle errors when using promises in JavaScript Chaining promises in JavaScript.
@@ -1257,7 +1289,7 @@ declare module WinJS {
* @param onProgress The function to be called if the promise reports progress. Data about the progress is passed as the single argument. Promises are not required to support progress.
* @returns The promise whose value is the result of executing the onComplete function.
**/
then<U>(onComplete?: (value: T) => Promise<U>, onError?: (error: any) => Promise<U>, onProgress?: (progress: any) => void): Promise<U>;
then<U>(onComplete?: (value: T) => IPromise<U>, onError?: (error: any) => IPromise<U>, onProgress?: (progress: any) => void): IPromise<U>;
/**
* Allows you to specify the work to be done on the fulfillment of the promised value, the error handling to be performed if the promise fails to fulfill a value, and the handling of progress notifications along the way. For more information about the differences between then and done, see the following topics: Quickstart: using promises in JavaScript How to handle errors when using promises in JavaScript Chaining promises in JavaScript.
@@ -1266,7 +1298,7 @@ declare module WinJS {
* @param onProgress The function to be called if the promise reports progress. Data about the progress is passed as the single argument. Promises are not required to support progress.
* @returns The promise whose value is the result of executing the onComplete function.
**/
then<U>(onComplete?: (value: T) => Promise<U>, onError?: (error: any) => U, onProgress?: (progress: any) => void): Promise<U>;
then<U>(onComplete?: (value: T) => IPromise<U>, onError?: (error: any) => U, onProgress?: (progress: any) => void): IPromise<U>;
/**
* Allows you to specify the work to be done on the fulfillment of the promised value, the error handling to be performed if the promise fails to fulfill a value, and the handling of progress notifications along the way. For more information about the differences between then and done, see the following topics: Quickstart: using promises in JavaScript How to handle errors when using promises in JavaScript Chaining promises in JavaScript.
@@ -1275,7 +1307,7 @@ declare module WinJS {
* @param onProgress The function to be called if the promise reports progress. Data about the progress is passed as the single argument. Promises are not required to support progress.
* @returns The promise whose value is the result of executing the onComplete function.
**/
then<U>(onComplete?: (value: T) => U, onError?: (error: any) => Promise<U>, onProgress?: (progress: any) => void): Promise<U>;
then<U>(onComplete?: (value: T) => IPromise<U>, onError?: (error: any) => void, onProgress?: (progress: any) => void): IPromise<U>;
/**
* Allows you to specify the work to be done on the fulfillment of the promised value, the error handling to be performed if the promise fails to fulfill a value, and the handling of progress notifications along the way. For more information about the differences between then and done, see the following topics: Quickstart: using promises in JavaScript How to handle errors when using promises in JavaScript Chaining promises in JavaScript.
@@ -1284,7 +1316,63 @@ declare module WinJS {
* @param onProgress The function to be called if the promise reports progress. Data about the progress is passed as the single argument. Promises are not required to support progress.
* @returns The promise whose value is the result of executing the onComplete function.
**/
then<U>(onComplete?: (value: T) => U, onError?: (error: any) => U, onProgress?: (progress: any) => void): Promise<U>;
then<U>(onComplete?: (value: T) => U, onError?: (error: any) => IPromise<U>, onProgress?: (progress: any) => void): IPromise<U>;
/**
* Allows you to specify the work to be done on the fulfillment of the promised value, the error handling to be performed if the promise fails to fulfill a value, and the handling of progress notifications along the way. For more information about the differences between then and done, see the following topics: Quickstart: using promises in JavaScript How to handle errors when using promises in JavaScript Chaining promises in JavaScript.
* @param onComplete The function to be called if the promise is fulfilled successfully with a value. The value is passed as the single argument. If the value is null, the value is returned. The value returned from the function becomes the fulfilled value of the promise returned by then. If an exception is thrown while this function is being executed, the promise returned by then moves into the error state.
* @param onError The function to be called if the promise is fulfilled with an error. The error is passed as the single argument. In different cases this object may be of different types, so it is necessary to test the object for the properties you expect. If the error is null, it is forwarded. The value returned from the function becomes the value of the promise returned by the then function.
* @param onProgress The function to be called if the promise reports progress. Data about the progress is passed as the single argument. Promises are not required to support progress.
* @returns The promise whose value is the result of executing the onComplete function.
**/
then<U>(onComplete?: (value: T) => U, onError?: (error: any) => U, onProgress?: (progress: any) => void): IPromise<U>;
/**
* Allows you to specify the work to be done on the fulfillment of the promised value, the error handling to be performed if the promise fails to fulfill a value, and the handling of progress notifications along the way. For more information about the differences between then and done, see the following topics: Quickstart: using promises in JavaScript How to handle errors when using promises in JavaScript Chaining promises in JavaScript.
* @param onComplete The function to be called if the promise is fulfilled successfully with a value. The value is passed as the single argument. If the value is null, the value is returned. The value returned from the function becomes the fulfilled value of the promise returned by then. If an exception is thrown while this function is being executed, the promise returned by then moves into the error state.
* @param onError The function to be called if the promise is fulfilled with an error. The error is passed as the single argument. In different cases this object may be of different types, so it is necessary to test the object for the properties you expect. If the error is null, it is forwarded. The value returned from the function becomes the value of the promise returned by the then function.
* @param onProgress The function to be called if the promise reports progress. Data about the progress is passed as the single argument. Promises are not required to support progress.
* @returns The promise whose value is the result of executing the onComplete function.
**/
then<U>(onComplete?: (value: T) => U, onError?: (error: any) => void, onProgress?: (progress: any) => void): IPromise<U>;
/**
* Allows you to specify the work to be done on the fulfillment of the promised value, the error handling to be performed if the promise fails to fulfill a value, and the handling of progress notifications along the way. For more information about the differences between then and done, see the following topics: Quickstart: using promises in JavaScript How to handle errors when using promises in JavaScript Chaining promises in JavaScript.
* @param onComplete The function to be called if the promise is fulfilled successfully with a value. The value is passed as the single argument. If the value is null, the value is returned. The value returned from the function becomes the fulfilled value of the promise returned by then. If an exception is thrown while this function is being executed, the promise returned by then moves into the error state.
* @param onError The function to be called if the promise is fulfilled with an error. The error is passed as the single argument. In different cases this object may be of different types, so it is necessary to test the object for the properties you expect. If the error is null, it is forwarded. The value returned from the function becomes the value of the promise returned by the then function.
* @param onProgress The function to be called if the promise reports progress. Data about the progress is passed as the single argument. Promises are not required to support progress.
* @returns The promise whose value is the result of executing the onComplete function.
**/
then<U>(onComplete?: (value: T) => void, onError?: (error: any) => IPromise<U>, onProgress?: (progress: any) => void): IPromise<U>;
/**
* Allows you to specify the work to be done on the fulfillment of the promised value, the error handling to be performed if the promise fails to fulfill a value, and the handling of progress notifications along the way. For more information about the differences between then and done, see the following topics: Quickstart: using promises in JavaScript How to handle errors when using promises in JavaScript Chaining promises in JavaScript.
* @param onComplete The function to be called if the promise is fulfilled successfully with a value. The value is passed as the single argument. If the value is null, the value is returned. The value returned from the function becomes the fulfilled value of the promise returned by then. If an exception is thrown while this function is being executed, the promise returned by then moves into the error state.
* @param onError The function to be called if the promise is fulfilled with an error. The error is passed as the single argument. In different cases this object may be of different types, so it is necessary to test the object for the properties you expect. If the error is null, it is forwarded. The value returned from the function becomes the value of the promise returned by the then function.
* @param onProgress The function to be called if the promise reports progress. Data about the progress is passed as the single argument. Promises are not required to support progress.
* @returns The promise whose value is the result of executing the onComplete function.
**/
then<U>(onComplete?: (value: T) => void, onError?: (error: any) => U, onProgress?: (progress: any) => void): IPromise<U>;
/**
* Allows you to specify the work to be done on the fulfillment of the promised value, the error handling to be performed if the promise fails to fulfill a value, and the handling of progress notifications along the way. For more information about the differences between then and done, see the following topics: Quickstart: using promises in JavaScript How to handle errors when using promises in JavaScript Chaining promises in JavaScript.
* @param onComplete The function to be called if the promise is fulfilled successfully with a value. The value is passed as the single argument. If the value is null, the value is returned. The value returned from the function becomes the fulfilled value of the promise returned by then. If an exception is thrown while this function is being executed, the promise returned by then moves into the error state.
* @param onError The function to be called if the promise is fulfilled with an error. The error is passed as the single argument. In different cases this object may be of different types, so it is necessary to test the object for the properties you expect. If the error is null, it is forwarded. The value returned from the function becomes the value of the promise returned by the then function.
* @param onProgress The function to be called if the promise reports progress. Data about the progress is passed as the single argument. Promises are not required to support progress.
* @returns The promise whose value is the result of executing the onComplete function.
**/
then<U>(onComplete?: (value: T) => void, onError?: (error: any) => void, onProgress?: (progress: any) => void): IPromise<U>;
/**
* A static helper that functions identically to then() off a promise instance.
* @param promise The promise to chain from.
* @param onComplete The function to be called if the promise is fulfilled successfully with a value. The value is passed as the single argument. If the value is null, the value is returned. The value returned from the function becomes the fulfilled value of the promise returned by then. If an exception is thrown while this function is being executed, the promise returned by then moves into the error state.
* @param onError The function to be called if the promise is fulfilled with an error. The error is passed as the single argument. In different cases this object may be of different types, so it is necessary to test the object for the properties you expect. If the error is null, it is forwarded. The value returned from the function becomes the value of the promise returned by the then function.
* @param onProgress The function to be called if the promise reports progress. Data about the progress is passed as the single argument. Promises are not required to support progress.
* @returns The promise whose value is the result of executing the onComplete function.
**/
static then(promise: IPromise<any>, onComplete?: (value: any) => any, onError?: (error: any) => any, onProgress?: (progress: any) => void): IPromise<any>;
/**
* Performs an operation on all the input promises and returns a promise that has the shape of the input and contains the result of the operation that has been performed on each input.
@@ -1294,7 +1382,7 @@ declare module WinJS {
* @param progress The function to be called if the promise reports progress. This function takes a single argument, which is the data about the progress of the promise. Promises are not required to support progress.
* @returns A Promise that is the result of calling join on the values parameter.
**/
static thenEach(values: any, complete?: (value: any) => void, error?: (error: any) => void, progress?: (progress: any) => void): Promise<any>;
static thenEach(values: any, complete?: (value: any) => void, error?: (error: any) => void, progress?: (progress: any) => void): IPromise<any>;
/**
* This method has two forms: WinJS.Promise.timeout(timeout) and WinJS.Promise.timeout(timeout, promise). WinJS.Promise.timeout(timeout) creates a promise that is completed asynchronously after the specified timeout, essentially wrapping a call to setTimeout within a promise. WinJS.Promise.timeout(timeout, promise) sets a timeout period for completion of the specified promise, automatically canceling the promise if it is not completed within the timeout period.
@@ -1302,21 +1390,21 @@ declare module WinJS {
* @param promise Optional. A promise that will be canceled if it doesn't complete within the timeout period.
* @returns If the promise parameter is omitted, returns a promise that will be fulfilled after the timeout period. If the promise paramater is provided, the same promise is returned.
**/
static timeout(timeout: number, promise?: Promise<any>): Promise<any>;
static timeout(timeout?: number, promise?: IPromise<any>): IPromise<any>;
/**
* Wraps a non-promise value in a promise. This method is like wrapError, which allows you to produce a Promise in error conditions, in that it allows you to return a Promise in success conditions.
* @param value Some non-promise value to be wrapped in a promise.
* @returns A promise that is successfully fulfilled with the specified value.
**/
static wrap<U>(value: U): Promise<U>;
static wrap<U>(value?: U): IPromise<U>;
/**
* Wraps a non-promise error value in a promise. You can use this function if you need to pass an error to a function that requires a promise.
* @param error A non-promise error value to be wrapped in a promise.
* @returns A promise that is in an error state with the specified value.
**/
static wrapError<U>(error: U): Promise<U>;
static wrapError<U>(error: U): IPromise<U>;
//#endregion Methods
@@ -1332,7 +1420,8 @@ declare module WinJS {
* @param tags The tag or tags to categorize the message (winjs, winjs controls, etc.).
* @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;
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.
@@ -1356,8 +1445,9 @@ declare module WinJS {
user?: string;
password?: string;
headers?: any;
data: any;
data?: any;
responseType?: string;
customRequestInitializer?: (request: XMLHttpRequest) => void;
}
//#endregion Interfaces
@@ -1518,7 +1608,7 @@ declare module WinJS.Resources {
* Processes data-win-res attributes on elements and replaces attributes and properties with resource strings.
* @param rootElement The element to process. The element and its child elements will be processed. If an element isn't specified, the entire document is processed.
**/
function processAll(rootElement?: HTMLElement): void;
function processAll(rootElement?: HTMLElement): Promise<void>;
/**
* Removes an event listener that the addEventListener method registered.
@@ -1623,7 +1713,7 @@ declare module WinJS.UI.Animation {
* @param offset Initial offsets where the animated objects begin relative to their final position at the end of the animation. Set this parameter to null to use the recommended default offset. Note When the incoming parameter specifies an array of elements, the offset parameter can specify an offset array with each item specified for its corresponding element array item. If the array of offsets is smaller than the array of elements, the last offset is applied to all remaining elements.
* @returns An object that completes when the animation is finished.
**/
function dragBetweenEnter(target: any, offset: any): Promise<any>;
function dragBetweenEnter(target: any, offset?: any): Promise<any>;
/**
* Performs an animation when a dragged object is moved away from items that it had previously involved in a dragBetweenEnter animation. The affected objects are animated back to their original positions.
@@ -1639,7 +1729,7 @@ declare module WinJS.UI.Animation {
* @param affected Element or elements whose position the dropped object affects. Typically, this is all other items in a reorderable list. This should be the same element or element collection passed as the affected parameter in the dragSourceStart animation.
* @returns An object that completes when the animation is finished.
**/
function dragSourceEnd(dragSource: any, offset: any, affected?: any): Promise<any>;
function dragSourceEnd(dragSource: any, offset?: any, affected?: any): Promise<any>;
/**
* Performs an animation when the user begins to drag an object.
@@ -1656,7 +1746,7 @@ declare module WinJS.UI.Animation {
* @param options Optional. Set this value to { mechanism: "transition" } to play the animation using CSS transitions instead of the default CSS animations. In some cases this can result in improved performance.
* @returns An object that completes when the animation is finished.
**/
function enterContent(incoming: any, offset: any, options?: any): Promise<any>;
function enterContent(incoming: any, offset?: any, options?: any): Promise<any>;
/**
* Performs an animation that shows a new page of content, either when transitioning between pages in a running app or when displaying the first content in a newly launched app.
@@ -1664,7 +1754,7 @@ declare module WinJS.UI.Animation {
* @param offset An initial offset where the element or elements begin relative to their final position at the end of the animation. Set this parameter to null to use the recommended default offset. Note When the element parameter specifies an array of elements, the offset parameter can specify an offset array with each item specified for its corresponding element array item. If the array of offsets is smaller than the array of elements, the last offset is applied to all remaining elements.
* @returns An object that completes when the animation is finished.
**/
function enterPage(element: any, offset: any): Promise<any>;
function enterPage(element: any, offset?: any): Promise<any>;
/**
* Performs an animation that hides one or more elements on a page.
@@ -1672,7 +1762,7 @@ declare module WinJS.UI.Animation {
* @param offset Initial offsets where the animated objects begin relative to their final position at the end of the animation. Set this parameter to null to use the recommended default offset. Note When the incoming parameter specifies an array of elements, the offset parameter can specify an offset array with each item specified for its corresponding element array item. If the array of offsets is smaller than the array of elements, the last offset is applied to all remaining elements.
* @returns An object that completes when the animation is finished.
**/
function exitContent(outgoing: any, offset: any): Promise<any>;
function exitContent(outgoing: any, offset?: any): Promise<any>;
/**
* Performs an animation that dismisses the current page when transitioning between pages in an app.
@@ -1680,7 +1770,7 @@ declare module WinJS.UI.Animation {
* @param offset Initial offsets where the animated objects begin relative to their final position at the end of the animation. Set this parameter to null to use the recommended default offset. Note When the incoming parameter specifies an array of elements, the offset parameter can specify an offset array with each item specified for its corresponding element array item. If the array of offsets is smaller than the array of elements, the last offset is applied to all remaining elements.
* @returns An object that completes when the animation is finished.
**/
function exitPage(outgoing: any, offset: any): Promise<any>;
function exitPage(outgoing: any, offset?: any): Promise<any>;
/**
* Performs an animation that fades an item or set of items into view.
@@ -1703,7 +1793,7 @@ declare module WinJS.UI.Animation {
* @param options Optional. Set this value to { mechanism: "transition" } to play the animation using CSS transitions instead of the default CSS animations. In some cases this can result in improved performance.
* @returns An object that completes when the animation is finished.
**/
function hideEdgeUI(element: any, offset: any, options?: any): Promise<any>;
function hideEdgeUI(element: any, offset?: any, options?: any): Promise<any>;
/**
* Performs an animation that hides a panel.
@@ -1741,7 +1831,7 @@ declare module WinJS.UI.Animation {
* @param options Optional. Set this value to { mechanism: "transition" } to play the animation using CSS transitions instead of the default CSS animations. In some cases this can result in improved performance.
* @returns An object that completes when the animation is finished.
**/
function showEdgeUI(element: any, offset: any, options?: any): Promise<any>;
function showEdgeUI(element: any, offset?: any, options?: any): Promise<any>;
/**
* Performs an animation that slides a large panel user interface (UI) into view.
@@ -1749,7 +1839,7 @@ declare module WinJS.UI.Animation {
* @param offset Initial offsets where the animated objects begin relative to their final position at the end of the animation. Offsets should be the chosen so that the elements begin the animation from just off-screen. Note When the element parameter specifies an array of elements, the offset parameter can specify an offset array with each item specified for its corresponding element array item. If the array of offsets is smaller than the array of elements, the last offset is applied to all remaining elements.
* @returns An object that completes when the animation is finished.
**/
function showPanel(element: any, offset: any): Promise<any>;
function showPanel(element: any, offset?: any): Promise<any>;
/**
* Performs an animation that displays a pop-up user interface (UI).
@@ -1757,7 +1847,7 @@ declare module WinJS.UI.Animation {
* @param offset Initial offsets where the animated objects begin relative to their final position at the end of the animation. Offsets should be the chosen so that the elements begin the animation from just off-screen. Set this parameter to null to use the recommended default offset. Note When the element parameter specifies an array of elements, the offset parameter can specify an offset array with each item specified for its corresponding element array item. If the array of offsets is smaller than the array of elements, the last offset is applied to all remaining elements.
* @returns An object that completes when the animation is finished.
**/
function showPopup(element: any, offset: any): Promise<any>;
function showPopup(element: any, offset?: any): Promise<any>;
/**
* Performs a deselection animation in response to a swipe interaction.
@@ -1773,7 +1863,7 @@ declare module WinJS.UI.Animation {
* @param offset An initial offset where the animated objects begin relative to their final position at the end of the animation. Set this parameter to null to use the recommended default offset. Note When the incoming parameter specifies an array of elements, the offset parameter can specify an offset array with each item specified for its corresponding element array item. If the array of offsets is smaller than the array of elements, the last offset is applied to all remaining elements.
* @returns An object that completes when the animation is finished.
**/
function swipeReveal(target: any, offset: any): Promise<any>;
function swipeReveal(target: any, offset?: any): Promise<any>;
/**
* Performs a selection animation in response to a swipe interaction.
@@ -1789,7 +1879,7 @@ declare module WinJS.UI.Animation {
* @param offset Initial offsets where incoming animated objects begin relative to their final position at the end of the animation. Set this parameter to null to use the recommended default offset. Note When the incoming parameter specifies an array of elements, the offset parameter can specify an offset array with each item specified for its corresponding element array item. If the array of offsets is smaller than the array of elements, the last offset is applied to all remaining elements.
* @returns An object that completes when the animation is finished.
**/
function updateBadge(incoming: any, offset: any): Promise<any>;
function updateBadge(incoming: any, offset?: any): Promise<any>;
//#endregion Functions
@@ -2244,32 +2334,10 @@ declare module WinJS.UI {
/**
* Provides a mechanism for retrieving IItem objects asynchronously.
**/
interface IItemPromise<T> {
//#region Events
/**
* Occurs when there is an error in processing.
* @param eventInfo An object that contains information about the event.
**/
onerror(eventInfo: CustomEvent): void;
//#endregion Events
interface IItemPromise<T> extends IPromise<T> {
//#region Methods
/**
* Attempts to cancel the fulfillment of a promised value. If the promise hasn't already been fulfilled and cancellation is supported, the promise enters the error state with a value of Error("Canceled").
**/
cancel(): void;
/**
* Allows you to specify the work to be done on the fulfillment of the promised value, the error handling to be performed if the promise fails to fulfill a value, and the handling of progress notifications along the way. After the handlers have finished executing, this function throws any error that would have been returned from then as a promise in the error state.
* @param onComplete The function to be called if the promise is fulfilled successfully with a value. The fulfilled value is passed as the single argument. If the value is null, the fulfilled value is returned. The value returned from the function becomes the fulfilled value of the promise returned by then. If an exception is thrown while executing the function, the promise returned by then moves into the error state.
* @param onError The function to be called if the promise is fulfilled with an error. The error is passed as the single argument. If it is null, the error is forwarded. The value returned from the function is the fulfilled value of the promise returned by then.
* @param onProgress The function to be called if the promise reports progress. Data about the progress is passed as the single argument. Promises are not required to support progress.
**/
done(onComplete: (item: T) => void, onError?: (error: Error) => void, onProgress?: (progressData: any) => void): void;
/**
* Stops change notification tracking for the IItem that fulfills this IItemPromise.
**/
@@ -2278,16 +2346,7 @@ declare module WinJS.UI {
/**
* Begins change notification tracking for the IItem that fulfills this IItemPromise.
**/
retain(): void;
/**
* Allows you to specify the work to be done on the fulfillment of the promised value, the error handling to be performed if the promise fails to fulfill a value, and the handling of progress notifications along the way.
* @param onComplete The function to be called if the promise is fulfilled successfully with a value. The value is passed as the single argument. If the value is null, the value is returned. The value returned from the function becomes the fulfilled value of the promise returned by then. If an exception is thrown while this function is being executed, the promise returned by then moves into the error state.
* @param onError The function to be called if the promise is fulfilled with an error. The error is passed as the single argument. If it is null, the error is forwarded. The value returned from the function becomes the fulfilled value of the promise returned by then.
* @param onProgress The function to be called if the promise reports progress. Data about the progress is passed as the single argument. Promises are not required to support progress.
* @returns The promise whose value is the result of executing the complete or error function.
**/
then(onComplete: (item: T) => void, onError?: (error: Error) => void, onProgress?: (progressData: any) => void): IItemPromise<T>;
retain(): IItemPromise<T>;
//#endregion Methods
@@ -4608,7 +4667,7 @@ declare module WinJS.UI {
* @param placement The placement of the Menu to the anchor: top, bottom, left, or right.
* @param alignment For top or bottom placement, the alignment of the Menu to the anchor's edge: center, left, or right.
**/
show(anchor: HTMLElement, placement: string, alignment: string): void;
show(anchor: HTMLElement, placement?: string, alignment?: string): void;
/**
* Shows the specified commands of the Menu.
@@ -5511,6 +5570,13 @@ declare module WinJS.UI {
}
/**
* A special data source for VirtualizedDataSource.computeDataSourceGroups
**/
interface IListGroupDataSource<T> extends IListDataSource<T> {
groups: IListDataSource<T>;
}
/**
* Serves as the base class for a custom IListDataSource.
**/
@@ -5577,9 +5643,9 @@ declare module WinJS.UI {
* @param groupKey A callback function that accepts a single argument: an item in the IListDataSource. The function is called for each item in the list and must return the group key for that item as a string.
* @param groupData A callback function that accepts a single argument: an item in the IListDataSource. The function is called on one IListDataSource item for each group and must return an object that represents the header of that group.
* @param options An object that can contain properties that specify additional options: groupCountEstimate, batchSize.
* @returns An IListDataSource that contains the items in the original data source and provides additional group information in the form of a "groups" property. The "groups" property returns another IListDataSource that enumerates the different groups in the list.
* @returns An IListGroupDataSource that contains the items in the original data source and provides additional group information in the form of a "groups" property. The "groups" property returns another IListDataSource that enumerates the different groups in the list.
**/
function computeDataSourceGroups<T>(listDataSource: IListDataSource<T>, groupKey: Function, groupData: Function, options?: any): IListDataSource<T>;
function computeDataSourceGroups<T>(listDataSource: IListDataSource<T>, groupKey: Function, groupData: Function, options?: any): IListGroupDataSource<T>;
/**
* Used to disables all Animations Library and ListView animations. Calling this function does not guarantee that the animations will be disabled, as the determination is made based on several factors.
@@ -5679,6 +5745,7 @@ declare module WinJS.UI.Fragments {
* @param href The URI that contains the fragment to be cleared. If no URI is provided, the entire contents of the cache are cleared.
**/
function clearCache(href: string): void;
function clearCache(href: HTMLElement): void;
/**
* Loads the contents of the specified URI into the specified element without copying it.
@@ -5695,6 +5762,7 @@ declare module WinJS.UI.Fragments {
* @returns A promise that is fulfilled when the fragment has been loaded. If a target element is not specified, the copied fragment is the completed value. The fragment is added to the cache. See also render, where the element is not added to the cache.
**/
function renderCopy(href: string, target?: HTMLElement): Promise<HTMLElement>;
function renderCopy(href: HTMLElement, target?: HTMLElement): Promise<HTMLElement>;
//#endregion Functions
@@ -5716,7 +5784,7 @@ declare module WinJS.UI.Pages {
* @param err The error that occurred.
* @returns Nothing if the error was handled, or an error promise if the error was not handled.
**/
error? (err: any): Promise<any>;
error? (err: any): any;
/**
* Initializes the control before the content of the control is set. Use the processed method for any initialization that should be done after the content of the control has been set.
@@ -5724,14 +5792,14 @@ declare module WinJS.UI.Pages {
* @param options The options passed to the constructor of the page.
* @returns A promise that is fulfilled when initialization is complete, if asynchronous processing is necessary. If not, returns nothing.
**/
init? (element: HTMLElement, options: any): Promise<any>;
init? (element: HTMLElement, options: any): any;
/**
* Creates DOM objects from the content in the specified URI. This method is called after the PageControl is defined and before the init method is called.
* @param uri The URI from which to create DOM objects.
* @returns A promise whose fulfilled value is the set of unparented DOM objects.
**/
load? (uri: string): Promise<any>;
load? (uri: string): any;
/**
* Initializes the control after the content of the control is set.
@@ -5739,7 +5807,7 @@ declare module WinJS.UI.Pages {
* @param options The options that are to be passed to the constructor of the page.
* @returns A promise that is fulfilled when initialization is complete, if asynchronous processing is necessary. If not, returns nothing.
**/
processed? (element: HTMLElement, options: any): Promise<any>;
processed? (element: HTMLElement, options: any): any;
/**
* Called after all initialization and rendering is complete. At this time, the element is ready for use.
@@ -5747,7 +5815,7 @@ declare module WinJS.UI.Pages {
* @param options An object that contains one or more property/value pairs to apply to the PageControl. How these property/value pairs are used (or not used) depends on the implementation of that particular PageControl.
* @returns A promise that is fulfilled when the element is ready for use, if asynchronous processing is necessary. If not, returns nothing.
**/
ready? (element: HTMLElement, options: any): Promise<any>;
ready? (element: HTMLElement, options: any): any;
/**
* Takes the elements returned by the load method and attaches them to the specified element.
@@ -5765,11 +5833,6 @@ declare module WinJS.UI.Pages {
//#region Objects
/**
* A modular unit of HTML, CSS, and JavaScript that can be navigated to or used as a custom WinJS control.
**/
class PageControl {
}
//#endregion Objects
@@ -5781,14 +5844,14 @@ declare module WinJS.UI.Pages {
* @param members An object that defines the members that the control will have.
* @returns A constructor function that creates the PageControl.
**/
function define(uri: string, members: IPageControlMembers): PageControl;
function define(uri: string, members: IPageControlMembers): (element?: HTMLElement, options?: any, complete?: (page: any) => void, parentedPromise?: Promise<any>) => void;
/**
* Gets an already-defined page control for the specified URI, or creates a new one.
* @param uri The URI for the content that defines the page.
* @returns A constructor function that creates the page.
**/
function get(uri: string): Function;
function get(uri: string): (element?: HTMLElement, options?: any, complete?: (page: any) => void, parentedPromise?: Promise<any>) => void;
/**
* Creates a PageControl from the specified URI and inserts it inside the specified element.
@@ -5798,7 +5861,7 @@ declare module WinJS.UI.Pages {
* @param parentedPromise A Promise that is fulfilled when the new PageControl is done rendering and its contents becomes the child of element.
* @returns A promise that is fulfilled when rendering is complete, if asynchronous processing is necessary. If not, returns nothing.
**/
function render(uri: string, element: HTMLElement, options?: any, parentedPromise?: Promise<any>): Promise<void>;
function render(uri: string, element?: HTMLElement, options?: any, parentedPromise?: Promise<any>): Promise<any>;
//#endregion Functions
@@ -6362,6 +6425,12 @@ declare module WinJS.Utilities {
**/
include(items: T[]): void;
/**
* 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.
**/
include(items: HTMLCollection): void;
/**
* Registers the listener for the specified event on all the elements in the collection.
* @param eventType The name of the event.
@@ -6416,7 +6485,7 @@ declare module WinJS.Utilities {
* @param renderDonePromiseCallback If supplied, this function is called each time the template gets rendered, and is passed a promise that is fulfilled when the template rendering is complete.
* @returns The QueryCollection.
**/
template(templateElement: HTMLElement, data: any, renderDonePromiseCallback: Function): QueryCollection<T>;
template(templateElement: HTMLElement, data: any, renderDonePromiseCallback?: Function): QueryCollection<T>;
/**
* Toggles (adds or removes) the specified class on all the elements in the collection. If the class is present, it is removed; if it is absent, it is added.
@@ -6537,7 +6606,7 @@ declare module WinJS.Utilities {
* @param parent The parent element.
* @returns The relative left coordinate.
**/
function getRelativeLeft(element: HTMLElement, parent: HTMLElement): number;
function getRelativeLeft(element?: HTMLElement, parent?: HTMLElement): number;
/**
* Gets the top coordinate of the element relative to the specified parent.
@@ -6545,7 +6614,7 @@ declare module WinJS.Utilities {
* @param parent The parent element.
* @returns The relative top coordinate.
**/
function getRelativeTop(element: HTMLElement, parent: HTMLElement): number;
function getRelativeTop(element?: HTMLElement, parent?: HTMLElement): number;
/**
* Gets the height of the element, including its margins.
@@ -6663,6 +6732,7 @@ declare module WinJS.Utilities {
* @param options The tags for messages to log. Multiple tags should be separated by spaces. May contain type, tags, excludeTags and action properties.
**/
function startLog(options?: ILogOptions): void;
function startLog(tags?: string): void;
/**
* Removes the WinJS logger that had previously been set up.
@@ -6691,10 +6761,10 @@ declare module WinJS.Utilities {
//#region Interfaces
interface ILogOptions {
type: string;
type?: string;
action?: (message: string, tags: string, type: string) => void;
excludeTags: string;
tags: string;
excludeTags?: string;
tags?: string;
}
interface IPosition {

342
winjs/winjs-2.0.d.ts vendored
View File

@@ -1,6 +1,6 @@
// Type definitions for WinJS
// Project: http://msdn.microsoft.com/en-us/library/windows/apps/br229773.aspx
// Definitions by: TypeScript samples <https://www.typescriptlang.org/>, Adam Hewitt <https://github.com/adamhewitt627>, Craig Treasure <https://github.com/craigktreasure>
// Project: http://try.buildwinjs.com/
// Definitions by: TypeScript samples <https://www.typescriptlang.org/>, Adam Hewitt <https://github.com/adamhewitt627>, Craig Treasure <https://github.com/craigktreasure>, Jeff Fisher <https://github.com/xirzec>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/* *****************************************************************************
@@ -22,7 +22,7 @@ and limitations under the License.
* Defines an Element object.
**/
interface Element {
winControl: any; // TODO: This should be control?
winControl: any;
}
/**
@@ -55,7 +55,7 @@ interface IOHelper {
* Writes the specified text to the specified file.
* @param fileName The name of the file.
* @param text The content to be written to the file.
* @returns A promise that completes with a value that is the number of characters written.
* @returns A promise that is completed when the file has been written.
**/
writeText(fileName: string, text: string): WinJS.Promise<number>;
}
@@ -372,6 +372,12 @@ declare module WinJS.Binding {
//#endregion Properties
/**
* Returns a key/data pair for the specified index.
* @param index The index of the value to retrieve.
* @returns An object that has two properties: key and data.
**/
getItem(index: number): IGroupKeyDataPair<T>;
}
/**
@@ -442,7 +448,7 @@ declare module WinJS.Binding {
* 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;
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.
@@ -549,7 +555,7 @@ 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<T>;
createGrouped(groupKey: (x: T) => string, groupData: (x: T) => any, groupSorter?: (left: string, right: string) => number): GroupedSortedListProjection<T>;
/**
* Creates a live sorted projection over this list. As the list changes, the sorted projection reacts to those changes and may also change.
@@ -609,7 +615,7 @@ declare module WinJS.Binding {
* @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;
join(separator?: string): string;
/**
* Gets the index of the last occurrence of the specified value in a list.
@@ -617,7 +623,7 @@ declare module WinJS.Binding {
* @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;
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.
@@ -671,7 +677,7 @@ declare module WinJS.Binding {
* @param end The index that specifies the end of the section.
* @returns Returns a section of list.
**/
slice(begin: number, end: number): T[];
slice(begin: number, end?: number): T[];
/**
* Checks whether the specified callback function returns true for any element of a list.
@@ -724,6 +730,7 @@ declare module WinJS.Binding {
* @returns The new length of the list.
**/
push(value: T): number;
push(...values: T[]): number;
/**
* Removes the first element from a list and returns it.
@@ -737,6 +744,7 @@ declare module WinJS.Binding {
* @returns The new length of the list.
**/
unshift(value: T): number;
unshift(...values: T[]): number;
//#endregion Methods
}
@@ -944,30 +952,28 @@ declare module WinJS.Binding {
* @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?: string);
constructor(element: HTMLElement, options?: any);
//#endregion Constructors
//#region Methods
render: {
/**
* 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.
**/
(dataContext: any, container?: HTMLElement): Promise<HTMLElement>;
/**
* 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<HTMLElement>;
/**
* 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.
**/
value(href: string, dataContext: any, container?: HTMLElement): Promise<HTMLElement>;
};
/**
* 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<HTMLElement>;
//#endregion Methods
@@ -1128,6 +1134,12 @@ declare module WinJS.Binding {
data: T;
}
interface IGroupKeyDataPair<T> extends IKeyDataPair<T> {
groupSize: number;
firstItemIndexHint: number;
firstItemKey: string;
}
//#endregion Interfaces
}
@@ -1144,7 +1156,7 @@ declare module WinJS.Class {
* @param staticMembers The set of static fields, properties, and methods made available on the type.
* @returns The newly-defined type.
**/
function define(constructor: Function, instanceMembers?: any, staticMembers?: any): any;
function define(constructor?: Function, instanceMembers?: any, staticMembers?: any): any;
/**
* Creates a sub-class based on the specified baseClass parameter, using prototype inheritance.
@@ -1200,10 +1212,24 @@ declare module WinJS {
}
interface IPromise<T> {
cancel(): void;
done<U>(onComplete?: (value: T) => any, onError?: (error: any) => any, onProgress?: (progress: any) => void): void;
then<U>(onComplete?: (value: T) => IPromise<U>, onError?: (error: any) => IPromise<U>, onProgress?: (progress: any) => void): IPromise<U>;
then<U>(onComplete?: (value: T) => IPromise<U>, onError?: (error: any) => U, onProgress?: (progress: any) => void): IPromise<U>;
then<U>(onComplete?: (value: T) => IPromise<U>, onError?: (error: any) => void, onProgress?: (progress: any) => void): IPromise<U>;
then<U>(onComplete?: (value: T) => U, onError?: (error: any) => IPromise<U>, onProgress?: (progress: any) => void): IPromise<U>;
then<U>(onComplete?: (value: T) => U, onError?: (error: any) => U, onProgress?: (progress: any) => void): IPromise<U>;
then<U>(onComplete?: (value: T) => U, onError?: (error: any) => void, onProgress?: (progress: any) => void): IPromise<U>;
then<U>(onComplete?: (value: T) => void, onError?: (error: any) => IPromise<U>, onProgress?: (progress: any) => void): IPromise<U>;
then<U>(onComplete?: (value: T) => void, onError?: (error: any) => U, onProgress?: (progress: any) => void): IPromise<U>;
then<U>(onComplete?: (value: T) => void, onError?: (error: any) => void, onProgress?: (progress: any) => void): IPromise<U>;
}
/**
* Provides a mechanism to schedule work to be done on a value that has not yet been computed. It is an 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.
**/
class Promise<T> {
class Promise<T> implements IPromise<T> {
//#region Constructors
/**
@@ -1222,7 +1248,7 @@ declare module WinJS {
* Occurs when there is an error in processing a promise.
* @param eventInfo An object that contains information about the event.
**/
onerror(eventInfo: CustomEvent): void;
static onerror(eventInfo: CustomEvent): void;
//#endregion Events
@@ -1234,34 +1260,40 @@ declare module WinJS {
* @param listener The listener to invoke when the event is raised.
* @param capture true to initiate capture, otherwise false.
**/
addEventListener(type: string, listener: Function, capture?: boolean): void;
static addEventListener(type: string, listener: Function, capture?: boolean): void;
/**
* Returns a promise that is fulfilled when one of the input promises has been fulfilled.
* @param value An array that contains Promise objects or objects whose property values include Promise objects.
* @returns A promise that on fulfillment yields the value of the input (complete or error).
**/
static any(value: Promise<any>[]): Promise<any>;
static any(value: IPromise<any>[]): IPromise<any>;
static any(value: any): IPromise<any>;
/**
* Returns a promise. If the object is already a Promise it is returned; otherwise the object is wrapped in a Promise. You can use this function when you need to treat a non-Promise object like a Promise, for example when you are calling a function that expects a promise, but already have the value needed rather than needing to get it asynchronously.
* @param value The value to be treated as a Promise.
* @returns The promise.
**/
static as<U>(value: U): Promise<U>;
static as<U>(value?: U): IPromise<U>;
/**
* Attempts to cancel the fulfillment of a promised value. If the promise hasn't already been fulfilled and cancellation is supported, the promise enters the error state with a value of Error("Canceled").
**/
cancel(): void;
/**
* Canceled promise value, can be returned from a promise completion handler to indicate cancelation of the promise chain.
*/
static cancel: IPromise<any>;
/**
* Raises an event of the specified type and 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;
static dispatchEvent(type: string, details: any): boolean;
/**
* Allows you to specify the work to be done on the fulfillment of the promised value, the error handling to be performed if the promise fails to fulfill a value, and the handling of progress notifications along the way. After the handlers have finished executing, this function throws any error that would have been returned from then as a promise in the error state. For more information about the differences between then and done, see the following topics: Quickstart: using promises in JavaScript How to handle errors when using promises in JavaScript Chaining promises in JavaScript.
@@ -1283,7 +1315,7 @@ declare module WinJS {
* @param values An object whose members contain values, some of which may be promises.
* @returns A Promise whose value is an object with the same field names as those of the object in the values parameter, where each field value is the fulfilled value of a promise.
**/
static join(values: any): Promise<any>;
static join(values: any): IPromise<any>;
/**
* Removes an event listener from the control.
@@ -1291,7 +1323,7 @@ declare module WinJS {
* @param listener The listener to remove.
* @param capture Specifies whether or not to initiate capture.
**/
removeEventListener(eventType: string, listener: Function, capture?: boolean): void;
static removeEventListener(eventType: string, listener: Function, capture?: boolean): void;
/**
* Allows you to specify the work to be done on the fulfillment of the promised value, the error handling to be performed if the promise fails to fulfill a value, and the handling of progress notifications along the way. For more information about the differences between then and done, see the following topics: Quickstart: using promises in JavaScript How to handle errors when using promises in JavaScript Chaining promises in JavaScript.
@@ -1300,7 +1332,7 @@ declare module WinJS {
* @param onProgress The function to be called if the promise reports progress. Data about the progress is passed as the single argument. Promises are not required to support progress.
* @returns The promise whose value is the result of executing the onComplete function.
**/
then<U>(onComplete?: (value: T) => Promise<U>, onError?: (error: any) => Promise<U>, onProgress?: (progress: any) => void): Promise<U>;
then<U>(onComplete?: (value: T) => IPromise<U>, onError?: (error: any) => IPromise<U>, onProgress?: (progress: any) => void): IPromise<U>;
/**
* Allows you to specify the work to be done on the fulfillment of the promised value, the error handling to be performed if the promise fails to fulfill a value, and the handling of progress notifications along the way. For more information about the differences between then and done, see the following topics: Quickstart: using promises in JavaScript How to handle errors when using promises in JavaScript Chaining promises in JavaScript.
@@ -1309,7 +1341,7 @@ declare module WinJS {
* @param onProgress The function to be called if the promise reports progress. Data about the progress is passed as the single argument. Promises are not required to support progress.
* @returns The promise whose value is the result of executing the onComplete function.
**/
then<U>(onComplete?: (value: T) => Promise<U>, onError?: (error: any) => U, onProgress?: (progress: any) => void): Promise<U>;
then<U>(onComplete?: (value: T) => IPromise<U>, onError?: (error: any) => U, onProgress?: (progress: any) => void): IPromise<U>;
/**
* Allows you to specify the work to be done on the fulfillment of the promised value, the error handling to be performed if the promise fails to fulfill a value, and the handling of progress notifications along the way. For more information about the differences between then and done, see the following topics: Quickstart: using promises in JavaScript How to handle errors when using promises in JavaScript Chaining promises in JavaScript.
@@ -1318,7 +1350,7 @@ declare module WinJS {
* @param onProgress The function to be called if the promise reports progress. Data about the progress is passed as the single argument. Promises are not required to support progress.
* @returns The promise whose value is the result of executing the onComplete function.
**/
then<U>(onComplete?: (value: T) => U, onError?: (error: any) => Promise<U>, onProgress?: (progress: any) => void): Promise<U>;
then<U>(onComplete?: (value: T) => IPromise<U>, onError?: (error: any) => void, onProgress?: (progress: any) => void): IPromise<U>;
/**
* Allows you to specify the work to be done on the fulfillment of the promised value, the error handling to be performed if the promise fails to fulfill a value, and the handling of progress notifications along the way. For more information about the differences between then and done, see the following topics: Quickstart: using promises in JavaScript How to handle errors when using promises in JavaScript Chaining promises in JavaScript.
@@ -1327,7 +1359,63 @@ declare module WinJS {
* @param onProgress The function to be called if the promise reports progress. Data about the progress is passed as the single argument. Promises are not required to support progress.
* @returns The promise whose value is the result of executing the onComplete function.
**/
then<U>(onComplete?: (value: T) => U, onError?: (error: any) => U, onProgress?: (progress: any) => void): Promise<U>;
then<U>(onComplete?: (value: T) => U, onError?: (error: any) => IPromise<U>, onProgress?: (progress: any) => void): IPromise<U>;
/**
* Allows you to specify the work to be done on the fulfillment of the promised value, the error handling to be performed if the promise fails to fulfill a value, and the handling of progress notifications along the way. For more information about the differences between then and done, see the following topics: Quickstart: using promises in JavaScript How to handle errors when using promises in JavaScript Chaining promises in JavaScript.
* @param onComplete The function to be called if the promise is fulfilled successfully with a value. The value is passed as the single argument. If the value is null, the value is returned. The value returned from the function becomes the fulfilled value of the promise returned by then. If an exception is thrown while this function is being executed, the promise returned by then moves into the error state.
* @param onError The function to be called if the promise is fulfilled with an error. The error is passed as the single argument. In different cases this object may be of different types, so it is necessary to test the object for the properties you expect. If the error is null, it is forwarded. The value returned from the function becomes the value of the promise returned by the then function.
* @param onProgress The function to be called if the promise reports progress. Data about the progress is passed as the single argument. Promises are not required to support progress.
* @returns The promise whose value is the result of executing the onComplete function.
**/
then<U>(onComplete?: (value: T) => U, onError?: (error: any) => U, onProgress?: (progress: any) => void): IPromise<U>;
/**
* Allows you to specify the work to be done on the fulfillment of the promised value, the error handling to be performed if the promise fails to fulfill a value, and the handling of progress notifications along the way. For more information about the differences between then and done, see the following topics: Quickstart: using promises in JavaScript How to handle errors when using promises in JavaScript Chaining promises in JavaScript.
* @param onComplete The function to be called if the promise is fulfilled successfully with a value. The value is passed as the single argument. If the value is null, the value is returned. The value returned from the function becomes the fulfilled value of the promise returned by then. If an exception is thrown while this function is being executed, the promise returned by then moves into the error state.
* @param onError The function to be called if the promise is fulfilled with an error. The error is passed as the single argument. In different cases this object may be of different types, so it is necessary to test the object for the properties you expect. If the error is null, it is forwarded. The value returned from the function becomes the value of the promise returned by the then function.
* @param onProgress The function to be called if the promise reports progress. Data about the progress is passed as the single argument. Promises are not required to support progress.
* @returns The promise whose value is the result of executing the onComplete function.
**/
then<U>(onComplete?: (value: T) => U, onError?: (error: any) => void, onProgress?: (progress: any) => void): IPromise<U>;
/**
* Allows you to specify the work to be done on the fulfillment of the promised value, the error handling to be performed if the promise fails to fulfill a value, and the handling of progress notifications along the way. For more information about the differences between then and done, see the following topics: Quickstart: using promises in JavaScript How to handle errors when using promises in JavaScript Chaining promises in JavaScript.
* @param onComplete The function to be called if the promise is fulfilled successfully with a value. The value is passed as the single argument. If the value is null, the value is returned. The value returned from the function becomes the fulfilled value of the promise returned by then. If an exception is thrown while this function is being executed, the promise returned by then moves into the error state.
* @param onError The function to be called if the promise is fulfilled with an error. The error is passed as the single argument. In different cases this object may be of different types, so it is necessary to test the object for the properties you expect. If the error is null, it is forwarded. The value returned from the function becomes the value of the promise returned by the then function.
* @param onProgress The function to be called if the promise reports progress. Data about the progress is passed as the single argument. Promises are not required to support progress.
* @returns The promise whose value is the result of executing the onComplete function.
**/
then<U>(onComplete?: (value: T) => void, onError?: (error: any) => IPromise<U>, onProgress?: (progress: any) => void): IPromise<U>;
/**
* Allows you to specify the work to be done on the fulfillment of the promised value, the error handling to be performed if the promise fails to fulfill a value, and the handling of progress notifications along the way. For more information about the differences between then and done, see the following topics: Quickstart: using promises in JavaScript How to handle errors when using promises in JavaScript Chaining promises in JavaScript.
* @param onComplete The function to be called if the promise is fulfilled successfully with a value. The value is passed as the single argument. If the value is null, the value is returned. The value returned from the function becomes the fulfilled value of the promise returned by then. If an exception is thrown while this function is being executed, the promise returned by then moves into the error state.
* @param onError The function to be called if the promise is fulfilled with an error. The error is passed as the single argument. In different cases this object may be of different types, so it is necessary to test the object for the properties you expect. If the error is null, it is forwarded. The value returned from the function becomes the value of the promise returned by the then function.
* @param onProgress The function to be called if the promise reports progress. Data about the progress is passed as the single argument. Promises are not required to support progress.
* @returns The promise whose value is the result of executing the onComplete function.
**/
then<U>(onComplete?: (value: T) => void, onError?: (error: any) => U, onProgress?: (progress: any) => void): IPromise<U>;
/**
* Allows you to specify the work to be done on the fulfillment of the promised value, the error handling to be performed if the promise fails to fulfill a value, and the handling of progress notifications along the way. For more information about the differences between then and done, see the following topics: Quickstart: using promises in JavaScript How to handle errors when using promises in JavaScript Chaining promises in JavaScript.
* @param onComplete The function to be called if the promise is fulfilled successfully with a value. The value is passed as the single argument. If the value is null, the value is returned. The value returned from the function becomes the fulfilled value of the promise returned by then. If an exception is thrown while this function is being executed, the promise returned by then moves into the error state.
* @param onError The function to be called if the promise is fulfilled with an error. The error is passed as the single argument. In different cases this object may be of different types, so it is necessary to test the object for the properties you expect. If the error is null, it is forwarded. The value returned from the function becomes the value of the promise returned by the then function.
* @param onProgress The function to be called if the promise reports progress. Data about the progress is passed as the single argument. Promises are not required to support progress.
* @returns The promise whose value is the result of executing the onComplete function.
**/
then<U>(onComplete?: (value: T) => void, onError?: (error: any) => void, onProgress?: (progress: any) => void): IPromise<U>;
/**
* A static helper that functions identically to then() off a promise instance.
* @param promise The promise to chain from.
* @param onComplete The function to be called if the promise is fulfilled successfully with a value. The value is passed as the single argument. If the value is null, the value is returned. The value returned from the function becomes the fulfilled value of the promise returned by then. If an exception is thrown while this function is being executed, the promise returned by then moves into the error state.
* @param onError The function to be called if the promise is fulfilled with an error. The error is passed as the single argument. In different cases this object may be of different types, so it is necessary to test the object for the properties you expect. If the error is null, it is forwarded. The value returned from the function becomes the value of the promise returned by the then function.
* @param onProgress The function to be called if the promise reports progress. Data about the progress is passed as the single argument. Promises are not required to support progress.
* @returns The promise whose value is the result of executing the onComplete function.
**/
static then(promise: IPromise<any>, onComplete?: (value: any) => any, onError?: (error: any) => any, onProgress?: (progress: any) => void): IPromise<any>;
/**
* Performs an operation on all the input promises and returns a promise that has the shape of the input and contains the result of the operation that has been performed on each input.
@@ -1337,7 +1425,7 @@ declare module WinJS {
* @param progress The function to be called if the promise reports progress. This function takes a single argument, which is the data about the progress of the promise. Promises are not required to support progress.
* @returns A Promise that is the result of calling join on the values parameter.
**/
static thenEach(values: any, complete?: (value: any) => void, error?: (error: any) => void, progress?: (progress: any) => void): Promise<any>;
static thenEach(values: any, complete?: (value: any) => void, error?: (error: any) => void, progress?: (progress: any) => void): IPromise<any>;
/**
* This method has two forms: WinJS.Promise.timeout(timeout) and WinJS.Promise.timeout(timeout, promise). WinJS.Promise.timeout(timeout) creates a promise that is completed asynchronously after the specified timeout, essentially wrapping a call to setTimeout within a promise. WinJS.Promise.timeout(timeout, promise) sets a timeout period for completion of the specified promise, automatically canceling the promise if it is not completed within the timeout period.
@@ -1345,21 +1433,21 @@ declare module WinJS {
* @param promise Optional. A promise that will be canceled if it doesn't complete within the timeout period.
* @returns If the promise parameter is omitted, returns a promise that will be fulfilled after the timeout period. If the promise paramater is provided, the same promise is returned.
**/
static timeout(timeout: number, promise?: Promise<any>): Promise<any>;
static timeout(timeout?: number, promise?: IPromise<any>): IPromise<any>;
/**
* Wraps a non-promise value in a promise. This method is like wrapError, which allows you to produce a Promise in error conditions, in that it allows you to return a Promise in success conditions.
* @param value Some non-promise value to be wrapped in a promise.
* @returns A promise that is successfully fulfilled with the specified value.
**/
static wrap<U>(value: U): Promise<U>;
static wrap<U>(value?: U): IPromise<U>;
/**
* Wraps a non-promise error value in a promise. You can use this function if you need to pass an error to a function that requires a promise.
* @param error A non-promise error value to be wrapped in a promise.
* @returns A promise that is in an error state with the specified value.
**/
static wrapError<U>(error: U): Promise<U>;
static wrapError<U>(error: U): IPromise<U>;
//#endregion Methods
@@ -1375,7 +1463,8 @@ declare module WinJS {
* @param tags The tag or tags to categorize the message (winjs, winjs controls, etc.).
* @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;
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.
@@ -1399,8 +1488,9 @@ declare module WinJS {
user?: string;
password?: string;
headers?: any;
data: any;
data?: any;
responseType?: string;
customRequestInitializer?: (request: XMLHttpRequest) => void;
}
//#endregion Interfaces
@@ -1561,7 +1651,7 @@ declare module WinJS.Resources {
* Processes data-win-res attributes on elements and replaces attributes and properties with resource strings.
* @param rootElement The element to process. The element and its child elements will be processed. If an element isn't specified, the entire document is processed.
**/
function processAll(rootElement?: HTMLElement): void;
function processAll(rootElement?: HTMLElement): Promise<void>;
/**
* Removes an event listener that the addEventListener method registered.
@@ -1666,7 +1756,7 @@ declare module WinJS.UI.Animation {
* @param offset Initial offsets where the animated objects begin relative to their final position at the end of the animation. Set this parameter to null to use the recommended default offset. Note When the incoming parameter specifies an array of elements, the offset parameter can specify an offset array with each item specified for its corresponding element array item. If the array of offsets is smaller than the array of elements, the last offset is applied to all remaining elements.
* @returns An object that completes when the animation is finished.
**/
function dragBetweenEnter(target: any, offset: any): Promise<any>;
function dragBetweenEnter(target: any, offset?: any): Promise<any>;
/**
* Performs an animation when a dragged object is moved away from items that it had previously involved in a dragBetweenEnter animation. The affected objects are animated back to their original positions.
@@ -1682,7 +1772,7 @@ declare module WinJS.UI.Animation {
* @param affected Element or elements whose position the dropped object affects. Typically, this is all other items in a reorderable list. This should be the same element or element collection passed as the affected parameter in the dragSourceStart animation.
* @returns An object that completes when the animation is finished.
**/
function dragSourceEnd(dragSource: any, offset: any, affected?: any): Promise<any>;
function dragSourceEnd(dragSource: any, offset?: any, affected?: any): Promise<any>;
/**
* Performs an animation when the user begins to drag an object.
@@ -1699,7 +1789,7 @@ declare module WinJS.UI.Animation {
* @param options Optional. Set this value to { mechanism: "transition" } to play the animation using CSS transitions instead of the default CSS animations. In some cases this can result in improved performance.
* @returns An object that completes when the animation is finished.
**/
function enterContent(incoming: any, offset: any, options?: any): Promise<any>;
function enterContent(incoming: any, offset?: any, options?: any): Promise<any>;
/**
* Performs an animation that shows a new page of content, either when transitioning between pages in a running app or when displaying the first content in a newly launched app.
@@ -1707,7 +1797,7 @@ declare module WinJS.UI.Animation {
* @param offset An initial offset where the element or elements begin relative to their final position at the end of the animation. Set this parameter to null to use the recommended default offset. Note When the element parameter specifies an array of elements, the offset parameter can specify an offset array with each item specified for its corresponding element array item. If the array of offsets is smaller than the array of elements, the last offset is applied to all remaining elements.
* @returns An object that completes when the animation is finished.
**/
function enterPage(element: any, offset: any): Promise<any>;
function enterPage(element: any, offset?: any): Promise<any>;
/**
* Performs an animation that hides one or more elements on a page.
@@ -1715,7 +1805,7 @@ declare module WinJS.UI.Animation {
* @param offset Initial offsets where the animated objects begin relative to their final position at the end of the animation. Set this parameter to null to use the recommended default offset. Note When the incoming parameter specifies an array of elements, the offset parameter can specify an offset array with each item specified for its corresponding element array item. If the array of offsets is smaller than the array of elements, the last offset is applied to all remaining elements.
* @returns An object that completes when the animation is finished.
**/
function exitContent(outgoing: any, offset: any): Promise<any>;
function exitContent(outgoing: any, offset?: any): Promise<any>;
/**
* Performs an animation that dismisses the current page when transitioning between pages in an app.
@@ -1723,7 +1813,7 @@ declare module WinJS.UI.Animation {
* @param offset Initial offsets where the animated objects begin relative to their final position at the end of the animation. Set this parameter to null to use the recommended default offset. Note When the incoming parameter specifies an array of elements, the offset parameter can specify an offset array with each item specified for its corresponding element array item. If the array of offsets is smaller than the array of elements, the last offset is applied to all remaining elements.
* @returns An object that completes when the animation is finished.
**/
function exitPage(outgoing: any, offset: any): Promise<any>;
function exitPage(outgoing: any, offset?: any): Promise<any>;
/**
* Performs an animation that fades an item or set of items into view.
@@ -1746,7 +1836,7 @@ declare module WinJS.UI.Animation {
* @param options Optional. Set this value to { mechanism: "transition" } to play the animation using CSS transitions instead of the default CSS animations. In some cases this can result in improved performance.
* @returns An object that completes when the animation is finished.
**/
function hideEdgeUI(element: any, offset: any, options?: any): Promise<any>;
function hideEdgeUI(element: any, offset?: any, options?: any): Promise<any>;
/**
* Performs an animation that hides a panel.
@@ -1754,7 +1844,7 @@ declare module WinJS.UI.Animation {
* @param offset Initial offsets where the animated objects begin relative to their final position at the end of the animation. Offsets should be the chosen so that the elements end the animation just off-screen. Note When the element parameter specifies an array of elements, the offset parameter can specify an offset array with each item specified for its corresponding element array item. If the array of offsets is smaller than the array of elements, the last offset is applied to all remaining elements.
* @returns An object that completes when the animation is finished.
**/
function hidePanel(element: any, offset: any): Promise<any>;
function hidePanel(element: any, offset?: any): Promise<any>;
/**
* Performs an animation that removes pop-up user interface (UI).
@@ -1784,7 +1874,7 @@ declare module WinJS.UI.Animation {
* @param options Optional. Set this value to { mechanism: "transition" } to play the animation using CSS transitions instead of the default CSS animations. In some cases this can result in improved performance.
* @returns An object that completes when the animation is finished.
**/
function showEdgeUI(element: any, offset: any, options?: any): Promise<any>;
function showEdgeUI(element: any, offset?: any, options?: any): Promise<any>;
/**
* Performs an animation that slides a large panel user interface (UI) into view.
@@ -1792,7 +1882,7 @@ declare module WinJS.UI.Animation {
* @param offset Initial offsets where the animated objects begin relative to their final position at the end of the animation. Offsets should be the chosen so that the elements begin the animation from just off-screen. Note When the element parameter specifies an array of elements, the offset parameter can specify an offset array with each item specified for its corresponding element array item. If the array of offsets is smaller than the array of elements, the last offset is applied to all remaining elements.
* @returns An object that completes when the animation is finished.
**/
function showPanel(element: any, offset: any): Promise<any>;
function showPanel(element: any, offset?: any): Promise<any>;
/**
* Performs an animation that displays a pop-up user interface (UI).
@@ -1800,7 +1890,7 @@ declare module WinJS.UI.Animation {
* @param offset Initial offsets where the animated objects begin relative to their final position at the end of the animation. Offsets should be the chosen so that the elements begin the animation from just off-screen. Set this parameter to null to use the recommended default offset. Note When the element parameter specifies an array of elements, the offset parameter can specify an offset array with each item specified for its corresponding element array item. If the array of offsets is smaller than the array of elements, the last offset is applied to all remaining elements.
* @returns An object that completes when the animation is finished.
**/
function showPopup(element: any, offset: any): Promise<any>;
function showPopup(element: any, offset?: any): Promise<any>;
/**
* Performs a deselection animation in response to a swipe interaction.
@@ -1816,7 +1906,7 @@ declare module WinJS.UI.Animation {
* @param offset An initial offset where the animated objects begin relative to their final position at the end of the animation. Set this parameter to null to use the recommended default offset. Note When the incoming parameter specifies an array of elements, the offset parameter can specify an offset array with each item specified for its corresponding element array item. If the array of offsets is smaller than the array of elements, the last offset is applied to all remaining elements.
* @returns An object that completes when the animation is finished.
**/
function swipeReveal(target: any, offset: any): Promise<any>;
function swipeReveal(target: any, offset?: any): Promise<any>;
/**
* Performs a selection animation in response to a swipe interaction.
@@ -1832,7 +1922,7 @@ declare module WinJS.UI.Animation {
* @param offset Initial offsets where incoming animated objects begin relative to their final position at the end of the animation. Set this parameter to null to use the recommended default offset. Note When the incoming parameter specifies an array of elements, the offset parameter can specify an offset array with each item specified for its corresponding element array item. If the array of offsets is smaller than the array of elements, the last offset is applied to all remaining elements.
* @returns An object that completes when the animation is finished.
**/
function updateBadge(incoming: any, offset: any): Promise<any>;
function updateBadge(incoming: any, offset?: any): Promise<any>;
//#endregion Functions
@@ -2329,32 +2419,9 @@ declare module WinJS.UI {
/**
* Provides a mechanism for retrieving IItem objects asynchronously.
**/
interface IItemPromise<T> {
//#region Events
/**
* Occurs when there is an error in processing.
* @param eventInfo An object that contains information about the event.
**/
onerror(eventInfo: CustomEvent): void;
//#endregion Events
interface IItemPromise<T> extends IPromise<T> {
//#region Methods
/**
* Attempts to cancel the fulfillment of a promised value. If the promise hasn't already been fulfilled and cancellation is supported, the promise enters the error state with a value of Error("Canceled").
**/
cancel(): void;
/**
* Allows you to specify the work to be done on the fulfillment of the promised value, the error handling to be performed if the promise fails to fulfill a value, and the handling of progress notifications along the way. After the handlers have finished executing, this function throws any error that would have been returned from then as a promise in the error state.
* @param onComplete The function to be called if the promise is fulfilled successfully with a value. The fulfilled value is passed as the single argument. If the value is null, the fulfilled value is returned. The value returned from the function becomes the fulfilled value of the promise returned by then. If an exception is thrown while executing the function, the promise returned by then moves into the error state.
* @param onError The function to be called if the promise is fulfilled with an error. The error is passed as the single argument. If it is null, the error is forwarded. The value returned from the function is the fulfilled value of the promise returned by then.
* @param onProgress The function to be called if the promise reports progress. Data about the progress is passed as the single argument. Promises are not required to support progress.
**/
done(onComplete: (item: T) => void, onError?: (error: Error) => void, onProgress?: (progressData: any) => void): void;
/**
* Stops change notification tracking for the IItem that fulfills this IItemPromise.
**/
@@ -2363,16 +2430,7 @@ declare module WinJS.UI {
/**
* Begins change notification tracking for the IItem that fulfills this IItemPromise.
**/
retain(): void;
/**
* Allows you to specify the work to be done on the fulfillment of the promised value, the error handling to be performed if the promise fails to fulfill a value, and the handling of progress notifications along the way.
* @param onComplete The function to be called if the promise is fulfilled successfully with a value. The value is passed as the single argument. If the value is null, the value is returned. The value returned from the function becomes the fulfilled value of the promise returned by then. If an exception is thrown while this function is being executed, the promise returned by then moves into the error state.
* @param onError The function to be called if the promise is fulfilled with an error. The error is passed as the single argument. If it is null, the error is forwarded. The value returned from the function becomes the fulfilled value of the promise returned by then.
* @param onProgress The function to be called if the promise reports progress. Data about the progress is passed as the single argument. Promises are not required to support progress.
* @returns The promise whose value is the result of executing the complete or error function.
**/
then(onComplete: (item: T) => void, onError?: (error: Error) => void, onProgress?: (progressData: any) => void): IItemPromise<T>;
retain(): IItemPromise<T>;
//#endregion Methods
@@ -3254,6 +3312,11 @@ declare module WinJS.UI {
* Gets or sets whether the ListView item is focused and is showing its focus visual.
**/
showFocus?: boolean;
/**
* Gets the type, if any.
**/
type?: WinJS.UI.ObjectType;
}
/**
@@ -4264,7 +4327,7 @@ declare module WinJS.UI {
* @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;
show(anchor: HTMLElement, placement?: string, alignment?: string): void;
//#endregion Methods
@@ -4350,6 +4413,14 @@ declare module WinJS.UI {
**/
executeAnimations(): void;
/**
* Determines the next item to receive keyboard focus.
* @param currentItem An object that describes the current item. It has these properties: index, type.
* @param pressedKey The key that was pressed.
* @returns An object that describes the next item that should receive focus. It has these properties: index, type.
**/
getAdjacent(currentItem: any, pressedKey: WinJS.Utilities.Key): any;
/**
* This method is no longer supported.
* @param itemIndex
@@ -4670,7 +4741,7 @@ declare module WinJS.UI {
/**
* This API supports the SemanticZoom infrastructure and is not intended to be used directly from your code.
**/
zoomableView: IZoomableView<Hub>;
zoomableView: IZoomableView<any>;
//#endregion Properties
@@ -4919,6 +4990,14 @@ declare module WinJS.UI {
**/
executeAnimations(): void;
/**
* Determines the next item to receive keyboard focus.
* @param currentItem An object that describes the current item. It has these properties: index, type.
* @param pressedKey The key that was pressed.
* @returns An object that describes the next item that should receive focus. It has these properties: index, type.
**/
getAdjacent(currentItem: any, pressedKey: WinJS.Utilities.Key): any;
/**
* This method is no longer supported.
* @param itemIndex
@@ -5511,7 +5590,7 @@ declare module WinJS.UI {
* @param placement The placement of the Menu to the anchor: top, bottom, left, or right.
* @param alignment For top or bottom placement, the alignment of the Menu to the anchor's edge: center, left, or right.
**/
show(anchor: HTMLElement, placement: string, alignment: string): void;
show(anchor: HTMLElement, placement?: string, alignment?: string): void;
/**
* Shows the specified commands of the Menu.
@@ -6136,9 +6215,10 @@ declare module WinJS.UI {
/**
* Creates a new Repeater control.
* @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(options?: any);
constructor(element?: HTMLElement, options?: any);
//#endregion Constructors
@@ -6411,6 +6491,8 @@ declare module WinJS.UI {
//#endregion Properties
static createResultSuggestionImage(url: string): any;
}
/**
@@ -7110,6 +7192,13 @@ declare module WinJS.UI {
}
/**
* A special data source for VirtualizedDataSource.computeDataSourceGroups
**/
interface IListGroupDataSource<T> extends IListDataSource<T> {
groups: IListDataSource<T>;
}
/**
* Serves as the base class for a custom IListDataSource.
**/
@@ -7176,9 +7265,9 @@ declare module WinJS.UI {
* @param groupKey A callback function that accepts a single argument: an item in the IListDataSource. The function is called for each item in the list and must return the group key for that item as a string.
* @param groupData A callback function that accepts a single argument: an item in the IListDataSource. The function is called on one IListDataSource item for each group and must return an object that represents the header of that group.
* @param options An object that can contain properties that specify additional options: groupCountEstimate, batchSize.
* @returns An IListDataSource that contains the items in the original data source and provides additional group information in the form of a "groups" property. The "groups" property returns another IListDataSource that enumerates the different groups in the list.
* @returns An IListGroupDataSource that contains the items in the original data source and provides additional group information in the form of a "groups" property. The "groups" property returns another IListDataSource that enumerates the different groups in the list.
**/
function computeDataSourceGroups<T>(listDataSource: IListDataSource<T>, groupKey: Function, groupData: Function, options?: any): IListDataSource<T>;
function computeDataSourceGroups<T>(listDataSource: IListDataSource<T>, groupKey: Function, groupData: Function, options?: any): IListGroupDataSource<T>;
/**
* Used to disables all Animations Library and ListView animations. Calling this function does not guarantee that the animations will be disabled, as the determination is made based on several factors.
@@ -7278,6 +7367,7 @@ declare module WinJS.UI.Fragments {
* @param href The URI that contains the fragment to be cleared. If no URI is provided, the entire contents of the cache are cleared.
**/
function clearCache(href: string): void;
function clearCache(href: HTMLElement): void;
/**
* Loads the contents of the specified URI into the specified element without copying it.
@@ -7294,6 +7384,7 @@ declare module WinJS.UI.Fragments {
* @returns A promise that is fulfilled when the fragment has been loaded. If a target element is not specified, the copied fragment is the completed value. The fragment is added to the cache. See also render, where the element is not added to the cache.
**/
function renderCopy(href: string, target?: HTMLElement): Promise<HTMLElement>;
function renderCopy(href: HTMLElement, target?: HTMLElement): Promise<HTMLElement>;
//#endregion Functions
@@ -7315,7 +7406,7 @@ declare module WinJS.UI.Pages {
* @param err The error that occurred.
* @returns Nothing if the error was handled, or an error promise if the error was not handled.
**/
error? (err: any): Promise<any>;
error? (err: any): any;
/**
* Initializes the control before the content of the control is set. Use the processed method for any initialization that should be done after the content of the control has been set.
@@ -7323,14 +7414,14 @@ declare module WinJS.UI.Pages {
* @param options The options passed to the constructor of the page.
* @returns A promise that is fulfilled when initialization is complete, if asynchronous processing is necessary. If not, returns nothing.
**/
init? (element: HTMLElement, options: any): Promise<any>;
init? (element: HTMLElement, options: any): any;
/**
* Creates DOM objects from the content in the specified URI. This method is called after the PageControl is defined and before the init method is called.
* @param uri The URI from which to create DOM objects.
* @returns A promise whose fulfilled value is the set of unparented DOM objects.
**/
load? (uri: string): Promise<any>;
load? (uri: string): any;
/**
* Initializes the control after the content of the control is set.
@@ -7338,7 +7429,7 @@ declare module WinJS.UI.Pages {
* @param options The options that are to be passed to the constructor of the page.
* @returns A promise that is fulfilled when initialization is complete, if asynchronous processing is necessary. If not, returns nothing.
**/
processed? (element: HTMLElement, options: any): Promise<any>;
processed? (element: HTMLElement, options: any): any;
/**
* Called after all initialization and rendering is complete. At this time, the element is ready for use.
@@ -7346,7 +7437,7 @@ declare module WinJS.UI.Pages {
* @param options An object that contains one or more property/value pairs to apply to the PageControl. How these property/value pairs are used (or not used) depends on the implementation of that particular PageControl.
* @returns A promise that is fulfilled when the element is ready for use, if asynchronous processing is necessary. If not, returns nothing.
**/
ready? (element: HTMLElement, options: any): Promise<any>;
ready? (element: HTMLElement, options: any): any;
/**
* Takes the elements returned by the load method and attaches them to the specified element.
@@ -7364,11 +7455,6 @@ declare module WinJS.UI.Pages {
//#region Objects
/**
* A modular unit of HTML, CSS, and JavaScript that can be navigated to or used as a custom WinJS control.
**/
class PageControl {
}
//#endregion Objects
@@ -7380,14 +7466,14 @@ declare module WinJS.UI.Pages {
* @param members An object that defines the members that the control will have.
* @returns A constructor function that creates the PageControl.
**/
function define(uri: string, members: IPageControlMembers): PageControl;
function define(uri: string, members: IPageControlMembers): (element?: HTMLElement, options?: any, complete?: (page: any) => void, parentedPromise?: Promise<any>) => void;
/**
* Gets an already-defined page control for the specified URI, or creates a new one.
* @param uri The URI for the content that defines the page.
* @returns A constructor function that creates the page.
**/
function get(uri: string): Function;
function get(uri: string): (element?: HTMLElement, options?: any, complete?: (page: any) => void, parentedPromise?: Promise<any>) => void;
/**
* Creates a PageControl from the specified URI and inserts it inside the specified element.
@@ -7397,7 +7483,7 @@ declare module WinJS.UI.Pages {
* @param parentedPromise A Promise that is fulfilled when the new PageControl is done rendering and its contents becomes the child of element.
* @returns A promise that is fulfilled when rendering is complete, if asynchronous processing is necessary. If not, returns nothing.
**/
function render(uri: string, element: HTMLElement, options?: any, parentedPromise?: Promise<any>): Promise<void>;
function render(uri: string, element?: HTMLElement, options?: any, parentedPromise?: Promise<any>): Promise<any>;
//#endregion Functions
@@ -7961,6 +8047,12 @@ declare module WinJS.Utilities {
**/
include(items: T[]): void;
/**
* 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.
**/
include(items: HTMLCollection): void;
/**
* Registers the listener for the specified event on all the elements in the collection.
* @param eventType The name of the event.
@@ -8015,7 +8107,7 @@ declare module WinJS.Utilities {
* @param renderDonePromiseCallback If supplied, this function is called each time the template gets rendered, and is passed a promise that is fulfilled when the template rendering is complete.
* @returns The QueryCollection.
**/
template(templateElement: HTMLElement, data: any, renderDonePromiseCallback: Function): QueryCollection<T>;
template(templateElement: HTMLElement, data: any, renderDonePromiseCallback?: Function): QueryCollection<T>;
/**
* Toggles (adds or removes) the specified class on all the elements in the collection. If the class is present, it is removed; if it is absent, it is added.
@@ -8142,7 +8234,7 @@ declare module WinJS.Utilities {
* @param parent The parent element.
* @returns The relative left coordinate.
**/
function getRelativeLeft(element: HTMLElement, parent: HTMLElement): number;
function getRelativeLeft(element?: HTMLElement, parent?: HTMLElement): number;
/**
* Gets the top coordinate of the element relative to the specified parent.
@@ -8150,7 +8242,7 @@ declare module WinJS.Utilities {
* @param parent The parent element.
* @returns The relative top coordinate.
**/
function getRelativeTop(element: HTMLElement, parent: HTMLElement): number;
function getRelativeTop(element?: HTMLElement, parent?: HTMLElement): number;
/**
* Gets the height of the element, including its margins.
@@ -8202,7 +8294,7 @@ declare module WinJS.Utilities {
* @param element The element to mark as disposable.
* @param disposeImpl The function containing the element-specific dispose logic, called by the dispose function that markDisposable attaches.
**/
function markDisposable(element: HTMLElement, disposeImpl: Function): void;
function markDisposable(element: HTMLElement, disposeImpl?: Function): void;
/**
* Marks a function as being compatible with declarative processing. Declarative processing is performed by WinJS.UI.processAll or WinJS.Binding.processAll.
@@ -8275,6 +8367,7 @@ declare module WinJS.Utilities {
* @param options The tags for messages to log. Multiple tags should be separated by spaces. May contain type, tags, excludeTags and action properties.
**/
function startLog(options?: ILogOptions): void;
function startLog(tags?: string): void;
/**
* Removes the WinJS logger that had previously been set up.
@@ -8303,10 +8396,10 @@ declare module WinJS.Utilities {
//#region Interfaces
interface ILogOptions {
type: string;
type?: string;
action?: (message: string, tags: string, type: string) => void;
excludeTags: string;
tags: string;
excludeTags?: string;
tags?: string;
}
interface IPosition {
@@ -8470,6 +8563,15 @@ declare module WinJS.Utilities.Scheduler {
//#endregion Interfaces
//#region Properties
/**
* Gets the current priority at which the caller is executing.
**/
var currentPriority: Priority;
//#endregion Properties
//#region Functions
/**

338
winjs/winjs-2.1.d.ts vendored
View File

@@ -1,6 +1,6 @@
// Type definitions for WinJS
// Project: http://msdn.microsoft.com/en-us/library/windows/apps/br229773.aspx
// Definitions by: TypeScript samples <https://www.typescriptlang.org/>, Adam Hewitt <https://github.com/adamhewitt627>, Craig Treasure <https://github.com/craigktreasure>
// Project: http://try.buildwinjs.com/
// Definitions by: TypeScript samples <https://www.typescriptlang.org/>, Adam Hewitt <https://github.com/adamhewitt627>, Craig Treasure <https://github.com/craigktreasure>, Jeff Fisher <https://github.com/xirzec>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/* *****************************************************************************
@@ -22,7 +22,7 @@ and limitations under the License.
* Defines an Element object.
**/
interface Element {
winControl: any; // TODO: This should be control?
winControl: any;
}
/**
@@ -55,7 +55,7 @@ interface IOHelper {
* Writes the specified text to the specified file.
* @param fileName The name of the file.
* @param text The content to be written to the file.
* @returns A promise that completes with a value that is the number of characters written.
* @returns A promise that is completed when the file has been written.
**/
writeText(fileName: string, text: string): WinJS.Promise<number>;
}
@@ -378,6 +378,12 @@ declare module WinJS.Binding {
//#endregion Properties
/**
* Returns a key/data pair for the specified index.
* @param index The index of the value to retrieve.
* @returns An object that has two properties: key and data.
**/
getItem(index: number): IGroupKeyDataPair<T>;
}
/**
@@ -448,7 +454,7 @@ declare module WinJS.Binding {
* 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;
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.
@@ -555,7 +561,7 @@ 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<T>;
createGrouped(groupKey: (x: T) => string, groupData: (x: T) => any, groupSorter?: (left: string, right: string) => number): GroupedSortedListProjection<T>;
/**
* Creates a live sorted projection over this list. As the list changes, the sorted projection reacts to those changes and may also change.
@@ -615,7 +621,7 @@ declare module WinJS.Binding {
* @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;
join(separator?: string): string;
/**
* Gets the index of the last occurrence of the specified value in a list.
@@ -623,7 +629,7 @@ declare module WinJS.Binding {
* @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;
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.
@@ -677,7 +683,7 @@ declare module WinJS.Binding {
* @param end The index that specifies the end of the section.
* @returns Returns a section of list.
**/
slice(begin: number, end: number): T[];
slice(begin: number, end?: number): T[];
/**
* Checks whether the specified callback function returns true for any element of a list.
@@ -730,6 +736,7 @@ declare module WinJS.Binding {
* @returns The new length of the list.
**/
push(value: T): number;
push(...values: T[]): number;
/**
* Removes the first element from a list and returns it.
@@ -743,6 +750,7 @@ declare module WinJS.Binding {
* @returns The new length of the list.
**/
unshift(value: T): number;
unshift(...values: T[]): number;
//#endregion Methods
}
@@ -950,30 +958,28 @@ declare module WinJS.Binding {
* @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?: string);
constructor(element: HTMLElement, options?: any);
//#endregion Constructors
//#region Methods
render: {
/**
* 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.
**/
(dataContext: any, container?: HTMLElement): Promise<HTMLElement>;
/**
* 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<HTMLElement>;
/**
* 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.
**/
value(href: string, dataContext: any, container?: HTMLElement): Promise<HTMLElement>;
};
/**
* 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<HTMLElement>;
//#endregion Methods
@@ -1143,6 +1149,12 @@ declare module WinJS.Binding {
data: T;
}
interface IGroupKeyDataPair<T> extends IKeyDataPair<T> {
groupSize: number;
firstItemIndexHint: number;
firstItemKey: string;
}
//#endregion Interfaces
}
@@ -1159,7 +1171,7 @@ declare module WinJS.Class {
* @param staticMembers The set of static fields, properties, and methods made available on the type.
* @returns The newly-defined type.
**/
function define(constructor: Function, instanceMembers?: any, staticMembers?: any): any;
function define(constructor?: Function, instanceMembers?: any, staticMembers?: any): any;
/**
* Creates a sub-class based on the specified baseClass parameter, using prototype inheritance.
@@ -1215,10 +1227,24 @@ declare module WinJS {
}
interface IPromise<T> {
cancel(): void;
done<U>(onComplete?: (value: T) => any, onError?: (error: any) => any, onProgress?: (progress: any) => void): void;
then<U>(onComplete?: (value: T) => IPromise<U>, onError?: (error: any) => IPromise<U>, onProgress?: (progress: any) => void): IPromise<U>;
then<U>(onComplete?: (value: T) => IPromise<U>, onError?: (error: any) => U, onProgress?: (progress: any) => void): IPromise<U>;
then<U>(onComplete?: (value: T) => IPromise<U>, onError?: (error: any) => void, onProgress?: (progress: any) => void): IPromise<U>;
then<U>(onComplete?: (value: T) => U, onError?: (error: any) => IPromise<U>, onProgress?: (progress: any) => void): IPromise<U>;
then<U>(onComplete?: (value: T) => U, onError?: (error: any) => U, onProgress?: (progress: any) => void): IPromise<U>;
then<U>(onComplete?: (value: T) => U, onError?: (error: any) => void, onProgress?: (progress: any) => void): IPromise<U>;
then<U>(onComplete?: (value: T) => void, onError?: (error: any) => IPromise<U>, onProgress?: (progress: any) => void): IPromise<U>;
then<U>(onComplete?: (value: T) => void, onError?: (error: any) => U, onProgress?: (progress: any) => void): IPromise<U>;
then<U>(onComplete?: (value: T) => void, onError?: (error: any) => void, onProgress?: (progress: any) => void): IPromise<U>;
}
/**
* Provides a mechanism to schedule work to be done on a value that has not yet been computed. It is an 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.
**/
class Promise<T> {
class Promise<T> implements IPromise<T> {
//#region Constructors
/**
@@ -1237,7 +1263,7 @@ declare module WinJS {
* Occurs when there is an error in processing a promise.
* @param eventInfo An object that contains information about the event.
**/
onerror(eventInfo: CustomEvent): void;
static onerror(eventInfo: CustomEvent): void;
//#endregion Events
@@ -1249,34 +1275,40 @@ declare module WinJS {
* @param listener The listener to invoke when the event is raised.
* @param capture true to initiate capture, otherwise false.
**/
addEventListener(type: string, listener: Function, capture?: boolean): void;
static addEventListener(type: string, listener: Function, capture?: boolean): void;
/**
* Returns a promise that is fulfilled when one of the input promises has been fulfilled.
* @param value An array that contains Promise objects or objects whose property values include Promise objects.
* @returns A promise that on fulfillment yields the value of the input (complete or error).
**/
static any(value: Promise<any>[]): Promise<any>;
static any(value: IPromise<any>[]): IPromise<any>;
static any(value: any): IPromise<any>;
/**
* Returns a promise. If the object is already a Promise it is returned; otherwise the object is wrapped in a Promise. You can use this function when you need to treat a non-Promise object like a Promise, for example when you are calling a function that expects a promise, but already have the value needed rather than needing to get it asynchronously.
* @param value The value to be treated as a Promise.
* @returns The promise.
**/
static as<U>(value: U): Promise<U>;
static as<U>(value?: U): IPromise<U>;
/**
* Attempts to cancel the fulfillment of a promised value. If the promise hasn't already been fulfilled and cancellation is supported, the promise enters the error state with a value of Error("Canceled").
**/
cancel(): void;
/**
* Canceled promise value, can be returned from a promise completion handler to indicate cancelation of the promise chain.
*/
static cancel: IPromise<any>;
/**
* Raises an event of the specified type and 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;
static dispatchEvent(type: string, details: any): boolean;
/**
* Allows you to specify the work to be done on the fulfillment of the promised value, the error handling to be performed if the promise fails to fulfill a value, and the handling of progress notifications along the way. After the handlers have finished executing, this function throws any error that would have been returned from then as a promise in the error state. For more information about the differences between then and done, see the following topics: Quickstart: using promises in JavaScript How to handle errors when using promises in JavaScript Chaining promises in JavaScript.
@@ -1298,7 +1330,7 @@ declare module WinJS {
* @param values An object whose members contain values, some of which may be promises.
* @returns A Promise whose value is an object with the same field names as those of the object in the values parameter, where each field value is the fulfilled value of a promise.
**/
static join(values: any): Promise<any>;
static join(values: any): IPromise<any>;
/**
* Removes an event listener from the control.
@@ -1306,7 +1338,7 @@ declare module WinJS {
* @param listener The listener to remove.
* @param capture Specifies whether or not to initiate capture.
**/
removeEventListener(eventType: string, listener: Function, capture?: boolean): void;
static removeEventListener(eventType: string, listener: Function, capture?: boolean): void;
/**
* Allows you to specify the work to be done on the fulfillment of the promised value, the error handling to be performed if the promise fails to fulfill a value, and the handling of progress notifications along the way. For more information about the differences between then and done, see the following topics: Quickstart: using promises in JavaScript How to handle errors when using promises in JavaScript Chaining promises in JavaScript.
@@ -1315,7 +1347,7 @@ declare module WinJS {
* @param onProgress The function to be called if the promise reports progress. Data about the progress is passed as the single argument. Promises are not required to support progress.
* @returns The promise whose value is the result of executing the onComplete function.
**/
then<U>(onComplete?: (value: T) => Promise<U>, onError?: (error: any) => Promise<U>, onProgress?: (progress: any) => void): Promise<U>;
then<U>(onComplete?: (value: T) => IPromise<U>, onError?: (error: any) => IPromise<U>, onProgress?: (progress: any) => void): IPromise<U>;
/**
* Allows you to specify the work to be done on the fulfillment of the promised value, the error handling to be performed if the promise fails to fulfill a value, and the handling of progress notifications along the way. For more information about the differences between then and done, see the following topics: Quickstart: using promises in JavaScript How to handle errors when using promises in JavaScript Chaining promises in JavaScript.
@@ -1324,7 +1356,7 @@ declare module WinJS {
* @param onProgress The function to be called if the promise reports progress. Data about the progress is passed as the single argument. Promises are not required to support progress.
* @returns The promise whose value is the result of executing the onComplete function.
**/
then<U>(onComplete?: (value: T) => Promise<U>, onError?: (error: any) => U, onProgress?: (progress: any) => void): Promise<U>;
then<U>(onComplete?: (value: T) => IPromise<U>, onError?: (error: any) => U, onProgress?: (progress: any) => void): IPromise<U>;
/**
* Allows you to specify the work to be done on the fulfillment of the promised value, the error handling to be performed if the promise fails to fulfill a value, and the handling of progress notifications along the way. For more information about the differences between then and done, see the following topics: Quickstart: using promises in JavaScript How to handle errors when using promises in JavaScript Chaining promises in JavaScript.
@@ -1333,7 +1365,7 @@ declare module WinJS {
* @param onProgress The function to be called if the promise reports progress. Data about the progress is passed as the single argument. Promises are not required to support progress.
* @returns The promise whose value is the result of executing the onComplete function.
**/
then<U>(onComplete?: (value: T) => U, onError?: (error: any) => Promise<U>, onProgress?: (progress: any) => void): Promise<U>;
then<U>(onComplete?: (value: T) => IPromise<U>, onError?: (error: any) => void, onProgress?: (progress: any) => void): IPromise<U>;
/**
* Allows you to specify the work to be done on the fulfillment of the promised value, the error handling to be performed if the promise fails to fulfill a value, and the handling of progress notifications along the way. For more information about the differences between then and done, see the following topics: Quickstart: using promises in JavaScript How to handle errors when using promises in JavaScript Chaining promises in JavaScript.
@@ -1342,7 +1374,63 @@ declare module WinJS {
* @param onProgress The function to be called if the promise reports progress. Data about the progress is passed as the single argument. Promises are not required to support progress.
* @returns The promise whose value is the result of executing the onComplete function.
**/
then<U>(onComplete?: (value: T) => U, onError?: (error: any) => U, onProgress?: (progress: any) => void): Promise<U>;
then<U>(onComplete?: (value: T) => U, onError?: (error: any) => IPromise<U>, onProgress?: (progress: any) => void): IPromise<U>;
/**
* Allows you to specify the work to be done on the fulfillment of the promised value, the error handling to be performed if the promise fails to fulfill a value, and the handling of progress notifications along the way. For more information about the differences between then and done, see the following topics: Quickstart: using promises in JavaScript How to handle errors when using promises in JavaScript Chaining promises in JavaScript.
* @param onComplete The function to be called if the promise is fulfilled successfully with a value. The value is passed as the single argument. If the value is null, the value is returned. The value returned from the function becomes the fulfilled value of the promise returned by then. If an exception is thrown while this function is being executed, the promise returned by then moves into the error state.
* @param onError The function to be called if the promise is fulfilled with an error. The error is passed as the single argument. In different cases this object may be of different types, so it is necessary to test the object for the properties you expect. If the error is null, it is forwarded. The value returned from the function becomes the value of the promise returned by the then function.
* @param onProgress The function to be called if the promise reports progress. Data about the progress is passed as the single argument. Promises are not required to support progress.
* @returns The promise whose value is the result of executing the onComplete function.
**/
then<U>(onComplete?: (value: T) => U, onError?: (error: any) => U, onProgress?: (progress: any) => void): IPromise<U>;
/**
* Allows you to specify the work to be done on the fulfillment of the promised value, the error handling to be performed if the promise fails to fulfill a value, and the handling of progress notifications along the way. For more information about the differences between then and done, see the following topics: Quickstart: using promises in JavaScript How to handle errors when using promises in JavaScript Chaining promises in JavaScript.
* @param onComplete The function to be called if the promise is fulfilled successfully with a value. The value is passed as the single argument. If the value is null, the value is returned. The value returned from the function becomes the fulfilled value of the promise returned by then. If an exception is thrown while this function is being executed, the promise returned by then moves into the error state.
* @param onError The function to be called if the promise is fulfilled with an error. The error is passed as the single argument. In different cases this object may be of different types, so it is necessary to test the object for the properties you expect. If the error is null, it is forwarded. The value returned from the function becomes the value of the promise returned by the then function.
* @param onProgress The function to be called if the promise reports progress. Data about the progress is passed as the single argument. Promises are not required to support progress.
* @returns The promise whose value is the result of executing the onComplete function.
**/
then<U>(onComplete?: (value: T) => U, onError?: (error: any) => void, onProgress?: (progress: any) => void): IPromise<U>;
/**
* Allows you to specify the work to be done on the fulfillment of the promised value, the error handling to be performed if the promise fails to fulfill a value, and the handling of progress notifications along the way. For more information about the differences between then and done, see the following topics: Quickstart: using promises in JavaScript How to handle errors when using promises in JavaScript Chaining promises in JavaScript.
* @param onComplete The function to be called if the promise is fulfilled successfully with a value. The value is passed as the single argument. If the value is null, the value is returned. The value returned from the function becomes the fulfilled value of the promise returned by then. If an exception is thrown while this function is being executed, the promise returned by then moves into the error state.
* @param onError The function to be called if the promise is fulfilled with an error. The error is passed as the single argument. In different cases this object may be of different types, so it is necessary to test the object for the properties you expect. If the error is null, it is forwarded. The value returned from the function becomes the value of the promise returned by the then function.
* @param onProgress The function to be called if the promise reports progress. Data about the progress is passed as the single argument. Promises are not required to support progress.
* @returns The promise whose value is the result of executing the onComplete function.
**/
then<U>(onComplete?: (value: T) => void, onError?: (error: any) => IPromise<U>, onProgress?: (progress: any) => void): IPromise<U>;
/**
* Allows you to specify the work to be done on the fulfillment of the promised value, the error handling to be performed if the promise fails to fulfill a value, and the handling of progress notifications along the way. For more information about the differences between then and done, see the following topics: Quickstart: using promises in JavaScript How to handle errors when using promises in JavaScript Chaining promises in JavaScript.
* @param onComplete The function to be called if the promise is fulfilled successfully with a value. The value is passed as the single argument. If the value is null, the value is returned. The value returned from the function becomes the fulfilled value of the promise returned by then. If an exception is thrown while this function is being executed, the promise returned by then moves into the error state.
* @param onError The function to be called if the promise is fulfilled with an error. The error is passed as the single argument. In different cases this object may be of different types, so it is necessary to test the object for the properties you expect. If the error is null, it is forwarded. The value returned from the function becomes the value of the promise returned by the then function.
* @param onProgress The function to be called if the promise reports progress. Data about the progress is passed as the single argument. Promises are not required to support progress.
* @returns The promise whose value is the result of executing the onComplete function.
**/
then<U>(onComplete?: (value: T) => void, onError?: (error: any) => U, onProgress?: (progress: any) => void): IPromise<U>;
/**
* Allows you to specify the work to be done on the fulfillment of the promised value, the error handling to be performed if the promise fails to fulfill a value, and the handling of progress notifications along the way. For more information about the differences between then and done, see the following topics: Quickstart: using promises in JavaScript How to handle errors when using promises in JavaScript Chaining promises in JavaScript.
* @param onComplete The function to be called if the promise is fulfilled successfully with a value. The value is passed as the single argument. If the value is null, the value is returned. The value returned from the function becomes the fulfilled value of the promise returned by then. If an exception is thrown while this function is being executed, the promise returned by then moves into the error state.
* @param onError The function to be called if the promise is fulfilled with an error. The error is passed as the single argument. In different cases this object may be of different types, so it is necessary to test the object for the properties you expect. If the error is null, it is forwarded. The value returned from the function becomes the value of the promise returned by the then function.
* @param onProgress The function to be called if the promise reports progress. Data about the progress is passed as the single argument. Promises are not required to support progress.
* @returns The promise whose value is the result of executing the onComplete function.
**/
then<U>(onComplete?: (value: T) => void, onError?: (error: any) => void, onProgress?: (progress: any) => void): IPromise<U>;
/**
* A static helper that functions identically to then() off a promise instance.
* @param promise The promise to chain from.
* @param onComplete The function to be called if the promise is fulfilled successfully with a value. The value is passed as the single argument. If the value is null, the value is returned. The value returned from the function becomes the fulfilled value of the promise returned by then. If an exception is thrown while this function is being executed, the promise returned by then moves into the error state.
* @param onError The function to be called if the promise is fulfilled with an error. The error is passed as the single argument. In different cases this object may be of different types, so it is necessary to test the object for the properties you expect. If the error is null, it is forwarded. The value returned from the function becomes the value of the promise returned by the then function.
* @param onProgress The function to be called if the promise reports progress. Data about the progress is passed as the single argument. Promises are not required to support progress.
* @returns The promise whose value is the result of executing the onComplete function.
**/
static then(promise: IPromise<any>, onComplete?: (value: any) => any, onError?: (error: any) => any, onProgress?: (progress: any) => void): IPromise<any>;
/**
* Performs an operation on all the input promises and returns a promise that has the shape of the input and contains the result of the operation that has been performed on each input.
@@ -1352,7 +1440,7 @@ declare module WinJS {
* @param progress The function to be called if the promise reports progress. This function takes a single argument, which is the data about the progress of the promise. Promises are not required to support progress.
* @returns A Promise that is the result of calling join on the values parameter.
**/
static thenEach(values: any, complete?: (value: any) => void, error?: (error: any) => void, progress?: (progress: any) => void): Promise<any>;
static thenEach(values: any, complete?: (value: any) => void, error?: (error: any) => void, progress?: (progress: any) => void): IPromise<any>;
/**
* This method has two forms: WinJS.Promise.timeout(timeout) and WinJS.Promise.timeout(timeout, promise). WinJS.Promise.timeout(timeout) creates a promise that is completed asynchronously after the specified timeout, essentially wrapping a call to setTimeout within a promise. WinJS.Promise.timeout(timeout, promise) sets a timeout period for completion of the specified promise, automatically canceling the promise if it is not completed within the timeout period.
@@ -1360,21 +1448,21 @@ declare module WinJS {
* @param promise Optional. A promise that will be canceled if it doesn't complete within the timeout period.
* @returns If the promise parameter is omitted, returns a promise that will be fulfilled after the timeout period. If the promise paramater is provided, the same promise is returned.
**/
static timeout(timeout: number, promise?: Promise<any>): Promise<any>;
static timeout(timeout?: number, promise?: IPromise<any>): IPromise<any>;
/**
* Wraps a non-promise value in a promise. This method is like wrapError, which allows you to produce a Promise in error conditions, in that it allows you to return a Promise in success conditions.
* @param value Some non-promise value to be wrapped in a promise.
* @returns A promise that is successfully fulfilled with the specified value.
**/
static wrap<U>(value: U): Promise<U>;
static wrap<U>(value?: U): IPromise<U>;
/**
* Wraps a non-promise error value in a promise. You can use this function if you need to pass an error to a function that requires a promise.
* @param error A non-promise error value to be wrapped in a promise.
* @returns A promise that is in an error state with the specified value.
**/
static wrapError<U>(error: U): Promise<U>;
static wrapError<U>(error: U): IPromise<U>;
//#endregion Methods
@@ -1390,7 +1478,8 @@ declare module WinJS {
* @param tags The tag or tags to categorize the message (winjs, winjs controls, etc.).
* @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;
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.
@@ -1414,8 +1503,9 @@ declare module WinJS {
user?: string;
password?: string;
headers?: any;
data: any;
data?: any;
responseType?: string;
customRequestInitializer?: (request: XMLHttpRequest) => void;
}
//#endregion Interfaces
@@ -1576,7 +1666,7 @@ declare module WinJS.Resources {
* Processes data-win-res attributes on elements and replaces attributes and properties with resource strings.
* @param rootElement The element to process. The element and its child elements will be processed. If an element isn't specified, the entire document is processed.
**/
function processAll(rootElement?: HTMLElement): void;
function processAll(rootElement?: HTMLElement): Promise<void>;
/**
* Removes an event listener that the addEventListener method registered.
@@ -1722,7 +1812,7 @@ declare module WinJS.UI.Animation {
* @param offset Initial offsets where the animated objects begin relative to their final position at the end of the animation. Set this parameter to null to use the recommended default offset. Note When the incoming parameter specifies an array of elements, the offset parameter can specify an offset array with each item specified for its corresponding element array item. If the array of offsets is smaller than the array of elements, the last offset is applied to all remaining elements.
* @returns An object that completes when the animation is finished.
**/
function dragBetweenEnter(target: any, offset: any): Promise<any>;
function dragBetweenEnter(target: any, offset?: any): Promise<any>;
/**
* Performs an animation when a dragged object is moved away from items that it had previously involved in a dragBetweenEnter animation. The affected objects are animated back to their original positions.
@@ -1738,7 +1828,7 @@ declare module WinJS.UI.Animation {
* @param affected Element or elements whose position the dropped object affects. Typically, this is all other items in a reorderable list. This should be the same element or element collection passed as the affected parameter in the dragSourceStart animation.
* @returns An object that completes when the animation is finished.
**/
function dragSourceEnd(dragSource: any, offset: any, affected?: any): Promise<any>;
function dragSourceEnd(dragSource: any, offset?: any, affected?: any): Promise<any>;
/**
* Performs an animation when the user begins to drag an object.
@@ -1755,7 +1845,7 @@ declare module WinJS.UI.Animation {
* @param options Optional. Set this value to { mechanism: "transition" } to play the animation using CSS transitions instead of the default CSS animations. In some cases this can result in improved performance.
* @returns An object that completes when the animation is finished.
**/
function enterContent(incoming: any, offset: any, options?: any): Promise<any>;
function enterContent(incoming: any, offset?: any, options?: any): Promise<any>;
/**
* Performs an animation that shows a new page of content, either when transitioning between pages in a running app or when displaying the first content in a newly launched app.
@@ -1763,7 +1853,7 @@ declare module WinJS.UI.Animation {
* @param offset An initial offset where the element or elements begin relative to their final position at the end of the animation. Set this parameter to null to use the recommended default offset. Note When the element parameter specifies an array of elements, the offset parameter can specify an offset array with each item specified for its corresponding element array item. If the array of offsets is smaller than the array of elements, the last offset is applied to all remaining elements.
* @returns An object that completes when the animation is finished.
**/
function enterPage(element: any, offset: any): Promise<any>;
function enterPage(element: any, offset?: any): Promise<any>;
/**
* Performs an animation that hides one or more elements on a page.
@@ -1771,7 +1861,7 @@ declare module WinJS.UI.Animation {
* @param offset Initial offsets where the animated objects begin relative to their final position at the end of the animation. Set this parameter to null to use the recommended default offset. Note When the incoming parameter specifies an array of elements, the offset parameter can specify an offset array with each item specified for its corresponding element array item. If the array of offsets is smaller than the array of elements, the last offset is applied to all remaining elements.
* @returns An object that completes when the animation is finished.
**/
function exitContent(outgoing: any, offset: any): Promise<any>;
function exitContent(outgoing: any, offset?: any): Promise<any>;
/**
* Performs an animation that dismisses the current page when transitioning between pages in an app.
@@ -1779,7 +1869,7 @@ declare module WinJS.UI.Animation {
* @param offset Initial offsets where the animated objects begin relative to their final position at the end of the animation. Set this parameter to null to use the recommended default offset. Note When the incoming parameter specifies an array of elements, the offset parameter can specify an offset array with each item specified for its corresponding element array item. If the array of offsets is smaller than the array of elements, the last offset is applied to all remaining elements.
* @returns An object that completes when the animation is finished.
**/
function exitPage(outgoing: any, offset: any): Promise<any>;
function exitPage(outgoing: any, offset?: any): Promise<any>;
/**
* Performs an animation that fades an item or set of items into view.
@@ -1802,7 +1892,7 @@ declare module WinJS.UI.Animation {
* @param options Optional. Set this value to { mechanism: "transition" } to play the animation using CSS transitions instead of the default CSS animations. In some cases this can result in improved performance.
* @returns An object that completes when the animation is finished.
**/
function hideEdgeUI(element: any, offset: any, options?: any): Promise<any>;
function hideEdgeUI(element: any, offset?: any, options?: any): Promise<any>;
/**
* Performs an animation that hides a panel.
@@ -1810,7 +1900,7 @@ declare module WinJS.UI.Animation {
* @param offset Initial offsets where the animated objects begin relative to their final position at the end of the animation. Offsets should be the chosen so that the elements end the animation just off-screen. Note When the element parameter specifies an array of elements, the offset parameter can specify an offset array with each item specified for its corresponding element array item. If the array of offsets is smaller than the array of elements, the last offset is applied to all remaining elements.
* @returns An object that completes when the animation is finished.
**/
function hidePanel(element: any, offset: any): Promise<any>;
function hidePanel(element: any, offset?: any): Promise<any>;
/**
* Performs an animation that removes pop-up user interface (UI).
@@ -1840,7 +1930,7 @@ declare module WinJS.UI.Animation {
* @param options Optional. Set this value to { mechanism: "transition" } to play the animation using CSS transitions instead of the default CSS animations. In some cases this can result in improved performance.
* @returns An object that completes when the animation is finished.
**/
function showEdgeUI(element: any, offset: any, options?: any): Promise<any>;
function showEdgeUI(element: any, offset?: any, options?: any): Promise<any>;
/**
* Performs an animation that slides a large panel user interface (UI) into view.
@@ -1848,7 +1938,7 @@ declare module WinJS.UI.Animation {
* @param offset Initial offsets where the animated objects begin relative to their final position at the end of the animation. Offsets should be the chosen so that the elements begin the animation from just off-screen. Note When the element parameter specifies an array of elements, the offset parameter can specify an offset array with each item specified for its corresponding element array item. If the array of offsets is smaller than the array of elements, the last offset is applied to all remaining elements.
* @returns An object that completes when the animation is finished.
**/
function showPanel(element: any, offset: any): Promise<any>;
function showPanel(element: any, offset?: any): Promise<any>;
/**
* Performs an animation that displays a pop-up user interface (UI).
@@ -1856,7 +1946,7 @@ declare module WinJS.UI.Animation {
* @param offset Initial offsets where the animated objects begin relative to their final position at the end of the animation. Offsets should be the chosen so that the elements begin the animation from just off-screen. Set this parameter to null to use the recommended default offset. Note When the element parameter specifies an array of elements, the offset parameter can specify an offset array with each item specified for its corresponding element array item. If the array of offsets is smaller than the array of elements, the last offset is applied to all remaining elements.
* @returns An object that completes when the animation is finished.
**/
function showPopup(element: any, offset: any): Promise<any>;
function showPopup(element: any, offset?: any): Promise<any>;
/**
* Slides elements off through the bottom of the screen.
@@ -1926,7 +2016,7 @@ declare module WinJS.UI.Animation {
* @param offset An initial offset where the animated objects begin relative to their final position at the end of the animation. Set this parameter to null to use the recommended default offset. Note When the incoming parameter specifies an array of elements, the offset parameter can specify an offset array with each item specified for its corresponding element array item. If the array of offsets is smaller than the array of elements, the last offset is applied to all remaining elements.
* @returns An object that completes when the animation is finished.
**/
function swipeReveal(target: any, offset: any): Promise<any>;
function swipeReveal(target: any, offset?: any): Promise<any>;
/**
* Performs a selection animation in response to a swipe interaction.
@@ -1971,7 +2061,7 @@ declare module WinJS.UI.Animation {
* @param offset Initial offsets where incoming animated objects begin relative to their final position at the end of the animation. Set this parameter to null to use the recommended default offset. Note When the incoming parameter specifies an array of elements, the offset parameter can specify an offset array with each item specified for its corresponding element array item. If the array of offsets is smaller than the array of elements, the last offset is applied to all remaining elements.
* @returns An object that completes when the animation is finished.
**/
function updateBadge(incoming: any, offset: any): Promise<any>;
function updateBadge(incoming: any, offset?: any): Promise<any>;
//#endregion Functions
@@ -2469,32 +2559,10 @@ declare module WinJS.UI {
/**
* Provides a mechanism for retrieving IItem objects asynchronously.
**/
interface IItemPromise<T> {
//#region Events
/**
* Occurs when there is an error in processing.
* @param eventInfo An object that contains information about the event.
**/
onerror(eventInfo: CustomEvent): void;
//#endregion Events
interface IItemPromise<T> extends IPromise<T> {
//#region Methods
/**
* Attempts to cancel the fulfillment of a promised value. If the promise hasn't already been fulfilled and cancellation is supported, the promise enters the error state with a value of Error("Canceled").
**/
cancel(): void;
/**
* Allows you to specify the work to be done on the fulfillment of the promised value, the error handling to be performed if the promise fails to fulfill a value, and the handling of progress notifications along the way. After the handlers have finished executing, this function throws any error that would have been returned from then as a promise in the error state.
* @param onComplete The function to be called if the promise is fulfilled successfully with a value. The fulfilled value is passed as the single argument. If the value is null, the fulfilled value is returned. The value returned from the function becomes the fulfilled value of the promise returned by then. If an exception is thrown while executing the function, the promise returned by then moves into the error state.
* @param onError The function to be called if the promise is fulfilled with an error. The error is passed as the single argument. If it is null, the error is forwarded. The value returned from the function is the fulfilled value of the promise returned by then.
* @param onProgress The function to be called if the promise reports progress. Data about the progress is passed as the single argument. Promises are not required to support progress.
**/
done(onComplete: (item: T) => void, onError?: (error: Error) => void, onProgress?: (progressData: any) => void): void;
/**
* Stops change notification tracking for the IItem that fulfills this IItemPromise.
**/
@@ -2503,18 +2571,7 @@ declare module WinJS.UI {
/**
* Begins change notification tracking for the IItem that fulfills this IItemPromise.
**/
retain(): void;
/**
* Allows you to specify the work to be done on the fulfillment of the promised value, the error handling to be performed if the promise fails to fulfill a value, and the handling of progress notifications along the way.
* @param onComplete The function to be called if the promise is fulfilled successfully with a value. The value is passed as the single argument. If the value is null, the value is returned. The value returned from the function becomes the fulfilled value of the promise returned by then. If an exception is thrown while this function is being executed, the promise returned by then moves into the error state.
* @param onError The function to be called if the promise is fulfilled with an error. The error is passed as the single argument. If it is null, the error is forwarded. The value returned from the function becomes the fulfilled value of the promise returned by then.
* @param onProgress The function to be called if the promise reports progress. Data about the progress is passed as the single argument. Promises are not required to support progress.
* @returns The promise whose value is the result of executing the complete or error function.
**/
then(onComplete: (item: T) => void, onError?: (error: Error) => void, onProgress?: (progressData: any) => void): IItemPromise<T>;
//#endregion Methods
retain(): IItemPromise<T>;
//#region Properties
@@ -3394,6 +3451,11 @@ declare module WinJS.UI {
* Gets or sets whether the ListView item is focused and is showing its focus visual.
**/
showFocus?: boolean;
/**
* Gets the type, if any.
**/
type?: WinJS.UI.ObjectType;
}
/**
@@ -4076,6 +4138,14 @@ declare module WinJS.UI {
**/
executeAnimations(): void;
/**
* Determines the next item to receive keyboard focus.
* @param currentItem An object that describes the current item. It has these properties: index, type.
* @param pressedKey The key that was pressed.
* @returns An object that describes the next item that should receive focus. It has these properties: index, type.
**/
getAdjacent(currentItem: any, pressedKey: WinJS.Utilities.Key): any;
/**
* This method is no longer supported.
* @param itemIndex
@@ -4462,6 +4532,14 @@ declare module WinJS.UI {
**/
executeAnimations(): void;
/**
* Determines the next item to receive keyboard focus.
* @param currentItem An object that describes the current item. It has these properties: index, type.
* @param pressedKey The key that was pressed.
* @returns An object that describes the next item that should receive focus. It has these properties: index, type.
**/
getAdjacent(currentItem: any, pressedKey: WinJS.Utilities.Key): any;
/**
* This method is no longer supported.
* @param itemIndex
@@ -5056,7 +5134,7 @@ declare module WinJS.UI {
/**
* Gets or sets the header for this PivotItem.
**/
header: HTMLElement;
header: string;
//#endregion Properties
}
@@ -5070,9 +5148,10 @@ declare module WinJS.UI {
/**
* Creates a new Repeater control.
* @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(options?: any);
constructor(element?: HTMLElement, options?: any);
//#endregion Constructors
@@ -5544,6 +5623,13 @@ declare module WinJS.UI {
}
/**
* A special data source for VirtualizedDataSource.computeDataSourceGroups
**/
interface IListGroupDataSource<T> extends IListDataSource<T> {
groups: IListDataSource<T>;
}
/**
* Serves as the base class for a custom IListDataSource.
**/
@@ -5610,9 +5696,9 @@ declare module WinJS.UI {
* @param groupKey A callback function that accepts a single argument: an item in the IListDataSource. The function is called for each item in the list and must return the group key for that item as a string.
* @param groupData A callback function that accepts a single argument: an item in the IListDataSource. The function is called on one IListDataSource item for each group and must return an object that represents the header of that group.
* @param options An object that can contain properties that specify additional options: groupCountEstimate, batchSize.
* @returns An IListDataSource that contains the items in the original data source and provides additional group information in the form of a "groups" property. The "groups" property returns another IListDataSource that enumerates the different groups in the list.
* @returns An IListGroupDataSource that contains the items in the original data source and provides additional group information in the form of a "groups" property. The "groups" property returns another IListDataSource that enumerates the different groups in the list.
**/
function computeDataSourceGroups<T>(listDataSource: IListDataSource<T>, groupKey: Function, groupData: Function, options?: any): IListDataSource<T>;
function computeDataSourceGroups<T>(listDataSource: IListDataSource<T>, groupKey: Function, groupData: Function, options?: any): IListGroupDataSource<T>;
/**
* Used to disables all Animations Library and ListView animations. Calling this function does not guarantee that the animations will be disabled, as the determination is made based on several factors.
@@ -5719,6 +5805,7 @@ declare module WinJS.UI.Fragments {
* @param href The URI that contains the fragment to be cleared. If no URI is provided, the entire contents of the cache are cleared.
**/
function clearCache(href: string): void;
function clearCache(href: HTMLElement): void;
/**
* Loads the contents of the specified URI into the specified element without copying it.
@@ -5735,6 +5822,7 @@ declare module WinJS.UI.Fragments {
* @returns A promise that is fulfilled when the fragment has been loaded. If a target element is not specified, the copied fragment is the completed value. The fragment is added to the cache. See also render, where the element is not added to the cache.
**/
function renderCopy(href: string, target?: HTMLElement): Promise<HTMLElement>;
function renderCopy(href: HTMLElement, target?: HTMLElement): Promise<HTMLElement>;
//#endregion Functions
@@ -5756,7 +5844,7 @@ declare module WinJS.UI.Pages {
* @param err The error that occurred.
* @returns Nothing if the error was handled, or an error promise if the error was not handled.
**/
error? (err: any): Promise<any>;
error? (err: any): any;
/**
* Initializes the control before the content of the control is set. Use the processed method for any initialization that should be done after the content of the control has been set.
@@ -5764,14 +5852,14 @@ declare module WinJS.UI.Pages {
* @param options The options passed to the constructor of the page.
* @returns A promise that is fulfilled when initialization is complete, if asynchronous processing is necessary. If not, returns nothing.
**/
init? (element: HTMLElement, options: any): Promise<any>;
init? (element: HTMLElement, options: any): any;
/**
* Creates DOM objects from the content in the specified URI. This method is called after the PageControl is defined and before the init method is called.
* @param uri The URI from which to create DOM objects.
* @returns A promise whose fulfilled value is the set of unparented DOM objects.
**/
load? (uri: string): Promise<any>;
load? (uri: string): any;
/**
* Initializes the control after the content of the control is set.
@@ -5779,7 +5867,7 @@ declare module WinJS.UI.Pages {
* @param options The options that are to be passed to the constructor of the page.
* @returns A promise that is fulfilled when initialization is complete, if asynchronous processing is necessary. If not, returns nothing.
**/
processed? (element: HTMLElement, options: any): Promise<any>;
processed? (element: HTMLElement, options: any): any;
/**
* Called after all initialization and rendering is complete. At this time, the element is ready for use.
@@ -5787,7 +5875,7 @@ declare module WinJS.UI.Pages {
* @param options An object that contains one or more property/value pairs to apply to the PageControl. How these property/value pairs are used (or not used) depends on the implementation of that particular PageControl.
* @returns A promise that is fulfilled when the element is ready for use, if asynchronous processing is necessary. If not, returns nothing.
**/
ready? (element: HTMLElement, options: any): Promise<any>;
ready? (element: HTMLElement, options: any): any;
/**
* Takes the elements returned by the load method and attaches them to the specified element.
@@ -5805,12 +5893,6 @@ declare module WinJS.UI.Pages {
//#region Objects
/**
* A modular unit of HTML, CSS, and JavaScript that can be navigated to or used as a custom WinJS control.
**/
class PageControl {
}
//#endregion Objects
//#region Functions
@@ -5821,14 +5903,14 @@ declare module WinJS.UI.Pages {
* @param members An object that defines the members that the control will have.
* @returns A constructor function that creates the PageControl.
**/
function define(uri: string, members: IPageControlMembers): PageControl;
function define(uri: string, members: IPageControlMembers): (element?: HTMLElement, options?: any, complete?: (page: any) => void, parentedPromise?: Promise<any>) => void;
/**
* Gets an already-defined page control for the specified URI, or creates a new one.
* @param uri The URI for the content that defines the page.
* @returns A constructor function that creates the page.
**/
function get(uri: string): Function;
function get(uri: string): (element?: HTMLElement, options?: any, complete?: (page: any) => void, parentedPromise?: Promise<any>) => void;
/**
* Creates a PageControl from the specified URI and inserts it inside the specified element.
@@ -5838,7 +5920,7 @@ declare module WinJS.UI.Pages {
* @param parentedPromise A Promise that is fulfilled when the new PageControl is done rendering and its contents becomes the child of element.
* @returns A promise that is fulfilled when rendering is complete, if asynchronous processing is necessary. If not, returns nothing.
**/
function render(uri: string, element: HTMLElement, options?: any, parentedPromise?: Promise<any>): Promise<void>;
function render(uri: string, element?: HTMLElement, options?: any, parentedPromise?: Promise<any>): Promise<any>;
//#endregion Functions
@@ -6402,6 +6484,12 @@ declare module WinJS.Utilities {
**/
include(items: T[]): void;
/**
* 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.
**/
include(items: HTMLCollection): void;
/**
* Registers the listener for the specified event on all the elements in the collection.
* @param eventType The name of the event.
@@ -6456,7 +6544,7 @@ declare module WinJS.Utilities {
* @param renderDonePromiseCallback If supplied, this function is called each time the template gets rendered, and is passed a promise that is fulfilled when the template rendering is complete.
* @returns The QueryCollection.
**/
template(templateElement: HTMLElement, data: any, renderDonePromiseCallback: Function): QueryCollection<T>;
template(templateElement: HTMLElement, data: any, renderDonePromiseCallback?: Function): QueryCollection<T>;
/**
* Toggles (adds or removes) the specified class on all the elements in the collection. If the class is present, it is removed; if it is absent, it is added.
@@ -6583,7 +6671,7 @@ declare module WinJS.Utilities {
* @param parent The parent element.
* @returns The relative left coordinate.
**/
function getRelativeLeft(element: HTMLElement, parent: HTMLElement): number;
function getRelativeLeft(element?: HTMLElement, parent?: HTMLElement): number;
/**
* Gets the top coordinate of the element relative to the specified parent.
@@ -6591,7 +6679,7 @@ declare module WinJS.Utilities {
* @param parent The parent element.
* @returns The relative top coordinate.
**/
function getRelativeTop(element: HTMLElement, parent: HTMLElement): number;
function getRelativeTop(element?: HTMLElement, parent?: HTMLElement): number;
/**
* Gets the height of the element, including its margins.
@@ -6643,7 +6731,7 @@ declare module WinJS.Utilities {
* @param element The element to mark as disposable.
* @param disposeImpl The function containing the element-specific dispose logic, called by the dispose function that markDisposable attaches.
**/
function markDisposable(element: HTMLElement, disposeImpl: Function): void;
function markDisposable(element: HTMLElement, disposeImpl?: Function): void;
/**
* Marks a function as being compatible with declarative processing. Declarative processing is performed by WinJS.UI.processAll or WinJS.Binding.processAll.
@@ -6716,6 +6804,7 @@ declare module WinJS.Utilities {
* @param options The tags for messages to log. Multiple tags should be separated by spaces. May contain type, tags, excludeTags and action properties.
**/
function startLog(options?: ILogOptions): void;
function startLog(tags?: string): void;
/**
* Removes the WinJS logger that had previously been set up.
@@ -6749,10 +6838,10 @@ declare module WinJS.Utilities {
//#region Interfaces
interface ILogOptions {
type: string;
type?: string;
action?: (message: string, tags: string, type: string) => void;
excludeTags: string;
tags: string;
excludeTags?: string;
tags?: string;
}
interface IPosition {
@@ -6916,6 +7005,15 @@ declare module WinJS.Utilities.Scheduler {
//#endregion Interfaces
//#region Properties
/**
* Gets the current priority at which the caller is executing.
**/
var currentPriority: Priority;
//#endregion Properties
//#region Functions
/**

634
winjs/winjs.d.ts vendored

File diff suppressed because it is too large Load Diff