typescript-closure-tools
Version:
Command-line tools to convert closure-style JSDoc annotations to typescript, and to convert typescript sources to closure externs files
1,122 lines (919 loc) • 338 kB
TypeScript
// 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>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/* *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
///<reference path="../winrt/winrt.d.ts"/>
/**
* Defines an Element object.
**/
interface Element {
winControl: any; // TODO: This should be control?
}/**
* Provides application-level functionality, for example activation, storage, and application events.
**/
declare module WinJS.Application {
//#region Objects
/**
* The local storage of the application.
**/
var local: {
//#region Methods
/**
* Determines whether the specified file exists in the folder.
* @param filename The name of the file.
* @returns A promise that completes with a value of either true (if the file exists) or false.
**/
exists(filename: string): Promise<boolean>;
/**
* Reads the specified file. If the file doesn't exist, the specified default value is returned.
* @param fileName The file to read from.
* @param def The default value to be returned if the file failed to open.
* @returns A promise that completes with a value that is either the contents of the file, or the specified default value.
**/
readText(fileName: string, def?: string): Promise<string>;
/**
* Deletes a file from the folder.
* @param fileName The file to be deleted.
* @returns A promise that is fulfilled when the file has been deleted.
**/
remove(fileName: string): Promise<void>;
/**
* 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.
**/
writeText(fileName: string, text: string): Promise<void>;
//#endregion Methods
};
/**
* The roaming storage of the application.
**/
var roaming: {
//#region Methods
/**
* Determines whether the specified file exists in the folder.
* @param filename The name of the file.
* @returns A promise that completes with a value of either true (if the file exists) or false.
**/
exists(filename: string): Promise<boolean>;
/**
* Reads the specified file. If the file doesn't exist, the specified default value is returned.
* @param fileName The file to read from.
* @param def The default value to be returned if the file failed to open.
* @returns A promise that completes with a value that is either the contents of the file, or the specified default value.
**/
readText(fileName: string, def?: string): Promise<string>;
/**
* Deletes a file from the folder.
* @param fileName The file to be deleted.
* @returns A promise that is fulfilled when the file has been deleted.
**/
remove(fileName: string): Promise<void>;
/**
* 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.
**/
writeText(fileName: string, text: string): Promise<void>;
//#endregion Methods
};
/**
* An object used for storing app information that can be used to restore the app's state after it has been suspended and then resumed. Data that can usefully be contained in this object includes the current navigation page or any information the user has added to the input controls on the page. You should not add information about customization (for example colors) or user-defined lists of content.
**/
var sessionState: any;
/**
* The temp storage of the application.
**/
var temp: {
//#region Methods
/**
* Determines whether the specified file exists in the folder.
* @param filename The name of the file.
* @returns A promise that completes with a value of either true (if the file exists) or false.
**/
exists(filename: string): Promise<boolean>;
/**
* Reads the specified file. If the file doesn't exist, the specified default value is returned.
* @param fileName The file to read from.
* @param def The default value to be returned if the file failed to open.
* @returns A promise that completes with a value that is either the contents of the file, or the specified default value.
**/
readText(fileName: string, def?: string): Promise<string>;
/**
* Deletes a file from the folder.
* @param fileName The file to be deleted.
* @returns A promise that is fulfilled when the file has been deleted.
**/
remove(fileName: string): Promise<void>;
/**
* Writes the specified text to the specified file.
* @param fileName The name of the file.
* @param text The text to write.
* @returns A Promise that completes with the number of bytes successfully written to the file.
**/
writeText(fileName: string, text: string): Promise<void>;
//#endregion Methods
};
//#endregion Objects
//#region Methods
/**
* Informs the application object that asynchronous work is being performed, and that this event handler should not be considered complete until the promise completes. This function can be set inside the handlers for all WinJS.Application events: onactivated oncheckpoint onerror onloaded onready onsettings onunload.
* @param promise The promise that should complete before processing is complete.
**/
function setPromise(promise: Promise<any>): void;
//#endregion Methods
//#region Functions
/**
* Adds an event listener for application-level events: activated, checkpoint, error, loaded, ready, settings, and unload.
* @param type The type (name) of the event. You can use any of the following:"activated", "checkpoint", "error", "loaded", "ready", "settings", and" unload".
* @param listener The listener to invoke when the event is raised.
* @param capture true to initiate capture, otherwise false.
**/
function addEventListener(type: string, listener: Function, capture?: boolean): void;
/**
* Queues a checkpoint event.
**/
function checkpoint(): void;
/**
* Queues an event to be processed by the WinJS.Application event queue.
* @param eventRecord The event object is expected to have a type property that is used as the event name when dispatching on the WinJS.Application event queue. The entire object is provided to event listeners in the detail property of the event.
**/
function queueEvent(eventRecord: any): void;
/**
* Removes an event listener from the control.
* @param type The type (name) of the event.
* @param listener The listener to remove.
* @param useCapture Specifies whether or not to initiate capture.
**/
function removeEventListener(type: string, listener: Function, useCapture?: any): void;
/**
* Starts dispatching application events (the activated, checkpoint, error, loaded, ready, settings, and unload events).
**/
function start(): void;
/**
* Stops application event processing and resets WinJS.Application to its initial state. All WinJS.Application event listeners (for the activated, checkpoint, error, loaded, ready, settings, and unload events) are removed.
**/
function stop(): void;
//#endregion Functions
//#region Events
/**
* Occurs when WinRT activation has occurred. The name of this event is "activated" (and also "mainwindowactivated"). This event occurs after the loaded event and before the ready event.
* @param eventInfo An object that contains information about the event. For more information about event arguments, see the WinRT event argument classes: WebUICachedFileUpdaterActivatedEventArgs, WebUICameraSettingsActivatedEventArgs, WebUIContactPickerActivatedEventArgs, WebUIDeviceActivatedEventArgs, WebUIFileActivatedEventArgs, WebUIFileOpenPickerActivatedEventArgs, WebUIFileSavePickerActivatedEventArgs, WebUILaunchActivatedEventArgs, WebUIPrintTaskSettingsActivatedEventArgs, WebUIProtocolActivatedEventArgs, WebUISearchActivatedEventArgs, WebUIShareTargetActivatedEventArgs.
**/
function onactivated(eventInfo: CustomEvent): void;
/**
* Occurs when receiving PLM notification or when the checkpoint function is called.
* @param eventInfo An object that contains information about the event. The detail property of this object includes the following subproperties: type, setPromise.
**/
function oncheckpoint(eventInfo: CustomEvent): void;
/**
* Occurs when an unhandled error has been raised.
* @param eventInfo An object that contains information about the event.
**/
function onerror(eventInfo: CustomEvent): void;
/**
* Occurs after the DOMContentLoaded event, which fires after the page has been parsed but before all the resources are loaded. This event occurs before the activated event and the ready event.
* @param eventInfo An object that contains information about the event. The detail property of this object includes the following subproperties: type, setPromise.
**/
function onloaded(eventInfo: CustomEvent): void;
/**
* Occurs when the application is ready. This event occurs after the loaded event and the activated event.
* @param eventInfo An object that contains information about the event. The detail property of this object includes the following sub-properties: type, setPromise.
**/
function onready(eventInfo: CustomEvent): void;
/**
* Occurs when the settings charm is invoked.
* @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: type, applicationcommands.
**/
function onsettings(eventInfo: CustomEvent): void;
/**
* Occurs when the application is about to be unloaded.
* @param eventInfo An object that contains information about the event. The detail property of this object includes the following sub-properties: type, setPromise.
**/
function onunload(eventInfo: CustomEvent): void;
//#endregion Events
}
/**
* Provides functionality for data and template binding.
**/
declare module WinJS.Binding {
//#region Properties
/**
* Determines whether or not binding should automatically set the ID of an element. This property should be set to true in apps that use WinJS (WinJS) binding.
**/
var optimizeBindingReferences: boolean;
//#endregion Properties
//#region Objects
/**
* Allows you to add bindable properties dynamically.
**/
var dynamicObservableMixin: {
//#region Methods
/**
* Adds a property with change notification to this object, including a ECMAScript5 property definition.
* @param name The name of the property to add.
* @param value This object is returned.
**/
addProperty(name: string, value: any): void;
/**
* Links the specified action to the property specified in the name parameter. This function is invoked when the value of the property may have changed. It is not guaranteed that the action will be called only when a value has actually changed, nor is it guaranteed that the action will be called for every value change. The implementation of this function coalesces change notifications, such that multiple updates to a property value may result in only a single call to the specified action.
* @param name The name of the property to which to bind the action.
* @param action The function to invoke asynchronously when the property may have changed.
* @returns This object is returned.
**/
bind(name: string, action: any): Function;
/**
* Gets a property value by name.
* @param name The name of the property to get.
* @returns The value of the property as an observable object.
**/
getProperty(name: string): any;
/**
* Notifies listeners that a property value was updated.
* @param name The name of the property that is being updated.
* @param newValue The new value for the property.
* @param oldValue The old value for the property.
* @returns A promise that is completed when the notifications are complete.
**/
notify(name: string, newValue: string, oldValue: string): Promise<any>;
/**
* Removes a property value.
* @param name The name of the property to remove.
* @returns This object is returned.
**/
removeProperty(name: string): any;
/**
* Updates a property value and notifies any listeners.
* @param name The name of the property to update.
* @param value The new value of the property.
* @returns This object is returned.
**/
setProperty(name: string, value: any): any;
/**
* Removes one or more listeners from the notification list for a given property.
* @param name The name of the property to unbind. If this parameter is omitted, all listeners for all events are removed.
* @param action The function to remove from the listener list for the specified property. If this parameter is omitted, all listeners are removed for the specific property.
* @returns This object is returned.
**/
unbind(name: string, action: Function): any;
/**
* Updates a property value and notifies any listeners.
* @param name The name of the property to update.
* @param value The new value of the property.
* @returns A promise that completes when the notifications for this property change have been processed. If multiple notifications are coalesced, the promise may be canceled or the value of the promise may be updated. The fulfilled value of the promise is the new value of the property for which the notifications have been completed.
**/
updateProperty(name: string, value: any): Promise<any>;
//#endregion Methods
};
/**
* Do not instantiate. A list returned by the createFiltered method.
**/
class FilteredListProjection<T> extends ListProjection<T> {
//#region Methods
/**
* 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): IKeyDataPair<T>;
/**
* Returns the index of the first occurrence of a key in a list.
* @param key The key to locate in the list.
* @returns The index of the first occurrence of a key in a list, or -1 if not found.
**/
indexOfKey(key: string): number;
/**
* Forces the list to send a itemmutated notification to any listeners for the value at the specified index.
* @param index The index of the value that was mutated.
**/
notifyMutated(index: number): void;
/**
* Replaces the value at the specified index with a new value.
* @param index The index of the value that was replaced.
* @param newValue The new value.
**/
setAt(index: number, newValue: T): void;
//#endregion Methods
//#region Properties
/**
* The length of the list. Returns an integer value one higher than the highest element defined in an list.
**/
length: number;
//#endregion Properties
}
/**
* Do not instantiate. A list of groups.
**/
class GroupsListProjection<T> extends ListBase<T> {
//#region Methods
/**
* Gets 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): IKeyDataPair<T>;
/**
* Gets a key/data pair for the specified key.
* @param key The key of the value to retrieve.
* @returns An object with two properties: key and data.
**/
getItemFromKey(key: string): IKeyDataPair<T>;
/**
* Returns the index of the first occurrence of a key in a list.
* @param key The key to locate in the list.
* @returns The index of the first occurrence of a key in a list, or -1 if not found.
**/
indexOfKey(key: string): number;
//#endregion Methods
//#region Properties
/**
* The length of the list. Returns an integer value one higher than the highest element defined in an list.
**/
length: number;
//#endregion Properties
}
/**
* Do not instantiate. Sorts the underlying list by group key and within a group respects the position of the item in the underlying list. Returned by createGrouped.
**/
class GroupedSortedListProjection<T> extends SortedListProjection<T> {
//#region Properties
/**
* Gets a List, which is a projection of the groups that were identified in this list.
**/
groups: GroupsListProjection<T>;
//#endregion Properties
}
/**
* Represents a list of objects that can be accessed by index or by a string key. Provides methods to search, sort, filter, and manipulate the data.
**/
class List<T> extends ListBaseWithMutators<T> {
//#region Constructors
/**
* Creates a List object.
* @constructor
* @param list The array containing the elements to initalize the list.
* @param options You can set two Boolean options: binding and proxy. If options.binding is true, the list contains the result of calling as on the element values. If options.proxy is true, the list specified as the first parameter is used as the storage for the List. This option should be used with care, because uncoordinated edits to the data storage may result in errors.
**/
constructor(list?: T[], options?: any);
//#endregion Constructors
//#region Methods
/**
* Gets a key/data pair for the specified list index.
* @param index The index of value to retrieve.
* @returns An object with .key and .data properties.
**/
getItem(index: number): IKeyDataPair<T>;
/**
* Gets a key/data pair for the list item key specified.
* @param key The key of the value to retrieve.
* @returns An object with .key and .data properties.
**/
getItemFromKey(key: string): IKeyDataPair<T>;
/**
* Gets the index of the first occurrence of a key in a list.
* @param key The key to locate in the list.
* @returns The index of the first occurrence of a key in a list, or -1 if not found.
**/
indexOfKey(key: string): number;
/**
* Moves the value at index to the specified position.
* @param index The original index of the value.
* @param newIndex The index of the value after the move.
**/
move(index: number, newIndex: number): void;
/**
* Forces the list to send a itemmutated notification to any listeners for the value at the specified index.
* @param index The index of the value that was mutated.
**/
notifyMutated(index: number): void;
/**
* Returns a list with the elements reversed. This method reverses the elements of a list object in place. It does not create a new list object during execution.
**/
reverse(): void;
/**
* Replaces the value at the specified index with a new value.
* @param index The index of the value that was replaced.
* @param newValue The new value.
**/
setAt(index: number, newValue: T): void;
/**
* Returns a list with the elements sorted. This method sorts the elements of a list object in place. It does not create a new list object during execution.
* @param sortFunction The function used to determine the order of the elements. If omitted, the elements are sorted in ascending, ASCII character order. This function must always return the same results, given the same inputs. The results should not depend on values that are subject to change. You must call notifyMutated each time an item changes. Do not batch change notifications.
**/
sort(sortFunction: (left: T, right: T) => number): void;
/**
* Removes elements from a list and, if necessary, inserts new elements in their place, returning the deleted elements.
* @param start The zero-based location in the list from which to start removing elements.
* @param howMany The number of elements to remove.
* @param item The elements to insert into the list in place of the deleted elements.
* @returns The deleted elements.
**/
splice(start: number, howMany?: number, ...item: T[]): T[];
//#endregion Methods
//#region Properties
/**
* Gets or sets the length of the list, which is an integer value one higher than the highest element defined in the list.
**/
length: number;
//#endregion Properties
}
/**
* Represents a base class for lists.
**/
class ListBase<T> {
//#region Events
/**
* An item in the list has changed its value.
* @param eventInfo An object that contains information about the event. The detail contains the following information: index, key, newItem, newValue, oldItem, oldValue.
**/
onitemchanged(eventInfo: CustomEvent): void;
/**
* A new item has been inserted into the list.
* @param eventInfo An object that contains information about the event. The detail contains the following information: index, key, value.
**/
oniteminserted(eventInfo: CustomEvent): void;
/**
* An item has been changed locations in the list.
* @param eventInfo An object that contains information about the event. The detail contains the following information: index, key, value.
**/
onitemmoved(eventInfo: CustomEvent): void;
/**
* An item has been mutated. This event occurs as a result of calling the notifyMutated method.
* @param eventInfo An object that contains information about the event. The detail contains the following information: index, key, value.
**/
onitemmutated(eventInfo: CustomEvent): void;
/**
* An item has been removed from the list.
* @param eventInfo An object that contains information about the event. The detail contains the following information: index, key, value.
**/
onitemremoved(eventInfo: CustomEvent): void;
/**
* The list has been refreshed. Any references to items in the list may be incorrect.
* @param eventInfo An object that contains information about the event. The detail property of this object is null.
**/
onreload(eventInfo: CustomEvent): void;
//#endregion Events
//#region Methods
/**
* Adds an event listener to the control.
* @param type The type (name) of the event.
* @param listener The listener to invoke when the event gets raised.
* @param useCapture If true, initiates capture, otherwise false.
**/
addEventListener(type: string, listener: Function, useCapture?: boolean): void;
/**
* Links the specified action to the property specified in the name parameter. This function is invoked when the value of the property may have changed. It is not guaranteed that the action will be called only when a value has actually changed, nor is it guaranteed that the action will be called for every value change. The implementation of this function coalesces change notifications, such that multiple updates to a property value may result in only a single call to the specified action.
* @param name The name of the property to which to bind the action.
* @param action The function to invoke asynchronously when the property may have changed.
* @returns A reference to this observableMixin object.
**/
bind(name: string, action: Function): any;
/**
* Returns a new list consisting of a combination of two arrays.
* @param item Additional items to add to the end of the list.
* @returns An array containing the concatenation of the list and any other supplied items.
**/
concat(...item: T[]): T[];
/**
* Creates a live filtered projection over this list. As the list changes, the filtered projection reacts to those changes and may also change.
* @param predicate A function that accepts a single argument. The createFiltered function calls the callback with each element in the list. If the function returns true, that element will be included in the filtered list. This function must always return the same results, given the same inputs. The results should not depend on values that are subject to change. You must call notifyMutated each time an item changes. Do not batch change notifications.
* @returns A filtered projection over the list.
**/
createFiltered(predicate: (x: T) => boolean): FilteredListProjection<T>;
/**
* Creates a live grouped projection over this list. As the list changes, the grouped projection reacts to those changes and may also change. The grouped projection sorts all the elements of the list to be in group-contiguous order. The grouped projection also contains a .groups property, which is a List representing the groups that were found in the list.
* @param groupKey A function that accepts a single argument. The function is called with each element in the list, the function should return a string representing the group containing the element. This function must always return the same results, given the same inputs. The results should not depend on values that are subject to change. You must call notifyMutated each time an item changes. Do not batch change notifications.
* @param groupData A function that accepts a single argument. The function is called once, on one element per group. It should return the value that should be set as the data of the .groups list element for this group. The data value usually serves as summary or header information for the group.
* @param groupSorter A function that accepts two arguments. The function is called with pairs of group keys found in the list. It must return one of the following numeric values: negative if the first argument is less than the second (sorted before), zero if the two arguments are equivalent, positive if the first argument is greater than the second (sorted after).
* @returns A grouped projection over the list.
**/
createGrouped(groupKey: (x: T) => string, groupData: (x: T) => 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.
* @param sorter A function that accepts two arguments. The function is called with elements in the list. It must return one of the following numeric values: negative if the first argument is less than the second, zero if the two arguments are equivalent, positive if the first argument is greater than the second. This function must always return the same results, given the same inputs. The results should not depend on values that are subject to change. You must call notifyMutated each time an item changes. Do not batch change notifications.
* @returns A sorted projection over the list.
**/
createSorted(sorter: (left: T, right: T) => number): SortedListProjection<T>;
/**
* Raises an event of the specified type and with the specified additional properties.
* @param type The type (name) of the event.
* @param eventProperties The set of additional properties to be attached to the event object when the event is raised.
* @returns true if preventDefault was called on the event.
**/
dispatchEvent(type: string, eventProperties: any): boolean;
/**
* Checks whether the specified callback function returns true for all elements in a list.
* @param callback A function that accepts up to three arguments. This function is called for each element in the list until it returns false or the end of the list is reached.
* @param thisArg An object to which the this keyword can refer in the callback function. If thisArg is omitted, undefined is used.
* @returns true if the callback returns true for all elements in the list.
**/
every(callback: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean;
/**
* Returns the elements of a list that meet the condition specified in a callback function.
* @param callback A function that accepts up to three arguments. The function is called for each element in the list. This function must always return the same results, given the same inputs. The results should not depend on values that are subject to change. You must call notifyMutated each time an item changes. Do not batch change notifications.
* @param thisArg An object to which the this keyword can refer in the callback function. If thisArg is omitted, undefined is used.
* @returns An array containing the elements that meet the condition specified in the callback function.
**/
filter(callback: (value: T, index: number, array: T[]) => any, thisArg?: any): T[];
/**
* Calls the specified callback function for each element in a list.
* @param callback A function that accepts up to three arguments. The function is called for each element in the list. The arguments are as follows: value, index, array.
* @param thisArg An object to which the this keyword can refer in the callback function. If thisArg is omitted, undefined is used.
**/
forEach(callback: (value: T, index: number, array: T[]) => void, thisArg?: any): void;
/**
* Gets the value at the specified index.
* @param index The index of the value to get.
* @returns The value at the specified index.
**/
getAt(index: number): T;
/**
* Gets the index of the first occurrence of the specified value in a list.
* @param searchElement The value to locate in the list.
* @param fromIndex The index at which to begin the search. If fromIndex is omitted, the search starts at index 0.
* @returns The index of the first occurrence of a value in a list or -1 if not found.
**/
indexOf(searchElement: T, fromIndex?: number): number;
/**
* Returns a string consisting of all the elements of a list separated by the specified separator string.
* @param separator A string used to separate the elements of a list. If this parameter is omitted, the list elements are separated with a comma.
* @returns The elements of a list separated by the specified separator string.
**/
join(separator: string): string;
/**
* Gets the index of the last occurrence of the specified value in a list.
* @param searchElement The value to locate in the list.
* @param fromIndex The index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the list.
* @returns The index of the last occurrence of a value in a list, or -1 if not found.
**/
lastIndexOf(searchElement: T, fromIndex: number): number;
/**
* Calls the specified callback function on each element of a list, and returns an array that contains the results.
* @param callback A function that accepts up to three arguments. The function is called for each element in the list.
* @param thisArg n object to which the this keyword can refer in the callback function. If thisArg is omitted, undefined is used.
* @returns An array containing the result of calling the callback function on each element in the list.
**/
map<G>(callback: (value: T, index: number, array: T[]) => G, thisArg?: any): G[];
/**
* Notifies listeners that a property value was updated.
* @param name The name of the property that is being updated.
* @param newValue The new value for the property.
* @param oldValue The old value for the property.
* @returns A promise that is completed when the notifications are complete.
**/
notify(name: string, newValue: any, oldValue: any): Promise<any>;
/**
* Forces the list to send a reload notification to any listeners.
**/
notifyReload(): void;
/**
* Accumulates a single result by calling the specified callback function for all elements in a list. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.
* @param callback A function that accepts up to four arguments. These arguments are: previousValue, currentValue, currentIndex, array. The function is called for each element in the list.
* @param initiallValue If initialValue is specified, it is used as the value with which to start the accumulation. The first call to the function provides this value as an argument instead of a list value.
* @returns The return value from the last call to the callback function.
**/
reduce(callback: (previousValue: any, currentValue: any, currentIndex: number, array: T[]) => T, initiallValue?: T): T;
/**
* Accumulates a single result by calling the specified callback function for all elements in a list, starting with the last member of the list. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.
* @param callback A function that accepts up to four arguments. These arguments are: previousValue, currentValue, currentIndex, array. The function is called for each element in the list.
* @param initialValue If initialValue is specified, it is used as the value with which to start the accumulation. The first call to the callback function provides this value as an argument instead of a list value.
* @returns The return value from the last call to callback function.
**/
reduceRight(callback: (previousValue: any, currentValue: any, currentIndex: number, array: T[]) => T, initialValue?: T): T;
/**
* Removes an event listener from the control.
* @param type The type (name) of the event.
* @param listener The listener to remove.
* @param useCapture true if capture is to be initiated, otherwise false.
**/
removeEventListener(type: string, listener: Function, useCapture?: boolean): void;
/**
* Extracts a section of a list and returns a new list.
* @param begin The index that specifies the beginning of the section.
* @param end The index that specifies the end of the section.
* @returns Returns a section of list.
**/
slice(begin: number, end: number): T[];
/**
* Checks whether the specified callback function returns true for any element of a list.
* @param callback A function that accepts up to three arguments. The function is called for each element in the list until it returns true, or until the end of the list.
* @param thisArg An object to which the this keyword can refer in the callback function. If thisArg is omitted, undefined is used.
* @returns true if callback returns true for any element in the list.
**/
some(callback: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean;
/**
* Removes one or more listeners from the notification list for a given property.
* @param name The name of the property to unbind. If this parameter is omitted, all listeners for all events are removed.
* @param action The function to remove from the listener list for the specified property. If this parameter is omitted, all listeners are removed for the specific property.
* @returns This object is returned.
**/
unbind(name: string, action: Function): any;
//#endregion Methods
//#region Properties
/**
* Gets the IListDataSource for the list. The only purpose of this property is to adapt a List to the data model that is used by ListView and FlipView.
**/
dataSource: WinJS.UI.IListDataSource<T>;
/**
* Indicates that the object is compatibile with declarative processing.
**/
static supportedForProcessing: boolean;
//#endregion Properties
}
/**
* Represents a base class for normal list modifying operations.
**/
class ListBaseWithMutators<T> extends ListBase<T> {
//#region Methods
/**
* Removes the last element from a list and returns it.
* @returns The last element from the list.
**/
pop(): T;
/**
* Appends new element(s) to a list, and returns the new length of the list.
* @param value The element to insert at the end of the list.
* @returns The new length of the list.
**/
push(value: T): number;
/**
* Removes the first element from a list and returns it.
* @returns The first element from the list.
**/
shift(): T;
/**
* Appends new element(s) to a list, and returns the new length of the list.
* @param value The element to insert at the start of the list.
* @returns The new length of the list.
**/
unshift(value: T): number;
//#endregion Methods
}
/**
* Represents a base class for list projections.
**/
class ListProjection<T> extends ListBaseWithMutators<T> {
//#region Methods
/**
* Disconnects a WinJS.Binding.List projection from its underlying WinJS.Binding.List. It's only important to call this method when the WinJS.Binding.List projection and the WinJS.Binding.List have different lifetimes. (Call this method on the WinJS.Binding.List projection, not the underlying WinJS.Binding.List.)
**/
dispose(): void;
/**
* Gets a key/data pair for the specified key.
* @param key The key of the value to retrieve.
* @returns An object with two properties: key and data.
**/
getItemFromKey(key: string): IKeyDataPair<T>;
/**
* Moves the value at index to position newIndex.
* @param index The original index of the value.
* @param newIndex The index of the value after the move.
**/
move(index: number, newIndex: number): void;
/**
* Removes elements from a list and, if necessary, inserts new elements in their place, returning the deleted elements.
* @param start The zero-based location in the list from which to start removing elements.
* @param howMany The number of elements to remove.
* @param item The elements to insert into the list in place of the deleted elements.
* @returns The deleted elements.
**/
splice(start: number, howMany?: number, ...item: T[]): T[];
//#endregion Methods
}
/**
* Provides a standard implementation of the bindable contract, as well as a basic storage mechanism that participates in change notification and an asynchronous notification implementation.
**/
var mixin: {
//#region Methods
/**
* Adds a property to the object. The property includes change notification and an ECMAScript 5 property definition .
* @param name The name of the property to add.
* @param value The value of the property.
* @returns This object is returned.
**/
addProperty(name: string, value: any): any;
/**
* Links the specified action to the property specified in the name parameter. This function is invoked when the value of the property may have changed. It is not guaranteed that the action will be called only when a value has actually changed, nor is it guaranteed that the action will be called for every value change. The implementation of this function coalesces change notifications, such that multiple updates to a property value may result in only a single call to the specified action.
* @param name The name of the property to which to bind the action.
* @param action The function to invoke asynchronously when the property may have changed.
* @returns This object is returned.
**/
bind(name: string, action: any): Function;
/**
* Gets a property value by name.
* @param name The name of the property to get.
* @returns The value of the property as an observable object.
**/
getProperty(name: string): any;
/**
* Notifies listeners that a property value was updated.
* @param name The name of the property that is being updated.
* @param newValue The new value for the property.
* @param oldValue The old value for the property.
* @returns A promise that is completed when the notifications are complete.
**/
notify(name: string, newValue: string, oldValue: string): Promise<any>;
/**
* Removes a property value.
* @param name The name of the property to remove.
* @returns This object is returned.
**/
removeProperty(name: string): any;
/**
* Updates a property value and notifies any listeners.
* @param name The name of the property to update.
* @param value The new value of the property.
* @returns This object is returned.
**/
setProperty(name: string, value: any): any;
/**
* Removes one or more listeners from the notification list for a given property.
* @param name The name of the property to unbind. If this parameter is omitted, all listeners for all events are removed.
* @param action The function to remove from the listener list for the specified property. If this parameter is omitted, all listeners are removed for the specific property.
* @returns This object is returned.
**/
unbind(name: string, action: Function): any;
/**
* Updates a property value and notifies any listeners.
* @param name The name of the property to update.
* @param value The new value of the property.
* @returns A promise that completes when the notifications for this property change have been processed. If multiple notifications are coalesced, the promise may be canceled or the value of the promise may be updated. The fulfilled value of the promise is the new value of the property for which the notifications have been completed.
**/
updateProperty(name: string, value: any): Promise<any>;
//#endregion Methods
};
/**
* Provides functions that can make an object observable.
**/
var observableMixin: {
//#region Methods
/**
* Links the specified action to the property specified in the name parameter. This function is invoked when the value of the property may have changed. It is not guaranteed that the action will be called only when a value has actually changed, nor is it guaranteed that the action will be called for every value change. The implementation of this function coalesces change notifications, such that multiple updates to a property value may result in only a single call to the specified action.
* @param name The name of the property to which to bind the action.
* @param action The function to invoke asynchronously when the property may have changed.
* @returns A reference to this observableMixin object.
**/
bind(name: string, action: Function): any;
/**
* Notifies listeners that a property value was updated.
* @param name The name of the property that is being updated.
* @param newValue The new value for the property.
* @param oldValue The old value for the property.
* @returns A promise that is completed when the notifications are complete.
**/
notify(name: string, newValue: any, oldValue: any): Promise<any>;
/**
* Removes one or more listeners from the notification list for a given property.
* @param name The name of the property to unbind. If this parameter is omitted, all listeners for all events are removed.
* @param action The function to remove from the listener list for the specified property. If this parameter is omitted, all listeners are removed for the specific property.
* @returns This object is returned.
**/
unbind(name: string, action: Function): any;
//#endregion Methods
};
/**
* Do not instantiate. Returned by the createSorted method.
**/
class SortedListProjection<T> extends ListProjection<T> {
//#region Methods
/**
* 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): IKeyDataPair<T>;
/**
* Returns the index of the first occurrence of a key.
* @param key The key to locate in the list.
* @returns The index of the first occurrence of a key in a list, or -1 if not found.
**/
indexOfKey(key: string): number;
/**
* Forces the list to send a itemmutated notification to any listeners for the value at the specified index.
* @param index The index of the value that was mutated.
**/
notifyMutated(index: number): void;
/**
* Replaces the value at the specified index with a new value.
* @param index The index of the value to be replaced.
* @param newValue The new value.
**/
setAt(index: number, newValue: T): void;
//#endregion Methods
//#region Properties
/**
* Gets or sets the length of the list. Returns an integer value one higher than the highest element defined in a list.
**/
length: number;
//#endregion Properties
}
/**
* Provides a reusable declarative binding element.
**/
class Template {
//#region Constructors
/**
* Creates a template that provides a reusable declarative binding element.
* @constructor
* @param element The DOM element to convert to a template.
* @param options If this parameter is supplied, the template is loaded from the URI and the content of the element parameter is ignored. You can add the following options: href.
**/
constructor(element: HTMLElement, options?: string);
//#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>;
/**
* 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>;
};
//#endregion Methods
//#region Properties
/**
* Gets or sets the default binding initializer for the template.
**/
bindingInitializer: any;
/**
* Gets or sets a value that specifies whether a debug break is inserted into the first rendering of each template. This property only has an effect when the app is in debug mode.
**/
debugBreakOnRender: boolean;
/**
* This property is deprecated and might not be available in future versions of the WinJS. Gets or sets a value that specifies whether optimized template processing has been disabled.
**/
disableOptimizedProcessing: boolean;
/**
* Gets the DOM element that is used as the template.
**/
element: HTMLElement;
/**
* Gets a value that specifies whether templates should be instantiated without the creation of an additional child element.
**/
extractChild: boolean;
/**
* Determines whether the Template contains declarative controls that must be processed separately. This property is always true. The controls that belong to a Template object's children are instantiated when a Template instance is rendered.
**/
isDeclarativeControlContainer: boolean;
//#endregion Properties
}
//#endregion Objects
//#region Functions
/**
* Adds a CSS class from the specified path of the source object to a destination object.
* @param source The source object that has the class to copy.
* @param sourceProperties The path on the source object to the source class.
* @param dest The destination object.
**/
function addClassOneTime(source: any, sourceProperties: any[], dest: HTMLElement): void;
/**
* Returns an observable object. This may be an observable proxy for the specified object, an existing proxy, or the specified object itself if it directly supports observation.
* @param data The object to observe.
* @returns The observable object.
**/
function as<U>(data: U): U;
/**
* Binds to one or more properties on the observable object or or on child values of that object.
* @param observable The object to bind to.
* @param bindingDescriptor An object literal containing the binding declarations. Binding declarations take the form: { propertyName: (function | bindingDeclaration), ... }.
* @returns An object that contains at least a "cancel" field, which is a function that removes all bindings associated with this bind request.
**/
function bind(observable: any, bindingDescriptor: any): any;
/**
* Creates a default binding initializer for binding between a source property and a destination property with the specified converter function that is executed on the value of the source property.
* @param convert The conversion function that takes the source property and produces a value that is set to the destination property. This function must be accessible from the global namespace.
* @returns The binding initializer.
**/
function converter(convert: Function): Function;
/**
* Creates a one-way binding between the source object and the destination object. Warning Do not attempt to bind data to the ID of an HTML element.
* @param source The source object.
* @param sourceProperties The path on the source object to the source property.
* @param dest The destination object.
* @param destProperties The path on the destination object to the destination property.
* @returns An object with a cancel method that is used to coalesce bindings.
**/
function defa