diff --git a/.gitignore b/.gitignore index c10001e..096ddf3 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,7 @@ test-reports.xml npm-debug.log node_modules +!preuninstall.js +!postinstall.js +!Gruntfile.js +.d.ts diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 0000000..1764098 --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,98 @@ +var now = new Date().toISOString(); + +function shallowCopy(obj) { + var result = {}; + Object.keys(obj).forEach(function(key) { + result[key] = obj[key]; + }); + return result; +} + +var travisTag = process.env["TRAVIS_TAG"]; + +module.exports = function(grunt) { + var path = require("path"); + + grunt.loadNpmTasks("grunt-shell"); + + grunt.registerTask("set_package_version", function(version) { + version = version || travisTag; + if (!version) { + return; + } + + var packageJson = grunt.file.readJSON("package.json"); + packageJson.version = version; + grunt.file.write("package.json", JSON.stringify(packageJson, null, " ")); + }); + + grunt.registerTask("pack", [ + "set_package_version", + "shell:build_package", + ]); + + grunt.registerTask("publish", function(versionTag) { + grunt.config.set('versionTag', versionTag); + grunt.task.run('shell:travis_publish'); + }); + + grunt.initConfig({ + pkg: grunt.file.readJSON("package.json"), + + ts: { + options: { + target: 'es5', + module: 'commonjs', + sourceMap: true, + declaration: false, + removeComments: false, + noImplicitAny: false, + experimentalDecorators: true, + emitDecoratorMetadata: true + }, + + devlib: { + src: ["**/*.ts", "!node_modules/**/*.ts", "!declarations.d.ts"], + reference: ".d.ts" + }, + + release_build: { + src: ["**/*.ts", "!node_modules/**/*.ts", "test/**/*.ts"], + reference: ".d.ts", + options: { + sourceMap: false, + removeComments: true + } + } + }, + + shell: { + options: { + stdout: true, + stderr: true, + failOnError: true + }, + + build_package: { + command: "npm pack", + }, + + travis_publish: { + command: [ + 'git tag -a <%= versionTag %> -m "nativescript-unit-test-runner v<%= versionTag %>" remotes/origin/master', + 'git push origin <%= versionTag %>' + ].join('&&') + } + }, + + clean: { + src: ["**/*.js*", "!**/*.json", "!postinstall.js", "!preuninstall.ts", "!Gruntfile.js", "!node_modules/**/*", "*.tgz"] + } + }); + + grunt.loadNpmTasks("grunt-contrib-clean"); + grunt.loadNpmTasks("grunt-contrib-watch"); + grunt.loadNpmTasks("grunt-ts"); + + grunt.registerTask("default", "ts:devlib"); +}; diff --git a/app.ts b/app.ts index 6c5b883..07e5720 100644 --- a/app.ts +++ b/app.ts @@ -1,4 +1,3 @@ -import application = require("application"); -application.mainModule = "./tns_modules/nativescript-unit-test-runner/main-page"; +import * as application from "application"; application.cssFile = "./tns_modules/nativescript-unit-test-runner/app.css"; -application.start(); +application.start({ moduleName: "./tns_modules/nativescript-unit-test-runner/main-page" }); diff --git a/declarations.d.ts b/declarations.d.ts index 17e20e7..3a1c94c 100644 --- a/declarations.d.ts +++ b/declarations.d.ts @@ -2,20 +2,10 @@ startsWith(prefix: string): boolean; } -declare var global; -declare var require; - - -declare module module { - var id: string; - var filename: string; - var exports: any; -} // Same as module.exports declare var exports: any; declare function exit(exitCode: number): void; - declare module java { module lang { module System { @@ -24,971 +14,3 @@ declare module java { } } -/** - * Contains the Observable class, which represents an observable object, or "data" in the model-view paradigm. - */ -declare module "data/observable" { - /** - * Base event data. - */ - interface EventData { - /** - * The name of the event. - */ - eventName: string; - /** - * The Observable instance that has raised the event. - */ - object: Observable; - } - - /** - * Data for the "propertyChange" event. - */ - interface PropertyChangeData extends EventData { - /** - * The name of the property that has changed. - */ - propertyName: string; - /** - * The new value of the property. - */ - value: any; - } - - /** - * Observable is used when you want to be notified when a change occurs. Use on/off methods to add/remove listener. - */ - class Observable { - /** - * String value used when hooking to propertyChange event. - */ - public static propertyChangeEvent: string; - - /** - * Creates an Observable instance and sets its properties accroding to the supplied JSON object. - */ - constructor(json?: any); - - /** - * Gets the name of the constructor function for this instance. E.g. for a Button class this will return "Button". - */ - typeName: string; - - /** - * A basic method signature to hook an event listener (shortcut alias to the addEventListener method). - * @param eventNames - String corresponding to events (e.g. "propertyChange"). Optionally could be used more events separated by `,` (e.g. "propertyChange", "change"). - * @param callback - Callback function which will be executed when event is raised. - * @param thisArg - An optional parameter which will be used as `this` context for callback execution. - */ - on(eventNames: string, callback: (data: EventData) => void, thisArg?: any); - - /** - * Raised when a propertyChange occurs. - */ - on(event: "propertyChange", callback: (data: EventData) => void, thisArg?: any); - - /** - * Shortcut alias to the removeEventListener method. - */ - off(eventNames: string, callback?: any, thisArg?: any); - - /** - * Adds a listener for the specified event name. - * @param eventNames Comma delimited names of the events to attach the listener to. - * @param callback A function to be called when some of the specified event(s) is raised. - * @param thisArg An optional parameter which when set will be used as "this" in callback method call. - */ - addEventListener(eventNames: string, callback: (data: EventData) => void, thisArg?: any); - - /** - * Removes listener(s) for the specified event name. - * @param eventNames Comma delimited names of the events the specified listener is associated with. - * @param callback An optional parameter pointing to a specific listener. If not defined, all listeners for the event names will be removed. - * @param thisArg An optional parameter which when set will be used to refine search of the correct callback which will be removed as event listener. - */ - removeEventListener(eventNames: string, callback?: any, thisArg?: any); - - /** - * Updates the specified property with the provided value. - */ - set(name: string, value: any): void; - - /** - * Gets the value of the specified property. - */ - get(name: string): any; - - /** - * Notifies all the registered listeners for the event provided in the data.eventName. - * @param data The data associated with the event. - */ - notify(data: T): void; - - /** - * Notifies all the registered listeners for the property change event. - */ - notifyPropertyChange(propertyName: string, newValue: any): void; - - /** - * Checks whether a listener is registered for the specified event name. - * @param eventName The name of the event to check for. - */ - hasListeners(eventName: string): boolean; - - //@private - /** - * This method is intended to be overriden by inheritors to provide additional implementation. - */ - _setCore(data: PropertyChangeData); - _createPropertyChangeData(name: string, value: any): PropertyChangeData; - _emit(eventNames: string); - //@endprivate - } -} - -declare module "data/observable-array" { - import observable = require("data/observable"); - - /** - * Event args for "changed" event. - */ - interface ChangedData extends observable.EventData { - /** - * Change type. - */ - action: string; - - /** - * Start index. - */ - index: number; - - /** - * Removed items. - */ - removed: Array; - - /** - * Number of added items. - */ - addedCount: number; - } - - /** - * Change types. - */ - class ChangeType { - static Add: string; - static Delete: string; - static Update: string; - static Splice: string; - } - - /** - * Advanced array like class used when you want to be notified when a change occurs. - */ - class ObservableArray extends observable.Observable { - /** - * String value used when hooking to change event. - */ - public static changeEvent: string; - - /** - * A basic method signature to hook an event listener (shortcut alias to the addEventListener method). - * @param eventNames - String corresponding to events (e.g. "propertyChange"). Optionally could be used more events separated by `,` (e.g. "propertyChange", "change"). - * @param callback - Callback function which will be executed when event is raised. - * @param thisArg - An optional parameter which will be used as `this` context for callback execution. - */ - on(eventNames: string, callback: (data: observable.EventData) => void, thisArg?: any); - - /** - * Raised when a change occurs. - */ - on(event: "change", callback: (args: ChangedData) => void, thisArg?: any); - - /** - * Create ObservableArray with specified length. - */ - constructor(arrayLength?: number); - - /** - * Create ObservableArray from source Array. - */ - constructor(items: T[]); - - /** - * Create ObservableArray from T items. - */ - constructor(...items: T[]); - - /** - * Returns item at specified index. - */ - getItem(index: number): T; - /** - * Sets item at specified index. - */ - setItem(index: number, value: T): void; - /** - * Returns a string representation of an array. - */ - toString(): string; - toLocaleString(): string; - /** - * Combines two or more arrays. - * @param items Additional items to add to the end of array1. - */ - concat(...items: U[]): T[]; - /** - * Combines two or more arrays. - * @param items Additional items to add to the end of array1. - */ - concat(...items: T[]): T[]; - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** - * Removes the last element from an array and returns it. - */ - pop(): T; - /** - * Appends new elements to an array, and returns the new length of the array. - * @param items New elements of the Array. - */ - push(items: T[]): number; - /** - * Appends new elements to an array, and returns the new length of the array. - * @param items New elements of the Array. - */ - push(...items: T[]): number; - - /** - * Reverses the elements in an Array. - */ - reverse(): T[]; - /** - * Removes the first element from an array and returns it. - */ - shift(): T; - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): T[]; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: T, b: T) => number): T[]; - - /** - * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. - * @param start The zero-based location in the array from which to start removing elements. - */ - splice(start: number): T[]; - - /** - * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. - * @param start The zero-based location in the array from which to start removing elements. - * @param deleteCount The number of elements to remove. - * @param items Elements to insert into the array in place of the deleted elements. - */ - splice(start: number, deleteCount: number, ...items: T[]): T[]; - - /** - * Inserts new elements at the start of an array. - * @param items Elements to insert at the start of the Array. - */ - unshift(...items: T[]): number; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0. - */ - indexOf(searchElement: T, fromIndex?: number): number; - - /** - * Returns the index of the last occurrence of a specified value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the array. - */ - lastIndexOf(searchElement: T, fromIndex?: number): number; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls the callbackfn function for each element in array1 until the callbackfn returns false, or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the callbackfn function for each element in array1 until the callbackfn returns true, or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; - - /** - * Calls a defined callback function on each element of an array, and returns an array that contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): T[]; - - /** - * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. - */ - reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; - /** - * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; - /** - * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; - - /** - * Gets or sets the length of the array. This is a number one higher than the highest element defined in an array. - */ - length: number; - } -} - -// Type definitions for es6-promise -// Project: https://github.com/jakearchibald/ES6-Promise -// Definitions by: François de Campredon -// Definitions: https://github.com/borisyankov/DefinitelyTyped -interface Thenable { - then(onFulfilled?: (value: R) => Thenable, onRejected?: (error: any) => Thenable): Thenable; - then(onFulfilled?: (value: R) => Thenable, onRejected?: (error: any) => U): Thenable; - then(onFulfilled?: (value: R) => Thenable, onRejected?: (error: any) => void): Thenable; - then(onFulfilled?: (value: R) => U, onRejected?: (error: any) => Thenable): Thenable; - then(onFulfilled?: (value: R) => U, onRejected?: (error: any) => U): Thenable; - then(onFulfilled?: (value: R) => U, onRejected?: (error: any) => void): Thenable; -} - -declare class Promise implements Thenable { - /** - * If you call resolve in the body of the callback passed to the constructor, - * your promise is fulfilled with result object passed to resolve. - * If you call reject your promise is rejected with the object passed to resolve. - * For consistency and debugging (eg stack traces), obj should be an instanceof Error. - * Any errors thrown in the constructor callback will be implicitly passed to reject(). - */ - constructor(callback: (resolve: (result?: R) => void, reject: (error: any) => void) => void); - /** - * If you call resolve in the body of the callback passed to the constructor, - * your promise will be fulfilled/rejected with the outcome of thenable passed to resolve. - * If you call reject your promise is rejected with the object passed to resolve. - * For consistency and debugging (eg stack traces), obj should be an instanceof Error. - * Any errors thrown in the constructor callback will be implicitly passed to reject(). - */ - constructor(callback: (resolve: (thenable?: Thenable) => void, reject: (error: any) => void) => void); - - /** - * onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects. - * Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called. - * Both callbacks have a single parameter , the fulfillment value or rejection reason. - * "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve. - * If an error is thrown in the callback, the returned promise rejects with that error. - * @param onFulfilled called when/if "promise" resolves - * @param onRejected called when/if "promise" rejects - */ - then(onFulfilled?: (value: R) => Thenable, onRejected?: (error: any) => Thenable): Promise; - /** - * onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects. - * Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called. - * Both callbacks have a single parameter , the fulfillment value or rejection reason. - * "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve. - * If an error is thrown in the callback, the returned promise rejects with that error. - * @param onFulfilled called when/if "promise" resolves - * @param onRejected called when/if "promise" rejects - */ - then(onFulfilled?: (value: R) => Thenable, onRejected?: (error: any) => U): Promise; - /** - * onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects. - * Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called. - * Both callbacks have a single parameter , the fulfillment value or rejection reason. - * "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve. - * If an error is thrown in the callback, the returned promise rejects with that error. - * @param onFulfilled called when/if "promise" resolves - * @param onRejected called when/if "promise" rejects - */ - then(onFulfilled?: (value: R) => Thenable, onRejected?: (error: any) => void): Promise; - /** - * onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects. - * Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called. - * Both callbacks have a single parameter , the fulfillment value or rejection reason. - * "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve. - * If an error is thrown in the callback, the returned promise rejects with that error. - * @param onFulfilled called when/if "promise" resolves - * @param onRejected called when/if "promise" rejects - */ - then(onFulfilled?: (value: R) => U, onRejected?: (error: any) => Thenable): Promise; - /** - * onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects. - * Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called. - * Both callbacks have a single parameter , the fulfillment value or rejection reason. - * "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve. - * If an error is thrown in the callback, the returned promise rejects with that error. - * @param onFulfilled called when/if "promise" resolves - * @param onRejected called when/if "promise" rejects - */ - then(onFulfilled?: (value: R) => U, onRejected?: (error: any) => U): Promise; - /** - * onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects. - * Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called. - * Both callbacks have a single parameter , the fulfillment value or rejection reason. - * "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve. - * If an error is thrown in the callback, the returned promise rejects with that error. - * @param onFulfilled called when/if "promise" resolves - * @param onRejected called when/if "promise" rejects - */ - then(onFulfilled?: (value: R) => U, onRejected?: (error: any) => void): Promise; - - /** - * Sugar for promise.then(undefined, onRejected) - * @param onRejected called when/if "promise" rejects - */ - catch(onRejected?: (error: any) => Thenable): Promise; - /** - * Sugar for promise.then(undefined, onRejected) - * @param onRejected called when/if "promise" rejects - */ - catch(onRejected?: (error: any) => U): Promise; - /** - * Sugar for promise.then(undefined, onRejected) - * @param onRejected called when/if "promise" rejects - */ - catch(onRejected?: (error: any) => void): Promise; -} - -declare module Promise { - /** - * Returns promise (only if promise.constructor == Promise) - */ - function cast(promise: Promise): Promise; - /** - * Make a promise that fulfills to obj. - */ - function cast(object: R): Promise; - - /** - * Make a new promise from the thenable. - * A thenable is promise-like in as far as it has a "then" method. - * This also creates a new promise if you pass it a genuine JavaScript promise, making it less efficient for casting than Promise.cast. - */ - function resolve(thenable?: Thenable): Promise; - /** - * Make a promise that fulfills to obj. Same as Promise.cast(obj) in this situation. - */ - function resolve(object?: R): Promise; - - /** - * Make a promise that rejects to obj. For consistency and debugging (eg stack traces), obj should be an instanceof Error - */ - function reject(error: any): Promise; - - /** - * Make a promise that fulfills when every item in the array fulfills, and rejects if (and when) any item rejects. - * the array passed to all can be a mixture of promise-like objects and other objects. - * The fulfillment value is an array (in order) of fulfillment values. The rejection value is the first rejection value. - */ - function all(promises: Promise[]): Promise; - - /** - * Make a Promise that fulfills when any item fulfills, and rejects if any item rejects. - */ - function race(promises: Promise[]): Promise; -} - -/** - * Allows you to send web requests and receive the responses. - */ -declare module "http" { - /** - * Downloads the content from the specified URL as a string. - * @param url The URL to request from. - */ - export function getString(url: string): Promise - - /** - * Downloads the content from the specified URL as a string. - * @param options An object that specifies various request options. - */ - export function getString(options: HttpRequestOptions): Promise - - /** - * Downloads the content from the specified URL as a string and returns its JSON.parse representation. - * @param url The URL to request from. - */ - export function getJSON(url: string): Promise - - /** - * Downloads the content from the specified URL as a string and returns its JSON.parse representation. - * @param options An object that specifies various request options. - */ - export function getJSON(options: HttpRequestOptions): Promise - - /** - * Makes a generic http request using the provided options and returns a HttpResponse Object. - * @param options An object that specifies various request options. - */ - export function request(options: HttpRequestOptions): Promise; - - /** - * Provides options for the http requests. - */ - export interface HttpRequestOptions { - /** - * Gets or sets the request url. - */ - url: string; - - /** - * Gets or sets the request method. - */ - method: string; - - /** - * Gets or sets the request headers in JSON format. - */ - headers?: any; - - /** - * Gets or sets the request body. - */ - content?: string | FormData; - - /** - * Gets or sets the request timeout in milliseconds. - */ - timeout?: number; - } - - /** - * Encapsulates HTTP-response information from an HTTP-request. - */ - export interface HttpResponse { - /** - * Gets the response status code. - */ - statusCode: number; - - /** - * Gets the response headers. - */ - headers: any; - - /** - * Gets the response content. - */ - content?: HttpContent; - } - - /** - * Encapsulates the content of an HttpResponse. - */ - export interface HttpContent { - /** - * Gets the response body as raw data. - */ - raw: any; - - /** - * Gets the response body as string. - */ - toString: () => string; - - /** - * Gets the response body as JSON object. - */ - toJSON: () => any; - } -} - -/** - * Contains all kinds of information about the device, its operating system and software. - */ -declare module "platform" { - - /* - * Enum holding platform names. - */ - export module platformNames { - export var android: string; - export var ios: string; - } - - /* - * An object containing device specific information. - */ - export class device { - /** - * Gets the manufacturer of the device. - * For example: "Apple" or "HTC" or "Samsung". - */ - static manufacturer: string; - - /** - * Gets the model of the device. - * For example: "Nexus 5" or "iPhone". - */ - static model: string; - - /** - * Gets the model of the device. - * For example: "Android" or "iOS". - */ - static os: string; - - /** - * Gets the OS version. - * For example: 4.4.4(android), 8.1(ios) - */ - static osVersion: string; - - /** - * Gets the OS version. - * For example: 19(android), 8.1(ios). - */ - static sdkVersion: string; - - /** - * Gets the type current device. - * Available values: "phone", "tablet". - */ - static deviceType: string; - - /** - * Gets the uuid. - * On iOS this will return a new uuid if the application re-installed on the device. - * If you need to receive the same uuid even after the application has been re-installed on the device, - * use this plugin: https://www.npmjs.com/package/nativescript-ios-uuid - */ - static uuid: string; - - /** - * Gets the preferred language. For example "en" or "en_US" - */ - static language: string; - } - - /** - * An object containing screen information. - */ - export interface ScreenMetrics { - /** - * Gets the absolute width of the screen in pixels. - */ - widthPixels: number; - - /** - * Gets the absolute height of the screen in pixels. - */ - heightPixels: number; - - /** - * Gets the absolute width of the screen in density independent pixels. - */ - widthDIPs: number; - - /** - * Gets the absolute height of the screen in density independent pixels. - */ - heightDIPs: number; - - /** - * The logical density of the display. This is a scaling factor for the Density Independent Pixel unit. - */ - scale: number; - } - - /** - * An object describing general information about a display. - */ - export class screen { - /** - * Gets information about the main screen of the current device. - */ - static mainScreen: ScreenMetrics; - } -} - -/** - * Contains the Frame class, which represents the logical View unit that is responsible for navigation within an application. - */ -declare module "ui/frame" { - /** - * Represents the logical View unit that is responsible for navigation withing an application. - * Typically an application will have a Frame object at a root level. - * Nested frames are supported, enabling hierarchical navigation scenarios. - */ - export class Frame { - /** - * Navigates to a Page instance as described by the module name. - * This method will require the module and will check for a Page property in the exports of the module. - * @param pageModuleName The name of the module to require starting from the application root. - * For example if you want to navigate to page called "myPage.js" in a folder called "subFolder" and your root folder is "app" you can call navigate method like this: - * var frames = require("ui/frame"); - * frames.topmost().navigate("app/subFolder/myPage"); - */ - navigate(pageModuleName: string); - } - - /** - * Gets the topmost frame in the frames stack. An application will typically has one frame instance. Multiple frames handle nested (hierarchical) navigation scenarios. - */ - export function topmost(): Frame; -} - -/** - * Contains the application abstraction with all related methods. - */ -declare module "application" { - import observable = require("data/observable"); - import frame = require("ui/frame"); - - /** - * An extended JavaScript Error which will have the nativeError property initialized in case the error is caused by executing platform-specific code. - */ - export interface NativeScriptError extends Error { - /** - * Represents the native error object. - */ - nativeError: any; - } - - /** - * String value used when hooking to launch event. - */ - export var launchEvent: string; - - /** - * String value used when hooking to uncaughtError event. - */ - export var uncaughtErrorEvent: string; - - /** - * String value used when hooking to suspend event. - */ - export var suspendEvent: string; - - /** - * String value used when hooking to resume event. - */ - export var resumeEvent: string; - - /** - * String value used when hooking to exitevent. - */ - export var exitEvent: string; - - /** - * String value used when hooking to lowMemory event. - */ - export var lowMemoryEvent: string; - - /** - * String value used when hooking to orientationChanged event. - */ - export var orientationChangedEvent: string; - - /** - * Event data containing information for the application events. - */ - export interface ApplicationEventData { - /** - * Gets the native iOS event arguments. Valid only when running on iOS. - */ - ios?: any; - - /** - * Gets the native Android event arguments. Valid only when running on Android. - */ - android?: any; - - /** - * The name of the event. - */ - eventName: string; - - /** - * The instance that has raised the event. - */ - object: any; - } - - /** - * Event data containing information for orientation changed event. - */ - export interface OrientationChangedEventData extends ApplicationEventData { - /** - * New orientation value. - */ - newValue: string; - } - - /** - * The main page path (without the file extension) for the application starting from the application root. - * For example if you have page called "main.js" in a folder called "subFolder" and your root folder is "app" you can specify mainModule like this: - * var application = require("application"); - * application.mainModule = "app/subFolder/main"; - * application.start(); - */ - export var mainModule: string; - - /** - * The application level css file name (starting from the application root). Used to set css across all pages. - * Css will be applied for every page and page css will be applied after. - */ - export var cssFile: string; - - /** - * Call this method to start the application. Important: All code after this method call will not be executed! - */ - export function start(); - - /** - * A callback to be used when an uncaught error occurs while the application is running. - * The application will be shut down after this method returns. - * Loading new UI at this point is erroneous and may lead to unpredictable results. - * The method is intended to be used for crash reports and/or application restart. - */ - export function onUncaughtError(error: NativeScriptError): void; - - /** - * This method will be called when the Application is suspended. - */ - export function onSuspend(); - - /** - * This method will be called when the Application is resumed after it has been suspended. - */ - export function onResume(); - - /** - * This method will be called when the Application is about to exitEvent. - */ - export function onExit(); - - /** - * This method will be called when there is low memory on the target device. - */ - export function onLowMemory(); - - /** - * A basic method signature to hook an event listener (shortcut alias to the addEventListener method). - * @param eventNames - String corresponding to events (e.g. "onLaunch"). Optionally could be used more events separated by `,` (e.g. "onLaunch", "onSuspend"). - * @param callback - Callback function which will be executed when event is raised. - * @param thisArg - An optional parameter which will be used as `this` context for callback execution. - */ - export function on(eventNames: string, callback: (data: any) => void, thisArg?: any); - - /** - * Shortcut alias to the removeEventListener method. - * @param eventNames - String corresponding to events (e.g. "onLaunch"). - * @param callback - Callback function which will be removed. - * @param thisArg - An optional parameter which will be used as `this` context for callback execution. - */ - export function off(eventNames: string, callback ?: any, thisArg ?: any); - - /** - * Notifies all the registered listeners for the event provided in the data.eventName. - * @param data The data associated with the event. - */ - export function notify(data: any): void; - - /** - * Checks whether a listener is registered for the specified event name. - * @param eventName The name of the event to check for. - */ - export function hasListeners(eventName: string): boolean; - - /** - * This event is raised on application launchEvent. - */ - export function on(event: "launch", callback: (args: ApplicationEventData) => void, thisArg?: any); - - /** - * This event is raised when the Application is suspended. - */ - export function on(event: "suspend", callback: (args: ApplicationEventData) => void, thisArg?: any); - - /** - * This event is raised when the Application is resumed after it has been suspended. - */ - export function on(event: "resume", callback: (args: ApplicationEventData) => void, thisArg?: any); - - /** - * This event is raised when the Application is about to exitEvent. - */ - export function on(event: "exit", callback: (args: ApplicationEventData) => void, thisArg?: any); - - /** - * This event is raised when there is low memory on the target device. - */ - export function on(event: "lowMemory", callback: (args: ApplicationEventData) => void, thisArg?: any); - - /** - * This event is raised when an uncaught error occurs while the application is running. - */ - export function on(event: "uncaughtError", callback: (args: ApplicationEventData) => void, thisArg?: any); - - /** - * This event is raised the orientation of the current device has changed. - */ - export function on(event: "orientationChanged", callback: (args: OrientationChangedEventData) => void, thisArg?: any); - - /** - * This is the Android-specific application object instance. - * Encapsulates methods and properties specific to the Android platform. - * Will be undefined when TargetOS is iOS. - */ - export var android: any; - - /** - * This is the iOS-specific application object instance. - * Encapsulates methods and properties specific to the iOS platform. - * Will be undefined when TargetOS is Android. - */ - export var ios: any; - - /** - * Data for the Android activity events. - */ -} diff --git a/definitions/node.d.ts b/definitions/node.d.ts new file mode 100644 index 0000000..43233a8 --- /dev/null +++ b/definitions/node.d.ts @@ -0,0 +1,2192 @@ +// Type definitions for Node.js v4.x +// Project: http://nodejs.org/ +// Definitions by: Microsoft TypeScript , DefinitelyTyped +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/************************************************ +* * +* Node.js v4.x API * +* * +************************************************/ + +interface Error { + stack?: string; +} + + +// compat for TypeScript 1.5.3 +// if you use with --target es3 or --target es5 and use below definitions, +// use the lib.es6.d.ts that is bundled with TypeScript 1.5.3. +interface WeakMapConstructor {} +interface WeakSetConstructor {} + +/************************************************ +* * +* GLOBAL * +* * +************************************************/ +declare var process: NodeJS.Process; +declare var global: any; + +declare var __filename: string; +declare var __dirname: string; + +declare function setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer; +declare function clearTimeout(timeoutId: NodeJS.Timer): void; +declare function setInterval(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer; +declare function clearInterval(intervalId: NodeJS.Timer): void; +declare function setImmediate(callback: (...args: any[]) => void, ...args: any[]): any; +declare function clearImmediate(immediateId: any): void; + +interface NodeRequireFunction { + (id: string): any; +} + +interface NodeRequire extends NodeRequireFunction { + resolve(id:string): string; + cache: any; + extensions: any; + main: any; +} + +declare var require: NativeScriptRequire; + +interface NodeModule { + exports: any; + require: NodeRequireFunction; + id: string; + filename: string; + loaded: boolean; + parent: any; + children: any[]; +} + +declare var module: NativeScriptModule; + +// Same as module.exports +declare var exports: any; +declare var SlowBuffer: { + new (str: string, encoding?: string): Buffer; + new (size: number): Buffer; + new (size: Uint8Array): Buffer; + new (array: any[]): Buffer; + prototype: Buffer; + isBuffer(obj: any): boolean; + byteLength(string: string, encoding?: string): number; + concat(list: Buffer[], totalLength?: number): Buffer; +}; + + +// Buffer class +interface Buffer extends NodeBuffer {} + +/** + * Raw data is stored in instances of the Buffer class. + * A Buffer is similar to an array of integers but corresponds to a raw memory allocation outside the V8 heap. A Buffer cannot be resized. + * Valid string encodings: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex' + */ +declare var Buffer: { + /** + * Allocates a new buffer containing the given {str}. + * + * @param str String to store in buffer. + * @param encoding encoding to use, optional. Default is 'utf8' + */ + new (str: string, encoding?: string): Buffer; + /** + * Allocates a new buffer of {size} octets. + * + * @param size count of octets to allocate. + */ + new (size: number): Buffer; + /** + * Allocates a new buffer containing the given {array} of octets. + * + * @param array The octets to store. + */ + new (array: Uint8Array): Buffer; + /** + * Allocates a new buffer containing the given {array} of octets. + * + * @param array The octets to store. + */ + new (array: any[]): Buffer; + /** + * Copies the passed {buffer} data onto a new {Buffer} instance. + * + * @param buffer The buffer to copy. + */ + new (buffer: Buffer): Buffer; + prototype: Buffer; + /** + * Returns true if {obj} is a Buffer + * + * @param obj object to test. + */ + isBuffer(obj: any): obj is Buffer; + /** + * Returns true if {encoding} is a valid encoding argument. + * Valid string encodings in Node 0.12: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex' + * + * @param encoding string to test. + */ + isEncoding(encoding: string): boolean; + /** + * Gives the actual byte length of a string. encoding defaults to 'utf8'. + * This is not the same as String.prototype.length since that returns the number of characters in a string. + * + * @param string string to test. + * @param encoding encoding used to evaluate (defaults to 'utf8') + */ + byteLength(string: string, encoding?: string): number; + /** + * Returns a buffer which is the result of concatenating all the buffers in the list together. + * + * If the list has no items, or if the totalLength is 0, then it returns a zero-length buffer. + * If the list has exactly one item, then the first item of the list is returned. + * If the list has more than one item, then a new Buffer is created. + * + * @param list An array of Buffer objects to concatenate + * @param totalLength Total length of the buffers when concatenated. + * If totalLength is not provided, it is read from the buffers in the list. However, this adds an additional loop to the function, so it is faster to provide the length explicitly. + */ + concat(list: Buffer[], totalLength?: number): Buffer; + /** + * The same as buf1.compare(buf2). + */ + compare(buf1: Buffer, buf2: Buffer): number; +}; + +/************************************************ +* * +* GLOBAL INTERFACES * +* * +************************************************/ +declare module NodeJS { + export interface ErrnoException extends Error { + errno?: number; + code?: string; + path?: string; + syscall?: string; + stack?: string; + } + + export interface EventEmitter { + addListener(event: string, listener: Function): EventEmitter; + on(event: string, listener: Function): EventEmitter; + once(event: string, listener: Function): EventEmitter; + removeListener(event: string, listener: Function): EventEmitter; + removeAllListeners(event?: string): EventEmitter; + setMaxListeners(n: number): EventEmitter; + getMaxListeners(): number; + listeners(event: string): Function[]; + emit(event: string, ...args: any[]): boolean; + listenerCount(type: string): number; + } + + export interface ReadableStream extends EventEmitter { + readable: boolean; + read(size?: number): string|Buffer; + setEncoding(encoding: string): void; + pause(): void; + resume(): void; + pipe(destination: T, options?: { end?: boolean; }): T; + unpipe(destination?: T): void; + unshift(chunk: string): void; + unshift(chunk: Buffer): void; + wrap(oldStream: ReadableStream): ReadableStream; + } + + export interface WritableStream extends EventEmitter { + writable: boolean; + write(buffer: Buffer|string, cb?: Function): boolean; + write(str: string, encoding?: string, cb?: Function): boolean; + end(): void; + end(buffer: Buffer, cb?: Function): void; + end(str: string, cb?: Function): void; + end(str: string, encoding?: string, cb?: Function): void; + } + + export interface ReadWriteStream extends ReadableStream, WritableStream {} + + export interface Process extends EventEmitter { + stdout: WritableStream; + stderr: WritableStream; + stdin: ReadableStream; + argv: string[]; + execArgv: string[]; + execPath: string; + abort(): void; + chdir(directory: string): void; + cwd(): string; + env: any; + exit(code?: number): void; + getgid(): number; + setgid(id: number): void; + setgid(id: string): void; + getuid(): number; + setuid(id: number): void; + setuid(id: string): void; + version: string; + versions: { + http_parser: string; + node: string; + v8: string; + ares: string; + uv: string; + zlib: string; + openssl: string; + }; + config: { + target_defaults: { + cflags: any[]; + default_configuration: string; + defines: string[]; + include_dirs: string[]; + libraries: string[]; + }; + variables: { + clang: number; + host_arch: string; + node_install_npm: boolean; + node_install_waf: boolean; + node_prefix: string; + node_shared_openssl: boolean; + node_shared_v8: boolean; + node_shared_zlib: boolean; + node_use_dtrace: boolean; + node_use_etw: boolean; + node_use_openssl: boolean; + target_arch: string; + v8_no_strict_aliasing: number; + v8_use_snapshot: boolean; + visibility: string; + }; + }; + kill(pid:number, signal?: string|number): void; + pid: number; + title: string; + arch: string; + platform: string; + memoryUsage(): { rss: number; heapTotal: number; heapUsed: number; }; + nextTick(callback: Function): void; + umask(mask?: number): number; + uptime(): number; + hrtime(time?:number[]): number[]; + + // Worker + send?(message: any, sendHandle?: any): void; + } + + export interface Global { + Array: typeof Array; + ArrayBuffer: typeof ArrayBuffer; + Boolean: typeof Boolean; + Buffer: typeof Buffer; + DataView: typeof DataView; + Date: typeof Date; + Error: typeof Error; + EvalError: typeof EvalError; + Float32Array: typeof Float32Array; + Float64Array: typeof Float64Array; + Function: typeof Function; + GLOBAL: Global; + Infinity: typeof Infinity; + Int16Array: typeof Int16Array; + Int32Array: typeof Int32Array; + Int8Array: typeof Int8Array; + Intl: typeof Intl; + JSON: typeof JSON; + Map: MapConstructor; + Math: typeof Math; + NaN: typeof NaN; + Number: typeof Number; + Object: typeof Object; + Promise: Function; + RangeError: typeof RangeError; + ReferenceError: typeof ReferenceError; + RegExp: typeof RegExp; + Set: SetConstructor; + String: typeof String; + Symbol: Function; + SyntaxError: typeof SyntaxError; + TypeError: typeof TypeError; + URIError: typeof URIError; + Uint16Array: typeof Uint16Array; + Uint32Array: typeof Uint32Array; + Uint8Array: typeof Uint8Array; + Uint8ClampedArray: Function; + WeakMap: WeakMapConstructor; + WeakSet: WeakSetConstructor; + clearImmediate: (immediateId: any) => void; + clearInterval: (intervalId: NodeJS.Timer) => void; + clearTimeout: (timeoutId: NodeJS.Timer) => void; + console: typeof console; + decodeURI: typeof decodeURI; + decodeURIComponent: typeof decodeURIComponent; + encodeURI: typeof encodeURI; + encodeURIComponent: typeof encodeURIComponent; + escape: (str: string) => string; + eval: typeof eval; + global: Global; + isFinite: typeof isFinite; + isNaN: typeof isNaN; + parseFloat: typeof parseFloat; + parseInt: typeof parseInt; + process: Process; + root: Global; + setImmediate: (callback: (...args: any[]) => void, ...args: any[]) => any; + setInterval: (callback: (...args: any[]) => void, ms: number, ...args: any[]) => NodeJS.Timer; + setTimeout: (callback: (...args: any[]) => void, ms: number, ...args: any[]) => NodeJS.Timer; + undefined: typeof undefined; + unescape: (str: string) => string; + gc: () => void; + v8debug?: any; + } + + export interface Timer { + ref() : void; + unref() : void; + } +} + +/** + * @deprecated + */ +interface NodeBuffer { + [index: number]: number; + write(string: string, offset?: number, length?: number, encoding?: string): number; + toString(encoding?: string, start?: number, end?: number): string; + toJSON(): any; + length: number; + equals(otherBuffer: Buffer): boolean; + compare(otherBuffer: Buffer): number; + copy(targetBuffer: Buffer, targetStart?: number, sourceStart?: number, sourceEnd?: number): number; + slice(start?: number, end?: number): Buffer; + writeUIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; + writeUIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; + writeIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; + writeIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; + readUIntLE(offset: number, byteLength: number, noAssert?: boolean): number; + readUIntBE(offset: number, byteLength: number, noAssert?: boolean): number; + readIntLE(offset: number, byteLength: number, noAssert?: boolean): number; + readIntBE(offset: number, byteLength: number, noAssert?: boolean): number; + readUInt8(offset: number, noAsset?: boolean): number; + readUInt16LE(offset: number, noAssert?: boolean): number; + readUInt16BE(offset: number, noAssert?: boolean): number; + readUInt32LE(offset: number, noAssert?: boolean): number; + readUInt32BE(offset: number, noAssert?: boolean): number; + readInt8(offset: number, noAssert?: boolean): number; + readInt16LE(offset: number, noAssert?: boolean): number; + readInt16BE(offset: number, noAssert?: boolean): number; + readInt32LE(offset: number, noAssert?: boolean): number; + readInt32BE(offset: number, noAssert?: boolean): number; + readFloatLE(offset: number, noAssert?: boolean): number; + readFloatBE(offset: number, noAssert?: boolean): number; + readDoubleLE(offset: number, noAssert?: boolean): number; + readDoubleBE(offset: number, noAssert?: boolean): number; + writeUInt8(value: number, offset: number, noAssert?: boolean): number; + writeUInt16LE(value: number, offset: number, noAssert?: boolean): number; + writeUInt16BE(value: number, offset: number, noAssert?: boolean): number; + writeUInt32LE(value: number, offset: number, noAssert?: boolean): number; + writeUInt32BE(value: number, offset: number, noAssert?: boolean): number; + writeInt8(value: number, offset: number, noAssert?: boolean): number; + writeInt16LE(value: number, offset: number, noAssert?: boolean): number; + writeInt16BE(value: number, offset: number, noAssert?: boolean): number; + writeInt32LE(value: number, offset: number, noAssert?: boolean): number; + writeInt32BE(value: number, offset: number, noAssert?: boolean): number; + writeFloatLE(value: number, offset: number, noAssert?: boolean): number; + writeFloatBE(value: number, offset: number, noAssert?: boolean): number; + writeDoubleLE(value: number, offset: number, noAssert?: boolean): number; + writeDoubleBE(value: number, offset: number, noAssert?: boolean): number; + fill(value: any, offset?: number, end?: number): Buffer; + indexOf(value: string | number | Buffer, byteOffset?: number): number; +} + +/************************************************ +* * +* MODULES * +* * +************************************************/ +declare module "buffer" { + export var INSPECT_MAX_BYTES: number; + var BuffType: typeof Buffer; + var SlowBuffType: typeof SlowBuffer; + export { BuffType as Buffer, SlowBuffType as SlowBuffer }; +} + +declare module "querystring" { + export interface StringifyOptions { + encodeURIComponent?: Function; + } + + export interface ParseOptions { + maxKeys?: number; + decodeURIComponent?: Function; + } + + export function stringify(obj: T, sep?: string, eq?: string, options?: StringifyOptions): string; + export function parse(str: string, sep?: string, eq?: string, options?: ParseOptions): any; + export function parse(str: string, sep?: string, eq?: string, options?: ParseOptions): T; + export function escape(str: string): string; + export function unescape(str: string): string; +} + +declare module "events" { + export class EventEmitter implements NodeJS.EventEmitter { + static EventEmitter: EventEmitter; + static listenerCount(emitter: EventEmitter, event: string): number; // deprecated + static defaultMaxListeners: number; + + addListener(event: string, listener: Function): EventEmitter; + on(event: string, listener: Function): EventEmitter; + once(event: string, listener: Function): EventEmitter; + removeListener(event: string, listener: Function): EventEmitter; + removeAllListeners(event?: string): EventEmitter; + setMaxListeners(n: number): EventEmitter; + getMaxListeners(): number; + listeners(event: string): Function[]; + emit(event: string, ...args: any[]): boolean; + listenerCount(type: string): number; + } +} + +declare module "http" { + import * as events from "events"; + import * as net from "net"; + import * as stream from "stream"; + + export interface RequestOptions { + protocol?: string; + host?: string; + hostname?: string; + family?: number; + port?: number; + localAddress?: string; + socketPath?: string; + method?: string; + path?: string; + headers?: { [key: string]: any }; + auth?: string; + agent?: Agent|boolean; + } + + export interface Server extends events.EventEmitter { + listen(port: number, hostname?: string, backlog?: number, callback?: Function): Server; + listen(port: number, hostname?: string, callback?: Function): Server; + listen(path: string, callback?: Function): Server; + listen(handle: any, listeningListener?: Function): Server; + close(cb?: any): Server; + address(): { port: number; family: string; address: string; }; + maxHeadersCount: number; + } + /** + * @deprecated Use IncomingMessage + */ + export interface ServerRequest extends IncomingMessage { + connection: net.Socket; + } + export interface ServerResponse extends events.EventEmitter, stream.Writable { + // Extended base methods + write(buffer: Buffer): boolean; + write(buffer: Buffer, cb?: Function): boolean; + write(str: string, cb?: Function): boolean; + write(str: string, encoding?: string, cb?: Function): boolean; + write(str: string, encoding?: string, fd?: string): boolean; + + writeContinue(): void; + writeHead(statusCode: number, reasonPhrase?: string, headers?: any): void; + writeHead(statusCode: number, headers?: any): void; + statusCode: number; + statusMessage: string; + headersSent: boolean; + setHeader(name: string, value: string | string[]): void; + sendDate: boolean; + getHeader(name: string): string; + removeHeader(name: string): void; + write(chunk: any, encoding?: string): any; + addTrailers(headers: any): void; + + // Extended base methods + end(): void; + end(buffer: Buffer, cb?: Function): void; + end(str: string, cb?: Function): void; + end(str: string, encoding?: string, cb?: Function): void; + end(data?: any, encoding?: string): void; + } + export interface ClientRequest extends events.EventEmitter, stream.Writable { + // Extended base methods + write(buffer: Buffer): boolean; + write(buffer: Buffer, cb?: Function): boolean; + write(str: string, cb?: Function): boolean; + write(str: string, encoding?: string, cb?: Function): boolean; + write(str: string, encoding?: string, fd?: string): boolean; + + write(chunk: any, encoding?: string): void; + abort(): void; + setTimeout(timeout: number, callback?: Function): void; + setNoDelay(noDelay?: boolean): void; + setSocketKeepAlive(enable?: boolean, initialDelay?: number): void; + + // Extended base methods + end(): void; + end(buffer: Buffer, cb?: Function): void; + end(str: string, cb?: Function): void; + end(str: string, encoding?: string, cb?: Function): void; + end(data?: any, encoding?: string): void; + } + export interface IncomingMessage extends events.EventEmitter, stream.Readable { + httpVersion: string; + headers: any; + rawHeaders: string[]; + trailers: any; + rawTrailers: any; + setTimeout(msecs: number, callback: Function): NodeJS.Timer; + /** + * Only valid for request obtained from http.Server. + */ + method?: string; + /** + * Only valid for request obtained from http.Server. + */ + url?: string; + /** + * Only valid for response obtained from http.ClientRequest. + */ + statusCode?: number; + /** + * Only valid for response obtained from http.ClientRequest. + */ + statusMessage?: string; + socket: net.Socket; + } + /** + * @deprecated Use IncomingMessage + */ + export interface ClientResponse extends IncomingMessage { } + + export interface AgentOptions { + /** + * Keep sockets around in a pool to be used by other requests in the future. Default = false + */ + keepAlive?: boolean; + /** + * When using HTTP KeepAlive, how often to send TCP KeepAlive packets over sockets being kept alive. Default = 1000. + * Only relevant if keepAlive is set to true. + */ + keepAliveMsecs?: number; + /** + * Maximum number of sockets to allow per host. Default for Node 0.10 is 5, default for Node 0.12 is Infinity + */ + maxSockets?: number; + /** + * Maximum number of sockets to leave open in a free state. Only relevant if keepAlive is set to true. Default = 256. + */ + maxFreeSockets?: number; + } + + export class Agent { + maxSockets: number; + sockets: any; + requests: any; + + constructor(opts?: AgentOptions); + + /** + * Destroy any sockets that are currently in use by the agent. + * It is usually not necessary to do this. However, if you are using an agent with KeepAlive enabled, + * then it is best to explicitly shut down the agent when you know that it will no longer be used. Otherwise, + * sockets may hang open for quite a long time before the server terminates them. + */ + destroy(): void; + } + + export var METHODS: string[]; + + export var STATUS_CODES: { + [errorCode: number]: string; + [errorCode: string]: string; + }; + export function createServer(requestListener?: (request: IncomingMessage, response: ServerResponse) =>void ): Server; + export function createClient(port?: number, host?: string): any; + export function request(options: RequestOptions, callback?: (res: IncomingMessage) => void): ClientRequest; + export function get(options: any, callback?: (res: IncomingMessage) => void): ClientRequest; + export var globalAgent: Agent; +} + +declare module "cluster" { + import * as child from "child_process"; + import * as events from "events"; + + export interface ClusterSettings { + exec?: string; + args?: string[]; + silent?: boolean; + } + + export class Worker extends events.EventEmitter { + id: string; + process: child.ChildProcess; + suicide: boolean; + send(message: any, sendHandle?: any): void; + kill(signal?: string): void; + destroy(signal?: string): void; + disconnect(): void; + } + + export var settings: ClusterSettings; + export var isMaster: boolean; + export var isWorker: boolean; + export function setupMaster(settings?: ClusterSettings): void; + export function fork(env?: any): Worker; + export function disconnect(callback?: Function): void; + export var worker: Worker; + export var workers: Worker[]; + + // Event emitter + export function addListener(event: string, listener: Function): void; + export function on(event: "disconnect", listener: (worker: Worker) => void): void; + export function on(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): void; + export function on(event: "fork", listener: (worker: Worker) => void): void; + export function on(event: "listening", listener: (worker: Worker, address: any) => void): void; + export function on(event: "message", listener: (worker: Worker, message: any) => void): void; + export function on(event: "online", listener: (worker: Worker) => void): void; + export function on(event: "setup", listener: (settings: any) => void): void; + export function on(event: string, listener: Function): any; + export function once(event: string, listener: Function): void; + export function removeListener(event: string, listener: Function): void; + export function removeAllListeners(event?: string): void; + export function setMaxListeners(n: number): void; + export function listeners(event: string): Function[]; + export function emit(event: string, ...args: any[]): boolean; +} + +declare module "zlib" { + import * as stream from "stream"; + export interface ZlibOptions { chunkSize?: number; windowBits?: number; level?: number; memLevel?: number; strategy?: number; dictionary?: any; } + + export interface Gzip extends stream.Transform { } + export interface Gunzip extends stream.Transform { } + export interface Deflate extends stream.Transform { } + export interface Inflate extends stream.Transform { } + export interface DeflateRaw extends stream.Transform { } + export interface InflateRaw extends stream.Transform { } + export interface Unzip extends stream.Transform { } + + export function createGzip(options?: ZlibOptions): Gzip; + export function createGunzip(options?: ZlibOptions): Gunzip; + export function createDeflate(options?: ZlibOptions): Deflate; + export function createInflate(options?: ZlibOptions): Inflate; + export function createDeflateRaw(options?: ZlibOptions): DeflateRaw; + export function createInflateRaw(options?: ZlibOptions): InflateRaw; + export function createUnzip(options?: ZlibOptions): Unzip; + + export function deflate(buf: Buffer, callback: (error: Error, result: any) =>void ): void; + export function deflateSync(buf: Buffer, options?: ZlibOptions): any; + export function deflateRaw(buf: Buffer, callback: (error: Error, result: any) =>void ): void; + export function deflateRawSync(buf: Buffer, options?: ZlibOptions): any; + export function gzip(buf: Buffer, callback: (error: Error, result: any) =>void ): void; + export function gzipSync(buf: Buffer, options?: ZlibOptions): any; + export function gunzip(buf: Buffer, callback: (error: Error, result: any) =>void ): void; + export function gunzipSync(buf: Buffer, options?: ZlibOptions): any; + export function inflate(buf: Buffer, callback: (error: Error, result: any) =>void ): void; + export function inflateSync(buf: Buffer, options?: ZlibOptions): any; + export function inflateRaw(buf: Buffer, callback: (error: Error, result: any) =>void ): void; + export function inflateRawSync(buf: Buffer, options?: ZlibOptions): any; + export function unzip(buf: Buffer, callback: (error: Error, result: any) =>void ): void; + export function unzipSync(buf: Buffer, options?: ZlibOptions): any; + + // Constants + export var Z_NO_FLUSH: number; + export var Z_PARTIAL_FLUSH: number; + export var Z_SYNC_FLUSH: number; + export var Z_FULL_FLUSH: number; + export var Z_FINISH: number; + export var Z_BLOCK: number; + export var Z_TREES: number; + export var Z_OK: number; + export var Z_STREAM_END: number; + export var Z_NEED_DICT: number; + export var Z_ERRNO: number; + export var Z_STREAM_ERROR: number; + export var Z_DATA_ERROR: number; + export var Z_MEM_ERROR: number; + export var Z_BUF_ERROR: number; + export var Z_VERSION_ERROR: number; + export var Z_NO_COMPRESSION: number; + export var Z_BEST_SPEED: number; + export var Z_BEST_COMPRESSION: number; + export var Z_DEFAULT_COMPRESSION: number; + export var Z_FILTERED: number; + export var Z_HUFFMAN_ONLY: number; + export var Z_RLE: number; + export var Z_FIXED: number; + export var Z_DEFAULT_STRATEGY: number; + export var Z_BINARY: number; + export var Z_TEXT: number; + export var Z_ASCII: number; + export var Z_UNKNOWN: number; + export var Z_DEFLATED: number; + export var Z_NULL: number; +} + +declare module "os" { + export interface CpuInfo { + model: string; + speed: number; + times: { + user: number; + nice: number; + sys: number; + idle: number; + irq: number; + }; + } + + export interface NetworkInterfaceInfo { + address: string; + netmask: string; + family: string; + mac: string; + internal: boolean; + } + + export function tmpdir(): string; + export function homedir(): string; + export function endianness(): string; + export function hostname(): string; + export function type(): string; + export function platform(): string; + export function arch(): string; + export function release(): string; + export function uptime(): number; + export function loadavg(): number[]; + export function totalmem(): number; + export function freemem(): number; + export function cpus(): CpuInfo[]; + export function networkInterfaces(): {[index: string]: NetworkInterfaceInfo[]}; + export var EOL: string; +} + +declare module "https" { + import * as tls from "tls"; + import * as events from "events"; + import * as http from "http"; + + export interface ServerOptions { + pfx?: any; + key?: any; + passphrase?: string; + cert?: any; + ca?: any; + crl?: any; + ciphers?: string; + honorCipherOrder?: boolean; + requestCert?: boolean; + rejectUnauthorized?: boolean; + NPNProtocols?: any; + SNICallback?: (servername: string) => any; + } + + export interface RequestOptions extends http.RequestOptions{ + pfx?: any; + key?: any; + passphrase?: string; + cert?: any; + ca?: any; + ciphers?: string; + rejectUnauthorized?: boolean; + secureProtocol?: string; + } + + export interface Agent { + maxSockets: number; + sockets: any; + requests: any; + } + export var Agent: { + new (options?: RequestOptions): Agent; + }; + export interface Server extends tls.Server { } + export function createServer(options: ServerOptions, requestListener?: Function): Server; + export function request(options: RequestOptions, callback?: (res: http.IncomingMessage) =>void ): http.ClientRequest; + export function get(options: RequestOptions, callback?: (res: http.IncomingMessage) =>void ): http.ClientRequest; + export var globalAgent: Agent; +} + +declare module "punycode" { + export function decode(string: string): string; + export function encode(string: string): string; + export function toUnicode(domain: string): string; + export function toASCII(domain: string): string; + export var ucs2: ucs2; + interface ucs2 { + decode(string: string): number[]; + encode(codePoints: number[]): string; + } + export var version: any; +} + +declare module "repl" { + import * as stream from "stream"; + import * as events from "events"; + + export interface ReplOptions { + prompt?: string; + input?: NodeJS.ReadableStream; + output?: NodeJS.WritableStream; + terminal?: boolean; + eval?: Function; + useColors?: boolean; + useGlobal?: boolean; + ignoreUndefined?: boolean; + writer?: Function; + } + export function start(options: ReplOptions): events.EventEmitter; +} + +declare module "readline" { + import * as events from "events"; + import * as stream from "stream"; + + export interface Key { + sequence?: string; + name?: string; + ctrl?: boolean; + meta?: boolean; + shift?: boolean; + } + + export interface ReadLine extends events.EventEmitter { + setPrompt(prompt: string): void; + prompt(preserveCursor?: boolean): void; + question(query: string, callback: (answer: string) => void): void; + pause(): ReadLine; + resume(): ReadLine; + close(): void; + write(data: string|Buffer, key?: Key): void; + } + + export interface Completer { + (line: string): CompleterResult; + (line: string, callback: (err: any, result: CompleterResult) => void): any; + } + + export interface CompleterResult { + completions: string[]; + line: string; + } + + export interface ReadLineOptions { + input: NodeJS.ReadableStream; + output?: NodeJS.WritableStream; + completer?: Completer; + terminal?: boolean; + historySize?: number; + } + + export function createInterface(input: NodeJS.ReadableStream, output?: NodeJS.WritableStream, completer?: Completer, terminal?: boolean): ReadLine; + export function createInterface(options: ReadLineOptions): ReadLine; + + export function cursorTo(stream: NodeJS.WritableStream, x: number, y: number): void; + export function moveCursor(stream: NodeJS.WritableStream, dx: number|string, dy: number|string): void; + export function clearLine(stream: NodeJS.WritableStream, dir: number): void; + export function clearScreenDown(stream: NodeJS.WritableStream): void; +} + +declare module "vm" { + export interface Context { } + export interface Script { + runInThisContext(): void; + runInNewContext(sandbox?: Context): void; + } + export function runInThisContext(code: string, filename?: string): void; + export function runInNewContext(code: string, sandbox?: Context, filename?: string): void; + export function runInContext(code: string, context: Context, filename?: string): void; + export function createContext(initSandbox?: Context): Context; + export function createScript(code: string, filename?: string): Script; +} + +declare module "child_process" { + import * as events from "events"; + import * as stream from "stream"; + + export interface ChildProcess extends events.EventEmitter { + stdin: stream.Writable; + stdout: stream.Readable; + stderr: stream.Readable; + stdio: (stream.Readable|stream.Writable)[]; + pid: number; + kill(signal?: string): void; + send(message: any, sendHandle?: any): void; + disconnect(): void; + unref(): void; + } + + export function spawn(command: string, args?: string[], options?: { + cwd?: string; + stdio?: any; + custom?: any; + env?: any; + detached?: boolean; + }): ChildProcess; + export function exec(command: string, options: { + cwd?: string; + stdio?: any; + customFds?: any; + env?: any; + encoding?: string; + timeout?: number; + maxBuffer?: number; + killSignal?: string; + }, callback?: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess; + export function exec(command: string, callback?: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess; + export function execFile(file: string, + callback?: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess; + export function execFile(file: string, args?: string[], + callback?: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess; + export function execFile(file: string, args?: string[], options?: { + cwd?: string; + stdio?: any; + customFds?: any; + env?: any; + encoding?: string; + timeout?: number; + maxBuffer?: number; + killSignal?: string; + }, callback?: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess; + export function fork(modulePath: string, args?: string[], options?: { + cwd?: string; + env?: any; + execPath?: string; + execArgv?: string[]; + silent?: boolean; + uid?: number; + gid?: number; + }): ChildProcess; + export function spawnSync(command: string, args?: string[], options?: { + cwd?: string; + input?: string | Buffer; + stdio?: any; + env?: any; + uid?: number; + gid?: number; + timeout?: number; + maxBuffer?: number; + killSignal?: string; + encoding?: string; + }): { + pid: number; + output: string[]; + stdout: string | Buffer; + stderr: string | Buffer; + status: number; + signal: string; + error: Error; + }; + export function execSync(command: string, options?: { + cwd?: string; + input?: string|Buffer; + stdio?: any; + env?: any; + uid?: number; + gid?: number; + timeout?: number; + maxBuffer?: number; + killSignal?: string; + encoding?: string; + }): string | Buffer; + export function execFileSync(command: string, args?: string[], options?: { + cwd?: string; + input?: string|Buffer; + stdio?: any; + env?: any; + uid?: number; + gid?: number; + timeout?: number; + maxBuffer?: number; + killSignal?: string; + encoding?: string; + }): string | Buffer; +} + +declare module "url" { + export interface Url { + href?: string; + protocol?: string; + auth?: string; + hostname?: string; + port?: string; + host?: string; + pathname?: string; + search?: string; + query?: any; // string | Object + slashes?: boolean; + hash?: string; + path?: string; + } + + export function parse(urlStr: string, parseQueryString?: boolean , slashesDenoteHost?: boolean ): Url; + export function format(url: Url): string; + export function resolve(from: string, to: string): string; +} + +declare module "dns" { + export function lookup(domain: string, family: number, callback: (err: Error, address: string, family: number) =>void ): string; + export function lookup(domain: string, callback: (err: Error, address: string, family: number) =>void ): string; + export function resolve(domain: string, rrtype: string, callback: (err: Error, addresses: string[]) =>void ): string[]; + export function resolve(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; + export function resolve4(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; + export function resolve6(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; + export function resolveMx(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; + export function resolveTxt(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; + export function resolveSrv(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; + export function resolveNs(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; + export function resolveCname(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; + export function reverse(ip: string, callback: (err: Error, domains: string[]) =>void ): string[]; +} + +declare module "net" { + import * as stream from "stream"; + + export interface Socket extends stream.Duplex { + // Extended base methods + write(buffer: Buffer): boolean; + write(buffer: Buffer, cb?: Function): boolean; + write(str: string, cb?: Function): boolean; + write(str: string, encoding?: string, cb?: Function): boolean; + write(str: string, encoding?: string, fd?: string): boolean; + + connect(port: number, host?: string, connectionListener?: Function): void; + connect(path: string, connectionListener?: Function): void; + bufferSize: number; + setEncoding(encoding?: string): void; + write(data: any, encoding?: string, callback?: Function): void; + destroy(): void; + pause(): void; + resume(): void; + setTimeout(timeout: number, callback?: Function): void; + setNoDelay(noDelay?: boolean): void; + setKeepAlive(enable?: boolean, initialDelay?: number): void; + address(): { port: number; family: string; address: string; }; + unref(): void; + ref(): void; + + remoteAddress: string; + remoteFamily: string; + remotePort: number; + localAddress: string; + localPort: number; + bytesRead: number; + bytesWritten: number; + + // Extended base methods + end(): void; + end(buffer: Buffer, cb?: Function): void; + end(str: string, cb?: Function): void; + end(str: string, encoding?: string, cb?: Function): void; + end(data?: any, encoding?: string): void; + } + + export var Socket: { + new (options?: { fd?: string; type?: string; allowHalfOpen?: boolean; }): Socket; + }; + + export interface Server extends Socket { + listen(port: number, host?: string, backlog?: number, listeningListener?: Function): Server; + listen(path: string, listeningListener?: Function): Server; + listen(handle: any, listeningListener?: Function): Server; + close(callback?: Function): Server; + address(): { port: number; family: string; address: string; }; + maxConnections: number; + connections: number; + } + export function createServer(connectionListener?: (socket: Socket) =>void ): Server; + export function createServer(options?: { allowHalfOpen?: boolean; }, connectionListener?: (socket: Socket) =>void ): Server; + export function connect(options: { port: number, host?: string, localAddress? : string, localPort? : string, family? : number, allowHalfOpen?: boolean; }, connectionListener?: Function): Socket; + export function connect(port: number, host?: string, connectionListener?: Function): Socket; + export function connect(path: string, connectionListener?: Function): Socket; + export function createConnection(options: { port: number, host?: string, localAddress? : string, localPort? : string, family? : number, allowHalfOpen?: boolean; }, connectionListener?: Function): Socket; + export function createConnection(port: number, host?: string, connectionListener?: Function): Socket; + export function createConnection(path: string, connectionListener?: Function): Socket; + export function isIP(input: string): number; + export function isIPv4(input: string): boolean; + export function isIPv6(input: string): boolean; +} + +declare module "dgram" { + import * as events from "events"; + + interface RemoteInfo { + address: string; + port: number; + size: number; + } + + interface AddressInfo { + address: string; + family: string; + port: number; + } + + export function createSocket(type: string, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket; + + interface Socket extends events.EventEmitter { + send(buf: Buffer, offset: number, length: number, port: number, address: string, callback?: (error: Error, bytes: number) => void): void; + bind(port: number, address?: string, callback?: () => void): void; + close(): void; + address(): AddressInfo; + setBroadcast(flag: boolean): void; + setMulticastTTL(ttl: number): void; + setMulticastLoopback(flag: boolean): void; + addMembership(multicastAddress: string, multicastInterface?: string): void; + dropMembership(multicastAddress: string, multicastInterface?: string): void; + } +} + +declare module "fs" { + import * as stream from "stream"; + import * as events from "events"; + + interface Stats { + isFile(): boolean; + isDirectory(): boolean; + isBlockDevice(): boolean; + isCharacterDevice(): boolean; + isSymbolicLink(): boolean; + isFIFO(): boolean; + isSocket(): boolean; + dev: number; + ino: number; + mode: number; + nlink: number; + uid: number; + gid: number; + rdev: number; + size: number; + blksize: number; + blocks: number; + atime: Date; + mtime: Date; + ctime: Date; + birthtime: Date; + } + + interface FSWatcher extends events.EventEmitter { + close(): void; + } + + export interface ReadStream extends stream.Readable { + close(): void; + } + export interface WriteStream extends stream.Writable { + close(): void; + bytesWritten: number; + } + + /** + * Asynchronous rename. + * @param oldPath + * @param newPath + * @param callback No arguments other than a possible exception are given to the completion callback. + */ + export function rename(oldPath: string, newPath: string, callback?: (err?: NodeJS.ErrnoException) => void): void; + /** + * Synchronous rename + * @param oldPath + * @param newPath + */ + export function renameSync(oldPath: string, newPath: string): void; + export function truncate(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function truncate(path: string, len: number, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function truncateSync(path: string, len?: number): void; + export function ftruncate(fd: number, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function ftruncate(fd: number, len: number, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function ftruncateSync(fd: number, len?: number): void; + export function chown(path: string, uid: number, gid: number, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function chownSync(path: string, uid: number, gid: number): void; + export function fchown(fd: number, uid: number, gid: number, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function fchownSync(fd: number, uid: number, gid: number): void; + export function lchown(path: string, uid: number, gid: number, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function lchownSync(path: string, uid: number, gid: number): void; + export function chmod(path: string, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function chmod(path: string, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function chmodSync(path: string, mode: number): void; + export function chmodSync(path: string, mode: string): void; + export function fchmod(fd: number, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function fchmod(fd: number, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function fchmodSync(fd: number, mode: number): void; + export function fchmodSync(fd: number, mode: string): void; + export function lchmod(path: string, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function lchmod(path: string, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function lchmodSync(path: string, mode: number): void; + export function lchmodSync(path: string, mode: string): void; + export function stat(path: string, callback?: (err: NodeJS.ErrnoException, stats: Stats) => any): void; + export function lstat(path: string, callback?: (err: NodeJS.ErrnoException, stats: Stats) => any): void; + export function fstat(fd: number, callback?: (err: NodeJS.ErrnoException, stats: Stats) => any): void; + export function statSync(path: string): Stats; + export function lstatSync(path: string): Stats; + export function fstatSync(fd: number): Stats; + export function link(srcpath: string, dstpath: string, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function linkSync(srcpath: string, dstpath: string): void; + export function symlink(srcpath: string, dstpath: string, type?: string, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function symlinkSync(srcpath: string, dstpath: string, type?: string): void; + export function readlink(path: string, callback?: (err: NodeJS.ErrnoException, linkString: string) => any): void; + export function readlinkSync(path: string): string; + export function realpath(path: string, callback?: (err: NodeJS.ErrnoException, resolvedPath: string) => any): void; + export function realpath(path: string, cache: {[path: string]: string}, callback: (err: NodeJS.ErrnoException, resolvedPath: string) =>any): void; + export function realpathSync(path: string, cache?: { [path: string]: string }): string; + /* + * Asynchronous unlink - deletes the file specified in {path} + * + * @param path + * @param callback No arguments other than a possible exception are given to the completion callback. + */ + export function unlink(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void; + /* + * Synchronous unlink - deletes the file specified in {path} + * + * @param path + */ + export function unlinkSync(path: string): void; + /* + * Asynchronous rmdir - removes the directory specified in {path} + * + * @param path + * @param callback No arguments other than a possible exception are given to the completion callback. + */ + export function rmdir(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void; + /* + * Synchronous rmdir - removes the directory specified in {path} + * + * @param path + */ + export function rmdirSync(path: string): void; + /* + * Asynchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777. + * + * @param path + * @param callback No arguments other than a possible exception are given to the completion callback. + */ + export function mkdir(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void; + /* + * Asynchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777. + * + * @param path + * @param mode + * @param callback No arguments other than a possible exception are given to the completion callback. + */ + export function mkdir(path: string, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void; + /* + * Asynchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777. + * + * @param path + * @param mode + * @param callback No arguments other than a possible exception are given to the completion callback. + */ + export function mkdir(path: string, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void; + /* + * Synchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777. + * + * @param path + * @param mode + * @param callback No arguments other than a possible exception are given to the completion callback. + */ + export function mkdirSync(path: string, mode?: number): void; + /* + * Synchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777. + * + * @param path + * @param mode + * @param callback No arguments other than a possible exception are given to the completion callback. + */ + export function mkdirSync(path: string, mode?: string): void; + export function readdir(path: string, callback?: (err: NodeJS.ErrnoException, files: string[]) => void): void; + export function readdirSync(path: string): string[]; + export function close(fd: number, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function closeSync(fd: number): void; + export function open(path: string, flags: string, callback?: (err: NodeJS.ErrnoException, fd: number) => any): void; + export function open(path: string, flags: string, mode: number, callback?: (err: NodeJS.ErrnoException, fd: number) => any): void; + export function open(path: string, flags: string, mode: string, callback?: (err: NodeJS.ErrnoException, fd: number) => any): void; + export function openSync(path: string, flags: string, mode?: number): number; + export function openSync(path: string, flags: string, mode?: string): number; + export function utimes(path: string, atime: number, mtime: number, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function utimes(path: string, atime: Date, mtime: Date, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function utimesSync(path: string, atime: number, mtime: number): void; + export function utimesSync(path: string, atime: Date, mtime: Date): void; + export function futimes(fd: number, atime: number, mtime: number, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function futimes(fd: number, atime: Date, mtime: Date, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function futimesSync(fd: number, atime: number, mtime: number): void; + export function futimesSync(fd: number, atime: Date, mtime: Date): void; + export function fsync(fd: number, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function fsyncSync(fd: number): void; + export function write(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: NodeJS.ErrnoException, written: number, buffer: Buffer) => void): void; + export function write(fd: number, buffer: Buffer, offset: number, length: number, callback?: (err: NodeJS.ErrnoException, written: number, buffer: Buffer) => void): void; + export function write(fd: number, data: any, callback?: (err: NodeJS.ErrnoException, written: number, str: string) => void): void; + export function write(fd: number, data: any, offset: number, callback?: (err: NodeJS.ErrnoException, written: number, str: string) => void): void; + export function write(fd: number, data: any, offset: number, encoding: string, callback?: (err: NodeJS.ErrnoException, written: number, str: string) => void): void; + export function writeSync(fd: number, buffer: Buffer, offset: number, length: number, position: number): number; + export function read(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: NodeJS.ErrnoException, bytesRead: number, buffer: Buffer) => void): void; + export function readSync(fd: number, buffer: Buffer, offset: number, length: number, position: number): number; + /* + * Asynchronous readFile - Asynchronously reads the entire contents of a file. + * + * @param fileName + * @param encoding + * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file. + */ + export function readFile(filename: string, encoding: string, callback: (err: NodeJS.ErrnoException, data: string) => void): void; + /* + * Asynchronous readFile - Asynchronously reads the entire contents of a file. + * + * @param fileName + * @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFile returns a string; otherwise it returns a Buffer. + * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file. + */ + export function readFile(filename: string, options: { encoding: string; flag?: string; }, callback: (err: NodeJS.ErrnoException, data: string) => void): void; + /* + * Asynchronous readFile - Asynchronously reads the entire contents of a file. + * + * @param fileName + * @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFile returns a string; otherwise it returns a Buffer. + * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file. + */ + export function readFile(filename: string, options: { flag?: string; }, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void; + /* + * Asynchronous readFile - Asynchronously reads the entire contents of a file. + * + * @param fileName + * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file. + */ + export function readFile(filename: string, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void; + /* + * Synchronous readFile - Synchronously reads the entire contents of a file. + * + * @param fileName + * @param encoding + */ + export function readFileSync(filename: string, encoding: string): string; + /* + * Synchronous readFile - Synchronously reads the entire contents of a file. + * + * @param fileName + * @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFileSync returns a string; otherwise it returns a Buffer. + */ + export function readFileSync(filename: string, options: { encoding: string; flag?: string; }): string; + /* + * Synchronous readFile - Synchronously reads the entire contents of a file. + * + * @param fileName + * @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFileSync returns a string; otherwise it returns a Buffer. + */ + export function readFileSync(filename: string, options?: { flag?: string; }): Buffer; + export function writeFile(filename: string, data: any, callback?: (err: NodeJS.ErrnoException) => void): void; + export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; + export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; + export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void; + export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: string; flag?: string; }): void; + export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; + export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; + export function appendFile(filename: string, data: any, callback?: (err: NodeJS.ErrnoException) => void): void; + export function appendFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void; + export function appendFileSync(filename: string, data: any, options?: { encoding?: string; mode?: string; flag?: string; }): void; + export function watchFile(filename: string, listener: (curr: Stats, prev: Stats) => void): void; + export function watchFile(filename: string, options: { persistent?: boolean; interval?: number; }, listener: (curr: Stats, prev: Stats) => void): void; + export function unwatchFile(filename: string, listener?: (curr: Stats, prev: Stats) => void): void; + export function watch(filename: string, listener?: (event: string, filename: string) => any): FSWatcher; + export function watch(filename: string, options: { persistent?: boolean; }, listener?: (event: string, filename: string) => any): FSWatcher; + export function exists(path: string, callback?: (exists: boolean) => void): void; + export function existsSync(path: string): boolean; + /** Constant for fs.access(). File is visible to the calling process. */ + export var F_OK: number; + /** Constant for fs.access(). File can be read by the calling process. */ + export var R_OK: number; + /** Constant for fs.access(). File can be written by the calling process. */ + export var W_OK: number; + /** Constant for fs.access(). File can be executed by the calling process. */ + export var X_OK: number; + /** Tests a user's permissions for the file specified by path. */ + export function access(path: string, callback: (err: NodeJS.ErrnoException) => void): void; + export function access(path: string, mode: number, callback: (err: NodeJS.ErrnoException) => void): void; + /** Synchronous version of fs.access. This throws if any accessibility checks fail, and does nothing otherwise. */ + export function accessSync(path: string, mode ?: number): void; + export function createReadStream(path: string, options?: { + flags?: string; + encoding?: string; + fd?: number; + mode?: number; + autoClose?: boolean; + }): ReadStream; + export function createWriteStream(path: string, options?: { + flags?: string; + encoding?: string; + fd?: number; + mode?: number; + }): WriteStream; +} + +declare module "path" { + + /** + * A parsed path object generated by path.parse() or consumed by path.format(). + */ + export interface ParsedPath { + /** + * The root of the path such as '/' or 'c:\' + */ + root: string; + /** + * The full directory path such as '/home/user/dir' or 'c:\path\dir' + */ + dir: string; + /** + * The file name including extension (if any) such as 'index.html' + */ + base: string; + /** + * The file extension (if any) such as '.html' + */ + ext: string; + /** + * The file name without extension (if any) such as 'index' + */ + name: string; + } + + /** + * Normalize a string path, reducing '..' and '.' parts. + * When multiple slashes are found, they're replaced by a single one; when the path contains a trailing slash, it is preserved. On Windows backslashes are used. + * + * @param p string path to normalize. + */ + export function normalize(p: string): string; + /** + * Join all arguments together and normalize the resulting path. + * Arguments must be strings. In v0.8, non-string arguments were silently ignored. In v0.10 and up, an exception is thrown. + * + * @param paths string paths to join. + */ + export function join(...paths: any[]): string; + /** + * Join all arguments together and normalize the resulting path. + * Arguments must be strings. In v0.8, non-string arguments were silently ignored. In v0.10 and up, an exception is thrown. + * + * @param paths string paths to join. + */ + export function join(...paths: string[]): string; + /** + * The right-most parameter is considered {to}. Other parameters are considered an array of {from}. + * + * Starting from leftmost {from} paramter, resolves {to} to an absolute path. + * + * If {to} isn't already absolute, {from} arguments are prepended in right to left order, until an absolute path is found. If after using all {from} paths still no absolute path is found, the current working directory is used as well. The resulting path is normalized, and trailing slashes are removed unless the path gets resolved to the root directory. + * + * @param pathSegments string paths to join. Non-string arguments are ignored. + */ + export function resolve(...pathSegments: any[]): string; + /** + * Determines whether {path} is an absolute path. An absolute path will always resolve to the same location, regardless of the working directory. + * + * @param path path to test. + */ + export function isAbsolute(path: string): boolean; + /** + * Solve the relative path from {from} to {to}. + * At times we have two absolute paths, and we need to derive the relative path from one to the other. This is actually the reverse transform of path.resolve. + * + * @param from + * @param to + */ + export function relative(from: string, to: string): string; + /** + * Return the directory name of a path. Similar to the Unix dirname command. + * + * @param p the path to evaluate. + */ + export function dirname(p: string): string; + /** + * Return the last portion of a path. Similar to the Unix basename command. + * Often used to extract the file name from a fully qualified path. + * + * @param p the path to evaluate. + * @param ext optionally, an extension to remove from the result. + */ + export function basename(p: string, ext?: string): string; + /** + * Return the extension of the path, from the last '.' to end of string in the last portion of the path. + * If there is no '.' in the last portion of the path or the first character of it is '.', then it returns an empty string + * + * @param p the path to evaluate. + */ + export function extname(p: string): string; + /** + * The platform-specific file separator. '\\' or '/'. + */ + export var sep: string; + /** + * The platform-specific file delimiter. ';' or ':'. + */ + export var delimiter: string; + /** + * Returns an object from a path string - the opposite of format(). + * + * @param pathString path to evaluate. + */ + export function parse(pathString: string): ParsedPath; + /** + * Returns a path string from an object - the opposite of parse(). + * + * @param pathString path to evaluate. + */ + export function format(pathObject: ParsedPath): string; + + export module posix { + export function normalize(p: string): string; + export function join(...paths: any[]): string; + export function resolve(...pathSegments: any[]): string; + export function isAbsolute(p: string): boolean; + export function relative(from: string, to: string): string; + export function dirname(p: string): string; + export function basename(p: string, ext?: string): string; + export function extname(p: string): string; + export var sep: string; + export var delimiter: string; + export function parse(p: string): ParsedPath; + export function format(pP: ParsedPath): string; + } + + export module win32 { + export function normalize(p: string): string; + export function join(...paths: any[]): string; + export function resolve(...pathSegments: any[]): string; + export function isAbsolute(p: string): boolean; + export function relative(from: string, to: string): string; + export function dirname(p: string): string; + export function basename(p: string, ext?: string): string; + export function extname(p: string): string; + export var sep: string; + export var delimiter: string; + export function parse(p: string): ParsedPath; + export function format(pP: ParsedPath): string; + } +} + +declare module "string_decoder" { + export interface NodeStringDecoder { + write(buffer: Buffer): string; + detectIncompleteChar(buffer: Buffer): number; + } + export var StringDecoder: { + new (encoding: string): NodeStringDecoder; + }; +} + +declare module "tls" { + import * as crypto from "crypto"; + import * as net from "net"; + import * as stream from "stream"; + + var CLIENT_RENEG_LIMIT: number; + var CLIENT_RENEG_WINDOW: number; + + export interface TlsOptions { + host?: string; + port?: number; + pfx?: any; //string or buffer + key?: any; //string or buffer + passphrase?: string; + cert?: any; + ca?: any; //string or buffer + crl?: any; //string or string array + ciphers?: string; + honorCipherOrder?: any; + requestCert?: boolean; + rejectUnauthorized?: boolean; + NPNProtocols?: any; //array or Buffer; + SNICallback?: (servername: string) => any; + } + + export interface ConnectionOptions { + host?: string; + port?: number; + socket?: net.Socket; + pfx?: any; //string | Buffer + key?: any; //string | Buffer + passphrase?: string; + cert?: any; //string | Buffer + ca?: any; //Array of string | Buffer + rejectUnauthorized?: boolean; + NPNProtocols?: any; //Array of string | Buffer + servername?: string; + } + + export interface Server extends net.Server { + // Extended base methods + listen(port: number, host?: string, backlog?: number, listeningListener?: Function): Server; + listen(path: string, listeningListener?: Function): Server; + listen(handle: any, listeningListener?: Function): Server; + + listen(port: number, host?: string, callback?: Function): Server; + close(): Server; + address(): { port: number; family: string; address: string; }; + addContext(hostName: string, credentials: { + key: string; + cert: string; + ca: string; + }): void; + maxConnections: number; + connections: number; + } + + export interface ClearTextStream extends stream.Duplex { + authorized: boolean; + authorizationError: Error; + getPeerCertificate(): any; + getCipher: { + name: string; + version: string; + }; + address: { + port: number; + family: string; + address: string; + }; + remoteAddress: string; + remotePort: number; + } + + export interface SecurePair { + encrypted: any; + cleartext: any; + } + + export interface SecureContextOptions { + pfx?: any; //string | buffer + key?: any; //string | buffer + passphrase?: string; + cert?: any; // string | buffer + ca?: any; // string | buffer + crl?: any; // string | string[] + ciphers?: string; + honorCipherOrder?: boolean; + } + + export interface SecureContext { + context: any; + } + + export function createServer(options: TlsOptions, secureConnectionListener?: (cleartextStream: ClearTextStream) =>void ): Server; + export function connect(options: TlsOptions, secureConnectionListener?: () =>void ): ClearTextStream; + export function connect(port: number, host?: string, options?: ConnectionOptions, secureConnectListener?: () =>void ): ClearTextStream; + export function connect(port: number, options?: ConnectionOptions, secureConnectListener?: () =>void ): ClearTextStream; + export function createSecurePair(credentials?: crypto.Credentials, isServer?: boolean, requestCert?: boolean, rejectUnauthorized?: boolean): SecurePair; + export function createSecureContext(details: SecureContextOptions): SecureContext; +} + +declare module "crypto" { + export interface CredentialDetails { + pfx: string; + key: string; + passphrase: string; + cert: string; + ca: any; //string | string array + crl: any; //string | string array + ciphers: string; + } + export interface Credentials { context?: any; } + export function createCredentials(details: CredentialDetails): Credentials; + export function createHash(algorithm: string): Hash; + export function createHmac(algorithm: string, key: string): Hmac; + export function createHmac(algorithm: string, key: Buffer): Hmac; + export interface Hash { + update(data: any, input_encoding?: string): Hash; + digest(encoding: 'buffer'): Buffer; + digest(encoding: string): any; + digest(): Buffer; + } + export interface Hmac extends NodeJS.ReadWriteStream { + update(data: any, input_encoding?: string): Hmac; + digest(encoding: 'buffer'): Buffer; + digest(encoding: string): any; + digest(): Buffer; + } + export function createCipher(algorithm: string, password: any): Cipher; + export function createCipheriv(algorithm: string, key: any, iv: any): Cipher; + export interface Cipher { + update(data: Buffer): Buffer; + update(data: string, input_encoding?: string, output_encoding?: string): string; + final(): Buffer; + final(output_encoding: string): string; + setAutoPadding(auto_padding: boolean): void; + } + export function createDecipher(algorithm: string, password: any): Decipher; + export function createDecipheriv(algorithm: string, key: any, iv: any): Decipher; + export interface Decipher { + update(data: Buffer): Buffer; + update(data: string, input_encoding?: string, output_encoding?: string): string; + final(): Buffer; + final(output_encoding: string): string; + setAutoPadding(auto_padding: boolean): void; + } + export function createSign(algorithm: string): Signer; + export interface Signer extends NodeJS.WritableStream { + update(data: any): void; + sign(private_key: string, output_format: string): string; + } + export function createVerify(algorith: string): Verify; + export interface Verify extends NodeJS.WritableStream { + update(data: any): void; + verify(object: string, signature: string, signature_format?: string): boolean; + } + export function createDiffieHellman(prime_length: number): DiffieHellman; + export function createDiffieHellman(prime: number, encoding?: string): DiffieHellman; + export interface DiffieHellman { + generateKeys(encoding?: string): string; + computeSecret(other_public_key: string, input_encoding?: string, output_encoding?: string): string; + getPrime(encoding?: string): string; + getGenerator(encoding: string): string; + getPublicKey(encoding?: string): string; + getPrivateKey(encoding?: string): string; + setPublicKey(public_key: string, encoding?: string): void; + setPrivateKey(public_key: string, encoding?: string): void; + } + export function getDiffieHellman(group_name: string): DiffieHellman; + export function pbkdf2(password: string|Buffer, salt: string|Buffer, iterations: number, keylen: number, callback: (err: Error, derivedKey: Buffer) => any): void; + export function pbkdf2(password: string|Buffer, salt: string|Buffer, iterations: number, keylen: number, digest: string, callback: (err: Error, derivedKey: Buffer) => any): void; + export function pbkdf2Sync(password: string|Buffer, salt: string|Buffer, iterations: number, keylen: number) : Buffer; + export function pbkdf2Sync(password: string|Buffer, salt: string|Buffer, iterations: number, keylen: number, digest: string) : Buffer; + export function randomBytes(size: number): Buffer; + export function randomBytes(size: number, callback: (err: Error, buf: Buffer) =>void ): void; + export function pseudoRandomBytes(size: number): Buffer; + export function pseudoRandomBytes(size: number, callback: (err: Error, buf: Buffer) =>void ): void; + export interface RsaPublicKey { + key: string; + padding?: any; + } + export interface RsaPrivateKey { + key: string; + passphrase?: string, + padding?: any; + } + export function publicEncrypt(public_key: string|RsaPublicKey, buffer: Buffer): Buffer + export function privateDecrypt(private_key: string|RsaPrivateKey, buffer: Buffer): Buffer +} + +declare module "stream" { + import * as events from "events"; + + export class Stream extends events.EventEmitter { + pipe(destination: T, options?: { end?: boolean; }): T; + } + + export interface ReadableOptions { + highWaterMark?: number; + encoding?: string; + objectMode?: boolean; + } + + export class Readable extends events.EventEmitter implements NodeJS.ReadableStream { + readable: boolean; + constructor(opts?: ReadableOptions); + _read(size: number): void; + read(size?: number): any; + setEncoding(encoding: string): void; + pause(): void; + resume(): void; + pipe(destination: T, options?: { end?: boolean; }): T; + unpipe(destination?: T): void; + unshift(chunk: any): void; + wrap(oldStream: NodeJS.ReadableStream): NodeJS.ReadableStream; + push(chunk: any, encoding?: string): boolean; + } + + export interface WritableOptions { + highWaterMark?: number; + decodeStrings?: boolean; + objectMode?: boolean; + } + + export class Writable extends events.EventEmitter implements NodeJS.WritableStream { + writable: boolean; + constructor(opts?: WritableOptions); + _write(chunk: any, encoding: string, callback: Function): void; + write(chunk: any, cb?: Function): boolean; + write(chunk: any, encoding?: string, cb?: Function): boolean; + end(): void; + end(chunk: any, cb?: Function): void; + end(chunk: any, encoding?: string, cb?: Function): void; + } + + export interface DuplexOptions extends ReadableOptions, WritableOptions { + allowHalfOpen?: boolean; + } + + // Note: Duplex extends both Readable and Writable. + export class Duplex extends Readable implements NodeJS.ReadWriteStream { + writable: boolean; + constructor(opts?: DuplexOptions); + _write(chunk: any, encoding: string, callback: Function): void; + write(chunk: any, cb?: Function): boolean; + write(chunk: any, encoding?: string, cb?: Function): boolean; + end(): void; + end(chunk: any, cb?: Function): void; + end(chunk: any, encoding?: string, cb?: Function): void; + } + + export interface TransformOptions extends ReadableOptions, WritableOptions {} + + // Note: Transform lacks the _read and _write methods of Readable/Writable. + export class Transform extends events.EventEmitter implements NodeJS.ReadWriteStream { + readable: boolean; + writable: boolean; + constructor(opts?: TransformOptions); + _transform(chunk: any, encoding: string, callback: Function): void; + _flush(callback: Function): void; + read(size?: number): any; + setEncoding(encoding: string): void; + pause(): void; + resume(): void; + pipe(destination: T, options?: { end?: boolean; }): T; + unpipe(destination?: T): void; + unshift(chunk: any): void; + wrap(oldStream: NodeJS.ReadableStream): NodeJS.ReadableStream; + push(chunk: any, encoding?: string): boolean; + write(chunk: any, cb?: Function): boolean; + write(chunk: any, encoding?: string, cb?: Function): boolean; + end(): void; + end(chunk: any, cb?: Function): void; + end(chunk: any, encoding?: string, cb?: Function): void; + } + + export class PassThrough extends Transform {} +} + +declare module "util" { + export interface InspectOptions { + showHidden?: boolean; + depth?: number; + colors?: boolean; + customInspect?: boolean; + } + + export function format(format: any, ...param: any[]): string; + export function debug(string: string): void; + export function error(...param: any[]): void; + export function puts(...param: any[]): void; + export function print(...param: any[]): void; + export function log(string: string): void; + export function inspect(object: any, showHidden?: boolean, depth?: number, color?: boolean): string; + export function inspect(object: any, options: InspectOptions): string; + export function isArray(object: any): boolean; + export function isRegExp(object: any): boolean; + export function isDate(object: any): boolean; + export function isError(object: any): boolean; + export function inherits(constructor: any, superConstructor: any): void; + export function debuglog(key:string): (msg:string,...param: any[])=>void; +} + +declare module "assert" { + function internal (value: any, message?: string): void; + module internal { + export class AssertionError implements Error { + name: string; + message: string; + actual: any; + expected: any; + operator: string; + generatedMessage: boolean; + + constructor(options?: {message?: string; actual?: any; expected?: any; + operator?: string; stackStartFunction?: Function}); + } + + export function fail(actual?: any, expected?: any, message?: string, operator?: string): void; + export function ok(value: any, message?: string): void; + export function equal(actual: any, expected: any, message?: string): void; + export function notEqual(actual: any, expected: any, message?: string): void; + export function deepEqual(actual: any, expected: any, message?: string): void; + export function notDeepEqual(acutal: any, expected: any, message?: string): void; + export function strictEqual(actual: any, expected: any, message?: string): void; + export function notStrictEqual(actual: any, expected: any, message?: string): void; + export function deepStrictEqual(actual: any, expected: any, message?: string): void; + export function notDeepStrictEqual(actual: any, expected: any, message?: string): void; + export var throws: { + (block: Function, message?: string): void; + (block: Function, error: Function, message?: string): void; + (block: Function, error: RegExp, message?: string): void; + (block: Function, error: (err: any) => boolean, message?: string): void; + }; + + export var doesNotThrow: { + (block: Function, message?: string): void; + (block: Function, error: Function, message?: string): void; + (block: Function, error: RegExp, message?: string): void; + (block: Function, error: (err: any) => boolean, message?: string): void; + }; + + export function ifError(value: any): void; + } + + export = internal; +} + +declare module "tty" { + import * as net from "net"; + + export function isatty(fd: number): boolean; + export interface ReadStream extends net.Socket { + isRaw: boolean; + setRawMode(mode: boolean): void; + isTTY: boolean; + } + export interface WriteStream extends net.Socket { + columns: number; + rows: number; + isTTY: boolean; + } +} + +declare module "domain" { + import * as events from "events"; + + export class Domain extends events.EventEmitter { + run(fn: Function): void; + add(emitter: events.EventEmitter): void; + remove(emitter: events.EventEmitter): void; + bind(cb: (err: Error, data: any) => any): any; + intercept(cb: (data: any) => any): any; + dispose(): void; + + addListener(event: string, listener: Function): Domain; + on(event: string, listener: Function): Domain; + once(event: string, listener: Function): Domain; + removeListener(event: string, listener: Function): Domain; + removeAllListeners(event?: string): Domain; + } + + export function create(): Domain; +} + +declare module "constants" { + export var E2BIG: number; + export var EACCES: number; + export var EADDRINUSE: number; + export var EADDRNOTAVAIL: number; + export var EAFNOSUPPORT: number; + export var EAGAIN: number; + export var EALREADY: number; + export var EBADF: number; + export var EBADMSG: number; + export var EBUSY: number; + export var ECANCELED: number; + export var ECHILD: number; + export var ECONNABORTED: number; + export var ECONNREFUSED: number; + export var ECONNRESET: number; + export var EDEADLK: number; + export var EDESTADDRREQ: number; + export var EDOM: number; + export var EEXIST: number; + export var EFAULT: number; + export var EFBIG: number; + export var EHOSTUNREACH: number; + export var EIDRM: number; + export var EILSEQ: number; + export var EINPROGRESS: number; + export var EINTR: number; + export var EINVAL: number; + export var EIO: number; + export var EISCONN: number; + export var EISDIR: number; + export var ELOOP: number; + export var EMFILE: number; + export var EMLINK: number; + export var EMSGSIZE: number; + export var ENAMETOOLONG: number; + export var ENETDOWN: number; + export var ENETRESET: number; + export var ENETUNREACH: number; + export var ENFILE: number; + export var ENOBUFS: number; + export var ENODATA: number; + export var ENODEV: number; + export var ENOENT: number; + export var ENOEXEC: number; + export var ENOLCK: number; + export var ENOLINK: number; + export var ENOMEM: number; + export var ENOMSG: number; + export var ENOPROTOOPT: number; + export var ENOSPC: number; + export var ENOSR: number; + export var ENOSTR: number; + export var ENOSYS: number; + export var ENOTCONN: number; + export var ENOTDIR: number; + export var ENOTEMPTY: number; + export var ENOTSOCK: number; + export var ENOTSUP: number; + export var ENOTTY: number; + export var ENXIO: number; + export var EOPNOTSUPP: number; + export var EOVERFLOW: number; + export var EPERM: number; + export var EPIPE: number; + export var EPROTO: number; + export var EPROTONOSUPPORT: number; + export var EPROTOTYPE: number; + export var ERANGE: number; + export var EROFS: number; + export var ESPIPE: number; + export var ESRCH: number; + export var ETIME: number; + export var ETIMEDOUT: number; + export var ETXTBSY: number; + export var EWOULDBLOCK: number; + export var EXDEV: number; + export var WSAEINTR: number; + export var WSAEBADF: number; + export var WSAEACCES: number; + export var WSAEFAULT: number; + export var WSAEINVAL: number; + export var WSAEMFILE: number; + export var WSAEWOULDBLOCK: number; + export var WSAEINPROGRESS: number; + export var WSAEALREADY: number; + export var WSAENOTSOCK: number; + export var WSAEDESTADDRREQ: number; + export var WSAEMSGSIZE: number; + export var WSAEPROTOTYPE: number; + export var WSAENOPROTOOPT: number; + export var WSAEPROTONOSUPPORT: number; + export var WSAESOCKTNOSUPPORT: number; + export var WSAEOPNOTSUPP: number; + export var WSAEPFNOSUPPORT: number; + export var WSAEAFNOSUPPORT: number; + export var WSAEADDRINUSE: number; + export var WSAEADDRNOTAVAIL: number; + export var WSAENETDOWN: number; + export var WSAENETUNREACH: number; + export var WSAENETRESET: number; + export var WSAECONNABORTED: number; + export var WSAECONNRESET: number; + export var WSAENOBUFS: number; + export var WSAEISCONN: number; + export var WSAENOTCONN: number; + export var WSAESHUTDOWN: number; + export var WSAETOOMANYREFS: number; + export var WSAETIMEDOUT: number; + export var WSAECONNREFUSED: number; + export var WSAELOOP: number; + export var WSAENAMETOOLONG: number; + export var WSAEHOSTDOWN: number; + export var WSAEHOSTUNREACH: number; + export var WSAENOTEMPTY: number; + export var WSAEPROCLIM: number; + export var WSAEUSERS: number; + export var WSAEDQUOT: number; + export var WSAESTALE: number; + export var WSAEREMOTE: number; + export var WSASYSNOTREADY: number; + export var WSAVERNOTSUPPORTED: number; + export var WSANOTINITIALISED: number; + export var WSAEDISCON: number; + export var WSAENOMORE: number; + export var WSAECANCELLED: number; + export var WSAEINVALIDPROCTABLE: number; + export var WSAEINVALIDPROVIDER: number; + export var WSAEPROVIDERFAILEDINIT: number; + export var WSASYSCALLFAILURE: number; + export var WSASERVICE_NOT_FOUND: number; + export var WSATYPE_NOT_FOUND: number; + export var WSA_E_NO_MORE: number; + export var WSA_E_CANCELLED: number; + export var WSAEREFUSED: number; + export var SIGHUP: number; + export var SIGINT: number; + export var SIGILL: number; + export var SIGABRT: number; + export var SIGFPE: number; + export var SIGKILL: number; + export var SIGSEGV: number; + export var SIGTERM: number; + export var SIGBREAK: number; + export var SIGWINCH: number; + export var SSL_OP_ALL: number; + export var SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION: number; + export var SSL_OP_CIPHER_SERVER_PREFERENCE: number; + export var SSL_OP_CISCO_ANYCONNECT: number; + export var SSL_OP_COOKIE_EXCHANGE: number; + export var SSL_OP_CRYPTOPRO_TLSEXT_BUG: number; + export var SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS: number; + export var SSL_OP_EPHEMERAL_RSA: number; + export var SSL_OP_LEGACY_SERVER_CONNECT: number; + export var SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER: number; + export var SSL_OP_MICROSOFT_SESS_ID_BUG: number; + export var SSL_OP_MSIE_SSLV2_RSA_PADDING: number; + export var SSL_OP_NETSCAPE_CA_DN_BUG: number; + export var SSL_OP_NETSCAPE_CHALLENGE_BUG: number; + export var SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG: number; + export var SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG: number; + export var SSL_OP_NO_COMPRESSION: number; + export var SSL_OP_NO_QUERY_MTU: number; + export var SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION: number; + export var SSL_OP_NO_SSLv2: number; + export var SSL_OP_NO_SSLv3: number; + export var SSL_OP_NO_TICKET: number; + export var SSL_OP_NO_TLSv1: number; + export var SSL_OP_NO_TLSv1_1: number; + export var SSL_OP_NO_TLSv1_2: number; + export var SSL_OP_PKCS1_CHECK_1: number; + export var SSL_OP_PKCS1_CHECK_2: number; + export var SSL_OP_SINGLE_DH_USE: number; + export var SSL_OP_SINGLE_ECDH_USE: number; + export var SSL_OP_SSLEAY_080_CLIENT_DH_BUG: number; + export var SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG: number; + export var SSL_OP_TLS_BLOCK_PADDING_BUG: number; + export var SSL_OP_TLS_D5_BUG: number; + export var SSL_OP_TLS_ROLLBACK_BUG: number; + export var ENGINE_METHOD_DSA: number; + export var ENGINE_METHOD_DH: number; + export var ENGINE_METHOD_RAND: number; + export var ENGINE_METHOD_ECDH: number; + export var ENGINE_METHOD_ECDSA: number; + export var ENGINE_METHOD_CIPHERS: number; + export var ENGINE_METHOD_DIGESTS: number; + export var ENGINE_METHOD_STORE: number; + export var ENGINE_METHOD_PKEY_METHS: number; + export var ENGINE_METHOD_PKEY_ASN1_METHS: number; + export var ENGINE_METHOD_ALL: number; + export var ENGINE_METHOD_NONE: number; + export var DH_CHECK_P_NOT_SAFE_PRIME: number; + export var DH_CHECK_P_NOT_PRIME: number; + export var DH_UNABLE_TO_CHECK_GENERATOR: number; + export var DH_NOT_SUITABLE_GENERATOR: number; + export var NPN_ENABLED: number; + export var RSA_PKCS1_PADDING: number; + export var RSA_SSLV23_PADDING: number; + export var RSA_NO_PADDING: number; + export var RSA_PKCS1_OAEP_PADDING: number; + export var RSA_X931_PADDING: number; + export var RSA_PKCS1_PSS_PADDING: number; + export var POINT_CONVERSION_COMPRESSED: number; + export var POINT_CONVERSION_UNCOMPRESSED: number; + export var POINT_CONVERSION_HYBRID: number; + export var O_RDONLY: number; + export var O_WRONLY: number; + export var O_RDWR: number; + export var S_IFMT: number; + export var S_IFREG: number; + export var S_IFDIR: number; + export var S_IFCHR: number; + export var S_IFLNK: number; + export var O_CREAT: number; + export var O_EXCL: number; + export var O_TRUNC: number; + export var O_APPEND: number; + export var F_OK: number; + export var R_OK: number; + export var W_OK: number; + export var X_OK: number; + export var UV_UDP_REUSEADDR: number; +} diff --git a/definitions/tns-core-modules/LICENSE b/definitions/tns-core-modules/LICENSE new file mode 100644 index 0000000..49e2a9f --- /dev/null +++ b/definitions/tns-core-modules/LICENSE @@ -0,0 +1,13 @@ + Copyright (c) 2015 Telerik AD + + 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 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/definitions/tns-core-modules/application-settings/application-settings.d.ts b/definitions/tns-core-modules/application-settings/application-settings.d.ts new file mode 100644 index 0000000..e1b42d6 --- /dev/null +++ b/definitions/tns-core-modules/application-settings/application-settings.d.ts @@ -0,0 +1,58 @@ +/** + * Allows you to save and restore any kind of information related to your application. + */ +declare module "application-settings" { + /** + * Checks whether such a key exists. + * @param key The key to check for. + */ + export function hasKey(key: string): boolean; + + /** + * Gets a value (if existing) for a key as a Boolean Object. A default value can be provided in case there is no existing value. + * @param key The key to check for. + * @param defaultValue An optional value to be returned in case there is no existing value. + */ + export function getBoolean(key: string, defaultValue?: boolean): boolean; + + /** + * Gets a value (if existing) for a key as a String Object. A default value can be provided in case there is no existing value. + * @param key The key to check for. + * @param defaultValue An optional value to be returned in case there is no existing value. + */ + export function getString(key: string, defaultValue?: string): string; + + /** + * Gets a value (if existing) for a key as a Number Object. A default value can be provided in case there is no existing value. + * @param key The key to check for. + * @param defaultValue An optional value to be returned in case there is no existing value. + */ + export function getNumber(key: string, defaultValue?: number): number; + + /** + * Sets a Boolean Object for a key. + * @param key The key. + * @param value The value. + */ + export function setBoolean(key: string, value: boolean): void; + + /** + * Sets a String Object for a key. + * @param key The key. + * @param value The value. + */ + export function setString(key: string, value: string): void; + + /** + * Sets a Number Object for a key. + * @param key The key. + * @param value The value. + */ + export function setNumber(key: string, value: number): void; + + /** + * Removes a value (if existing) for a key. + * @param key The key to check for. + */ + export function remove(key: string): void; +} \ No newline at end of file diff --git a/definitions/tns-core-modules/application/application.d.ts b/definitions/tns-core-modules/application/application.d.ts new file mode 100644 index 0000000..157b135 --- /dev/null +++ b/definitions/tns-core-modules/application/application.d.ts @@ -0,0 +1,549 @@ +/** + * Contains the application abstraction with all related methods. + */ +declare module "application" { + import cssSelector = require("ui/styling/css-selector"); + import observable = require("data/observable"); + import frame = require("ui/frame"); + import {View} from "ui/core/view"; + /** + * An extended JavaScript Error which will have the nativeError property initialized in case the error is caused by executing platform-specific code. + */ + export interface NativeScriptError extends Error { + /** + * Represents the native error object. + */ + nativeError: any; + } + + /** + * String value used when hooking to launch event. + */ + export var launchEvent: string; + + /** + * String value used when hooking to uncaughtError event. + */ + export var uncaughtErrorEvent: string; + + /** + * String value used when hooking to suspend event. + */ + export var suspendEvent: string; + + /** + * String value used when hooking to resume event. + */ + export var resumeEvent: string; + + /** + * String value used when hooking to exitevent. + */ + export var exitEvent: string; + + /** + * String value used when hooking to lowMemory event. + */ + export var lowMemoryEvent: string; + + /** + * String value used when hooking to orientationChanged event. + */ + export var orientationChangedEvent: string; + + /** + * Event data containing information for the application events. + */ + export interface ApplicationEventData { + /** + * Gets the native iOS event arguments. Valid only when running on iOS. + */ + ios?: any; + + /** + * Gets the native Android event arguments. Valid only when running on Android. + */ + android?: any; + + /** + * The name of the event. + */ + eventName: string; + + /** + * The instance that has raised the event. + */ + object: any; + } + + /** + * Event data containing information for launch event. + */ + export interface LaunchEventData extends ApplicationEventData { + /** + * The root view for this Window on iOS or Activity for Android. + * If not set a new Frame will be created as a root view in order to maintain backwards compatibility. + */ + root?: View; + } + + /** + * Event data containing information for orientation changed event. + */ + export interface OrientationChangedEventData extends ApplicationEventData { + /** + * New orientation value. + */ + newValue: string; + } + + /** + * The main page path (without the file extension) for the application starting from the application root. + * For example if you have page called "main.js" in a folder called "subFolder" and your root folder is "app" you can specify mainModule like this: + * var application = require("application"); + * application.mainModule = "app/subFolder/main"; + * application.start(); + */ + export var mainModule: string; + + /** + * The main navigation entry to be used when loading the main Page. + */ + export var mainEntry: frame.NavigationEntry; + + /** + * An application level static resources. + */ + export var resources: any; + + /** + * The application level css file name (starting from the application root). Used to set css across all pages. + * Css will be applied for every page and page css will be applied after. + */ + export var cssFile: string; + + /** + * Cached css selectors created from the content of the css file. + */ + export var cssSelectorsCache: Array; + + /** + * Loads css file and parses to a css syntax tree. + * @param cssFile Optional parameter to point to an arbitrary css file. If not specified, the cssFile property is used. + */ + export function loadCss(cssFile?: string): Array; + + /** + * Call this method to start the application. Important: All code after this method call will not be executed! + */ + export function start(entry?: frame.NavigationEntry); + + /** + * The main entry point event. This method is expected to use the root frame to navigate to the main application page. + */ + export function onLaunch(context?: any): void; + + /** + * A callback to be used when an uncaught error occurs while the application is running. + * The application will be shut down after this method returns. + * Loading new UI at this point is erroneous and may lead to unpredictable results. + * The method is intended to be used for crash reports and/or application restart. + */ + export function onUncaughtError(error: NativeScriptError): void; + + /** + * This method will be called when the Application is suspended. + */ + export function onSuspend(); + + /** + * This method will be called when the Application is resumed after it has been suspended. + */ + export function onResume(); + + /** + * This method will be called when the Application is about to exitEvent. + */ + export function onExit(); + + /** + * This method will be called when there is low memory on the target device. + */ + export function onLowMemory(); + + /** + * A basic method signature to hook an event listener (shortcut alias to the addEventListener method). + * @param eventNames - String corresponding to events (e.g. "onLaunch"). Optionally could be used more events separated by `,` (e.g. "onLaunch", "onSuspend"). + * @param callback - Callback function which will be executed when event is raised. + * @param thisArg - An optional parameter which will be used as `this` context for callback execution. + */ + export function on(eventNames: string, callback: (data: any) => void, thisArg?: any); + + /** + * Shortcut alias to the removeEventListener method. + * @param eventNames - String corresponding to events (e.g. "onLaunch"). + * @param callback - Callback function which will be removed. + * @param thisArg - An optional parameter which will be used as `this` context for callback execution. + */ + export function off(eventNames: string, callback?: any, thisArg?: any); + + /** + * Notifies all the registered listeners for the event provided in the data.eventName. + * @param data The data associated with the event. + */ + export function notify(data: any): void; + + /** + * Checks whether a listener is registered for the specified event name. + * @param eventName The name of the event to check for. + */ + export function hasListeners(eventName: string): boolean; + + /** + * This event is raised on application launchEvent. + */ + export function on(event: "launch", callback: (args: LaunchEventData) => void, thisArg?: any); + + /** + * This event is raised when the Application is suspended. + */ + export function on(event: "suspend", callback: (args: ApplicationEventData) => void, thisArg?: any); + + /** + * This event is raised when the Application is resumed after it has been suspended. + */ + export function on(event: "resume", callback: (args: ApplicationEventData) => void, thisArg?: any); + + /** + * This event is raised when the Application is about to exitEvent. + */ + export function on(event: "exit", callback: (args: ApplicationEventData) => void, thisArg?: any); + + /** + * This event is raised when there is low memory on the target device. + */ + export function on(event: "lowMemory", callback: (args: ApplicationEventData) => void, thisArg?: any); + + /** + * This event is raised when an uncaught error occurs while the application is running. + */ + export function on(event: "uncaughtError", callback: (args: ApplicationEventData) => void, thisArg?: any); + + /** + * This event is raised the orientation of the current device has changed. + */ + export function on(event: "orientationChanged", callback: (args: OrientationChangedEventData) => void, thisArg?: any); + + /** + * This is the Android-specific application object instance. + * Encapsulates methods and properties specific to the Android platform. + * Will be undefined when TargetOS is iOS. + */ + export var android: AndroidApplication; + + /** + * This is the iOS-specific application object instance. + * Encapsulates methods and properties specific to the iOS platform. + * Will be undefined when TargetOS is Android. + */ + export var ios: iOSApplication; + + /** + * Data for the Android activity events. + */ + export interface AndroidActivityEventData { + /** + * The activity. + */ + activity: any /* android.app.Activity */; + + /** + * The name of the event. + */ + eventName: string; + + /** + * The instance that has raised the event. + */ + object: any; + } + + /** + * Data for the Android activity events with bundle. + */ + export interface AndroidActivityBundleEventData extends AndroidActivityEventData { + /** + * The bundle. + */ + bundle: any /* android.os.Bundle */; + } + + /** + * Data for the Android activity result event. + */ + export interface AndroidActivityResultEventData extends AndroidActivityEventData { + /** + * The request code. + */ + requestCode: number; + + /** + * The result code. + */ + resultCode: number; + + /** + * The intent. + */ + intent: any /* android.content.Intent */; + } + + /** + * Data for the Android activity back pressed event. + */ + export interface AndroidActivityBackPressedEventData extends AndroidActivityEventData { + /** + * In the event handler, set this value to true if you want to cancel the back navigation and do something else instead. + */ + cancel: boolean; + } + + /** + * The abstraction of an Android-specific application object. + */ + export class AndroidApplication extends observable.Observable { + /** + * The [android Application](http://developer.android.com/reference/android/app/Application.html) object instance provided to the init of the module. + */ + nativeApp: any /* android.app.Application */; + + /** + * The application's [android Context](http://developer.android.com/reference/android/content/Context.html) object instance. + */ + context: any /* android.content.Context */; + + /** + * The currently active (loaded) [android Activity](http://developer.android.com/reference/android/app/Activity.html). This property is automatically updated upon Activity events. + */ + foregroundActivity: any /* android.app.Activity */; + + /** + * The currently active (loaded) Context. This is typically the top-level Activity that is just created. + */ + currentContext: any /* android.content.Context */; + + /** + * The main (start) Activity for the application. + */ + startActivity: any /* android.app.Activity */; + + /** + * The name of the application package. + */ + packageName: string; + + /** + * True if the application is not running (suspended), false otherwise. + */ + paused: boolean; + + /** + * This method is called by the JavaScript Bridge when navigation to a new activity is triggered. + * @param intent - Native (android) intent used to create the activity. + * Returns com.tns.NativeScriptActivity.extend implementation. + */ + getActivity(intent: any /* android.content.Intent */): any; + + /** + * [Deprecated. Please use the respective event instead.] Direct handler of the [onActivityCreated method](http://developer.android.com/reference/android/app/Application.ActivityLifecycleCallbacks.html). + */ + onActivityCreated: (activity: any /* android.app.Activity */, bundle: any /* android.os.Bundle */) => void; + + /** + * [Deprecated. Please use the respective event instead.] Direct handler of the [onActivityDestroyed method](http://developer.android.com/reference/android/app/Application.ActivityLifecycleCallbacks.html). + */ + onActivityDestroyed: (activity: any /* android.app.Activity */) => void; + + /** + * [Deprecated. Please use the respective event instead.] Direct handler of the [onActivityDestroyed method](http://developer.android.com/reference/android/app/Application.ActivityLifecycleCallbacks.html). + */ + onActivityStarted: (activity: any /* android.app.Activity */) => void; + + /** + * [Deprecated. Please use the respective event instead.] Direct handler of the [onActivityPaused method](http://developer.android.com/reference/android/app/Application.ActivityLifecycleCallbacks.html). + */ + onActivityPaused: (activity: any /* android.app.Activity */) => void; + + /** + * [Deprecated. Please use the respective event instead.] Direct handler of the [onActivityResumed method](http://developer.android.com/reference/android/app/Application.ActivityLifecycleCallbacks.html). + */ + onActivityResumed: (activity: any /* android.app.Activity */) => void; + + /** + * [Deprecated. Please use the respective event instead.] Direct handler of the [onActivityStopped method](http://developer.android.com/reference/android/app/Application.ActivityLifecycleCallbacks.html). + */ + onActivityStopped: (activity: any /* android.app.Activity */) => void; + + /** + * [Deprecated. Please use the respective event instead.] Direct handler of the [onActivitySaveInstanceState method](http://developer.android.com/reference/android/app/Application.ActivityLifecycleCallbacks.html). + */ + onSaveActivityState: (activity: any /* android.app.Activity */, bundle: any /* android.os.Bundle */) => void; + + /** + * [Deprecated. Please use the respective event instead.] Direct handler of the onActivityResult method. + */ + onActivityResult: (requestCode: number, resultCode: number, data: any /* android.content.Intent */) => void; + + /** + * A basic method signature to hook an event listener (shortcut alias to the addEventListener method). + * @param eventNames - String corresponding to events (e.g. "propertyChange"). Optionally could be used more events separated by `,` (e.g. "propertyChange", "change"). + * @param callback - Callback function which will be executed when event is raised. + * @param thisArg - An optional parameter which will be used as `this` context for callback execution. + */ + on(eventNames: string, callback: (data: AndroidActivityEventData) => void, thisArg?: any); + + /** + * This event is raised on android application ActivityCreated. + */ + on(event: "activityCreated", callback: (args: AndroidActivityBundleEventData) => void, thisArg?: any); + + /** + * This event is raised on android application ActivityDestroyed. + */ + on(event: "activityDestroyed", callback: (args: AndroidActivityEventData) => void, thisArg?: any); + + /** + * This event is raised on android application ActivityStarted. + */ + on(event: "activityStarted", callback: (args: AndroidActivityEventData) => void, thisArg?: any); + + /** + * This event is raised on android application ActivityPaused. + */ + on(event: "activityPaused", callback: (args: AndroidActivityEventData) => void, thisArg?: any); + + /** + * This event is raised on android application ActivityResumed. + */ + on(event: "activityResumed", callback: (args: AndroidActivityEventData) => void, thisArg?: any); + + /** + * This event is raised on android application ActivityStopped. + */ + on(event: "activityStopped", callback: (args: AndroidActivityEventData) => void, thisArg?: any); + + /** + * This event is raised on android application SaveActivityState. + */ + on(event: "saveActivityState", callback: (args: AndroidActivityBundleEventData) => void, thisArg?: any); + + /** + * This event is raised on android application ActivityResult. + */ + on(event: "activityResult", callback: (args: AndroidActivityResultEventData) => void, thisArg?: any); + + /** + * This event is raised on the back button is pressed in an android application. + */ + on(event: "activityBackPressed", callback: (args: AndroidActivityBackPressedEventData) => void, thisArg?: any); + + /** + * String value used when hooking to activityCreated event. + */ + public static activityCreatedEvent: string; + + /** + * String value used when hooking to activityDestroyed event. + */ + public static activityDestroyedEvent: string; + + /** + * String value used when hooking to activityStarted event. + */ + public static activityStartedEvent: string; + + /** + * String value used when hooking to activityPaused event. + */ + public static activityPausedEvent: string; + + /** + * String value used when hooking to activityResumed event. + */ + public static activityResumedEvent: string; + + /** + * String value used when hooking to activityStopped event. + */ + public static activityStoppedEvent: string; + + /** + * String value used when hooking to saveActivityState event. + */ + public static saveActivityStateEvent: string; + + /** + * String value used when hooking to activityResult event. + */ + public static activityResultEvent: string; + + /** + * String value used when hooking to activityBackPressed event. + */ + public static activityBackPressedEvent: string; + + /** + * Register a BroadcastReceiver to be run in the main activity thread. The receiver will be called with any broadcast Intent that matches filter, in the main application thread. + * For more information, please visit 'http://developer.android.com/reference/android/content/Context.html#registerReceiver%28android.content.BroadcastReceiver,%20android.content.IntentFilter%29' + * @param intentFilter A string containing the intent filter. + * @param onReceiveCallback A callback function that will be called each time the receiver receives a broadcast. + */ + registerBroadcastReceiver(intentFilter: string, onReceiveCallback: (context: any /* android.content.Context */, intent: any /* android.content.Intent */) => void): void; + + /** + * Unregister a previously registered BroadcastReceiver. + * For more information, please visit 'http://developer.android.com/reference/android/content/Context.html#unregisterReceiver(android.content.BroadcastReceiver)' + * @param intentFilter A string containing the intent filter with which the receiver was originally registered. + */ + unregisterBroadcastReceiver(intentFilter: string): void; + } + + /* tslint:disable */ + /** + * The abstraction of an iOS-specific application object. + */ + export interface iOSApplication { + /* tslint:enable */ + /** + * The root view controller for the application. + */ + rootController: any /* UIViewController */; + + /** + * The [UIApplication](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIApplication_Class/index.html). + */ + nativeApp: any /* UIApplication */; + + /** + * The [UIApplicationDelegate](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIApplicationDelegate_Protocol/index.html) class. + */ + delegate: any /* typeof UIApplicationDelegate */; + + /** + * Adds an observer to the default notification center for the specified notification. + * For more information, please visit 'https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSNotificationCenter_Class/#//apple_ref/occ/instm/NSNotificationCenter/addObserver:selector:name:object:' + * @param notificationName A string containing the name of the notification. + * @param onReceiveCallback A callback function that will be called each time the observer receives a notification. + */ + addNotificationObserver(notificationName: string, onReceiveCallback: (notification: any /* NSNotification */) => void): any; + + /** + * Removes the observer for the specified notification from the default notification center. + * For more information, please visit 'https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSNotificationCenter_Class/#//apple_ref/occ/instm/NSNotificationCenter/addObserver:selector:name:object:' + * @param observer The observer that was returned from the addNotificationObserver method. + * @param notificationName A string containing the name of the notification. + * @param onReceiveCallback A callback function that will be called each time the observer receives a notification. + */ + removeNotificationObserver(observer: any, notificationName: string): void; + } +} diff --git a/definitions/tns-core-modules/camera/camera.d.ts b/definitions/tns-core-modules/camera/camera.d.ts new file mode 100644 index 0000000..e05f941 --- /dev/null +++ b/definitions/tns-core-modules/camera/camera.d.ts @@ -0,0 +1,35 @@ +/** + * Allows you to take pictrues with the device's camera. + */ +declare module "camera" { + + import imageSource = require("image-source"); + + /** + * Take a photo using the camera. + * @param options - Optional parameter for setting different camera options. + */ + export function takePicture(options?: CameraOptions): Promise; + + export interface CameraOptions { + /** + * Defines the desired width (in device independent pixels) of the taken image. It should be used with height property. + * If `keepAspectRatio` actual image width could be different in order to keep the aspect ratio of the original camera image. + * The actual image width will be greater than requested if the display density of the device is higher (than 1) (full HD+ resolutions). + */ + width?: number; + + /** + * Defines the desired height (in device independent pixels) of the taken image. It should be used with width property. + * If `keepAspectRatio` actual image width could be different in order to keep the aspect ratio of the original camera image. + * The actual image height will be greater than requested if the display density of the device is higher (than 1) (full HD+ resolutions). + */ + height?: number; + + /** + * Defines if camera picture aspect ratio should be kept during picture resizing. + * This property could affect width or heigth return values. + */ + keepAspectRatio?: boolean; + } +} diff --git a/definitions/tns-core-modules/color/color.d.ts b/definitions/tns-core-modules/color/color.d.ts new file mode 100644 index 0000000..271ad15 --- /dev/null +++ b/definitions/tns-core-modules/color/color.d.ts @@ -0,0 +1,78 @@ +/** + * Allows creating colors to be used when styling the UI. + */ +declare module "color" { + /** + * Represents a color object. Stores all color components (alpha (opacity), red, green, blue) in a [0..255] range. + */ + class Color { + constructor(knownColor: string); + constructor(hex: string); + constructor(argb: number); + constructor(alpha: number, red: number, green: number, blue: number); + + /** + * Gets the Alpha component (in the [0, 255] range) of this color. This is a read-only property. + */ + public a: number; + + /** + * Gets the Red component (in the [0, 255] range) of this color. This is a read-only property. + */ + public r: number; + + /** + * Gets the Green component (in the [0, 255] range) of this color. This is a read-only property. + */ + public g: number; + + /** + * Gets the Blue component (in the [0, 255] range) of this color. This is a read-only property. + */ + public b: number; + + /** + * Gets the Hexadecimal string representation of this color. This is a read-only property. + */ + public hex: string; + + /** + * Gets the Argb Number representation of this color where each 8 bits represent a single color component. This is a read-only property. + */ + public argb: number; + + /** + * Gets the known name of this instance. Defined only if it has been constructed from a known color name - e.g. "red". This is a read-only property. + */ + public name: string; + + /** + * Gets the android-specific integer value representation. Same as the Argb one. This is a read-only property. + */ + android: number; + + /** + * Gets the iOS-specific UIColor value representation. This is a read-only property. + */ + ios: any /* UIColor */; + + /** + * Specifies whether this Color is equal to the Color parameter. + * @param value The Color to test. + */ + public equals(value: Color): boolean; + + /** + * Compares two Color instances. + * @param value1 A Color to compare. + * @param value2 A Color to compare. + */ + public static equals(value1: Color, value2: Color): boolean; + + /** + * Validates if a value can be converted to color. + * @param value Input string. + */ + public static isValid(value: any): boolean; + } +} diff --git a/definitions/tns-core-modules/color/known-colors.d.ts b/definitions/tns-core-modules/color/known-colors.d.ts new file mode 100644 index 0000000..b0d972b --- /dev/null +++ b/definitions/tns-core-modules/color/known-colors.d.ts @@ -0,0 +1,145 @@ +declare module "color/known-colors" { + export var AliceBlue; + export var AntiqueWhite; + export var Aqua; + export var Aquamarine; + export var Azure; + export var Beige; + export var Bisque; + export var Black; + export var BlanchedAlmond; + export var Blue; + export var BlueViolet; + export var Brown; + export var BurlyWood; + export var CadetBlue; + export var Chartreuse; + export var Chocolate; + export var Coral; + export var CornflowerBlue; + export var Cornsilk; + export var Crimson; + export var Cyan; + export var DarkBlue; + export var DarkCyan; + export var DarkGoldenRod; + export var DarkGray; + export var DarkGreen; + export var DarkKhaki; + export var DarkMagenta; + export var DarkOliveGreen; + export var DarkOrange; + export var DarkOrchid; + export var DarkRed; + export var DarkSalmon; + export var DarkSeaGreen; + export var DarkSlateBlue; + export var DarkSlateGray; + export var DarkTurquoise; + export var DarkViolet; + export var DeepPink; + export var DeepSkyBlue; + export var DimGray; + export var DodgerBlue; + export var FireBrick; + export var FloralWhite; + export var ForestGreen; + export var Fuchsia; + export var Gainsboro; + export var GhostWhite; + export var Gold; + export var GoldenRod; + export var Gray; + export var Green; + export var GreenYellow; + export var HoneyDew; + export var HotPink; + export var IndianRed; + export var Indigo; + export var Ivory; + export var Khaki; + export var Lavender; + export var LavenderBlush; + export var LawnGreen; + export var LemonChiffon; + export var LightBlue; + export var LightCoral; + export var LightCyan; + export var LightGoldenRodYellow; + export var LightGray; + export var LightGreen; + export var LightPink; + export var LightSalmon; + export var LightSeaGreen; + export var LightSkyBlue; + export var LightSlateGray; + export var LightSteelBlue; + export var LightYellow; + export var Lime; + export var LimeGreen; + export var Linen; + export var Magenta; + export var Maroon; + export var MediumAquaMarine; + export var MediumBlue; + export var MediumOrchid; + export var MediumPurple; + export var MediumSeaGreen; + export var MediumSlateBlue; + export var MediumSpringGreen; + export var MediumTurquoise; + export var MediumVioletRed; + export var MidnightBlue; + export var MintCream; + export var MistyRose; + export var Moccasin; + export var NavajoWhite; + export var Navy; + export var OldLace; + export var Olive; + export var OliveDrab; + export var Orange; + export var OrangeRed; + export var Orchid; + export var PaleGoldenRod; + export var PaleGreen; + export var PaleTurquoise; + export var PaleVioletRed; + export var PapayaWhip; + export var PeachPuff; + export var Peru; + export var Pink; + export var Plum; + export var PowderBlue; + export var Purple; + export var Red; + export var RosyBrown; + export var RoyalBlue; + export var SaddleBrown; + export var Salmon; + export var SandyBrown; + export var SeaGreen; + export var SeaShell; + export var Sienna; + export var Silver; + export var SkyBlue; + export var SlateBlue; + export var SlateGray; + export var Snow; + export var SpringGreen; + export var SteelBlue; + export var Tan; + export var Teal; + export var Thistle; + export var Tomato; + export var Turquoise; + export var Violet; + export var Wheat; + export var White; + export var WhiteSmoke; + export var Yellow; + export var YellowGreen; + + export function isKnownName(name: string): boolean; + export function getKnownColor(name: string): string +} diff --git a/definitions/tns-core-modules/connectivity/connectivity.d.ts b/definitions/tns-core-modules/connectivity/connectivity.d.ts new file mode 100644 index 0000000..28df802 --- /dev/null +++ b/definitions/tns-core-modules/connectivity/connectivity.d.ts @@ -0,0 +1,42 @@ +/** + * Contains connectivity utility methods. + */ +declare module "connectivity" { + /** + * Gets the type of connection. + * Returns a value from the connectivity.connectionType enumeration. + * To use this method on Android you need to have the android.permission.ACCESS_NETWORK_STATE permission added to the AndroidManifest.xml file. + */ + export function getConnectionType(): number; + + /** + * Defines the different connection types. + */ + export module connectionType { + /** + * Denotes no connection. + */ + export var none: number; + + /** + * Denotes a WiFi connection. + */ + export var wifi: number; + + /** + * Denotes a mobile connection, i.e. cellular network or WAN + */ + export var mobile: number; + } + + /** + * Starts monitoring the connection type. + * @param connectionChangedCallback A function that will be called when the connection type changes. + */ + export function startMonitoring(connectionTypeChangedCallback: (newConnectionType: number) => void): void; + + /** + * Stops monitoring the connection type. + */ + export function stopMonitoring(): void; +} \ No newline at end of file diff --git a/definitions/tns-core-modules/console/console.d.ts b/definitions/tns-core-modules/console/console.d.ts new file mode 100644 index 0000000..4864086 --- /dev/null +++ b/definitions/tns-core-modules/console/console.d.ts @@ -0,0 +1,74 @@ +/** + * Allows printing messages to the device's console. + */ +declare module "console" { + /** + * Encapsulates methods used to print some information in the console. + * Instance of this class is declared in the global JavaScript context and is accessible by directly calling console.[xxx] methods. + */ + class Console { + /** + * Begins counting a time span for a given name (key). + * @param reportName The key for the operation. + */ + public time(reportName: string): void; + + /** + * Ends a previously started time span through the time method. + * @param reportName The key for the operation. Must have an already started time(reportName) operation with the same key. + */ + public timeEnd(reportName: string): void; + + /** + * Asserts a boolean condition and prints a message in case the assert fails. + * @param test A value that should not be Falsy. + * @param message The message to be displayed in case the asserted value is Falsy. + * @param formatParams Optional formatting parameters to be applied to the printed message. + */ + public assert(test: boolean, message: string, ...formatParams: any[]): void; + + /** + * Reports some information. + * @param message The information message to be printed to the console. + * @param formatParams Optional formatting parameters to be applied to the printed message. + */ + public info(message: any, ...formatParams: any[]): void; + + /** + * Reports a warning. + * @param message The warning message to be printed to the console. + * @param formatParams Optional formatting parameters to be applied to the printed message. + */ + public warn(message: any, ...formatParams: any[]): void; + + /** + * Reports an error. + * @param message The error message to be printed to the console. + * @param formatParams Optional formatting parameters to be applied to the printed message. + */ + public error(message: any, ...formatParams: any[]): void; + + /** + * Verbously logs a message. + * @param message The message to be printed to the console. + * @param formatParams Optional formatting parameters to be applied to the printed message. + */ + public log(message: any, ...formatParams: any[]): void; + + /** + * Prints the current stack trace in the console. + */ + public trace(): void; + + /** + * Prints the state of the specified object to the console. + * @param obj The object instance to be dumped. + */ + public dump(obj: any): void; + + /** + * Prints the state of the specified object to the console. + */ + public dir(obj: any): void; + } +} \ No newline at end of file diff --git a/definitions/tns-core-modules/css-value/reworkcss-value.d.ts b/definitions/tns-core-modules/css-value/reworkcss-value.d.ts new file mode 100644 index 0000000..77b3224 --- /dev/null +++ b/definitions/tns-core-modules/css-value/reworkcss-value.d.ts @@ -0,0 +1,11 @@ +declare module "css-value" { + interface CSSValue { + type: string; + string: string; + unit?: string; + value?: number; + } + + function parse(cssValue: string): Array; + export = parse; +} diff --git a/definitions/tns-core-modules/css/reworkcss.d.ts b/definitions/tns-core-modules/css/reworkcss.d.ts new file mode 100644 index 0000000..daa036a --- /dev/null +++ b/definitions/tns-core-modules/css/reworkcss.d.ts @@ -0,0 +1,31 @@ +declare module "css" { + export interface Position { + start: { line: number; column: number }; + end: { line: number; column: number }; + } + + export interface Node { + type: string; + position: Position; + } + + export interface Declaration extends Node { + property: string; + value: string; + } + + export interface Rule extends Node { + selectors: string[]; + declarations: Declaration[]; + } + + export interface StyleSheet { + rules: Rule[]; + } + + export interface SyntaxTree { + stylesheet: StyleSheet; + } + + export function parse(css: string, options: any): SyntaxTree; +} diff --git a/definitions/tns-core-modules/data/observable-array/observable-array.d.ts b/definitions/tns-core-modules/data/observable-array/observable-array.d.ts new file mode 100644 index 0000000..8d76e34 --- /dev/null +++ b/definitions/tns-core-modules/data/observable-array/observable-array.d.ts @@ -0,0 +1,245 @@ +// Test: http://jsperf.com/array-vs-observable-array-vs-array-observe + +/** + * Contains the ObservableArray class, which is capable of detecting and responding to changes of a collection of objects. + */ +declare module "data/observable-array" { + import observable = require("data/observable"); + + /** + * Event args for "changed" event. + */ + interface ChangedData extends observable.EventData { + /** + * Change type. + */ + action: string; + + /** + * Start index. + */ + index: number; + + /** + * Removed items. + */ + removed: Array; + + /** + * Number of added items. + */ + addedCount: number; + } + + /** + * Change types. + */ + class ChangeType { + static Add: string; + static Delete: string; + static Update: string; + static Splice: string; + } + + /** + * Advanced array like class used when you want to be notified when a change occurs. + */ + class ObservableArray extends observable.Observable { + /** + * String value used when hooking to change event. + */ + public static changeEvent: string; + + /** + * A basic method signature to hook an event listener (shortcut alias to the addEventListener method). + * @param eventNames - String corresponding to events (e.g. "propertyChange"). Optionally could be used more events separated by `,` (e.g. "propertyChange", "change"). + * @param callback - Callback function which will be executed when event is raised. + * @param thisArg - An optional parameter which will be used as `this` context for callback execution. + */ + on(eventNames: string, callback: (data: observable.EventData) => void, thisArg?: any); + + /** + * Raised when a change occurs. + */ + on(event: "change", callback: (args: ChangedData) => void, thisArg?: any); + + /** + * Create ObservableArray with specified length. + */ + constructor(arrayLength?: number); + + /** + * Create ObservableArray from source Array. + */ + constructor(items: T[]); + + /** + * Create ObservableArray from T items. + */ + constructor(...items: T[]); + + /** + * Returns item at specified index. + */ + getItem(index: number): T; + /** + * Sets item at specified index. + */ + setItem(index: number, value: T): void; + /** + * Returns a string representation of an array. + */ + toString(): string; + toLocaleString(): string; + /** + * Combines two or more arrays. + * @param items Additional items to add to the end of array1. + */ + concat(...items: U[]): T[]; + /** + * Combines two or more arrays. + * @param items Additional items to add to the end of array1. + */ + concat(...items: T[]): T[]; + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + /** + * Removes the last element from an array and returns it. + */ + pop(): T; + /** + * Appends new elements to an array, and returns the new length of the array. + * @param items New elements of the Array. + */ + push(items: T[]): number; + /** + * Appends new elements to an array, and returns the new length of the array. + * @param items New elements of the Array. + */ + push(...items: T[]): number; + + /** + * Reverses the elements in an Array. + */ + reverse(): T[]; + /** + * Removes the first element from an array and returns it. + */ + shift(): T; + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): T[]; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: T, b: T) => number): T[]; + + /** + * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. + * @param start The zero-based location in the array from which to start removing elements. + */ + splice(start: number): T[]; + + /** + * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. + * @param start The zero-based location in the array from which to start removing elements. + * @param deleteCount The number of elements to remove. + * @param items Elements to insert into the array in place of the deleted elements. + */ + splice(start: number, deleteCount: number, ...items: T[]): T[]; + + /** + * Inserts new elements at the start of an array. + * @param items Elements to insert at the start of the Array. + */ + unshift(...items: T[]): number; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0. + */ + indexOf(searchElement: T, fromIndex?: number): number; + + /** + * Returns the index of the last occurrence of a specified value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the array. + */ + lastIndexOf(searchElement: T, fromIndex?: number): number; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls the callbackfn function for each element in array1 until the callbackfn returns false, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the callbackfn function for each element in array1 until the callbackfn returns true, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; + + /** + * Calls a defined callback function on each element of an array, and returns an array that contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): T[]; + + /** + * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; + /** + * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; + /** + * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; + + /** + * Gets or sets the length of the array. This is a number one higher than the highest element defined in an array. + */ + length: number; + } +} \ No newline at end of file diff --git a/definitions/tns-core-modules/data/observable/observable.d.ts b/definitions/tns-core-modules/data/observable/observable.d.ts new file mode 100644 index 0000000..d70e751 --- /dev/null +++ b/definitions/tns-core-modules/data/observable/observable.d.ts @@ -0,0 +1,146 @@ +/** + * Contains the Observable class, which represents an observable object, or "data" in the model-view paradigm. + */ +declare module "data/observable" { + /** + * Base event data. + */ + interface EventData { + /** + * The name of the event. + */ + eventName: string; + /** + * The Observable instance that has raised the event. + */ + object: Observable; + } + + /** + * Data for the "propertyChange" event. + */ + interface PropertyChangeData extends EventData { + /** + * The name of the property that has changed. + */ + propertyName: string; + /** + * The new value of the property. + */ + value: any; + } + + /** + * Helper class that is used to fire property change even when real object is the same. + * By default property change will not be fired for a same object. + * By wrapping object into a WrappedValue instance `same object restriction` will be passed. + */ + class WrappedValue { + /** + * Property which holds the real value. + */ + wrapped: any; + + /** + * Creates an instance of WrappedValue object. + * @param value - the real value which should be wrapped. + */ + constructor(value: any); + + /** + * Gets the real value of previously wrappedValue. + * @param value - Value that should be unwraped. If there is no wrappedValue property of the value object then value will be returned. + */ + static unwrap(value: any): any; + + /** + * Returns an instance of WrappedValue. The actual instance is get from a WrappedValues pool. + * @param value - Value that should be wrapped. + */ + static wrap(value: any): WrappedValue + + } + + /** + * Observable is used when you want to be notified when a change occurs. Use on/off methods to add/remove listener. + */ + class Observable { + /** + * String value used when hooking to propertyChange event. + */ + public static propertyChangeEvent: string; + + /** + * Creates an Observable instance and sets its properties accroding to the supplied JSON object. + */ + constructor(json?: any); + + /** + * Gets the name of the constructor function for this instance. E.g. for a Button class this will return "Button". + */ + typeName: string; + + /** + * A basic method signature to hook an event listener (shortcut alias to the addEventListener method). + * @param eventNames - String corresponding to events (e.g. "propertyChange"). Optionally could be used more events separated by `,` (e.g. "propertyChange", "change"). + * @param callback - Callback function which will be executed when event is raised. + * @param thisArg - An optional parameter which will be used as `this` context for callback execution. + */ + on(eventNames: string, callback: (data: EventData) => void, thisArg?: any); + + /** + * Raised when a propertyChange occurs. + */ + on(event: "propertyChange", callback: (data: EventData) => void, thisArg?: any); + + /** + * Shortcut alias to the removeEventListener method. + */ + off(eventNames: string, callback?: any, thisArg?: any); + + /** + * Adds a listener for the specified event name. + * @param eventNames Comma delimited names of the events to attach the listener to. + * @param callback A function to be called when some of the specified event(s) is raised. + * @param thisArg An optional parameter which when set will be used as "this" in callback method call. + */ + addEventListener(eventNames: string, callback: (data: EventData) => void, thisArg?: any); + + /** + * Removes listener(s) for the specified event name. + * @param eventNames Comma delimited names of the events the specified listener is associated with. + * @param callback An optional parameter pointing to a specific listener. If not defined, all listeners for the event names will be removed. + * @param thisArg An optional parameter which when set will be used to refine search of the correct callback which will be removed as event listener. + */ + removeEventListener(eventNames: string, callback?: any, thisArg?: any); + + /** + * Updates the specified property with the provided value. + */ + set(name: string, value: any): void; + + /** + * Gets the value of the specified property. + */ + get(name: string): any; + + /** + * Notifies all the registered listeners for the event provided in the data.eventName. + * @param data The data associated with the event. + */ + notify(data: T): void; + + /** + * Notifies all the registered listeners for the property change event. + */ + notifyPropertyChange(propertyName: string, newValue: any): void; + + /** + * Checks whether a listener is registered for the specified event name. + * @param eventName The name of the event to check for. + */ + hasListeners(eventName: string): boolean; + + + } +} diff --git a/definitions/tns-core-modules/data/virtual-array/virtual-array.d.ts b/definitions/tns-core-modules/data/virtual-array/virtual-array.d.ts new file mode 100644 index 0000000..203332b --- /dev/null +++ b/definitions/tns-core-modules/data/virtual-array/virtual-array.d.ts @@ -0,0 +1,96 @@ +/** + * Contains the VirtualArray class, which is an advanced array like class that helps loading items on demand. + */ +declare module "data/virtual-array" { + import observable = require("data/observable"); + import observableArray = require("data/observable-array"); + + /** + * Provides event args for "changed" event. + */ + export interface ChangedData extends observableArray.ChangedData { + // + } + + /** + * Change types (Add, Delete, Update, Splice). + */ + export class ChangeType extends observableArray.ChangeType { + // + } + + /** + * Advanced array like class that helps loading items on demand. + */ + export class VirtualArray extends observable.Observable { + /** + * String value used when hooking to change event. + */ + public static changeEvent: string; + + /** + * String value used when hooking to itemsLoading event. + */ + public static itemsLoadingEvent: string; + + constructor(arrayLength?: number); + + /** + * Gets or sets length for the virtual array. + */ + length: number; + + /** + * Gets or sets load size for the virtual array. + */ + loadSize: number; + + /** + * Returns item at specified index. + */ + getItem(index: number): T; + + /** + * Sets item at specified index. + */ + setItem(index: number, value: T): void; + + /** + * Loads items from an array starting at index. + */ + load(index: number, items: T[]): void; + + /** + * A basic method signature to hook an event listener (shortcut alias to the addEventListener method). + * @param eventNames - String corresponding to events (e.g. "propertyChange"). Optionally could be used more events separated by `,` (e.g. "propertyChange", "change"). + * @param callback - Callback function which will be executed when event is raised. + * @param thisArg - An optional parameter which will be used as `this` context for callback execution. + */ + on(eventNames: string, callback: (data: observable.EventData) => void, thisArg?: any); + + /** + * Raised when still not loaded items are requested. + */ + on(event: "itemsLoading", callback: (args: ItemsLoading) => void, thisArg?: any); + + /** + * Raised when a change occurs. + */ + on(event: "change", callback: (args: ChangedData) => void, thisArg?: any); + } + + /** + * Event args for "itemsLoading" event. + */ + export interface ItemsLoading extends observable.EventData { + /** + * Start index. + */ + index: number; + + /** + * Number of items to load. + */ + count: number; + } +} \ No newline at end of file diff --git a/definitions/tns-core-modules/declarations.d.ts b/definitions/tns-core-modules/declarations.d.ts new file mode 100644 index 0000000..fbecd74 --- /dev/null +++ b/definitions/tns-core-modules/declarations.d.ts @@ -0,0 +1,151 @@ +/* tslint:disable:no-unused-variable */ + +declare class Request { + constructor(input: string|Request, init?: RequestInit); + method: string; + url: string; + headers: Headers; + context: RequestContext; + referrer: string; + mode: RequestMode; + credentials: RequestCredentials; + cache: RequestCache; +} + +interface RequestInit { + method?: string; + headers?: HeaderInit|{ [index: string]: string }; + body?: BodyInit; + mode?: RequestMode; + credentials?: RequestCredentials; + cache?: RequestCache; +} + +declare enum RequestContext { + "audio", "beacon", "cspreport", "download", "embed", "eventsource", "favicon", "fetch", + "font", "form", "frame", "hyperlink", "iframe", "image", "imageset", "import", + "internal", "location", "manifest", "object", "ping", "plugin", "prefetch", "script", + "serviceworker", "sharedworker", "subresource", "style", "track", "video", "worker", + "xmlhttprequest", "xslt" +} + +declare enum RequestMode { "same-origin", "no-cors", "cors" } +declare enum RequestCredentials { "omit", "same-origin", "include" } +declare enum RequestCache { "default", "no-store", "reload", "no-cache", "force-cache", "only-if-cached" } + +declare class Headers { + append(name: string, value: string): void; + delete(name: string): void; + get(name: string): string; + getAll(name: string): Array; + has(name: string): boolean; + set(name: string, value: string): void; +} + +declare class Body { + bodyUsed: boolean; + /* + arrayBuffer(): Promise; + blob(): Promise; + */ + formData(): Promise; + json(): Promise; + text(): Promise; +} + +declare class Response extends Body { + constructor(body?: BodyInit, init?: ResponseInit); + error(): Response; + redirect(url: string, status: number): Response; + type: ResponseType; + url: string; + status: number; + ok: boolean; + statusText: string; + headers: Headers; + clone(): Response; +} + +declare enum ResponseType { "basic", "cors", "default", "error", "opaque" } + +declare class ResponseInit { + status: number; + statusText: string; + headers: HeaderInit; +} + +declare type HeaderInit = Headers|Array; +declare type BodyInit = Blob|FormData|string; +declare type RequestInfo = Request|string; + +declare function fetch(url: string, init?: RequestInit): Promise; + +interface XMLHttpRequest { + send(data?: FormData): void; +} + +interface Console { + time(reportName: string): void; + timeEnd(reportName: string): void; + assert(test: boolean, message: string, ...formatParams: any[]): void; + info(message: any, ...formatParams: any[]): void; + warn(message: any, ...formatParams: any[]): void; + error(message: any, ...formatParams: any[]): void; + log(message: any, ...formatParams: any[]): void; + trace(): void; + dump(obj: any): void; + createDump(obj: any): string; + dir(obj: any): void; +} + +declare var console: Console; +declare var require: NativeScriptRequire; + +// Global functions +declare function Deprecated(target: Object, key?: string | symbol, value?: any): void; +declare function Experimental(target: Object, key?: string | symbol, value?: any): void; + +declare function Log(data: any): void; +declare function log(data: any): void; +declare function float(num: number): any; +declare function long(num: number): any; +declare function fail(data: any): void; + +declare var __dirname: string; +declare var __filename: string; + +/** + * Calls a function after a specified delay. + * @param callback The function to be called. + * @param milliseconds The time to wait before the function is called. Defaults to 0. + */ +declare function setTimeout(callback: Function, milliseconds?: number): number; + +/** + * Clears the delay set by a call to the setTimeout function. + * @param id The identifier returned by the previously called setTimeout() method. + */ +declare function clearTimeout(id: number): void; + +/** + * Calls a function repeatedly with a delay between each call. + * @param callback The function to be called. + * @param milliseconds The delay between each function call. + */ +declare function setInterval(callback: Function, milliseconds?: number): number; + +/** + * Clears repeated function which was set up by calling setInterval(). + * @param id The identifier returned by the setInterval() method. + */ +declare function clearInterval(id: number): void; + +declare class WeakRef { + constructor(obj: T); + get(): T; + clear(): void; +} + +declare var module: NativeScriptModule; +// Same as module.exports +declare var exports: any; diff --git a/definitions/tns-core-modules/es-collections.d.ts b/definitions/tns-core-modules/es-collections.d.ts new file mode 100644 index 0000000..c55bfd1 --- /dev/null +++ b/definitions/tns-core-modules/es-collections.d.ts @@ -0,0 +1,49 @@ +/* tslint:disable */ +///////////////////////////// +/// IE11 ECMAScript Extensions +///////////////////////////// + +interface List extends Array {} + +interface Map { + clear(): void; + delete(key: K): boolean; + forEach(callbackfn: (value: V, index: K, map: Map) => void, thisArg?: any): void; + get(key: K): V; + has(key: K): boolean; + set(key: K, value: V): Map; + size: number; + keys(): Array; + values(): Array; +} +declare var Map: { + new (): Map; + + // needed by Angular + // alexeagle: PATCHED + new(m: Map): Map; + new(l: List): Map; + prototype: Map; +} + +//For compatibility - some libs insist on the Map/Set types being named that way +declare type MapConstructor = typeof Map; +declare type SetConstructor = typeof Set; + +interface Set { + add(value: T): Set; + clear(): void; + delete(value: T): boolean; + forEach(callbackfn: (value: T, index: T, set: Set) => void, thisArg?: any): void; + has(value: T): boolean; + size: number; +} +declare var Set: { + new (): Set; + + // needed by Angular + // alexeagle PATCHED + new(s: Set): Set; + new(l: List): Set; + prototype: Set; +} diff --git a/definitions/tns-core-modules/es6-promise.d.ts b/definitions/tns-core-modules/es6-promise.d.ts new file mode 100644 index 0000000..5ebee38 --- /dev/null +++ b/definitions/tns-core-modules/es6-promise.d.ts @@ -0,0 +1,146 @@ +/* tslint:disable */ +// Type definitions for es6-promise +// Project: https://github.com/jakearchibald/ES6-Promise +// Definitions by: François de Campredon +// Definitions: https://github.com/borisyankov/DefinitelyTyped +interface Thenable { + then(onFulfilled?: (value: R) => Thenable, onRejected?: (error: any) => Thenable): Thenable; + then(onFulfilled?: (value: R) => Thenable, onRejected?: (error: any) => U): Thenable; + then(onFulfilled?: (value: R) => Thenable, onRejected?: (error: any) => void): Thenable; + then(onFulfilled?: (value: R) => U, onRejected?: (error: any) => Thenable): Thenable; + then(onFulfilled?: (value: R) => U, onRejected?: (error: any) => U): Thenable; + then(onFulfilled?: (value: R) => U, onRejected?: (error: any) => void): Thenable; +} + +interface Promise extends Thenable { + /** + * onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects. + * Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called. + * Both callbacks have a single parameter , the fulfillment value or rejection reason. + * "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve. + * If an error is thrown in the callback, the returned promise rejects with that error. + * @param onFulfilled called when/if "promise" resolves + * @param onRejected called when/if "promise" rejects + */ + then(onFulfilled?: (value: R) => Thenable, onRejected?: (error: any) => Thenable): Promise; + /** + * onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects. + * Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called. + * Both callbacks have a single parameter , the fulfillment value or rejection reason. + * "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve. + * If an error is thrown in the callback, the returned promise rejects with that error. + * @param onFulfilled called when/if "promise" resolves + * @param onRejected called when/if "promise" rejects + */ + then(onFulfilled?: (value: R) => Thenable, onRejected?: (error: any) => U): Promise; + /** + * onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects. + * Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called. + * Both callbacks have a single parameter , the fulfillment value or rejection reason. + * "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve. + * If an error is thrown in the callback, the returned promise rejects with that error. + * @param onFulfilled called when/if "promise" resolves + * @param onRejected called when/if "promise" rejects + */ + then(onFulfilled?: (value: R) => Thenable, onRejected?: (error: any) => void): Promise; + /** + * onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects. + * Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called. + * Both callbacks have a single parameter , the fulfillment value or rejection reason. + * "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve. + * If an error is thrown in the callback, the returned promise rejects with that error. + * @param onFulfilled called when/if "promise" resolves + * @param onRejected called when/if "promise" rejects + */ + then(onFulfilled?: (value: R) => U, onRejected?: (error: any) => Thenable): Promise; + /** + * onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects. + * Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called. + * Both callbacks have a single parameter , the fulfillment value or rejection reason. + * "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve. + * If an error is thrown in the callback, the returned promise rejects with that error. + * @param onFulfilled called when/if "promise" resolves + * @param onRejected called when/if "promise" rejects + */ + then(onFulfilled?: (value: R) => U, onRejected?: (error: any) => U): Promise; + /** + * onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects. + * Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called. + * Both callbacks have a single parameter , the fulfillment value or rejection reason. + * "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve. + * If an error is thrown in the callback, the returned promise rejects with that error. + * @param onFulfilled called when/if "promise" resolves + * @param onRejected called when/if "promise" rejects + */ + then(onFulfilled?: (value: R) => U, onRejected?: (error: any) => void): Promise; + + /** + * Sugar for promise.then(undefined, onRejected) + * @param onRejected called when/if "promise" rejects + */ + catch(onRejected?: (error: any) => Thenable): Promise; + /** + * Sugar for promise.then(undefined, onRejected) + * @param onRejected called when/if "promise" rejects + */ + catch(onRejected?: (error: any) => U): Promise; + /** + * Sugar for promise.then(undefined, onRejected) + * @param onRejected called when/if "promise" rejects + */ + catch(onRejected?: (error: any) => void): Promise; +} + +interface PromiseConstructor { + /** + * A reference to the prototype. + */ + prototype: Promise; + + /** + * Creates a new Promise. + * @param executor A callback used to initialize the promise. This callback is passed two arguments: + * a resolve callback used resolve the promise with a value or the result of another promise, + * and a reject callback used to reject the promise with a provided reason or error. + */ + new (executor: (resolve: (value?: T | Thenable) => void, reject: (reason?: any) => void) => void): Promise; + + /** + * Returns promise (only if promise.constructor == Promise) + */ + cast(promise: Promise): Promise; + /** + * Make a promise that fulfills to obj. + */ + cast(object: R): Promise; + + /** + * Make a new promise from the thenable. + * A thenable is promise-like in as far as it has a "then" method. + * This also creates a new promise if you pass it a genuine JavaScript promise, making it less efficient for casting than Promise.cast. + */ + resolve(thenable?: Thenable): Promise; + /** + * Make a promise that fulfills to obj. Same as Promise.cast(obj) in this situation. + */ + resolve(object?: R): Promise; + + /** + * Make a promise that rejects to obj. For consistency and debugging (eg stack traces), obj should be an instanceof Error + */ + reject(error: any): Promise; + + /** + * Make a promise that fulfills when every item in the array fulfills, and rejects if (and when) any item rejects. + * the array passed to all can be a mixture of promise-like objects and other objects. + * The fulfillment value is an array (in order) of fulfillment values. The rejection value is the first rejection value. + */ + all(promises: Promise[]): Promise; + + /** + * Make a Promise that fulfills when any item fulfills, and rejects if any item rejects. + */ + race(promises: Promise[]): Promise; +} + +declare var Promise: PromiseConstructor; diff --git a/definitions/tns-core-modules/es6.d.ts b/definitions/tns-core-modules/es6.d.ts new file mode 100644 index 0000000..bba5f46 --- /dev/null +++ b/definitions/tns-core-modules/es6.d.ts @@ -0,0 +1 @@ +declare var Symbol: any; \ No newline at end of file diff --git a/definitions/tns-core-modules/file-system/file-name-resolver.d.ts b/definitions/tns-core-modules/file-system/file-name-resolver.d.ts new file mode 100644 index 0000000..6fe115b --- /dev/null +++ b/definitions/tns-core-modules/file-system/file-name-resolver.d.ts @@ -0,0 +1,23 @@ +/** + * Provides FileNameResolver class used for loading files based on device capabilities. + */ +declare module "file-system/file-name-resolver" { + export interface PlatformContext { + width: number; + height: number; + os: string; + deviceType: string; + } + + export class FileNameResolver { + constructor(context: PlatformContext); + resolveFileName(path: string, ext: string): string; + clearCache(): void; + } + + export function resolveFileName(path: string, ext: string): string; + export function clearCache(): void; + + + +} \ No newline at end of file diff --git a/definitions/tns-core-modules/file-system/file-system-access.d.ts b/definitions/tns-core-modules/file-system/file-system-access.d.ts new file mode 100644 index 0000000..2a03f3f --- /dev/null +++ b/definitions/tns-core-modules/file-system/file-system-access.d.ts @@ -0,0 +1,173 @@ +declare module "file-system/file-system-access" { + /** + * An utility class used to provide methods to access and work with the file system. + */ + export class FileSystemAccess { + /** + * Gets the last modified date of a file with a given path. + * @param path Path to the file. + */ + getLastModified(path: string): Date; + + /** + * Gets the parent folder of a file with a given path. + * @param path Path to the file. + * @param onError A callback function to use if any error occurs. + * Returns path Absolute path of the parent folder, name Name of the parent folder. + */ + getParent(path: string, onError?: (error: any) => any): { path: string; name: string }; + + /** + * Gets a file from a given path. + * @param path Path to the file. + * @param onError A callback function to use if any error occurs. + * Returns path Absolute path of the file, name Name of the file, extension Extension of the file. + */ + getFile(path: string, onError?: (error: any) => any): { path: string; name: string; extension: string }; + + /** + * Gets the folder of a file with a given path. + * @param path Path to the file. + * @param onError A callback function to use if any error occurs. + * Returns path Absolute path of the folder, name Name of the folder. + */ + getFolder(path: string, onError?: (error: any) => any): { path: string; name: string }; + + /** + * Gets all entities of a given path (folder) + * @param onSuccess A callback function to call if operation is successful + * @param onError (optional) A callback function to use if any error occurs. + */ + getEntities(path: string, onError?: (error: any) => any): Array<{ path: string; name: string; extension: string }>; + + /** + * Performs an action onSuccess for every entity in a folder with a given path. + * Breaks the loop if onSuccess function returns false + * @param onEntity A callback function which is called for each entity. + * @param onError (optional) A callback function to use if any error occurs. + */ + eachEntity(path: string, onEntity: (entity: { path: string; name: string; extension: string }) => boolean, onError?: (error: any) => any); + + /** + * Checks if a file with a given path exist. + */ + fileExists(path: string): boolean; + + /** + * Checks if a folder with a given path exist. + */ + folderExists(path: string): boolean; + + /** + * Deletes a file with a given path. + * @param path Path of the file. + * @param onError (optional) A callback function to use if any error occurs. + */ + deleteFile(path: string, onError?: (error: any) => any); + + /** + * Deletes a folder with a given path. + * @param path Path of the folder. + * @param onError (optional) A callback function to use if any error occurs. + */ + deleteFolder(path: string, onError?: (error: any) => any); + + /** + * Deletes a content of a folder with a given path. + * @param path Path of the folder. + * @param onError (optional) A callback function to use if any error occurs. + */ + emptyFolder(path: string, onError?: (error: any) => any): void; + + /** + * Rename a file or a folder with a given path. + * @param path Current path of the entity which should be renamed. + * @param newPath The new path which will be asigned of the entity. + * @param onError (optional) A callback function to use if any error occurs. + */ + rename(path: string, newPath: string, onError?: (error: any) => any): void; + + /** + * Gets the special documents folder. + * Returns for Android: "/data/data/applicationPackageName/files", iOS: "/var/mobile/Applications/appID/Documents" + */ + getDocumentsFolderPath(): string; + + /** + * Gets the special documents folder. + * Returns for Android: "/data/data/applicationPackageName/cache", iOS: "/var/mobile/Applications/appID/Library/Caches" + */ + getTempFolderPath(): string; + + /** + * Gets the path to the logical root of the application - that is /path/to/appfiles/app. + */ + getLogicalRootPath(): string; + + /** + * Reads a text from a file with a given path. + * @param path The path to the source file. + * @param onSuccess A callback function which is called when a text is red. + * @param onError (optional) A callback function to use if any error occurs. + * @param encoding (optional) If set reads the text with the specified encoding (default UTF-8). + */ + readText(path: string, onError?: (error: any) => any, encoding?: any): string; + + /** + * Reads a binary content from a file with a given path. + * @param path The path to the source file. + * @param onSuccess A callback function which is called when a text is red. + * @param onError (optional) A callback function to use if any error occurs. + */ + read(path: string, onError?: (error: any) => any): any; + + /** + * Writes a text to a file with a given path. + * @param path The path to the source file. + * @param content The content which will be written to the file. + * @param onSuccess (optional) A callback function which is called when a text is written. + * @param onError (optional) A callback function to use if any error occurs. + * @param encoding (optional) If set writes the text with the specified encoding (default UTF-8). + */ + writeText(path: string, content: string, onError?: (error: any) => any, encoding?: any); + + /** + * Writes a binary to a file with a given path. + * @param path The path to the source file. + * @param content The content which will be written to the file. + * @param onSuccess (optional) A callback function which is called when a text is written. + * @param onError (optional) A callback function to use if any error occurs. + */ + write(path: string, content: any, onError?: (error: any) => any); + + /** + * Gets extension of the file with a given path. + * @param path A path to the file. + */ + getFileExtension(path: string): string; + + /** + * Gets the path separator (for the current platform). + */ + getPathSeparator(): string; + + /** + * Normalizes a path. + * @param path A path which should be normalized. + * Returns a normalized path as string. + */ + normalizePath(path: string): string; + + /** + * Join two paths (without normalize) only removes some trailing and dublicating path separators. + * @param left First path to join. + * @param right Second path to join. + */ + joinPath(left: string, right: string): string; + + /** + * Joins an array of file paths. + */ + joinPaths(paths: string[]): string; + } +} \ No newline at end of file diff --git a/definitions/tns-core-modules/file-system/file-system.d.ts b/definitions/tns-core-modules/file-system/file-system.d.ts new file mode 100644 index 0000000..fc45a60 --- /dev/null +++ b/definitions/tns-core-modules/file-system/file-system.d.ts @@ -0,0 +1,234 @@ +/** + * Provides high-level abstractions for file system entities such as files, folders, known folders, paths, separators, etc. + */ +declare module "file-system" { + + /** + * Represents a single entity on the file system. + */ + export class FileSystemEntity { + /** + * Gets the Date object specifying the last time this entity was modified. + */ + lastModified: Date; + + /** + * Gets the name of the entity. + */ + name: string; + + /** + * Gets the fully-qualified path (including the extension for a File) of the entity. + */ + path: string; + + /** + * Gets the Folder object representing the parent of this entity. + * Will be null for a root folder like Documents or Temporary. + * This property is readonly. + */ + parent: Folder; + + /** + * Removes (deletes) the current Entity from the file system. + */ + remove(): Promise; + + /** + * Removes (deletes) the current Entity from the file system synchronously. + */ + removeSync(onError?: (error: any) => any): void; + + /** + * Renames the current entity using the specified name. + * @param newName The new name to be applied to the entity. + */ + rename(newName: string): Promise; + + /** + * Renames the current entity synchronously, using the specified name. + * @param newName The new name to be applied to the entity. + */ + renameSync(newName: string, onError?: (error: any) => any): void; + } + + /** + * Represents a File entity on the file system. + */ + export class File extends FileSystemEntity { + /** + * Checks whether a File with the specified path already exists. + * @param path The path to check for. + */ + static exists(path: string): boolean; + + /** + * Gets the extension of the file. + */ + extension: string; + + /** + * Gets a value indicating whether the file is currently locked, meaning a background operation associated with this file is running. + */ + isLocked: boolean; + + /** + * Gets or creates a File entity at the specified path. + * @param path The path to get/create the file at. + */ + static fromPath(path: string): File; + + /** + * Reads the content of the file as a string using the specified encoding (defaults to UTF-8). + * @param encoding An optional value specifying the preferred encoding (defaults to UTF-8). + */ + readText(encoding?: string): Promise; + + /** + * Reads the content of the file as a string synchronously, using the specified encoding (defaults to UTF-8). + * @param onError An optional function to be called if some IO-error occurs. + * @param encoding An optional value specifying the preferred encoding (defaults to UTF-8). + */ + readTextSync(onError?: (error: any) => any, encoding?: string): string; + + /** + * Reads the binary content of the file synchronously. + * @param onError An optional function to be called if some IO-error occurs. + */ + readSync(onError?: (error: any) => any): any; + + /** + * Writes the provided string to the file, using the specified encoding (defaults to UTF-8). + * @param content The content to be saved to the file. + * @param encoding An optional value specifying the preferred encoding (defaults to UTF-8). + */ + writeText(content: string, encoding?: string): Promise; + + /** + * Writes the provided string to the file synchronously, using the specified encoding (defaults to UTF-8). + * @param content The content to be saved to the file. + * @param onError An optional function to be called if some IO-error occurs. + * @param encoding An optional value specifying the preferred encoding (defaults to UTF-8). + */ + writeTextSync(content: string, onError?: (error: any) => any, encoding?: string): void; + + /** + * Writes the provided binary content to the file synchronously. + * @param content The binary content to be saved to the file. + * @param onError An optional function to be called if some IO-error occurs. + */ + writeSync(content: any, onError?: (error: any) => any): void; + } + + /** + * Represents a Folder (directory) entity on the file system. + */ + export class Folder extends FileSystemEntity { + /** + * Determines whether this instance is a KnownFolder (accessed through the KnownFolders object). + */ + isKnown: boolean; + + /** + * Gets or creates a Folder entity at the specified path. + * @param path The path to get/create the folder at. + */ + static fromPath(path: string): Folder; + + /** + * Checks whether a Folder with the specified path already exists. + * @param path The path to check for. + */ + static exists(path: string): boolean; + + /** + * Checks whether this Folder contains an Entity with the specified name. + * The path of the folder is added to the name to resolve the complete path to check for. + * @param name The name of the entity to check for. + */ + contains(name: string): boolean; + + /** + * Deletes all the files and folders (recursively), contained within this Folder. + */ + clear(): Promise; + + /** + * Deletes all the files and folders (recursively), contained within this Folder synchronously. + * @param onError An optional function to be called if some error occurs. + */ + clearSync(onError?: (error: any) => void): void; + + /** + * Gets or creates a File entity with the specified name within this Folder. + * @param name The name of the file to get/create. + */ + getFile(name: string): File; + + /** + * Gets or creates a Folder entity with the specified name within this Folder. + * @param name The name of the folder to get/create. + */ + getFolder(name: string): Folder; + + /** + * Gets all the top-level entities residing within this folder. + */ + getEntities(): Promise>; + + /** + * Gets all the top-level entities residing within this folder synchronously. + * @param onError An optional function to be called if some error occurs. + */ + getEntitiesSync(onError?: (error: any) => any): Promise>; + + /** + * Enumerates all the top-level FileSystem entities residing within this folder. + * @param onEntity A callback that receives the current entity. If the callback returns false this will mean for the iteration to stop. + */ + eachEntity(onEntity: (entity: FileSystemEntity) => boolean); + } + + /** + * Provides access to the top-level Folders instances that are accessible from the application. Use these as entry points to access the FileSystem. + */ + module knownFolders { + /** + * Gets the Documents folder available for the current application. This Folder is private for the application and not accessible from Users/External apps. + */ + export function documents(): Folder; + + /** + * Gets the Temporary (Caches) folder available for the current application. This Folder is private for the application and not accessible from Users/External apps. + */ + export function temp(): Folder; + + /** + * Gets the root folder for the current application. This Folder is private for the application and not accessible from Users/External apps. + * iOS - this folder is read-only and contains the app and all its resources. + */ + export function currentApp(): Folder; + } + + /** + * Enables path-specific operations like join, extension, etc. + */ + export module path { + /** + * Normalizes a path, taking care of occurrances like ".." and "//". + * @param path The path to be normalized. + */ + export function normalize(path: string): string; + + /** + * Joins all the provided string components, forming a valid and normalized path. + * @param paths An array of string components to be joined. + */ + export function join(...paths: string[]): string; + + /** + * Gets the string used to separate file paths. + */ + export var separator: string; + } +} \ No newline at end of file diff --git a/definitions/tns-core-modules/fps-meter/fps-meter.d.ts b/definitions/tns-core-modules/fps-meter/fps-meter.d.ts new file mode 100644 index 0000000..019edd0 --- /dev/null +++ b/definitions/tns-core-modules/fps-meter/fps-meter.d.ts @@ -0,0 +1,30 @@ +/** + * Allows you to capture the frames-per-second metrics of your application. + */ +declare module "fps-meter" { + + /** + * Starts the frames-per-second meter. + */ + export function start(): void; + + /** + * Stops the frames-per-second meter. + */ + export function stop(): void; + + /** + * Returns a valid indicating whether the frames-per-second meter is currently running. + */ + export function running(): boolean; + + /** + * Adds a callback function to be called each time FPS data is due to be reported. Returns an unique id which can be used to remove this callback later. + */ + export function addCallback(callback: (fps: number, minFps?: number) => void): number; + + /** + * Removes the callback with the specified id. + */ + export function removeCallback(id: number); +} \ No newline at end of file diff --git a/definitions/tns-core-modules/fps-meter/fps-native.d.ts b/definitions/tns-core-modules/fps-meter/fps-native.d.ts new file mode 100644 index 0000000..3256db9 --- /dev/null +++ b/definitions/tns-core-modules/fps-meter/fps-native.d.ts @@ -0,0 +1,28 @@ +declare module "fps-meter/fps-native" { + + /** + * An utility class used to measure frames per second. + */ + export class FPSCallback { + + /** + * Initializes a new instance of FPSCallback class. + */ + constructor(onFrame: (currentTimeMillis: number) => void); + + /** + * Starts the frame per seconds measurement. + */ + start(): void; + + /** + * Stops the frame per seconds measurement. + */ + stop(): void; + + /** + * Gets if the current instance of FPSCallback is running. + */ + running: boolean; + } +} \ No newline at end of file diff --git a/definitions/tns-core-modules/http/http.d.ts b/definitions/tns-core-modules/http/http.d.ts new file mode 100644 index 0000000..c8781cf --- /dev/null +++ b/definitions/tns-core-modules/http/http.d.ts @@ -0,0 +1,143 @@ +/** + * Allows you to send web requests and receive the responses. + */ +declare module "http" { + import image = require("image-source"); + import fs = require("file-system"); + + /** + * Downloads the content from the specified URL as a string. + * @param url The URL to request from. + */ + export function getString(url: string): Promise + + /** + * Downloads the content from the specified URL as a string. + * @param options An object that specifies various request options. + */ + export function getString(options: HttpRequestOptions): Promise + + /** + * Downloads the content from the specified URL as a string and returns its JSON.parse representation. + * @param url The URL to request from. + */ + export function getJSON(url: string): Promise + + /** + * Downloads the content from the specified URL as a string and returns its JSON.parse representation. + * @param options An object that specifies various request options. + */ + export function getJSON(options: HttpRequestOptions): Promise + + /** + * Downloads the content from the specified URL and attempts to decode it as an image. + * @param url The URL to request from. + */ + export function getImage(url: string): Promise + + /** + * Downloads the content from the specified URL and attempts to decode it as an image. + * @param options An object that specifies various request options. + */ + export function getImage(options: HttpRequestOptions): Promise + + /** + * Downloads the content from the specified URL and attempts to save it as file. + * @param url The URL to request from. + * @param destinationFilePath Optional. The downloaded file path. + */ + export function getFile(url: string, destinationFilePath?: string): Promise + + /** + * Downloads the content from the specified URL and attempts to save it as file. + * @param options An object that specifies various request options. + * @param destinationFilePath Optional. The downloaded file path. + */ + export function getFile(options: HttpRequestOptions, destinationFilePath?: string): Promise + + /** + * Makes a generic http request using the provided options and returns a HttpResponse Object. + * @param options An object that specifies various request options. + */ + export function request(options: HttpRequestOptions): Promise; + + /** + * Provides options for the http requests. + */ + export interface HttpRequestOptions { + /** + * Gets or sets the request url. + */ + url: string; + + /** + * Gets or sets the request method. + */ + method: string; + + /** + * Gets or sets the request headers in JSON format. + */ + headers?: any; + + /** + * Gets or sets the request body. + */ + content?: string | FormData; + + /** + * Gets or sets the request timeout in milliseconds. + */ + timeout?: number; + } + + /** + * Encapsulates HTTP-response information from an HTTP-request. + */ + export interface HttpResponse { + /** + * Gets the response status code. + */ + statusCode: number; + + /** + * Gets the response headers. + */ + headers: any; + + /** + * Gets the response content. + */ + content?: HttpContent; + } + + /** + * Encapsulates the content of an HttpResponse. + */ + export interface HttpContent { + /** + * Gets the response body as raw data. + */ + raw: any; + + /** + * Gets the response body as string. + */ + toString: () => string; + + /** + * Gets the response body as JSON object. + */ + toJSON: () => any; + + /** + * Gets the response body as ImageSource. + */ + toImage: () => Promise; + + /** + * Gets the response body as file. + */ + toFile: (destinationFilePath?: string) => fs.File; + } +} \ No newline at end of file diff --git a/definitions/tns-core-modules/image-source/image-source.d.ts b/definitions/tns-core-modules/image-source/image-source.d.ts new file mode 100644 index 0000000..38f31c7 --- /dev/null +++ b/definitions/tns-core-modules/image-source/image-source.d.ts @@ -0,0 +1,125 @@ +/** + * Contains the ImageSource class, which encapsulates the common abstraction behind a platform specific object (typically a Bitmap) that is used as a source for images. + */ +declare module "image-source" { + + /** + * Encapsulates the common abstraction behind a platform specific object (typically a Bitmap) that is used as a source for images. + */ + export class ImageSource { + /** + * Gets the height of this instance. This is a read-only property. + */ + height: number; + + /** + * Gets the width of this instance. This is a read-only property. + */ + width: number; + + /** + * The iOS-specific [UIImage](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIImage_Class/) instance. Will be undefined when running on Android. + */ + ios: any /* UIImage */; + + /** + * The Android-specific [image](http://developer.android.com/reference/android/graphics/Bitmap.html) instance. Will be undefined when running on iOS. + */ + android: any /* android.graphics.Bitmap */; + + /** + * Loads this instance from the specified resource name. + * @param name The name of the resource (without its extension). + */ + loadFromResource(name: string): boolean; + + /** + * Loads this instance from the specified file. + * @param path The location of the file on the file system. + */ + loadFromFile(path: string): boolean; + + /** + * Loads this instance from the specified native image data. + * @param data The native data (byte array) to load the image from. This will be either Stream for Android or NSData for iOS. + */ + loadFromData(data: any): boolean; + + /** + * Loads this instance from the specified native image data. + * @param source The Base64 string to load the image from. + */ + loadFromBase64(source: string): boolean; + + /** + * Sets the provided native source object (typically a Bitmap). + * This will update either the android or ios properties, depending on the target os. + * @param source The native image object. Will be either a Bitmap for Android or a UIImage for iOS. + */ + setNativeSource(source: any): boolean; + + /** + * Saves this instance to the specified file, using the provided image format and quality. + * @param path The path of the file on the file system to save to. + * @param format The format (encoding) of the image. + * @param quality Optional parameter, specifying the quality of the encoding. Defaults to the maximum available quality. + */ + saveToFile(path: string, format: string, quality?: number): boolean; + + /** + * Converts the image to base64 encoded string, using the provided image format and quality. + * @param format The format (encoding) of the image. + * @param quality Optional parameter, specifying the quality of the encoding. Defaults to the maximum available quality. + */ + toBase64String(format: string, quality?: number): string; + } + + /** + * Creates a new ImageSource instance and loads it from the specified resource name. + * @param name The name of the resource (without its extension). + */ + export function fromResource(name: string): ImageSource; + + /** + * Creates a new ImageSource instance and loads it from the specified file. + * @param path The location of the file on the file system. + */ + export function fromFile(path: string): ImageSource; + + /** + * Creates a new ImageSource instance and loads it from the specified resource name. + * @param data The native data (byte array) to load the image from. This will be either Stream for Android or NSData for iOS. + */ + export function fromData(data: any): ImageSource; + + /** + * Creates a new ImageSource instance and loads it from the specified resource name. + * @param source The Base64 string to load the image from. + */ + export function fromBase64(source: string): ImageSource; + + /** + * Creates a new ImageSource instance and sets the provided native source object (typically a Bitmap). + * The native source object will update either the android or ios properties, depending on the target os. + * @param source The native image object. Will be either a Bitmap for Android or a UIImage for iOS. + */ + export function fromNativeSource(source: any): ImageSource; + + /** + * Downloads the image from the provided Url and creates a new ImageSource instance from it. + * @param url The link to the remote image object. This operation will download and decode the image. + */ + export function fromUrl(url: string): Promise; + + /** + * Creates a new ImageSource instance and loads it from the specified local file or resource(if spexified with "res://" prefix) + * @param path The location of the file on the file system. + */ + export function fromFileOrResource(path: string): ImageSource; + + /** + * [Obsolete. Please use utils.isFileOrResourcePath instead!] Returns true if the specified path points to a resource or local file. + * @param path The path. + */ + export function isFileOrResourcePath(path: string): boolean +} diff --git a/definitions/tns-core-modules/js-libs/esprima/esprima.d.ts b/definitions/tns-core-modules/js-libs/esprima/esprima.d.ts new file mode 100644 index 0000000..05f09f5 --- /dev/null +++ b/definitions/tns-core-modules/js-libs/esprima/esprima.d.ts @@ -0,0 +1,274 @@ +/* tslint:disable */ + +// Type definitions for Esprima v1.2.0 +// Project: http://esprima.org +// Definitions by: teppeis +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module "js-libs/esprima" { + var version: string; + function parse(code: string, options?: Options): Syntax.Program; + function tokenize(code: string, options?: Options): Array; + + interface Token { + type: string + value: string + } + + interface Options { + loc?: boolean + range?: boolean + raw?: boolean + tokens?: boolean + comment?: boolean + attachComment?: boolean + tolerant?: boolean + source?: boolean + } + + module Syntax { + // Node + interface Node { + type: string + loc?: LineLocation + range?: number[] + leadingComments?: Comment[] + trailingComments?: Comment[] + } + interface LineLocation { + start: Position + end: Position + } + interface Position { + line: number + column: number + } + + // Comment + interface Comment extends Node { + value: string + } + + // Program + interface Program extends Node { + body: SomeStatement[] + comments?: Comment[] + } + + // Function + interface Function extends Node { + id: Identifier // | null + params: Identifier[] + defaults: SomeExpression[] + rest: Identifier // | null + body: BlockStatementOrExpression + generator: boolean + expression: boolean + } + interface BlockStatementOrExpression extends Array, BlockStatement, SomeExpression { + body: BlockStatementOrExpression + } + + // Statement + interface Statement extends Node { + } + interface EmptyStatement extends Statement { + } + interface BlockStatement extends Statement { + body: SomeStatement[] + } + interface ExpressionStatement extends Statement { + expression: SomeExpression + } + interface IfStatement extends Statement { + test: SomeExpression + consequent: SomeStatement + alternate: SomeStatement + } + interface LabeledStatement extends Statement { + label: Identifier + body: SomeStatement + } + interface BreakStatement extends Statement { + label: Identifier // | null + } + interface ContinueStatement extends Statement { + label: Identifier // | null + } + interface WithStatement extends Statement { + object: SomeExpression + body: SomeStatement + } + interface SwitchStatement extends Statement { + discriminant: SomeExpression + cases: SwitchCase[] + lexical: boolean + } + interface ReturnStatement extends Statement { + argument: SomeExpression // | null + } + interface ThrowStatement extends Statement { + argument: SomeExpression + } + interface TryStatement extends Statement { + block: BlockStatement + handler: CatchClause // | null + guardedHandlers: CatchClause[] + finalizer: BlockStatement // | null + } + interface WhileStatement extends Statement { + test: SomeExpression + body: SomeStatement + } + interface DoWhileStatement extends Statement { + body: SomeStatement + test: SomeExpression + } + interface ForStatement extends Statement { + init: VariableDeclaratorOrExpression // | null + test: SomeExpression // | null + update: SomeExpression // | null + body: SomeStatement + } + interface ForInStatement extends Statement { + left: VariableDeclaratorOrExpression + right: SomeExpression + body: SomeStatement + each: boolean + } + interface VariableDeclaratorOrExpression extends VariableDeclarator, SomeExpression { + } + interface DebuggerStatement extends Statement { + } + interface SomeStatement extends + EmptyStatement, ExpressionStatement, BlockStatement, IfStatement, + LabeledStatement, BreakStatement, ContinueStatement, WithStatement, + SwitchStatement, ReturnStatement, ThrowStatement, TryStatement, + WhileStatement, DoWhileStatement, ForStatement, ForInStatement, DebuggerStatement { + body: SomeStatementOrList + } + interface SomeStatementOrList extends Array, SomeStatement { + } + + // Declration + interface Declration extends Statement { + } + interface FunctionDeclration extends Declration { + id: Identifier + params: Identifier[] // Pattern + defaults: SomeExpression[] + rest: Identifier + body: BlockStatementOrExpression + generator: boolean + expression: boolean + } + interface VariableDeclaration extends Declration { + declarations: VariableDeclarator[] + kind: string // "var" | "let" | "const" + } + interface VariableDeclarator extends Node { + id: Identifier // Pattern + init: SomeExpression + } + + // Expression + interface Expression extends Node { // | Pattern + } + interface SomeExpression extends + ThisExpression, ArrayExpression, ObjectExpression, FunctionExpression, + ArrowFunctionExpression, SequenceExpression, UnaryExpression, BinaryExpression, + AssignmentExpression, UpdateExpression, LogicalExpression, ConditionalExpression, + NewExpression, CallExpression, MemberExpression { + } + interface ThisExpression extends Expression { + } + interface ArrayExpression extends Expression { + elements: SomeExpression[] // [ Expression | null ] + } + interface ObjectExpression extends Expression { + properties: Property[] + } + interface Property extends Node { + key: LiteralOrIdentifier // Literal | Identifier + value: SomeExpression + kind: string // "init" | "get" | "set" + } + interface LiteralOrIdentifier extends Literal, Identifier { + } + interface FunctionExpression extends Function, Expression { + } + interface ArrowFunctionExpression extends Function, Expression { + } + interface SequenceExpression extends Expression { + expressions: SomeExpression[] + } + interface UnaryExpression extends Expression { + operator: string // UnaryOperator + prefix: boolean + argument: SomeExpression + } + interface BinaryExpression extends Expression { + operator: string // BinaryOperator + left: SomeExpression + right: SomeExpression + } + interface AssignmentExpression extends Expression { + operator: string // AssignmentOperator + left: SomeExpression + right: SomeExpression + } + interface UpdateExpression extends Expression { + operator: string // UpdateOperator + argument: SomeExpression + prefix: boolean + } + interface LogicalExpression extends Expression { + operator: string // LogicalOperator + left: SomeExpression + right: SomeExpression + } + interface ConditionalExpression extends Expression { + test: SomeExpression + alternate: SomeExpression + consequent: SomeExpression + } + interface NewExpression extends Expression { + callee: SomeExpression + arguments: SomeExpression[] + } + interface CallExpression extends Expression { + callee: SomeExpression + arguments: SomeExpression[] + } + interface MemberExpression extends Expression { + object: SomeExpression + property: IdentifierOrExpression // Identifier | Expression + computed: boolean + } + interface IdentifierOrExpression extends Identifier, SomeExpression { + } + + // Pattern + // interface Pattern extends Node { + // } + + // Clauses + interface SwitchCase extends Node { + test: SomeExpression + consequent: SomeStatement[] + } + interface CatchClause extends Node { + param: Identifier // Pattern + guard: SomeExpression + body: BlockStatement + } + + // Misc + interface Identifier extends Node, Expression { // | Pattern + name: string + } + interface Literal extends Node, Expression { + value: any // string | boolean | null | number | RegExp + } + } +} \ No newline at end of file diff --git a/definitions/tns-core-modules/location/location.d.ts b/definitions/tns-core-modules/location/location.d.ts new file mode 100644 index 0000000..44ad32f --- /dev/null +++ b/definitions/tns-core-modules/location/location.d.ts @@ -0,0 +1,191 @@ +/** + * Allows you to use the geolocation of the device. + */ +declare module "location" { + // For future usage + //class LocationRegion { + // public latitude: number; + // public longitude: number; + + // public raduis: number; // radius in meters + //} + + /** + * A data class that encapsulates common properties for a geolocation. + */ + export class Location { + /** + * The latitude of the geolocation, in degrees. + */ + latitude: number; + + /** + * The longitude of the geolocation, in degrees. + */ + longitude: number; + + /** + * The altitude (if available), in meters above sea level. + */ + altitude: number; + + /** + * The horizontal accuracy, in meters. + */ + horizontalAccuracy: number; + + /** + * The vertical accuracy, in meters. + */ + verticalAccuracy: number; + + /** + * The speed, in meters/second over ground. + */ + speed: number; + + /** + * The direction (course), in degrees. + */ + direction: number; + + /** + * The time at which this location was determined. + */ + timestamp: Date; + + /** + * The android-specific [location](http://developer.android.com/reference/android/location/Location.html) object. + */ + android: any /* android.location.Location */; + + /** + * The ios-specific [CLLocation](https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocation_Class/) object. + */ + ios: any /* CLLocation */; + } + + /** + * Provides options for location monitoring. + */ + export interface Options { + /** + * Specifies desired accuracy in meters. Defaults to DesiredAccuracy.HIGH + */ + desiredAccuracy?: number; + + /** + * Update distance filter in meters. Specifies how often to update. Default on iOS is no filter, on Android it is 0 meters + */ + updateDistance?: number; + + /** + * Minimum time interval between location updates, in milliseconds (ignored on iOS) + */ + minimumUpdateTime?: number; + + /** + * how old locations to receive in ms. + */ + maximumAge?: number; + + /** + * how long to wait for a location in ms. + */ + timeout?: number; + } + + /** + * Provides methods for querying geolocation (in case available) on the target platform. + */ + export class LocationManager { + /** + * Checks whether the location services are switched ON for this device (on Android) or application (iOS). + */ + static isEnabled(): boolean; + + /** + * Measures the distance in meters between two locations. + * @param loc1 The first location. + * @param loc2 The second location. + */ + static distance(loc1: Location, loc2: Location): number; + + /** + * The desired accuracy in meters. Defaults to DesiredAccuracy.HIGH + */ + desiredAccuracy: number; + + /** + * The update distance filter in meters. Specifies how often to update. Default on iOS is no filter, on Android it is 0 meters. + */ + updateDistance: number; + + /** + * True if the location listener is already started. In this case all other start requests will be ignored. + */ + isStarted: boolean; + + /** + * Starts location monitoring. + * @param onLocation A function that will be called upon every location update received. + * @param onError An optional error callback. + * @param options An optional object specifying location update settings. + */ + startLocationMonitoring(onLocation: (location: Location) => any, onError?: (error: Error) => any, options?: Options); + + /** + * Stops location monitoring. + */ + stopLocationMonitoring(); + + /** + * Returns last known location from device's location services or null of no known last location. + */ + lastKnownLocation: Location; + + /** + * An android-specific data for location. + */ + android: AndroidLocationManager; + + /** + * An ios-specific data for location. + */ + ios: iOSLocationManager; + } + + /** + * Provides Android specific data related to location. + */ + export interface AndroidLocationManager { + /** + * The android-specific location manager [LocationManager](http://developer.android.com/reference/android/location/LocationManager.html) + */ + manager: any /* android.location.LocationManager */; + + /** + * The minimum time interval between subsequent location updates, in milliseconds. + */ + minimumUpdateTime: number; + } + + /** + * Fires a single shot location search. If you specify timeout in options (milliseconds), location search will stop on timeout. + * If you specify timeout = 0 it just requests the last known location. + * However if you specify maximumAge and the location received is older it won't be received. + * @param options - An optional object specifying location update settings. + */ + export function getLocation(options?: Options): Promise; + + /* tslint:disable */ + /** + * Provides iOS specific data related to location. + */ + export interface iOSLocationManager { + /** + * The ios-specific location manager [CLLocationManager](https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocationManager_Class/) + */ + manager: any /* CLLocationManager */; + } +} diff --git a/definitions/tns-core-modules/module.d.ts b/definitions/tns-core-modules/module.d.ts new file mode 100644 index 0000000..772a2cc --- /dev/null +++ b/definitions/tns-core-modules/module.d.ts @@ -0,0 +1,13 @@ +//Base module declarations +//Not required in Angular apps since it clashes with its typings. +declare var global: any; + +interface NativeScriptRequire { + (id: string): any; +} + +interface NativeScriptModule { + id: string; + filename: string; + exports: any; +} diff --git a/definitions/tns-core-modules/package.json b/definitions/tns-core-modules/package.json new file mode 100644 index 0000000..7cea332 --- /dev/null +++ b/definitions/tns-core-modules/package.json @@ -0,0 +1,104 @@ +{ + "name": "tns-core-modules", + "description": "Telerik NativeScript Core Modules", + "version": "1.6.2", + "homepage": "https://www.nativescript.org", + "repository": { + "type": "git", + "url": "https://github.com/NativeScript/NativeScript/commit/a3b688a3b9000497a1ab153d45df3f06b0ba3bc5" + }, + "files": [ + "**/*.*", + "**/*", + "!.baseDir.*", + "!node-tests/", + "!apps/" + ], + "license": "Apache-2.0", + "devDependencies": { + "chai": "3.2.0", + "grunt": "0.4.5", + "grunt-contrib-clean": "0.6.0", + "grunt-contrib-copy": "git+https://github.com/ErjanGavalji/grunt-contrib-copy.git#1c976a133210be4ce8c96313f5daf14833f7f8f9", + "grunt-env": "0.4.4", + "grunt-exec": "0.4.6", + "grunt-mkdir": "0.1.2", + "grunt-multi-dest": "1.0.0", + "grunt-shell": "1.1.2", + "grunt-simple-mocha": "0.4.0", + "grunt-ts": "5.3.2", + "grunt-typedoc": "0.2.3", + "grunt-untar": "0.0.1", + "mocha": "2.2.5", + "shelljs": "0.5.3", + "grunt-tslint": "3.0.0", + "time-grunt": "^1.3.0", + "tslint": "3.3.0", + "typescript": "1.7.5" + }, + "typings": "tns-core-modules.d.ts", + "dependencies": { + "tns-core-modules-widgets": "1.6.1" + }, + "nativescript": { + "platforms": { + "ios": "1.6.0", + "android": "1.6.0" + } + }, + "_id": "tns-core-modules@1.6.2", + "_shasum": "05bbf174813448b1cb0f76b1897c72573927fbec", + "_resolved": "https://registry.npmjs.org/tns-core-modules/-/tns-core-modules-1.6.2.tgz", + "_from": "tns-core-modules@>=1.6.2 <2.0.0", + "scripts": {}, + "_npmVersion": "3.7.1", + "_nodeVersion": "5.5.0", + "_npmUser": { + "name": "hdeshev", + "email": "hristo@deshev.com" + }, + "dist": { + "shasum": "05bbf174813448b1cb0f76b1897c72573927fbec", + "tarball": "http://registry.npmjs.org/tns-core-modules/-/tns-core-modules-1.6.2.tgz" + }, + "maintainers": [ + { + "name": "enchev", + "email": "vladimir.enchev@gmail.com" + }, + { + "name": "erjangavalji", + "email": "erjan.gavalji@gmail.com" + }, + { + "name": "fatme", + "email": "hfatme@gmail.com" + }, + { + "name": "hdeshev", + "email": "hristo@deshev.com" + }, + { + "name": "ligaz", + "email": "stefan.dobrev@gmail.com" + }, + { + "name": "nsndeck", + "email": "nedyalko.nikolov@telerik.com" + }, + { + "name": "sdobrev", + "email": "stefan.dobrev@gmail.com" + }, + { + "name": "valio.stoychev", + "email": "valio.stoychev@gmail.com" + } + ], + "_npmOperationalInternal": { + "host": "packages-9-west.internal.npmjs.com", + "tmp": "tmp/tns-core-modules-1.6.2.tgz_1456230220993_0.6211725694593042" + }, + "directories": {}, + "readme": "ERROR: No README data found!" +} diff --git a/definitions/tns-core-modules/platform/platform.d.ts b/definitions/tns-core-modules/platform/platform.d.ts new file mode 100644 index 0000000..ce157d0 --- /dev/null +++ b/definitions/tns-core-modules/platform/platform.d.ts @@ -0,0 +1,113 @@ +/* tslint:disable:class-name */ +/** + * Contains all kinds of information about the device, its operating system and software. + */ +declare module "platform" { + + /* + * Enum holding platform names. + */ + export module platformNames { + export var android: string; + export var ios: string; + } + + /* + * An object containing device specific information. + */ + export class device { + /** + * Gets the manufacturer of the device. + * For example: "Apple" or "HTC" or "Samsung". + */ + static manufacturer: string; + + /** + * Gets the model of the device. + * For example: "Nexus 5" or "iPhone". + */ + static model: string; + + /** + * Gets the model of the device. + * For example: "Android" or "iOS". + */ + static os: string; + + /** + * Gets the OS version. + * For example: 4.4.4(android), 8.1(ios) + */ + static osVersion: string; + + /** + * Gets the OS version. + * For example: 19(android), 8.1(ios). + */ + static sdkVersion: string; + + /** + * Gets the type current device. + * Available values: "phone", "tablet". + */ + static deviceType: string; + + /** + * Gets the uuid. + * On iOS this will return a new uuid if the application re-installed on the device. + * If you need to receive the same uuid even after the application has been re-installed on the device, + * use this plugin: https://www.npmjs.com/package/nativescript-ios-uuid + */ + static uuid: string; + + /** + * Gets the preferred language. For example "en" + */ + static language: string; + + /** + * Gets the preferred region. For example "US" + */ + static region: string; + } + + /** + * An object containing screen information. + */ + export interface ScreenMetrics { + /** + * Gets the absolute width of the screen in pixels. + */ + widthPixels: number; + + /** + * Gets the absolute height of the screen in pixels. + */ + heightPixels: number; + + /** + * Gets the absolute width of the screen in density independent pixels. + */ + widthDIPs: number; + + /** + * Gets the absolute height of the screen in density independent pixels. + */ + heightDIPs: number; + + /** + * The logical density of the display. This is a scaling factor for the Density Independent Pixel unit. + */ + scale: number; + } + + /** + * An object describing general information about a display. + */ + export class screen { + /** + * Gets information about the main screen of the current device. + */ + static mainScreen: ScreenMetrics; + } +} diff --git a/definitions/tns-core-modules/text/formatted-string.d.ts b/definitions/tns-core-modules/text/formatted-string.d.ts new file mode 100644 index 0000000..40b5abc --- /dev/null +++ b/definitions/tns-core-modules/text/formatted-string.d.ts @@ -0,0 +1,102 @@ +/** + * Contains the FormattedString and Span classes, which are used to create a formatted (rich text) strings. + */ +declare module "text/formatted-string" { + import spanModule = require("text/span"); + import observable = require("data/observable"); + import observableArray = require("data/observable-array"); + import colorModule = require("color"); + import view = require("ui/core/view"); + + /** + * Interface that specifies View that have formattedText property (like TextBase and Button). + */ + export interface FormattedStringView { + formattedText: FormattedString; + } + + /** + * A class used to create a formatted (rich text) string. + */ + class FormattedString extends observable.Observable implements view.AddArrayFromBuilder, view.AddChildFromBuilder { + /** + * An observable collection of Span objects used to define common text properties. + */ + public spans: observableArray.ObservableArray; + + /** + * Initializes a new instance of FormattedString class. + */ + constructor(); + + /** + * A human readable representation of the formatted string. + */ + public toString(): string; + + /** + * Gets or sets the font family which will be used for all spans that not have a specific value for font family. + */ + public fontFamily: string; + + /** + * Gets or sets the font size which will be used for all spans that not have a specific value for font size. + */ + public fontSize: number; + + /** + * Gets or sets the font attributes which will be used for all spans that not have a specific value for font attributes. + */ + public fontAttributes: number; + + /** + * Gets or sets the font foreground color which will be used for all spans that not have a specific value for font foreground color. + */ + public foregroundColor: colorModule.Color; + + /** + * Gets or sets the font background color which will be used for all spans that not have a specific value for font background color. + */ + public backgroundColor: colorModule.Color; + + /** + * Gets or sets underline which will be used for all spans that not have a specific value for underline. + */ + public underline: number; + + /** + * Gets or sets strikethrough which will be used for all spans that not have a specific value for strikethrough. + */ + public strikethrough: number; + + /** + * Propogates binding context through the spans collection. + * @param newBindingContext The value of the newly set binding context. + */ + public updateSpansBindingContext(newBindingContext: any): void + + /** + * Gets the parent view of the formatted string. + */ + public parent: view.View; + + /** + * A function that is called when an array declaration is found in xml. + * @param name - Name of the array. + * @param value - The actual value of the array. + */ + public _addArrayFromBuilder(name: string, value: Array): void; + + /** + * Called for every child element declared in xml. + * @param name - Name of the element. + * @param value - Value of the element. + */ + public _addChildFromBuilder(name: string, value: any): void; + + /** + * A static method used to add child elements of the FormattedString class to a View declared in xml. + */ + public static addFormattedStringToView(view: FormattedStringView, name: string, value: any): void; + } +} \ No newline at end of file diff --git a/definitions/tns-core-modules/text/span.d.ts b/definitions/tns-core-modules/text/span.d.ts new file mode 100644 index 0000000..d6f2b69 --- /dev/null +++ b/definitions/tns-core-modules/text/span.d.ts @@ -0,0 +1,76 @@ +declare module "text/span" { + import colorModule = require("color"); + import bindable = require("ui/core/bindable"); + import formattedString = require("text/formatted-string"); + + /** + * A class used to create a single part of formatted string with a common text properties. + */ + class Span extends bindable.Bindable { + /** + * Gets or sets the font family of the span. + */ + public fontFamily: string; + + /** + * Gets or sets the font size of the span. + */ + public fontSize: number; + + /** + * Gets or sets the font attributes of the span. + * It could be set to more than one value e.g. (Bold | Italic). + */ + public fontAttributes: number; + + /** + * Gets or sets the font foreground color of the span. + */ + public foregroundColor: colorModule.Color; + + /** + * Gets or sets the font background color of the span. + */ + public backgroundColor: colorModule.Color; + + /** + * Gets or sets underline for the span. + */ + public underline: number; + + /** + * Gets or sets strikethrough for the span. + */ + public strikethrough: number; + + /** + * A collection of modifiers build upon all text related properties. + */ + public spanModifiers: Array; + + /** + * Gets or sets the text for the span. + */ + public text: string; + + /** + * An instance of the parent formatted string (used internally to support some short hand property settings). + */ + public parentFormattedString: formattedString.FormattedString; + + /** + * Updates all span modifiers according to current values of all text related properties. + */ + public updateSpanModifiers(parent: formattedString.FormattedString): void; + + /** + * Initializes a process of updating a span (text related property(s)). + */ + public beginEdit(): void; + + /** + * Ends the process previously initiated by beginEdit and updates the span modifiers collection. + */ + public endEdit(): void; + } +} \ No newline at end of file diff --git a/definitions/tns-core-modules/text/text.d.ts b/definitions/tns-core-modules/text/text.d.ts new file mode 100644 index 0000000..aaaac87 --- /dev/null +++ b/definitions/tns-core-modules/text/text.d.ts @@ -0,0 +1,40 @@ +/** + * Defines specific text related enumerations. + */ +declare module "text" { + /** + * Defines the supported character encodings. + */ + module encoding { + /** + * Denotes ISO-8859-1 character encoding. + */ + export var ISO_8859_1: any; + + /** + * Denotes US_ASCII character encoding. + */ + export var US_ASCII: any; + + /** + * Denotes UTF_16 character encoding. + */ + export var UTF_16: any; + + /** + * Denotes UTF_16BE character encoding. + */ + export var UTF_16BE: any; + + /** + * Denotes UTF_16LE character encoding. + */ + export var UTF_16LE: any; + + /** + * Denotes UTF_8 character encoding. + */ + export var UTF_8: any; + } +} + diff --git a/definitions/tns-core-modules/timer/timer.d.ts b/definitions/tns-core-modules/timer/timer.d.ts new file mode 100644 index 0000000..4237786 --- /dev/null +++ b/definitions/tns-core-modules/timer/timer.d.ts @@ -0,0 +1,30 @@ +/** + * Allows you to create, start, stop and react to timers. + */ +declare module "timer" { + /** + * Calls a function after a specified delay. + * @param callback The function to be called. + * @param milliseconds The time to wait before the function is called. Defaults to 0. + */ + export function setTimeout(callback: Function, milliseconds?: number): number; + + /** + * Clears the delay set by a call to the setTimeout function. + * @param id The identifier returned by the previously called setTimeout() method. + */ + export function clearTimeout(id: number): void; + + /** + * Calls a function repeatedly with a delay between each call. + * @param callback The function to be called. + * @param milliseconds The delay between each function call. + */ + export function setInterval(callback: Function, milliseconds?: number): number; + + /** + * Clears repeated function which was set up by calling setInterval(). + * @param id The identifier returned by the setInterval() method. + */ + export function clearInterval(id: number): void; +} \ No newline at end of file diff --git a/definitions/tns-core-modules/tns-core-modules.base.d.ts b/definitions/tns-core-modules/tns-core-modules.base.d.ts new file mode 100644 index 0000000..eee93a3 --- /dev/null +++ b/definitions/tns-core-modules/tns-core-modules.base.d.ts @@ -0,0 +1,92 @@ +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// \ No newline at end of file diff --git a/definitions/tns-core-modules/tns-core-modules.d.ts b/definitions/tns-core-modules/tns-core-modules.d.ts new file mode 100644 index 0000000..46481b3 --- /dev/null +++ b/definitions/tns-core-modules/tns-core-modules.d.ts @@ -0,0 +1,6 @@ +/// +/// +/// +/// +/// +/// \ No newline at end of file diff --git a/definitions/tns-core-modules/tns-core-modules.es6.d.ts b/definitions/tns-core-modules/tns-core-modules.es6.d.ts new file mode 100644 index 0000000..3ff2797 --- /dev/null +++ b/definitions/tns-core-modules/tns-core-modules.es6.d.ts @@ -0,0 +1,2 @@ +/// +/// \ No newline at end of file diff --git a/definitions/tns-core-modules/trace/trace.d.ts b/definitions/tns-core-modules/trace/trace.d.ts new file mode 100644 index 0000000..1a9e657 --- /dev/null +++ b/definitions/tns-core-modules/trace/trace.d.ts @@ -0,0 +1,111 @@ +/** + * Allows you to trace and print specific information based on categories. + */ +declare module "trace" { + /** + * Enables the trace module. + */ + export function enable(): void; + + /** + * Disables the trace module. + */ + export function disable(): void; + + /** + * Adds a TraceWriter instance to the trace module. + * @param writer The TraceWriter instance to add. + */ + export function addWriter(writer: TraceWriter); + + /** + * Removes a TraceWriter instance from the trace module. + * @param writer The TraceWriter instance to remove. + */ + export function removeWriter(writer: TraceWriter); + + /** + * Clears all the writers from the trace module. + */ + export function clearWriters(); + + /** + * Sets the categories the module will trace. + * @param categories The comma-separated list of categories. If not specified all messages from all categories will be traced. + */ + export function setCategories(categories: string); + + /** + * Adds categories to existing categories the module will trace. + * @param categories The comma-separated list of categories. If not specified all messages from all categories will be traced. + */ + export function addCategories(categories: string); + + /** + * Writes a message using the available writers. + * @param message The message to be written. + * @param category The category of the message. + * @param type Optional, the type of the message - info, warning, error. + */ + export function write(message: any, category: string, type?: number); + + /** + * Notifies all the attached listeners for an event that has occurred in the sender object. + * @param object The Object instance that raised the event. + * @param name The name of the raised event. + * @param data An optional parameter that passes the data associated with the event. + */ + export function notifyEvent(object: Object, name: string, data?: any); + + export function addEventListener(listener: EventListener); + + export function removeEventListener(listener: EventListener); + + /** + * An enum that defines all predefined categories. + */ + module categories { + export var VisualTreeEvents: string; + export var Layout: string; + export var Style: string; + export var ViewHierarchy: string; + export var NativeLifecycle: string; + export var Debug: string; + export var Navigation: string; + export var Test: string; + export var Binding: string; + export var Error: string; + export var Animation: string; + export var Transition: string; + + export var All: string; + + export var separator: string; + export function concat(...categories: string[]): string; + } + + /** + * An enum that defines all predefined message types. + */ + module messageType { + export var log: number; + export var info: number; + export var warn: number; + export var error: number; + } + + /** + * An interface used to define a writer used by trace to print (log). + */ + export interface TraceWriter { + write(message: any, category: string, type?: number); + } + + /** + * An interface used to trace information about specific event. + */ + export interface EventListener { + filter: string; + on(object: Object, name: string, data?: any); + } +} \ No newline at end of file diff --git a/definitions/tns-core-modules/ui/action-bar/action-bar.d.ts b/definitions/tns-core-modules/ui/action-bar/action-bar.d.ts new file mode 100644 index 0000000..771b2fc --- /dev/null +++ b/definitions/tns-core-modules/ui/action-bar/action-bar.d.ts @@ -0,0 +1,257 @@ +/** + * Contains the action bar related classes. + */ +declare module "ui/action-bar" { + import observable = require("data/observable"); + import view = require("ui/core/view"); + import dependencyObservable = require("ui/core/dependency-observable"); + import bindable = require("ui/core/bindable"); + import pages = require("ui/page"); + + /** + * Provides an abstraction over the ActionBar (android) and NavigationBar (iOS). + */ + export class ActionBar extends view.View implements view.AddArrayFromBuilder, view.AddChildFromBuilder { + + /** + * Gets or sets the action bar title. + */ + title: string; + + /** + * Gets or sets the title view. When set - replaces the title with a custom view. + */ + titleView: view.View; + + /** + * Gets or sets the navigation button (a.k.a. the back button). + */ + navigationButton: NavigationButton; + + /** + * Gets the collection of action items. + */ + actionItems: ActionItems; + + /** + * Gets the android specific options of the action bar. + */ + android: AndroidActionBarSettings; + + /** + * Gets the page that contains the action bar. + */ + page: pages.Page; + + /** + * Updates the action bar. + */ + update(); + + + + _addArrayFromBuilder(name: string, value: Array): void; + _addChildFromBuilder(name: string, value: any): void; + } + + /** + * Represents a collection of ActionItems. + */ + export class ActionItems { + /** + * Adds an item to the collection. + * @param item - the item to be added + */ + addItem(item: ActionItem): void; + + /** + * Removes an item to the collection. + * @param item - The item to be removed. + */ + removeItem(item: ActionItem): void; + + /** + * Gets an array of the current action items in the collection. + */ + getItems(): Array; + + /** + * Gets an item at a specified index. + * @param index - The index. + */ + getItemAt(index: number): ActionItem; + } + + /** + * Represents an action item in the action bar. + */ + export class ActionItem extends bindable.Bindable { + /** + * String value used when hooking to tap event. + */ + public static tapEvent: string; + + /** + * Represents the observable property backing the text property. + */ + public static textProperty: dependencyObservable.Property; + + /** + * Represents the observable property backing the icon property. + */ + public static iconProperty: dependencyObservable.Property; + + /** + * Represents the observable property backing the visibility property. + */ + public static visibilityProperty: dependencyObservable.Property; + + /** + * Gets or sets the text of the action item. + */ + text: string; + + /** + * Gets or sets the icon of the action item. + */ + icon: string; + + /** + * Gets or sets the visibility of the action item. + */ + visibility: string; + + /** + * Gets the action bar that contains the action item. + */ + actionBar: ActionBar; + + /** + * Gets the page that contains the action item. + */ + page: pages.Page; + + /** + * A basic method signature to hook an event listener (shortcut alias to the addEventListener method). + * @param eventNames - String corresponding to events (e.g. "propertyChange"). Optionally could be used more events separated by `,` (e.g. "propertyChange", "change"). + * @param callback - Callback function which will be executed when event is raised. + * @param thisArg - An optional parameter which will be used as `this` context for callback execution. + */ + on(eventNames: string, callback: (data: observable.EventData) => void); + + /** + * Raised when a tap event occurs. + */ + on(event: "tap", callback: (args: observable.EventData) => void); + + + + /** + * Gets the iOS specific options of the action item. + */ + ios: IOSActionItemSettings; + + /** + * Gets the Android specific options of the action item. + */ + android: AndroidActionItemSettings; + } + + /** + * Represents Android specific options of the action item. + */ + export interface AndroidActionItemSettings { + /** + * Gets or sets the position of the action item in the action bar. + * 1. actionBar - item is shown in the action bar. + * 2. actionBarIfRoom - item is shown in the action bar if there is room for it. Otherwise it is put in the popup menu. + * 3. popup - item is shown in the popup menu. + * Note: Property not applicable to NavigationButton + */ + position: string; + + /** + * Gets or sets the name of the system drawable resource to be displayed. + * Use this property instead of ActionItem.icon if you want to diplsay a built-in Android system icon. + * The value should be a string such as 'ic_menu_search' if you want to display the built-in Android Menu Search icon for example. + * For a full list of Android drawable names, please visit http://androiddrawables.com + */ + systemIcon: string; + } + + /** + * Represents iOS specific options of the action item. + */ + export interface IOSActionItemSettings { + /** + * Gets or sets the position of the action item in the action bar. + * 1. left - items is shown at the left part of the navigation bar. This is the default value. + * 2. right - items is shown at the right part of the navigation bar. + * Note: Property not applicable to NavigationButton + */ + position: string; + + /** + * Gets or sets a number representing the iOS system item to be displayed. + * Use this property instead of ActionItem.icon if you want to diplsay a built-in iOS system icon. + * Note: Property not applicable to NavigationButton + * The value should be a number from the UIBarButtonSystemItem enumeration + * (https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIBarButtonItem_Class/#//apple_ref/c/tdef/UIBarButtonSystemItem) + * 0: Done + * 1: Cancel + * 2: Edit + * 3: Save + * 4: Add + * 5: FlexibleSpace + * 6: FixedSpace + * 7: Compose + * 8: Reply + * 9: Action + * 10: Organize + * 11: Bookmarks + * 12: Search + * 13: Refresh + * 14: Stop + * 15: Camera + * 16: Trash + * 17: Play + * 18: Pause + * 19: Rewind + * 20: FastForward + * 21: Undo + * 22: Redo + * 23: PageCurl + */ + systemIcon: number; + } + + /** + * Represents Android specific options of the action bar. + */ + export interface AndroidActionBarSettings { + + /** + * Gets or sets the action bar icon. + */ + icon: string; + + /** + * Gets or sets the visibility of the action bar icon. + * The icon is visible by default in pre-lollipop (API level < 20) versions of android and is hidden in lollipop (API level >= 20) + * The possible values are: + * 1. auto - the default behavior. This is the default value. + * 2. always - the icon is aways shown. + * 3. never - the icon is aways hidden. + */ + iconVisibility: string; + } + + /** + * Represents the navigation (a.k.a. "back") button. + */ + export class NavigationButton extends ActionItem { + + } + + +} diff --git a/definitions/tns-core-modules/ui/activity-indicator/activity-indicator.d.ts b/definitions/tns-core-modules/ui/activity-indicator/activity-indicator.d.ts new file mode 100644 index 0000000..33d3d3a --- /dev/null +++ b/definitions/tns-core-modules/ui/activity-indicator/activity-indicator.d.ts @@ -0,0 +1,32 @@ +/** + * Contains the ActivityIndicator class, which represents a widget for showing that something is currently busy. + */ +declare module "ui/activity-indicator" { + import view = require("ui/core/view"); + import dependencyObservable = require("ui/core/dependency-observable"); + + /** + * Represents a UI widget which displays a progress indicator hinting the user for some background operation running. + */ + export class ActivityIndicator extends view.View { + /** + * Represents the busy property of the ActivityIndicator class. + */ + public static busyProperty: dependencyObservable.Property; + + /** + * Gets the native [android widget](http://developer.android.com/reference/android/widget/ProgressBar.html) that represents the user interface for this component. Valid only when running on Android OS. + */ + android: any /* android.widget.ProgressBar */; + + /** + * Gets the native iOS [UIActivityIndicatorView](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIActivityIndicatorView_Class/index.html) that represents the user interface for this component. Valid only when running on iOS. + */ + ios: any /* UIActivityIndicatorView */; + + /** + * Gets or sets a value indicating whether the widget is currently displaying progress. + */ + busy: boolean; + } +} diff --git a/definitions/tns-core-modules/ui/animation/animation.d.ts b/definitions/tns-core-modules/ui/animation/animation.d.ts new file mode 100644 index 0000000..07549da --- /dev/null +++ b/definitions/tns-core-modules/ui/animation/animation.d.ts @@ -0,0 +1,96 @@ +declare module "ui/animation" { + import viewModule = require("ui/core/view"); + import colorModule = require("color"); + + /** + * Defines animation options for the View.animate method. + */ + export interface AnimationDefinition { + /** + * The view whose property is to be animated. + */ + target?: viewModule.View; + + /** + * Animates the opacity of the view. Value should be a number between 0.0 and 1.0 + */ + opacity?: number; + + /** + * Animates the backgroundColor of the view. + */ + backgroundColor?: colorModule.Color; + + /** + * Animates the translate affine transform of the view. + */ + translate?: Pair; + + /** + * Animates the scale affine transform of the view. + */ + scale?: Pair; + + /** + * Animates the rotate affine transform of the view. Value should be a number specifying the rotation amount in degrees. + */ + rotate?: number; + + /** + * The length of the animation in milliseconds. The default duration is 300 milliseconds. + */ + duration?: number; + + /** + * The amount of time, in milliseconds, to delay starting the animation. + */ + delay?: number; + + /** + * Specifies how many times the animation should be played. Default is 1. + * iOS animations support fractional iterations, i.e. 1.5. + * To repeat an animation infinitely, use Number.POSITIVE_INFINITY + */ + iterations?: number; + + /** + * An optional animation curve. Possible values are contained in the [AnimationCurve enumeration](../enums/AnimationCurve/README.md). + * Alternatively, you can pass an instance of type UIViewAnimationCurve for iOS or android.animation.TimeInterpolator for Android. + */ + curve?: any; + } + + /** + * Defines a custom animation timing curve by using the cubic-bezier function. + * Possible values are numeric values from 0 to 1 + */ + export class CubicBezierAnimationCurve { + + public x1: number; + public y1: number; + public x2: number; + public y2: number; + + constructor(x1: number, y1: number, x2: number, y2: number); + } + + /** + * Defines a pair of values (horizontal and vertical) for translate and scale animations. + */ + export interface Pair { + x: number; + y: number; + } + + /** + * Defines a animation set. + */ + export class Animation { + constructor(animationDefinitions: Array, playSequentially?: boolean); + public play: () => Promise; + public cancel: () => void; + public isPlaying: boolean; + } + + +} diff --git a/definitions/tns-core-modules/ui/border/border.d.ts b/definitions/tns-core-modules/ui/border/border.d.ts new file mode 100644 index 0000000..6f26cfa --- /dev/null +++ b/definitions/tns-core-modules/ui/border/border.d.ts @@ -0,0 +1,27 @@ +/** + * Contains the Border class, which represents a UI border component. + */ +declare module "ui/border" { + import contentView = require("ui/content-view"); + import color = require("color"); + + /** + * Represents a UI border component. + */ + export class Border extends contentView.ContentView { + /** + * Gets or sets the corner radius of the border component. + */ + cornerRadius: number; + + /** + * Gets or sets the border width of the border component. + */ + borderWidth: number; + + /** + * Gets or sets the border color of the border component. + */ + borderColor: color.Color; + } +} \ No newline at end of file diff --git a/definitions/tns-core-modules/ui/builder/builder.d.ts b/definitions/tns-core-modules/ui/builder/builder.d.ts new file mode 100644 index 0000000..930d827 --- /dev/null +++ b/definitions/tns-core-modules/ui/builder/builder.d.ts @@ -0,0 +1,15 @@ +declare module "ui/builder" { + import view = require("ui/core/view"); + import page = require("ui/page"); + + export function load(fileName: string, exports?: any): view.View; + export function load(options: LoadOptions): view.View; + export function parse(value: string | view.Template, exports?: any): view.View; + + export interface LoadOptions { + path: string; + name: string; + exports?: any; + page?: page.Page; + } +} diff --git a/definitions/tns-core-modules/ui/builder/component-builder.d.ts b/definitions/tns-core-modules/ui/builder/component-builder.d.ts new file mode 100644 index 0000000..24711fc --- /dev/null +++ b/definitions/tns-core-modules/ui/builder/component-builder.d.ts @@ -0,0 +1,11 @@ +declare module "ui/builder/component-builder" { + import view = require("ui/core/view"); + + export function getComponentModule(elementName: string, namespace: string, attributes: Object, exports: Object): ComponentModule; + export function setPropertyValue(instance: view.View, instanceModuleExports: Object, pageExports: Object, propertyName: string, propertyValue: string) : void; + + export interface ComponentModule { + component: view.View; + exports: any; + } +} diff --git a/definitions/tns-core-modules/ui/builder/special-properties.d.ts b/definitions/tns-core-modules/ui/builder/special-properties.d.ts new file mode 100644 index 0000000..66ed2b3 --- /dev/null +++ b/definitions/tns-core-modules/ui/builder/special-properties.d.ts @@ -0,0 +1,7 @@ +declare module "ui/builder/special-properties" { + import view = require("ui/core/view"); + + export type PropertySetter = (instance: view.View, propertyValue: string) => void; + export function registerSpecialProperty(name: string, setter: PropertySetter): void; + export function getSpecialPropertySetter(name: string): PropertySetter; +} diff --git a/definitions/tns-core-modules/ui/button/button.d.ts b/definitions/tns-core-modules/ui/button/button.d.ts new file mode 100644 index 0000000..66bb7d8 --- /dev/null +++ b/definitions/tns-core-modules/ui/button/button.d.ts @@ -0,0 +1,75 @@ +/** + * Contains the Button class, which represents a standard button widget. + */ +declare module "ui/button" { + import observable = require("data/observable"); + import dependencyObservable = require("ui/core/dependency-observable"); + import view = require("ui/core/view"); + import formattedString = require("text/formatted-string"); + + /** + * Represents a standard Button widget. + */ + export class Button extends view.View implements formattedString.FormattedStringView, view.AddChildFromBuilder { + /** + * Represents the observable property backing the text property of each Button instance. + */ + public static textProperty: dependencyObservable.Property; + + /** + * Dependency property used to support binding operations for the text wrapping of the current button instance. + */ + public static textWrapProperty: dependencyObservable.Property; + + /** + * String value used when hooking to tap event. + */ + public static tapEvent: string; + + /** + * Gets the native [android widget](http://developer.android.com/reference/android/widget/Button.html) that represents the user interface for this component. Valid only when running on Android OS. + */ + android: any /* android.widget.Button */; + + /** + * Gets the native [UIButton](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIButton_Class/) that represents the user interface for this component. Valid only when running on iOS. + */ + ios: any /* UIButton */; + + /** + * Gets or sets the text (label) displayed by this instance. + */ + text: string; + + /** + * Gets or sets whether the Button wraps text or not. + */ + textWrap: boolean; + + /** + * Gets or sets the formatted text (label) displayed by this instance. + */ + formattedText: formattedString.FormattedString; + + /** + * A basic method signature to hook an event listener (shortcut alias to the addEventListener method). + * @param eventNames - String corresponding to events (e.g. "propertyChange"). Optionally could be used more events separated by `,` (e.g. "propertyChange", "change"). + * @param callback - Callback function which will be executed when event is raised. + * @param thisArg - An optional parameter which will be used as `this` context for callback execution. + */ + on(eventNames: string, callback: (data: observable.EventData) => void, thisArg?: any); + + /** + * Raised when a tap event occurs. + */ + on(event: "tap", callback: (args: observable.EventData) => void, thisArg?: any); + + /** + * Called for every child element declared in xml. + * This method will add a child element (value) to current element. + * @param name - Name of the element. + * @param value - Value of the element. + */ + _addChildFromBuilder(name: string, value: any): void; + } +} diff --git a/definitions/tns-core-modules/ui/content-view/content-view.d.ts b/definitions/tns-core-modules/ui/content-view/content-view.d.ts new file mode 100644 index 0000000..f2545be --- /dev/null +++ b/definitions/tns-core-modules/ui/content-view/content-view.d.ts @@ -0,0 +1,23 @@ +/** + * + */ +declare module "ui/content-view" { + import view = require("ui/core/view"); + + /** + * Represents a View that has a single child - content. + * The View itself does not have visual representation and serves as a placeholder for its content in the logical tree. + */ + class ContentView extends view.View implements view.AddChildFromBuilder { + /** + * Gets or sets the single child of the view. + */ + content: view.View; + + + + _addChildFromBuilder(name: string, value: any): void; + + layoutView: view.View; + } +} \ No newline at end of file diff --git a/definitions/tns-core-modules/ui/core/bindable.d.ts b/definitions/tns-core-modules/ui/core/bindable.d.ts new file mode 100644 index 0000000..5938455 --- /dev/null +++ b/definitions/tns-core-modules/ui/core/bindable.d.ts @@ -0,0 +1,72 @@ +declare module "ui/core/bindable" { + import dependencyObservable = require("ui/core/dependency-observable"); + + /** + * The options object used in the Bindable.bind method. + */ + export interface BindingOptions { + /** + * The property name of the source object (typically the ViewModel) to bind to. + */ + sourceProperty: string; + /** + * The property name of the target object (that is the Bindable instance) to bind the source property to. + */ + targetProperty: string; + /** + * True to establish a two-way binding, false otherwise. A two-way binding will synchronize both the source and the target property values regardless of which one initiated the change. + */ + twoWay?: boolean; + /** + * An expression used for calculations (convertions) based on the value of the property. + */ + expression?: string; + } + + /** + * An interface which defines methods need to create binding value converter. + */ + export interface ValueConverter { + /** + * A method that will be executed when a value (of the binding property) should be converted to the observable model. + * For example: user types in a text field, but our business logic requires to store data in a different manner (e.g. in lower case). + * @param params - An array of parameters where first element is the value of the property and next elements are parameters send to converter. + */ + toModel: (...params: any[]) => any; + /** + * A method that will be executed when a value should be converted to the UI view. For example we have a date object which should be displayed to the end user in a specific date format. + * @param params - An array of parameters where first element is the value of the property and next elements are parameters send to converter. + */ + toView: (...params: any[]) => any; + } + + /** + * Represents an extended DependencyObservable object that supports data-binding. + */ + export class Bindable extends dependencyObservable.DependencyObservable { + /** + * Represents the dependency Property used to back the bindingContext value. + */ + public static bindingContextProperty: dependencyObservable.Property; + + /** + * Gets or sets the binding context of this instance. This object is used as a source for each Binding that does not have a source object specified. + */ + bindingContext: any; + /** + * Establishes a binding between the source object and this Bindable instance. + * @param options The options for the binding. + * @param source An optional parameter, specifying the source object to bind to. If no source is specified the bindingContext value (if any) will be used as a source. + */ + bind(options: BindingOptions, source?: Object); + /** + * Removes the existing binding (if any) for the specified property. + * @param property The name of the property to unbind. + */ + unbind(property: string); + + _onBindingContextChanged(oldValue: any, newValue: any); + + + } +} diff --git a/definitions/tns-core-modules/ui/core/control-state-change.d.ts b/definitions/tns-core-modules/ui/core/control-state-change.d.ts new file mode 100644 index 0000000..9522dc4 --- /dev/null +++ b/definitions/tns-core-modules/ui/core/control-state-change.d.ts @@ -0,0 +1,14 @@ +declare module "ui/core/control-state-change" { + /** + * An utility class used for supporting styling infrastructure. + */ + class ControlStateChangeListener { + + /** + * Initializes an instance of ControlStateChangeListener class. + * @param control An instance of the UIControl which state will be watched. + * @param callback A callback called when a visual state of the UIControl is changed. + */ + constructor(control: any /* UIControl */, callback: (state: string) => void); + } +} diff --git a/definitions/tns-core-modules/ui/core/dependency-observable.d.ts b/definitions/tns-core-modules/ui/core/dependency-observable.d.ts new file mode 100644 index 0000000..2152849 --- /dev/null +++ b/definitions/tns-core-modules/ui/core/dependency-observable.d.ts @@ -0,0 +1,293 @@ +/** + * Contains the DependencyObservable class, which represents an extended Observable object that uses Property instances for value backing mechanism. + */ +declare module "ui/core/dependency-observable" { + import observable = require("data/observable"); + + /** + * Interface used by Propery 'defaultValueGetter' function to specify if the default value returned by the native instance can be cached or not. + * One example is - android.widget.Button background. It is state drawable so it cannot be reused/cached. + */ + export interface NativeValueResult { + result: any; + cacheable: boolean; + } + + /** + * Represents a special Property which supports changed callback, metadata and value validation. + */ + export class Property { + /** + * Creates a new Property instance. + * @param name The name of the property. + * @param ownerType The name of class that registers this property. + * @param metadata The PropertyMetadata object associated with this property. + * @param valueConverter A function that can create an instance of the property type given a string. Used when parsing CSS and XML attribute values which are strings. + */ + constructor(name: string, ownerType: string, metadata: PropertyMetadata, valueConverter?: (value: string) => any); + + /** + * Gets the name of the property. This is a read-only property. + */ + name: string; + + /** + * Gets the id of the property. This is used for fast lookup. This is a read-only property. + */ + id: number; + + /** + * Gets the PropertyMetadata object associated with the property. This is a read-only property. + */ + metadata: PropertyMetadata; + + /** + * Gets the valueConverter function associated with the property. This is a read-only property. + */ + valueConverter: (value: string) => any + + /** + * Gets or sets the defaultValueGetter function used to get the default value for this property. + * If default value is 'undefined' and this property is set this function will be used to extract the default value from the native instance. + */ + defaultValueGetter: (instance: DependencyObservable) => NativeValueResult; + } + + /** + * Represents an Object that describes a Property instance. + */ + export class PropertyMetadata { + /** + * Creates a new PropertyMetadata instance. + * @param defaultValue The default value for the property. E.g. 0 for a numeric property. + * @param options An optional parameter that specifies how the associated property should be processed by the visual tree. Valid values are one or more bitwise combinations from the PropertyMetadataSettings module. + * @param onChanged An optional callback that will be raised whenever the associated property changes for any DependencyObservable instance that uses the property to store a value. + * @param onValidateValue An optional callback that will be raised prior to a change of the associated property for any DependencyObservable instance that uses the property. + * @param equalityComparer An optional function that used to compare if two property values are equal. + */ + constructor( + defaultValue: any, + options?: number, + onChanged?: PropertyChangedCallback, + onValidateValue?: PropertyValidationCallback, + equalityComparer?: PropertyEqualityComparer); + + /** + * Gets the options parameter passed to the constructor of this instance. This is a read-only property. + */ + options: number; + /** + * Gets the default value parameter passed to the constructor of this instance. This is a read-only property. + */ + defaultValue: any; + /** + * Gets or sets the callback to be raised whenever the associated property changes for any DependencyObservable instance that uses the property to store a value. + */ + onValueChanged: PropertyChangedCallback; + /** + * Gets or sets the callback to be raised whenever the associated property is about to change for any DependencyObservable instance that uses the property to store a value. + */ + onValidateValue: PropertyValidationCallback; + /** + * Gets function that used to compare if two property values are equal. + */ + equalityComparer: PropertyEqualityComparer; + /** + * Checks whether the PropertyMetadataSettings.affectsLayout bit is present in the options value. + */ + affectsLayout: boolean; + /** + * Checks whether the PropertyMetadataSettings.Inheritable bit is present in the options value. + */ + inheritable: boolean; + /** + * Checks whether the PropertyMetadataSettings.AffectsStyle bit is present in the options value. + */ + affectsStyle: boolean; + } + + /** + * The data for the event raised when a value of a Property changes for a DependencyObservable instance. + */ + export interface PropertyChangeData extends observable.EventData { + /** + * The Property associated with the change. + */ + property: Property; + /** + * The old property value. + */ + oldValue: any; + /** + * The new property value. + */ + newValue: any; + } + + /** + * Defines the signature of the function that handles the propertyChanged event. + */ + export interface PropertyChangedCallback { + (data: PropertyChangeData): void; + } + + /** + * Defines the signature of the function that handles the validateValue event. + */ + export interface PropertyValidationCallback { + (value: any): boolean; + } + + /** + * Defines the signature of the function that compares if two property values are equal. + */ + export interface PropertyEqualityComparer { + (x: any, y: any): boolean; + } + + /** + * Represents an Object that is used to back a value for a Property in a DependencyObservable Object instance. + */ + export class PropertyEntry { + /** + * Creates a new PropertyEntry instance, associated with the specified Property. + * @param property The Property this entry is attached to. + */ + constructor(property: Property); + /** + * Resets effective value and all the modifiers available for this entry. + */ + resetValue(): void; + + /** + * Gets the Property instance this entry is associated with. This is a read-only property. + */ + property: Property; + /** + * Gets the effective value of this entry. + * The value is composed depending on the current valueSource value, using the following priority: + * 1. VisualState + * 2. Local + * 3. Css + * 4. Inherited + * 5. Default + */ + effectiveValue: any; + /** + * Gets the source of the current effective value for this entry. The available options for this property are defined in the ValueSource namespace. + */ + valueSource: number; + /** + * Gets or sets the local value for this entry. This will trigger re-evaluation of the current effective value. + */ + localValue: any; + /** + * Gets or sets the inherited value for this entry. This will trigger re-evaluation of the current effective value. + */ + inheritedValue: any; + /** + * Gets or sets the css value for this entry. This will trigger re-evaluation of the current effective value. + */ + cssValue: any; + /** + * Gets or sets the visual-state value for this entry. This will trigger re-evaluation of the current effective value. + */ + visualStateValue: any; + } + + /** + * Represents an extended Observable Object that uses Property instances for value backing mechanism. + * This routine allows for various value modifiers per Property, which is used for inheritance, data-binding and styling purposes. + */ + export class DependencyObservable extends observable.Observable { + // TODO: Do we want to expose the get/setValue methods as public? + /** + * Gets a value for the property. + * @param property - A dependency property to retrieve a value for. + */ + _getValue(property: Property): any; + + /** + * Gets the value source (local, inherited) of a property. + * @param property - A dependency property to retrieve a value source for. + */ + _getValueSource(property: Property): number; + + /** + * Sets a value for a property. + * @param property - A dependency property to set. + * @param value - The new value. + * @param source(optional) - The value source (default is local). + */ + _setValue(property: Property, value: any, source?: number): void; + + /** + * Resets a value for a property. + * @param - property - A dependency property to reset. + * @param source(optional) - The value source (default is local). + */ + _resetValue(property: Property, source?: number): void; + + /** + * Handler for property changed event. + * @param property - A dependency property indentifier. + * @param oldValue - The old value of the property. + * @param newValue - The new value of the property. + */ + _onPropertyChanged(property: Property, oldValue: any, newValue: any): void; + + /** + * Iterates all the properties which have a PropertyEntry registered for this instance. + */ + _eachSetProperty(callback: (property: Property) => boolean): void; + //@endprivate + } + + /** + * Lists the possible values for the PropertyMetadata.options property. Each actual numeric value is a power of two allowing for bitwise operations. + */ + export module PropertyMetadataSettings { + /** + * No options are specified. This is the default value. + */ + export var None: number; + /** + * A change in the Property associated with the metadata will invalidate the layout. + */ + export var AffectsLayout; + /** + * The Property associated with the metadata is inheritable and its value should be propagated down in the visual tree. + */ + export var Inheritable: number; + /** + * A change in the Property associated with the metadata will cause all CSS styles to be re-evaluated for for owning element. + */ + export var AffectsStyle: number; + } + + /** + * Lists the possible values for the PropertyEntry.valueSource property. + */ + export module ValueSource { + /** + * Default value, coming from the PropertyMetadata.defaultValue. + */ + export var Default: number; + /** + * Inherited value, coming from the logical parent of the current DependencyObservable instance. + */ + export var Inherited: number; + /** + * Css value, coming a css selector and rule that matches the current DependencyObservable instance. + */ + export var Css: number; + /** + * Local value, set directly to the current DependencyObservable instance. + */ + export var Local: number; + /** + * VisualState value, coming from a visual-state css selector. E.g. { button:pressed }. + */ + export var VisualState: number; + } +} \ No newline at end of file diff --git a/definitions/tns-core-modules/ui/core/proxy.d.ts b/definitions/tns-core-modules/ui/core/proxy.d.ts new file mode 100644 index 0000000..1763c85 --- /dev/null +++ b/definitions/tns-core-modules/ui/core/proxy.d.ts @@ -0,0 +1,60 @@ +declare module "ui/core/proxy" { + import dependencyObservable = require("ui/core/dependency-observable"); + import bindable = require("ui/core/bindable"); + + /** + * A class that describes dependency property metadata. + */ + class PropertyMetadata extends dependencyObservable.PropertyMetadata { + /** + * Gets or sets a dependencyObservable.PropertyChangedCallback which is used to set the value on native side. + */ + public onSetNativeValue: dependencyObservable.PropertyChangedCallback; + + /** + * Initializes a new instance of PropertyMetadata class. + * @param defaultValue A value to be used as default value for the dependency property. + * @param options (optional) A value that states how this property affects visual tree. + * @param onChanged (optional) A callback function which will be executed when value of the dependency property is changed. + * @param onValidateValue (optional) A callback function which will be executed to validate the value of the dependency property. + * @param onSetNativeValue (optional) A callback function which will be executed to set the value on native side. + */ + constructor( + defaultValue: any, + options?: number, + onChanged?: dependencyObservable.PropertyChangedCallback, + onValidateValue?: dependencyObservable.PropertyValidationCallback, + onSetNativeValue?: dependencyObservable.PropertyChangedCallback); + } + + /** + * A class that serves as a proxy between JavaScript object and native object. + * Used in cases when native instance is not avaibale yet (stores all properties). + */ + class ProxyObject extends bindable.Bindable { + /** + * Gets the android-specific native instance that lies behind this proxy. Will be available if running on an Android platform. + */ + public android: any; + + /** + * Gets the ios-specific native instance that lies behind this proxy. Will be available if running on an iOS platform. + */ + public ios: any; + + /** + * A property is changed. + */ + public _onPropertyChanged(property: dependencyObservable.Property, oldValue: any, newValue: any): void; + + /** + * A property has changed on the native side directly - e.g. the user types in a TextField. + */ + public _onPropertyChangedFromNative(property: dependencyObservable.Property, newValue: any): void; + + /** + * Synchronizes all properties with native values. + */ + public _syncNativeProperties(): void; + } +} \ No newline at end of file diff --git a/definitions/tns-core-modules/ui/core/view.d.ts b/definitions/tns-core-modules/ui/core/view.d.ts new file mode 100644 index 0000000..9595a3f --- /dev/null +++ b/definitions/tns-core-modules/ui/core/view.d.ts @@ -0,0 +1,570 @@ +declare module "ui/core/view" { + import style = require("ui/styling"); + import dependencyObservable = require("ui/core/dependency-observable"); + import proxy = require("ui/core/proxy"); + import gestures = require("ui/gestures"); + import color = require("color"); + import observable = require("data/observable"); + import animation = require("ui/animation"); + + /** + * Gets a child view by id. + * @param view - The parent (container) view of the view to look for. + * @param id - The id of the view to look for. + * Returns an instance of a view (if found), otherwise undefined. + */ + export function getViewById(view: View, id: string): View; + + /** + * Iterates through all child views (via visual tree) and executes a function. + * @param view - Starting view (parent container). + * @param callback - A function to execute on every child. If function returns false it breaks the iteration. + */ + export function eachDescendant(view: View, callback: (child: View) => boolean); + + /** + * Gets an ancestor from a given type. + * @param view - Starting view (child view). + * @param criterion - The type of ancestor view we are looking for. Could be a string containing a class name or an actual type. + * Returns an instance of a view (if found), otherwise undefined. + */ + export function getAncestor(view: View, criterion: string | Function): View; + + export function isEventOrGesture(name: string, view: View): boolean; + + /** + * Defines interface for an optional parameter used to create a view. + */ + export interface Options { + /** + * Gets or sets the desired width of the view. + */ + width?: number; + /** + * Gets or sets the desired height of the view. + */ + height?: number; + /** + * Gets or sets the minimum width the view may grow to. + */ + minWidth?: number; + /** + * Gets or sets the minimum height the view may grow to. + */ + minHeight?: number; + /** + * Gets or sets the alignment of this view within its parent along the Horizontal axis. + */ + horizontalAlignment?: string; + /** + * Gets or sets the alignment of this view within its parent along the Vertical axis. + */ + verticalAlignment?: string; + /** + * Specifies extra space on the left side of this view. + */ + marginLeft: number; + + /** + * Specifies extra space on the top side of this view. + */ + marginTop: number; + + /** + * Specifies extra space on the right side of this view. + */ + marginRight: number; + + /** + * Specifies extra space on the bottom side of this view. + */ + marginBottom: number; + /** + * Gets or sets the visibility of this view. + */ + visibility?: string; + /** + * [Deprecated. Please use className instead] Gets or sets the CSS class of this view. + */ + cssClass?: string; + + /** + * Gets or sets the CSS class name of this view. + */ + className?: string; + /** + * Gets or sets the id of this view. + */ + id?: string; + } + + /** + * This class is the base class for all UI components. + * A View occupies a rectangular area on the screen and is responsible for drawing and layouting of all UI components within. + */ + export class View extends proxy.ProxyObject implements ApplyXmlAttributes { + /** + * Gets or sets the corner radius of the view. + */ + borderRadius: number; + + /** + * Gets or sets the border width of the view. + */ + borderWidth: number; + + /** + * Gets or sets the border color of the view. + */ + borderColor: color.Color; + + /** + * Gets or sets the automation text of the view. + */ + automationText: string; + + /** + * String value used when hooking to loaded event. + */ + public static loadedEvent: string; + + /** + * String value used when hooking to unloaded event. + */ + public static unloadedEvent: string; + + /** + * Represents the observable property backing the automationText property of each View. + */ + public static automationTextProperty: dependencyObservable.Property; + + /** + * Represents the observable property backing the id property of each View. + */ + public static idProperty: dependencyObservable.Property; + + /** + * [Deprecated. Please use className instead.] Represents the observable property backing the cssClass property of each View. + */ + public static cssClassProperty: dependencyObservable.Property; + + /** + * Represents the observable property backing the className property of each View. + */ + public static classNameProperty: dependencyObservable.Property; + + /** + * Represents the observable property backing the isEnabled property of each View. + */ + public static isEnabledProperty: dependencyObservable.Property; + + /** + * Represents the observable property backing the isUserInteractionEnabled property of each View. + */ + public static isUserInteractionEnabledProperty: dependencyObservable.Property; + + constructor(options?: Options); + + //----------Style property shortcuts---------- + + /** + * Gets or sets the color of the view. + */ + color: color.Color; + + /** + * Gets or sets the background color of the view. + */ + backgroundColor: color.Color; + + /** + * Gets or sets the background image of the view. + */ + backgroundImage: string; + + /** + * Gets or sets the minimum width the view may grow to. + */ + minWidth: number; + + /** + * Gets or sets the minimum height the view may grow to. + */ + minHeight: number; + + /** + * Gets or sets the desired width of the view. + */ + width: number; + + /** + * Gets or sets the desired height of the view. + */ + height: number; + + /** + * Gets or sets margin style property. + */ + margin: string; + + /** + * Specifies extra space on the left side of this view. + */ + marginLeft: number; + + /** + * Specifies extra space on the top side of this view. + */ + marginTop: number; + + /** + * Specifies extra space on the right side of this view. + */ + marginRight: number; + + /** + * Specifies extra space on the bottom side of this view. + */ + marginBottom: number; + + /** + * Gets or sets the alignment of this view within its parent along the Horizontal axis. + */ + horizontalAlignment: string; + + /** + * Gets or sets the alignment of this view within its parent along the Vertical axis. + */ + verticalAlignment: string; + + /** + * Gets or sets the visibility of the view. + */ + visibility: string; + + /** + * Gets or sets the opacity style property. + */ + opacity: number; + + //----------Style property shortcuts---------- + + /** + * Gets or sets the translateX affine transform of the view. + */ + translateX: number; + + /** + * Gets or sets the translateY affine transform of the view. + */ + translateY: number; + + /** + * Gets or sets the scaleX affine transform of the view. + */ + scaleX: number; + + /** + * Gets or sets the scaleY affine transform of the view. + */ + scaleY: number; + + /** + * Gets or sets the X component of the origin point around which the view will be transformed. The deafault value is 0.5 representing the center of the view. + */ + originX: number; + + /** + * Gets or sets the Y component of the origin point around which the view will be transformed. The deafault value is 0.5 representing the center of the view. + */ + originY: number; + + /** + * Gets or sets the rotate affine transform of the view. + */ + rotate: number; + + /** + * Gets or sets a value indicating whether the the view is enabled. This affects the appearance of the view. + */ + isEnabled: boolean; + + /** + * Gets or sets a value indicating whether the user can interact with the view. This does not affect the appearance of the view. + */ + isUserInteractionEnabled: boolean; + + /** + * Gets or sets the id for this view. + */ + id: string; + + /** + * [Deprecated. Please use className instead.] Gets or sets the CSS class for this view. + */ + cssClass: string; + + /** + * Gets or sets the CSS class name for this view. + */ + className: string; + + /** + * Gets the style object associated to this view. + */ + style: style.Style; + + /** + * Gets the View instance that parents this view. This property is read-only. + */ + parent: View; + + /** + * Gets is layout is valid. This is a read-only property. + */ + isLayoutValid: boolean; + + cssType: string; + + visualState: string; + + /** + * Gets owner page. This is a read-only property. + */ + page: View; + + /** + * This is called to find out how big a view should be. The parent supplies constraint information in the width and height parameters. + * The actual measurement work of a view is performed in onMeasure(int, int), called by this method. Therefore, only onMeasure(int, int) can and must be overridden by subclasses. + * @param widthMeasureSpec Horizontal space requirements as imposed by the parent + * @param heightMeasureSpec Vertical space requirements as imposed by the parent + */ + public measure(widthMeasureSpec: number, heightMeasureSpec: number): void; + + /** + * Assign a size and position to a view and all of its descendants + * This is the second phase of the layout mechanism. (The first is measuring). In this phase, each parent calls layout on all of its children to position them. This is typically done using the child measurements that were stored in the measure pass(). + * Derived classes should not override this method. Derived classes with children should override onLayout. In that method, they should call layout on each of their children. + * @param l Left position, relative to parent + * @param t Top position, relative to parent + * @param r Right position, relative to parent + * @param b Bottom position, relative to parent + */ + public layout(left: number, top: number, right: number, bottom: number): void; + + /** + * Returns the raw width component. + */ + public getMeasuredWidth(): number; + + /** + * Returns the raw height component. + */ + public getMeasuredHeight(): number; + + /** + * Call this when something has changed which has invalidated the layout of this view. This will schedule a layout pass of the view tree. + */ + public requestLayout(): void; + + /** + * Measure the view and its content to determine the measured width and the measured height. This method is invoked by measure(int, int) and should be overriden by subclasses to provide accurate and efficient measurement of their contents. + * When overriding this method, you must call setMeasuredDimension(int, int) to store the measured width and height of this view. Failure to do so will trigger an exception, thrown by measure(int, int). + * @param widthMeasureSpec horizontal space requirements as imposed by the parent. The requirements are encoded with View.MeasureSpec. + * @param heightMeasureSpec vertical space requirements as imposed by the parent. The requirements are encoded with View.MeasureSpec. + */ + public onMeasure(widthMeasureSpec: number, heightMeasureSpec: number): void; + + /** + * Called from layout when this view should assign a size and position to each of its children. Derived classes with children should override this method and call layout on each of their children. + * @param left Left position, relative to parent + * @param top Top position, relative to parent + * @param right Right position, relative to parent + * @param bottom Bottom position, relative to parent + */ + public onLayout(left: number, top: number, right: number, bottom: number): void; + + /** + * This method must be called by onMeasure(int, int) to store the measured width and measured height. Failing to do so will trigger an exception at measurement time. + * @param measuredWidth The measured width of this view. May be a complex bit mask as defined by MEASURED_SIZE_MASK and MEASURED_STATE_TOO_SMALL. + * @param measuredHeight The measured height of this view. May be a complex bit mask as defined by MEASURED_SIZE_MASK and MEASURED_STATE_TOO_SMALL. + */ + public setMeasuredDimension(measuredWidth: number, measuredHeight: number): void; + + /** + * Called from onLayout when native view position is about to be changed. + * @param parent This parameter is not used. You can pass null. + * @param left Left position, relative to parent + * @param top Top position, relative to parent + * @param right Right position, relative to parent + * @param bottom Bottom position, relative to parent + */ + public layoutNativeView(left: number, top: number, right: number, bottom: number): void; + + /** + * Measure a child by taking into account its margins and a given measureSpecs. + * @param parent This parameter is not used. You can pass null. + * @param child The view to be measured. + * @param measuredWidth The measured width that the parent layout specifies for this view. + * @param measuredHeight The measured height that the parent layout specifies for this view. + */ + public static measureChild(parent: View, child: View, widthMeasureSpec: number, heightMeasureSpec: number): { measuredWidth: number; measuredHeight: number }; + + /** + * Layout a child by taking into account its margins, horizontal and vertical alignments and a given bounds. + * @param parent This parameter is not used. You can pass null. + * @param left Left position, relative to parent + * @param top Top position, relative to parent + * @param right Right position, relative to parent + * @param bottom Bottom position, relative to parent + */ + public static layoutChild(parent: View, child: View, left: number, top: number, right: number, bottom: number): void; + + /** + * Utility to reconcile a desired size and state, with constraints imposed + * by a MeasureSpec. Will take the desired size, unless a different size + * is imposed by the constraints. The returned value is a compound integer, + * with the resolved size in the {@link #MEASURED_SIZE_MASK} bits and + * optionally the bit {@link #MEASURED_STATE_TOO_SMALL} set if the resulting + * size is smaller than the size the view wants to be. + */ + public static resolveSizeAndState(size: number, specSize: number, specMode: number, childMeasuredState: number): number; + + /** + * Returns the child view with the specified id. + */ + getViewById(id: string): T; + + /** + * Tries to focus the view. + * Returns a value indicating whether this view or one of its descendants actually took focus. + */ + public focus(): boolean; + + /** + * Sets in-line CSS string as style. + * @param style - In-line CSS string. + */ + public setInlineStyle(style: string): void; + + public getGestureObservers(type: gestures.GestureTypes): Array; + + /** + * [Deprecated. Please use the on() instead.] Adds a gesture observer. + * @param type - Type of the gesture. + * @param callback - A function that will be executed when gesture is received. + * @param thisArg - An optional parameter which will be used as `this` context for callback execution. + */ + observe(type: gestures.GestureTypes, callback: (args: gestures.GestureEventData) => void, thisArg?: any); + + /** + * A basic method signature to hook an event listener (shortcut alias to the addEventListener method). + * @param eventNames - String corresponding to events (e.g. "propertyChange"). Optionally could be used more events separated by `,` (e.g. "propertyChange", "change") or you can use gesture types. + * @param callback - Callback function which will be executed when event is raised. + * @param thisArg - An optional parameter which will be used as `this` context for callback execution. + */ + on(eventNames: string | gestures.GestureTypes, callback: (data: observable.EventData) => void, thisArg?: any); + + /** + * Removes listener(s) for the specified event name. + * @param eventNames Comma delimited names of the events or gesture types the specified listener is associated with. + * @param callback An optional parameter pointing to a specific listener. If not defined, all listeners for the event names will be removed. + * @param thisArg An optional parameter which when set will be used to refine search of the correct callback which will be removed as event listener. + */ + off(eventNames: string | gestures.GestureTypes, callback?: any, thisArg?: any); + + /** + * Raised when a loaded event occurs. + */ + on(event: "loaded", callback: (args: observable.EventData) => void, thisArg?: any); + + /** + * Raised when an unloaded event occurs. + */ + on(event: "unloaded", callback: (args: observable.EventData) => void, thisArg?: any); + + public animate(options: animation.AnimationDefinition): Promise; + public createAnimation(options: animation.AnimationDefinition): animation.Animation; + + // Lifecycle events + onLoaded(): void; + onUnloaded(): void; + isLoaded: boolean; + + _addView(view: View, atIndex?: number); + _propagateInheritableProperties(view: View) + _inheritProperties(parentView: View) + _removeView(view: View); + _context: any /* android.content.Context */; + + _childIndexToNativeChildIndex(index?: number): number; + _getNativeViewsCount(): number; + + _eachLayoutView(callback: (View) => void): void; + + _addToSuperview(superview: any, index?: number): boolean; + _removeFromSuperview(); + + public _applyXmlAttribute(attribute: string, value: any): boolean; + + // TODO: Implement logic for stripping these lines out + + } + + /** + * Base class for all UI components that implements custom layouts. + */ + export class CustomLayoutView extends View { + } + + /** + * Defines an interface for a View factory function. + * Commonly used to specify the visualization of data objects. + */ + interface Template { + /** + * Call signature of the factory function. + * Returns a new View instance. + */ + (): View; + } + + /** + * Defines an interface for adding arrays declared in xml. + */ + interface AddArrayFromBuilder { + /** + * A function that is called when an array declaration is found in xml. + * @param name - Name of the array. + * @param value - The actual value of the array. + */ + _addArrayFromBuilder(name: string, value: Array): void; + } + + /** + * Defines an interface for adding a child element declared in xml. + */ + interface AddChildFromBuilder { + /** + * Called for every child element declared in xml. + * This method will add a child element (value) to current element. + * @param name - Name of the element. + * @param value - Value of the element. + */ + _addChildFromBuilder(name: string, value: any): void; + } + + /** + * Defines an interface used to create a member of a class from string representation (used in xml declaration). + */ + interface ApplyXmlAttributes { + /** + * Called for every attribute in xml declaration. <... fontAttributes="bold" ../> + * @param attributeName - the name of the attribute (fontAttributes) + * @param attrValue - the value of the attribute (bold) + * Should return true if this attribute is handled and there is no need default handler to process it. + */ + _applyXmlAttribute(attributeName: string, attrValue: any): boolean; + } + +} diff --git a/definitions/tns-core-modules/ui/core/weak-event-listener.d.ts b/definitions/tns-core-modules/ui/core/weak-event-listener.d.ts new file mode 100644 index 0000000..e1b8430 --- /dev/null +++ b/definitions/tns-core-modules/ui/core/weak-event-listener.d.ts @@ -0,0 +1,21 @@ +declare module "ui/core/weak-event-listener" { + import observable = require("data/observable"); + + /** + * Attaches a WeakEventListener. + * @param source Observable class which emits the event. + * @param eventName The event name. + * @param handler The function which should be called when event occurs. + * @param target Subscriber (target) of the event listener. It will be used as a thisArg in the handler function. + */ + export function addWeakEventListener(source: observable.Observable, eventName: string, handler: (eventData: observable.EventData) => void, target: any) : void; + + /** + * Removes a WeakEventListener. + * @param source Observable class which emits the event. + * @param eventName The event name. + * @param handler The function which should be called when event occurs. + * @param target Subscriber (target) of the event listener. It will be used as a thisArg in the handler function. + */ + export function removeWeakEventListener(source: observable.Observable, eventName: string, handler: (eventData: observable.EventData) => void, target: any): void; +} \ No newline at end of file diff --git a/definitions/tns-core-modules/ui/date-picker/date-picker.d.ts b/definitions/tns-core-modules/ui/date-picker/date-picker.d.ts new file mode 100644 index 0000000..6408e7f --- /dev/null +++ b/definitions/tns-core-modules/ui/date-picker/date-picker.d.ts @@ -0,0 +1,53 @@ +/** + * Contains the DatePicker class. + */ +declare module "ui/date-picker" { + import view = require("ui/core/view"); + import dependencyObservable = require("ui/core/dependency-observable"); + + /** + * Represents an date picker. + */ + export class DatePicker extends view.View { + public static yearProperty: dependencyObservable.Property; + public static monthProperty: dependencyObservable.Property; + public static dayProperty: dependencyObservable.Property; + + constructor(); + + /** + * Gets the native [android.widget.DatePicker](http://developer.android.com/reference/android/widget/DatePicker.html) that represents the user interface for this component. Valid only when running on Android OS. + */ + android: any /* android.widget.DatePicker */; + + /** + * Gets the native iOS [UIDatePicker](http://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UIDatePicker_Class/index.html) that represents the user interface for this component. Valid only when running on iOS. + */ + ios: any /* UIDatePicker */; + + /** + * Gets or sets the year. + */ + year: number; + + /** + * Gets or sets the month. The months start from 1. + */ + month: number; + + /** + * Gets or sets the day. The days start from 1. + */ + day: number; + + /** + * Gets or sets the max date. + */ + maxDate: Date; + + /** + * Gets or sets the min date. + */ + minDate: Date; + } +} diff --git a/definitions/tns-core-modules/ui/dialogs/dialogs.d.ts b/definitions/tns-core-modules/ui/dialogs/dialogs.d.ts new file mode 100644 index 0000000..ffb3b8b --- /dev/null +++ b/definitions/tns-core-modules/ui/dialogs/dialogs.d.ts @@ -0,0 +1,225 @@ +/** + * Allows you to show different dialogs such as alerts, prompts, etc. + */ +declare module "ui/dialogs" { + /** + * Defines the input type for prompt dialog. + */ + export module inputType { + /** + * Plain text input type. + */ + export var text: string; + + /** + * Password input type. + */ + export var password: string; + } + + /** + * The alert() method displays an alert box with a specified message. + * @param message Specifies the text to display in the alert box. + */ + export function alert(message: string): Promise; + + /** + * The alert() method displays an alert box with a specified message. + * @param options Specifies the options for the alert box. + */ + export function alert(options: AlertOptions): Promise; + + /** + * The confirm() method displays a dialog box with a specified message. + * @param message Specifies the text to display in the confirm box. + */ + export function confirm(message: string): Promise; + + /** + * The confirm() method displays a dialog box with a specified message. + * @param options Specifies the options for the confirm box. + */ + export function confirm(options: ConfirmOptions): Promise; + + /** + * The prompt() method displays a dialog box that prompts the visitor for input. + * @param message The text to display in the dialog box. + * @param defaultText The default text to display in the input box. Optional. + */ + export function prompt(message: string, defaultText?: string): Promise; + + /** + * The prompt() method displays a dialog box that prompts the visitor for input. + * @param options The options for the dialog box. + */ + export function prompt(options: PromptOptions): Promise; + + /** + * The login() method displays a login dialog box that prompts the visitor for user name and password. + * @param message The text to display in the dialog box. + * @param userName The default text to display in the user name input box. Optional. + * @param password The default text to display in the password input box. Optional. + */ + export function login(message: string, userName?: string, password?: string): Promise; + + /** + * The login() method displays a login dialog box that prompts the visitor for user name and password. + * @param options The options for the dialog box. + */ + export function login(options: LoginOptions): Promise; + + /** + * The action() method displays a action box that prompts the visitor to choose some action. + * @param message The text to display in the dialog box. + * @param cancelButtonText The text to display in the cancel button. + * @param actions List of available actions. + */ + export function action(message: string, cancelButtonText: string, actions: Array): Promise; + + /** + * The action() method displays a action box that prompts the visitor to choose some action. + * @param options The options for the dialog box. + */ + export function action(options: ActionOptions): Promise; + + /** + * Provides options for the dialog. + */ + export interface CancelableOptions { + /** + * [Android only] Gets or sets if the dialog can be canceled by taping outside of the dialog. + */ + cancelable?: boolean; + } + + /** + * Provides options for the dialog. + */ + export interface ActionOptions extends CancelableOptions { + /** + * Gets or sets the dialog title. + */ + title?: string; + + /** + * Gets or sets the dialog message. + */ + message?: string; + + /** + * Gets or sets the Cancel button text. + */ + cancelButtonText?: string; + + /** + * Gets or sets the list of available actions. + */ + actions?: Array; + } + + /** + * Provides options for the dialog. + */ + export interface DialogOptions extends CancelableOptions { + /** + * Gets or sets the dialog title. + */ + title?: string; + + /** + * Gets or sets the dialog message. + */ + message?: string; + + } + + /** + * Provides options for the alert. + */ + export interface AlertOptions extends DialogOptions { + /** + * Gets or sets the OK button text. + */ + okButtonText?: string; + } + + /** + * Provides options for the confirm dialog. + */ + export interface ConfirmOptions extends AlertOptions { + /** + * Gets or sets the Cancel button text. + */ + cancelButtonText?: string; + + /** + * Gets or sets the neutral button text. + */ + neutralButtonText?: string; + } + + /** + * Provides options for the prompt dialog. + */ + export interface PromptOptions extends ConfirmOptions { + /** + * Gets or sets the default text to display in the input box. + */ + defaultText?: string; + + /** + * Gets or sets the prompt input type (plain text or password). + */ + inputType?: string; + } + + /** + * Provides options for the login dialog. + */ + export interface LoginOptions extends ConfirmOptions { + /** + * Gets or sets the default text to display in the user name input box. + */ + userName?: string; + + /** + * Gets or sets the default text to display in the password input box. + */ + password?: string; + } + + /** + * Provides result data from the prompt dialog. + */ + export interface PromptResult { + /** + * Gets or sets the prompt dialog boolean result. + */ + result: boolean; + + /** + * Gets or sets the text entered in the prompt dialog. + */ + text: string; + } + + /** + * Provides result data from the login dialog. + */ + export interface LoginResult { + /** + * Gets or sets the login dialog boolean result. + */ + result: boolean; + + /** + * Gets or sets the user entered in the login dialog. + */ + userName: string; + + /** + * Gets or sets the password entered in the login dialog. + */ + password: string; + } +} \ No newline at end of file diff --git a/definitions/tns-core-modules/ui/editable-text-base/editable-text-base.d.ts b/definitions/tns-core-modules/ui/editable-text-base/editable-text-base.d.ts new file mode 100644 index 0000000..947219f --- /dev/null +++ b/definitions/tns-core-modules/ui/editable-text-base/editable-text-base.d.ts @@ -0,0 +1,99 @@ +declare module "ui/editable-text-base" { + import dependencyObservable = require("ui/core/dependency-observable"); + import textBase = require("ui/text-base"); + + /** + * Represents the base class for all editable text views. + */ + export class EditableTextBase extends textBase.TextBase { + public static keyboardTypeProperty: dependencyObservable.Property; + public static returnKeyTypeProperty: dependencyObservable.Property; + public static editableProperty: dependencyObservable.Property; + public static updateTextTriggerProperty: dependencyObservable.Property; + public static autocapitalizationTypeProperty: dependencyObservable.Property; + public static autocorrectProperty: dependencyObservable.Property; + + constructor(options?: Options); + + /** + * Gets or sets the soft keyboard type. Possible values are contained in the [KeyboardType enumeration](../enums/KeyboardType/README.md). + */ + keyboardType: string; + + /** + * Gets or sets the soft keyboard return key flavor. Possible values are contained in the [ReturnKeyType enumeration](../enums/ReturnKeyType/README.md). + */ + returnKeyType: string; + + /** + * Gets or sets whether the instance is editable. + */ + editable: boolean; + + /** + * Gets or sets a value indicating when the text property will be updated. + * Possible values are contained in the [UpdateTextTrigger enumeration](../enums/UpdateTextTrigger/README.md). + */ + updateTextTrigger: string; + + /** + * Gets or sets the autocapitalization type. Possible values are contained in the [AutocapitalizationType enumeration](../enums/AutocapitalizationType/README.md). + */ + autocapitalizationType: string; + + /** + * Enables or disables autocorrection. + */ + autocorrect: boolean; + + /** + * Gets or sets the placeholder text. + */ + hint: string; + + /** + * Hides the soft input method, ususally a soft keyboard. + */ + dismissSoftInput(): void; + } + + /** + * An interface for common options used to create an editable text component. + */ + export interface Options extends textBase.Options { + /** + * Gets or sets the soft keyboard type. + */ + keyboardType?: string; + + /** + * Gets or sets the soft keyboard return key flavor. + */ + returnKeyType?: string; + + /** + * Gets or sets whether the instance is editable. + */ + editable?: boolean; + + /** + * Gets or sets a value indicating when the text property will be updated. + */ + updateTextTrigger?: string; + + /** + * Gets or sets the autocapitalization type. + */ + autocapitalizationType?: string; + + /** + * Gets or sets the placeholder text. + */ + hint?: string; + + /** + * Enables or disables autocorrection. + */ + autocorrect?: boolean; + } +} \ No newline at end of file diff --git a/definitions/tns-core-modules/ui/enums/enums.d.ts b/definitions/tns-core-modules/ui/enums/enums.d.ts new file mode 100644 index 0000000..6be324f --- /dev/null +++ b/definitions/tns-core-modules/ui/enums/enums.d.ts @@ -0,0 +1,558 @@ +declare module "ui/enums" { + + import animationModule = require("ui/animation"); + + /** + * Represents a soft keyboard flavor. + */ + module KeyboardType { + /** + * Android: [TYPE_CLASS_DATETIME](http://developer.android.com/reference/android/text/InputType.html#TYPE_CLASS_DATETIME) | [TYPE_DATETIME_VARIATION_NORMAL](http://developer.android.com/reference/android/text/InputType.html#TYPE_DATETIME_VARIATION_NORMAL) + * iOS: [UIKeyboardTypeNumbersAndPunctuation](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITextInputTraits_Protocol/index.html#//apple_ref/c/tdef/UIKeyboardType) + */ + export var datetime: string; + + /** + * Android: [TYPE_CLASS_PHONE](http://developer.android.com/reference/android/text/InputType.html#TYPE_CLASS_PHONE) + * iOS: [UIKeyboardTypePhonePad](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITextInputTraits_Protocol/index.html#//apple_ref/c/tdef/UIKeyboardType) + */ + export var phone: string; + + /** + * Android: [TYPE_CLASS_NUMBER](http://developer.android.com/reference/android/text/InputType.html#TYPE_CLASS_NUMBER) | android.text.InputType.TYPE_NUMBER_VARIATION_NORMAL | [TYPE_NUMBER_FLAG_SIGNED](http://developer.android.com/reference/android/text/InputType.html#TYPE_NUMBER_FLAG_SIGNED) | [TYPE_NUMBER_FLAG_DECIMAL](http://developer.android.com/reference/android/text/InputType.html#TYPE_NUMBER_FLAG_DECIMAL) + * iOS: [UIKeyboardTypeNumbersAndPunctuation](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITextInputTraits_Protocol/index.html#//apple_ref/c/tdef/UIKeyboardType) + */ + export var number: string; + + /** + * Android: [TYPE_CLASS_TEXT](http://developer.android.com/reference/android/text/InputType.html#TYPE_CLASS_TEXT) | [TYPE_TEXT_VARIATION_URI](http://developer.android.com/reference/android/text/InputType.html#TYPE_TEXT_VARIATION_URI) + * iOS: [UIKeyboardTypeURL](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITextInputTraits_Protocol/index.html#//apple_ref/c/tdef/UIKeyboardType) + */ + export var url: string; + + /** + * Android: [TYPE_CLASS_TEXT](http://developer.android.com/reference/android/text/InputType.html#TYPE_CLASS_TEXT) | [TYPE_TEXT_VARIATION_EMAIL_ADDRESS](http://developer.android.com/reference/android/text/InputType.html#TYPE_TEXT_VARIATION_EMAIL_ADDRESS) + * iOS: [UIKeyboardTypeEmailAddress](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITextInputTraits_Protocol/index.html#//apple_ref/c/tdef/UIKeyboardType) + */ + export var email: string; + } + + /** + * Represents the flavor of the return key on the soft keyboard. + */ + module ReturnKeyType { + /** + * Android: [IME_ACTION_DONE](http://developer.android.com/reference/android/view/inputmethod/EditorInfo.html#IME_ACTION_DONE) + * iOS: [UIReturnKeyDone](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITextInputTraits_Protocol/index.html#//apple_ref/c/tdef/UIReturnKeyType) + */ + export var done: string; + + /** + * Android: [IME_ACTION_NEXT](http://developer.android.com/reference/android/view/inputmethod/EditorInfo.html#IME_ACTION_NEXT) + * iOS: [UIReturnKeyNext](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITextInputTraits_Protocol/index.html#//apple_ref/c/tdef/UIReturnKeyType) + */ + export var next: string; + + /** + * Android: [IME_ACTION_GO](http://developer.android.com/reference/android/view/inputmethod/EditorInfo.html#IME_ACTION_GO) + * iOS: [UIReturnKeyGo](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITextInputTraits_Protocol/index.html#//apple_ref/c/tdef/UIReturnKeyType) + */ + export var go: string; + + /** + * Android: [IME_ACTION_SEARCH](http://developer.android.com/reference/android/view/inputmethod/EditorInfo.html#IME_ACTION_SEARCH) + * iOS: [UIReturnKeySearch](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITextInputTraits_Protocol/index.html#//apple_ref/c/tdef/UIReturnKeyType) + */ + export var search: string; + + /** + * Android: [IME_ACTION_SEND](http://developer.android.com/reference/android/view/inputmethod/EditorInfo.html#IME_ACTION_SEND) + * iOS: [UIReturnKeySend](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITextInputTraits_Protocol/index.html#//apple_ref/c/tdef/UIReturnKeyType) + */ + export var send: string; + } + + /** + * Represents a text-align enumeration. + */ + module TextAlignment { + /** + * Represents left text-align. + */ + export var left: string; + + /** + * Represents center text-align. + */ + export var center: string; + + /** + * Represents right text-align. + */ + export var right: string; + } + + /** + * Orientation indicates a direction of a layout that can exist in a horizontal or vertical state. + */ + module Orientation { + /** + * Layout should be horizontally oriented. + */ + export var horizontal: string; + /** + * Layout should be vertically oriented. + */ + export var vertical: string; + } + + /** + * Orientation of a device. + */ + module DeviceOrientation { + /** + * Portrait orientation. + */ + export var portrait: string; + /** + * Landscape orientation. + */ + export var landscape: string; + /** + * Orientation cannot be determined. + */ + export var unknown: string; + } + + /** + * HorizontalAlignment indicates where an element should be displayed on the horizontal axis relative to the allocated layout slot of the parent element. + */ + module HorizontalAlignment { + /** + * An element should be left aligned. + */ + export var left: string; + + /** + * An element should be center aligned. + */ + export var center: string; + + /** + * An element should be right aligned. + */ + export var right: string; + + /** + * An element should be stretched to fill all the available size. + */ + export var stretch: string; + } + + /** + * VerticalAlignment indicates where an element should be displayed on the horizontal axis relative to the allocated layout slot of the parent element. + */ + module VerticalAlignment { + /** + * An element should be top aligned. + */ + export var top: string; + + /** + * An element should be center aligned. + */ + export var center: string; + + /** + * Same as center. An element should be aligned in the middle. + */ + export var middle: string; + + /** + * An element should be bottom aligned. + */ + export var bottom: string; + + /** + * An element should be stretched to fill all the available size. + */ + export var stretch: string; + } + + /** + * Describes how content is resized to fill its allocated space. + */ + module Stretch { + /** + * The image preserves its original size. + */ + export var none: string; + + /** + * The image is resized to fill in the destination dimensions while it preserves its native aspect ratio. + */ + export var aspectFill: string; + + /** + * The image is resized to fit the destination dimensions while it preserves + * its native aspect ratio. If the aspect ratio of the destination rectangle differs from the image, + * the image is clipped to fit in the destination + */ + export var aspectFit: string; + + /** + * The image is resized to fill the destination dimensions. The aspect ratio is not preserved. + */ + export var fill: string; + } + + /** + * Represents the visibility mode of a view. + */ + export module Visibility { + /** + * The view is visible. + */ + export var visible: string; + + /** + * Obsolete. Please use 'collapse' instead! + */ + export var collapsed: string; + + /** + * The view is not visible and won't take place in the layout. + */ + export var collapse: string; + } + + /** + * A flag enum that represents common font attributes. + */ + module FontAttributes { + /** + * Denotes that text should be drawn in a normal style. + */ + export var Normal: number; + + /** + * Denotes that text should be drawn in a bold weight. + */ + export var Bold: number; + + /** + * Denotes that text should be drawn in a italic style. + */ + export var Italic: number; + } + + /** + * Describes the type of a device + */ + module DeviceType { + /** + * Indicates a smart-phone device. + */ + export var Phone: string; + + /** + * Indicates a tablet device. + */ + export var Tablet: string; + } + + /** + * Represents an enumeration specifying when the text property of an EditableTextBase will be updated. + */ + module UpdateTextTrigger { + /** + * The text property will be udpaded when the widget loses focus. + */ + export var focusLost: string; + + /** + * The text property will be udpaded on every single character typed by the user. + */ + export var textChanged: string; + } + + /** + * Specifies common accuracy values. + */ + module Accuracy { + /** + * The default accuracy. About 300 meters. + */ + export var any: number; + + /** + * High accuracy. About 3 meters. + */ + export var high: number; + } + + /** + * Specifies the Dock position of a child element that is inside a DockLayout. + */ + module Dock { + /** + * A child element that is positioned on the left side of the DockLayout. + */ + export var left: string; + + /** + * A child element that is positioned on the top side of the DockLayout. + */ + export var top: string; + + /** + * A child element that is positioned on the right side of the DockLayout. + */ + export var right: string; + + /** + * A child element that is positioned on the bottom side of the DockLayout. + */ + export var bottom: string; + } + + /** + * Represents the auto-capitalization style for a text input. + */ + module AutocapitalizationType { + /** + * Do not capitalize any text automatically. + */ + export var none: string; + + /** + * Capitalize the first letter of each word automatically. + */ + export var words: string; + + /** + * Capitalize the first letter of each sentence automatically. + */ + export var sentences: string; + + /** + * Capitalize all characters automatically. + */ + export var allCharacters: string; + } + + /** + * Defines the recognized image formats. + */ + module ImageFormat { + /** + * The W3C Portable Network Graphics (PNG) image format. + */ + export var png: string; + + /** + * The Joint Photographic Experts Group (JPEG) image format. + */ + export var jpeg: string; + } + + /** + * Specifies NavigationBar visibility mode. + */ + module NavigationBarVisibility { + /** + * NavigationBar will be visible if there if frame backstack canGoBack is true or if the page Action Bar is not empty. + */ + export var auto: string; + + /** + * NavigationBar will be hidden. + */ + export var never: string; + + /** + * NavigationBar will be visible. + */ + export var always: string; + } + + /** + * Specifies the visibility of the application bar icon + */ + export module AndroidActionBarIconVisibility { + export var auto: string; + export var never: string; + export var always: string; + } + + /** + * Specifies android MenuItem position. + */ + module AndroidActionItemPosition { + /** + * Always show this item as a button in an Action Bar. + */ + export var actionBar: string; + + /** + * Show this item as a button in an Action Bar if the system decides there is room for it. + */ + export var actionBarIfRoom: string; + + /** + * Never show this item as a button in an Action Bar. + */ + export var popup: string; + } + + /** + * Specifies different font styles. + */ + export module FontStyle { + /** + * Normal font style. + */ + export var normal: string; + + /** + * Italic font style. + */ + export var italic: string; + } + + /** + * Specifies different text decorations. + */ + export module TextDecoration { + /** + * No decoration. + */ + export var none: string; + + /** + * Text decoration underline. + */ + export var underline: string; + + /** + * Text decoration line-through. + */ + export var lineThrough: string; + } + + /** + * Specifies different text transforms. + */ + export module TextTransform { + /** + * No transform. + */ + export var none: string; + + /** + * Text transform capitalize. + */ + export var capitalize: string; + + /** + * Text transform uppercase. + */ + export var uppercase: string; + + /** + * Text transform lowercase. + */ + export var lowercase: string; + } + + /** + * Specifies different white spaces. + */ + export module WhiteSpace { + /** + * Normal wrap. + */ + export var normal: string; + + /** + * No wrap. + */ + export var nowrap: string; + } + + /** + * Specifies different font weights. + */ + export module FontWeight { + /** + * Normal font weight. + */ + export var normal: string; + + /** + * Bold font weight. + */ + export var bold: string; + } + + /** + * Specifies background repeat. + */ + export module BackgroundRepeat { + export var repeat: string; + export var repeatX: string; + export var repeatY: string; + export var noRepeat: string; + } + + /** + * Specifies android MenuItem position. + */ + module IOSActionItemPosition { + /** + * Show this item at the left of the navigation bar. + */ + export var left: string; + + /** + * Show this item at the right of the action bar. + */ + export var right: string; + } + + /** + * Represents an animation curve type. + */ + module AnimationCurve { + + /** + * An ease-in curve causes the animation to begin slowly, and then speed up as it progresses. + */ + export var easeIn: string; + + /** + * An ease-out curve causes the animation to begin quickly, and then slow down as it completes. + */ + export var easeOut: string; + + /** + * An ease-in ease-out curve causes the animation to begin slowly, accelerate through the middle of its duration, and then slow again before completing. + */ + export var easeInOut: string; + + /** + * A linear animation curve causes an animation to occur evenly over its duration. + */ + export var linear: string; + + /** + * A spring animation curve causes an animation to produce a spring (bounce) effect. + */ + export var spring: string; + + /** + * A custom cubic bezier function defined by its two control points. Possible values are numeric values from 0 to 1 + */ + export function cubicBezier(x1: number, y1: number, x2: number, y2: number): animationModule.CubicBezierAnimationCurve; + } +} diff --git a/definitions/tns-core-modules/ui/frame/frame.d.ts b/definitions/tns-core-modules/ui/frame/frame.d.ts new file mode 100644 index 0000000..90829f0 --- /dev/null +++ b/definitions/tns-core-modules/ui/frame/frame.d.ts @@ -0,0 +1,306 @@ +/** + * Contains the Frame class, which represents the logical View unit that is responsible for navigation within an application. + */ +declare module "ui/frame" { + import view = require("ui/core/view"); + import observable = require("data/observable"); + import pages = require("ui/page"); + import transition = require("ui/transition"); + + /** + * Represents the logical View unit that is responsible for navigation withing an application. + * Typically an application will have a Frame object at a root level. + * Nested frames are supported, enabling hierarchical navigation scenarios. + */ + export class Frame extends view.View { + /** + * Deprecated. + * String value used when hooking to androidOptionSelected event (prefix `android` states that this event is available only in Android). + */ + public static androidOptionSelectedEvent: string; + + /** + * Navigates to the previous entry (if any) in the back stack. + * @param to The backstack entry to navigate back to. + */ + goBack(to?: BackstackEntry); + + /** + * Checks whether the goBack operation is available. + */ + canGoBack(): boolean; + + /** + * Navigates to a Page instance as described by the module name. + * This method will require the module and will check for a Page property in the exports of the module. + * @param pageModuleName The name of the module to require starting from the application root. + * For example if you want to navigate to page called "myPage.js" in a folder called "subFolder" and your root folder is "app" you can call navigate method like this: + * var frames = require("ui/frame"); + * frames.topmost().navigate("app/subFolder/myPage"); + */ + navigate(pageModuleName: string); + + /** + * Creates a new Page instance using the provided callback and navigates to that Page. + * @param create The function to be used to create the new Page instance. + */ + navigate(create: () => pages.Page); + + /** + * Navigates to a Page resolved by the provided NavigationEntry object. + * Since there are a couple of ways to specify a Page instance through an entry, there is a resolution priority: + * 1. entry.moduleName + * 2. entry.create() + * @param entry The NavigationEntry instance. + */ + navigate(entry: NavigationEntry); + + /** + * Gets the back stack of this instance. + */ + backStack: Array; + + /** + * Gets the Page instance the Frame is currently navigated to. + */ + currentPage: pages.Page; + + /** + * Gets the NavigationEntry instance the Frame is currently navigated to. + */ + currentEntry: NavigationEntry; + + /** + * Gets or sets if navigation transitions should be animated. + */ + animated: boolean; + + /** + * Gets or sets the default navigation transition for this frame. + */ + transition: NavigationTransition; + + /** + * Gets or sets if navigation transitions should be animated globally. + */ + static defaultAnimatedNavigation: boolean; + + /** + * Gets or sets the default NavigationTransition for all frames across the app. + */ + static defaultTransition: NavigationTransition; + + /** + * Gets the AndroidFrame object that represents the Android-specific APIs for this Frame. Valid when running on Android OS. + */ + android: AndroidFrame; + + /** + * Gets the iOSFrame object that represents the iOS-specific APIs for this Frame. Valid when running on iOS. + */ + ios: iOSFrame; + + + + /** + * A basic method signature to hook an event listener (shortcut alias to the addEventListener method). + * @param eventNames - String corresponding to events (e.g. "propertyChange"). Optionally could be used more events separated by `,` (e.g. "propertyChange", "change"). + * @param callback - Callback function which will be executed when event is raised. + * @param thisArg - An optional parameter which will be used as `this` context for callback execution. + */ + on(eventNames: string, callback: (args: observable.EventData) => void, thisArg?: any); + + /** + * Raised when native android [onOptionsItemSelected method](http://developer.android.com/reference/android/app/Activity.html#onOptionsItemSelected(android.view.MenuItem)) is called. + */ + on(event: "optionSelected", callback: (args: observable.EventData) => void, thisArg?: any); + } + + /** + * Gets the topmost frame in the frames stack. An application will typically has one frame instance. Multiple frames handle nested (hierarchical) navigation scenarios. + */ + export function topmost(): Frame; + + /** + * Navigates back using the navigation hierarchy (if any). Updates the Frame stack as needed. + * This method will start from the topmost Frame and will recursively search for an instance that has the canGoBack operation available. + */ + export function goBack(); + + /** + * Gets the frames stack. + */ + export function stack(): Array; + + /** + * Represents an entry in passed to navigate method. + */ + export interface NavigationEntry { + /** + * The name of the module containing the Page instance to load. Optional. + */ + moduleName?: string; + + /** + * A function used to create the Page instance. Optional. + */ + create?: () => pages.Page; + + /** + * An object passed to the onNavigatedTo callback of the Page. Typically this is used to pass some data among pages. Optional. + */ + context?: any; + + /** + * True to navigate to the new Page using animated transitions, false otherwise. + */ + animated?: boolean; + + /** + * Specifies an optional navigation transition for all platforms. If not specified, the default platform transition will be used. + */ + transition?: NavigationTransition; + + /** + * Specifies an optional navigation transition for iOS. If not specified, the default platform transition will be used. + */ + transitioniOS?: NavigationTransition; + + /** + * Specifies an optional navigation transition for iOS. If not specified, the default platform transition will be used. + */ + transitionAndroid?: NavigationTransition; + + /** + * True to record the navigation in the backstack, false otherwise. + * If the parameter is set to false then the Page will be displayed but once navigated from it will not be able to be navigated back to. + */ + backstackVisible?: boolean; + + /** + * True to clear the navigation history, false otherwise. Very useful when navigating away from login pages. + */ + clearHistory?: boolean; + } + + /** + * Represents an object specifying a page navigation transition. + */ + export interface NavigationTransition { + /** + * Can be one of the built-in transitions: + * - curl (same as curlUp) (iOS only) + * - curlUp (iOS only) + * - curlDown (iOS only) + * - explode (Android Lollipop an up only) + * - fade + * - flip (same as flipRight) + * - flipRight + * - flipLeft + * - slide (same as slideLeft) + * - slideLeft + * - slideRight + * - slideTop + * - slideBottom + */ + name?: string; + + /** + * An user-defined instance of the "ui/transition".Transition class. + */ + instance?: transition.Transition; + + /** + * The length of the transition in milliseconds. If you do not specify this, the default platform transition duration will be used. + */ + duration?: number; + + /** + * An optional transition animation curve. Possible values are contained in the [AnimationCurve enumeration](../enums/AnimationCurve/README.md). + * Alternatively, you can pass an instance of type UIViewAnimationCurve for iOS or android.animation.TimeInterpolator for Android. + */ + curve?: any; + } + + /** + * Represents an entry in the back stack of a Frame object. + */ + export interface BackstackEntry { + entry: NavigationEntry; + resolvedPage: pages.Page; + } + + /** + * Represents the data passed to the androidOptionSelected event. + * This event is raised by the Android OS when an option in the Activity's action bar has been selected. + */ + export interface AndroidOptionEventData extends observable.EventData { + /** + * Gets the Android-specific menu item that has been selected. + */ + item: any /* android.view.IMenuItem */; + + /** + * True to mark the event as handled (that is to prevent the default processing). + */ + handled: boolean; + } + + /** + * Represents the Android-specific Frame object, aggregated within the common Frame one. + * In Android there are two types of navigation - using new Activity instances or using Fragments within the main Activity. + * To start a new Activity, a new Frame instance should be created and navigated to the desired Page. + */ + export interface AndroidFrame extends observable.Observable { + /** + * Gets the native [android ViewGroup](http://developer.android.com/reference/android/view/ViewGroup.html) instance that represents the root layout part of the Frame. + */ + rootViewGroup: any /* android.view.ViewGroup */; + + /** + * Gets the native [android Activity](http://developer.android.com/reference/android/app/Activity.html) instance associated with this Frame. In case of nested Frame objects, this property points to the activity of the root Frame. + */ + activity: any /* android.app.Activity */; + + /** + * Gets the current (foreground) activity for the application. This property will recursively traverse all existing Frame objects and check for own Activity property. + */ + currentActivity: any /* android.app.Activity */; + + /** + * Gets the actionBar property of the currentActivity. + */ + actionBar: any /* android.app.ActionBar */; + + /** + * Determines whether the Activity associated with this Frame will display an action bar or not. + */ + showActionBar: boolean; + + /** + * Gets or sets whether the page UI will be cached when navigating away from the page. + */ + cachePagesOnNavigate: boolean; + } + + /* tslint:disable */ + /** + * Represents the iOS-specific Frame object, aggregated within the common Frame one. + * In iOS the native controller, associated with a Frame object is UINavigationController. + * The navigation controller will automatically hide/show its navigation bar depending on the back stack of the Frame. + */ + export interface iOSFrame { + /** + * Gets the native [UINavigationController](https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UINavigationController_Class/index.html) instance associated with this Frame. + */ + controller: any /* UINavigationController */; + + /** + * Gets or sets the visibility of navigationBar. + * Use NavBarVisibility enumeration - auto, never, always + */ + navBarVisibility: string; + } + + +} \ No newline at end of file diff --git a/definitions/tns-core-modules/ui/gestures/gestures.d.ts b/definitions/tns-core-modules/ui/gestures/gestures.d.ts new file mode 100644 index 0000000..ca8a56f --- /dev/null +++ b/definitions/tns-core-modules/ui/gestures/gestures.d.ts @@ -0,0 +1,302 @@ +/** + * Contains the GesturesObserver class, which lets you observe and respond to user gestures + */ +declare module "ui/gestures" { + import view = require("ui/core/view"); + import observable = require("data/observable"); + + /** + * Defines an enum with supported gesture types. + */ + export enum GestureTypes { + /** + * Denotes tap (click) gesture. + */ + tap, + /** + * Denotes double tap gesture. + */ + doubleTap, + /** + * Denotes pinch gesture. + */ + pinch, + /** + * Denotes pan gesture. + */ + pan, + /** + * Denotes swipe gesture. + */ + swipe, + /** + * Denotes rotation gesture. + */ + rotation, + /** + * Denotes long press gesture. + */ + longPress, + /** + * Denotes touch action. + */ + touch + } + + /** + * Defines an enum with supported gesture types. + */ + export enum GestureStateTypes { + /** + * Gesture canceled. + */ + cancelled, + /** + * Gesture began. + */ + began, + /** + * Gesture changed. + */ + changed, + /** + * Gesture ended. + */ + ended + } + + /** + * Defines an enum for swipe gesture direction. + */ + export enum SwipeDirection { + /** + * Denotes right direction for swipe gesture. + */ + right, + /** + * Denotes left direction for swipe gesture. + */ + left, + /** + * Denotes up direction for swipe gesture. + */ + up, + /** + * Denotes down direction for swipe gesture. + */ + down + } + + /** + * Defines a touch action + */ + export module TouchAction { + /** + * Down action. + */ + export var down: string; + + /** + * Up action. + */ + export var up: string; + + /** + * Move action. + */ + export var move: string; + + /** + * Cancel action. + */ + export var cancel: string; + } + + /** + * Provides gesture event data. + */ + export interface GestureEventData extends observable.EventData { + /** + * Gets the type of the gesture. + */ + type: GestureTypes; + /** + * Gets the view which originates the gesture. + */ + view: view.View; + /** + * Gets the underlying native iOS specific [UIGestureRecognizer](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIGestureRecognizer_Class/). + */ + ios: any /* UIGestureRecognizer */; + /** + * Gets the underlying native android specific [gesture detector](http://developer.android.com/reference/android/view/GestureDetector.html). + */ + android: any + } + + /** + * Provides gesture event data. + */ + export interface TouchGestureEventData extends GestureEventData { + /** + * Gets action of the touch. Possible values: 'up', 'move', 'down', 'cancel' + */ + action: string; + + /** + * Gets the X coordinate of this event inside the view that triggered the event. + */ + getX(): number; + + /** + * Gets the Y coordinate of this event inside the view that triggered the event. + */ + getY(): number; + + /** + * Gets the number of pointers in the event. + */ + getPointerCount(): number; + + /** + * Gets the pointers that triggered the event. + * Note: In Android there is aways only one active pointer. + */ + getActivePointers(): Array; + + /** + * Gets all pointers. + */ + getAllPointers(): Array; + } + + /** + * Pointer is an object representing a finger (or other object) that is touching the screen. + */ + export interface Pointer { + /** + * The id of the pointer. + */ + android: any; + + /** + * The UITouch object associated to the touch + */ + ios: any; + + /** + * Gets the X coordinate of the pointer inside the view that triggered the event. + */ + getX(): number; + + /** + * Gets the Y coordinate of the pointer inside the view that triggered the event. + */ + getY(): number; + } + + /** + * Provides gesture event data for pinch gesture. + */ + export interface GestureEventDataWithState extends GestureEventData { + state: number; + } + + /** + * Provides gesture event data for pinch gesture. + */ + export interface PinchGestureEventData extends GestureEventDataWithState { + scale: number; + + getFocusX(): number; + getFocusY(): number; + } + + /** + * Provides gesture event data for swipe gesture. + */ + export interface SwipeGestureEventData extends GestureEventData { + direction: SwipeDirection; + } + + /** + * Provides gesture event data for pan gesture. + */ + export interface PanGestureEventData extends GestureEventDataWithState { + deltaX: number; + deltaY: number; + } + + /** + * Provides gesture event data for rotation gesture. + */ + export interface RotationGestureEventData extends GestureEventDataWithState { + rotation: number; + } + + /** + * Provides options for the GesturesObserver. + */ + export class GesturesObserver { + /** + * Creates an instance of GesturesObserver class. + * @param target - The view for which the observer is created. + * @param callback - A function that will be executed when a gesture is received. + * @param context - default this argument for the callbacks. + */ + constructor(target: view.View, callback: (args: GestureEventData) => void, context: any); + + /** + * Registers a gesture observer to a view and gesture. + * @param type - Type of the gesture. + */ + observe(type: GestureTypes); + + /** + * Disconnects the gesture observer. + */ + disconnect(); + + /** + * Gesture type attached to the observer. + */ + type: GestureTypes; + + /** + * A function that will be executed when a gesture is received. + */ + callback: (args: GestureEventData) => void; + + /** + * A context which will be used as `this` in callback execution. + */ + context: any; + + /** + * An internal Android specific method used to pass the motion event to the correct gesture observer. + */ + androidOnTouchEvent: (motionEvent: any /* android.view.MotionEvent */) => void; + } + + /** + * A short-hand function that is used to create a gesture observer for a view and gesture. + * @param target - View which will be watched for originating a specific gesture. + * @param type - Type of the gesture. + * @param callback - A function that will be executed when a gesture is received. + * @param context - this argument for the callback. + */ + export function observe(target: view.View, type: GestureTypes, callback: (args: GestureEventData) => void, context?: any): GesturesObserver; + + /** + * Returns a string representation of a gesture type. + * @param type - Type of the gesture. + * @param separator(optional) - Text separator between gesture type strings. + */ + export function toString(type: GestureTypes, separator?: string): string; + + /** + * Returns a gesture type enum value from a string (case insensitive). + * @param type - A string representation of a gesture type (e.g. Tap). + */ + export function fromString(type: string): GestureTypes; +} diff --git a/definitions/tns-core-modules/ui/html-view/html-view.d.ts b/definitions/tns-core-modules/ui/html-view/html-view.d.ts new file mode 100644 index 0000000..7369beb --- /dev/null +++ b/definitions/tns-core-modules/ui/html-view/html-view.d.ts @@ -0,0 +1,47 @@ +/** + * Contains the HtmlView class, which represents a standard html view widget. + */ +declare module "ui/html-view" { + import view = require("ui/core/view"); + import dependencyObservable = require("ui/core/dependency-observable"); + + /** + * Represents a view with html content. Use this component instead WebView when you want to show just static HTML content. + * [iOS support](https://developer.apple.com/library/ios/documentation/UIKit/Reference/NSAttributedString_UIKit_Additions/#//apple_ref/occ/instm/NSAttributedString/initWithData:options:documentAttributes:error:) + * [android support](http://developer.android.com/reference/android/text/Html.html) + */ + export class HtmlView extends view.View { + + /** + * Dependency property used to support binding operations for the html of the current HtmlView instance. + */ + public static htmlProperty: dependencyObservable.Property; + + constructor(options?: Options); + + /** + * Gets the native [android widget](http://developer.android.com/reference/android/widget/TextView.html) that represents the user interface for this component. Valid only when running on Android OS. + */ + android: any /* android.widget.TextView */; + + /** + * Gets the native [UILabel](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UILabel_Class/) that represents the user interface for this component. Valid only when running on iOS. + */ + ios: any /* UILabel */; + + /** + * Gets or sets html string for the HtmlView. + */ + html: string; + } + + /** + * Provides a set of most common options for creating a HtmlView. + */ + export interface Options extends view.Options { + /** + * Gets or sets the html content of a HtmlView. + */ + html?: string; + } +} diff --git a/definitions/tns-core-modules/ui/image-cache/image-cache.d.ts b/definitions/tns-core-modules/ui/image-cache/image-cache.d.ts new file mode 100644 index 0000000..7801e88 --- /dev/null +++ b/definitions/tns-core-modules/ui/image-cache/image-cache.d.ts @@ -0,0 +1,107 @@ +/** + * Contains the Cache class, which handles image download requests and caches the already downloaded images. + */ +declare module "ui/image-cache" { + import observable = require("data/observable"); + import imageSource = require("image-source"); + + /** + * Represents a single download request. + */ + export interface DownloadRequest { + /** + * The url of the image. + */ + url: string; + /** + * The key used to cache the image. + */ + key: string; + /** + * An optional function to be called when the download is complete. + */ + completed?: (image: any, key: string) => void; + } + + /** + * Represents a class that stores handles image download requests and caches the already downloaded images. + */ + export class Cache extends observable.Observable { + /** + * String value used when hooking to downloaded event. + */ + public static downloadedEvent: string; + /** + * The image to be used to notify for a pending download request - e.g. loading indicator. + */ + placeholder: imageSource.ImageSource; + /** + * The maximum number of simultaneous download requests. Defaults to 5. + */ + maxRequests: number; + + /** + * Enables previously suspended download requests. + */ + enableDownload(): void; + /** + * Temporary disables download requests. + */ + disableDownload(): void; + + /** + * Adds a new download request at the top of the download queue. This will be the next immediate download to start. + */ + push(request: DownloadRequest); + /** + * Adds a new download request at the end of the download queue. This will be the last download to start. + */ + enqueue(request: DownloadRequest); + + /** + * Gets the image for the specified key. May be undefined if the key is not present in the cache. + */ + get(key: string): any; + /** + * Sets the image for the specified key. + */ + set(key: string, image: any): void; + /** + * Removes the cache for the specified key. + */ + remove(key: string): void; + /** + * Removes all the previously cached images. + */ + clear(): void; + + /** + * A basic method signature to hook an event listener (shortcut alias to the addEventListener method). + * @param eventNames - String corresponding to events (e.g. "propertyChange"). Optionally could be used more events separated by `,` (e.g. "propertyChange", "change"). + * @param callback - Callback function which will be executed when event is raised. + * @param thisArg - An optional parameter which will be used as `this` context for callback execution. + */ + on(eventNames: string, callback: (args: observable.EventData) => void , thisArg?: any); + + /** + * Raised when the image has been downloaded. + */ + on(event: "downloaded", callback: (args: DownloadedData) => void , thisArg?: any); + + + } + + /** + * Provides data for downloaded event. + */ + export interface DownloadedData extends observable.EventData { + /** + * A string indentifier of the cached image. + */ + key: string; + /** + * Gets the cached image. + */ + image: imageSource.ImageSource; + } +} \ No newline at end of file diff --git a/definitions/tns-core-modules/ui/image/image.d.ts b/definitions/tns-core-modules/ui/image/image.d.ts new file mode 100644 index 0000000..1462bf9 --- /dev/null +++ b/definitions/tns-core-modules/ui/image/image.d.ts @@ -0,0 +1,68 @@ +/** + * Contains the Image class, which represents an image widget. + */ +declare module "ui/image" { + import dependencyObservable = require("ui/core/dependency-observable"); + import imageSource = require("image-source"); + import view = require("ui/core/view"); + + /** + * Represents a class that provides functionality for loading and streching image(s). + */ + export class Image extends view.View { + public static srcProperty: dependencyObservable.Property; + public static imageSourceProperty: dependencyObservable.Property; + public static isLoadingProperty: dependencyObservable.Property; + public static stretchProperty: dependencyObservable.Property; + + /** + * Gets the native [android widget](http://developer.android.com/reference/android/widget/ImageView.html) that represents the user interface for this component. Valid only when running on Android OS. + */ + android: any /* android.widget.ImageView */; + + /** + * Gets the native iOS [UIImageView](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIImageView_Class/) that represents the user interface for this component. Valid only when running on iOS. + */ + ios: any /* UIImageView */; + + /** + * Gets or sets the image source of the image. + */ + imageSource: imageSource.ImageSource; + + /** + * Gets or sets the source of the Image. This can be either an URL string or a native image instance. + */ + src: any; + + /** + * Gets a value indicating if the image is currently loading + */ + isLoading: boolean; + + /** + * Gets or sets the image stretch mode. + */ + stretch: string; + } + + /** + * Provides common options for creating an image. + */ + export interface Options extends view.Options { + /** + * Gets or sets the image source of the image. + */ + imageSource: imageSource.ImageSource; + + /** + * Gets or sets the URL of the image. + */ + src: string; + + /** + * Gets or sets the image stretch mode. Possible values are contained in the [Stretch enumeration](../enums/Stretch/README.md). + */ + stretch: string; + } +} diff --git a/definitions/tns-core-modules/ui/label/label.d.ts b/definitions/tns-core-modules/ui/label/label.d.ts new file mode 100644 index 0000000..986cfe6 --- /dev/null +++ b/definitions/tns-core-modules/ui/label/label.d.ts @@ -0,0 +1,51 @@ +/** + * Contains the Label class, which represents a standard label widget. + */ +declare module "ui/label" { + import view = require("ui/core/view"); + import dependencyObservable = require("ui/core/dependency-observable"); + import textBase = require("ui/text-base"); + + /** + * Represents a text label. + */ + export class Label extends textBase.TextBase { + + /** + * Dependency property used to support binding operations for the text wrapping of the current label instance. + */ + public static textWrapProperty: dependencyObservable.Property; + + constructor(options?: Options); + + /** + * Gets the native [android widget](http://developer.android.com/reference/android/widget/TextView.html) that represents the user interface for this component. Valid only when running on Android OS. + */ + android: any /* android.widget.TextView */; + + /** + * Gets the native [UILabel](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UILabel_Class/) that represents the user interface for this component. Valid only when running on iOS. + */ + ios: any /* UILabel */; + + /** + * Gets or sets whether the Label wraps text or not. + */ + textWrap: boolean; + } + + /** + * Provides a set of most common options for creating a label. + */ + export interface Options extends view.Options { + /** + * Gets or sets the text content of a Label. + */ + text?: string; + + /** + * Gets or sets whether the Label wraps text or not. + */ + textWrap?: boolean; + } +} diff --git a/definitions/tns-core-modules/ui/layouts/absolute-layout/absolute-layout.d.ts b/definitions/tns-core-modules/ui/layouts/absolute-layout/absolute-layout.d.ts new file mode 100644 index 0000000..f059e16 --- /dev/null +++ b/definitions/tns-core-modules/ui/layouts/absolute-layout/absolute-layout.d.ts @@ -0,0 +1,41 @@ +declare module "ui/layouts/absolute-layout" { + import {LayoutBase} from "ui/layouts/layout-base"; + import {View} from "ui/core/view"; + import {Property} from "ui/core/dependency-observable"; + + /** + * A layout that lets you specify exact locations (left/top coordinates) of its children. + */ + class AbsoluteLayout extends LayoutBase { + + /** + * Represents the observable property backing the left property. + */ + public static leftProperty: Property; + + /** + * Represents the observable property backing the top property. + */ + public static topProperty: Property; + + /** + * Gets the value of the Left property from a given View. + */ + static getLeft(view: View): number; + + /** + * Sets the value of the Left property from a given View. + */ + static setLeft(view: View, value: number): void; + + /** + * Gets the value of the Top property from a given View. + */ + static getTop(view: View): number; + + /** + * Sets the value of the Top property from a given View. + */ + static setTop(view: View, value: number): void; + } +} \ No newline at end of file diff --git a/definitions/tns-core-modules/ui/layouts/dock-layout/dock-layout.d.ts b/definitions/tns-core-modules/ui/layouts/dock-layout/dock-layout.d.ts new file mode 100644 index 0000000..d86d611 --- /dev/null +++ b/definitions/tns-core-modules/ui/layouts/dock-layout/dock-layout.d.ts @@ -0,0 +1,37 @@ +declare module "ui/layouts/dock-layout" { + import {LayoutBase} from "ui/layouts/layout-base"; + import {View} from "ui/core/view"; + import {Property} from "ui/core/dependency-observable"; + + /** + * A Layout that arranges its children at its outer edges, and allows its last child to take up the remaining space. + */ + class DockLayout extends LayoutBase { + + /** + * Represents the observable property backing the dock property. + */ + public static dockProperty: Property; + + /** + * Represents the observable property backing the stretchLastChild property of each DockLayout instance. + */ + public static stretchLastChildProperty: Property; + + /** + * Gets the value of the Left property from a given View. + */ + static getDock(view: View): string; + + /** + * Sets the value of the Left property from a given View. + */ + static setDock(view: View, value: string): void; + + /** + * Gets or sets a value that indicates whether the last child element within a DockLayout stretches to fill the remaining available space. + * The default value is true. + */ + stretchLastChild: boolean; + } +} \ No newline at end of file diff --git a/definitions/tns-core-modules/ui/layouts/grid-layout/grid-layout.d.ts b/definitions/tns-core-modules/ui/layouts/grid-layout/grid-layout.d.ts new file mode 100644 index 0000000..5463c04 --- /dev/null +++ b/definitions/tns-core-modules/ui/layouts/grid-layout/grid-layout.d.ts @@ -0,0 +1,179 @@ +declare module "ui/layouts/grid-layout" { + import {LayoutBase} from "ui/layouts/layout-base"; + import {View} from "ui/core/view"; + import {Property} from "ui/core/dependency-observable"; + + /** + * GridUnitType enum is used to indicate what kind of value the ItemSpec is holding. + */ + module GridUnitType { + /** + * The value indicates that content should be calculated without constraints. + */ + export var auto: string; + /** + * The value is expressed as a pixel. + */ + export var pixel: string; + /** + * The value is expressed as a weighted proportion of available space. + */ + export var star: string; + } + + /** + * Defines row/column specific properties that apply to GridLayout elements. + */ + export class ItemSpec { + + constructor(); + constructor(value: number, type: string); + constructor(value: number, type: "pixel"); + constructor(value: number, type: "star"); + constructor(value: number, type: "auto"); + + /** + * Gets the actual length of an ItemSpec. + */ + actualLength: number; + + /** + * Returns unit type of this ItemSpec instance. + */ + gridUnitType: string; + + /** + * Returns true if this ItemSpec instance holds + * an absolute (pixel) value. + */ + isAbsolute: boolean; + + /** + * Returns true if this GridLength instance is + * automatic (not specified). + */ + isAuto: boolean; + + /** + * Returns true if this ItemSpec instance holds weighted propertion + * of available space. + */ + isStar: boolean; + + /** + * Returns value part of this ItemSpec instance. + */ + value: number; + } + + /** + * Defines a rectangular layout area that consists of columns and rows. + */ + export class GridLayout extends LayoutBase { + + ///** + // * Initializes a new instance of GridLayout. + // * @param options Options to configure this GridLayout instance. + // */ + //constructor(options?: Options); + + /** + * Represents the observable property backing the column property. + */ + public static columnProperty: Property; + + /** + * Represents the observable property backing the columnSpan property. + */ + public static columnSpanProperty: Property; + + /** + * Represents the observable property backing the row property. + */ + public static rowProperty: Property; + + /** + * Represents the observable property backing the rowSpan property. + */ + public static rowSpanProperty: Property; + /** + * Gets the value of the Column attached property from a given View. + */ + static getColumn(view: View): number; + + /** + * Sets the value of the Column attached property to a given View. + */ + static setColumn(view: View, value: number): void; + + /** + * Gets the value of the ColumnSpan attached property from a given View. + */ + static getColumnSpan(view: View): number; + + /** + * Sets the value of the ColumnSpan attached property to a given View. + */ + static setColumnSpan(view: View, value: number): void; + + /** + * Gets the value of the Row attached property from a given View. + */ + static getRow(view: View): number; + + /** + * Sets the value of the Row attached property to a given View. + */ + static setRow(view: View, value: number): void; + + /** + * Gets the value of the RowSpan attached property from a given View. + */ + static getRowSpan(view: View): number; + + /** + * Sets the value of the RowSpan attached property to a given View. + */ + static setRowSpan(view: View, value: number): void; + + /** + * Adds a column specification to a GridLayout. + */ + public addColumn(itemSpec: ItemSpec): void; + + /** + * Adds a row specification to a GridLayout. + */ + public addRow(itemSpec: ItemSpec): void; + + /** + * Removes a column specification from a GridLayout. + */ + public removeColumn(itemSpec: ItemSpec): void; + + /** + * Removes all columns specification from a GridLayout. + */ + public removeColumns(): void; + + /** + * Removes a row specification from a GridLayout. + */ + public removeRow(itemSpec: ItemSpec): void; + + /** + * Removes all rows specification from a GridLayout. + */ + public removeRows(): void; + + /** + * Gets array of column specifications defined on this instance of GridLayout. + */ + public getColumns(): Array; + + /** + * Gets array of row specifications defined on this instance of GridLayout. + */ + public getRows(): Array; + } +} \ No newline at end of file diff --git a/definitions/tns-core-modules/ui/layouts/layout-base.d.ts b/definitions/tns-core-modules/ui/layouts/layout-base.d.ts new file mode 100644 index 0000000..c9d2dcc --- /dev/null +++ b/definitions/tns-core-modules/ui/layouts/layout-base.d.ts @@ -0,0 +1,108 @@ +declare module "ui/layouts/layout-base" { + import view = require("ui/core/view"); + import dependencyObservable = require("ui/core/dependency-observable"); + + /** + * Base class for all views that supports children positioning. + */ + export class LayoutBase extends view.CustomLayoutView { + + public static clipToBoundsProperty: dependencyObservable.Property; + + /** + * Returns the number of children in this Layout. + */ + getChildrenCount(): number; + + /** + * Returns the view at the specified position. + * @param index The position at which to get the child from. + */ + getChildAt(index: number): view.View; + + /** + * Returns the position of the child view + * @param child The child view that we are looking for. + */ + getChildIndex(child: view.View): number; + + /** + * Adds the view to children array. + * @param view The view to be added to the end of the children array. + */ + addChild(view: view.View): void; + + /** + * Inserts the view to children array at the specified index. + * @param view The view to be added to the end of the children array. + * @param atIndex The insertion index. + */ + insertChild(child: view.View, atIndex: number): void; + + /** + * Removes the specified view from the children array. + * @param view The view to remove from the children array. + */ + removeChild(view: view.View): void; + + /** + * Removes all views in this layout. + */ + removeChildren(): void; + + /** + * INTERNAL. Used by the layout system. + */ + _registerLayoutChild(child: view.View): void; + + /** + * INTERNAL. Used by the layout system. + */ + _unregisterLayoutChild(child: view.View): void; + + /** + * Calls the callback for each child that should be laid out. + * @param callback The callback + */ + eachLayoutChild(callback: (child: view.View, isLast: boolean) => void): void; + + /** + * Iterates over children and changes their width and height to one calculated from percentage values. + * + * @param widthMeasureSpec Width MeasureSpec of the parent layout. + * @param heightMeasureSpec Height MeasureSpec of the parent layout. + */ + protected static adjustChildrenLayoutParams(layoutBase: LayoutBase, widthMeasureSpec: number, heightMeasureSpec: number): void; + + /** + * Iterates over children and restores their original dimensions that were changed for + * percentage values. + */ + protected static restoreOriginalParams(layoutBase: LayoutBase): void; + + /** + * Gets or sets padding style property. + */ + padding: string; + + /** + * Specify the bottom padding of this layout. + */ + paddingBottom: number; + + /** + * Specify the left padding of this layout. + */ + paddingLeft: number; + + /** + * Specify the right padding of this layout. + */ + paddingRight: number; + + /** + * Specify the top padding of this layout. + */ + paddingTop: number; + } +} diff --git a/definitions/tns-core-modules/ui/layouts/layout.d.ts b/definitions/tns-core-modules/ui/layouts/layout.d.ts new file mode 100644 index 0000000..b943484 --- /dev/null +++ b/definitions/tns-core-modules/ui/layouts/layout.d.ts @@ -0,0 +1,10 @@ +declare module "ui/layouts/layout" { + import layoutBase = require("ui/layouts/layout-base"); + + /** + * Base class for all views that supports children positioning in cross platform manner. + */ + export class Layout extends layoutBase.LayoutBase { + // + } +} diff --git a/definitions/tns-core-modules/ui/layouts/stack-layout/stack-layout.d.ts b/definitions/tns-core-modules/ui/layouts/stack-layout/stack-layout.d.ts new file mode 100644 index 0000000..b117ebb --- /dev/null +++ b/definitions/tns-core-modules/ui/layouts/stack-layout/stack-layout.d.ts @@ -0,0 +1,20 @@ +declare module "ui/layouts/stack-layout" { + import {LayoutBase} from "ui/layouts/layout-base"; + import {Property} from "ui/core/dependency-observable"; + + /** + * A Layout that arranges its children horizontally or vertically. The direction can be set by orientation property. + */ + class StackLayout extends LayoutBase { + /** + * Represents the observable property backing the orientation property of each StackLayout instance. + */ + public static orientationProperty: Property; + + /** + * Gets or sets if layout should be horizontal or vertical. + * The default value is vertical. + */ + orientation: string; + } +} \ No newline at end of file diff --git a/definitions/tns-core-modules/ui/layouts/wrap-layout/wrap-layout.d.ts b/definitions/tns-core-modules/ui/layouts/wrap-layout/wrap-layout.d.ts new file mode 100644 index 0000000..68d0f90 --- /dev/null +++ b/definitions/tns-core-modules/ui/layouts/wrap-layout/wrap-layout.d.ts @@ -0,0 +1,44 @@ +declare module "ui/layouts/wrap-layout" { + import {LayoutBase} from "ui/layouts/layout-base"; + import {Property} from "ui/core/dependency-observable"; + + /** + * WrapLayout position children in rows or columns depending on orientation property + * until space is filled and then wraps them on new row or column. + */ + class WrapLayout extends LayoutBase { + + /** + * Represents the observable property backing the orientation property of each WrapLayout instance. + */ + public static orientationProperty: Property; + + /** + * Represents the observable property backing the itemWidth property of each WrapLayout instance. + */ + public static itemWidthProperty: Property; + + /** + * Represents the observable property backing the itemHeight property of each WrapLayout instance. + */ + public static itemHeightProperty: Property; + + /** + * Gets or sets the flow direction. Default value is horizontal. + * If orientation is horizontal items are arranged in rows, else items are arranged in columns. + */ + orientation: string; + + /** + * Gets or sets the width used to measure and layout each child. + * Default value is Number.NaN which does not restrict children. + */ + itemWidth: number; + + /** + * Gets or sets the height used to measure and layout each child. + * Default value is Number.NaN which does not restrict children. + */ + itemHeight: number; + } +} \ No newline at end of file diff --git a/definitions/tns-core-modules/ui/list-picker/list-picker.d.ts b/definitions/tns-core-modules/ui/list-picker/list-picker.d.ts new file mode 100644 index 0000000..a505d93 --- /dev/null +++ b/definitions/tns-core-modules/ui/list-picker/list-picker.d.ts @@ -0,0 +1,38 @@ +/** + * Contains the ListPicker class. + */ +declare module "ui/list-picker" { + import view = require("ui/core/view"); + import dependencyObservable = require("ui/core/dependency-observable"); + + /** + * Represents an list picker. + */ + export class ListPicker extends view.View { + public static selectedIndexProperty: dependencyObservable.Property; + public static itemsProperty: dependencyObservable.Property; + + constructor(); + + /** + * Gets the native [android.widget.NumberPicker](http://developer.android.com/reference/android/widget/NumberPicker.html) that represents the user interface for this component. Valid only when running on Android OS. + */ + android: any /* android.widget.NumberPicker */; + + /** + * Gets the native iOS [UIPickerView](http://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UIDatePicker_Class/index.html) that represents the user interface for this component. Valid only when running on iOS. + */ + ios: any /* UIPickerView */; + + /** + * Gets or sets the selected index. + */ + selectedIndex: number; + + /** + * Gets or set the items collection of the ListPicker. + * The items property can be set to an array or an object defining length and getItem(index) method. + */ + items: any; + } +} diff --git a/definitions/tns-core-modules/ui/list-view/list-view.d.ts b/definitions/tns-core-modules/ui/list-view/list-view.d.ts new file mode 100644 index 0000000..ba9dfad --- /dev/null +++ b/definitions/tns-core-modules/ui/list-view/list-view.d.ts @@ -0,0 +1,157 @@ +/** + * Contains the ListView class, which represents a standard list view widget. + */ +declare module "ui/list-view" { + import observable = require("data/observable"); + import dependencyObservable = require("ui/core/dependency-observable"); + import view = require("ui/core/view"); + import color = require("color"); + + /** + * Known template names. + */ + export module knownTemplates { + /** + * The ListView item template. + */ + export var itemTemplate: string; + } + + /** + * Represents a view that shows items in a vertically scrolling list. + */ + export class ListView extends view.View { + /** + * String value used when hooking to itemLoading event. + */ + public static itemLoadingEvent: string; + /** + * String value used when hooking to itemTap event. + */ + public static itemTapEvent: string; + /** + * String value used when hooking to loadMoreItems event. + */ + public static loadMoreItemsEvent: string; + + /** + * Represents the observable property backing the items property of each ListView instance. + */ + public static itemsProperty: dependencyObservable.Property; + + /** + * Represents the item template property of each ListView instance. + */ + public static itemTemplateProperty: dependencyObservable.Property; + + /** + * Represents the observable property backing the isScrolling property of each ListView instance. + */ + public static isScrollingProperty: dependencyObservable.Property; + + /** + * Represents the observable property backing the rowHeight property of each ListView instance. + */ + public static rowHeightProperty: dependencyObservable.Property; + + /** + * Gets the native [android widget](http://developer.android.com/reference/android/widget/ListView.html) that represents the user interface for this component. Valid only when running on Android OS. + */ + android: any /* android.widget.ListView */; + + /** + * Gets the native [iOS view](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITableView_Class/) that represents the user interface for this component. Valid only when running on iOS. + */ + ios: any /* UITableView */; + + /** + * Gets a value indicating whether the ListView is currently scrolling. + */ + isScrolling: boolean; + + /** + * Gets or set the items collection of the ListView. + * The items property can be set to an array or an object defining length and getItem(index) method. + */ + items: any; + + /** + * Gets or set the item template of the ListView. + */ + itemTemplate: string | view.Template; + + /** + * Gets or set the items separator line color of the ListView. + */ + separatorColor: color.Color; + + /** + * Gets or set row height of the ListView. + */ + rowHeight: number; + + /** + * Forces the ListView to reload all its items. + */ + refresh(); + + /** + * Scrolls the specified item with index into view. + * [iOS](https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UITableView_Class/#//apple_ref/occ/instm/UITableView/scrollToRowAtIndexPath:atScrollPosition:animated:) + * [Android](http://developer.android.com/reference/android/widget/ListView.html#setSelection(int)) + * @param index - Item index. + */ + scrollToIndex(index: number); + + /** + * A basic method signature to hook an event listener (shortcut alias to the addEventListener method). + * @param eventNames - String corresponding to events (e.g. "propertyChange"). Optionally could be used more events separated by `,` (e.g. "propertyChange", "change"). + * @param callback - Callback function which will be executed when event is raised. + * @param thisArg - An optional parameter which will be used as `this` context for callback execution. + */ + on(eventNames: string, callback: (data: observable.EventData) => void, thisArg?: any); + + /** + * Raised when a View for the data at the specified index should be created. + * The result should be returned trough the view property of the event data. + * Note, that the view property of the event data can be pre-initialized with + * an old instance of a view, so that it can be reused. + */ + on(event: "itemLoading", callback: (args: ItemEventData) => void, thisArg?: any); + + /** + * Raised when an item inside the ListView is tapped. + */ + on(event: "itemTap", callback: (args: ItemEventData) => void, thisArg?: any); + + /** + * Raised when the ListView is scrolled so that its last item is visible. + */ + on(event: "loadMoreItems", callback: (args: observable.EventData) => void, thisArg?: any); + } + + /** + * Event data containing information for the index and the view associated to a list view item. + */ + export interface ItemEventData extends observable.EventData { + /** + * The index of the item, for which the event is raised. + */ + index: number; + + /** + * The view that is associated to the item, for which the event is raised. + */ + view: view.View; + + /** + * Gets the native [iOS view](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITableViewCell_Class/) that represents the user interface where the view is hosted. Valid only when running on iOS. + */ + ios: any /* UITableViewCell */; + + /** + * Gets the native [android widget](http://developer.android.com/reference/android/view/ViewGroup.html) that represents the user interface where the view is hosted. Valid only when running on Android OS. + */ + android: any /* android.view.ViewGroup */; + } +} diff --git a/definitions/tns-core-modules/ui/page/page.d.ts b/definitions/tns-core-modules/ui/page/page.d.ts new file mode 100644 index 0000000..50ce76f --- /dev/null +++ b/definitions/tns-core-modules/ui/page/page.d.ts @@ -0,0 +1,220 @@ +/** + * Contains the Page class, which represents a logical unit for navigation inside a Frame. + */ +declare module "ui/page" { + import observable = require("data/observable"); + import view = require("ui/core/view"); + import contentView = require("ui/content-view"); + import frame = require("ui/frame"); + import actionBar = require("ui/action-bar"); + import dependencyObservable = require("ui/core/dependency-observable"); + + + + /** + * Defines the data for the page navigation events. + */ + export interface NavigatedData extends observable.EventData { + /** + * The navigation context (optional, may be undefined) passed to the page navigation events method. + */ + context: any; + + /** + * Represents if a navigation is forward or backward. + */ + isBackNavigation: boolean; + } + + /** + * Defines the data for the Page.shownModally event. + */ + export interface ShownModallyData extends observable.EventData { + /** + * The context (optional, may be undefined) passed to the page when shown modally. + */ + context: any; + + /** + * A callback to call when you want to close the modally shown page. Pass in any kind of arguments and you will receive when the callback parameter of Page.showModal is executed. + */ + closeCallback: Function; + } + + export module knownCollections { + export var actionItems: string; + } + + /** + * Represents a logical unit for navigation (inside Frame). + */ + export class Page extends contentView.ContentView { + /** + * Dependency property that specify if page background should span under status bar. + */ + public static backgroundSpanUnderStatusBarProperty: dependencyObservable.Property; + + /** + * Dependency property used to hide the Navigation Bar in iOS and the Action Bar in Android. + */ + public static actionBarHiddenProperty: dependencyObservable.Property; + + /** + * String value used when hooking to showingModally event. + */ + public static showingModallyEvent: string; + + /** + * String value used when hooking to shownModally event. + */ + public static shownModallyEvent: string; + + /** + * String value used when hooking to navigatingTo event. + */ + public static navigatingToEvent: string; + + /** + * String value used when hooking to navigatedTo event. + */ + public static navigatedToEvent: string; + + /** + * String value used when hooking to navigatingFrom event. + */ + public static navigatingFromEvent: string; + + /** + * String value used when hooking to navigatedFrom event. + */ + public static navigatedFromEvent: string; + + constructor(options?: Options) + + /** + * Gets or sets whether page background spans under status bar. + */ + backgroundSpanUnderStatusBar: boolean; + + /** + * Used to hide the Navigation Bar in iOS and the Action Bar in Android. + */ + actionBarHidden: boolean; + + /** + * A valid css string which will be applied for all nested UI components (based on css rules). + */ + css: string; + + /** + * Adds a new values to current css. + * @param cssString - A valid css which will be added to current css. + */ + addCss(cssString: string): void; + + /** + * Adds the content of the file to the current css. + * @param cssFileName - A valid file name (from the application root) which contains a valid css. + */ + addCssFile(cssFileName: string): void; + + /** + * A property that is used to pass a data from another page (while navigate to). + */ + navigationContext: any; + + /** + * Gets the Frame object controlling this instance. + */ + frame: frame.Frame; + + /** + * Gets the ActionBar for this page. + */ + actionBar: actionBar.ActionBar; + + /** + * A basic method signature to hook an event listener (shortcut alias to the addEventListener method). + * @param eventNames - String corresponding to events (e.g. "propertyChange"). Optionally could be used more events separated by `,` (e.g. "propertyChange", "change"). + * @param callback - Callback function which will be executed when event is raised. + * @param thisArg - An optional parameter which will be used as `this` context for callback execution. + */ + on(eventNames: string, callback: (data: observable.EventData) => void, thisArg?: any); + + /** + * Raised when navigation to the page has started. + */ + on(event: "navigatingTo", callback: (args: NavigatedData) => void, thisArg?: any); + + /** + * Raised when navigation to the page has finished. + */ + on(event: "navigatedTo", callback: (args: NavigatedData) => void, thisArg?: any); + + /** + * Raised when navigation from the page has started. + */ + on(event: "navigatingFrom", callback: (args: NavigatedData) => void, thisArg?: any); + + /** + * Raised when navigation from the page has finished. + */ + on(event: "navigatedFrom", callback: (args: NavigatedData) => void, thisArg?: any); + + /** + * Raised before the page is shown as a modal dialog. + */ + on(event: "showingModally", callback: (args: observable.EventData) => void, thisArg?: any); + + /** + * Raised after the page is shown as a modal dialog. + */ + on(event: "shownModally", callback: (args: ShownModallyData) => void, thisArg?: any); + + /** + * Shows the page contained in moduleName as a modal view. + * @param moduleName - The name of the page module to load starting from the application root. + * @param context - Any context you want to pass to the modally shown page. This same context will be available in the arguments of the Page.shownModally event handler. + * @param closeCallback - A function that will be called when the page is closed. Any arguments provided when calling ShownModallyData.closeCallback will be available here. + * @param fullscreen - An optional parameter specifying whether to show the modal page in full-screen mode. + */ + showModal(moduleName: string, context: any, closeCallback: Function, fullscreen?: boolean); + + /** + * Shows the page as a modal view. + */ + showModal(); + + /** + * Closes the current modal view that this page is showing. + */ + closeModal(); + + /** + * Returns the current modal view that this page is showing (is parent of), if any. + */ + modal: Page; + + + } + + /** + * Provides a set with most common option used to create a page instance. + */ + export interface Options extends view.Options { + /** + * Gets or sets the page module. + */ + module?: any; + + /** + * Gets or sets the page module file name. + */ + filename?: string; + + /** + * Gets or sets the page module exports. + */ + exports?: any; + } +} diff --git a/definitions/tns-core-modules/ui/placeholder/placeholder.d.ts b/definitions/tns-core-modules/ui/placeholder/placeholder.d.ts new file mode 100644 index 0000000..22ce84d --- /dev/null +++ b/definitions/tns-core-modules/ui/placeholder/placeholder.d.ts @@ -0,0 +1,45 @@ +/** + * Contains the Placeholder class, which is used to add a native view to the visual tree. + */ +declare module "ui/placeholder" { + import view = require("ui/core/view"); + import observable = require("data/observable"); + + /** + * Represents a Placeholder, which is used to add a native view to the visual tree. + */ + export class Placeholder extends view.View { + /** + * String value used when hooking to creatingView event. + */ + public static creatingViewEvent: string; + + /** + * A basic method signature to hook an event listener (shortcut alias to the addEventListener method). + * @param eventNames - String corresponding to events (e.g. "propertyChange"). Optionally could be used more events separated by `,` (e.g. "propertyChange", "change"). + * @param callback - Callback function which will be executed when event is raised. + * @param thisArg - An optional parameter which will be used as `this` context for callback execution. + */ + on(eventNames: string, callback: (args: observable.EventData) => void); + + /** + * Raised when a creatingView event occurs. + */ + on(event: "creatingView", callback: (args: CreateViewEventData) => void); + } + + /** + * Event data containing information for creating a native view that will be added to the visual tree. + */ + export interface CreateViewEventData extends observable.EventData { + /** + * The native view that should be added to the visual tree. + */ + view: any; + + /** + * An optional context for creating the view. + */ + context?: any; + } +} diff --git a/definitions/tns-core-modules/ui/progress/progress.d.ts b/definitions/tns-core-modules/ui/progress/progress.d.ts new file mode 100644 index 0000000..e540cdc --- /dev/null +++ b/definitions/tns-core-modules/ui/progress/progress.d.ts @@ -0,0 +1,42 @@ +/** + * Contains the Progress class, which represents a component capable of showing progress. + */ +declare module "ui/progress" { + import view = require("ui/core/view"); + import dependencyObservable = require("ui/core/dependency-observable"); + + /** + * Represents a progress component. + */ + export class Progress extends view.View { + /** + * Represents the observable property backing the value property of each Progress instance. + */ + public static valueProperty: dependencyObservable.Property; + + /** + * Represents the observable property backing the maxValue property of each Progress instance. + */ + public static maxValueProperty: dependencyObservable.Property; + + /** + * Gets the native [android widget](http://developer.android.com/reference/android/widget/ProgressBar.html) that represents the user interface for this component. Valid only when running on Android OS. + */ + android: any /* android.widget.ProgressBar */; + + /** + * Gets the native iOS [UIProgressView](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIProgressView_Class/) that represents the user interface for this component. Valid only when running on iOS. + */ + ios: any /* UIProgressView */; + + /** + * Gets or sets a progress current value. + */ + value: number; + + /** + * Gets or sets a progress max value. + */ + maxValue: number; + } +} diff --git a/definitions/tns-core-modules/ui/proxy-view-container/proxy-view-container.d.ts b/definitions/tns-core-modules/ui/proxy-view-container/proxy-view-container.d.ts new file mode 100644 index 0000000..2495edd --- /dev/null +++ b/definitions/tns-core-modules/ui/proxy-view-container/proxy-view-container.d.ts @@ -0,0 +1,6 @@ +declare module "ui/proxy-view-container" { + import layout = require("ui/layouts/layout-base"); + + export class ProxyViewContainer extends layout.LayoutBase { + } +} diff --git a/definitions/tns-core-modules/ui/repeater/repeater.d.ts b/definitions/tns-core-modules/ui/repeater/repeater.d.ts new file mode 100644 index 0000000..f3972b7 --- /dev/null +++ b/definitions/tns-core-modules/ui/repeater/repeater.d.ts @@ -0,0 +1,49 @@ +/** + * Contains the Repeater class, which represents a UI Repeater component. + */ +declare module "ui/repeater" { + import view = require("ui/core/view"); + import dependencyObservable = require("ui/core/dependency-observable"); + import layoutBaseModule = require("ui/layouts/layout-base"); + + /** + * Represents a UI Repeater component. + */ + export class Repeater extends view.View { + /** + * Represents the observable property backing the items property of each Repeater instance. + */ + public static itemsProperty: dependencyObservable.Property; + + /** + * Represents the item template property of each Repeater instance. + */ + public static itemTemplateProperty: dependencyObservable.Property; + + /** + * Represents the items layout property of each Repeater instance. + */ + public static itemsLayoutProperty: dependencyObservable.Property; + + /** + * Gets or set the items collection of the Repeater. + * The items property can be set to an array or an object defining length and getItem(index) method. + */ + items: any; + + /** + * Gets or set the item template of the Repeater. + */ + itemTemplate: string | view.Template; + + /** + * Gets or set the items layout of the Repeater. Default value is StackLayout with orientation="vertical". + */ + itemsLayout: layoutBaseModule.LayoutBase; + + /** + * Forces the Repeater to reload all its items. + */ + refresh(); + } +} \ No newline at end of file diff --git a/definitions/tns-core-modules/ui/scroll-view/scroll-view.d.ts b/definitions/tns-core-modules/ui/scroll-view/scroll-view.d.ts new file mode 100644 index 0000000..e014a54 --- /dev/null +++ b/definitions/tns-core-modules/ui/scroll-view/scroll-view.d.ts @@ -0,0 +1,79 @@ +/** + * Contains the ScrollView class, which represents a scrollable area that can have content that is larger than its bounds. + */ +declare module "ui/scroll-view" { + import contentView = require("ui/content-view"); + import observable = require("data/observable"); + import dependencyObservable = require("ui/core/dependency-observable"); + + export var orientationProperty: dependencyObservable.Property; + + /** + * Represents a scrollable area that can have content that is larger than its bounds. + */ + class ScrollView extends contentView.ContentView { + public static orientationProperty: dependencyObservable.Property; + + /** + * String value used when hooking to scroll event. + */ + public static scrollEvent: string; + + /** + * Gets a value that contains the vertical offset of the scrolled content. + */ + verticalOffset: number; + + /** + * Gets a value that contains the horizontal offset of the scrolled content. + */ + horizontalOffset: number; + + /** + * Gets the maximum value for the verticalOffset. + */ + scrollableHeight: number; + + /** + * Gets the maximum value for the horizontalOffset. + */ + scrollableWidth: number; + + /** + * Scrolls the content the specified vertical offset position. + * @param value The offset value + * @param animated true for animated scroll, false for immediate scroll. + */ + scrollToVerticalOffset(value: number, animated: boolean); + + /** + * Scrolls the content the specified horizontal offset position. + * @param value The offset value + * @param animated true for animated scroll, false for immediate scroll. + */ + scrollToHorizontalOffset(value: number, animated: boolean); + + /** + * Gets or sets direction in which the content can be scrolled. + */ + orientation: string; + + /** + * A basic method signature to hook an event listener (shortcut alias to the addEventListener method). + * @param eventNames - String corresponding to events (e.g. "propertyChange"). Optionally could be used more events separated by `,` (e.g. "propertyChange", "change"). + * @param callback - Callback function which will be executed when event is raised. + * @param thisArg - An optional parameter which will be used as `this` context for callback execution. + */ + on(eventNames: string, callback: (data: observable.EventData) => void, thisArg?: any); + + /** + * Raised when a scroll event occurs. + */ + on(event: "scroll", callback: (args: ScrollEventData) => void, thisArg?: any); + } + + interface ScrollEventData extends observable.EventData { + scrollX: number; + scrollY: number; + } +} \ No newline at end of file diff --git a/definitions/tns-core-modules/ui/search-bar/search-bar.d.ts b/definitions/tns-core-modules/ui/search-bar/search-bar.d.ts new file mode 100644 index 0000000..6d01bd5 --- /dev/null +++ b/definitions/tns-core-modules/ui/search-bar/search-bar.d.ts @@ -0,0 +1,87 @@ +/** + * Contains the SearchBar class, which represents a standard search bar component. + */ +declare module "ui/search-bar" { + import view = require("ui/core/view"); + import observable = require("data/observable"); + import dependencyObservable = require("ui/core/dependency-observable"); + import color = require("color"); + + /** + * Represents a search bar component. + */ + export class SearchBar extends view.View { + /** + * String value used when hooking to submit event. + */ + public static submitEvent: string; + + /** + * String value used when hooking to clear event. + */ + public static clearEvent: string; + + /** + * Dependency property used to support binding operations related to search-bar text. + */ + public static textProperty: dependencyObservable.Property; + + /** + * Gets or sets the TextField background color of the SearchBar component. + */ + public static textFieldBackgroundColorProperty: dependencyObservable.Property; + + /** + * Gets the native [android widget](http://developer.android.com/reference/android/widget/SearchView.html) that represents the user interface for this component. Valid only when running on Android OS. + */ + android: any /* android.widget.SearchView */; + + /** + * Gets the native iOS [UISearchBar](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UISearchBar_Class/) that represents the user interface for this component. Valid only when running on iOS. + */ + ios: any /* UISearchBar */; + + /** + * Gets or sets a search bar text. + */ + text: string; + + /** + * Gets or sets the text of the search bar text field hint/placeholder. + */ + hint: string; + + /** + * Gets or sets the TextField background color of the SearchBar component. + */ + textFieldBackgroundColor: color.Color; + + /** + * Gets or sets the TextField Hint color of the SearchBar component. + */ + textFieldHintColor: color.Color; + + /** + * A basic method signature to hook an event listener (shortcut alias to the addEventListener method). + * @param eventNames - String corresponding to events (e.g. "propertyChange"). Optionally could be used more events separated by `,` (e.g. "propertyChange", "change"). + * @param callback - Callback function which will be executed when event is raised. + * @param thisArg - An optional parameter which will be used as `this` context for callback execution. + */ + on(eventNames: string, callback: (data: observable.EventData) => void, thisArg?: any); + + /** + * Raised when a search bar search is submitted. + */ + on(event: "submit", callback: (args: observable.EventData) => void, thisArg?: any); + + /** + * Raised when a search bar search is closed. + */ + on(event: "close", callback: (args: observable.EventData) => void, thisArg?: any); + + /** + * Hides the soft input method, ususally a soft keyboard. + */ + dismissSoftInput(): void; + } +} diff --git a/definitions/tns-core-modules/ui/segmented-bar/segmented-bar.d.ts b/definitions/tns-core-modules/ui/segmented-bar/segmented-bar.d.ts new file mode 100644 index 0000000..c8343cd --- /dev/null +++ b/definitions/tns-core-modules/ui/segmented-bar/segmented-bar.d.ts @@ -0,0 +1,88 @@ +/** + * Contains the SegmentedBar class, which represents a SegmentedBar component. + */ +declare module "ui/segmented-bar" { + import view = require("ui/core/view"); + import dependencyObservable = require("ui/core/dependency-observable"); + import color = require("color"); + import bindable = require("ui/core/bindable"); + import observable = require("data/observable"); + + /** + * Represents a SegmentedBar item. + */ + class SegmentedBarItem extends bindable.Bindable { + /** + * Gets or sets the title of the SegmentedBarItem. + */ + public title: string; + } + + /** + * Defines the data for the SegmentedBar.selectedIndexChanged event. + */ + export interface SelectedIndexChangedEventData extends observable.EventData { + /** + * The old selected index. + */ + oldIndex: number; + + /** + * The new selected index. + */ + newIndex: number; + } + + /** + * Represents a UI SegmentedBar component. + */ + export class SegmentedBar extends view.View { + /** + * Gets or sets the selected index of the SegmentedBar component. + */ + selectedIndex: number; + + /** + * Gets or sets the selected background color of the SegmentedBar component. + */ + selectedBackgroundColor: color.Color; + + /** + * Gets or sets the items of the SegmentedBar. + */ + items: Array; + + /** + * Gets or sets the selected index dependency property of the SegmentedBar. + */ + public static selectedIndexProperty: dependencyObservable.Property; + + /** + * Gets or sets the selected background color property of the SegmentedBar. + */ + public static selectedBackgroundColorProperty: dependencyObservable.Property; + + /** + * Gets or sets the items dependency property of the SegmentedBar. + */ + public static itemsProperty: dependencyObservable.Property; + + /** + * String value used when hooking to the selectedIndexChanged event. + */ + public static selectedIndexChangedEvent: string; + + /** + * A basic method signature to hook an event listener (shortcut alias to the addEventListener method). + * @param eventNames - String corresponding to events (e.g. "propertyChange"). Optionally could be used more events separated by `,` (e.g. "propertyChange", "change"). + * @param callback - Callback function which will be executed when event is raised. + * @param thisArg - An optional parameter which will be used as `this` context for callback execution. + */ + on(eventNames: string, callback: (data: observable.EventData) => void, thisArg?: any); + + /** + * Raised when the selected index changes. + */ + on(event: "selectedIndexChanged", callback: (args: SelectedIndexChangedEventData) => void, thisArg?: any); + } +} \ No newline at end of file diff --git a/definitions/tns-core-modules/ui/slider/slider.d.ts b/definitions/tns-core-modules/ui/slider/slider.d.ts new file mode 100644 index 0000000..553dfaf --- /dev/null +++ b/definitions/tns-core-modules/ui/slider/slider.d.ts @@ -0,0 +1,52 @@ +/** + * Contains the Slider class, which represents a standard slider component. + */ +declare module "ui/slider" { + import view = require("ui/core/view"); + import dependencyObservable = require("ui/core/dependency-observable"); + + /** + * Represents a slider component. + */ + export class Slider extends view.View { + /** + * Represents the observable property backing the value property of each Slider instance. + */ + public static valueProperty: dependencyObservable.Property; + + /** + * Represents the observable property backing the minValue property of each Slider instance. + */ + public static minValueProperty: dependencyObservable.Property; + + /** + * Represents the observable property backing the maxValue property of each Slider instance. + */ + public static maxValueProperty: dependencyObservable.Property; + + /** + * Gets the native [android widget](http://developer.android.com/reference/android/widget/SeekBar.html) that represents the user interface for this component. Valid only when running on Android OS. + */ + android: any /* android.widget.SeekBar */; + + /** + * Gets the native iOS [UISlider](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UISlider_Class/) that represents the user interface for this component. Valid only when running on iOS. + */ + ios: any /* UISlider */; + + /** + * Gets or sets a slider current value. The default value is 0. + */ + value: number; + + /** + * Gets or sets a slider min value. The default value is 0. + */ + minValue: number; + + /** + * Gets or sets a slider max value. The default value is 100. + */ + maxValue: number; + } +} diff --git a/definitions/tns-core-modules/ui/styling/background.d.ts b/definitions/tns-core-modules/ui/styling/background.d.ts new file mode 100644 index 0000000..de680e1 --- /dev/null +++ b/definitions/tns-core-modules/ui/styling/background.d.ts @@ -0,0 +1,53 @@ +declare module "ui/styling/background" { + import imageSource = require("image-source"); + import colorModule = require("color"); + import viewModule = require("ui/core/view"); + + export interface BackgroundDrawParams { + repeatX: boolean; + repeatY: boolean; + posX: number; + posY: number; + sizeX?: number; + sizeY?: number; + } + + export class Background { + static default: Background; + color: colorModule.Color; + image: imageSource.ImageSource; + repeat: string; + position: string; + size: string; + + constructor( + color: colorModule.Color, + image: imageSource.ImageSource, + repeat: string, + position: string, + size: string); + + public withColor(value: colorModule.Color): Background; + public withImage(value: imageSource.ImageSource): Background; + + public withRepeat(value: string): Background; + + public withPosition(value: string): Background; + + public withSize(value: string): Background; + + public getDrawParams(width: number, height: number): BackgroundDrawParams; + + public isEmpty(): boolean; + + public static equals(value1: Background, value2: Background): boolean; + } + + export module ios { + export function createBackgroundUIColor(view: viewModule.View, flip?: boolean): any /* UIColor */; + } + + export module ad { + export function onBackgroundOrBorderPropertyChanged(v: viewModule.View); + } +} diff --git a/definitions/tns-core-modules/ui/styling/css-selector.d.ts b/definitions/tns-core-modules/ui/styling/css-selector.d.ts new file mode 100644 index 0000000..5740829 --- /dev/null +++ b/definitions/tns-core-modules/ui/styling/css-selector.d.ts @@ -0,0 +1,57 @@ +declare module "ui/styling/css-selector" { + import view = require("ui/core/view"); + import cssParser = require("css"); + import styleProperty = require("ui/styling/style-property"); + + export class CssSelector { + constructor(expression: string, declarations: cssParser.Declaration[]); + + expression: string; + attrExpression: string; + + declarations(): Array<{ property: string; value: any }>; + + specificity: number; + + matches(view: view.View): boolean; + + apply(view: view.View); + + eachSetter(callback: (property: styleProperty.Property, resolvedValue: any) => void); + } + + class CssTypeSelector extends CssSelector { + specificity: number; + matches(view: view.View): boolean; + } + + class CssIdSelector extends CssSelector { + specificity: number; + matches(view: view.View): boolean; + } + + class CssClassSelector extends CssSelector { + specificity: number; + matches(view: view.View): boolean; + } + + export class CssVisualStateSelector extends CssSelector { + specificity: number; + + key: string; + + state: string; + + constructor(expression: string, declarations: cssParser.Declaration[]); + matches(view: view.View): boolean; + } + + export function createSelector(expression: string, declarations: cssParser.Declaration[]): CssSelector; + + class InlineStyleSelector extends CssSelector { + constructor(declarations: cssParser.Declaration[]); + apply(view: view.View); + } + + export function applyInlineSyle(view: view.View, declarations: cssParser.Declaration[]); +} diff --git a/definitions/tns-core-modules/ui/styling/font.d.ts b/definitions/tns-core-modules/ui/styling/font.d.ts new file mode 100644 index 0000000..54b54dc --- /dev/null +++ b/definitions/tns-core-modules/ui/styling/font.d.ts @@ -0,0 +1,30 @@ +declare module "ui/styling/font" { + export class Font { + public static default: Font; + + public fontFamily: string; + public fontStyle: string; + public fontWeight: string; + public fontSize: number; + + public isBold: boolean; + public isItalic: boolean; + + constructor(family: string, size: number, style: string, weight: string); + + public getAndroidTypeface(): any /* android.graphics.Typeface */; + public getUIFont(defaultFont: any /* UIFont */): any /* UIFont */; + + public withFontFamily(family: string): Font; + public withFontStyle(style: string): Font; + public withFontWeight(weight: string): Font; + public withFontSize(size: number): Font; + + public static equals(value1: Font, value2: Font): boolean; + public static parse(cssValue: string): Font; + } + + export module ios { + export function registerFont(fontFile: string); + } +} diff --git a/definitions/tns-core-modules/ui/styling/style-property.d.ts b/definitions/tns-core-modules/ui/styling/style-property.d.ts new file mode 100644 index 0000000..ca99635 --- /dev/null +++ b/definitions/tns-core-modules/ui/styling/style-property.d.ts @@ -0,0 +1,28 @@ +declare module "ui/styling/style-property" { + import definition = require("ui/styling"); + import observable = require("ui/core/dependency-observable"); + + export function getShorthandPairs(name: string, value: any): Array>; + + export function registerShorthandCallback(name: string, callback: (value: any) => Array>): void; + + export function getPropertyByName(name: string): Property; + + export function getPropertyByCssName(name: string): Property; + + export function eachProperty(callback: (property: Property) => void); + + export function eachInheritableProperty(callback: (property: Property) => void); + + export class Property extends observable.Property implements definition.Property { + + constructor(name: string, cssName: string, metadata: observable.PropertyMetadata, valueConverter?: (value: any) => any); + + cssName: string; + } + + export interface KeyValuePair { + property: K; + value: V; + } +} \ No newline at end of file diff --git a/definitions/tns-core-modules/ui/styling/styling.d.ts b/definitions/tns-core-modules/ui/styling/styling.d.ts new file mode 100644 index 0000000..95114f0 --- /dev/null +++ b/definitions/tns-core-modules/ui/styling/styling.d.ts @@ -0,0 +1,311 @@ +declare module "ui/styling" { + import observable = require("ui/core/dependency-observable"); + import color = require("color"); + import view = require("ui/core/view"); + import dependencyObservable = require("ui/core/dependency-observable"); + + /** + * Represents an observable property which can have its value set form CSS style. + */ + export class Property extends observable.Property { + + /** + * Creates a new style property. + * @param name Name of the property + * @param cssName The name of property when it is defined in CSS + * @param metadata The property metadata + * @param valueConverter Converter function that will be used to convert the CSS value to the actual property type. + */ + constructor(name: string, cssName: string, metadata: observable.PropertyMetadata, valueConverter?: (value: any) => any); + + /** + * Gets the CSS name of the property. + */ + cssName: string; + + /** + * Gets the converter function that will be used to convert the CSS value to the actual property type. + */ + valueConverter: (value: any) => any; + } + + /** + * Represents as style object containing all the style properties for a particular view. + */ + export class Style extends observable.DependencyObservable { + /** + * Creates new style object. + * @param parentView The view for which the style is created for. + */ + constructor(parentView: view.View); + + /** + * Gets or sets the color style property. + */ + color: color.Color; + /** + * Gets or sets the background-color style property. + */ + backgroundColor: color.Color; + + /** + * Gets or sets the background-image style property. + */ + backgroundImage: string; + + /** + * Gets or sets the background-size style property. + */ + backgroundSize: string; + + /** + * Gets or sets the background-position style property. + */ + backgroundPosition: string; + + /** + * Gets or sets the background-repeat style property. + */ + backgroundRepeat: string; + + /** + * Gets or sets the border-color style property. + */ + borderColor: color.Color + + /** + * Gets or sets the border-width style property. + */ + borderWidth: number + + /** + * Gets or sets the border-radius style property. + */ + borderRadius: number; + + /** + * Gets or sets font-size style property. + */ + fontSize: number; + + /** + * Gets or sets font-family style property. + */ + fontFamily: string; + + /** + * Gets or sets font-style style property. + */ + fontStyle: string; + + /** + * Gets or sets font-weight style property. + */ + fontWeight: string; + + /** + * Gets or sets text-alignment style property. + */ + textAlignment: string; + + /** + * Gets or sets min-width style property. + */ + minWidth: number; + + /** + * Gets or sets min-height style property. + */ + minHeight: number; + + /** + * Gets or sets width style property. + */ + width: number; + + /** + * Gets or sets height style property. + */ + height: number; + + /** + * Gets or sets margin style property. + */ + margin: string; + + /** + * Specifies extra space on the left side of this view. + */ + marginLeft: number; + + /** + * Specifies extra space on the top side of this view. + */ + marginTop: number; + + /** + * Specifies extra space on the right side of this view. + */ + marginRight: number; + + /** + * Specifies extra space on the bottom side of this view. + */ + marginBottom: number; + + /** + * Gets or sets padding style property. + */ + padding: string; + + /** + * Specify the left padding of this view. + */ + paddingLeft: number; + + /** + * Specify the top padding of this view. + */ + paddingTop: number; + + /** + * Specify the right padding of this view. + */ + paddingRight: number; + + /** + * Specify the bottom padding of this view. + */ + paddingBottom: number; + + /** + * Gets or sets horizontal-alignment style property. + */ + horizontalAlignment: string; + + /** + * Gets or sets vertical-alignment style property. + */ + verticalAlignment: string; + + /** + * Gets or sets the visibility style property. + */ + visibility: string; + + /** + * Gets or sets the opacity style property. + */ + opacity: number; + + textDecoration: string; + textTransform: string; + whiteSpace: string; + + + } + + /** + * Encapsulates the style properties definitions and utility methods. + */ + module properties { + /** + * The font-size property definition. + */ + export var fontSizeProperty: Property; + + /** + * The color property definition. + */ + export var colorProperty: Property; + + /** + * The background-color property definition. + */ + export var backgroundColorProperty: Property; + + /** + * The text-alignment property definition. + */ + export var textAlignmentProperty: Property; + + /** + * Gets style Property by its name. + * @param The name. + */ + export function getPropertyByName(name: string): Property; + + /** + * Gets style Property by its CSS name. + * @param The CSS name. + */ + export function getPropertyByCssName(name: string): Property; + + /** + * Executes a callback for all defined style properties. + * @param The callback. + */ + export function eachProperty(callback: (property: Property) => void); + + /** + * Executes a callback for all defined inheritable style properties. + * @param The callback. + */ + export function eachInheritableProperty(callback: (property: Property) => void); + } + + /** + * Encapsulates CSS converter methods. + */ + module converters { + /** + * CSS color converter function. + * @param cssValue The css value. + */ + export function colorConverter(cssValue: any): color.Color; + + /** + * CSS font-size converter function. + * @param cssValue The css value. + */ + export function fontSizeConverter(cssValue: any): number; + + /** + * CSS text-align converter function. + * @param cssValue The css value. + */ + export function textAlignConverter(cssValue: any): string; + + /** + * CSS number converter function. + * @param cssValue The css value. + */ + export function numberConverter(cssValue: any): number; + + /** + * CSS visibility converter function. + * @param cssValue The css value. + */ + export function visibilityConverter(cssValue: any): number; + } + + /** + * Encapsulates visual states names. + */ + module visualStates { + /** + * The normal visual state. + */ + export var Normal: string; + + /** + * The hovered visual state. + */ + export var Hovered: string; + + /** + * The pressed visual state. + */ + export var Pressed: string; + } +} \ No newline at end of file diff --git a/definitions/tns-core-modules/ui/styling/visual-state-constants.d.ts b/definitions/tns-core-modules/ui/styling/visual-state-constants.d.ts new file mode 100644 index 0000000..be411f6 --- /dev/null +++ b/definitions/tns-core-modules/ui/styling/visual-state-constants.d.ts @@ -0,0 +1,16 @@ +declare module "ui/styling/visual-state-constants" { + /** + * Denotes Normal state of an UIControl. + */ + export var Normal: string; + + /** + * Denotes Hovered state of an UIControl. + */ + export var Hovered: string; + + /** + * Denotes Pressed state of an UIControl. + */ + export var Pressed: string; +} \ No newline at end of file diff --git a/definitions/tns-core-modules/ui/switch/switch.d.ts b/definitions/tns-core-modules/ui/switch/switch.d.ts new file mode 100644 index 0000000..9be9e9a --- /dev/null +++ b/definitions/tns-core-modules/ui/switch/switch.d.ts @@ -0,0 +1,33 @@ +/** + * Contains the Switch class, which represents a standard switch component. + */ +declare module "ui/switch" { + import view = require("ui/core/view"); + import dependencyObservable = require("ui/core/dependency-observable"); + + /** + * Represents a switch component. + */ + export class Switch extends view.View { + + /** + * Represents the observable property backing the checked property of each Switch instance. + */ + public static checkedProperty: dependencyObservable.Property; + + /** + * Gets the native [android widget](http://developer.android.com/reference/android/widget/Switch.html) that represents the user interface for this component. Valid only when running on Android OS. + */ + android: any /* android.widget.Switch */; + + /** + * Gets the native iOS [UISwitch](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UISwitch_Class/) that represents the user interface for this component. Valid only when running on iOS. + */ + ios: any /* UISwitch */; + + /** + * Gets or sets if a switch is checked or not. + */ + checked: boolean; + } +} diff --git a/definitions/tns-core-modules/ui/tab-view/tab-view.d.ts b/definitions/tns-core-modules/ui/tab-view/tab-view.d.ts new file mode 100644 index 0000000..dfbc6fd --- /dev/null +++ b/definitions/tns-core-modules/ui/tab-view/tab-view.d.ts @@ -0,0 +1,104 @@ +/** + * Contains the TabView class, which represents a standard content component with tabs. + */ +declare module "ui/tab-view" { + import view = require("ui/core/view"); + import dependencyObservable = require("ui/core/dependency-observable"); + import observable = require("data/observable"); + import bindable = require("ui/core/bindable"); + import color = require("color"); + + /** + * Represents a tab view entry. + */ + class TabViewItem extends bindable.Bindable { + /** + * Gets or sets the title of the TabViewItem. + */ + public title: string; + + /** + * Gets or sets the view of the TabViewItem. + */ + public view: view.View; + + /** + * Gets or sets the icon source of the TabViewItem. This could either be a a file name or resource id. + */ + public iconSource: string; + } + + /** + * Defines the data for the TabView.selectedIndexChanged event. + */ + export interface SelectedIndexChangedEventData extends observable.EventData { + /** + * The old selected index. + */ + oldIndex: number; + + /** + * The new selected index. + */ + newIndex: number; + } + + /** + * Represents a tab view. + */ + class TabView extends view.View { + public static itemsProperty: dependencyObservable.Property; + public static selectedIndexProperty: dependencyObservable.Property; + public static selectedColorProperty: dependencyObservable.Property; + + /** + * Gets or sets the items of the TabView. + */ + items: Array; + + /** + * Gets or sets the selectedIndex of the TabView. + */ + selectedIndex: number; + + /** + * Gets or sets the color used for selected item. + */ + selectedColor: color.Color; + + /** + * Gets or sets the color used for background of the tab items. + */ + tabsBackgroundColor: color.Color; + + /** + * Gets the native [android widget](http://developer.android.com/reference/android/support/v4/view/ViewPager.html) that represents the user interface for this component. Valid only when running on Android OS. + */ + android: any /* android.view.View */;//android.support.v4.view.ViewPager; + + /** + * Gets the native iOS [UITabBarController](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITabBarController_Class/) that represents the user interface for this component. Valid only when running on iOS. + */ + ios: any /* UITabBarController */; + + /** + * String value used when hooking to the selectedIndexChanged event. + */ + public static selectedIndexChangedEvent: string; + + /** + * A basic method signature to hook an event listener (shortcut alias to the addEventListener method). + * @param eventNames - String corresponding to events (e.g. "propertyChange"). Optionally could be used more events separated by `,` (e.g. "propertyChange", "change"). + * @param callback - Callback function which will be executed when event is raised. + * @param thisArg - An optional parameter which will be used as `this` context for callback execution. + */ + on(eventNames: string, callback: (data: observable.EventData) => void, thisArg?: any); + + /** + * Raised when the selected index changes. + */ + on(event: "selectedIndexChanged", callback: (args: SelectedIndexChangedEventData) => void, thisArg?: any); + + + } +} diff --git a/definitions/tns-core-modules/ui/text-base/text-base-styler.d.ts b/definitions/tns-core-modules/ui/text-base/text-base-styler.d.ts new file mode 100644 index 0000000..053dcf9 --- /dev/null +++ b/definitions/tns-core-modules/ui/text-base/text-base-styler.d.ts @@ -0,0 +1,5 @@ +declare module "ui/text-base/text-base-styler" { + export class TextBaseStyler { + public static registerHandlers(); + } +} \ No newline at end of file diff --git a/definitions/tns-core-modules/ui/text-base/text-base.d.ts b/definitions/tns-core-modules/ui/text-base/text-base.d.ts new file mode 100644 index 0000000..c49161e --- /dev/null +++ b/definitions/tns-core-modules/ui/text-base/text-base.d.ts @@ -0,0 +1,63 @@ +declare module "ui/text-base" { + import view = require("ui/core/view"); + import dependencyObservable = require("ui/core/dependency-observable"); + import formattedString = require("text/formatted-string"); + + /** + * Represents the base class for all text views. + */ + export class TextBase extends view.View implements view.AddChildFromBuilder, formattedString.FormattedStringView { + + /** + * Dependency property used to support binding operations for the text of the current text-base instance. + */ + public static textProperty: dependencyObservable.Property; + + /** + * Dependency property used to support binding operations for the formatted text of the current text-base instance. + */ + public static formattedTextProperty: dependencyObservable.Property; + + constructor(options?: Options); + + /** + * Gets or sets the text. + */ + text: string; + + /** + * Gets or sets text-alignment style property. + */ + textAlignment: string; + + /** + * Gets or sets font-size style property. + */ + fontSize: number; + + /** + * Gets or sets a formatted string. + */ + formattedText: formattedString.FormattedString; + + _onTextPropertyChanged(data: dependencyObservable.PropertyChangeData); + + /** + * Called for every child element declared in xml. + * This method will add a child element (value) to current element. + * @param name - Name of the element. + * @param value - Value of the element. + */ + _addChildFromBuilder(name: string, value: any): void; + } + + /** + * Defines interface for an optional parameter used to create a text-base component. + */ + export interface Options extends view.Options { + /** + * Gets or sets the text. + */ + text?: string; + } +} \ No newline at end of file diff --git a/definitions/tns-core-modules/ui/text-field/text-field.d.ts b/definitions/tns-core-modules/ui/text-field/text-field.d.ts new file mode 100644 index 0000000..f2a771d --- /dev/null +++ b/definitions/tns-core-modules/ui/text-field/text-field.d.ts @@ -0,0 +1,40 @@ +/** + * Contains the TextField class, which represents an editable single-line box. + */ +declare module "ui/text-field" { + import editableTextBase = require("ui/editable-text-base"); + + /** + * Represents an editable text field. + */ + export class TextField extends editableTextBase.EditableTextBase { + public static returnPressEvent: string; + + constructor(options?: editableTextBase.Options); + + /** + * Gets the native [android widget](http://developer.android.com/reference/android/widget/EditText.html) that represents the user interface for this component. Valid only when running on Android OS. + */ + android: any /* android.widget.EditText */; + + /** + * Gets the native iOS [UITextField](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITextField_Class/) that represents the user interface for this component. Valid only when running on iOS. + */ + ios: any /* UITextField */; + + /** + * Gets or sets if a text field is for password entry. + */ + secure: boolean; + } + + /** + * Defines interface for an optional parameter used to create a editable-text-base component. + */ + export interface Options extends editableTextBase.Options { + /** + * Gets or sets if a text field is for password entry. + */ + secure?: boolean; + } +} diff --git a/definitions/tns-core-modules/ui/text-view/text-view.d.ts b/definitions/tns-core-modules/ui/text-view/text-view.d.ts new file mode 100644 index 0000000..c898b01 --- /dev/null +++ b/definitions/tns-core-modules/ui/text-view/text-view.d.ts @@ -0,0 +1,23 @@ +/** + * Contains the TextView class, which represents an editable multi-line line box. + */ +declare module "ui/text-view" { + import editableTextBase = require("ui/editable-text-base"); + + /** + * Represents an editable multiline text view. + */ + export class TextView extends editableTextBase.EditableTextBase { + constructor(options?: editableTextBase.Options); + + /** + * Gets the native [android widget](http://developer.android.com/reference/android/widget/EditText.html) that represents the user interface for this component. Valid only when running on Android OS. + */ + android: any /* android.widget.EditText */; + + /** + * Gets the native iOS [UITextView](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITextView_Class/) that represents the user interface for this component. Valid only when running on iOS. + */ + ios: any /* UITextView */; + } +} diff --git a/definitions/tns-core-modules/ui/time-picker/time-picker.d.ts b/definitions/tns-core-modules/ui/time-picker/time-picker.d.ts new file mode 100644 index 0000000..ae65c1c --- /dev/null +++ b/definitions/tns-core-modules/ui/time-picker/time-picker.d.ts @@ -0,0 +1,64 @@ +/** + * Contains the TimePicker class. + */ +declare module "ui/time-picker" { + import view = require("ui/core/view"); + import dependencyObservable = require("ui/core/dependency-observable"); + + /** + * Represents an time picker. + */ + export class TimePicker extends view.View { + public static hourProperty: dependencyObservable.Property; + public static minuteProperty: dependencyObservable.Property; + + constructor(); + + /** + * Gets the native [android.widget.TimePicker](http://developer.android.com/reference/android/widget/TimePicker.html) that represents the user interface for this component. Valid only when running on Android OS. + */ + android: any /* android.widget.TimePicker */; + + /** + * Gets the native iOS [UIDatePicker](http://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UIDatePicker_Class/index.html) that represents the user interface for this component. Valid only when running on iOS. + */ + ios: any /* UIDatePicker */; + + /** + * Gets or sets the time hour. + */ + hour: number; + + /** + * Gets or sets the time minute. + */ + minute: number; + + /** + * Gets or sets the max time hour. + */ + maxHour: number; + + /** + * Gets or sets the max time minute. + */ + maxMinute: number; + + /** + * Gets or sets the min time hour. + */ + minHour: number; + + /** + * Gets or sets the min time minute. + */ + minMinute: number; + + /** + * Gets or sets the minute interval. + */ + minuteInterval: number; + + + } +} diff --git a/definitions/tns-core-modules/ui/transition/transition.d.ts b/definitions/tns-core-modules/ui/transition/transition.d.ts new file mode 100644 index 0000000..39939f4 --- /dev/null +++ b/definitions/tns-core-modules/ui/transition/transition.d.ts @@ -0,0 +1,21 @@ +declare module "ui/transition" { + import frame = require("ui/frame"); + + export module AndroidTransitionType { + export var enter: string; + export var exit: string; + export var popEnter: string; + export var popExit: string; + } + + export class Transition { + constructor(duration: number, curve: any); + public getDuration(): number; + public getCurve(): any; + public animateIOSTransition(containerView: any, fromView: any, toView: any, operation: any, completion: (finished: boolean) => void): void; + public createAndroidAnimator(transitionType: string): any; + public toString(): string; + } + + +} \ No newline at end of file diff --git a/definitions/tns-core-modules/ui/ui.d.ts b/definitions/tns-core-modules/ui/ui.d.ts new file mode 100644 index 0000000..2d80330 --- /dev/null +++ b/definitions/tns-core-modules/ui/ui.d.ts @@ -0,0 +1,56 @@ +/** + * Contains the all UI classes. + */ +declare module "ui" { + export * from "ui/action-bar"; + export * from "ui/activity-indicator"; + export * from "ui/animation"; + export * from "ui/builder"; + export * from "ui/button"; + export * from "ui/content-view"; + export * from "ui/core/bindable"; + export * from "ui/core/dependency-observable"; + export * from "ui/core/proxy"; + export * from "ui/core/view"; + export * from "ui/core/weak-event-listener"; + export * from "ui/dialogs"; + export * from "ui/date-picker"; + export * from "ui/editable-text-base"; + export * from "ui/enums"; + export * from "ui/frame"; + export * from "ui/gestures"; + export * from "ui/html-view"; + export * from "ui/image"; + export * from "ui/image-cache"; + export * from "ui/label"; + export * from "ui/layouts/layout-base"; + export * from "ui/layouts/layout"; + export * from "ui/layouts/absolute-layout"; + export * from "ui/layouts/dock-layout"; + export * from "ui/layouts/grid-layout"; + export * from "ui/layouts/stack-layout"; + export * from "ui/layouts/wrap-layout"; + export * from "ui/list-picker"; + export * from "ui/list-view"; + export * from "ui/page"; + export * from "ui/placeholder"; + export * from "ui/progress"; + export * from "ui/repeater"; + export * from "ui/scroll-view"; + export * from "ui/search-bar"; + export * from "ui/segmented-bar"; + export * from "ui/slider"; + export * from "ui/styling"; + export * from "ui/styling/background"; + export * from "ui/styling/css-selector"; + export * from "ui/styling/font"; + export * from "ui/styling/style-property"; + export * from "ui/styling/visual-state-constants"; + export * from "ui/switch"; + export * from "ui/tab-view"; + export * from "ui/text-base"; + export * from "ui/text-field"; + export * from "ui/text-view"; + export * from "ui/time-picker"; + export * from "ui/web-view"; +} \ No newline at end of file diff --git a/definitions/tns-core-modules/ui/utils.d.ts b/definitions/tns-core-modules/ui/utils.d.ts new file mode 100644 index 0000000..32025f7 --- /dev/null +++ b/definitions/tns-core-modules/ui/utils.d.ts @@ -0,0 +1,14 @@ +declare module "ui/utils" { + import view = require("ui/core/view"); + module ios { + /** + * Gets actual height of a [UIView](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIView_Class/) widget. + * @param uiView - An instance of UIView. + */ + export function getActualHeight(uiView: any /* UIView */): number; + + export function _layoutRootView(rootView: view.View, parentBounds: any /* CGRect */): void; + + export function getStatusBarHeight(): number; + } +} diff --git a/definitions/tns-core-modules/ui/web-view/web-view.d.ts b/definitions/tns-core-modules/ui/web-view/web-view.d.ts new file mode 100644 index 0000000..dbf2ba1 --- /dev/null +++ b/definitions/tns-core-modules/ui/web-view/web-view.d.ts @@ -0,0 +1,110 @@ +/** + * Contains the WebView class, which represents a standard browser widget. + */ +declare module "ui/web-view" { + import view = require("ui/core/view"); + import dependencyObservable = require("ui/core/dependency-observable"); + import observable = require("data/observable"); + + /** + * Represents a standard WebView widget. + */ + export class WebView extends view.View { + /** + * String value used when hooking to loadStarted event. + */ + public static loadStartedEvent: string; + + /** + * String value used when hooking to loadFinished event. + */ + public static loadFinishedEvent: string; + + /** + * Represents the observable property backing the Url property of each WebView instance. + */ + public static urlProperty: dependencyObservable.Property; + + /** + * Gets the native [android widget](http://developer.android.com/reference/android/webkit/WebView.html) that represents the user interface for this component. Valid only when running on Android OS. + */ + android: any /* android.webkit.WebView */; + + /** + * Gets the native [UIWebView](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIWebView_Class/) that represents the user interface for this component. Valid only when running on iOS. + */ + ios: any /* UIWebView */; + + /** + * [Obsolete. Please use src instead!] Gets or sets the url displayed by this instance. + */ + url: string; + + /** + * Gets or sets the url, local file path or HTML string. + */ + src: string; + + /** + * Gets a value indicating whether the WebView can navigate back. + */ + canGoBack: boolean; + + /** + * Gets a value indicating whether the WebView can navigate forward. + */ + canGoForward: boolean; + + /** + * Stops loading the current content (if any). + */ + stopLoading(): void; + + /** + * Navigates back. + */ + goBack(); + + /** + * Navigates forward. + */ + goForward(); + + /** + * Reload the current url. + */ + reload(); + + /** + * A basic method signature to hook an event listener (shortcut alias to the addEventListener method). + * @param eventNames - String corresponding to events (e.g. "propertyChange"). Optionally could be used more events separated by `,` (e.g. "propertyChange", "change"). + * @param callback - Callback function which will be executed when event is raised. + * @param thisArg - An optional parameter which will be used as `this` context for callback execution. + */ + on(eventNames: string, callback: (data: observable.EventData) => void, thisArg?: any); + + /** + * Raised when a loadFinished event occurs. + */ + on(event: "loadFinished", callback: (args: LoadEventData) => void, thisArg?: any); + + /** + * Raised when a loadStarted event occurs. + */ + on(event: "loadStarted", callback: (args: LoadEventData) => void, thisArg?: any); + } + + /** + * Event data containing information for the loading events of a WebView. + */ + export interface LoadEventData extends observable.EventData { + /** + * Gets the url of the web-view. + */ + url: string; + /** + * Gets the error (if any). + */ + error: string; + } +} diff --git a/definitions/tns-core-modules/utils/debug.d.ts b/definitions/tns-core-modules/utils/debug.d.ts new file mode 100644 index 0000000..12f711a --- /dev/null +++ b/definitions/tns-core-modules/utils/debug.d.ts @@ -0,0 +1,92 @@ +declare module "utils/debug" { + /** + * A runtime option indicating whether the build has debugging enabled. + */ + export var debug: boolean; + + /** + * A class encapsulating information for source code origin. + */ + export class Source { + + /** + * Creates a new Source instance by given uri, line and column. + */ + constructor(uri: string, line: number, column: number); + + /** + * Gets the URI of the source document; + */ + uri: string; + + /** + * Gets the line in the source document. + */ + line: number; + + /** + * Gets the position in the source document. + */ + column: number; + + /** + * Get the source of an object. + */ + public static get(object: any): Source; + + /** + * Set the source of an object. + */ + public static set(object: any, src: Source); + } + + /** + * An Error class that provides additional context to an error. + */ + export class ScopeError implements Error { + /** + * Creates a new ScopeError providing addtional context to the child error. + * @param child The child error to extend. + * @param message Additional message to prepend to the child error. + */ + constructor(child: Error, message?: string); + + /** + * Gets the child error. + */ + child: Error; + + /** + * Gets the error message. + */ + message: string; + + /** + * Gets the stack trace. + */ + stack: string; + + /** + * Gets the error name. + */ + name: string; + } + + /** + * Represents a scope error providing addiot + */ + export class SourceError extends ScopeError { + /** + * Creates a new SourceError by child error, source and optional message. + * @param child The child error to extend. + * @param source The source where the error occured. + * @param message Additonal message to prepend along the source location and the child error's message. + */ + constructor(child: Error, source: Source, message?: string); + + /** + * Gets the error source. + */ + source: Source; + } +} \ No newline at end of file diff --git a/definitions/tns-core-modules/utils/types.d.ts b/definitions/tns-core-modules/utils/types.d.ts new file mode 100644 index 0000000..4c4d223 --- /dev/null +++ b/definitions/tns-core-modules/utils/types.d.ts @@ -0,0 +1,86 @@ +declare module "utils/types" { + /** + * A function that checks if something is a valid string. + * @param value The value which will be checked. + * Returns true if value is a string. + */ + export function isString(value: any): boolean; + + /** + * A function that checks if something is a valid number. + * @param value The value which will be checked. + * Returns true if value is a number. + */ + export function isNumber(value: any): boolean; + + /** + * A function that checks if something is a function. + * @param value The value which will be checked. + * Returns true if value is a function. + */ + export function isFunction(value: any): boolean; + + /** + * A function that checks if something is "undefined". + * @param value The value which will be checked. + * Returns true if value is "undefined". + */ + export function isUndefined(value: any): boolean; + + /** + * A function that checks if something is defined (not undefined). + * @param value The value which will be checked. + * Returns true if value is defined. + */ + export function isDefined(value: any): boolean; + + /** + * A function that checks if something is not defined (null or undefined). + * @param value The value which will be checked. + * Returns true if value is null or undefined. + */ + export function isNullOrUndefined(value: any): boolean; + + /** + * A function that checks if something is a valid function. + * @param value The value which will be checked. + * Throws exception if passed value is not a valid function. + */ + export function verifyCallback(value: any): void; + + /** + * A function that gets the class name of an object. + * @param object The object which class will be get. + * Returns a string with the name of the class. + */ + export function getClass(object): string; + + /** + * A function that gets the entire class hierarchy of an object. + * @param object The object which class hierarchy will be get. + * Return an array of strings with the name of all classes. + */ + export function getBaseClasses(object): Array; + + /** + * A function that gets the ClassInfo for an object. + * @param object The object for which the ClassInfo will be get. + * Returns a ClassInfo for the object. + */ + export function getClassInfo(object: Object): ClassInfo; + + /** + * A Class holding information about a class + */ + export class ClassInfo { + /** + * Gets the name of the class. + */ + name: string; + + /** + * Gets the ClassInfo for the base class of the current info. + */ + baseClassInfo: ClassInfo; + } +} \ No newline at end of file diff --git a/definitions/tns-core-modules/utils/utils.d.ts b/definitions/tns-core-modules/utils/utils.d.ts new file mode 100644 index 0000000..5a8000c --- /dev/null +++ b/definitions/tns-core-modules/utils/utils.d.ts @@ -0,0 +1,231 @@ +declare module "utils/utils" { + import colorModule = require("color"); + + export var RESOURCE_PREFIX: string; + + + + /** + * Utility module related to layout. + */ + module layout { + /** + * Bits that provide the actual measured size. + */ + export var MEASURED_SIZE_MASK: number; + export var MEASURED_STATE_MASK: number; + export var MEASURED_STATE_TOO_SMALL: number; + export var UNSPECIFIED: number; + export var EXACTLY: number; + export var AT_MOST: number; + /** + * Gets measure specification mode from a given specification as string. + * @param mode - The measure specification mode. + */ + export function getMode(mode: number): string; + /** + * Gets measure specification mode from a given specification. + * @param spec - The measure specification. + */ + export function getMeasureSpecMode(spec: number): number; + /** + * Gets measure specification size from a given specification. + * @param spec - The measure specification. + */ + export function getMeasureSpecSize(spec: number): number; + /** + * Creates measure specification size from size and mode. + * @param size - The size component of measure specification. + * @param mode - The mode component of measure specification. + */ + export function makeMeasureSpec(size: number, mode: number): number; + /** + * Gets display density for the current device. + */ + export function getDisplayDensity(): number; + /** + * Convert value to device pixels. + * @param value - The pixel to convert. + */ + export function toDevicePixels(value: number): number; + /** + * Convert value to device independent pixels. + * @param value - The pixel to convert. + */ + export function toDeviceIndependentPixels(value: number): number; + + export function measureSpecToString(measureSpec: number): string; + } + + /** + * Module with android specific utilities. + */ + module ad { + export function setTextTransform(view, value: string); + export function setWhiteSpace(view, value: string); + export function setTextDecoration(view, value: string); + + /** + * Gets the native Android application instance. + */ + export function getApplication(): any /* android.app.Application */; + + /** + * Gets the Android application context. + */ + export function getApplicationContext(): any /* android.content.Context */; + + /** + * Gets the native Android input method manager. + */ + export function getInputMethodManager(): any /* android.view.inputmethod.InputMethodManager */; + + /** + * Hides the soft input method, ususally a soft keyboard. + */ + export function dismissSoftInput(nativeView: any /* android.view.View */): void; + + /** + * Shows the soft input method, ususally a soft keyboard. + */ + export function showSoftInput(nativeView: any /* android.view.View */): void; + + /** + * Utility module dealing with some android collections. + */ + module collections { + /** + * Converts string array into a String [hash set](http://developer.android.com/reference/java/util/HashSet.html). + * @param str - An array of strings to convert. + */ + export function stringArrayToStringSet(str: string[]): any; + /** + * Converts string hash set into array of strings. + * @param stringSet - A string hash set to convert. + */ + export function stringSetToStringArray(stringSet: any): string[]; + } + + /** + * Utility module related to android resources. + */ + module resources { + /** + * Gets the drawable id from a given name. + * @param name - Name of the resource. + */ + export function getDrawableId(name); + /** + * Gets the string id from a given name. + * @param name - Name of the resource. + */ + export function getStringId(name) + + /** + * Gets the id from a given name. + * @param name - Name of the resource. + */ + export function getId(name: string): number; + + /** + * Gets a color from the current theme. + * @param name - Name of the color resource. + */ + export function getPalleteColor(name: string, context: any /* android.content.Context */): number; + } + } + /** + * Module with ios specific utilities. + */ + module ios { + export function setTextDecorationAndTransform(view: any, decoration: string, transform: string); + export function setWhiteSpace(view, value: string, parentView?: any); + export function setTextAlignment(view, value: string); + + export interface TextUIView { + font: any; + textAlignment: number; + textColor: any; + text: string; + attributedText: any; + lineBreakMode: number; + numberOfLines: number; + } + + /** + * Utility module dealing with some iOS collections. + */ + module collections { + /** + * Converts JavaScript array to [NSArray](https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/). + * @param str - JavaScript string array to convert. + */ + export function jsArrayToNSArray(str: string[]): any; + /** + * Converts NSArray to JavaScript array. + * @param str - NSArray to convert. + */ + export function nsArrayToJSArray(a: any): string[]; + } + + /** + * Gets NativeScript color from [UIColor](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIColor_Class/). + * @param uiColor - UIColor instance used to create a NativeScript color. + */ + export function getColor(uiColor: any /* UIColor */): colorModule.Color; + /** + * Gets an information about if current mode is Landscape. + */ + export function isLandscape(): boolean; + /** + * Gets the iOS device major version (for 8.1 will return 8). + */ + export var MajorVersion: number; + + /** + * Opens file with associated application. + * @param filePath The file path. + */ + export function openFile(filePath: string): boolean + } + /** + * An utility function that copies properties from source object to target object. + * @param source - The source object. + * @param target - The target object. + */ + export function copyFrom(source: any, target: any); + /** + * An utility function that invokes garbage collection on the JavaScript side. + */ + export function GC(); + + /** + * Returns true if the specified path points to a resource or local file. + * @param path The path. + */ + export function isFileOrResourcePath(path: string): boolean + + /** + * Returns true if the specified URI is data URI (http://en.wikipedia.org/wiki/Data_URI_scheme). + * @param uri The URI. + */ + export function isDataURI(uri: string): boolean + + /** + * Returns object from JSON or JSONP string. + * @param source The JSON or JSONP string. + */ + export function parseJSON(source: string): any + + /** + * Opens url. + * @param url The url. + */ + export function openUrl(url: string): boolean + + /** + * Escapes special regex symbols (., *, ^, $ and so on) in string in order to create a valid regex from it. + * @param source The original value. + */ + export function escapeRegexSymbols(source: string): string +} diff --git a/definitions/tns-core-modules/weakmap.d.ts b/definitions/tns-core-modules/weakmap.d.ts new file mode 100644 index 0000000..d99417f --- /dev/null +++ b/definitions/tns-core-modules/weakmap.d.ts @@ -0,0 +1,13 @@ +/* tslint:disable:no-unused-variable */ + +interface WeakMap { + clear(): void; + delete(key: K): boolean; + get(key: K): V; + has(key: K): boolean; + set(key: K, value: V): WeakMap; +} + +declare var WeakMap: { + new (): WeakMap; +} diff --git a/definitions/tns-core-modules/xml/xml.d.ts b/definitions/tns-core-modules/xml/xml.d.ts new file mode 100644 index 0000000..67436cf --- /dev/null +++ b/definitions/tns-core-modules/xml/xml.d.ts @@ -0,0 +1,117 @@ +/** + * Contains the XmlParser class, which is a SAX parser using the easysax implementation + */ +declare module "xml" { + + /** + * Specifies the type of parser event. + */ + class ParserEventType { + + /** + * Specifies the StartElement event type. + */ + static StartElement: string; + + /** + * Specifies the EndElement event type. + */ + static EndElement: string; + + /** + * Specifies the Text event type. + */ + static Text: string; + + /** + * Specifies the CDATA event type. + */ + static CDATA: string; + + /** + * Specifies the Comment event type. + */ + static Comment: string; + } + + /** + * Defines a position within string, in line and column form. + */ + interface Position { + /** + * The line number. The first line is at index 1. + */ + line: number; + + /** + * The column number. The first character is at index 1. + */ + column: number; + } + + /** + * Provides information for a parser event. + */ + interface ParserEvent { + + /** + * Returns the type of the parser event. This is one of the ParserEventType static members. + */ + eventType: string; + + /** + * Get the position in the xml string where the event was generated. + */ + position: Position; + + /** + * If namespace processing is enabled, returns the prefix of the element in case the eventType is ParserEventType.StartElement or ParserEventType.EndElement. + */ + prefix?: string; + + /** + * If namespace processing is enabled, returns the namespace of the element in case the eventType is ParserEventType.StartElement or ParserEventType.EndElement. + */ + namespace?: string; + + /** + * Returns the name of the element in case the eventType is ParserEventType.StartElement or ParserEventType.EndElement. + */ + elementName?: string; + + /** + * Returns a JSON object with the attributes of an element in case the eventType is ParserEventType.StartElement. + */ + attributes?: Object; + + /** + * Returns the relevant data in case the eventType is ParserEventType.Text, ParserEventType.CDATA or ParserEventType.Comment. + */ + data?: string; + + /** + * Returns a JSON string representation of this instance. + */ + toString(): string; + } + + /** + * A simple non-validating SAX parser based on https://github.com/vflash/easysax version 0.1.14 + */ + class XmlParser { + + /** + * Creates a new instance of the XmlParser class. + * @param onEvent The callback to execute when a parser event occurs. The 'event' parameter contains information about the event. + * @param onError The callback to execute when a parser error occurs. The 'error' parameter contains the error. + * @param processNamespaces Specifies whether namespaces should be processed. + */ + constructor(onEvent: (event: ParserEvent) => void, onError?: (error: Error, position: Position) => void, processNamespaces?: boolean, angularSyntax?: boolean); + + /** + * Parses the supplied xml string. + * @param xmlString The string containing the xml to parse. + */ + parse(xmlString: string): void; + } +} diff --git a/lib/after-prepare.ts b/lib/after-prepare.ts new file mode 100644 index 0000000..92cabf4 --- /dev/null +++ b/lib/after-prepare.ts @@ -0,0 +1,15 @@ +import * as path from "path"; +import * as fs from "fs"; + +module.exports = function ($platformsData, $testExecutionService) { + if($testExecutionService && $testExecutionService.platform) { + let platformData = $platformsData.getPlatformData($testExecutionService.platform), + projectFilesPath = path.join(platformData.appDestinationDirectoryPath, "app"), + packageJsonPath = path.join(projectFilesPath, 'package.json'), + packageJson = JSON.parse(fs.readFileSync(packageJsonPath).toString()); + + // When test command is used in ns-cli, we should change the entry point of the application + packageJson.main = "./tns_modules/nativescript-unit-test-runner/app.js"; + fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson)); + } +} diff --git a/package.json b/package.json index 2c795f9..d532c24 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,12 @@ { "name": "nativescript-unit-test-runner", - "version": "0.2.8", + "version": "0.3.0", "description": "NativeScript unit test runner component.", "main": "app.js", "scripts": { - "test": "exit 0" + "test": "exit 0", + "preuninstall": "node preuninstall.js", + "postinstall": "node postinstall.js" }, "repository": { "type": "git", @@ -14,8 +16,26 @@ "license": "Apache-2.0", "devDependencies": { "grunt": "^0.4.5", - "grunt-ts": "^5.0.1" + "grunt-contrib-clean": "^1.0.0", + "grunt-contrib-watch": "^0.6.1", + "grunt-shell": "^1.1.2", + "grunt-ts": "^5.0.1", + "typescript": "^1.8.2" }, "nativescript": { + "platforms": { + "android": "1.6.0", + "ios": "1.6.0" + }, + "hooks": [ + { + "type": "after-prepare", + "script": "lib/after-prepare.js", + "inject": true + } + ] + }, + "dependencies": { + "nativescript-hook": "^0.2.1" } } diff --git a/postinstall.js b/postinstall.js new file mode 100644 index 0000000..917916f --- /dev/null +++ b/postinstall.js @@ -0,0 +1,3 @@ +var hook = require('nativescript-hook')(__dirname); +hook.postinstall(); + diff --git a/preuninstall.js b/preuninstall.js new file mode 100644 index 0000000..b72ac69 --- /dev/null +++ b/preuninstall.js @@ -0,0 +1 @@ +require('nativescript-hook')(__dirname).preuninstall();