diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index bb0933af5..5d99d1044 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -73,6 +73,7 @@ All definitions files include a header with the author and editors, so at some p * [Elm](http://elm-lang.org) (by [Dénes Harmath](https://github.com/thSoft)) * [ember.js](http://emberjs.com/) (by [Boris Yankov](https://github.com/borisyankov)) * [emissary](https://github.com/atom/emissary) (by [vvakame](https://github.com/vvakame)) +* [Emscripten](http://kripken.github.io/emscripten-site/) (by [Kensuke MATSUZAKI](https://github.com/zakki)) * [EpicEditor](http://epiceditor.com/) (by [Boris Yankov](https://github.com/borisyankov)) * [ES6-Promises](https://github.com/jakearchibald/ES6-Promises) (by [François de Campredon](https://github.com/fdecampredon/)) * [Esprima](http://esprima.org/) (by [Teppei Sato](https://github.com/teppeis)) @@ -117,6 +118,7 @@ All definitions files include a header with the author and editors, so at some p * [Google Translate API](https://developers.google.com/translate/) (by [Frank M](https://github.com/sgtfrankieboy)) * [Google Url Shortener](https://developers.google.com/url-shortener/) (by [Frank M](https://github.com/sgtfrankieboy)) * [Hammer.js](http://eightmedia.github.com/hammer.js/) (by [Boris Yankov](https://github.com/borisyankov)) +* [Hapi](http://github.com/spumko/hapi) (by [Hakubo](http://github.com/hakubo)) * [Handlebars](http://handlebarsjs.com/) (by [Boris Yankov](https://github.com/borisyankov)) * [HashMap](https://github.com/flesler/hashmap) (by [Rafał Wrzeszcz](https://wrzasq.pl)) * [HashSet](http://www.timdown.co.uk/jshashtable/jshashset.html) (by [Sergey Gerasimov](https://github.com/gerich-home)) @@ -320,6 +322,7 @@ All definitions files include a header with the author and editors, so at some p * [SignalR](http://www.asp.net/signalr) (by [Boris Yankov](https://github.com/borisyankov)) * [simple-cw-node](https://github.com/astronaughts/simple-cw-node) (by [vvakame](https://github.com/vvakame)) * [Sinon](http://sinonjs.org/) (by [William Sears](https://github.com/mrbigdog2u)) +* [SIPml](http://sipml5.org/) (by [Adriaan Groenenboom](https://github.com/chookies)) * [sjcl](http://crypto.stanford.edu/sjcl/) (by [Eugene Chernyshov](https://github.com/Evgenus)) * [SlickGrid](https://github.com/mleibman/SlickGrid) (by [Josh Baldwin](https://github.com/jbaldwin)) * [smoothie](https://github.com/joewalnes/smoothie) (by [Mike H. Hawley](https://github.com/mikehhawley) and [Drew Noakes](https://drewnoakes.com)) diff --git a/angular-ui-bootstrap/angular-ui-bootstrap-tests.ts b/angular-ui-bootstrap/angular-ui-bootstrap-tests.ts index 8ed8be859..608591b58 100644 --- a/angular-ui-bootstrap/angular-ui-bootstrap-tests.ts +++ b/angular-ui-bootstrap/angular-ui-bootstrap-tests.ts @@ -118,7 +118,7 @@ testApp.config(( }); testApp.controller('TestCtrl', ( - $scope: ng.IScope, + $scope: ng.ui.bootstrap.IModalScope, $log: ng.ILogService, $modal: ng.ui.bootstrap.IModalService, $modalStack: ng.ui.bootstrap.IModalStackService, @@ -147,9 +147,9 @@ testApp.controller('TestCtrl', ( $log.log('modal opened'); }); - modalInstance.result.then(closeResult=> { + modalInstance.result.then((closeResult:any)=> { $log.log('modal closed', closeResult); - }, dismissResult=> { + }, (dismissResult:any)=> { $log.log('modal dismissed', dismissResult); }); diff --git a/angular-ui-bootstrap/angular-ui-bootstrap.d.ts b/angular-ui-bootstrap/angular-ui-bootstrap.d.ts index 2d792d1b1..ad90dc9db 100644 --- a/angular-ui-bootstrap/angular-ui-bootstrap.d.ts +++ b/angular-ui-bootstrap/angular-ui-bootstrap.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Angular UI Bootstrap 0.10.0 +// Type definitions for Angular UI Bootstrap 0.11.0 // Project: https://github.com/angular-ui/bootstrap // Definitions by: Brian Surowiec // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -198,6 +198,22 @@ declare module ng.ui.bootstrap { opened: ng.IPromise; } + interface IModalScope extends ng.IScope { + /** + * Those methods make it easy to close a modal window without a need to create a dedicated controller + */ + + /** + * Dismiss the dialog without assigning a value to the promise output + */ + $dismiss(reason?: any): void; + + /** + * Close the dialog resolving the promise to the given value + */ + $close(result?: any): void; + } + interface IModalSettings { /** * a path to a template representing modal's content @@ -211,9 +227,9 @@ declare module ng.ui.bootstrap { /** * a scope instance to be used for the modal's content (actually the $modal service is going to create a child scope of a provided scope). - * Defaults to `$rootScope` + * Defaults to `$rootScope`. */ - scope?: any; + scope?: IModalScope; /** * a controller for a modal instance - it can initialize scope used by modal. @@ -246,6 +262,16 @@ declare module ng.ui.bootstrap { * additional CSS class(es) to be added to a modal window template */ windowClass?: string; + + /** + * optional size of modal window. Allowed values: 'sm' (small) or 'lg' (large). Requires Bootstrap 3.1.0 or later + */ + size?: string; + + /** + * a path to a template overriding modal's window template + */ + windowTemplateUrl?: string; } interface IModalStackService { diff --git a/chrome/chrome.d.ts b/chrome/chrome.d.ts index e7e58dbbc..df655e2b8 100755 --- a/chrome/chrome.d.ts +++ b/chrome/chrome.d.ts @@ -2230,13 +2230,19 @@ declare module chrome.webRequest { username: string; password: string; } - + + interface HttpHeader { + name: string; + value?: string; + binaryValue?: ArrayBuffer; + } + interface BlockingResponse { cancel?: boolean; redirectUrl?: string; - responseHeaders?: Object; + responseHeaders?: HttpHeader[]; authCredentials?: AuthCredentials; - requestHeaders?: Object; + requestHeaders?: HttpHeader[]; } interface RequestFilter { @@ -2256,7 +2262,7 @@ declare module chrome.webRequest { ip?: string; statusLine?: string; frameId: number; - responseHeaders?: Object; + responseHeaders?: HttpHeader[]; parentFrameId: number; fromCache: boolean; url: string; @@ -2275,7 +2281,7 @@ declare module chrome.webRequest { statusLine?: string; frameId: number; requestId: string; - responseHeaders: Object; + responseHeaders?: HttpHeader[]; type: string; method: string; } @@ -2285,7 +2291,7 @@ declare module chrome.webRequest { ip?: string; statusLine?: string; frameId: number; - responseHeaders?: Object; + responseHeaders?: HttpHeader[]; parentFrameId: number; fromCache: boolean; url: string; @@ -2307,7 +2313,7 @@ declare module chrome.webRequest { statusLine?: string; frameId: number; challenger: Challenger; - responseHeaders: Object; + responseHeaders?: HttpHeader[]; isProxy: boolean; realm?: string; parentFrameId: number; @@ -2326,7 +2332,7 @@ declare module chrome.webRequest { timeStamp: number; frameId: number; requestId: number; - requestHeaders?: Object; + requestHeaders?: HttpHeader[]; type: string; method: string; } @@ -2350,7 +2356,7 @@ declare module chrome.webRequest { ip?: string; statusLine?: string; frameId: number; - responseHeaders?: Object; + responseHeaders?: HttpHeader[]; parentFrameId: number; fromCache: boolean; url: string; @@ -2368,7 +2374,7 @@ declare module chrome.webRequest { timeStamp: number; frameId: number; requestId: string; - requestHeaders: Object; + requestHeaders?: HttpHeader[]; type: string; method: string; } diff --git a/d3/d3.d.ts b/d3/d3.d.ts index a451a0de5..e2bf337e4 100644 --- a/d3/d3.d.ts +++ b/d3/d3.d.ts @@ -1102,6 +1102,8 @@ declare module D3 { (layers: T[], index?: number): T[]; values(accessor?: (d: any) => any): StackLayout; offset(offset: string): StackLayout; + x(accessor: (d: any, i: number) => any): StackLayout; + y(accessor: (d: any, i: number) => any): StackLayout; } export interface TreeLayout { diff --git a/dropzone/dropzone.d.ts b/dropzone/dropzone.d.ts index 81596d88a..5dca7e169 100644 --- a/dropzone/dropzone.d.ts +++ b/dropzone/dropzone.d.ts @@ -72,6 +72,22 @@ declare class Dropzone { getRejectedFiles(): DropzoneFile[]; getQueuedFiles(): DropzoneFile[]; getUploadingFiles(): DropzoneFile[]; + + emit(eventName: string, file: DropzoneFile, str?: string); + emit(eventName: "thumbnail", file: DropzoneFile, path: string); + emit(eventName: "addedfile", file: DropzoneFile); + emit(eventName: "removedfile", file: DropzoneFile); + emit(eventName: "processing", file: DropzoneFile); + emit(eventName: "canceled", file: DropzoneFile); + emit(eventName: "complete", file: DropzoneFile); + + emit(eventName: string, e: Event); + emit(eventName: "drop", e: Event); + emit(eventName: "dragstart", e: Event); + emit(eventName: "dragend", e: Event); + emit(eventName: "dragenter", e: Event); + emit(eventName: "dragover", e: Event); + emit(eventName: "dragleave", e: Event); } interface JQuery { diff --git a/ember/ember.d.ts b/ember/ember.d.ts index 2a0b35e42..878d8a49c 100644 --- a/ember/ember.d.ts +++ b/ember/ember.d.ts @@ -11,12 +11,15 @@ declare var Handlebars: HandlebarsStatic; declare module EmberStates { interface Transition { + abort(): void; addInitialStates(): void; matchContextsToStates(contexts: any[]): void; normalize(manager: Ember.StateManager, contexts: any[]): void; removeUnchangedContexts(manager: Ember.StateManager): void; + retry(): void; sendEvents(eventName: string, sendRecursiveArguments: boolean, isUnhandledPass: boolean): void; sendRecursively(event: string, currentState: Ember.State, isUnhandledPass: boolean): void; + targetName: string; } } @@ -38,10 +41,10 @@ declare module EmberTesting { } interface Function { - observes(...string): Function; - observesBefore(...string): Function; - on(...string): Function; - property(...string): Function; + observes(...args: string[]): Function; + observesBefore(...args: string[]): Function; + on(...args: string[]): Function; + property(...args: string[]): Function; } interface String { @@ -50,9 +53,9 @@ interface String { classify(): string; dasherize(): string; decamelize(): string; - fmt(...string): string; + fmt(...args: string[]): string; htmlSafe(): typeof Handlebars.SafeString; - loc(...string): string; + loc(...args: string[]): string; underscore(): string; w(): string[]; } @@ -70,14 +73,14 @@ interface Array { clear(): any[]; compact(): any[]; contains(obj: any): boolean; - enumerableContentDidChange(start: number, removing: number, adding: number); - enumerableContentDidChange(start: number, removing: Ember.Enumerable, adding: number); - enumerableContentDidChange(start: number, removing: number, adding: Ember.Enumerable); - enumerableContentDidChange(start: number, removing: Ember.Enumerable, adding: Ember.Enumerable); - enumerableContentDidChange(removing: number, adding: number); - enumerableContentDidChange(removing: Ember.Enumerable, adding: number); - enumerableContentDidChange(removing: number, adding: Ember.Enumerable); - enumerableContentDidChange(removing: Ember.Enumerable, adding: Ember.Enumerable); + enumerableContentDidChange(start: number, removing: number, adding: number): any; + enumerableContentDidChange(start: number, removing: Ember.Enumerable, adding: number): any; + enumerableContentDidChange(start: number, removing: number, adding: Ember.Enumerable): any; + enumerableContentDidChange(start: number, removing: Ember.Enumerable, adding: Ember.Enumerable): any; + enumerableContentDidChange(removing: number, adding: number): any; + enumerableContentDidChange(removing: Ember.Enumerable, adding: number): any; + enumerableContentDidChange(removing: number, adding: Ember.Enumerable): any; + enumerableContentDidChange(removing: Ember.Enumerable, adding: Ember.Enumerable): any; enumerableContentWillChange(removing: number, adding: number): any[]; enumerableContentWillChange(removing: Ember.Enumerable, adding: number): any[]; enumerableContentWillChange(removing: number, adding: Ember.Enumerable): any[]; @@ -93,15 +96,15 @@ interface Array { getEach(key: string): any[]; indexOf(object: any, startAt: number): number; insertAt(idx: number, object: any): any[]; - invoke(methodName: string, ...any): any[]; + invoke(methodName: string, ...args: any[]): any[]; lastIndexOf(object: any, startAt: number): number; mapBy(key: string): any[]; nextObject(index: number, previousObject: any, context: any): any; objectAt(idx: number): any; - objectsAt(...number): any[]; + objectsAt(...args: number[]): any[]; popObject(): any; pushObject(obj: any): any; - pushObjects(...any): any[]; + pushObjects(...args: any[]): any[]; reduce(callback: ReduceCallback, initialValue: any, reducerProperty: string): any; reject: ItemIndexEnumerableCallbackTarget; rejectBy(key: string, value?: string): any[]; @@ -136,7 +139,7 @@ interface Array { decrementProperty(keyName: string, decrement?: number): number; endPropertyChanges(): any[]; get(keyName: string): any; - getProperties(...string): {}; + getProperties(...args: string[]): {}; getProperties(keys: string[]): {}; getWithDefault(keyName: string, defaultValue: any): any; hasObserverFor(key: string): boolean; @@ -190,8 +193,8 @@ interface CoreObjectArguments { } interface EnumerableConfigurationOptions { - willChange? ; - didChange? ; + willChange?: boolean ; + didChange?: boolean ; } interface ItemIndexEnumerableCallbackTarget { @@ -365,14 +368,14 @@ declare module Ember { someProperty(key: string, value?: string): boolean; compact(): any[]; contains(obj: any): boolean; - enumerableContentDidChange(start: number, removing: number, adding: number); - enumerableContentDidChange(start: number, removing: Enumerable, adding: number); - enumerableContentDidChange(start: number, removing: number, adding: Enumerable); - enumerableContentDidChange(start: number, removing: Enumerable, adding: Enumerable); - enumerableContentDidChange(removing: number, adding: number); - enumerableContentDidChange(removing: Enumerable, adding: number); - enumerableContentDidChange(removing: number, adding: Enumerable); - enumerableContentDidChange(removing: Enumerable, adding: Enumerable); + enumerableContentDidChange(start: number, removing: number, adding: number): any; + enumerableContentDidChange(start: number, removing: Enumerable, adding: number): any; + enumerableContentDidChange(start: number, removing: number, adding: Enumerable): any; + enumerableContentDidChange(start: number, removing: Enumerable, adding: Enumerable): any; + enumerableContentDidChange(removing: number, adding: number): any; + enumerableContentDidChange(removing: Enumerable, adding: number): any; + enumerableContentDidChange(removing: number, adding: Enumerable): any; + enumerableContentDidChange(removing: Enumerable, adding: Enumerable): any; enumerableContentWillChange(removing: number, adding: number): Enumerable; enumerableContentWillChange(removing: Enumerable, adding: number): Enumerable; enumerableContentWillChange(removing: number, adding: Enumerable): Enumerable; @@ -387,13 +390,13 @@ declare module Ember { forEach(callback: Function, target?: any): any; getEach(key: string): any[]; indexOf(object: any, startAt: number): number; - invoke(methodName: string, ...any): any[]; + invoke(methodName: string, ...args: any[]): any[]; lastIndexOf(object: any, startAt: number): number; map: ItemIndexEnumerableCallbackTarget; mapBy(key: string): any[]; nextObject(index: number, previousObject: any, context: any): any; objectAt(idx: number): any; - objectsAt(...number): any[]; + objectsAt(...args: number[]): any[]; reduce(callback: ReduceCallback, initialValue: any, reducerProperty: string): any; reject: ItemIndexEnumerableCallbackTarget; rejectBy(key: string, value?: string): any[]; @@ -405,9 +408,9 @@ declare module Ember { toArray(): any[]; uniq(): Enumerable; without(value: any): Enumerable; - '@each': EachProxy; + '@each': EachProxy; Boolean: boolean; - '[]': any[]; + '[]': any[]; firstObject: any; hasEnumerableObservers: boolean; lastObject: any; @@ -438,8 +441,8 @@ declare module Ember { sortAscending: boolean; sortFunction: Comparable; sortProperties: any[]; - replaceRoute(name: string, ...any); - transitionToRoute(name: string, ...any); + replaceRoute(name: string, ...args: any[]): void; + transitionToRoute(name: string, ...args: any[]): void; controllers: {}; needs: string[]; target: any; @@ -482,14 +485,14 @@ declare module Ember { clear(): any[]; compact(): any[]; contains(obj: any): boolean; - enumerableContentDidChange(start: number, removing: number, adding: number); - enumerableContentDidChange(start: number, removing: Enumerable, adding: number); - enumerableContentDidChange(start: number, removing: number, adding: Enumerable); - enumerableContentDidChange(start: number, removing: Enumerable, adding: Enumerable); - enumerableContentDidChange(removing: number, adding: number); - enumerableContentDidChange(removing: Enumerable, adding: number); - enumerableContentDidChange(removing: number, adding: Enumerable); - enumerableContentDidChange(removing: Enumerable, adding: Enumerable); + enumerableContentDidChange(start: number, removing: number, adding: number): any; + enumerableContentDidChange(start: number, removing: Enumerable, adding: number): any; + enumerableContentDidChange(start: number, removing: number, adding: Enumerable): any; + enumerableContentDidChange(start: number, removing: Enumerable, adding: Enumerable): any; + enumerableContentDidChange(removing: number, adding: number): any; + enumerableContentDidChange(removing: Enumerable, adding: number): any; + enumerableContentDidChange(removing: number, adding: Enumerable): any; + enumerableContentDidChange(removing: Enumerable, adding: Enumerable): any; enumerableContentWillChange(removing: number, adding: number): any[]; enumerableContentWillChange(removing: Enumerable, adding: number): any[]; enumerableContentWillChange(removing: number, adding: Enumerable): any[]; @@ -505,24 +508,24 @@ declare module Ember { getEach(key: string): any[]; indexOf(object: any, startAt: number): number; insertAt(idx: number, object: any): any[]; - invoke(methodName: string, ...any): any[]; + invoke(methodName: string, ...args: any[]): any[]; lastIndexOf(object: any, startAt: number): number; map: ItemIndexEnumerableCallbackTarget; mapBy(key: string): any[]; nextObject(index: number, previousObject: any, context: any): any; objectAt(idx: number): any; objectAtContent(idx: number): any; - objectsAt(...number): any[]; + objectsAt(...args: number[]): any[]; popObject(): any; pushObject(obj: any): any; - pushObjects(...any): any[]; + pushObjects(...args: any[]): any[]; reduce(callback: ReduceCallback, initialValue: any, reducerProperty: string): any; reject: ItemIndexEnumerableCallbackTarget; rejectBy(key: string, value?: string): any[]; removeArrayObserver(target: any, opts: EnumerableConfigurationOptions): any[]; removeAt(start: number, len: number): any; removeEnumerableObserver(target: any, opts: EnumerableConfigurationOptions): any[]; - replace(idx: number, amt: number, objects: any[]); + replace(idx: number, amt: number, objects: any[]): any; replaceContent(idx: number, amt: number, objects: any[]): void; reverseObjects(): any[]; setEach(key: string, value?: any): any; @@ -535,8 +538,8 @@ declare module Ember { unshiftObject(object: any): any; unshiftObjects(objects: any[]): any[]; without(value: any): any[]; - '[]': any[]; - '@each': EachProxy; + '[]': any[]; + '@each': EachProxy; Boolean: boolean; firstObject: any; hasEnumerableObservers: boolean; @@ -657,7 +660,7 @@ declare module Ember { cacheable(aFlag?: boolean): ComputedProperty; get(keyName: string): any; meta(meta: {}): ComputedProperty; - property(...string): ComputedProperty; + property(...args: string[]): ComputedProperty; readOnly(): ComputedProperty; set(keyName: string, newValue: any, oldValue: string): any; // ReSharper disable UsingOfReservedWord @@ -721,8 +724,8 @@ declare module Ember { Additional methods for the ControllerMixin. **/ class ControllerMixin { - replaceRoute(name: string, ...any): void; - transitionToRoute(name: string, ...any): void; + replaceRoute(name: string, ...args: any[]): void; + transitionToRoute(name: string, ...args: any[]): void; controllers: {}; needs: string[]; target: any; @@ -879,14 +882,14 @@ declare module Ember { someProperty(key: string, value?: string): boolean; compact(): any[]; contains(obj: any): boolean; - enumerableContentDidChange(start: number, removing: number, adding: number); - enumerableContentDidChange(start: number, removing: Enumerable, adding: number); - enumerableContentDidChange(start: number, removing: number, adding: Enumerable); - enumerableContentDidChange(start: number, removing: Enumerable, adding: Enumerable); - enumerableContentDidChange(removing: number, adding: number); - enumerableContentDidChange(removing: Enumerable, adding: number); - enumerableContentDidChange(removing: number, adding: Enumerable); - enumerableContentDidChange(removing: Enumerable, adding: Enumerable); + enumerableContentDidChange(start: number, removing: number, adding: number): any; + enumerableContentDidChange(start: number, removing: Enumerable, adding: number): any; + enumerableContentDidChange(start: number, removing: number, adding: Enumerable): any; + enumerableContentDidChange(start: number, removing: Enumerable, adding: Enumerable): any; + enumerableContentDidChange(removing: number, adding: number): any; + enumerableContentDidChange(removing: Enumerable, adding: number): any; + enumerableContentDidChange(removing: number, adding: Enumerable): any; + enumerableContentDidChange(removing: Enumerable, adding: Enumerable): any; enumerableContentWillChange(removing: number, adding: number): Enumerable; enumerableContentWillChange(removing: Enumerable, adding: number): Enumerable; enumerableContentWillChange(removing: number, adding: Enumerable): Enumerable; @@ -900,7 +903,7 @@ declare module Ember { findBy(key: string, value?: string): any; forEach(callback: Function, target?: any): any; getEach(key: string): any[]; - invoke(methodName: string, ...any): any[]; + invoke(methodName: string, ...args: any[]): any[]; map: ItemIndexEnumerableCallbackTarget; mapBy(key: string): any[]; nextObject(index: number, previousObject: any, context: any): any; @@ -913,7 +916,7 @@ declare module Ember { toArray(): any[]; uniq(): Enumerable; without(value: any): Enumerable; - '[]': any[]; + '[]': any[]; firstObject: any; hasEnumerableObservers: boolean; lastObject: any; @@ -954,7 +957,7 @@ declare module Ember { off(name: string, target: any, method: Function): Evented; on(name: string, target: any, method: Function): Evented; one(name: string, target: any, method: Function): Evented; - trigger(name: string, ...string): void; + trigger(name: string, ...args: string[]): void; } var FROZEN_ERROR: string; class Freezable { @@ -996,19 +999,19 @@ declare module Ember { class Compiler { } class JavaScriptCompiler { } function registerHelper(name: string, fn: Function, inverse?: boolean): void; - function registerPartial(name: string, str): void; - function K(); - function createFrame(object); + function registerPartial(name: string, str: any): void; + function K(): any; + function createFrame(objec: any): any; function Exception(message: string): void; class SafeString { constructor(str: string); static toString(): string; } - function parse(string: string); - function print(ast); - var logger; - function log(level, str): void; - function compile(environment, options?, context?, asObject?); + function parse(string: string): any; + function print(ast: any): void; + var logger: typeof Ember.Logger; + function log(level: string, str: string): void; + function compile(environment: any, options?: any, context?: any, asObject?: any): any; } class HashLocation extends Object { static detect(obj: any): boolean; @@ -1046,7 +1049,7 @@ declare module Ember { var IS_BINDING: RegExp; class Instrumentation { getProperties(obj: any, list: any[]): {}; - getProperties(obj: any, ...string): {}; + getProperties(obj: any, ...args: string[]): {}; instrument(name: string, payload: any, callback: Function, binding: any): void; reset(): void; subscribe(pattern: string, object: any): void; @@ -1094,11 +1097,11 @@ declare module Ember { } var Logger: { assert(param: any): void; - debug(...any): void; - error(...any): void; - info(...any): void; - log(...any): void; - warn(...any): void; + debug(...args: any[]): void; + error(...args: any[]): void; + info(...args: any[]): void; + log(...args: any[]): void; + warn(...args: any[]): void; }; function MANDATORY_SETTER_FUNCTION(value: string): void; var META_KEY: string; @@ -1137,14 +1140,14 @@ declare module Ember { clear(): any[]; compact(): any[]; contains(obj: any): boolean; - enumerableContentDidChange(start: number, removing: number, adding: number); - enumerableContentDidChange(start: number, removing: Enumerable, adding: number); - enumerableContentDidChange(start: number, removing: number, adding: Enumerable); - enumerableContentDidChange(start: number, removing: Enumerable, adding: Enumerable); - enumerableContentDidChange(removing: number, adding: number); - enumerableContentDidChange(removing: Enumerable, adding: number); - enumerableContentDidChange(removing: number, adding: Enumerable); - enumerableContentDidChange(removing: Enumerable, adding: Enumerable); + enumerableContentDidChange(start: number, removing: number, adding: number): any; + enumerableContentDidChange(start: number, removing: Enumerable, adding: number): any; + enumerableContentDidChange(start: number, removing: number, adding: Enumerable): any; + enumerableContentDidChange(start: number, removing: Enumerable, adding: Enumerable): any; + enumerableContentDidChange(removing: number, adding: number): any; + enumerableContentDidChange(removing: Enumerable, adding: number): any; + enumerableContentDidChange(removing: number, adding: Enumerable): any; + enumerableContentDidChange(removing: Enumerable, adding: Enumerable): any; enumerableContentWillChange(removing: number, adding: number): Enumerable; enumerableContentWillChange(removing: Enumerable, adding: number): Enumerable; enumerableContentWillChange(removing: number, adding: Enumerable): Enumerable; @@ -1160,23 +1163,23 @@ declare module Ember { getEach(key: string): any[]; indexOf(object: any, startAt: number): number; insertAt(idx: number, object: any): any[]; - invoke(methodName: string, ...any): any[]; + invoke(methodName: string, ...args: any[]): any[]; lastIndexOf(object: any, startAt: number): number; map: ItemIndexEnumerableCallbackTarget; mapBy(key: string): any[]; nextObject(index: number, previousObject: any, context: any): any; objectAt(idx: number): any; - objectsAt(...number): any[]; + objectsAt(...args: number[]): any[]; popObject(): any; pushObject(obj: any): any; - pushObjects(...any): any[]; + pushObjects(...args: any[]): any[]; reduce(callback: ReduceCallback, initialValue: any, reducerProperty: string): any; reject: ItemIndexEnumerableCallbackTarget; rejectBy(key: string, value?: string): any[]; removeArrayObserver(target: any, opts: EnumerableConfigurationOptions): any[]; removeAt(start: number, len: number): any; removeEnumerableObserver(target: any, opts: EnumerableConfigurationOptions): Enumerable; - replace(idx: number, amt: number, objects: any[]); + replace(idx: number, amt: number, objects: any[]): any; reverseObjects(): any[]; setEach(key: string, value?: any): any; setObjects(objects: any[]): any[]; @@ -1209,14 +1212,14 @@ declare module Ember { someProperty(key: string, value?: string): boolean; compact(): any[]; contains(obj: any): boolean; - enumerableContentDidChange(start: number, removing: number, adding: number); - enumerableContentDidChange(start: number, removing: Enumerable, adding: number); - enumerableContentDidChange(start: number, removing: number, adding: Enumerable); - enumerableContentDidChange(start: number, removing: Enumerable, adding: Enumerable); - enumerableContentDidChange(removing: number, adding: number); - enumerableContentDidChange(removing: Enumerable, adding: number); - enumerableContentDidChange(removing: number, adding: Enumerable); - enumerableContentDidChange(removing: Enumerable, adding: Enumerable); + enumerableContentDidChange(start: number, removing: number, adding: number): any; + enumerableContentDidChange(start: number, removing: Enumerable, adding: number): any; + enumerableContentDidChange(start: number, removing: number, adding: Enumerable): any; + enumerableContentDidChange(start: number, removing: Enumerable, adding: Enumerable): any; + enumerableContentDidChange(removing: number, adding: number): any; + enumerableContentDidChange(removing: Enumerable, adding: number): any; + enumerableContentDidChange(removing: number, adding: Enumerable): any; + enumerableContentDidChange(removing: Enumerable, adding: Enumerable): any; enumerableContentWillChange(removing: number, adding: number): Enumerable; enumerableContentWillChange(removing: Enumerable, adding: number): Enumerable; enumerableContentWillChange(removing: number, adding: Enumerable): Enumerable; @@ -1230,7 +1233,7 @@ declare module Ember { findBy(key: string, value?: string): any; forEach(callback: Function, target?: any): any; getEach(key: string): any[]; - invoke(methodName: string, ...any): any[]; + invoke(methodName: string, ...args: any[]): any[]; map: ItemIndexEnumerableCallbackTarget; mapBy(key: string): any[]; nextObject(index: number, previousObject: any, context: any): any; @@ -1245,7 +1248,7 @@ declare module Ember { toArray(): any[]; uniq(): Enumerable; without(value: any): Enumerable; - '[]': any[]; + '[]': any[]; firstObject: any; hasEnumerableObservers: boolean; lastObject: any; @@ -1280,14 +1283,14 @@ declare module Ember { clear(): any[]; compact(): any[]; contains(obj: any): boolean; - enumerableContentDidChange(start: number, removing: number, adding: number); - enumerableContentDidChange(start: number, removing: Enumerable, adding: number); - enumerableContentDidChange(start: number, removing: number, adding: Enumerable); - enumerableContentDidChange(start: number, removing: Enumerable, adding: Enumerable); - enumerableContentDidChange(removing: number, adding: number); - enumerableContentDidChange(removing: Enumerable, adding: number); - enumerableContentDidChange(removing: number, adding: Enumerable); - enumerableContentDidChange(removing: Enumerable, adding: Enumerable); + enumerableContentDidChange(start: number, removing: number, adding: number): any; + enumerableContentDidChange(start: number, removing: Enumerable, adding: number): any; + enumerableContentDidChange(start: number, removing: number, adding: Enumerable): any; + enumerableContentDidChange(start: number, removing: Enumerable, adding: Enumerable): any; + enumerableContentDidChange(removing: number, adding: number): any; + enumerableContentDidChange(removing: Enumerable, adding: number): any; + enumerableContentDidChange(removing: number, adding: Enumerable): any; + enumerableContentDidChange(removing: Enumerable, adding: Enumerable): any; enumerableContentWillChange(removing: number, adding: number): any[]; enumerableContentWillChange(removing: Enumerable, adding: number): any[]; enumerableContentWillChange(removing: number, adding: Enumerable): any[]; @@ -1303,23 +1306,23 @@ declare module Ember { getEach(key: string): any[]; indexOf(object: any, startAt: number): number; insertAt(idx: number, object: any): any[]; - invoke(methodName: string, ...any): any[]; + invoke(methodName: string, ...args: any[]): any[]; lastIndexOf(object: any, startAt: number): number; map: ItemIndexEnumerableCallbackTarget; mapBy(key: string): any[]; nextObject(index: number, previousObject: any, context: any): any; objectAt(idx: number): any; - objectsAt(...number): any[]; + objectsAt(...args: number[]): any[]; popObject(): any; pushObject(obj: any): any; - pushObjects(...any): any[]; + pushObjects(...args: any[]): any[]; reduce(callback: ReduceCallback, initialValue: any, reducerProperty: string): any; reject: ItemIndexEnumerableCallbackTarget; rejectBy(key: string, value?: string): any[]; removeArrayObserver(target: any, opts: EnumerableConfigurationOptions): any[]; removeAt(start: number, len: number): any; removeEnumerableObserver(target: any, opts: EnumerableConfigurationOptions): any[]; - replace(idx: number, amt: number, objects: any[]); + replace(idx: number, amt: number, objects: any[]): any; reverseObjects(): any[]; setEach(key: string, value?: any): any; setObjects(objects: any[]): any[]; @@ -1348,7 +1351,7 @@ declare module Ember { decrementProperty(keyName: string, decrement?: number): number; endPropertyChanges(): any[]; get(keyName: string): any; - getProperties(...string): {}; + getProperties(...args: string[]): {}; getProperties(keys: string[]): {}; getWithDefault(keyName: string, defaultValue: any): any; hasObserverFor(key: string): boolean; @@ -1426,7 +1429,7 @@ declare module Ember { decrementProperty(keyName: string, decrement?: number): number; endPropertyChanges(): Observable; get(keyName: string): any; - getProperties(...string): {}; + getProperties(...args: string[]): {}; getProperties(keys: string[]): {}; getWithDefault(keyName: string, defaultValue: any): any; hasObserverFor(key: string): boolean; @@ -1441,8 +1444,8 @@ declare module Ember { toggleProperty(keyName: string): any; } class ObjectController extends ObjectProxy implements ControllerMixin { - replaceRoute(name: string, ...any): void; - transitionToRoute(name: string, ...any): void; + replaceRoute(name: string, ...args: any[]): void; + transitionToRoute(name: string, ...args: any[]): void; controllers: Object; needs: string[]; target: any; @@ -1474,7 +1477,7 @@ declare module Ember { decrementProperty(keyName: string, decrement?: number): number; endPropertyChanges(): Observable; get(keyName: string): any; - getProperties(...string): {}; + getProperties(...args: string[]): {}; getProperties(keys: string[]): {}; getWithDefault(keyName: string, defaultValue: any): any; hasObserverFor(key: string): boolean; @@ -1551,12 +1554,12 @@ declare module Ember { render(name: string, options?: RenderOptions): void; renderTemplate(controller: Controller, model: {}): void; // ReSharper disable once InconsistentNaming - replaceWith(name: string, ...Object): void; - send(name: string, ...any): void; + replaceWith(name: string, ...object: any[]): void; + send(name: string, ...args: any[]): void; serialize(model: {}, params: string[]): string; setupController(controller: Controller, model: {}): void; // ReSharper disable once InconsistentNaming - transitionTo(name: string, ...Object): void; + transitionTo(name: string, ...object: any[]): void; actions: ActionsHash; } class Router extends Object { @@ -1634,14 +1637,14 @@ declare module Ember { someProperty(key: string, value?: string): boolean; compact(): any[]; contains(obj: any): boolean; - enumerableContentDidChange(start: number, removing: number, adding: number); - enumerableContentDidChange(start: number, removing: Enumerable, adding: number); - enumerableContentDidChange(start: number, removing: number, adding: Enumerable); - enumerableContentDidChange(start: number, removing: Enumerable, adding: Enumerable); - enumerableContentDidChange(removing: number, adding: number); - enumerableContentDidChange(removing: Enumerable, adding: number); - enumerableContentDidChange(removing: number, adding: Enumerable); - enumerableContentDidChange(removing: Enumerable, adding: Enumerable); + enumerableContentDidChange(start: number, removing: number, adding: number): any; + enumerableContentDidChange(start: number, removing: Enumerable, adding: number): any; + enumerableContentDidChange(start: number, removing: number, adding: Enumerable): any; + enumerableContentDidChange(start: number, removing: Enumerable, adding: Enumerable): any; + enumerableContentDidChange(removing: number, adding: number): any; + enumerableContentDidChange(removing: Enumerable, adding: number): any; + enumerableContentDidChange(removing: number, adding: Enumerable): any; + enumerableContentDidChange(removing: Enumerable, adding: Enumerable): any; enumerableContentWillChange(removing: number, adding: number): Set; enumerableContentWillChange(removing: Enumerable, adding: number): Set; enumerableContentWillChange(removing: number, adding: Enumerable): Set; @@ -1655,7 +1658,7 @@ declare module Ember { findBy(key: string, value?: string): any; forEach(callback: Function, target?: any): any; getEach(key: string): any[]; - invoke(methodName: string, ...any): any[]; + invoke(methodName: string, ...args: any[]): any[]; map: ItemIndexEnumerableCallbackTarget; mapBy(key: string): any[]; nextObject(index: number, previousObject: any, context: any): any; @@ -1679,13 +1682,13 @@ declare module Ember { freeze(): Set; isFrozen: boolean; add(obj: any): Set; - addEach(...any): Set; + addEach(...args: any[]): Set; clear(): Set; isEqual(obj: Set): boolean; pop(): any; push(obj: any): Set; remove(obj: any): Set; - removeEach(...any): Set; + removeEach(...args: any[]): Set; shift(): any; unshift(obj: any): Set; length: number; @@ -1699,14 +1702,14 @@ declare module Ember { someProperty(key: string, value?: string): boolean; compact(): any[]; contains(obj: any): boolean; - enumerableContentDidChange(start: number, removing: number, adding: number); - enumerableContentDidChange(start: number, removing: Enumerable, adding: number); - enumerableContentDidChange(start: number, removing: number, adding: Enumerable); - enumerableContentDidChange(start: number, removing: Enumerable, adding: Enumerable); - enumerableContentDidChange(removing: number, adding: number); - enumerableContentDidChange(removing: Enumerable, adding: number); - enumerableContentDidChange(removing: number, adding: Enumerable); - enumerableContentDidChange(removing: Enumerable, adding: Enumerable); + enumerableContentDidChange(start: number, removing: number, adding: number): any; + enumerableContentDidChange(start: number, removing: Enumerable, adding: number): any; + enumerableContentDidChange(start: number, removing: number, adding: Enumerable): any; + enumerableContentDidChange(start: number, removing: Enumerable, adding: Enumerable): any; + enumerableContentDidChange(removing: number, adding: number): any; + enumerableContentDidChange(removing: Enumerable, adding: number): any; + enumerableContentDidChange(removing: number, adding: Enumerable): any; + enumerableContentDidChange(removing: Enumerable, adding: Enumerable): any; enumerableContentWillChange(removing: number, adding: number): Enumerable; enumerableContentWillChange(removing: Enumerable, adding: number): Enumerable; enumerableContentWillChange(removing: number, adding: Enumerable): Enumerable; @@ -1720,7 +1723,7 @@ declare module Ember { findBy(key: string, value?: string): any; forEach(callback: Function, target?: any): any; getEach(key: string): any[]; - invoke(methodName: string, ...any): any[]; + invoke(methodName: string, ...args: any[]): any[]; map: ItemIndexEnumerableCallbackTarget; mapBy(key: string): any[]; nextObject(index: number, previousObject: any, context: any): any; @@ -1763,7 +1766,7 @@ declare module Ember { off(name: string, target: any, method: Function): State; on(name: string, target: any, method: Function): State; one(name: string, target: any, method: Function): State; - trigger(name: string, ...string): void; + trigger(name: string, ...args: string[]): void; getPathsCache(stateManager: {}, path: string): {}; init(): void; setPathsCache(stateManager: {}, path: string, transitions: any): void; @@ -1804,7 +1807,7 @@ declare module Ember { stateMetaFor(state: State): {}; transitionTo(path: string, context: any): void; triggerSetupContext(transitions: TransitionsHash): void; - unhandledEvent(manager: StateManager, event: string); + unhandledEvent(manager: StateManager, event: string): any; currentPath: string; currentState: State; errorOnUnhandledEvents: boolean; @@ -1816,9 +1819,9 @@ declare module Ember { function classify(str: string): string; function dasherize(str: string): string; function decamelize(str: string): string; - function fmt(...string): string; + function fmt(...args: string[]): string; function htmlSafe(str: string): void; // TODO: @returns Handlebars.SafeStringStatic; - function loc(...string): string; + function loc(...args: string[]): string; function underscore(str: string): string; function w(str: string): string[]; } @@ -2001,8 +2004,8 @@ declare module Ember { var computed: { (callback: Function): ComputedProperty; alias(dependentKey: string): ComputedProperty; - and(...string): ComputedProperty; - any(...string): ComputedProperty; + and(...args: string[]): ComputedProperty; + any(...args: string[]): ComputedProperty; bool(dependentKey: string): ComputedProperty; defaultTo(defaultPath: string): ComputedProperty; empty(dependentKey: string): ComputedProperty; @@ -2011,13 +2014,13 @@ declare module Ember { gte(dependentKey: string, value: number): ComputedProperty; lt(dependentKey: string, value: number): ComputedProperty; lte(dependentKey: string, value: number): ComputedProperty; - map(...string): ComputedProperty; + map(...args: string[]): ComputedProperty; match(dependentKey: string, regexp: RegExp): ComputedProperty; none(dependentKey: string): ComputedProperty; not(dependentKey: string): ComputedProperty; notEmpty(dependentKey: string): ComputedProperty; oneWay(dependentKey: string): ComputedProperty; - or(...string): ComputedProperty; + or(...args: string[]): ComputedProperty; }; // ReSharper disable DuplicatingLocalDeclaration var config: {}; @@ -2057,7 +2060,7 @@ declare module Ember { function handleErrors(func: Function, context: any): any; function hasListeners(context: any, name: string): boolean; function hasOwnProperty(prop: string): boolean; - function immediateObserver(func: Function, ...propertyNames): Function; + function immediateObserver(func: Function, ...propertyNames: any[]): Function; var imports: {}; function inspect(obj: any): string; function instrument(name: string, payload: any, callback: Function, binding: any): void; @@ -2079,13 +2082,13 @@ declare module Ember { function merge(original: any, updates: any): any; function meta(obj: any, writable?: boolean): {}; function metaPath(obj: any, path: string, writable?: boolean): any; - function mixin(obj: any, ...any): any; + function mixin(obj: any, ...args: any[]): any; /** Ember.none is deprecated. Please use Ember.isNone instead. **/ var none: typeof deprecateFunc; function normalizeTuple(target: any, path: string): any[]; - function observer(func: Function, ...string): Function; + function observer(func: Function, ...args: string[]): Function; function observersFor(obj: any, path: string): any[]; function onLoad(name: string, callback: Function): void; function oneWay(obj: any, to: string, from: string): Binding; @@ -2119,18 +2122,18 @@ declare module Ember { debounce(target: any, method: Function, ...args: any[]): void; debounce(target: any, method: string, ...args: any[]): void; end(): void; - join(target: any, method: Function, ...any): any; - join(target: any, method: string, ...any): any; + join(target: any, method: Function, ...args: any[]): any; + join(target: any, method: string, ...args: any[]): any; later(target: any, method: Function, ...args: any[]): string; later(target: any, method: string, ...args: any[]): string; - next(target: any, method: Function, ...any): number; - next(target: any, method: string, ...any): number; - once(target: any, method: Function, ...any): number; - once(target: any, method: string, ...any): number; - schedule(queue: string, target: any, method: Function, ...any): void; - schedule(queue: string, target: any, method: string, ...any): void; - scheduleOnce(queue: string, target: any, method: Function, ...any): void; - scheduleOnce(queue: string, target: any, method: string, ...any): void; + next(target: any, method: Function, ...args: any[]): number; + next(target: any, method: string, ...args: any[]): number; + once(target: any, method: Function, ...args: any[]): number; + once(target: any, method: string, ...args: any[]): number; + schedule(queue: string, target: any, method: Function, ...args: any[]): void; + schedule(queue: string, target: any, method: string, ...args: any[]): void; + scheduleOnce(queue: string, target: any, method: Function, ...args: any[]): void; + scheduleOnce(queue: string, target: any, method: string, ...args: any[]): void; sync(): void; throttle(target: any, method: Function, ...args: any[]): void; throttle(target: any, method: string, ...args: any[]): void; diff --git a/emscripten/emscripten-tests.ts b/emscripten/emscripten-tests.ts new file mode 100644 index 000000000..2f3a2b09c --- /dev/null +++ b/emscripten/emscripten-tests.ts @@ -0,0 +1,69 @@ +/// + + +/// Module +function ModuleTest(): void { + Module.print = function(text) { alert('stdout: ' + text) }; + + var int_sqrt = Module.cwrap('int_sqrt', 'number', ['number']) + int_sqrt(12) + int_sqrt(28) + + var myTypedArray = new Uint8Array(10); + var buf = Module._malloc(myTypedArray.length*myTypedArray.BYTES_PER_ELEMENT); + Module.HEAPU8.set(myTypedArray, buf); + Module.ccall('my_function', 'number', ['number'], [buf]); + Module._free(buf); +} + +/// FS +function FSTest(): void { + FS.mkdir('/working'); + FS.mount(NODEFS, { root: '.' }, '/working'); + + function myAppStartup(): void { + FS.mkdir('/data'); + FS.mount(IDBFS, {}, '/data'); + + FS.syncfs(true, function (err) { + // handle callback + }); + } + + function myAppShutdown() { + FS.syncfs(function (err) { + // handle callback + }); + } + + var id = FS.makedev(64, 0); + FS.registerDevice(id, {}); + FS.mkdev('/dummy', id); + + FS.writeFile('file', 'foobar'); + FS.symlink('file', 'link'); + + FS.writeFile('/foobar.txt', 'Hello, world'); + FS.unlink('/foobar.txt'); + + FS.writeFile('file', 'foobar'); + FS.symlink('file', 'link'); + + FS.writeFile('forbidden', 'can\'t touch this'); + FS.chmod('forbidden', 0000); + + FS.writeFile('file', 'foobar'); + FS.truncate('file', 3); + + var stream = FS.open('abinaryfile', 'r'); + var buf = new Uint8Array(4); + FS.read(stream, buf, 0, 4, 0); + FS.close(stream); + + var data = new Uint8Array(32); + var stream = FS.open('dummy', 'w+'); + FS.write(stream, data, 0, data.length, 0); + FS.close(stream); + + var lookup = FS.lookupPath("path", { parent: true }); +} diff --git a/emscripten/emscripten.d.ts b/emscripten/emscripten.d.ts new file mode 100644 index 000000000..547f10c76 --- /dev/null +++ b/emscripten/emscripten.d.ts @@ -0,0 +1,185 @@ +// Type definitions for Emscripten +// Project: http://kripken.github.io/emscripten-site/index.html +// Definitions by: Kensuke Matsuzaki +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module Emscripten { + interface FileSystemType { + } +} + +declare module Module { + function print(str: string): void; + function printErr(str: string): void; + var arguments: string[]; + var preInit: { (): void }[]; + var preRun: { (): void }[]; + var postRun: { (): void }[]; + var noExitRuntime: boolean; + + var Runtime: any; + + function ccall(ident: string, returnType: string, argTypes: string[], args: any[]): any; + function cwrap(ident: string, returnType: string, argTypes: string[]): any; + + function setValue(ptr: number, value: any, type: string, noSafe: boolean): void; + function getValue(ptr: number, type: string, noSafe: boolean): any; + + var ALLOC_NORMAL: number; + var ALLOC_STACK: number; + var ALLOC_STATIC: number; + var ALLOC_DYNAMIC: number; + var ALLOC_NONE: number; + + function allocate(slab: any, types: string, allocator: number, ptr: number): number; + function allocate(slab: any, types: string[], allocator: number, ptr: number): number; + + function Pointer_stringify(ptr: number, length?: number): string; + function UTF16ToString(ptr: number): string; + function stringToUTF16(str: string, outPtr: number): void; + function UTF32ToString(ptr: number): string; + function stringToUTF32(str: string, outPtr: number): void; + + // USE_TYPED_ARRAYS == 1 + var HEAP: Int32Array; + var IHEAP: Int32Array; + var FHEAP: Float64Array; + + // USE_TYPED_ARRAYS == 2 + var HEAP8: Int8Array; + var HEAP16: Int16Array; + var HEAP32: Int32Array; + var HEAPU8: Uint8Array; + var HEAPU16: Uint16Array; + var HEAPU32: Uint32Array; + var HEAPF32: Float32Array; + var HEAPF64: Float64Array; + + var TOTAL_STACK: number; + var TOTAL_MEMORY: number; + var FAST_MEMORY: number; + + function addOnPreRun(cb: () => any): void; + function addOnInit(cb: () => any): void; + function addOnPreMain(cb: () => any): void; + function addOnExit(cb: () => any): void; + function addOnPostRun(cb: () => any): void; + + // Tools + function intArrayFromString(stringy: string, dontAddNull?: boolean, length?: number): number[]; + function intArrayToString(array: number[]): string; + function writeStringToMemory(str: string, buffer: number, dontAddNull: boolean): void; + function writeArrayToMemory(array: number[], buffer: number): void; + function writeAsciiToMemory(str: string, buffer: number, dontAddNull: boolean): void; + + function addRunDependency(id: any): void; + function removeRunDependency(id: any): void; + + + var preloadedImages: any; + var preloadedAudios: any; + + function _malloc(size: number): number; + function _free(ptr: number): void; +} + +declare module FS { + interface Lookup { + path: string; + node: FSNode; + } + + interface FSStream {} + interface FSNode {} + interface ErrnoError {} + + var ignorePermissions: boolean; + var trackingDelegate: any; + var tracking: any; + var genericErrors: any; + + // + // paths + // + function lookupPath(path: string, opts: any): Lookup; + function getPath(node: FSNode): string; + + // + // nodes + // + function isFile(mode: number): boolean; + function isDir(mode: number): boolean; + function isLink(mode: number): boolean; + function isChrdev(mode: number): boolean; + function isBlkdev(mode: number): boolean; + function isFIFO(mode: number): boolean; + function isSocket(mode: number): boolean; + + // + // devices + // + function major(dev: number): number; + function minor(dev: number): number; + function makedev(ma: number, mi: number): number; + function registerDevice(dev: number, ops: any): void; + + // + // core + // + function syncfs(populate: boolean, callback: (e: any) => any): void; + function syncfs( callback: (e: any) => any, populate?: boolean): void; + function mount(type: Emscripten.FileSystemType, opts: any, mountpoint: string): any; + function unmount(mountpoint: string): void; + + function mkdir(path: string, mode?: number): any; + function mkdev(path: string, mode?: number, dev?: number): any; + function symlink(oldpath: string, newpath: string): any; + function rename(old_path: string, new_path: string): void; + function rmdir(path: string): void; + function readdir(path: string): any; + function unlink(path: string): void; + function readlink(path: string): string; + function stat(path: string, dontFollow?: boolean): any; + function lstat(path: string): any; + function chmod(path: string, mode: number, dontFollow?: boolean): void; + function lchmod(path: string, mode: number): void; + function fchmod(fd: number, mode: number): void; + function chown(path: string, uid: number, gid: number, dontFollow?: boolean): void; + function lchown(path: string, uid: number, gid: number): void; + function fchown(fd: number, uid: number, gid: number): void; + function truncate(path: string, len: number): void; + function ftruncate(fd: number, len: number): void; + function utime(path: string, atime: number, mtime: number): void; + function open(path: string, flags: string, mode?: number, fd_start?: number, fd_end?: number): FSStream; + function close(stream: FSStream): void; + function llseek(stream: FSStream, offset: number, whence: number): any; + function read(stream: FSStream, buffer: ArrayBufferView, offset: number, length: number, position?: number): number; + function write(stream: FSStream, buffer: ArrayBufferView, offset: number, length: number, position?: number, canOwn?: boolean): number; + function allocate(stream: FSStream, offset: number, length: number): void; + function mmap(stream: FSStream, buffer: ArrayBufferView, offset: number, length: number, position: number, prot: number, flags: number): any; + function ioctl(stream: FSStream, cmd: any, arg: any): any; + function readFile(path: string, opts?: {encoding: string; flags: string}): any; + function writeFile(path: string, data: ArrayBufferView, opts?: {encoding: string; flags: string}): void; + function writeFile(path: string, data: string, opts?: {encoding: string; flags: string}): void; + + // + // module-level FS code + // + function cwd(): string; + function chdir(path: string): void; + function init(input: () => number, output: (c: number) => any, error: (c: number) => any): void; + + function createLazyFile(parent: string, name: string, url: string, canRead: boolean, canWrite: boolean): FSNode; + function createLazyFile(parent: FSNode, name: string, url: string, canRead: boolean, canWrite: boolean): FSNode; + + function createPreloadedFile(parent: string, name: string, url: string, canRead: boolean, canWrite: boolean, onload?: ()=> void, onerror?: ()=>void, dontCreateFile?:boolean, canOwn?: boolean): void; + function createPreloadedFile(parent: FSNode, name: string, url: string, canRead: boolean, canWrite: boolean, onload?: ()=> void, onerror?: ()=>void, dontCreateFile?:boolean, canOwn?: boolean): void; +} + +declare var MEMFS: Emscripten.FileSystemType; +declare var NODEFS: Emscripten.FileSystemType; +declare var IDBFS: Emscripten.FileSystemType; + +interface Math { + imul(a: number, b: number): number; +} diff --git a/hapi/hapi-tests.ts b/hapi/hapi-tests.ts new file mode 100644 index 000000000..fcc870af6 --- /dev/null +++ b/hapi/hapi-tests.ts @@ -0,0 +1,26 @@ +/// + +import Hapi = require('hapi'); + +// Create a server with a host and port +var server = Hapi.createServer('localhost', 8000); + +// Add the route +server.route({ + method: 'GET', + path: '/hello', + handler: function (request: Hapi.Request, reply: Function) { + reply('hello world'); + } +}); + +server.route([{ + method: 'GET', + path: '/hello2', + handler: function (request: Hapi.Request, reply: Function) { + reply('hello world2'); + } +}]); + +// Start the server +server.start(); diff --git a/hapi/hapi.d.ts b/hapi/hapi.d.ts new file mode 100644 index 000000000..68b366d6d --- /dev/null +++ b/hapi/hapi.d.ts @@ -0,0 +1,457 @@ +// Type definitions for hapi +// Project: http://github.com/spumko/hapi +// Definitions by: Hakubo +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module Hapi { + export interface ServerOptions { + app?: any; +// cache?: string; +// cache?: { +// engine: any; +// }; + cache?: any; +// cors?: boolean; +// cors?: { +// origin?: Array; +// isOriginExposed?: boolean; +// matchOrigin?: boolean; +// maxAge?: number; +// headers?: Array; +// additionalHeaders?: Array; +// methods?: Array; +// additionalMethods?: Array; +// exposedHeaders?: Array; +// additionalExposedHeaders?: Array; +// credentials?: boolean; +// }; + cors?: any; +// security?: boolean; +// security?: { +// hsts?: boolean; +// hsts?: { +// maxAge: number; +// includeSubdomains: boolean; +// }; +// xframe?: boolean; +// xframe?: string; +// xframe?: { +// rule: string; +// source: any; +// }; +// xss?: boolean; +// noOpen?: boolean; +// noSniff?: boolean; +// }; + security?: any; + debug?: { + request: Array; + }; + files?: { + relativeTo: string; + etagsCacheMaxSize: number; + }; + json?: { +// replacer?: () => void; +// replacer?: Array<() => void>; + replacer?: any; + space?: number; + }; + labels?: Array; + load?: { + maxHeapUsedBytes?: number; + maxRssBytes?: number; + maxEventLoopDelay?: number; + sampleInterval?: number; + }; + location?: string; + payload?: { + maxBytes: number; + uploads: string; + }; + plugins?: any; + router?: { + isCaseSensitive?: boolean; + stripTrailingSlash?: boolean; + }; + state?: { + cookies: { + parse?: boolean; + failAction?: string; + clearInvalid?: boolean; + strictHeader?: boolean; + } + }; + timeout?: { +// server?: boolean; +// server?: number; + server?: any; +// client?: boolean; +// client?: number; + client?: any; +// socket?: boolean; +// socket?: number; + socket?: any; + }; + tls?: any; //This should be Node.tls + maxSockets?: number; + validation?: any; + views?: ServerView; + } + + export class Pack { + require(name: string, options: {}, callback: Function): void; + } + + export interface ServerView { + engines: { + [extension: string]: string; + module?: string; +// compile: ( +// template: string, +// options: any +// ) => void; +// compile: ( +// template: string, +// options: any, +// callback: ( +// err: any, +// compiled: ( +// context: any, +// options: any, +// callback: ( +// err: any, +// rendered: boolean +// ) => void +// ) => void +// ) => void +// ) => void; + compile?: any; + }; + defaultExtension?: string; + path?: string; + partialsPath?: string; + helpersPath?: string; + basePath?: string; + layout?: boolean; + layoutPath?: string; + layoutKeyword?: string; + encoding?: string; + isCached?: boolean; + allowAbsolutePaths?: boolean; + allowInsecureAccess?: boolean; + compileOptions?: any; + runtimeOptions?: any; + contentType?: string; + compileMode?: string; + } + + export interface RouteOptions { + path: string; + method: string; +// vhost?: string; +// vhost?: Array; + vhost?: any; +// handler: string; +// handler: (request: Request, reply: Function) => void; +// handler: { +// file: string; +// file: (request: Request) => void; +// file: { +// path: string; +// filename?: string; +// mode?: boolean; +// mode?: string; +// lookupCompressed: boolean; +// }; +// directory: { +// path: string; +// path: Array; +// path: (request: Request) => string; +// path: (request: Request) => Array; +// index?: boolean; +// listing?: boolean; +// showHidden?: boolean; +// redirectToSlash?: boolean; +// lookupCompressed?: boolean; +// defaultExtension?: string; +// }; +// proxy?: { +// host?: string; +// port?: number; +// protocol?: string; +// uri?: string; +// passThrough?: boolean; +// rejectUnauthorized?: boolean; +// xforward?: boolean; +// redirects?: boolean; +// redirects?: number; +// timeout?: number; +// +// mapUri?: (request: Request, callback: (err: any, uri: string, headers: {[key: string]: string}) => void) => void; +// onResponse: ( +// err: any, +// res: any,//Node Response +// req: any,//Node Request +// reply: () => void, +// settings: any, +// ttl: number +// ) => void; +// ttl: number; +// }; +// view: string; +// view: { +// template: string; +// context: { +// payload: any; +// params: any; +// query: any; +// pre: any; +// } +// }; +// config: { +// handler: any; +// bind: any; +// app: any; +// plugins: { +// [name: string]: any; +// }; +// pre: Array<() => void>; +// validate: { +// headers: any; +// params: any; +// query: any; +// payload: any; +// errorFields?: any; +// failAction?: string; +// failAction?: (source: string, error: any, next: () => void) => void; +// }; +// payload: { +// output: { +// data: any; +// stream: any; +// file: any; +// }; +// parse?: any; +// allow?: string; +// allow?: Array; +// override?: string; +// maxBytes?: number; +// uploads?: number; +// failAction?: string; +// }; +// response: { +// schema: any; +// sample: number; +// failAction: string; +// }; +// cache: { +// privacy: string; +// expiresIn: number; +// expiresAt: number; +// }; +// auth: string; +// auth: boolean; +// auth: { +// mode: string; +// strategies: Array; +// payload?: boolean; +// payload?: string; +// tos?: boolean; +// tos?: string; +// scope?: string; +// scope?: Array; +// entity: string; +// }; +// cors?: boolean; +// jsonp?: string; +// description?: string; +// notes?: string; +// notes?: Array; +// tags?: Array; +// } +// }; + handler: any; + } + + export class Server { + app: any; + methods: Array<() => void>; + info: { + port: number; + host?: string; + protocol?: string; + uri?: string; + }; + listener: any;// Node Http server + load: { + eventLoopDelay: number; + heapUsed: number; + rss: number; + }; + pack: Pack; + plugins: { + [pluginName: string]: any; + }; + + start(callback?: () => void): void; + stop(options?: {timeout: number;}, callback?: () => void): void; + route(options: RouteOptions): void; + route(routes: Array): void; + table(host?: string): Array; + log(tags: string, data?: string, timestamp?: number): void; + log(tags: Array, data?: string, timestamp?: number): void; + log(tags: string, data?: any, timestamp?: number): void; + log(tags: Array, data?: any, timestamp?: number): void; + state(name: string, options?: { + ttl: number; + isSecure: boolean; + isHttpOnly: boolean; + path: string; + domain: string; + autoValue: (request: Request, next: (err: any, value: any) => void) => void; + encoding?: string; + sign: any; + password: string; + iron: any; + }): void; + views(options: ServerView): void; + cache(name: string, options: { + expiresIn: number; + expiresAt: number; + staleIn: number; + staleTimeout: number; + cache: string; + }): void; + + auth: { + scheme(name: string, scheme: { + name: string; + scheme: (server: Server, options: any) => (authenticate: any, payload: any, response: any) => void; + }): void; + strategy: any; + }; + ext(event: any, method: string, options?: any): void; + method(method: Array<{name: string; fn: () => void; options: any}>): void; + method(name: string, fn: () => void, options: any): void; + inject(options: any, callback: any): void; + handler(name: string, method: (name: string, options: any) => void): void; + } + + export interface Request { + app: any; + auth: { + isAuthenticated: boolean; + credentials: Object; + artifacts: Object; + session: Object + }; + domain: any; + headers: Object; + id: number; + info: { + received: number; + remoteAddress: string; + remotePort: number; + referrer: string; + host: string; + }; + method: string; + mime?: string; + params: any; + path: string; + payload: any; + plugins: Object; + pre: Object; + response: Object; + responses: Object; + query: Object; + raw: { + req: any; //http.ClientRequest + res: any; //http.ClientResponse + }; + route: string; + server: Server; + session: any; + state: Object; + url: Object; + + setUrl? (url: string): void; + setMethod? (method: string): void; + log (tags: string, data?: string, timestamp?: number): void; + log (tags: string, data?: Object, timestamp?: number): void; + log (tags: string[], data?: string, timestamp?: number): void; + log (tags: string[], data?: Object, timestamp?: number): void; + getLog(): string[]; + getLog(tag: string): string[]; + getLog(tags: string[]): string[]; + tail(name?: string): Function; + } + + export interface Response { + statusCode: number; + headers: Object; + source: any; + variety: string; + app: any; + plugins: Object; + settings: { + encoding: string; + charset: string; + location: string; + ttl: number; + stringify: any; + passThrough: boolean; + } + + code (statusCode: number): void; + header (name: string, value: string, options?: { + append: boolean; + separator: string; + override: boolean; + }): void; + type (mimeType: string): void; + bytes (length: number): void; + vary (header: string): void; + location (location: string): void; + created (location: string): void; + redirect (location: string): void; + encoding (encoding: string): void; + charset (charset: string): void; + ttl (ttl: number): void; + state (name: string, value: string, options?: any): void; + unstate (name: string): void; + + replacer (method: Function): void; + replacer (method: Array): void; + spaces (count: number): void; + + temporary (isTemporary: boolean): void; + permanent (isPermanent: boolean): void; + rewritable (isRewritable: boolean): void; + } + + export module reply { + function file(path: string, options: { + filePath: string; + options: { + filename: string; + mode: string + } + }): void; + + function view(template: string, context?: Object, options?: Object): Response; + function close(options?: Object): void; + function proxy(options: Object): void; + + export function reply(result: any): any; + } + + export function createServer (host: string, port: number, options?: ServerOptions): Server; +} + +declare module "hapi" { + export = Hapi; +} diff --git a/history/history.d.ts b/history/history.d.ts index a8a3c4004..07a31d011 100644 --- a/history/history.d.ts +++ b/history/history.d.ts @@ -1,13 +1,13 @@ -// Type definitions for History.js -// Project: https://github.com/balupton/History.js -// Definitions by: Boris Yankov +// Type definitions for History.js 1.8.0 +// Project: https://github.com/browserstate/history.js +// Definitions by: Boris Yankov , Gidon Junge // Definitions: https://github.com/borisyankov/DefinitelyTyped interface HistoryAdapter { - bind(element, event, callback); - trigger(element, event); - onDomLoad(callback); + bind(element: any, event: string, callback: () => void); + trigger(element: any, event: string); + onDomLoad(callback: () => void); } // Since History is defined in lib.d.ts as well @@ -17,15 +17,45 @@ interface HistoryAdapter { // var Historyjs: Historyjs = History; interface Historyjs { + enabled: boolean; - pushState(data, title, url); - replaceState(data, title, url); - getState(); - getHash(); + + pushState(data: any, title: string, url: string); + replaceState(data: any, title: string, url: string); + getState(): HistoryState; + getStateByIndex(index: number): HistoryState; + getCurrentIndex(): number; + getHash(): string; + Adapter: HistoryAdapter; - back(); - forward(); - go(X); - log(...messages: any[]); - debug(...messages: any[]); + + back(): void; + forward(): void; + go(x: Number): void; + + log(...messages: any[]): void; + debug(...messages: any[]): void; + + options: HistoryOptions; } + +interface HistoryState { + data?: any; + title?: string; + url: string; +} + +interface HistoryOptions { + hashChangeInterval?: number; + safariPollInterval?: number; + doubleCheckInterval?: number; + disableSuid?: boolean; + storeInterval?: number; + busyDelay?: number; + debug?: boolean; + initialTitle?: string; + html4Mode?: boolean; + delayInit?: number; + + +} \ No newline at end of file diff --git a/jquery.pjax.falsandtru/jquery.pjax-tests.ts b/jquery.pjax.falsandtru/jquery.pjax-tests.ts index 18eae623c..f116da5df 100644 --- a/jquery.pjax.falsandtru/jquery.pjax-tests.ts +++ b/jquery.pjax.falsandtru/jquery.pjax-tests.ts @@ -1,35 +1,35 @@ -/// -/// - -function test_pjax() { - $.pjax(); -} - -function test_pjax_selector() { - $('a').pjax(); -} - -function test_pjax_option() { - $.pjax({ - area: 'body', - load: { - head: 'base, meta, link', - css: true, - script: true - }, - cache: { click: true, submit: false, popstate: true }, - server: { query: null } - }); -} - -function test_pjax_event() { - $.pjax({ - wait: 1000 - }); - $(document).bind('pjax.request', function () { - $('div.loading').fadeIn(100); - }); - $(document).bind('pjax.render', function () { - $('div.loading').fadeOut(500); - }); -} +/// +/// + +function test_pjax() { + $.pjax(); +} + +function test_pjax_selector() { + $('a').pjax(); +} + +function test_pjax_option() { + $.pjax({ + area: 'body', + load: { + head: 'base, meta, link', + css: true, + script: true + }, + cache: { click: true, submit: false, popstate: true }, + server: { query: null } + }); +} + +function test_pjax_event() { + $.pjax({ + wait: 1000 + }); + $(document).bind('pjax.request', function () { + $('div.loading').fadeIn(100); + }); + $(document).bind('pjax.render', function () { + $('div.loading').fadeOut(500); + }); +} diff --git a/jquery.pjax.falsandtru/jquery.pjax.d.ts b/jquery.pjax.falsandtru/jquery.pjax.d.ts index 07bc153df..36be74018 100644 --- a/jquery.pjax.falsandtru/jquery.pjax.d.ts +++ b/jquery.pjax.falsandtru/jquery.pjax.d.ts @@ -1,189 +1,189 @@ -// Type definitions for jquery.pjax.ts by falsandtru -// Project: https://github.com/falsandtru/jquery.pjax.js/ -// Definitions by: 新ゝ月 NewNotMoon -// Definitions: https://github.com/borisyankov/DefinitelyTyped - -/// - -interface PjaxSetting { - gns?: string; - ns?: string; - area?: any; // string, array, function( event, param, origUrl, destUrl ) - link?: string; - filter?: any; // string, function() - form?: string; - scope?: Object; - state?: any; // any, function(event, param, origUrl, destUrl ) - scrollTop?: any; // number, function( event, param, origUrl, destUrl ), null, false - scrollLeft?: any; // number, function( event, param, origUrl, destUrl ), null, false - scroll?: { - delay?: number; - record?: boolean //internal - queue?: number[] //internal - }; - ajax?: JQueryAjaxSettings; - contentType?: string; - load?: { - head?: string; - css?: boolean; - script?: boolean; - execute?: boolean; - reload?: string; - ignore?: string; - sync?: boolean; - ajax?: JQueryAjaxSettings; - rewrite?: (element: any) => any; - redirect?: boolean; - }; - interval?: number; - cache?: { - click?: boolean; - submit?: boolean; - popstate?: boolean; - get?: boolean; - post?: boolean; - page?: boolean; - size?: number; - mix?: number; - expires?: { - min?: number; - max?: number; - }; - }; - wait?: any; // number, function( event, param, origUrl, destUrl ): number - fallback?: any; // boolean, function( event, param, origUrl, destUrl ): boolean - fix?: { - location?: boolean; - history?: boolean; - scroll?: boolean; - reset?: boolean; - }; - database?: boolean; - server?: { - query?: any; // string, object - header?: { - area?: boolean; - head?: boolean; - css?: boolean; - script?: boolean; - }; - }; - callback?: (event: JQueryEventObject, param: any) => any; - callbacks?: { - before?: (event: JQueryEventObject, param: any) => any; - after?: (event: JQueryEventObject, param: any) => any; - ajax?: { - xhr?: (event: JQueryEventObject, param: any) => any; - beforeSend?: (event: JQueryEventObject, param: any, data: any, ajaxSettings: any) => any; - dataFilter?: (event: JQueryEventObject, param: any, data: any, dataType: any) => any; - success?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any; - error?: (event: JQueryEventObject, param: any, XMLHttpRequest: XMLHttpRequest, textStatus: string, errorThrown: any) => any; - complete?: (event: JQueryEventObject, param: any, XMLHttpRequest: XMLHttpRequest, textStatus: string) => any; - done?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any; - fail?: (event: JQueryEventObject, param: any, XMLHttpRequest: XMLHttpRequest, textStatus: string, errorThrown: any) => any; - always?: (event: JQueryEventObject, param: any, XMLHttpRequest: XMLHttpRequest, textStatus: string) => any; - }; - update?: { - before?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any; - after?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any; - cache?: { - before?: (event: JQueryEventObject, param: any, cache: any) => any; - after?: (event: JQueryEventObject, param: any, cache: any) => any; - }; - redirect?: { - before?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any; - after?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any; - }; - url?: { - before?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any; - after?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any; - }; - title?: { - before?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any; - after?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any; - }; - head?: { - before?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any; - after?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any; - }; - content?: { - before?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any; - after?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any; - }; - scroll?: { - before?: (event: JQueryEventObject, param: any) => any; - after?: (event: JQueryEventObject, param: any) => any; - }; - css?: { - before?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any; - after?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any; - }; - script?: { - before?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any; - after?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any; - }; - render?: { - before?: (event: JQueryEventObject, param: any) => any; - after?: (event: JQueryEventObject, param: any) => any; - }; - verify?: { - before?: (event: JQueryEventObject, param: any) => any; - after?: (event: JQueryEventObject, param: any) => any; - }; - success?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any; - error?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any; - complete?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any; - }; - param?: any; - - // internal - uuid?: string; - nss?: { - name?: string; - event?: string[]; - click?: string; - submit?: string; - popstate?: string; - scroll?: string; - data?: string; - class4html?: string; - requestHeader?: string; - }; - origLocation?: HTMLAnchorElement; - destLocation?: HTMLAnchorElement; - retry?: boolean; - speedcheck?: boolean; - disable?: boolean; - option?: any; - }; -} - -interface JQueryStatic { - pjax: { - (setting?: PjaxSetting): any; - enable(): any; - disable(): any; - click(url: string, attr: { href?: string; }): any; - click(url: HTMLAnchorElement, attr: { href?: string; }): any; - click(url: JQuery, attr: { href?: string; }): any; - click(url: any, attr: { href?: string; }): any; - submit(url: string, attr: { action?: string; method?: string; }, data: any): any; - submit(url: HTMLFormElement, attr?: { action?: string; method?: string; }, data?: any): any; - submit(url: JQuery, attr?: { action?: string; method?: string; }, data?: any): any; - submit(url: any, attr?: { action?: string; method?: string; }, data?: any): any; - follow(event: JQueryEventObject, ajax: JQueryXHR, timeStamp?: number): boolean; - setCache(): any; - setCache(url: string): any; - setCache(url: string, data: string): any; - setCache(url: string, data: string, textStatus: string, XMLHttpRequest: XMLHttpRequest): any; - getCache(): any; - getCache(url: string): any; - removeCache(url: string): any; - removeCache(): any; - clearCache(): any; - }; -} - -interface JQuery { - pjax(setting?: PjaxSetting): any; +// Type definitions for jquery.pjax.ts by falsandtru +// Project: https://github.com/falsandtru/jquery.pjax.js/ +// Definitions by: 新ゝ月 NewNotMoon +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +interface PjaxSetting { + gns?: string; + ns?: string; + area?: any; // string, array, function( event, param, origUrl, destUrl ) + link?: string; + filter?: any; // string, function() + form?: string; + scope?: Object; + state?: any; // any, function(event, param, origUrl, destUrl ) + scrollTop?: any; // number, function( event, param, origUrl, destUrl ), null, false + scrollLeft?: any; // number, function( event, param, origUrl, destUrl ), null, false + scroll?: { + delay?: number; + record?: boolean //internal + queue?: number[] //internal + }; + ajax?: JQueryAjaxSettings; + contentType?: string; + load?: { + head?: string; + css?: boolean; + script?: boolean; + execute?: boolean; + reload?: string; + ignore?: string; + sync?: boolean; + ajax?: JQueryAjaxSettings; + rewrite?: (element: any) => any; + redirect?: boolean; + }; + interval?: number; + cache?: { + click?: boolean; + submit?: boolean; + popstate?: boolean; + get?: boolean; + post?: boolean; + page?: boolean; + size?: number; + mix?: number; + expires?: { + min?: number; + max?: number; + }; + }; + wait?: any; // number, function( event, param, origUrl, destUrl ): number + fallback?: any; // boolean, function( event, param, origUrl, destUrl ): boolean + fix?: { + location?: boolean; + history?: boolean; + scroll?: boolean; + reset?: boolean; + }; + database?: boolean; + server?: { + query?: any; // string, object + header?: { + area?: boolean; + head?: boolean; + css?: boolean; + script?: boolean; + }; + }; + callback?: (event: JQueryEventObject, param: any) => any; + callbacks?: { + before?: (event: JQueryEventObject, param: any) => any; + after?: (event: JQueryEventObject, param: any) => any; + ajax?: { + xhr?: (event: JQueryEventObject, param: any) => any; + beforeSend?: (event: JQueryEventObject, param: any, data: any, ajaxSettings: any) => any; + dataFilter?: (event: JQueryEventObject, param: any, data: any, dataType: any) => any; + success?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any; + error?: (event: JQueryEventObject, param: any, XMLHttpRequest: XMLHttpRequest, textStatus: string, errorThrown: any) => any; + complete?: (event: JQueryEventObject, param: any, XMLHttpRequest: XMLHttpRequest, textStatus: string) => any; + done?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any; + fail?: (event: JQueryEventObject, param: any, XMLHttpRequest: XMLHttpRequest, textStatus: string, errorThrown: any) => any; + always?: (event: JQueryEventObject, param: any, XMLHttpRequest: XMLHttpRequest, textStatus: string) => any; + }; + update?: { + before?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any; + after?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any; + cache?: { + before?: (event: JQueryEventObject, param: any, cache: any) => any; + after?: (event: JQueryEventObject, param: any, cache: any) => any; + }; + redirect?: { + before?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any; + after?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any; + }; + url?: { + before?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any; + after?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any; + }; + title?: { + before?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any; + after?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any; + }; + head?: { + before?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any; + after?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any; + }; + content?: { + before?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any; + after?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any; + }; + scroll?: { + before?: (event: JQueryEventObject, param: any) => any; + after?: (event: JQueryEventObject, param: any) => any; + }; + css?: { + before?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any; + after?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any; + }; + script?: { + before?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any; + after?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any; + }; + render?: { + before?: (event: JQueryEventObject, param: any) => any; + after?: (event: JQueryEventObject, param: any) => any; + }; + verify?: { + before?: (event: JQueryEventObject, param: any) => any; + after?: (event: JQueryEventObject, param: any) => any; + }; + success?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any; + error?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any; + complete?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any; + }; + param?: any; + + // internal + uuid?: string; + nss?: { + name?: string; + event?: string[]; + click?: string; + submit?: string; + popstate?: string; + scroll?: string; + data?: string; + class4html?: string; + requestHeader?: string; + }; + origLocation?: HTMLAnchorElement; + destLocation?: HTMLAnchorElement; + retry?: boolean; + speedcheck?: boolean; + disable?: boolean; + option?: any; + }; +} + +interface JQueryStatic { + pjax: { + (setting?: PjaxSetting): any; + enable(): any; + disable(): any; + click(url: string, attr: { href?: string; }): any; + click(url: HTMLAnchorElement, attr: { href?: string; }): any; + click(url: JQuery, attr: { href?: string; }): any; + click(url: any, attr: { href?: string; }): any; + submit(url: string, attr: { action?: string; method?: string; }, data: any): any; + submit(url: HTMLFormElement, attr?: { action?: string; method?: string; }, data?: any): any; + submit(url: JQuery, attr?: { action?: string; method?: string; }, data?: any): any; + submit(url: any, attr?: { action?: string; method?: string; }, data?: any): any; + follow(event: JQueryEventObject, ajax: JQueryXHR, timeStamp?: number): boolean; + setCache(): any; + setCache(url: string): any; + setCache(url: string, data: string): any; + setCache(url: string, data: string, textStatus: string, XMLHttpRequest: XMLHttpRequest): any; + getCache(): any; + getCache(url: string): any; + removeCache(url: string): any; + removeCache(): any; + clearCache(): any; + }; +} + +interface JQuery { + pjax(setting?: PjaxSetting): any; } \ No newline at end of file diff --git a/js-url/js-url-tests.ts b/js-url/js-url-tests.ts index 0b26f6175..e5d3eaece 100644 --- a/js-url/js-url-tests.ts +++ b/js-url/js-url-tests.ts @@ -1,9 +1,9 @@ -/// - -url(); - -url('domain'); -url(1); - -url('domain', 'test.www.example.com/path/here'); -url(-1, 'test.www.example.com/path/here'); +/// + +url(); + +url('domain'); +url(1); + +url('domain', 'test.www.example.com/path/here'); +url(-1, 'test.www.example.com/path/here'); diff --git a/promise-pool/promise-pool-tests.ts b/promise-pool/promise-pool-tests.ts index 783d571ca..4f3bd40de 100644 --- a/promise-pool/promise-pool-tests.ts +++ b/promise-pool/promise-pool-tests.ts @@ -1,47 +1,47 @@ -import Q = require('q'); -import promisePool = require('promise-pool'); - -var pool = new promisePool.Pool((taskDataId, index) => { - return Q.delay(Math.floor(Math.random() * 5000)).then(function () { - taskDataId == 0; - index == 0; - }); -}, 20); - -pool - .pause() - .delay(5000) - .then(function () { - pool.resume(); - }); - -pool.retries == 0; -pool.retryInterval == 0; -pool.maxRetryInterval == 0; -pool.retryIntervalMultiplier == 0; - -pool.add(0); - -pool - .start(onProgress) - .then(result => { - result.total == 0; - return pool.reset(); - }) - .then(() => { - return pool.start(onProgress); - }) - .then(result => { - result.total == 0; - return pool.reset(); - }) - .then(() => { - pool.endless == true; - }); - -function onProgress(progress: promisePool.IProgress) { - progress.success == true; - progress.fulfilled == 0; - progress.total == 0; - progress.index == 0; +import Q = require('q'); +import promisePool = require('promise-pool'); + +var pool = new promisePool.Pool((taskDataId, index) => { + return Q.delay(Math.floor(Math.random() * 5000)).then(function () { + taskDataId == 0; + index == 0; + }); +}, 20); + +pool + .pause() + .delay(5000) + .then(function () { + pool.resume(); + }); + +pool.retries == 0; +pool.retryInterval == 0; +pool.maxRetryInterval == 0; +pool.retryIntervalMultiplier == 0; + +pool.add(0); + +pool + .start(onProgress) + .then(result => { + result.total == 0; + return pool.reset(); + }) + .then(() => { + return pool.start(onProgress); + }) + .then(result => { + result.total == 0; + return pool.reset(); + }) + .then(() => { + pool.endless == true; + }); + +function onProgress(progress: promisePool.IProgress) { + progress.success == true; + progress.fulfilled == 0; + progress.total == 0; + progress.index == 0; } \ No newline at end of file diff --git a/promise-pool/promise-pool.d.ts b/promise-pool/promise-pool.d.ts index b9214e7f0..03cf5892b 100644 --- a/promise-pool/promise-pool.d.ts +++ b/promise-pool/promise-pool.d.ts @@ -1,124 +1,124 @@ -// Type definitions for promise-pool -// Project: https://github.com/vilic/promise-pool -// Definitions by: VILIC VANE -// Definitions: https://github.com/borisyankov/DefinitelyTyped - -/// - -declare module "promise-pool" { - /** - * interface for the final result. - */ - export interface IResult { - fulfilled: number; - rejected: number; - total: number; - } - /** - * interface for progress data. - */ - export interface IProgress { - index: number; - success: boolean; - error: any; - retries: number; - fulfilled: number; - rejected: number; - pending: number; - total: number; - } - /** - * tasks pool that manages concurrency. - */ - export class Pool { - /** - * (get/set) the max concurrency of this task pool. - */ - public concurrency: number; - private _tasksData; - /** - * (get/set) the processor function that handles tasks data. - */ - public processor: (data: T, index: number) => Q.IPromise; - private _deferred; - private _pauseDeferred; - /** - * (get) the number of successful tasks. - */ - public fulfilled: number; - /** - * (get) the number of failed tasks. - */ - public rejected: number; - /** - * (get) the number of pending tasks. - */ - public pending: number; - /** - * (get) the number of completed tasks and pending tasks in total. - */ - public total: number; - /** - * (get/set) indicates whether this task pool is endless, if so, tasks can still be added even after all previous tasks have been fulfilled. - */ - public endless: boolean; - /** - * (get/set) defaults to 0, the number or retries that this task pool will take for every single task, could be Infinity. - */ - public retries: number; - /** - * (get/set) defaults to 0, interval (milliseconds) between each retries. - */ - public retryInterval: number; - /** - * (get/set) defaults to Infinity, max retry interval when retry interval multiplier applied. - */ - public maxRetryInterval: number; - /** - * (get/set) defaults to 1, the multiplier applies to interval after every retry. - */ - public retryIntervalMultiplier: number; - private _index; - private _currentConcurrency; - public onProgress: (progress: IProgress) => void; - /** - * initialize a task pool. - * @param processor a function takes the data and index as parameters and returns a promise. - * @param concurrency the concurrency of this task pool. - * @param endless defaults to false. indicates whether this task pool is endless, if so, tasks can still be added even after all previous tasks have been fulfilled. - * @param tasksData an initializing array of task data. - */ - constructor(processor: (data: T, index: number) => Q.IPromise, concurrency: number, endless?: boolean, tasksData?: T[]); - /** - * add a data item. - * @param taskData task data to add. - */ - public add(taskData: T): void; - /** - * add data items. - * @param tasskData tasks data to add. - */ - public add(tasksData: T[]): void; - /** - * start tasks, return a promise that will be fulfilled after all tasks accomplish if endless is false. - * @param onProgress a callback that will be triggered every time when a single task is fulfilled. - */ - public start(onProgress?: (progress: IProgress) => void): Q.Promise; - private _start(); - private _process(data, index); - private _notifyProgress(index, success, err, retries); - private _next(); - /** - * pause tasks and return a promise that will be fulfilled after the running tasks accomplish. this will wait for running tasks to complete instead of aborting them. - */ - public pause(): Q.Promise; - /** - * resume tasks. - */ - public resume(): void; - /** - * pause tasks, then clear pending tasks data and reset counters. return a promise that will be fulfilled after resetting accomplish. - */ - public reset(): Q.Promise; - } +// Type definitions for promise-pool +// Project: https://github.com/vilic/promise-pool +// Definitions by: VILIC VANE +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "promise-pool" { + /** + * interface for the final result. + */ + export interface IResult { + fulfilled: number; + rejected: number; + total: number; + } + /** + * interface for progress data. + */ + export interface IProgress { + index: number; + success: boolean; + error: any; + retries: number; + fulfilled: number; + rejected: number; + pending: number; + total: number; + } + /** + * tasks pool that manages concurrency. + */ + export class Pool { + /** + * (get/set) the max concurrency of this task pool. + */ + public concurrency: number; + private _tasksData; + /** + * (get/set) the processor function that handles tasks data. + */ + public processor: (data: T, index: number) => Q.IPromise; + private _deferred; + private _pauseDeferred; + /** + * (get) the number of successful tasks. + */ + public fulfilled: number; + /** + * (get) the number of failed tasks. + */ + public rejected: number; + /** + * (get) the number of pending tasks. + */ + public pending: number; + /** + * (get) the number of completed tasks and pending tasks in total. + */ + public total: number; + /** + * (get/set) indicates whether this task pool is endless, if so, tasks can still be added even after all previous tasks have been fulfilled. + */ + public endless: boolean; + /** + * (get/set) defaults to 0, the number or retries that this task pool will take for every single task, could be Infinity. + */ + public retries: number; + /** + * (get/set) defaults to 0, interval (milliseconds) between each retries. + */ + public retryInterval: number; + /** + * (get/set) defaults to Infinity, max retry interval when retry interval multiplier applied. + */ + public maxRetryInterval: number; + /** + * (get/set) defaults to 1, the multiplier applies to interval after every retry. + */ + public retryIntervalMultiplier: number; + private _index; + private _currentConcurrency; + public onProgress: (progress: IProgress) => void; + /** + * initialize a task pool. + * @param processor a function takes the data and index as parameters and returns a promise. + * @param concurrency the concurrency of this task pool. + * @param endless defaults to false. indicates whether this task pool is endless, if so, tasks can still be added even after all previous tasks have been fulfilled. + * @param tasksData an initializing array of task data. + */ + constructor(processor: (data: T, index: number) => Q.IPromise, concurrency: number, endless?: boolean, tasksData?: T[]); + /** + * add a data item. + * @param taskData task data to add. + */ + public add(taskData: T): void; + /** + * add data items. + * @param tasskData tasks data to add. + */ + public add(tasksData: T[]): void; + /** + * start tasks, return a promise that will be fulfilled after all tasks accomplish if endless is false. + * @param onProgress a callback that will be triggered every time when a single task is fulfilled. + */ + public start(onProgress?: (progress: IProgress) => void): Q.Promise; + private _start(); + private _process(data, index); + private _notifyProgress(index, success, err, retries); + private _next(); + /** + * pause tasks and return a promise that will be fulfilled after the running tasks accomplish. this will wait for running tasks to complete instead of aborting them. + */ + public pause(): Q.Promise; + /** + * resume tasks. + */ + public resume(): void; + /** + * pause tasks, then clear pending tasks data and reset counters. return a promise that will be fulfilled after resetting accomplish. + */ + public reset(): Q.Promise; + } } \ No newline at end of file diff --git a/q-retry/q-retry-tests.ts b/q-retry/q-retry-tests.ts index bf72f8ad7..e5d5dd8ca 100644 --- a/q-retry/q-retry-tests.ts +++ b/q-retry/q-retry-tests.ts @@ -1,39 +1,39 @@ -import Q = require('q-retry'); - -Q - .retry(() => { - return ''; - }) - .then(str => { - str.charAt; - return 0; - }) - .retry(num => { - num.toFixed; - }) - .retry(() => { - - }, 5) - .retry(() => { - - }, (reason, retries) => { - retries.toFixed; - }) - .retry(() => { - - }, (reason, retries) => { - retries.toFixed; - }, 10) - .retry(() => { - return ''; - }, (reason, retries) => { - - }, { - limit: 10, - interval: 1000, - maxInterval: 20000, - intervalMultiplier: 1.5 - }) - .then(str => { - str.charAt; +import Q = require('q-retry'); + +Q + .retry(() => { + return ''; + }) + .then(str => { + str.charAt; + return 0; + }) + .retry(num => { + num.toFixed; + }) + .retry(() => { + + }, 5) + .retry(() => { + + }, (reason, retries) => { + retries.toFixed; + }) + .retry(() => { + + }, (reason, retries) => { + retries.toFixed; + }, 10) + .retry(() => { + return ''; + }, (reason, retries) => { + + }, { + limit: 10, + interval: 1000, + maxInterval: 20000, + intervalMultiplier: 1.5 + }) + .then(str => { + str.charAt; }); \ No newline at end of file diff --git a/q-retry/q-retry.d.ts b/q-retry/q-retry.d.ts index fe6b42fd8..f4e6e47d9 100644 --- a/q-retry/q-retry.d.ts +++ b/q-retry/q-retry.d.ts @@ -1,39 +1,39 @@ -// Type definitions for q-retry -// Project: https://github.com/vilic/q-retry -// Definitions by: VILIC VANE -// Definitions: https://github.com/borisyankov/DefinitelyTyped - -/// - -declare module Q { - export interface IRetryOptions { - limit?: number; - interval?: number; - maxInterval?: number; - intervalMultiplier?: number; - } - - export function retry(process: () => IPromise, onFail: (reason: any, retries: number) => void, limit: number): Promise; - export function retry(process: () => IPromise, onFail: (reason: any, retries: number) => void, options?: IRetryOptions): Promise; - export function retry(process: () => IPromise, limit: number): Promise; - export function retry(process: () => IPromise, options?: IRetryOptions): Promise; - export function retry(process: () => U, onFail: (reason: any, retries: number) => void, limit: number): Promise; - export function retry(process: () => U, onFail: (reason: any, retries: number) => void, options?: IRetryOptions): Promise; - export function retry(process: () => U, limit: number): Promise; - export function retry(process: () => U, options?: IRetryOptions): Promise; - - interface Promise { - retry(process: (value: T) => IPromise, onFail: (reason: any, retries: number) => void, limit: number): Promise; - retry(process: (value: T) => IPromise, onFail: (reason: any, retries: number) => void, options?: IRetryOptions): Promise; - retry(process: (value: T) => IPromise, limit: number): Promise; - retry(process: (value: T) => IPromise, options?: IRetryOptions): Promise; - retry(process: (value: T) => U, onFail: (reason: any, retries: number) => void, limit: number): Promise; - retry(process: (value: T) => U, onFail: (reason: any, retries: number) => void, options?: IRetryOptions): Promise; - retry(process: (value: T) => U, limit: number): Promise; - retry(process: (value: T) => U, options?: IRetryOptions): Promise; - } -} - -declare module "q-retry" { - export = Q; +// Type definitions for q-retry +// Project: https://github.com/vilic/q-retry +// Definitions by: VILIC VANE +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module Q { + export interface IRetryOptions { + limit?: number; + interval?: number; + maxInterval?: number; + intervalMultiplier?: number; + } + + export function retry(process: () => IPromise, onFail: (reason: any, retries: number) => void, limit: number): Promise; + export function retry(process: () => IPromise, onFail: (reason: any, retries: number) => void, options?: IRetryOptions): Promise; + export function retry(process: () => IPromise, limit: number): Promise; + export function retry(process: () => IPromise, options?: IRetryOptions): Promise; + export function retry(process: () => U, onFail: (reason: any, retries: number) => void, limit: number): Promise; + export function retry(process: () => U, onFail: (reason: any, retries: number) => void, options?: IRetryOptions): Promise; + export function retry(process: () => U, limit: number): Promise; + export function retry(process: () => U, options?: IRetryOptions): Promise; + + interface Promise { + retry(process: (value: T) => IPromise, onFail: (reason: any, retries: number) => void, limit: number): Promise; + retry(process: (value: T) => IPromise, onFail: (reason: any, retries: number) => void, options?: IRetryOptions): Promise; + retry(process: (value: T) => IPromise, limit: number): Promise; + retry(process: (value: T) => IPromise, options?: IRetryOptions): Promise; + retry(process: (value: T) => U, onFail: (reason: any, retries: number) => void, limit: number): Promise; + retry(process: (value: T) => U, onFail: (reason: any, retries: number) => void, options?: IRetryOptions): Promise; + retry(process: (value: T) => U, limit: number): Promise; + retry(process: (value: T) => U, options?: IRetryOptions): Promise; + } +} + +declare module "q-retry" { + export = Q; } \ No newline at end of file diff --git a/q/Q.d.ts b/q/Q.d.ts index 90ec8b461..1352115e3 100644 --- a/q/Q.d.ts +++ b/q/Q.d.ts @@ -101,6 +101,11 @@ declare module Q { */ done(onFulfilled?: (value: T) => any, onRejected?: (reason: any) => any, onProgress?: (progress: any) => any): void; + /** + * If callback is a function, assumes it's a Node.js-style callback, and calls it as either callback(rejectionReason) when/if promise becomes rejected, or as callback(null, fulfillmentValue) when/if promise becomes fulfilled. If callback is not a function, simply returns promise. + */ + nodeify(callback: (reason: any, value: any) => void): Promise; + /** * Returns a promise to get the named property of an object. Essentially equivalent to * @@ -161,7 +166,7 @@ declare module Q { * Returns whether a given promise is in the pending state. When the static version is used on non-promises, the result is always false. */ isPending(): boolean; - + valueOf(): any; /** diff --git a/restangular/restangular-tests.ts b/restangular/restangular-tests.ts index 9d5aa9fb4..11d7a086d 100644 --- a/restangular/restangular-tests.ts +++ b/restangular/restangular-tests.ts @@ -22,7 +22,7 @@ myApp.config((RestangularProvider: restangular.IProvider) => { RestangularProvider.setRequestInterceptor(function (element, operation, route, url) { }); - RestangularProvider.addElementTransformer('accounts', false, function (elem) { + RestangularProvider.addElementTransformer('accounts', false, function (elem: any) { elem.accountName = 'Changed'; return elem; }); @@ -74,9 +74,13 @@ myApp.controller('TestCtrl', ( baseAccounts.post(newAccount); Restangular.allUrl('googlers', 'http://www.google.com/').getList(); + Restangular.allUrl('googlers', 'http://www.google.com/').getList(); Restangular.oneUrl('googlers', 'http://www.google.com/1').get(); + Restangular.oneUrl('googlers', 'http://www.google.com/1').get(); Restangular.one('accounts', 123).one('buildings', 456).get(); + Restangular.one('accounts', 123).one('buildings', 456).get(); Restangular.one('accounts', 123).getList('buildings'); + Restangular.one('accounts', 123).getList('buildings'); baseAccounts.getList().then(function (accounts) { var firstAccount = accounts[0]; @@ -104,7 +108,7 @@ myApp.controller('TestCtrl', ( console.log("There was an error saving"); }); - firstAccount.getList("users", {query: "params"}).then(function(users) { + firstAccount.getList("users", {query: "params"}).then(function(users: any) { users.post({userName: 'unknown'}); users.customGET("messages", {param: "myParam"}); @@ -151,7 +155,7 @@ myApp.controller('TestCtrl', ( configurer.setRequestInterceptor(function (element, operation, route, url) { }); - configurer.addElementTransformer('accounts', false, function (elem) { + configurer.addElementTransformer('accounts', false, function (elem: any) { elem.accountName = 'Changed'; return elem; }); diff --git a/restangular/restangular.d.ts b/restangular/restangular.d.ts index a1a7e8a5e..8b8fd9d2f 100644 --- a/restangular/restangular.d.ts +++ b/restangular/restangular.d.ts @@ -99,10 +99,14 @@ declare module restangular { interface IElement extends IService { get(queryParams?: any, headers?: any): IPromise; + get(queryParams?: any, headers?: any): IPromise; getList(subElement?: any, queryParams?: any, headers?: any): ICollectionPromise; + getList(subElement?: any, queryParams?: any, headers?: any): ICollectionPromise; put(queryParams?: any, headers?: any): IPromise; post(subElement: any, elementToPost: any, queryParams?: any, headers?: any): IPromise; + post(subElement: any, elementToPost: T, queryParams?: any, headers?: any): IPromise; post(elementToPost: any, queryParams?: any, headers?: any): IPromise; + post(elementToPost: T, queryParams?: any, headers?: any): IPromise; remove(queryParams?: any, headers?: any): IPromise; head(queryParams?: any, headers?: any): IPromise; trace(queryParams?: any, headers?: any): IPromise; @@ -114,7 +118,9 @@ declare module restangular { interface ICollection extends IService { getList(queryParams?: any, headers?: any): ICollectionPromise; + getList(queryParams?: any, headers?: any): ICollectionPromise; post(elementToPost: any, queryParams?: any, headers?: any): IPromise; + post(elementToPost: T, queryParams?: any, headers?: any): IPromise; head(queryParams?: any, headers?: any): IPromise; trace(queryParams?: any, headers?: any): IPromise; options(queryParams?: any, headers?: any): IPromise; diff --git a/sipml/sipml-test.ts b/sipml/sipml-test.ts new file mode 100644 index 000000000..5fed26fc6 --- /dev/null +++ b/sipml/sipml-test.ts @@ -0,0 +1,169 @@ +/// + +/* Code borrowed from http://sipml5.org/docgen/index.html?svn=224 */ + +var acceptMessage = (e: any)=> { + e.newSession.accept(); // e.newSession.reject(); to reject the message + console.info('SMS-content = ' + e.getContentString() + ' and SMS-content-type = ' + e.getContentType()); +}; +var acceptCall = (e:any)=> { + e.newSession.accept(); // e.newSession.reject() to reject the call +}; + + /* Initialize the engine */ +var readyCallback = (e:any)=> { + createSipStack(); // see next section +}; +var errorCallback = (e:any)=> { + console.error('Failed to initialize the engine: ' + e.message); +} +SIPml.init(readyCallback, errorCallback); + +/* Create a SIP stack */ +var sipStack: SIPml.Stack; +var eventsListener = (e:any)=> { + if(e.type == 'started'){ + login(); + } + else if(e.type == 'i_new_message'){ // incoming new SIP MESSAGE (SMS-like) + acceptMessage(e); + } + else if(e.type == 'i_new_call'){ // incoming audio/video call + acceptCall(e); + } +} + +function createSipStack(){ + sipStack = new SIPml.Stack('blaat'); + sipStack = new SIPml.Stack({ + realm: 'example.org', // mandatory: domain name + impi: 'bob', // mandatory: authorization name (IMS Private Identity) + impu: 'sip:bob@example.org', // mandatory: valid SIP Uri (IMS Public Identity) + password: 'mysecret', // optional + display_name: 'Bob legend', // optional + websocket_proxy_url: 'wss://sipml5.org:10062', // optional + outbound_proxy_url: 'udp://example.org:5060', // optional + enable_rtcweb_breaker: false, // optional + events_listener: { events: '*', listener: eventsListener }, // optional: '*' means all events + sip_headers: [ // optional + { name: 'User-Agent', value: 'IM-client/OMA1.0 sipML5-v1.0.0.0' }, + { name: 'Organization', value: 'Doubango Telecom' } + ] + } + ); +} +sipStack.start(); + +/* Register/login */ +var registerSession: SIPml.Session.Registration; +var eventsListener = (e:any)=>{ + console.info('session event = ' + e.type); + if(e.type == 'connected' && e.session == registerSession){ + makeCall(); + sendMessage(); + publishPresence(); + subscribePresence('johndoe'); // watch johndoe's presence status change + } +} +var login = ()=>{ + registerSession = sipStack.newSession('register', { + events_listener: { events: '*', listener: eventsListener } // optional: '*' means all events + }); + registerSession.register(); +} + +/* Making/receiving audio/video call */ +var callSession: SIPml.Session.Call; +var eventsListener = (e:any)=>{ + console.info('session event = ' + e.type); +} +var makeCall = ()=>{ + callSession = sipStack.newSession('call-audiovideo', { + video_local: document.getElementById('video-local'), + video_remote: document.getElementById('video-remote'), + audio_remote: document.getElementById('audio-remote'), + events_listener: { events: '*', listener: eventsListener } // optional: '*' means all events + }); + callSession.call('johndoe'); +} +var acceptCall = (e:any)=>{ + e.newSession.accept(); // e.newSession.reject() to reject the call +} + +/* Send/receive SIP MESSAGE (SMS-like) */ +var messageSession: SIPml.Session.Message; +var eventsListener = (e:any)=>{ + console.info('session event = ' + e.type); +} +var sendMessage = ()=>{ + messageSession = sipStack.newSession('message', { + events_listener: { events: '*', listener: eventsListener } // optional: '*' means all events + }); + messageSession.send('johndoe', 'Pêche à la moule', 'text/plain;charset=utf-8'); +} + +/* Publish presence status */ +var publishSession: SIPml.Session.Publish; +var eventsListener = (e:any)=>{ + console.info('session event = ' + e.type); +} +var publishPresence = ()=>{ + publishSession = sipStack.newSession('publish', { + events_listener: { events: '*', listener: eventsListener } // optional: '*' means all events + }); + var contentType = 'application/pidf+xml'; + var content = '\n' + + '\n' + + '\n' + + '\n'+ + ' open\n' + + ' away\n' + + '\n' + + 'tel:+33600000000\n' + + 'Bonjour de Paris :)\n' + + '\n' + + ''; + + // send the PUBLISH request + publishSession.publish(content, contentType,{ + expires: 200, + sip_caps: [ + { name: '+g.oma.sip-im' }, + { name: '+sip.ice' }, + { name: 'language', value: '\"en,fr\"' } + ], + sip_headers: [ + { name: 'Event', value: 'presence' }, + { name: 'Organization', value: 'Doubango Telecom' } + ] + }); +} + +/* Subscribe for presence status */ +var subscribeSession: SIPml.Session.Subscribe; +var eventsListener = (e:any)=>{ + console.info('session event = ' + e.type); + if(e.type == 'i_notify'){ + console.info('NOTIFY content = ' + e.getContentString()); + console.info('NOTIFY content-type = ' + e.getContentType()); + } +} +var subscribePresence = (to:string)=>{ + subscribeSession = sipStack.newSession('subscribe', { + expires: 200, + events_listener: { events: '*', listener: eventsListener }, + sip_headers: [ + { name: 'Event', value: 'presence' }, // only notify for 'presence' events + { name: 'Accept', value: 'application/pidf+xml' } // supported content types (COMMA-sparated) + ], + sip_caps: [ + { name: '+g.oma.sip-im', value: null }, + { name: '+audio', value: null }, + { name: 'language', value: '\"en,fr\"' } + ] + }); + // start watching for entity's presence status (You may track event type 'connected' to be sure that the request has been accepted by the server) + subscribeSession.subscribe(to); +} diff --git a/sipml/sipml.d.ts b/sipml/sipml.d.ts new file mode 100644 index 000000000..a4fe32784 --- /dev/null +++ b/sipml/sipml.d.ts @@ -0,0 +1,149 @@ +// Type definitions for SIPml5 +// Project: http://sipml5.org/ +// Definitions by: A. Groenenboom +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module SIPml { + class Event { + public description: string; + public type: string; + + public getContent(): Object; + public getContentString(): string; + public getContentType(): Object; + public getSipResponseCode(): number; + } + + class EventTarget { + public addEventListener(type: any, listener: Function): void; + public removeEventListener(type: any): void; + } + + class Session { + public accept(configuration?: Session.Configuration): number; + public getId(): number; + public getRemoteFriendlyName(): string; + public getRemoteUri(): string; + public reject(configuration?: Session.Configuration): number; + public setConfiguration(configuration?: Session.Configuration): void; + } + + export module Session { + interface Configuration { + audio_remote?: HTMLAudioElement; + bandwidth?: Object; + expires?: number; + from?: string; + sip_caps?: Object[]; + sip_headers?: Object[]; + video_local?: HTMLVideoElement; + video_remote?: HTMLVideoElement; + video_size?: Object; + } + + class Call extends Session { + public acceptTransfer(configuration?: Session.Configuration): number; + public call(to: string, configuration?: Session.Configuration): number; + public dtmf(): number; + public hangup(configuration?: Session.Configuration): number; + public hold(configuration?: Session.Configuration): number; + public info(): number; + public rejectTransfer(): number; + public resume(): number; + public transfer(): number; + } + + class Event extends SIPml.Event { + public session: Session; + + public getTransferDestinationFriendlyName(): string; + } + + class Message extends Session { + public send(to: string, content?: any, contentType?: string, configuration?: Session.Configuration): number; + } + + class Publish extends Session { + public publish(content?: any, contentType?: string, configuration?: Session.Configuration): number; + + public unpublish(configuration?: Session.Configuration): void; + } + + class Registration extends Session { + public register(configuration?: Session.Configuration): void; + public unregister(configuration?: Session.Configuration): void; + } + + class Subscribe extends Session { + public subscribe(to: string, configuration?: Session.Configuration): number; + public unsubscribe(configuration?: Session.Configuration): number; + } + } + + class Stack extends EventTarget { + public constructor(configuration?: Stack.Configuration); + public setConfiguration(configuration: Stack.Configuration): number; + public newSession(type: string, configuration: Stack.Configuration): any; + public start(): number; + public stop(timeout: number): number; + } + + export module Stack { + interface Configuration { + bandwidth?: Object; + display_name?: string; + enable_click2call?: boolean; + enable_early_ims?: boolean; + enable_media_stream_cache?: boolean; + enable_rtcweb_breaker?: boolean; + events_listener?: Object; + ice_servers?: Object[]; + impi?: string; + impu?: string; + outbound_proxy_url?: string; + password?: string; + realm?: string; + sip_headers?: Object[]; + video_size?: Object; + websocket_proxy_url?: string; + } + + class Event extends SIPml.Event { + public description: string; + public newSession: Session; + public type: string; + } + } + + function getNavigatorFriendlyName(): string; + + function getNavigatorVersion(): string; + + function getSystemFriendlyName(): string; + + function getWebRtc4AllVersion(): string; + + function haveMediaStream(): boolean; + + function init(readyCallback?: (e:any) => any, errorCallback?: (e:any) => any): boolean; + + function isInitialized(): boolean; + + function isNavigatorOutdated(): boolean; + + function isReady(): boolean; + + function isScreenShareSupported(): boolean; + + function isWebRtcPluginOutdated(): boolean; + + function isWebRtc4AllSupported(): boolean; + + function isWebRtcSupported(): boolean; + + function isWebSocketSupported(): boolean; + + function setDebugLevel(level: string): void; + + function setWebRtcType(type: string): boolean; +} diff --git a/smoothie/smoothie.d.ts b/smoothie/smoothie.d.ts index 18f0cc0a5..714590f84 100644 --- a/smoothie/smoothie.d.ts +++ b/smoothie/smoothie.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Smoothie Charts 1.21 +// Type definitions for Smoothie Charts 1.25 // Project: https://github.com/joewalnes/smoothie // Definitions by: Drew Noakes , Mike H. Hawley // Definitions: https://github.com/borisyankov/DefinitelyTyped/smoothie @@ -41,6 +41,11 @@ declare module "smoothie" */ constructor(options?: ITimeSeriesOptions); + /** + * Clears all data and state from this TimeSeries object. + */ + clear(): void; + /** * Recalculate the min/max values for this TimeSeries object. * diff --git a/threejs/tests/canvas/canvas_camera_orthographic.ts b/threejs/tests/canvas/canvas_camera_orthographic.ts index 0674e6fa4..7391d978b 100644 --- a/threejs/tests/canvas/canvas_camera_orthographic.ts +++ b/threejs/tests/canvas/canvas_camera_orthographic.ts @@ -55,12 +55,12 @@ // Cubes - var geometry = new THREE.BoxGeometry(50, 50, 50); + var geometry2 = new THREE.BoxGeometry(50, 50, 50); var material2 = new THREE.MeshLambertMaterial({ color: 0xffffff, shading: THREE.FlatShading, overdraw: 0.5 }); for (var i = 0; i < 100; i++) { - var cube = new THREE.Mesh(geometry, material2); + var cube = new THREE.Mesh(geometry2, material2); cube.scale.y = Math.floor(Math.random() * 2 + 1); diff --git a/threejs/tests/canvas/canvas_geometry_cube.ts b/threejs/tests/canvas/canvas_geometry_cube.ts index bf5f9ae99..c8f6b377c 100644 --- a/threejs/tests/canvas/canvas_geometry_cube.ts +++ b/threejs/tests/canvas/canvas_geometry_cube.ts @@ -61,12 +61,12 @@ // Plane - var geometry = new THREE.PlaneGeometry(200, 200); - geometry.applyMatrix(new THREE.Matrix4().makeRotationX(- Math.PI / 2)); + var geometry2 = new THREE.PlaneGeometry(200, 200); + geometry2.applyMatrix(new THREE.Matrix4().makeRotationX(- Math.PI / 2)); var material = new THREE.MeshBasicMaterial({ color: 0xe0e0e0, overdraw: 0.5 }); - plane = new THREE.Mesh(geometry, material); + plane = new THREE.Mesh(geometry2, material); scene.add(plane); renderer = new THREE.CanvasRenderer(); diff --git a/threejs/tests/canvas/canvas_materials.ts b/threejs/tests/canvas/canvas_materials.ts index a39a780ca..0d8f8a631 100644 --- a/threejs/tests/canvas/canvas_materials.ts +++ b/threejs/tests/canvas/canvas_materials.ts @@ -50,7 +50,7 @@ // Spheres - var geometry = new THREE.SphereGeometry(100, 14, 7); + var geometry2 = new THREE.SphereGeometry(100, 14, 7); materials = [ @@ -66,9 +66,9 @@ ]; - for (var i = 0, l = geometry.faces.length; i < l; i++) { + for (var i = 0, l = geometry2.faces.length; i < l; i++) { - var face = geometry.faces[i]; + var face = geometry2.faces[i]; if (Math.random() > 0.5) face.materialIndex = Math.floor(Math.random() * materials.length); } @@ -79,7 +79,7 @@ for (var i = 0, l = materials.length; i < l; i++) { - var sphere = new THREE.Mesh(geometry, materials[i]); + var sphere = new THREE.Mesh(geometry2, materials[i]); sphere.position.x = (i % 5) * 200 - 400; sphere.position.z = Math.floor(i / 5) * 200 - 200; diff --git a/threejs/three.d.ts b/threejs/three.d.ts index cddaf7b0f..a9c33693c 100644 --- a/threejs/three.d.ts +++ b/threejs/three.d.ts @@ -8,33 +8,7 @@ interface WebGLRenderingContext {} declare module THREE { export var REVISION: string; - // custom blending equations - // (numbers start from 100 not to clash with other - // mappings to OpenGL constants defined in Texture.js) - export enum BlendingEquation { } - export var AddEquation: BlendingEquation; - export var SubtractEquation: BlendingEquation; - export var ReverseSubtractEquation: BlendingEquation; - - // custom blending destination factors - export enum BlendingDstFactor { } - export var ZeroFactor: BlendingDstFactor; - export var OneFactor: BlendingDstFactor; - export var SrcColorFactor: BlendingDstFactor; - export var OneMinusSrcColorFactor: BlendingDstFactor; - export var SrcAlphaFactor: BlendingDstFactor; - export var OneMinusSrcAlphaFactor: BlendingDstFactor; - export var DstAlphaFactor: BlendingDstFactor; - export var OneMinusDstAlphaFactor: BlendingDstFactor; - - // custom blending source factors - export enum BlendingSrcFactor { } - export var DstColorFactor: BlendingSrcFactor; - export var OneMinusDstColorFactor: BlendingSrcFactor; - export var SrcAlphaSaturateFactor: BlendingSrcFactor; - // GL STATE CONSTANTS - export enum CullFace { } export var CullFaceNone: CullFace; export var CullFaceBack: CullFace; @@ -45,6 +19,12 @@ declare module THREE { export var FrontFaceDirectionCW: FrontFaceDirection; export var FrontFaceDirectionCCW: FrontFaceDirection; + // Shadowing Type + export enum ShadowMapType { } + export var BasicShadowMap: ShadowMapType; + export var PCFShadowMap: ShadowMapType; + export var PCFSoftShadowMap: ShadowMapType; + // MATERIAL CONSTANTS // side @@ -74,11 +54,30 @@ declare module THREE { export var MultiplyBlending: Blending; export var CustomBlending: Blending; - // Shadowing Type - export enum ShadowMapType { } - export var BasicShadowMap: ShadowMapType; - export var PCFShadowMap: ShadowMapType; - export var PCFSoftShadowMap: ShadowMapType; + // custom blending equations + // (numbers start from 100 not to clash with other + // mappings to OpenGL constants defined in Texture.js) + export enum BlendingEquation { } + export var AddEquation: BlendingEquation; + export var SubtractEquation: BlendingEquation; + export var ReverseSubtractEquation: BlendingEquation; + + // custom blending destination factors + export enum BlendingDstFactor { } + export var ZeroFactor: BlendingDstFactor; + export var OneFactor: BlendingDstFactor; + export var SrcColorFactor: BlendingDstFactor; + export var OneMinusSrcColorFactor: BlendingDstFactor; + export var SrcAlphaFactor: BlendingDstFactor; + export var OneMinusSrcAlphaFactor: BlendingDstFactor; + export var DstAlphaFactor: BlendingDstFactor; + export var OneMinusDstAlphaFactor: BlendingDstFactor; + + // custom blending src factors + export enum BlendingSrcFactor { } + export var DstColorFactor: BlendingSrcFactor; + export var OneMinusDstColorFactor: BlendingSrcFactor; + export var SrcAlphaSaturateFactor: BlendingSrcFactor; // TEXTURE CONSTANTS // Operations @@ -125,7 +124,6 @@ declare module THREE { // Pixel types export enum PixelType { } - export var UnsignedShort4444Type: PixelType; export var UnsignedShort5551Type: PixelType; export var UnsignedShort565Type: PixelType; @@ -145,6 +143,7 @@ declare module THREE { export var RGBA_S3TC_DXT3_Format: CompressedPixelFormat; export var RGBA_S3TC_DXT5_Format: CompressedPixelFormat; + // Cameras //////////////////////////////////////////////////////////////////////////////////////// /** @@ -171,6 +170,7 @@ declare module THREE { * @param vector point to look at */ lookAt(vector: Vector3): void; + clone(camera?: Camera): Camera; } @@ -335,9 +335,9 @@ declare module THREE { // Core /////////////////////////////////////////////////////////////////////////////////////////////// export class BufferAttribute { - constructor(array: any, itemSize: number); + constructor(array: any, itemSize: number); // array parameter should be TypedArray. - array: any; + array: number[]; itemSize: number; length: number; @@ -352,47 +352,47 @@ declare module THREE { // deprecated export class Int8Attribute extends BufferAttribute{ - constructor(data: any[], itemSize: number); + constructor(data: any, itemSize: number); } // deprecated export class Uint8Attribute extends BufferAttribute { - constructor(data: any[], itemSize: number); + constructor(data: any, itemSize: number); } // deprecated export class Uint8ClampedAttribute extends BufferAttribute { - constructor(data: any[], itemSize: number); + constructor(data: any, itemSize: number); } // deprecated export class Int16Attribute extends BufferAttribute { - constructor(data: any[], itemSize: number); + constructor(data: any, itemSize: number); } // deprecated export class Uint16Attribute extends BufferAttribute { - constructor(data: any[], itemSize: number); + constructor(data: any, itemSize: number); } // deprecated export class Int32Attribute extends BufferAttribute { - constructor(data: any[], itemSize: number); + constructor(data: any, itemSize: number); } // deprecated export class Uint32Attribute extends BufferAttribute { - constructor(data: any[], itemSize: number); + constructor(data: any, itemSize: number); } // deprecated export class Float32Attribute extends BufferAttribute { - constructor(data: any[], itemSize: number); + constructor(data: any, itemSize: number); } // deprecated export class Float64Attribute extends BufferAttribute { - constructor(data: any[], itemSize: number); + constructor(data: any, itemSize: number); } /** @@ -412,7 +412,6 @@ declare module THREE { * Unique number of this buffergeometry instance */ id: number; - uuid: string; name: string; attributes: BufferAttribute[]; @@ -445,6 +444,9 @@ declare module THREE { */ computeBoundingSphere(): void; + // deprecated + computeFaceNormals(): void; + /** * Computes vertex normals by averaging face normals. */ @@ -635,23 +637,21 @@ declare module THREE { */ c: number; - // properties inherits from Face /////////////////////////////////// - /** * Face normal. */ normal: Vector3; - /** - * Face color. - */ - color: Color; - /** * Array of 4 vertex normals. */ vertexNormals: Vector3[]; + /** + * Face color. + */ + color: Color; + /** * Array of 4 vertex normals. */ @@ -716,6 +716,8 @@ declare module THREE { */ id: number; + uuid: string; + /** * Name for this geometry. Default is an empty string. */ @@ -735,13 +737,6 @@ declare module THREE { */ colors: Color[]; - /** - * Array of vertex normals, matching number and order of vertices. - * Normal vectors are nessecary for lighting - * To signal an update in this array, Geometry.normalsNeedUpdate needs to be set to true. - */ -// normals: Vector3[]; - /** * Array of triangles or/and quads. * The array of faces describe how each vertex in the model is connected with each other. @@ -749,13 +744,6 @@ declare module THREE { */ faces: Face3[]; - /** - * Array of face UV layers. - * Each UV layer is an array of UV matching order and number of faces. - * To signal an update in this array, Geometry.uvsNeedUpdate needs to be set to true. - */ -// faceUvs: Vector2[][]; - /** * Array of face UV layers. * Each UV layer is an array of UV matching order and number of vertices in faces. @@ -901,6 +889,8 @@ declare module THREE { */ computeTangents(): void; + computeLineDistances(): void; + /** * Computes bounding box of the geometry, updating {@link Geometry.boundingBox} attribute. */ @@ -920,6 +910,8 @@ declare module THREE { */ mergeVertices(): number; + makeGroups(usesFaceMaterial: boolean, maxVerticesInGroup: number): void; + /** * Creates a new clone of the Geometry. */ @@ -931,10 +923,6 @@ declare module THREE { */ dispose(): void; - computeLineDistances(): void; - - makeGroups(usesFaceMaterial: boolean, maxVerticesInGroup: number): void; - // EventDispatcher mixins addEventListener(type: string, listener: (event: any) => void ): void; @@ -1063,8 +1051,9 @@ declare module THREE { /** * Order of axis for Euler angles. */ + // deprecated eulerOrder: string; - // eulerOrder:EulerOrder; + /** * This updates the position, rotation and scale with the matrix. @@ -1091,6 +1080,13 @@ declare module THREE { */ setRotationFromQuaternion( q: Quaternion ): void; + /** + * Rotate an object along an axis in object space. The axis is assumed to be normalized. + * @param axis A normalized vector in object space. + * @param angle The angle in radians. + */ + rotateOnAxis(axis: Vector3, angle: number): Object3D; + /** * * @param angle @@ -1109,6 +1105,12 @@ declare module THREE { */ rotateZ(angle: number): Object3D; + /** + * @param axis A normalized vector in object space. + * @param distance The distance to translate. + */ + translateOnAxis(axis: Vector3, distance: number): Object3D; + /** * * @param distance @@ -1187,10 +1189,10 @@ declare module THREE { * @param name String to match to the children's Object3d.name property. * @param recursive Boolean whether to search through the children's children. Default is false. */ - getObjectByName(name: string, recursive: boolean): Object3D; + getObjectByName(name: string, recursive?: boolean): Object3D; - getChildByName( name: string, recursive: boolean ): Object3D; + getChildByName( name: string, recursive?: boolean ): Object3D; /** * Updates local transform. @@ -1209,20 +1211,6 @@ declare module THREE { */ clone(object?: Object3D, recursive?: boolean): Object3D; - /** - * @param axis A normalized vector in object space. - * @param distance The distance to translate. - */ - translateOnAxis(axis: Vector3, distance: number): Object3D; - - /** - * Rotate an object along an axis in object space. The axis is assumed to be normalized. - * @param axis A normalized vector in object space. - * @param angle The angle in radians. - */ - rotateOnAxis(axis: Vector3, angle: number): Object3D; - - // EventDispatcher mixins addEventListener(type: string, listener: (event: any) => void ): void; hasEventListener(type: string, listener: (event: any) => void): void; @@ -1279,6 +1267,7 @@ declare module THREE { export class Raycaster { constructor(origin?: Vector3, direction?: Vector3, near?: number, far?: number); + ray: Ray; near: number; far: number; @@ -1324,15 +1313,15 @@ declare module THREE { export class AreaLight extends Light{ constructor(hex: number, intensity?: number); - position: Vector3; - right: Vector3; normal: Vector3; - quadraticAttenuation: number; - height: number; - linearAttenuation: number; - width: number; + right: Vector3; intensity: number; + width: number; + height: number; constantAttenuation: number; + linearAttenuation: number; + quadraticAttenuation: number; + } /** @@ -1350,12 +1339,6 @@ declare module THREE { constructor(hex?: number, intensity?: number); - /** - * Direction of the light is normalized vector from position to (0,0,0). - * Default — new THREE.Vector3(). - */ - position: Vector3; - /** * Target used for shadow camera orientation. */ @@ -1516,7 +1499,6 @@ declare module THREE { export class HemisphereLight extends Light { constructor(skyColorHex?: number, groundColorHex?: number, intensity?: number); - position: Vector3; groundColor: Color; intensity: number; @@ -1534,12 +1516,6 @@ declare module THREE { export class PointLight extends Light { constructor(hex?: number, intensity?: number, distance?: number); - /** - * Light's position. - * Default — new THREE.Vector3(). - */ - position: Vector3; - /* * Light's intensity. * Default - 1.0. @@ -1573,12 +1549,6 @@ declare module THREE { export class SpotLight extends Light { constructor(hex?: number, intensity?: number, distance?: number, angle?: number, exponent?: number); - /** - * Light's position. - * Default — new THREE.Vector3(). - */ - position: Vector3; - /** * Spotlight focus points at target.position. * Default position — (0,0,0). @@ -1668,11 +1638,11 @@ declare module THREE { * Default — 512. */ shadowMapHeight: number; - shadowMatrix: Matrix4; + shadowMap: RenderTarget; shadowMapSize: Vector2; shadowCamera: Camera; - shadowMap: RenderTarget; + shadowMatrix: Matrix4; clone(): SpotLight; } @@ -1734,12 +1704,12 @@ declare module THREE { */ crossOrigin: string; - needsTangents(materials: Material[]): boolean; - updateProgress(progress: Progress): void; - createMaterial(m: Material, texturePath: string): boolean; - initMaterials(materials: Material[], texturePath: string): Material[]; - extractUrlBase(url: string): string; addStatusElement(): HTMLElement; + updateProgress(progress: Progress): void; + extractUrlBase(url: string): string; + initMaterials(materials: Material[], texturePath: string): Material[]; + needsTangents(materials: Material[]): boolean; + createMaterial(m: Material, texturePath: string): boolean; static Handlers:LoaderHandler; } @@ -1756,17 +1726,8 @@ declare module THREE { load(url: string, onLoad: (bufferGeometry: BufferGeometry) => void, onProgress?: (event: any) => void, onError?: (event: any) => void): void; setCrossOrigin(crossOrigin: string): void; parse(json: any): BufferGeometry; - } - /* - * GeometryLoader class is experimental, and it is not yet included in the compiled source code. - * - export class GeometryLoader { - - } - */ - export class Cache{ constructor(); @@ -1777,12 +1738,22 @@ declare module THREE { remove(key: string): void; clear(): void; } + + /* + * GeometryLoader class is experimental, and it is not yet included in the compiled source code. + * + export class GeometryLoader { + + } + */ + /** * A loader for loading an image. * Unlike other loaders, this one emits events instead of using predefined callbacks. So if you're interested in getting notified when things happen, you need to add listeners to the object. */ export class ImageLoader { constructor(manager?: LoadingManager); + crossOrigin: string; /** @@ -1790,15 +1761,16 @@ declare module THREE { * @param url */ load(url: string, onLoad?: (image: HTMLImageElement) => void, onProgress?: (event: any) => void, onError?: (event: any) => void): HTMLImageElement; + setCrossOrigin(crossOrigin: string): void; } - /** * A loader for loading objects in JSON format. */ export class JSONLoader extends Loader { constructor(showStatus?: boolean); + withCredentials: boolean; /** @@ -1807,12 +1779,13 @@ declare module THREE { * @param texturePath If not specified, textures will be assumed to be in the same folder as the Javascript model file. */ load(url: string, callback: (geometry: JSonLoaderResultGeometry, materials: Material[]) => void , texturePath?: string): void; - parse(json:string, texturePath:string): any; + loadAjaxJSON(context: JSONLoader, url: string, callback: (geometry: Geometry, materials: Material[]) => void , texturePath?: string, callbackProgress?: (progress: Progress) => void ): void; + parse(json:string, texturePath:string): any; } - export class JSonLoaderResultGeometry extends Geometry { + export interface JSonLoaderResultGeometry extends Geometry { animation: AnimationData; } @@ -1883,16 +1856,34 @@ declare module THREE { export class XHRLoader { constructor(manager?: LoadingManager); - cache: Cache; - crossOrigin: string; responseType: string; + crossOrigin: string; load(url: string, onLoad?: (responseText: string) => void, onProgress?: (event: any) => void, onError?: (event: any) => void): void; - setCrossOrigin(crossOrigin: string): void; setResponseType(responseType: string): void; + setCrossOrigin(crossOrigin: string): void; } // Materials ////////////////////////////////////////////////////////////////////////////////// + export interface MaterialParameters { + name?: string; + side?: Side; + opacity?: number; + transparent?: boolean; + blending?: Blending; + blendSrc?: BlendingDstFactor; + blendDst?: BlendingSrcFactor; + blendEquation?: BlendingEquation; + depthTest?: boolean; + depthWrite?: boolean; + polygonOffset?: boolean; + polygonOffsetFactor?: number; + polygonOffsetUnits?: number; + alphaTest?: number; + overdraw?: number; + visible?: boolean; + needsUpdate?: boolean; + } /** * Materials describe the appearance of objects. They are defined in a (mostly) renderer-independent way, so you don't have to rewrite materials if you decide to use a different renderer. @@ -1905,11 +1896,19 @@ declare module THREE { */ id: number; + uuid: string; + /** * Material name. Default is an empty string. */ name: string; + /** + * Defines which of the face sides will be rendered - front, back or both. + * Default is THREE.FrontSide. Other options are THREE.BackSide and THREE.DoubleSide. + */ + side: Side; + /** * Opacity. Default is 1. */ @@ -1982,23 +1981,15 @@ declare module THREE { */ visible: boolean; - /** - * Defines which of the face sides will be rendered - front, back or both. - * Default is THREE.FrontSide. Other options are THREE.BackSide and THREE.DoubleSide. - */ - side: Side; - /** * Specifies that the material needs to be updated, WebGL wise. Set it to true if you made changes that need to be reflected in WebGL. * This property is automatically set to true when instancing a new material. */ needsUpdate: boolean; - clone(material?:Material): Material; - - dispose(): void; setValues(values: Object): void; - + clone(material?:Material): Material; + dispose(): void; // EventDispatcher mixins addEventListener(type: string, listener: (event: any) => void ): void; @@ -2007,7 +1998,7 @@ declare module THREE { dispatchEvent(event: { type: string; target: any; }): void; } - export interface LineBasicMaterialParameters { + export interface LineBasicMaterialParameters extends MaterialParameters { color?: number; linewidth?: number; linecap?: string; @@ -2017,8 +2008,8 @@ declare module THREE { } export class LineBasicMaterial extends Material { - constructor(parameters?: LineBasicMaterialParameters); + color: Color; linewidth: number; linecap: string; @@ -2029,86 +2020,87 @@ declare module THREE { clone(): LineBasicMaterial; } - export interface LineDashedMaterialParameters { - scale?: number; + export interface LineDashedMaterialParameters extends MaterialParameters { color?: number; - vertexColors?: boolean; - dashSize?: number; - fog?: boolean; - gapSize?: number; linewidth?: number; + scale?: number; + dashSize?: number; + gapSize?: number; + vertexColors?: Colors; + fog?: boolean; } export class LineDashedMaterial extends Material { constructor(parameters?: LineDashedMaterialParameters); - scale: number; + color: Color; - vertexColors: boolean; - dashSize: number; - fog: boolean; - gapSize: number; linewidth: number; + scale: number; + dashSize: number; + gapSize: number; + vertexColors: Colors; + fog: boolean; clone(): LineDashedMaterial; } - /** * parameters is an object with one or more properties defining the material's appearance. */ - export interface MeshBasicMaterialParameters { + export interface MeshBasicMaterialParameters extends MaterialParameters{ color?: number; - wireframe?: boolean; - wireframeLinewidth?: number; - wireframeLinecap?: string; - wireframeLinejoin?: string; - shading?: Shading; - vertexColors?: Colors; - fog?: boolean; + map?: Texture; lightMap?: Texture; specularMap?: Texture; alphaMap?: Texture; envMap?: Texture; - skinning?: boolean; - morphTargets?: boolean; - map?: Texture; combine?: Combine; reflectivity?: number; refractionRatio?: number; + fog?: boolean; + shading?: Shading; + wireframe?: boolean; + wireframeLinewidth?: number; + wireframeLinecap?: string; + wireframeLinejoin?: string; + vertexColors?: Colors; + skinning?: boolean; + morphTargets?: boolean; } export class MeshBasicMaterial extends Material { constructor(parameters?: MeshBasicMaterialParameters); color: Color; - wireframe: boolean; - wireframeLinewidth: number; - wireframeLinecap: string; - wireframeLinejoin: string; - shading: Shading; - vertexColors: Colors; - fog: boolean; + map: Texture; lightMap: Texture; specularMap: Texture; alphaMap: Texture; envMap: Texture; - skinning: boolean; - morphTargets: boolean; - map: Texture; combine: Combine; reflectivity: number; refractionRatio: number; + fog: boolean; + shading: Shading; + wireframe: boolean; + wireframeLinewidth: number; + wireframeLinecap: string; + wireframeLinejoin: string; + vertexColors: Colors; + skinning: boolean; + morphTargets: boolean; clone(): MeshBasicMaterial; } - export interface MeshDepthMaterialParameters { + export interface MeshDepthMaterialParameters extends MaterialParameters{ wireframe?: boolean; wireframeLinewidth?: number; } export class MeshDepthMaterial extends Material { constructor(parameters?: MeshDepthMaterialParameters); + wireframe: boolean; wireframeLinewidth: number; @@ -2124,30 +2116,30 @@ declare module THREE { clone(): MeshFaceMaterial; } - export interface MeshLambertMaterialParameters { + export interface MeshLambertMaterialParameters extends MaterialParameters{ color?: number; ambient?: number; emissive?: number; + wrapAround?: boolean; + wrapRGB?: Vector3; + map?: Texture; + lightMap?: Texture; + specularMap?: Texture; + alphaMap?: Texture; + envMap?: Texture; + combine?: Combine; + reflectivity?: number; + refractionRatio?: number; + fog?: boolean; shading?: Shading; wireframe?: boolean; wireframeLinewidth?: number; wireframeLinecap?: string; wireframeLinejoin?: string; vertexColors?: Colors; - fog?: boolean; - map?: Texture; - lightMap?: Texture; - specularMap?: Texture; - alphaMap?: Texture; - envMap?: Texture; - reflectivity?: number; - refractionRatio?: number; - combine?: Combine; skinning?: boolean; morphTargets?: boolean; - wrapRGB?: Vector3; morphNormals?: boolean; - wrapAround?: boolean; } export class MeshLambertMaterial extends Material { @@ -2155,119 +2147,119 @@ declare module THREE { color: Color; ambient: Color; emissive: Color; + wrapAround: boolean; + wrapRGB: Vector3; + map: Texture; + lightMap: Texture; + specularMap: Texture; + alphaMap: Texture; + envMap: Texture; + combine: Combine; + reflectivity: number; + refractionRatio: number; + fog: boolean; shading: Shading; wireframe: boolean; wireframeLinewidth: number; wireframeLinecap: string; wireframeLinejoin: string; vertexColors: Colors; - fog: boolean; - map: Texture; - lightMap: Texture; - specularMap: Texture; - alphaMap: Texture; - envMap: Texture; - reflectivity: number; - refractionRatio: number; - combine: Combine; skinning: boolean; morphTargets: boolean; - wrapRGB: Vector3; morphNormals: boolean; - wrapAround: boolean; clone(): MeshLambertMaterial; } - export interface MeshNormalMaterialParameters { - morphTargets?: boolean; + export interface MeshNormalMaterialParameters extends MaterialParameters{ shading?: Shading; wireframe?: boolean; wireframeLinewidth?: number; + morphTargets?: boolean; } export class MeshNormalMaterial extends Material { constructor(parameters?: MeshNormalMaterialParameters); - morphTargets: boolean; + shading: Shading; wireframe: boolean; wireframeLinewidth: number; + morphTargets: boolean; clone(): MeshNormalMaterial; } - export interface MeshPhongMaterialParameters { + export interface MeshPhongMaterialParameters extends MaterialParameters{ color?: number; // diffuse ambient?: number; emissive?: number; specular?: number; shininess?: number; + metal?: boolean; + wrapAround?: boolean; + wrapRGB?: Vector3; + map?: Texture; + lightMap?: Texture; + bumpMap?: Texture; + bumpScale?: number; + normalMap?: Texture; + normalScale?: Vector2; + specularMap?: Texture; + alphaMap?: Texture; + envMap?: Texture; + combine?: Combine; + reflectivity?: number; + refractionRatio?: number; + fog?: boolean; shading?: Shading; wireframe?: boolean; wireframeLinewidth?: number; wireframeLinecap?: string; wireframeLinejoin?: string; vertexColors?: Colors; - fog?: boolean; - map?: Texture; - lightMap?: Texture; - specularMap?: Texture; - alphaMap?: Texture; - envMap?: Texture; - reflectivity?: number; - refractionRatio?: number; - combine?: Combine; skinning?: boolean; morphTargets?: boolean; - normalScale?: Vector2; morphNormals?: boolean; - metal?: boolean; - bumpScale?: number; - wrapAround?: boolean; - perPixel?: boolean; - normalMap?: Texture; - bumpMap?: Texture; - wrapRGB?: Vector3; } export class MeshPhongMaterial extends Material { constructor(parameters?: MeshPhongMaterialParameters); + color: Color; // diffuse ambient: Color; emissive: Color; specular: Color; shininess: number; + metal: boolean; + wrapAround: boolean; + wrapRGB: Vector3; + map: Texture; + lightMap: Texture; + bumpMap: Texture; + bumpScale: number; + normalMap: Texture; + normalScale: Vector2; + specularMap: Texture; + alphaMap: Texture; + envMap: Texture; + combine: Combine; + reflectivity: number; + refractionRatio: number; + fog: boolean; shading: Shading; wireframe: boolean; wireframeLinewidth: number; wireframeLinecap: string; wireframeLinejoin: string; vertexColors: Colors; - fog: boolean; - map: Texture; - lightMap: Texture; - specularMap: Texture; - alphaMap: Texture; - envMap: Texture; - reflectivity: number; - refractionRatio: number; - combine: Combine; skinning: boolean; morphTargets: boolean; - normalScale: Vector2; morphNormals: boolean; - metal: boolean; - bumpScale: number; - wrapAround: boolean; - - normalMap: Texture; - bumpMap: Texture; - wrapRGB: Vector3; clone(): MeshPhongMaterial; } - export interface PointCloudMaterialParameters { + export interface PointCloudMaterialParameters extends MaterialParameters{ color?: number; map?: Texture; size?: number; @@ -2277,7 +2269,6 @@ declare module THREE { } export class PointCloudMaterial extends Material { - constructor(parameters?: PointCloudMaterialParameters); color: Color; @@ -2305,75 +2296,47 @@ declare module THREE { } - export interface ShaderMaterialParameters { + export interface ShaderMaterialParameters extends MaterialParameters{ + defines?: any; uniforms?: any; - fragmentShader?: string; - vertexShader?: string; - morphTargets?: boolean; - lights?: boolean; - morphNormals?: boolean; - wireframe?: boolean; - vertexColors?: Colors; - skinning?: boolean; - fog?: boolean; attributes?: any; + vertexShader?: string; + fragmentShader?: string; shading?: Shading; linewidth?: number; + wireframe?: boolean; wireframeLinewidth?: number; - defines?: any; + fog?: boolean; + lights?: boolean; + vertexColors?: Colors; + skinning?: boolean; + morphTargets?: boolean; + morphNormals?: boolean; } export class ShaderMaterial extends Material { constructor(parameters?: ShaderMaterialParameters); + defines: any; uniforms: any; - fragmentShader: string; - vertexShader: string; - morphTargets: boolean; - lights: boolean; - morphNormals: boolean; - wireframe: boolean; - vertexColors: Colors; - skinning: boolean; - fog: boolean; attributes: any; + vertexShader: string; + fragmentShader: string; shading: Shading; linewidth: number; + wireframe: boolean; wireframeLinewidth: number; - defines: any; + fog: boolean; + lights: boolean; + vertexColors: Colors; + skinning: boolean; + morphTargets: boolean; + morphNormals: boolean; clone(): ShaderMaterial; } - export interface SpriteMaterialParameters { - map?: Texture; - uvScale?: Vector2; - sizeAttenuation?: boolean; - color?: number; - uvOffset?: Vector2; - fog?: boolean; - useScreenCoordinates?: boolean; - scaleByViewport?: boolean; - alignment?: Vector2; - } - - export class SpriteMaterial extends Material { - constructor(parameters?: SpriteMaterialParameters); - - map: Texture; - uvScale: Vector2; - sizeAttenuation: boolean; - color: Color; - uvOffset: Vector2; - fog: boolean; - useScreenCoordinates: boolean; - scaleByViewport: boolean; - alignment: Vector2; - - clone(): SpriteMaterial; - } - - export interface SpriteCanvasMaterialParameters { + export interface SpriteCanvasMaterialParameters extends MaterialParameters{ color?: number; } @@ -2387,67 +2350,87 @@ declare module THREE { clone(): SpriteCanvasMaterial; } + export interface SpriteMaterialParameters extends MaterialParameters{ + color?: number; + map?: Texture; + rotation?: number; + fog?: boolean; + } + + export class SpriteMaterial extends Material { + constructor(parameters?: SpriteMaterialParameters); + + color: Color; + map: Texture; + rotation: number; + fog: boolean; + + clone(): SpriteMaterial; + } + // Math ////////////////////////////////////////////////////////////////////////////////// export class Box2 { constructor(min?: Vector2, max?: Vector2); + max: Vector2; min: Vector2; set(min: Vector2, max: Vector2): Box2; - expandByPoint(point: Vector2): Box2; - clampPoint(point: Vector2, optionalTarget?: Vector2): Vector2; - isIntersectionBox(box: Box2): boolean; setFromPoints(points: Vector2[]): Box2; - size(optionalTarget?: Vector2): Vector2; - union(box: Box2): Box2; - getParameter(point: Vector2): Vector2; - expandByScalar(scalar: number): Box2; - intersect(box: Box2): Box2; - containsBox(box: Box2): boolean; - translate(offset: Vector2): Box2; - empty(): boolean; - clone(): Box2; - equals(box: Box2): boolean; - expandByVector(vector: Vector2): Box2; + setFromCenterAndSize(center: Vector2, size: number): Box2; copy(box: Box2): Box2; makeEmpty(): Box2; + empty(): boolean; center(optionalTarget?: Vector2): Vector2; - distanceToPoint(point: Vector2): number; + size(optionalTarget?: Vector2): Vector2; + expandByPoint(point: Vector2): Box2; + expandByVector(vector: Vector2): Box2; + expandByScalar(scalar: number): Box2; containsPoint(point: Vector2): boolean; - setFromCenterAndSize(center: Vector2, size: number): Box2; + containsBox(box: Box2): boolean; + getParameter(point: Vector2): Vector2; + isIntersectionBox(box: Box2): boolean; + clampPoint(point: Vector2, optionalTarget?: Vector2): Vector2; + distanceToPoint(point: Vector2): number; + intersect(box: Box2): Box2; + union(box: Box2): Box2; + translate(offset: Vector2): Box2; + equals(box: Box2): boolean; + clone(): Box2; } export class Box3 { constructor(min?: Vector3, max?: Vector3); + max: Vector3; min: Vector3; set(min: Vector3, max: Vector3): Box3; - applyMatrix4(matrix: Matrix4): Box3; - expandByPoint(point: Vector3): Box3; - clampPoint(point: Vector3, optionalTarget?: Vector3): Vector3; - isIntersectionBox(box: Box3): boolean; setFromPoints(points: Vector3[]): Box3; - size(optionalTarget?: Vector3): Vector3; - union(box: Box3): Box3; - getParameter(point: Vector3): Vector3; - expandByScalar(scalar: number): Box3; - intersect(box: Box3): Box3; - containsBox(box: Box3): boolean; - translate(offset: Vector3): Box3; - empty(): boolean; - clone(): Box3; - equals(box: Box3): boolean; - expandByVector(vector: Vector3): Box3; - copy(box: Box3): Box3; - makeEmpty(): Box3; - center(optionalTarget?: Vector3): Vector3; - getBoundingSphere(): Sphere; - distanceToPoint(point: Vector3): number; - containsPoint(point: Vector3): boolean; setFromCenterAndSize(center: Vector3, size: number): Box3; setFromObject(object: Object3D): Box3; + copy(box: Box3): Box3; + makeEmpty(): Box3; + empty(): boolean; + center(optionalTarget?: Vector3): Vector3; + size(optionalTarget?: Vector3): Vector3; + expandByPoint(point: Vector3): Box3; + expandByVector(vector: Vector3): Box3; + expandByScalar(scalar: number): Box3; + containsPoint(point: Vector3): boolean; + containsBox(box: Box3): boolean; + getParameter(point: Vector3): Vector3; + isIntersectionBox(box: Box3): boolean; + clampPoint(point: Vector3, optionalTarget?: Vector3): Vector3; + distanceToPoint(point: Vector3): number; + getBoundingSphere(): Sphere; + intersect(box: Box3): Box3; + union(box: Box3): Box3; + applyMatrix4(matrix: Matrix4): Box3; + translate(offset: Vector3): Box3; + equals(box: Box3): boolean; + clone(): Box3; } export interface HSL { @@ -2488,6 +2471,31 @@ declare module THREE { set(color: Color): Color; set(color: number): Color; set(color: string): Color; + setHex(hex: number): Color; + + /** + * Sets this color from RGB values. + * @param r Red channel value between 0 and 1. + * @param g Green channel value between 0 and 1. + * @param b Blue channel value between 0 and 1. + */ + setRGB(r: number, g: number, b: number): Color; + + /** + * Sets this color from HSL values. + * Based on MochiKit implementation by Bob Ippolito. + * + * @param h Hue channel value between 0 and 1. + * @param s Saturation value channel between 0 and 1. + * @param l Value channel value between 0 and 1. + */ + setHSL(h: number, s: number, l: number): Color; + + /** + * Sets this color from a CSS context style string. + * @param contextStyle Color in CSS context style format. + */ + setStyle(style: string): Color; /** * Copies given color. @@ -2517,14 +2525,6 @@ declare module THREE { */ convertLinearToGamma(): Color; - /** - * Sets this color from RGB values. - * @param r Red channel value between 0 and 1. - * @param g Green channel value between 0 and 1. - * @param b Blue channel value between 0 and 1. - */ - setRGB(r: number, g: number, b: number): Color; - /** * Returns the hexadecimal value of this color. */ @@ -2535,13 +2535,7 @@ declare module THREE { */ getHexString(): string; - setHex(hex: number): Color; - - /** - * Sets this color from a CSS context style string. - * @param contextStyle Color in CSS context style format. - */ - setStyle(style: string): Color; + getHSL(): HSL; /** * Returns the value of this color in CSS context style. @@ -2549,18 +2543,6 @@ declare module THREE { */ getStyle(): string; - /** - * Sets this color from HSL values. - * Based on MochiKit implementation by Bob Ippolito. - * - * @param h Hue channel value between 0 and 1. - * @param s Saturation value channel between 0 and 1. - * @param l Value channel value between 0 and 1. - */ - setHSL(h: number, s: number, l: number): Color; - - getHSL(): HSL; - offsetHSL(h: number, s: number, l: number): Color; add(color: Color): Color; @@ -2570,6 +2552,8 @@ declare module THREE { multiplyScalar(s: number): Color; lerp(color: Color, alpha: number): Color; equals(color: Color): boolean; + fromArray(rgb: number[]): Color; + toArray(): number[]; /** * Clones this color. @@ -2737,12 +2721,14 @@ declare module THREE { set(x: number, y: number, z: number, order?: string): Euler; copy(euler: Euler): Euler; - setFromRotationMatrix(m: Matrix4, order: string): Euler; - setFromQuaternion(q:Quaternion, order: string): Euler; + setFromRotationMatrix(m: Matrix4, order?: string): Euler; + setFromQuaternion(q:Quaternion, order?: string, update?: boolean): Euler; reorder(newOrder: string): Euler; + equals(euler: Euler): boolean; fromArray(xyzo: any[]): Euler; toArray(): any[]; - equals(euler: Euler): boolean; + onChange: () => void; + clone(): Euler; } @@ -2757,13 +2743,15 @@ declare module THREE { */ planes: Plane[]; - setFromMatrix(m: Matrix4): Frustum; - intersectsObject(object: Object3D): boolean; - clone(): Frustum; set(p0?: number, p1?: number, p2?: number, p3?: number, p4?: number, p5?: number): Frustum; copy(frustum: Frustum): Frustum; - containsPoint(point: Vector3): boolean; + setFromMatrix(m: Matrix4): Frustum; + intersectsObject(object: Object3D): boolean; intersectsSphere(sphere: Sphere): boolean; + intersectsBox(box: Box3): boolean; + containsPoint(point: Vector3): boolean; + clone(): Frustum; + } export class Line3 { @@ -2773,19 +2761,21 @@ declare module THREE { set(start?: Vector3, end?: Vector3): Line3; copy(line: Line3): Line3; - clone(): Line3; - equals(line: Line3): boolean; - distance(): number; - distanceSq(): number; - applyMatrix4(matrix: Matrix4): Line3; - at(t: number, optionalTarget?: Vector3): Vector3; center(optionalTarget?: Vector3): Vector3; delta(optionalTarget?: Vector3): Vector3; - closestPointToPoint(point: Vector3, clampToLine?: boolean, optionalTarget?: Vector3): Vector3; + distanceSq(): number; + distance(): number; + at(t: number, optionalTarget?: Vector3): Vector3; closestPointToPointParameter(point: Vector3, clampToLine?: boolean): number; + closestPointToPoint(point: Vector3, clampToLine?: boolean, optionalTarget?: Vector3): Vector3; + applyMatrix4(matrix: Matrix4): Line3; + equals(line: Line3): boolean; + clone(): Line3; } interface Math { + generateUUID(): string; + /** * Clamps the x to be between a and b. * @@ -2814,6 +2804,10 @@ declare module THREE { */ mapLinear(x: number, a1: number, a2: number, b1: number, b2: number): number; + smoothstep(x: number, min: number, max: number): number; + + smootherstep(x: number, min: number, max: number): number; + /** * Random float from 0 to 1 with 16 bits of randomness. * Standard Math.random() creates repetitive patterns when applied over larger space. @@ -2844,9 +2838,7 @@ declare module THREE { radToDeg(radians: number): number; - smoothstep(x: number, min: number, max: number): number; - - smootherstep(x: number, min: number, max: number): number; + isPowerOfTwo(value: number): boolean; } /** @@ -2874,8 +2866,6 @@ declare module THREE { */ copy(m: Matrix): Matrix; - multiplyVector3Array(a: number[]): number[]; - /** * multiplyScalar(s:number):T; */ @@ -2918,29 +2908,29 @@ declare module THREE { */ elements: Float32Array; + set(n11: number, n12: number, n13: number, n21: number, n22: number, n23: number, n31: number, n32: number, n33: number): Matrix3; + identity(): Matrix3; + copy(m: Matrix3): Matrix3; + applyToVector3Array(array: number[], offset?: number, length?: number): number[]; + multiplyScalar(s: number): Matrix3; + determinant(): number; + getInverse(matrix: Matrix3, throwOnInvertible?: boolean): Matrix3; + getInverse(matrix: Matrix4, throwOnInvertible?: boolean): Matrix3; + /** * Transposes this matrix in place. */ transpose(): Matrix3; + flattenToArrayOffset(array: number[], offset: number): number[]; + getNormalMatrix(m: Matrix4): Matrix3; /** * Transposes this matrix into the supplied array r, and returns itself. */ transposeIntoArray(r: number[]): number[]; - - determinant(): number; - set(n11: number, n12: number, n13: number, n21: number, n22: number, n23: number, n31: number, n32: number, n33: number): Matrix3; - multiplyScalar(s: number): Matrix3; - // DEPRECATED - multiplyVector3Array(a: number[]): number[]; - applyToVector3Array(array: number[], offset?: number, length?: number): number[]; - flattenToArrayOffset(array: number[], offset: number): number[]; - getNormalMatrix(m: Matrix4): Matrix3; - getInverse(matrix: Matrix3, throwOnInvertible?: boolean): Matrix3; - getInverse(matrix: Matrix4, throwOnInvertible?: boolean): Matrix3; - copy(m: Matrix3): Matrix3; + fromArray(array: number[]): Matrix3; + toArray(): number[]; clone(): Matrix3; - identity(): Matrix3; } /** @@ -2992,7 +2982,8 @@ declare module THREE { * Copies the rotation component of the supplied matrix m into this matrix rotation component. */ extractRotation(m: Matrix4): Matrix4; - + makeRotationFromEuler(euler: Euler): Matrix4; + makeRotationFromQuaternion(q: Quaternion): Matrix4; /** * Constructs a rotation matrix, looking from eye towards center with defined up vector. */ @@ -3018,6 +3009,7 @@ declare module THREE { * Multiplies this matrix by s. */ multiplyScalar(s: number): Matrix4; + applyToVector3Array(array: number[], offset?: number, length?: number): number[]; /** * Computes determinant of this matrix. @@ -3046,25 +3038,12 @@ declare module THREE { */ getInverse(m: Matrix4, throwOnInvertible?: boolean): Matrix4; - makeRotationFromEuler(euler: Euler): Matrix4; - makeRotationFromQuaternion(q: Quaternion): Matrix4; - /** * Multiplies the columns of this matrix by vector v. */ scale(v: Vector3): Matrix4; - /** - * Sets this matrix to the transformation composed of translation, rotation and scale. - */ - compose(translation: Vector3, rotation: Quaternion, scale: Vector3): Matrix4; - - /** - * Decomposes this matrix into the translation, rotation and scale components. - * If parameters are not passed, new instances will be created. - */ - decompose(translation?: Vector3, rotation?: Quaternion, scale?: Vector3): Object[]; // [Vector3, Quaternion, Vector3] - + getMaxScaleOnAxis(): number; /** * Sets this matrix as translation transform. */ @@ -3105,6 +3084,17 @@ declare module THREE { */ makeScale(x: number, y: number, z: number): Matrix4; + /** + * Sets this matrix to the transformation composed of translation, rotation and scale. + */ + compose(translation: Vector3, rotation: Quaternion, scale: Vector3): Matrix4; + + /** + * Decomposes this matrix into the translation, rotation and scale components. + * If parameters are not passed, new instances will be created. + */ + decompose(translation?: Vector3, rotation?: Quaternion, scale?: Vector3): Object[]; // [Vector3, Quaternion, Vector3] + /** * Creates a frustum matrix. */ @@ -3119,17 +3109,12 @@ declare module THREE { * Creates an orthographic projection matrix. */ makeOrthographic(left: number, right: number, top: number, bottom: number, near: number, far: number): Matrix4; - + fromArray(array: number[]): Matrix4; + toArray(): number[]; /** * Clones this matrix. */ clone(): Matrix4; - - // DEPRECATED - multiplyVector3Array(a: number[]): number[]; - applyToVector3Array(array: number[], offset?: number, length?: number): number[]; - - getMaxScaleOnAxis(): number; } export class Plane { @@ -3138,24 +3123,24 @@ declare module THREE { normal: Vector3; constant: number; - normalize(): Plane; set(normal: Vector3, constant: number): Plane; + setComponents(x: number, y: number, z: number, w: number): Plane; + setFromNormalAndCoplanarPoint(normal: Vector3, point: Vector3): Plane; + setFromCoplanarPoints(a: Vector3, b: Vector3, c: Vector3): Plane; copy(plane: Plane): Plane; - applyMatrix4(matrix: Matrix4, optionalNormalMatrix?: Matrix3): Plane; + normalize(): Plane; + negate(): Plane; + distanceToPoint(point: Vector3): number; + distanceToSphere(sphere: Sphere): number; + projectPoint(point: Vector3, optionalTarget?: Vector3): Vector3; orthoPoint(point: Vector3, optionalTarget?: Vector3): Vector3; isIntersectionLine(line: Line3): boolean; intersectLine(line: Line3, optionalTarget?: Vector3): Vector3; - setFromNormalAndCoplanarPoint(normal: Vector3, point: Vector3): Plane; - clone(): Plane; - distanceToPoint(point: Vector3): number; - equals(plane: Plane): boolean; - setComponents(x: number, y: number, z: number, w: number): Plane; - distanceToSphere(sphere: Sphere): number; - setFromCoplanarPoints(a: Vector3, b: Vector3, c: Vector3): Plane; - projectPoint(point: Vector3, optionalTarget?: Vector3): Vector3; - negate(): Plane; - translate(offset: Vector3): Plane; coplanarPoint(optionalTarget?: boolean): Vector3; + applyMatrix4(matrix: Matrix4, optionalNormalMatrix?: Matrix3): Plane; + translate(offset: Vector3): Plane; + equals(plane: Plane): boolean; + clone(): Plane; } /** @@ -3207,11 +3192,16 @@ declare module THREE { * Sets this quaternion from rotation component of m. Adapted from http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm. */ setFromRotationMatrix(m: Matrix4): Quaternion; - + setFromUnitVectors(vFrom: Vector3, vTo: Vector4): Quaternion; /** * Inverts this quaternion. */ inverse(): Quaternion; + + conjugate(): Quaternion; + dot(v: Vector3): number; + lengthSq(): number; + /** * Computes length of this quaternion. */ @@ -3237,6 +3227,11 @@ declare module THREE { * Deprecated. Use Vector3.applyQuaternion instead */ multiplyVector3(vector: Vector3): Vector3; + slerp(qb: Quaternion, t: number): Quaternion; + equals(v: Quaternion): boolean; + fromArray(n: number[]): Quaternion; + toArray(): number[]; + onChange: () => void; /** * Clones this quaternion. @@ -3247,20 +3242,6 @@ declare module THREE { * Adapted from http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/slerp/. */ static slerp(qa: Quaternion, qb: Quaternion, qm: Quaternion, t: number): Quaternion; - - slerp(qb: Quaternion, t: number): Quaternion; - - toArray(): number[]; - - equals(v: Quaternion): boolean; - - dot(v: Vector3): number; - - lengthSq(): number; - - fromArray(n: number[]): Quaternion; - - conjugate(): Quaternion; } export class Ray { @@ -3269,25 +3250,24 @@ declare module THREE { origin: Vector3; direction: Vector3; - applyMatrix4(matrix4: Matrix4): Ray; - at(t: number, optionalTarget?: Vector3): Vector3; - clone(): Ray; - closestPointToPoint(point: Vector3, optionalTarget?: Vector3): Vector3; - copy(ray: Ray): Ray; - distanceSqToSegment(v0: Vector3, v1: Vector3, optionalPointOnRay?: Vector3, optionalPointOnSegment?: Vector3): number; - distanceToPlane(plane: Plane): number; - distanceToPoint(point: Vector3): number; - equals(ray: Ray): boolean; - intersectBox(box: Box3, optionalTarget?: Vector3): Vector3; - intersectPlane(plane: Plane, optionalTarget?: Vector3): Vector3; - intersectSphere(sphere: Sphere, optionalTarget?: Vector3): Vector3; - intersectTriangle(a: Vector3, b: Vector3, c: Vector3, backfaceCulling: boolean, optionalTarget?: Vector3): Vector3; - isIntersectionBox(box: Box3): boolean; - isIntersectionPlane(plane: Plane): boolean; - isIntersectionSphere(sphere: Sphere): boolean; - - recast(t: number): Ray; set(origin: Vector3, direction: Vector3): Ray; + copy(ray: Ray): Ray; + at(t: number, optionalTarget?: Vector3): Vector3; + recast(t: number): Ray; + closestPointToPoint(point: Vector3, optionalTarget?: Vector3): Vector3; + distanceToPoint(point: Vector3): number; + distanceSqToSegment(v0: Vector3, v1: Vector3, optionalPointOnRay?: Vector3, optionalPointOnSegment?: Vector3): number; + isIntersectionSphere(sphere: Sphere): boolean; + intersectSphere(sphere: Sphere, optionalTarget?: Vector3): Vector3; + isIntersectionPlane(plane: Plane): boolean; + distanceToPlane(plane: Plane): number; + intersectPlane(plane: Plane, optionalTarget?: Vector3): Vector3; + isIntersectionBox(box: Box3): boolean; + intersectBox(box: Box3, optionalTarget?: Vector3): Vector3; + intersectTriangle(a: Vector3, b: Vector3, c: Vector3, backfaceCulling: boolean, optionalTarget?: Vector3): Vector3; + applyMatrix4(matrix4: Matrix4): Ray; + equals(ray: Ray): boolean; + clone(): Ray; } export class Sphere { @@ -3297,18 +3277,19 @@ declare module THREE { radius: number; set(center: Vector3, radius: number): Sphere; - applyMatrix4(matrix: Matrix4): Sphere; - clampPoint(point: Vector3, optionalTarget?: Vector3): Vector3; - translate(offset: Vector3): Sphere; - clone(): Sphere; - equals(sphere: Sphere): boolean; setFromPoints(points: Vector3[], optionalCenter?: Vector3): Sphere; - distanceToPoint(point: Vector3): number; - getBoundingBox(optionalTarget?: Box3): Box3; - containsPoint(point: Vector3): boolean; copy(sphere: Sphere): Sphere; - intersectsSphere(sphere: Sphere): boolean; empty(): boolean; + containsPoint(point: Vector3): boolean; + distanceToPoint(point: Vector3): number; + intersectsSphere(sphere: Sphere): boolean; + clampPoint(point: Vector3, optionalTarget?: Vector3): Vector3; + getBoundingBox(optionalTarget?: Box3): Box3; + applyMatrix4(matrix: Matrix4): Sphere; + translate(offset: Vector3): Sphere; + equals(sphere: Sphere): boolean; + + clone(): Sphere; } export interface SplineControlPoint { @@ -3371,17 +3352,17 @@ declare module THREE { b: Vector3; c: Vector3; - setFromPointsAndIndices(points: Vector3[], i0: number, i1: number, i2: number): Triangle; set(a: Vector3, b: Vector3, c: Vector3): Triangle; - normal(optionalTarget?: Vector3): Vector3; - barycoordFromPoint(point: Vector3, optionalTarget?: Vector3): Vector3; - clone(): Triangle; + setFromPointsAndIndices(points: Vector3[], i0: number, i1: number, i2: number): Triangle; + copy(triangle: Triangle): Triangle; area(): number; midpoint(optionalTarget?: Vector3): Vector3; - equals(triangle: Triangle): boolean; + normal(optionalTarget?: Vector3): Vector3; plane(optionalTarget?: Vector3): Plane; + barycoordFromPoint(point: Vector3, optionalTarget?: Vector3): Vector3; containsPoint(point: Vector3): boolean; - copy(triangle: Triangle): Triangle; + equals(triangle: Triangle): boolean; + clone(): Triangle; static normal(a: Vector3, b: Vector3, c: Vector3, optionalTarget?: Vector3): Vector3; static barycoordFromPoint(point: Vector3, a: Vector3, b: Vector3, c: Vector3, optionalTarget: Vector3): Vector3; @@ -3516,6 +3497,26 @@ declare module THREE { */ set(x: number, y: number): Vector2; + /** + * Sets X component of this vector. + */ + setX(x: number): Vector2; + + /** + * Sets Y component of this vector. + */ + setY(y: number): Vector2; + + /** + * Sets a component of this vector. + */ + setComponent(index: number, value: number): void; + + /** + * Gets a component of this vector. + */ + getComponent(index: number): number; + /** * Copies value of v to this vector. */ @@ -3530,6 +3531,7 @@ declare module THREE { * Sets this vector to a + b. */ addVectors(a: Vector2, b: Vector2): Vector2; + addScalar(s: number): Vector2; /** * Subtracts v from this vector. @@ -3541,24 +3543,34 @@ declare module THREE { */ subVectors(a: Vector2, b: Vector2): Vector2; + multiply(v: Vector2): Vector2; /** * Multiplies this vector by scalar s. */ multiplyScalar(s: number): Vector2; + divide(v: Vector2): Vector2; /** * Divides this vector by scalar s. * Set vector to ( 0, 0 ) if s == 0. */ divideScalar(s: number): Vector2; + min(v: Vector2): Vector2; + + max(v: Vector2): Vector2; + clamp(min: Vector2, max: Vector2): Vector2; + clampScalar(min: number, max: number): Vector2; + floor(): Vector2; + ceil(): Vector2; + round(): Vector2; + roundToZero(): Vector2; + /** * Inverts this vector. */ negate(): Vector2; - - /** * Computes dot product of this vector and v. */ @@ -3594,53 +3606,18 @@ declare module THREE { */ setLength(l: number): Vector2; + lerp(v: Vector2, alpha: number): Vector2; /** * Checks for strict equality of this vector and v. */ equals(v: Vector2): boolean; + fromArray(xy: number[]): Vector2; + toArray(): number[]; /** * Clones this vector. */ clone(): Vector2; - - clamp(min: Vector2, max: Vector2): Vector2; - clampScalar(min: number, max: number): Vector2; - floor(): Vector2; - ceil(): Vector2; - round(): Vector2; - roundToZero(): Vector2; - lerp(v: Vector2, alpha: number): Vector2; - - /** - * Sets a component of this vector. - */ - setComponent(index: number, value: number): void; - - addScalar(s: number): Vector2; - - /** - * Gets a component of this vector. - */ - getComponent(index: number): number; - - fromArray(xy: number[]): Vector2; - - toArray(): number[]; - - min(v: Vector2): Vector2; - - max(v: Vector2): Vector2; - - /** - * Sets X component of this vector. - */ - setX(x: number): Vector2; - - /** - * Sets Y component of this vector. - */ - setY(y: number): Vector2; } /** @@ -3684,6 +3661,9 @@ declare module THREE { */ setZ(z: number): Vector3; + setComponent(index: number, value: number): void; + getComponent(index: number): number; + /** * Copies value of v to this vector. */ @@ -3693,6 +3673,7 @@ declare module THREE { * Adds v to this vector. */ add(a: Object): Vector3; + addScalar(s: number): Vector3; /** * Sets this vector to a + b. @@ -3709,16 +3690,34 @@ declare module THREE { */ subVectors(a: Vector3, b: Vector3): Vector3; + multiply(v: Vector3): Vector3; /** * Multiplies this vector by scalar s. */ multiplyScalar(s: number): Vector3; + multiplyVectors(a: Vector3, b: Vector3): Vector3; + applyEuler(euler: Euler): Vector3; + applyAxisAngle(axis: Vector3, angle: number): Vector3; + applyMatrix3(m: Matrix3): Vector3; + applyMatrix4(m: Matrix4): Vector3; + applyProjection(m: Matrix4): Vector3; + applyQuaternion(q: Quaternion): Vector3; + transformDirection(m: Matrix4): Vector3; + divide(v: Vector3): Vector3; /** * Divides this vector by scalar s. * Set vector to ( 0, 0, 0 ) if s == 0. */ divideScalar(s: number): Vector3; + min(v: Vector3): Vector3; + max(v: Vector3): Vector3; + clamp(min: Vector3, max: Vector3): Vector3; + clampScalar(min: number, max: number): Vector3; + floor(): Vector3; + ceil(): Vector3; + round(): Vector3; + roundToZero(): Vector3; /** * Inverts this vector. @@ -3751,20 +3750,11 @@ declare module THREE { */ normalize(): Vector3; - /** - * Computes distance of this vector to v. - */ - distanceTo(v: Vector3): number; - - /** - * Computes squared distance of this vector to v. - */ - distanceToSquared(v: Vector3): number; - /** * Normalizes this vector and multiplies it by l. */ setLength(l: number): Vector3; + lerp(v: Vector3, alpha: number): Vector3; /** * Sets this vector to cross product of itself and v. @@ -3775,46 +3765,36 @@ declare module THREE { * Sets this vector to cross product of a and b. */ crossVectors(a: Vector3, b: Vector3): Vector3; + projectOnVector(v: Vector3): Vector3; + projectOnPlane(planeNormal: Vector3): Vector3; + reflect(vector: Vector3): Vector3; + angleTo(v: Vector3): number; + + /** + * Computes distance of this vector to v. + */ + distanceTo(v: Vector3): number; + + /** + * Computes squared distance of this vector to v. + */ + distanceToSquared(v: Vector3): number; setFromMatrixPosition(m: Matrix4): Vector3; setFromMatrixScale(m: Matrix4): Vector3; + setFromMatrixColumn(index: number, matrix: Matrix4): Vector3; + /** * Checks for strict equality of this vector and v. */ equals(v: Vector3): boolean; + fromArray(xyz: number[]): Vector3; + toArray(): number[]; + /** * Clones this vector. */ clone(): Vector3; - clamp(min: Vector3, max: Vector3): Vector3; - clampScalar(min: number, max: number): Vector3; - floor(): Vector3; - ceil(): Vector3; - round(): Vector3; - roundToZero(): Vector3; - applyMatrix3(m: Matrix3): Vector3; - applyMatrix4(m: Matrix4): Vector3; - projectOnPlane(planeNormal: Vector3): Vector3; - projectOnVector(v: Vector3): Vector3; - addScalar(s: number): Vector3; - divide(v: Vector3): Vector3; - min(v: Vector3): Vector3; - max(v: Vector3): Vector3; - setComponent(index: number, value: number): void; - transformDirection(m: Matrix4): Vector3; - multiplyVectors(a: Vector3, b: Vector3): Vector3; - getComponent(index: number): number; - applyAxisAngle(axis: Vector3, angle: number): Vector3; - lerp(v: Vector3, alpha: number): Vector3; - angleTo(v: Vector3): number; - setFromMatrixColumn(index: number, matrix: Matrix4): Vector3; - reflect(vector: Vector3): Vector3; - fromArray(xyz: number[]): Vector3; - multiply(v: Vector3): Vector3; - applyProjection(m: Matrix4): Vector3; - toArray(): number[]; - applyEuler(euler: Euler): Vector3; - applyQuaternion(q: Quaternion): Vector3; } /** @@ -3833,6 +3813,30 @@ declare module THREE { * Sets value of this vector. */ set(x: number, y: number, z: number, w: number): Vector4; + + /** + * Sets X component of this vector. + */ + setX(x: number): Vector4; + + /** + * Sets Y component of this vector. + */ + setY(y: number): Vector4; + + /** + * Sets Z component of this vector. + */ + setZ(z: number): Vector4; + + /** + * Sets w component of this vector. + */ + setW(w: number): Vector4; + + setComponent(index: number, value: number): void; + getComponent(index: number): number; + /** * Copies value of v to this vector. */ @@ -3842,6 +3846,7 @@ declare module THREE { * Adds v to this vector. */ add(v: Vector4): Vector4; + addScalar(s: number): Vector4; /** * Sets this vector to a + b. @@ -3862,12 +3867,35 @@ declare module THREE { * Multiplies this vector by scalar s. */ multiplyScalar(s: number): Vector4; + applyMatrix4(m: Matrix4): Vector4; /** * Divides this vector by scalar s. * Set vector to ( 0, 0, 0 ) if s == 0. */ divideScalar(s: number): Vector4; + + /** + * http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToAngle/index.htm + * @param q is assumed to be normalized + */ + setAxisAngleFromQuaternion(q: Quaternion): Vector4; + + /** + * http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToAngle/index.htm + * @param m assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled) + */ + setAxisAngleFromRotationMatrix(m: Matrix3): Vector4; + + min(v: Vector4): Vector4; + max(v: Vector4): Vector4; + clamp(min: Vector4, max: Vector4): Vector4; + clampScalar(min: number, max: number): Vector4; + floor(): Vector4; + ceil(): Vector4; + round(): Vector4; + roundToZero(): Vector4; + /** * Inverts this vector. */ @@ -3887,6 +3915,7 @@ declare module THREE { * Computes length of this vector. */ length(): number; + lengthManhattan(): number; /** * Normalizes this vector. @@ -3901,62 +3930,19 @@ declare module THREE { * Linearly interpolate between this vector and v with alpha factor. */ lerp(v: Vector4, alpha: number): Vector4; - /** - * Clones this vector. - */ - clone(): Vector4; - clamp(min: Vector4, max: Vector4): Vector4; - clampScalar(min: number, max: number): Vector4; - floor(): Vector4; - ceil(): Vector4; - round(): Vector4; - roundToZero(): Vector4; - applyMatrix4(m: Matrix4): Vector4; - min(v: Vector4): Vector4; - max(v: Vector4): Vector4; - addScalar(s: number): Vector4; /** * Checks for strict equality of this vector and v. */ equals(v: Vector4): boolean; - /** - * http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToAngle/index.htm - * @param m assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled) - */ - setAxisAngleFromRotationMatrix(m: Matrix3): Vector4; - - /** - * http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToAngle/index.htm - * @param q is assumed to be normalized - */ - setAxisAngleFromQuaternion(q: Quaternion): Vector4; - - getComponent(index: number): number; - setComponent(index: number, value: number): void; fromArray(xyzw: number[]): number[]; toArray(): number[]; - lengthManhattan(): number; - /** - * Sets X component of this vector. - */ - setX(x: number): Vector4; /** - * Sets Y component of this vector. + * Clones this vector. */ - setY(y: number): Vector4; - - /** - * Sets Z component of this vector. - */ - setZ(z: number): Vector4; - - /** - * Sets w component of this vector. - */ - setW(w: number): Vector4; + clone(): Vector4; } // Objects ////////////////////////////////////////////////////////////////////////////////// @@ -3970,7 +3956,7 @@ declare module THREE { accumulatedPosWeight: number; accumulatedSclWeight: number; - update(forceUpdate?: boolean): void; + updateMatrixWorld(forceUpdate?: boolean): void; } export class Line extends Object3D { @@ -3980,6 +3966,7 @@ declare module THREE { constructor(geometry?: BufferGeometry, material?: LineDashedMaterial, type?: number); constructor(geometry?: BufferGeometry, material?: LineBasicMaterial, type?: number); constructor(geometry?: BufferGeometry, material?: ShaderMaterial, type?: number); + geometry: Geometry; material: LineBasicMaterial; type: LineType; @@ -3996,11 +3983,12 @@ declare module THREE { constructor(); objects: any[]; + addLevel(object: Object3D, distance?: number): void; getObjectForDistance(distance: number): Object3D; raycast(raycaster: Raycaster, intersects: any): void; update(camera: Camera): void; - clone(): LOD; + clone(object?: LOD): LOD; } export class Mesh extends Object3D { @@ -4010,8 +3998,8 @@ declare module THREE { geometry: Geometry; material: Material; - getMorphTargetIndexByName(name: string): number; updateMorphTargets(): void; + getMorphTargetIndexByName(name: string): number; raycast(raycaster: Raycaster, intersects: any): void; clone(object?: Mesh): Mesh; } @@ -4025,24 +4013,25 @@ declare module THREE { constructor(geometry?: Geometry, material?: MeshPhongMaterial); constructor(geometry?: Geometry, material?: ShaderMaterial); - directionBackwards: boolean; - direction: number; - endKeyframe: number; - mirroredLoop: boolean; - startKeyframe: number; - lastKeyframe: number; - length: number; - time: number; duration: number; // milliseconds + mirroredLoop: boolean; + time: number; + lastKeyframe: number; currentKeyframe: number; + direction: number; + directionBackwards: boolean; + + startKeyframe: number; + endKeyframe: number; + length: number; - setDirectionForward(): void; - playAnimation(label: string, fps: number): void; setFrameRange(start: number, end: number): void; + setDirectionForward(): void; setDirectionBackward(): void; parseAnimations(): void; - updateAnimation(delta: number): void; setAnimationLabel(label: string, start: number, end: number): void; + playAnimation(label: string, fps: number): void; + updateAnimation(delta: number): void; interpolateTargets( a: number, b: number, t: number ): void; clone(object?: MorphAnimMesh): MorphAnimMesh; } @@ -4072,7 +4061,6 @@ declare module THREE { * An instance of Material, defining the object's appearance. Default is a ParticleBasicMaterial with randomised colour. */ material: Material; - sortParticles: boolean; raycast(raycaster: Raycaster, intersects: any): void; @@ -4081,9 +4069,15 @@ declare module THREE { export class Skeleton { constructor(bones: Bone[], boneInverses?: Matrix4[], useVertexTexture?: boolean); - bones: Bone[]; + useVertexTexture: boolean; + identityMatrix: Matrix4; + bones: Bone[]; + boneTextureWidth: number; + boneTextureHeight: number; boneMatrices: Float32Array; + boneTexture: DataTexture; + boneInverses: Matrix4[]; calculateInverses(bone: Bone): void; pose(): void; @@ -4128,8 +4122,8 @@ declare module THREE { export interface Renderer { render(scene: Scene, camera: Camera): void; - setSize(width:number, height:number, updateStyle?:boolean): void; - domElement: HTMLCanvasElement; + setSize(width:number, height:number, updateStyle?:boolean): void; + domElement: HTMLCanvasElement; } export interface CanvasRendererParameters { @@ -4140,26 +4134,31 @@ declare module THREE { export class CanvasRenderer implements Renderer { constructor(parameters?: CanvasRendererParameters); - info: { render: { vertices: number; faces: number; }; }; domElement: HTMLCanvasElement; devicePixelRatio: number; autoClear: boolean; sortObjects: boolean; sortElements: boolean; + info: { render: { vertices: number; faces: number; }; }; - getMaxAnisotropy(): number; - render(scene: Scene, camera: Camera): void; - clear(): void; + supportsVertexTextures(): void; + setFaceCulling(): void; + setSize(width: number, height: number, updateStyle?: boolean): void; + setViewport(x: number, y: number, width: number, height: number): void; + setScissor(): void; + enableScissorTest(): void; setClearColor(color: Color, opacity?: number): void; setClearColor(color: string, opacity?: number): void; setClearColor(color: number, opacity?: number): void; - setFaceCulling(): void; - supportsVertexTextures(): void; - setSize(width: number, height: number, updateStyle?: boolean): void; setClearColorHex(hex: number, alpha?: number): void; getClearColor(): Color; getClearAlpha(): number; - setViewport(x: number, y: number, width: number, height: number): void; + getMaxAnisotropy(): number; + clear(): void; + clearColor(): void; + clearDepth(): void; + clearStencil(): void; + render(scene: Scene, camera: Camera): void; } export interface RendererPlugin { @@ -4242,6 +4241,8 @@ declare module THREE { //context:WebGLRenderingContext; context: any; + devicePixelRatio: number; + /** * Defines whether the renderer should automatically clear its output before rendering. */ @@ -4353,7 +4354,6 @@ declare module THREE { }; shadowMapPlugin: ShadowMapPlugin; - devicePixelRatio: number; /** * Return the WebGL context. @@ -4367,6 +4367,8 @@ declare module THREE { supportsFloatTextures(): boolean; supportsStandardDerivatives(): boolean; supportsCompressedTextureS3TC(): boolean; + getMaxAnisotropy(): number; + getPrecision(): string; /** * Resizes the output canvas to (width, height), and also sets the viewport to fit that size, starting in (0, 0). @@ -4395,6 +4397,17 @@ declare module THREE { setClearColor(color: string, alpha?: number): void; setClearColor(color: number, alpha?: number): void; + /** + * Sets the clear color, using hex for the color and alpha for the opacity. + * + * @example + * // Creates a renderer with black background + * var renderer = new THREE.WebGLRenderer(); + * renderer.setSize(200, 100); + * renderer.setClearColorHex(0x000000, 1); + */ + setClearColorHex(hex: number, alpha: number): void; + /** * Returns a THREE.Color instance with the current clear color. */ @@ -4414,6 +4427,7 @@ declare module THREE { clearColor(): void; clearDepth(): void; clearStencil(): void; + clearTarget(renderTarget:WebGLRenderTarget, color: boolean, depth: boolean, stencil: boolean): void; /** * Initialises the postprocessing plugin, and adds it to the renderPluginsPost array. @@ -4455,26 +4469,12 @@ declare module THREE { * @param frontFace "ccw" or "cw */ setFaceCulling(cullFace?: CullFace, frontFace?: FrontFaceDirection): void; + setMaterialFaces(material: Material): void; setDepthTest(depthTest: boolean): void; setDepthWrite(depthWrite: boolean): void; setBlending(blending: Blending, blendEquation: BlendingEquation, blendSrc: BlendingSrcFactor, blendDst: BlendingDstFactor): void; setTexture(texture: Texture, slot: number): void; setRenderTarget(renderTarget: RenderTarget): void; - getMaxAnisotropy(): number; - getPrecision(): string; - setMaterialFaces(material: Material): void; - clearTarget(renderTarget:WebGLRenderTarget, color: boolean, depth: boolean, stencil: boolean): void; - - /** - * Sets the clear color, using hex for the color and alpha for the opacity. - * - * @example - * // Creates a renderer with black background - * var renderer = new THREE.WebGLRenderer(); - * renderer.setSize(200, 100); - * renderer.setClearColorHex(0x000000, 1); - */ - setClearColorHex(hex: number, alpha: number): void; } export interface RenderTarget { @@ -4494,6 +4494,7 @@ declare module THREE { export class WebGLRenderTarget implements RenderTarget { constructor(width: number, height: number, options?: WebGLRenderTargetOptions); + width: number; height: number; wrapS: Wrapping; @@ -4508,6 +4509,8 @@ declare module THREE { depthBuffer: boolean; stencilBuffer: boolean; generateMipmaps: boolean; + shareDepthFrom: any; + clone(): WebGLRenderTarget; dispose(): void; @@ -4521,134 +4524,132 @@ declare module THREE { export class WebGLRenderTargetCube extends WebGLRenderTarget { constructor(width: number, height: number, options?: WebGLRenderTargetOptions); + activeCubeFace: number; // PX 0, NX 1, PY 2, NY 3, PZ 4, NZ 5 } // Renderers / Renderables ///////////////////////////////////////////////////////////////////// - export class RenderableFace { constructor(); - color: Color; - material: Material; - uvs: Vector2[][]; + id: number; v1: RenderableVertex; v2: RenderableVertex; v3: RenderableVertex; normalModel: Vector3; - vertexNormalsLength: number; - z: number; vertexNormalsModel: Vector3[]; + vertexNormalsLength: number; + color: Color; + material: Material; + uvs: Vector2[][]; + z: number; + } export class RenderableLine { constructor(); + id: number; v1: RenderableVertex; v2: RenderableVertex; - z: number; + vertexColors: Color[]; material: Material; + z: number; } export class RenderableObject { constructor(); + id: number; object: Object; z: number; - id: number; } export class RenderableSprite { constructor(); + id: number; + object: Object; + x: number; + y: number; + z: number; + rotation: number; scale: Vector2; material: Material; - object: Object; - y: number; - x: number; - rotation: number; - z: number; } export class RenderableVertex { constructor(); - visible: boolean; - positionScreen: Vector4; + position: Vector3; positionWorld: Vector3; + positionScreen: Vector4; + visible: boolean; copy(vertex: RenderableVertex): void; } - // Renderers / Shaders ///////////////////////////////////////////////////////////////////// // Renderers / Shaders ///////////////////////////////////////////////////////////////////// export interface ShaderChunk { [name: string]: string; - fog_pars_fragment: string; - fog_fragment: string; - envmap_pars_fragment: string; - envmap_fragment: string; - envmap_pars_vertex: string; - worldpos_vertex: string; - envmap_vertex: string; - map_particle_pars_fragment: string; - map_particle_fragment: string; - map_pars_vertex: string; - map_pars_fragment: string; - map_vertex: string; - map_fragment: string; - lightmap_pars_fragment: string; - lightmap_pars_vertex: string; - lightmap_fragment: string; - lightmap_vertex: string; + + alphamap_fragment: string; + alphamap_pars_fragment: string; + alphatest_fragment: string; bumpmap_pars_fragment: string; - normalmap_pars_fragment: string; - specularmap_pars_fragment: string; - specularmap_fragment: string; - lights_lambert_pars_vertex: string; - lights_lambert_vertex: string; - lights_phong_pars_vertex: string; - lights_phong_vertex: string; - lights_phong_pars_fragment: string; - lights_phong_fragment: string; - color_pars_fragment: string; color_fragment: string; + color_pars_fragment: string; color_pars_vertex: string; color_vertex: string; - skinning_pars_vertex: string; - skinbase_vertex: string; - skinning_vertex: string; + default_vertex: string; + defaultnormal_vertex: string; + envmap_fragment: string; + envmap_pars_fragment: string; + envmap_pars_vertex: string; + envmap_vertex: string; + fog_fragment: string; + fog_pars_fragment: string; + + lightmap_fragment: string; + lightmap_pars_fragment: string; + lightmap_pars_vertex: string; + lightmap_vertex: string; + lights_lambert_pars_vertex: string; + lights_lambert_vertex: string; + lights_phong_fragment: string; + lights_phong_pars_fragment: string; + lights_phong_pars_vertex: string; + lights_phong_vertex: string; + linear_to_gamma_fragment: string; + logdepthbuf_fragment: string; + logdepthbuf_pars_fragment: string; + logdepthbuf_pars_vertex: string; + logdepthbuf_vertex: string; + map_fragment: string; + map_pars_fragment: string; + map_pars_vertex: string; + map_particle_fragment: string; + map_particle_pars_fragment: string; + map_vertex: string; + morphnormal_vertex: string; morphtarget_pars_vertex: string; morphtarget_vertex: string; - default_vertex: string; - morphnormal_vertex: string; - skinnormal_vertex: string; - defaultnormal_vertex: string; - shadowmap_pars_fragment: string; + normalmap_pars_fragment: string; shadowmap_fragment: string; + shadowmap_pars_fragment: string; shadowmap_pars_vertex: string; shadowmap_vertex: string; - alphatest_fragment: string; - linear_to_gamma_fragment: string; + skinbase_vertex: string; + skinning_pars_vertex: string; + skinning_vertex: string; + skinnormal_vertex: string; + specularmap_fragment: string; + specularmap_pars_fragment: string; + worldpos_vertex: string; } export var ShaderChunk: ShaderChunk; - export var UniformsUtils: { - merge(uniforms: any[]): any; - clone(uniforms_src: any): any; - }; - - export var UniformsLib: { - common: any; - bump: any; - normalmap: any; - fog: any; - lights: any; - particle: any; - shadowmap: any; - }; - export interface Shader { uniforms: any; vertexShader: string; @@ -4661,15 +4662,28 @@ declare module THREE { lambert: Shader; phong: Shader; particle_basic: Shader; - depth: Shader; dashed: Shader; + depth: Shader; normal: Shader; normalmap: Shader; cube: Shader; depthRGBA: Shader; }; + export var UniformsLib: { + common: any; + bump: any; + normalmap: any; + fog: any; + lights: any; + particle: any; + shadowmap: any; + }; + export var UniformsUtils: { + merge(uniforms: any[]): any; + clone(uniforms_src: any): any; + }; // Renderers / WebGL ///////////////////////////////////////////////////////////////////// export class WebGLProgram{ @@ -4721,6 +4735,7 @@ declare module THREE { */ export class FogExp2 implements IFog { constructor(hex: number, density?: number); + name: string; color: Color; @@ -4748,13 +4763,12 @@ declare module THREE { * If not null, it will force everything in the scene to be rendered with that material. Default is null. */ overrideMaterial: Material; + autoUpdate: boolean; /** * Default is false. */ matrixAutoUpdate: boolean; - - autoUpdate: boolean; } // Textures ///////////////////////////////////////////////////////////////////// @@ -4771,7 +4785,11 @@ declare module THREE { magFilter?: TextureFilter, minFilter?: TextureFilter, anisotropy?: number - ); + ); + + image: { width: number; height: number; }; + mipmaps: ImageData[]; + generateMipmaps: boolean; clone(): CompressedTexture; } @@ -4787,7 +4805,7 @@ declare module THREE { format?: PixelFormat, type?: TextureDataType, anisotropy?: number - ); + ); images: any[]; @@ -4807,7 +4825,9 @@ declare module THREE { magFilter: TextureFilter, minFilter: TextureFilter, anisotropy?: number - ); + ); + + image: { data: ImageData; width: number; height: number; }; clone(): DataTexture; } @@ -4858,33 +4878,33 @@ declare module THREE { anisotropy?: number ); + id: number; + uuid: string; + name: string; image: any; // HTMLImageElement or ImageData ; + mipmaps: ImageData[]; mapping: Mapping; wrapS: Wrapping; wrapT: Wrapping; magFilter: TextureFilter; minFilter: TextureFilter; + anisotropy: number; format: PixelFormat; type: TextureDataType; - anisotropy: number; - needsUpdate: boolean; - repeat: Vector2; offset: Vector2; - name: string; + repeat: Vector2; generateMipmaps: boolean; - flipY: boolean; - mipmaps: ImageData[]; - unpackAlignment: number; premultiplyAlpha: boolean; + flipY: boolean; + unpackAlignment: number; + needsUpdate: boolean; onUpdate: () => void; - id: number; - - clone(): Texture; - dispose(): void; - static DEFAULT_IMAGE: any; static DEFAULT_MAPPING: any; + clone(): Texture; + update(): void; + dispose(): void; // EventDispatcher mixins addEventListener(type: string, listener: (event: any) => void ): void; @@ -4902,23 +4922,23 @@ declare module THREE { } export var FontUtils: { - - divisions: number; - style: string; - weight: string; - face: string; faces: { [weight: string]: { [style: string]: Face3; }; }; + face: string; + weight: string; + style: string; size: number; + divisions: number; + getFace(): Face3; + loadFace(data: TypefaceData): TypefaceData; drawText(text: string): { paths: Path[]; offset: number; }; + extractGlyphPoints(c: string, face: Face3, scale: number, offset: number, path: Path): { offset: number; path: Path; }; + + generateShapes(text: string, parameters?: { size?: number; curveSegments?: number; font?: string; weight?: string; style?: string; }): Shape[]; Triangulate: { (contour: Vector2[], indices: boolean): Vector2[]; area(contour: Vector2[]): number; }; - extractGlyphPoints(c: string, face: Face3, scale: number, offset: number, path: Path): { offset: number; path: Path; }; - generateShapes(text: string, parameters?: { size?: number; curveSegments?: number; font?: string; weight?: string; style?: string; }): Shape[]; - loadFace(data: TypefaceData): TypefaceData; - getFace(): Face3; }; export var GeometryUtils: { @@ -4935,16 +4955,16 @@ declare module THREE { export var ImageUtils: { crossOrigin: string; - generateDataTexture(width: number, height: number, color: Color): DataTexture; loadTexture(url: string, mapping?: Mapping, onLoad?: (texture: Texture) => void, onError?: (message: string) => void): Texture; - loadTextureCube(array: string[], mapping?: Mapping, onLoad?: () => void , onError?: (message: string) => void ): Texture; + loadTextureCube(array: string[], mapping?: Mapping, onLoad?: (texture: Texture) => void , onError?: (message: string) => void ): Texture; getNormalMap(image: HTMLImageElement, depth?: number): HTMLCanvasElement; + generateDataTexture(width: number, height: number, color: Color): DataTexture; }; export var SceneUtils: { createMultiMaterialObject(geometry: Geometry, materials: Material[]): Object3D; - attach(child: Object3D, scene: Scene, parent: Object3D): void; detach(child: Object3D, parent: Object3D, scene: Scene): void; + attach(child: Object3D, scene: Scene, parent: Object3D): void; }; // Extras / Animation ///////////////////////////////////////////////////////////////////// @@ -4981,6 +5001,7 @@ declare module THREE { loop: boolean; weight: number; keyTypes: string[]; + interpolationType: number; play(startTime?: number, weight?: number): void; stop(): void; @@ -5004,21 +5025,6 @@ declare module THREE { update(deltaTimeMS: number): void; }; - export class MorphAnimation { - constructor(mesh: Mesh); - - mesh: Mesh; - frames: number; - currentTime: number; - duration: number; - loop: boolean; - isPlaying: boolean; - - play(): void; - pause(): void; - update(deltaTimeMS: number): void; - } - export class KeyFrameAnimation { constructor(data: any); @@ -5038,102 +5044,20 @@ declare module THREE { getPrevKeyWith(type: string, h: number, key: number): KeyFrame; } - // Extras / Curves ///////////////////////////////////////////////////////////////////// - export class ArcCurve extends EllipseCurve { - constructor(aX: number, aY: number, aRadius: number, aStartAngle: number, aEndAngle: number, aClockwise: boolean ); + export class MorphAnimation { + constructor(mesh: Mesh); + + mesh: Mesh; + frames: number; + currentTime: number; + duration: number; + loop: boolean; + isPlaying: boolean; + + play(): void; + pause(): void; + update(deltaTimeMS: number): void; } - export class ClosedSplineCurve3 extends Curve { - constructor( points:Vector3[] ); - - points:Vector3[]; - - getPoint(t: number): Vector3; - } - export class CubicBezierCurve extends Curve { - constructor( v0: Vector2, v1: Vector2, v2: Vector2, v3: Vector2 ); - - v0: Vector2; - v1: Vector2; - v2: Vector2; - v3: Vector2; - - getPoint(t: number): Vector2; - } - export class CubicBezierCurve3 extends Curve { - constructor( v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3 ); - - v0: Vector3; - v1: Vector3; - v2: Vector3; - v3: Vector3; - - getPoint(t: number): Vector3; - } - export class EllipseCurve extends Curve { - constructor( aX: number, aY: number, xRadius: number, yRadius: number, aStartAngle: number, aEndAngle: number, aClockwise: boolean ); - - aX: number; - aY: number; - xRadius: number; - yRadius: number; - aStartAngle: number; - aEndAngle: number; - aClockwise: boolean; - - getPoint(t: number): Vector2; - } - export class LineCurve extends Curve { - constructor( v1: Vector2, v2: Vector2 ); - - v1: Vector2; - v2: Vector2; - - getPoint(t: number): Vector2; - getPointAt(u: number): Vector2; - getTangent(t: number): Vector2; - } - export class LineCurve3 extends Curve { - constructor( v1: Vector3, v2: Vector3 ); - - v1: Vector3; - v2: Vector3; - - getPoint(t: number): Vector3; - } - export class QuadraticBezierCurve extends Curve { - constructor( v0: Vector2, v1: Vector2, v2: Vector2 ); - - v0: Vector2; - v1: Vector2; - v2: Vector2; - - getPoint(t: number): Vector2; - getTangent(t: number): Vector2; - } - export class QuadraticBezierCurve3 extends Curve { - constructor( v0: Vector3, v1: Vector3, v2: Vector3 ); - - v0: Vector3; - v1: Vector3; - v2: Vector3; - - getPoint(t: number): Vector3; - } - export class SplineCurve extends Curve { - constructor( points: Vector2[] ); - - points:Vector2[]; - - getPoint(t: number): Vector2; - } - export class SplineCurve3 extends Curve { - constructor( points: Vector3[] ); - - points:Vector3[]; - - getPoint(t: number): Vector3; - } - // Extras / Core ///////////////////////////////////////////////////////////////////// @@ -5142,8 +5066,6 @@ declare module THREE { * class Curve<T extends Vector> */ export class Curve { - needsUpdate: boolean; - /** * Returns a vector for point t of the curve where t is between 0 and 1 * getPoint(t: number): T; @@ -5225,29 +5147,31 @@ declare module THREE { bends: Path[]; autoClose: boolean; - getWrapPoints(oldPts: Vector2[], path: Path): Vector2[]; - createPointsGeometry(divisions: number): Geometry; - addWrapPath(bendpath: Path): void; - createGeometry(points: Vector2[]): Geometry; add(curve: Curve): void; - getTransformedSpacedPoints(segments: number, bends?: Path[]): Vector2[]; - createSpacedPointsGeometry(divisions: number): Geometry; - closePath(): void; - getBoundingBox(): BoundingBox; - getCurveLengths(): number; - getTransformedPoints(segments: number, bends?: Path): Vector2[]; checkConnection(): boolean; + closePath(): void; + getPoint(t: number): Vector; + getLength(): number; + getCurveLengths(): number; + getBoundingBox(): BoundingBox; + createPointsGeometry(divisions: number): Geometry; + createSpacedPointsGeometry(divisions: number): Geometry; + createGeometry(points: Vector2[]): Geometry; + addWrapPath(bendpath: Path): void; + getTransformedPoints(segments: number, bends?: Path): Vector2[]; + getTransformedSpacedPoints(segments: number, bends?: Path[]): Vector2[]; + getWrapPoints(oldPts: Vector2[], path: Path): Vector2[]; } export class Gyroscope extends Object3D { constructor(); - scaleWorld: Vector3; translationWorld: Vector3; - quaternionWorld: Quaternion; translationObject: Vector3; - scaleObject: Vector3; + quaternionWorld: Quaternion; quaternionObject: Quaternion; + scaleWorld: Vector3; + scaleObject: Vector3; updateMatrixWorld(force?: boolean): void; } @@ -5285,6 +5209,8 @@ declare module THREE { absarc(aX: number, aY: number, aRadius: number, aStartAngle: number, aEndAngle: number, aClockwise: boolean): void; ellipse(aX: number, aY: number, xRadius: number, yRadius: number, aStartAngle: number, aEndAngle: number, aClockwise: boolean): void; absellipse(aX: number, aY: number, xRadius: number, yRadius: number, aStartAngle: number, aEndAngle: number, aClockwise: boolean): void; + getSpacedPoints(divisions?: number, closedPath?: boolean): Vector[]; + getPoints(divisions?: number, closedPath?: boolean): Vector[]; toShapes(): Shape[]; } @@ -5296,22 +5222,120 @@ declare module THREE { holes: Path[]; + extrude(options?: any): ExtrudeGeometry; makeGeometry(options?: any): ShapeGeometry; + getPointsHoles(divisions: number): Vector2[][]; + getSpacedPointsHoles(divisions: number): Vector2[][]; extractAllPoints(divisions: number): { shape: Vector2[]; holes: Vector2[][]; }; - extrude(options?: any): ExtrudeGeometry; extractPoints(divisions: number): Vector2[]; extractAllSpacedPoints(divisions: Vector2): { shape: Vector2[]; holes: Vector2[][]; }; - getPointsHoles(divisions: number): Vector2[][]; - getSpacedPointsHoles(divisions: number): Vector2[][]; + } + // Extras / Curves ///////////////////////////////////////////////////////////////////// + export class ArcCurve extends EllipseCurve { + constructor(aX: number, aY: number, aRadius: number, aStartAngle: number, aEndAngle: number, aClockwise: boolean ); + } + export class ClosedSplineCurve3 extends Curve { + constructor( points?:Vector3[] ); + + points:Vector3[]; + + getPoint(t: number): Vector3; + } + + export class CubicBezierCurve extends Curve { + constructor( v0: Vector2, v1: Vector2, v2: Vector2, v3: Vector2 ); + + v0: Vector2; + v1: Vector2; + v2: Vector2; + v3: Vector2; + + getPoint(t: number): Vector2; + getTangent(t: number): Vector2; + } + export class CubicBezierCurve3 extends Curve { + constructor( v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3 ); + + v0: Vector3; + v1: Vector3; + v2: Vector3; + v3: Vector3; + + getPoint(t: number): Vector3; + } + export class EllipseCurve extends Curve { + constructor( aX: number, aY: number, xRadius: number, yRadius: number, aStartAngle: number, aEndAngle: number, aClockwise: boolean ); + + aX: number; + aY: number; + xRadius: number; + yRadius: number; + aStartAngle: number; + aEndAngle: number; + aClockwise: boolean; + + getPoint(t: number): Vector2; + } + export class LineCurve extends Curve { + constructor( v1: Vector2, v2: Vector2 ); + + v1: Vector2; + v2: Vector2; + + getPoint(t: number): Vector2; + getPointAt(u: number): Vector2; + getTangent(t: number): Vector2; + } + export class LineCurve3 extends Curve { + constructor( v1: Vector3, v2: Vector3 ); + + v1: Vector3; + v2: Vector3; + + getPoint(t: number): Vector3; + } + export class QuadraticBezierCurve extends Curve { + constructor( v0: Vector2, v1: Vector2, v2: Vector2 ); + + v0: Vector2; + v1: Vector2; + v2: Vector2; + + getPoint(t: number): Vector2; + getTangent(t: number): Vector2; + } + export class QuadraticBezierCurve3 extends Curve { + constructor( v0: Vector3, v1: Vector3, v2: Vector3 ); + + v0: Vector3; + v1: Vector3; + v2: Vector3; + + getPoint(t: number): Vector3; + } + export class SplineCurve extends Curve { + constructor( points?: Vector2[] ); + + points:Vector2[]; + + getPoint(t: number): Vector2; + } + export class SplineCurve3 extends Curve { + constructor( points?: Vector3[] ); + + points:Vector3[]; + + getPoint(t: number): Vector3; + } // Extras / Geomerties ///////////////////////////////////////////////////////////////////// /** @@ -5327,10 +5351,33 @@ declare module THREE { * @param depthSegments — Number of segmented faces along the depth of the sides. */ constructor(width: number, height: number, depth: number, widthSegments?: number, heightSegments?: number, depthSegments?: number); + + parameters: { + width: number; + height: number; + depth: number; + widthSegments: number; + heightSegments: number; + depthSegments: number; + }; + widthSegments: number; + heightSegments: number; + depthSegments: number; } export class CircleGeometry extends Geometry { constructor(radius?: number, segments?: number, thetaStart?: number, thetaLength?: number); + + parameters: { + radius: number; + segments: number; + thetaStart: number; + thetaLength: number; + }; + radius: number; + segments: number; + thetaStart: number; + thetaLength: number; } export class CubeGeometry extends BoxGeometry { @@ -5346,6 +5393,21 @@ declare module THREE { * @param openEnded - A Boolean indicating whether or not to cap the ends of the cylinder. */ constructor(radiusTop?: number, radiusBottom?: number, height?: number, radiusSegments?: number, heightSegments?: number, openEnded?: boolean); + + parameters: { + radiusTop: number; + radiusBottom: number; + height: number; + radialSegments: number; + heightSegments: number; + openEnded: boolean; + }; + radiusTop: number; + radiusBottom: number; + height: number; + radialSegments: number; + heightSegments: number; + openEnded: boolean; } export class ExtrudeGeometry extends Geometry { @@ -5358,14 +5420,29 @@ declare module THREE { export class IcosahedronGeometry extends PolyhedronGeometry { constructor(radius: number, detail: number); + + parameters: { + radius: number; + detail: number; + }; + radius: number; + detail: number; } export class LatheGeometry extends Geometry { - constructor(points: Vector3[], steps?: number, angle?: number); + constructor(points: Vector3[], segments?: number, phiStart?: number, phiLength?: number); + } export class OctahedronGeometry extends PolyhedronGeometry { constructor(radius: number, detail: number); + + parameters: { + radius: number; + detail: number; + }; + radius: number; + detail: number; } export class ParametricGeometry extends Geometry { @@ -5374,6 +5451,17 @@ declare module THREE { export class PlaneGeometry extends Geometry { constructor(width: number, height: number, widthSegments?: number, heightSegments?: number); + + parameters: { + width: number; + height: number; + widthSegments: number; + heightSegments: number; + }; + width: number; + height: number; + widthSegments: number; + heightSegments: number; } export class PolyhedronGeometry extends Geometry { @@ -5383,6 +5471,7 @@ declare module THREE { export class RingGeometry extends Geometry { constructor(innerRadius?: number, outerRadius?: number, thetaSegments?: number, phiSegments?: number, thetaStart?: number, thetaLength?: number); } + export class ShapeGeometry extends Geometry { constructor(shape: Shape, options?: any); constructor(shapes: Shape[], options?: any); @@ -5399,14 +5488,31 @@ declare module THREE { * The geometry is created by sweeping and calculating vertexes around the Y axis (horizontal sweep) and the Z axis (vertical sweep). Thus, incomplete spheres (akin to 'sphere slices') can be created through the use of different values of phiStart, phiLength, thetaStart and thetaLength, in order to define the points in which we start (or end) calculating those vertices. * * @param radius — sphere radius. Default is 50. - * @param segmentsWidth — number of horizontal segments. Minimum value is 3, and the default is 8. - * @param segmentsHeight — number of vertical segments. Minimum value is 2, and the default is 6. + * @param widthSegments — number of horizontal segments. Minimum value is 3, and the default is 8. + * @param heightSegments — number of vertical segments. Minimum value is 2, and the default is 6. * @param phiStart — specify horizontal starting angle. Default is 0. * @param phiLength — specify horizontal sweep angle size. Default is Math.PI * 2. * @param thetaStart — specify vertical starting angle. Default is 0. * @param thetaLength — specify vertical sweep angle size. Default is Math.PI. */ constructor(radius: number, widthSegments?: number, heightSegments?: number, phiStart?: number, phiLength?: number, thetaStart?: number, thetaLength?: number); + + parameters: { + radius: number; + widthSegments: number; + heightSegments: number; + phiStart: number; + phiLength: number; + thetaStart: number; + thetaLength: number; + }; + radius: number; + widthSegments: number; + heightSegments: number; + phiStart: number; + phiLength: number; + thetaStart: number; + thetaLength: number; } export class TetrahedronGeometry extends PolyhedronGeometry { @@ -5431,19 +5537,56 @@ declare module THREE { export class TorusGeometry extends Geometry { constructor(radius?: number, tube?: number, radialSegments?: number, tubularSegments?: number, arc?: number); + + parameters: { + radius: number; + tube: number; + radialSegments: number; + tubularSegments: number; + arc: number; + }; + radius: number; + tube: number; + radialSegments: number; + tubularSegments: number; + arc: number; } export class TorusKnotGeometry extends Geometry { constructor(radius?: number, tube?: number, radialSegments?: number, tubularSegments?: number, p?: number, q?: number, heightScale?: number); + + parameters: { + radius: number; + tube: number; + radialSegments: number; + tubularSegments: number; + p: number; + q: number; + heightScale: number; + }; + radius: number; + tube: number; + radialSegments: number; + tubularSegments: number; + p: number; + q: number; + heightScale: number; } export class TubeGeometry extends Geometry { constructor(path: Path, segments?: number, radius?: number, radiusSegments?: number, closed?: boolean); + parameters: { + path: Path; + segments: number; + radius: number; + radialSegments: number; + closed: boolean; + }; path: Path; segments: number; radius: number; - radiusSegments: number; + radialSegments: number; closed: boolean; tangents: Vector3[]; normals: Vector3[]; @@ -5460,29 +5603,26 @@ declare module THREE { line: Line; cone: Mesh; - setColor(hex: number): void; - setLength(length: number): void; setDirection(dir: Vector3): void; + setLength(length: number): void; + setColor(hex: number): void; } export class AxisHelper extends Line { - constructor(size: number); + constructor(size?: number); } export class BoundingBoxHelper extends Mesh { - constructor(object: Object3D, hex: number); + constructor(object: Object3D, hex?: number); object: Object3D; - vertices: Vector3[]; + box: Box3[]; update(): void; } export class BoxHelper extends Line { - constructor(object: Object3D); - - object: Object3D; - box: Box3; + constructor(object?: Object3D); update(object?: Object3D): void; } @@ -5490,35 +5630,33 @@ declare module THREE { export class CameraHelper extends Line { constructor(camera: Camera); - pointMap: { [id: string]: number[]; }; camera: Camera; + pointMap: { [id: string]: number[]; }; update(): void; } export class DirectionalLightHelper extends Object3D { - constructor(light: Light, size: number); + constructor(light: Light, size?: number); - lightPlane: Line; light: Light; + lightPlane: Line; targetLine: Line; - update(): void; dispose(): void; + update(): void; } export class EdgesHelper extends Line { constructor(object: Object3D, hex?: number); - matrixAutoUpdate: boolean; - matrixWorld: Matrix4; } export class FaceNormalsHelper extends Line { constructor(object: Object3D, size?: number, hex?: number, linewidth?: number); + object: Object3D; size: number; - matrixAutoUpdate: boolean; normalMatrix: Matrix3; update(object?: Object3D): void; @@ -5527,23 +5665,28 @@ declare module THREE { export class GridHelper extends Line { constructor(size: number, step: number); + color1: Color; + color2: Color; + setColors(colorCenterLine: number, colorGrid: number): void; } export class HemisphereLightHelper extends Object3D { constructor(light: Light, sphereSize: number, arrowLength: number, domeSize: number); - lightSphere: Mesh; light: Light; + colors: Color[]; + lightSphere: Mesh; + dispose(): void; update(): void; } export class PointLightHelper extends Object3D { constructor(light: Light, sphereSize: number); - lightSphere: Mesh; light: Light; + dispose(): void; update(): void; } @@ -5552,8 +5695,7 @@ declare module THREE { bones: Bone[]; root: Object3D; - matrixWorld: Matrix4; - matrixAutoUpdate: boolean; + getBoneList(object: Object3D): Bone[]; update(): void; } @@ -5561,18 +5703,18 @@ declare module THREE { export class SpotLightHelper extends Object3D { constructor(light: Light, sphereSize: number, arrowLength: number); - lightSphere: Mesh; light: Light; - lightCone: Mesh; + cone: Mesh; + dispose(): void; update(): void; } export class VertexNormalsHelper extends Line { constructor(object: Object3D, size?: number, hex?: number, linewidth?: number); + object: Object3D; size: number; - matrixAutoUpdate: boolean; normalMatrix: Matrix3; update(object?: Object3D): void; @@ -5581,8 +5723,8 @@ declare module THREE { export class VertexTangentsHelper extends Line { constructor(object: Object3D, size?: number, hex?: number, linewidth?: number); + object: Object3D; size: number; - matrixAutoUpdate: boolean; update(object?: Object3D): void; } @@ -5590,8 +5732,6 @@ declare module THREE { export class WireframeHelper extends Line { constructor(object: Object3D, hex?: number); - matrixAutoUpdate: boolean; - matrixWorld: Matrix4; } // Extras / Objects ///////////////////////////////////////////////////////////////////// @@ -5652,19 +5792,19 @@ declare module THREE { animationsMap: { [name: string]: MorphBlendMeshAnimation; }; animationsList: MorphBlendMeshAnimation[]; - setAnimationWeight(name: string, weight: number): void; - setAnimationFPS(name: string, fps: number): void; createAnimation(name: string, start: number, end: number, fps: number): void; - playAnimation(name: string): void; - update(delta: number): void; autoCreateAnimations(fps: number): void; - setAnimationDuration(name: string, duration: number): void; setAnimationDirectionForward(name: string): void; - getAnimationDuration(name: string): number; - getAnimationTime(name: string): number; setAnimationDirectionBackward(name: string): void; + setAnimationFPS(name: string, fps: number): void; + setAnimationDuration(name: string, duration: number): void; + setAnimationWeight(name: string, weight: number): void; setAnimationTime(name: string, time: number): void; + getAnimationTime(name: string): number; + getAnimationDuration(name: string): number; + playAnimation(name: string): void; stopAnimation(name: string): void; + update(delta: number): void; } // Extras / Renderers / Plugins ///////////////////////////////////////////////////////////////////// @@ -5676,8 +5816,8 @@ declare module THREE { renderTarget: RenderTarget; init(renderer: Renderer): void; - update(scene: Scene, camera: Camera): void; render(scene: Scene, camera: Camera): void; + update(scene: Scene, camera: Camera): void; } export class LensFlarePlugin implements RendererPlugin { @@ -5691,9 +5831,8 @@ declare module THREE { constructor(); init(renderer: Renderer): void; - - update(scene: Scene, camera: Camera): void; render(scene: Scene, camera: Camera): void; + update(scene: Scene, camera: Camera): void; } export class SpritePlugin implements RendererPlugin { diff --git a/timezonecomplete/timezonecomplete-1.3.0.d.ts b/timezonecomplete/timezonecomplete-1.3.0.d.ts index d4960def4..602a44084 100644 --- a/timezonecomplete/timezonecomplete-1.3.0.d.ts +++ b/timezonecomplete/timezonecomplete-1.3.0.d.ts @@ -1,702 +1,702 @@ -// Type definitions for timezonecomplete 1.3.0 -// Project: https://github.com/SpiritIT/timezonecomplete -// Definitions by: Rogier Schouten -// Definitions: https://github.com/borisyankov/DefinitelyTyped -// Generated by dts-bundle v0.2.0 - -declare module 'timezonecomplete-1.3.0' { - /** - * @return True iff the given year is a leap year. - */ - export function isLeapYear(year: number): boolean; - /** - * @param year The full year - * @param month The month 1-12 - * @return The number of days in the given month - */ - export function daysInMonth(year: number, month: number): number; - /** - * Returns an ISO time string. Note that months are 1-12. - */ - export function isoString(year: number, month: number, day: number, hour: number, minute: number, second: number, millisecond: number): string; - /** - * Time units - */ - export enum TimeUnit { - Second = 0, - Minute = 1, - Hour = 2, - Day = 3, - Week = 4, - Month = 5, - Year = 6, - } - /** - * Time duration. Create one e.g. like this: var d = Duration.hours(1). - * Note that time durations do not take leap seconds etc. into account: - * one hour is simply represented as 3600000 milliseconds. - */ - export class Duration { - /** - * Construct a time duration - * @param n Number of hours - * @return A duration of n hours - */ - static hours(n: number): Duration; - /** - * Construct a time duration - * @param n Number of minutes - * @return A duration of n minutes - */ - static minutes(n: number): Duration; - /** - * Construct a time duration - * @param n Number of seconds - * @return A duration of n seconds - */ - static seconds(n: number): Duration; - /** - * Construct a time duration - * @param n Number of milliseconds - * @return A duration of n milliseconds - */ - static milliseconds(n: number): Duration; - /** - * Construct a time duration of 0 - */ - constructor(); - /** - * Construct a time duration from a number of milliseconds - */ - constructor(milliseconds: number); - /** - * Construct a time duration from a string in format - * [-]h[:m[:s[.n]]] e.g. -01:00:30.501 - */ - constructor(input: string); - /** - * @return another instance of Duration with the same value. - */ - clone(): Duration; - /** - * The entire duration in milliseconds (negative or positive) - */ - milliseconds(): number; - /** - * The millisecond part of the duration (always positive) - * @return e.g. 400 for a -01:02:03.400 duration - */ - millisecond(): number; - /** - * The entire duration in seconds (negative or positive, fractional) - * @return e.g. 1.5 for a 1500 milliseconds duration - */ - seconds(): number; - /** - * The second part of the duration (always positive) - * @return e.g. 3 for a -01:02:03.400 duration - */ - second(): number; - /** - * The entire duration in minutes (negative or positive, fractional) - * @return e.g. 1.5 for a 90000 milliseconds duration - */ - minutes(): number; - /** - * The minute part of the duration (always positive) - * @return e.g. 2 for a -01:02:03.400 duration - */ - minute(): number; - /** - * The entire duration in hours (negative or positive, fractional) - * @return e.g. 1.5 for a 5400000 milliseconds duration - */ - hours(): number; - /** - * The hour part of the duration (always positive). - * Note that this part can exceed 23 hours, because for - * now, we do not have a days() function - * @return e.g. 25 for a -25:02:03.400 duration - */ - wholeHours(): number; - /** - * Sign - * @return "-" if the duration is negative - */ - sign(): string; - /** - * @return True iff (this < other) - */ - lessThan(other: Duration): boolean; - /** - * @return True iff this and other represent the same time duration - */ - equals(other: Duration): boolean; - /** - * @return True iff this > other - */ - greaterThan(other: Duration): boolean; - /** - * @return The minimum (most negative) of this and other - */ - min(other: Duration): Duration; - /** - * @return The maximum (most positive) of this and other - */ - max(other: Duration): Duration; - /** - * Multiply with a fixed number. - * @return a new Duration of (this * value) - */ - multiply(value: number): Duration; - /** - * Divide by a fixed number. - * @return a new Duration of (this / value) - */ - divide(value: number): Duration; - /** - * Add a duration. - * @return a new Duration of (this + value) - */ - add(value: Duration): Duration; - /** - * Subtract a duration. - * @return a new Duration of (this - value) - */ - sub(value: Duration): Duration; - /** - * String in [-]hh:mm:ss.nnn notation. All fields are - * always present except the sign. - */ - toFullString(): string; - /** - * String in [-]hh[:mm[:ss[.nnn]]] notation. Fields are - * added as necessary - */ - toString(): string; - } - /** - * The type of time zone - */ - export enum TimeZoneKind { - /** - * Local time offset as determined by JavaScript Date class. - */ - Local = 0, - /** - * Fixed offset from UTC, without DST. - */ - Offset = 1, - /** - * IANA timezone managed through Olsen TZ database. Includes - * DST if applicable. - */ - Proper = 2, - } - /** - * Time zone. The object is immutable because it is cached: - * requesting a time zone twice yields the very same object. - * Note that we use time zone offsets inverted w.r.t. JavaScript Date.getTimezoneOffset(), - * i.e. offset 90 means +01:30. - * - * Time zones come in three flavors: the local time zone, as calculated by JavaScript Date, - * a fixed offset ("+01:30") without DST, or a IANA timezone ("Europe/Amsterdam") with DST - * applied depending on the time zone rules. - */ - export class TimeZone { - /** - * The local time zone for a given date. Note that - * the time zone varies with the date: amsterdam time for - * 2014-01-01 is +01:00 and amsterdam time for 2014-07-01 is +02:00 - */ - static local(): TimeZone; - /** - * The UTC time zone. - */ - static utc(): TimeZone; - /** - * Returns a time zone object from the cache. If it does not exist, it is created. - * @return The time zone with the given offset w.r.t. UTC in minutes, e.g. 90 for +01:30 - */ - static zone(offset: number): TimeZone; - /** - * Returns a time zone object from the cache. If it does not exist, it is created. - * @param s: Empty string for local time, a TZ database time zone name (e.g. Europe/Amsterdam) - * or an offset string (either +01:30, +0130, +01, Z). For a full list of names, see: - * https://en.wikipedia.org/wiki/List_of_tz_database_time_zones - */ - static zone(s: string): TimeZone; - /** - * The time zone identifier. Can be an offset "-01:30" or an - * IANA time zone name "Europe/Amsterdam", or "localtime" for - * the local time zone. - */ - name(): string; - /** - * The kind of time zone (Local/Offset/Proper) - */ - kind(): TimeZoneKind; - /** - * Equality operator. Maps zero offsets and different names for UTC onto - * each other. Other time zones are not mapped onto each other. - */ - equals(other: TimeZone): boolean; - /** - * Is this zone equivalent to UTC? - */ - isUtc(): boolean; - /** - * Calculate timezone offset from a UTC time. - * @param year local full year - * @param month local month 1-12 (note this deviates from JavaScript date) - * @param day local day of month 1-31 - * @param hour local hour 0-23 - * @param minute local minute 0-59 - * @param second local second 0-59 - * @param millisecond local millisecond 0-999 - * @return the offset of this time zone with respect to UTC at the given time. - */ - offsetForUtc(year: number, month: number, day: number, hour?: number, minute?: number, second?: number, millisecond?: number): number; - /** - * Calculate timezone offset from a zone-local time (NOT a UTC time). - * @param year local full year - * @param month local month 1-12 (note this deviates from JavaScript date) - * @param day local day of month 1-31 - * @param hour local hour 0-23 - * @param minute local minute 0-59 - * @param second local second 0-59 - * @param millisecond local millisecond 0-999 - * @return the offset of this time zone with respect to UTC at the given time. - */ - offsetForZone(year: number, month: number, day: number, hour?: number, minute?: number, second?: number, millisecond?: number): number; - /** - * Convenience function, takes values from a Javascript Date - * Calls offsetForUtc() with the contents of the date - * @param date: the date - * @param funcs: the set of functions to use: get() or getUTC() - */ - offsetForUtcDate(date: Date, funcs: DateFunctions): number; - /** - * Convenience function, takes values from a Javascript Date - * Calls offsetForUtc() with the contents of the date - * @param date: the date - * @param funcs: the set of functions to use: get() or getUTC() - */ - offsetForZoneDate(date: Date, funcs: DateFunctions): number; - /** - * The time zone identifier (normalized). - * Either "localtime", IANA name, or "+hh:mm" offset. - */ - toString(): string; - /** - * Convert an offset number into an offset string - * @param offset The offset in minutes from UTC e.g. 90 minutes - * @return the offset in ISO notation "+01:30" for +90 minutes - */ - static offsetToString(offset: number): string; - /** - * String to offset conversion. - * @param s Formats: "-01:00", "-0100", "-01", "Z" - * @return offset w.r.t. UTC in minutes - */ - static stringToOffset(s: string): number; - } - /** - * For testing purposes, we often need to manipulate what the current - * time is. This is an interface for a custom time source object - * so in tests you can use a custom time source. - */ - export interface TimeSource { - /** - * Return the current date+time as a javascript Date object - */ - now(): Date; - } - /** - * Default time source, returns actual time - */ - export class RealTimeSource implements TimeSource { - now(): Date; - } - /** - * Indicates how a Date object should be interpreted. - * Either we can take getYear(), getMonth() etc for our field - * values, or we can take getUTCYear() etc to do that. - */ - export enum DateFunctions { - /** - * Use the Date.getFullYear(), Date.getMonth(), ... functions. - */ - Get = 0, - /** - * Use the Date.getUTCFullYear(), Date.getUTCMonth(), ... functions. - */ - GetUTC = 1, - } - /** - * Day-of-week. Note the enum values correspond to JavaScript day-of-week: - * Sunday = 0, Monday = 1 etc - */ - export enum WeekDay { - Sunday = 0, - Monday = 1, - Tuesday = 2, - Wednesday = 3, - Thursday = 4, - Friday = 5, - Saturday = 6, - } - /** - * Our very own DateTime class which is time zone-aware - * and which can be mocked for testing purposes - */ - export class DateTime { - /** - * Actual time source in use. Setting this property allows to - * fake time in tests. DateTime.nowLocal() and DateTime.nowUtc() - * use this property for obtaining the current time. - */ - static timeSource: TimeSource; - /** - * Current date+time in local time (derived from DateTime.timeSource.now()). - */ - static nowLocal(): DateTime; - /** - * Current date+time in UTC time (derived from DateTime.timeSource.now()). - */ - static nowUtc(): DateTime; - /** - * Current date+time in the given time zone (derived from DateTime.timeSource.now()). - * @param timeZone The desired time zone. - */ - static now(timeZone: TimeZone): DateTime; - /** - * Constructor. Creates current time in local timezone. - */ - constructor(); - /** - * Constructor - * @param isoString String in ISO 8601 format. Instead of ISO time zone, - * it may include a space and then and IANA time zone. - * e.g. "2007-04-05T12:30:40.500" (no time zone, naive date) - * e.g. "2007-04-05T12:30:40.500+01:00" (UTC offset without daylight saving time) - * or "2007-04-05T12:30:40.500Z" (UTC) - * or "2007-04-05T12:30:40.500 Europe/Amsterdam" (IANA time zone, with daylight saving time if applicable) - * @param timeZone if given, the date in the string is assumed to be in this time zone. - * Note that it is NOT CONVERTED to the time zone. Useful - * for strings without a time zone - */ - constructor(isoString: string, timeZone?: TimeZone); - /** - * Constructor. You provide a date, then you say whether to take the - * date.getYear()/getXxx methods or the date.getUTCYear()/date.getUTCXxx methods, - * and then you state which time zone that date is in. - * - * @param date A date object. - * @param getters Specifies which set of Date getters contains the date in the given time zone: the - * Date.getXxx() methods or the Date.getUTCXxx() methods. - * @param timeZone The time zone that the given date is assumed to be in (may be null for unaware dates) - */ - constructor(date: Date, getFuncs: DateFunctions, timeZone?: TimeZone); - /** - * Constructor. Note that unlike JavaScript dates we require fields to be in normal ranges. - * Use the add(duration) or sub(duration) for arithmetic. - * @param year The full year (e.g. 2014) - * @param month The month [1-12] (note this deviates from JavaScript Date) - * @param day The day of the month [1-31] - * @param hour The hour of the day [0-24) - * @param minute The minute of the hour [0-59] - * @param second The second of the minute [0-59] - * @param millisecond The millisecond of the second [0-999] - * @param timeZone The time zone, or null (for unaware dates) - */ - constructor(year: number, month: number, day: number, hour?: number, minute?: number, second?: number, millisecond?: number, timeZone?: TimeZone); - /** - * Constructor - * @param unixTimestamp milliseconds since 1970-01-01T00:00:00.000 - * @param timeZone the time zone that the timestamp is assumed to be in (usually UTC). - */ - constructor(unixTimestamp: number, timeZone?: TimeZone); - /** - * @return a copy of this object - */ - clone(): DateTime; - /** - * @return The time zone that the date is in. May be null for unaware dates. - */ - zone(): TimeZone; - /** - * @return the offset w.r.t. UTC in minutes. Returns 0 for unaware dates and for UTC dates. - */ - offset(): number; - /** - * @return The full year e.g. 2014 - */ - year(): number; - /** - * @return The month 1-12 (note this deviates from JavaScript Date) - */ - month(): number; - /** - * @return The day of the month 1-31 - */ - day(): number; - /** - * @return The hour 0-23 - */ - hour(): number; - /** - * @return the minutes 0-59 - */ - minute(): number; - /** - * @return the seconds 0-59 - */ - second(): number; - /** - * @return the milliseconds 0-999 - */ - millisecond(): number; - /** - * @return the day-of-week (the enum values correspond to JavaScript - * week day numbers) - */ - weekDay(): WeekDay; - /** - * @return Milliseconds since 1970-01-01T00:00:00.000Z - */ - unixUtcMillis(): number; - /** - * @return The full year e.g. 2014 - */ - utcYear(): number; - /** - * @return The UTC month 1-12 (note this deviates from JavaScript Date) - */ - utcMonth(): number; - /** - * @return The UTC day of the month 1-31 - */ - utcDay(): number; - /** - * @return The UTC hour 0-23 - */ - utcHour(): number; - /** - * @return The UTC minutes 0-59 - */ - utcMinute(): number; - /** - * @return The UTC seconds 0-59 - */ - utcSecond(): number; - /** - * @return The UTC milliseconds 0-999 - */ - utcMillisecond(): number; - /** - * @return the UTC day-of-week (the enum values correspond to JavaScript - * week day numbers) - */ - utcWeekDay(): WeekDay; - /** - * Convert this date to the given time zone (in-place). - * Throws if this date does not have a time zone. - * @return this (for chaining) - */ - convert(zone?: TimeZone): DateTime; - /** - * Returns this date converted to the given time zone. - * Unaware dates can only be converted to unaware dates (clone) - * For unaware dates, an exception is thrown - * @param zone The new time zone. This may be null to create unaware date. - * @return The converted date - */ - toZone(zone?: TimeZone): DateTime; - /** - * Convert to JavaScript date with the zone time in the getX() methods. - * Unless the timezone is local, the Date.getUTCX() methods will NOT be correct. - */ - toDate(): Date; - /** - * Add a time duration. Note that this simply adds a number - * of milliseconds to UTC and converts back to zone(), - * so in the presence of e.g. leap seconds there may be a - * shift in the seconds field if you add an hour. - * There is not DST handling and no leap second handling. - * @return this + duration - */ - add(duration: Duration): DateTime; - /** - * Add an amount of time to UTC, taking leap seconds etc into account. - * Adding e.g. 1 hour will increment the utcHour() field - * date by one. In case of DST changes, the local hour() field - * may not increase or increase by 2 hours. So if you add a month, the - * local time may vary by an hour. There will not be a shift - * in seconds due to leap seconds. - */ - add(amount: number, unit: TimeUnit): DateTime; - /** - * Add an amount of time to the zone time, as regularly as possible. - * Adding e.g. 1 hour will increment the hour() field of the zone - * date by one. In case of DST changes, the utcHour() field may - * increase by 1 or increase by 2. Adding a day will leave the time portion - * intact. However, adding an hour around a forward DST change adds two hours, - * since there is a zone time (2AM in Holland) that does not exist. - */ - addLocal(amount: number, unit: TimeUnit): DateTime; - /** - * Same as add(-1*duration); - */ - sub(duration: Duration): DateTime; - /** - * Same as add(-1*amount, unit); - */ - sub(amount: number, unit: TimeUnit): DateTime; - /** - * Same as addLocal(-1*amount, unit); - */ - subLocal(amount: number, unit: TimeUnit): DateTime; - /** - * Time difference between two DateTimes - * @return this - other - */ - diff(other: DateTime): Duration; - /** - * @return True iff (this < other) - */ - lessThan(other: DateTime): boolean; - /** - * @return True iff (this <= other) - */ - lessEqual(other: DateTime): boolean; - /** - * @return True iff this and other represent the same time in UTC - */ - equals(other: DateTime): boolean; - /** - * @return True iff this and other represent the same time and - * have the same zone - */ - identical(other: DateTime): boolean; - /** - * @return True iff this > other - */ - greaterThan(other: DateTime): boolean; - /** - * @return True iff this >= other - */ - greaterEqual(other: DateTime): boolean; - /** - * Proper ISO 8601 format string with any IANA zone converted to ISO offset - * E.g. "2014-01-01T23:15:33+01:00" for Europe/Amsterdam - */ - toIsoString(): string; - /** - * Modified ISO 8601 format string with IANA name if applicable. - * E.g. "2014-01-01T23:15:33.000 Europe/Amsterdam" - */ - toString(): string; - /** - * Modified ISO 8601 format string in UTC without time zone info - */ - toUtcString(): string; - } - /** - * Specifies how the period should repeat across the day - * during DST changes. - */ - export enum PeriodDst { - /** - * Keep repeating in similar intervals measured in UTC, - * unaffected by Daylight Saving Time. - * E.g. a repetition of one hour will take one real hour - * every time, even in a time zone with DST. - * Leap seconds, leap days and month length - * differences will still make the intervals different. - */ - RegularIntervals = 0, - /** - * Ensure that the time at which the intervals occur stay - * at the same place in the day, local time. So e.g. - * a period of one day, starting at 8:05AM Europe/Amsterdam time - * will always start at 8:05 Europe/Amsterdam. This means that - * in UTC time, some intervals will be 25 hours and some - * 23 hours during DST changes. - * Another example: an hourly interval will be hourly in local time, - * skipping an hour in UTC for a DST backward change. - */ - RegularLocalTime = 1, - } - /** - * Convert a PeriodDst to a string: "regular intervals" or "regular local time" - */ - export function periodDstToString(p: PeriodDst): string; - /** - * Repeating time period: consists of a starting point and - * a time length. This class accounts for leap seconds and leap days. - */ - export class Period { - /** - * Constructor - * LIMITATION: if dst equals RegularLocalTime, and unit is Second, Minute or Hour, - * then the amount must be a factor of 24. So 120 seconds is allowed while 121 seconds is not. - * This is due to the enormous processing power required by these cases. They are not - * implemented and you will get an assert. - * - * @param start The start of the period. If the period is in Months or Years, and - * the day is 29 or 30 or 31, the results are maximised to end-of-month. - * @param amount The amount of units. - * @param unit The unit. - * @param dst Specifies how to handle Daylight Saving Time. Not relevant - * if the time zone of the start datetime does not have DST. - */ - constructor(start: DateTime, amount: number, unit: TimeUnit, dst: PeriodDst); - /** - * The start date - */ - start(): DateTime; - /** - * The amount of units - */ - amount(): number; - /** - * The unit - */ - unit(): TimeUnit; - /** - * The dst handling mode - */ - dst(): PeriodDst; - /** - * The first occurrence of the period greater than - * the given date. The given date need not be at a period boundary. - * Pre: the fromdate and startdate must either both have timezones or not - * @param fromDate: the date after which to return the next date - * @return the first date matching the period after fromDate, given - * in the same zone as the fromDate. - */ - findFirst(fromDate: DateTime): DateTime; - /** - * Returns the next timestamp in the period. The given timestamp must - * be at a period boundary, otherwise the answer is incorrect. - * This function has MUCH better performance than findFirst. - * Returns the datetime "count" times away from the given datetime. - * @param prev Boundary date. Must have a time zone (any time zone) iff the period start date has one. - * @param count Optional, must be >= 1 and whole. - * @return (prev + count * period), in the same timezone as prev. - */ - findNext(prev: DateTime, count?: number): DateTime; - /** - * Returns an ISO duration string - * P[n]Y[n]M[n]DT[n]H[n]M[n][.n]S or P[n]W - */ - toIsoString(): string; - /** - * A string representation e.g. - * "10 years, starting at 2014-03-01T12:00:00 Europe/Amsterdam keeping regular intervals". - */ - toString(): string; - } -} - +// Type definitions for timezonecomplete 1.3.0 +// Project: https://github.com/SpiritIT/timezonecomplete +// Definitions by: Rogier Schouten +// Definitions: https://github.com/borisyankov/DefinitelyTyped +// Generated by dts-bundle v0.2.0 + +declare module 'timezonecomplete-1.3.0' { + /** + * @return True iff the given year is a leap year. + */ + export function isLeapYear(year: number): boolean; + /** + * @param year The full year + * @param month The month 1-12 + * @return The number of days in the given month + */ + export function daysInMonth(year: number, month: number): number; + /** + * Returns an ISO time string. Note that months are 1-12. + */ + export function isoString(year: number, month: number, day: number, hour: number, minute: number, second: number, millisecond: number): string; + /** + * Time units + */ + export enum TimeUnit { + Second = 0, + Minute = 1, + Hour = 2, + Day = 3, + Week = 4, + Month = 5, + Year = 6, + } + /** + * Time duration. Create one e.g. like this: var d = Duration.hours(1). + * Note that time durations do not take leap seconds etc. into account: + * one hour is simply represented as 3600000 milliseconds. + */ + export class Duration { + /** + * Construct a time duration + * @param n Number of hours + * @return A duration of n hours + */ + static hours(n: number): Duration; + /** + * Construct a time duration + * @param n Number of minutes + * @return A duration of n minutes + */ + static minutes(n: number): Duration; + /** + * Construct a time duration + * @param n Number of seconds + * @return A duration of n seconds + */ + static seconds(n: number): Duration; + /** + * Construct a time duration + * @param n Number of milliseconds + * @return A duration of n milliseconds + */ + static milliseconds(n: number): Duration; + /** + * Construct a time duration of 0 + */ + constructor(); + /** + * Construct a time duration from a number of milliseconds + */ + constructor(milliseconds: number); + /** + * Construct a time duration from a string in format + * [-]h[:m[:s[.n]]] e.g. -01:00:30.501 + */ + constructor(input: string); + /** + * @return another instance of Duration with the same value. + */ + clone(): Duration; + /** + * The entire duration in milliseconds (negative or positive) + */ + milliseconds(): number; + /** + * The millisecond part of the duration (always positive) + * @return e.g. 400 for a -01:02:03.400 duration + */ + millisecond(): number; + /** + * The entire duration in seconds (negative or positive, fractional) + * @return e.g. 1.5 for a 1500 milliseconds duration + */ + seconds(): number; + /** + * The second part of the duration (always positive) + * @return e.g. 3 for a -01:02:03.400 duration + */ + second(): number; + /** + * The entire duration in minutes (negative or positive, fractional) + * @return e.g. 1.5 for a 90000 milliseconds duration + */ + minutes(): number; + /** + * The minute part of the duration (always positive) + * @return e.g. 2 for a -01:02:03.400 duration + */ + minute(): number; + /** + * The entire duration in hours (negative or positive, fractional) + * @return e.g. 1.5 for a 5400000 milliseconds duration + */ + hours(): number; + /** + * The hour part of the duration (always positive). + * Note that this part can exceed 23 hours, because for + * now, we do not have a days() function + * @return e.g. 25 for a -25:02:03.400 duration + */ + wholeHours(): number; + /** + * Sign + * @return "-" if the duration is negative + */ + sign(): string; + /** + * @return True iff (this < other) + */ + lessThan(other: Duration): boolean; + /** + * @return True iff this and other represent the same time duration + */ + equals(other: Duration): boolean; + /** + * @return True iff this > other + */ + greaterThan(other: Duration): boolean; + /** + * @return The minimum (most negative) of this and other + */ + min(other: Duration): Duration; + /** + * @return The maximum (most positive) of this and other + */ + max(other: Duration): Duration; + /** + * Multiply with a fixed number. + * @return a new Duration of (this * value) + */ + multiply(value: number): Duration; + /** + * Divide by a fixed number. + * @return a new Duration of (this / value) + */ + divide(value: number): Duration; + /** + * Add a duration. + * @return a new Duration of (this + value) + */ + add(value: Duration): Duration; + /** + * Subtract a duration. + * @return a new Duration of (this - value) + */ + sub(value: Duration): Duration; + /** + * String in [-]hh:mm:ss.nnn notation. All fields are + * always present except the sign. + */ + toFullString(): string; + /** + * String in [-]hh[:mm[:ss[.nnn]]] notation. Fields are + * added as necessary + */ + toString(): string; + } + /** + * The type of time zone + */ + export enum TimeZoneKind { + /** + * Local time offset as determined by JavaScript Date class. + */ + Local = 0, + /** + * Fixed offset from UTC, without DST. + */ + Offset = 1, + /** + * IANA timezone managed through Olsen TZ database. Includes + * DST if applicable. + */ + Proper = 2, + } + /** + * Time zone. The object is immutable because it is cached: + * requesting a time zone twice yields the very same object. + * Note that we use time zone offsets inverted w.r.t. JavaScript Date.getTimezoneOffset(), + * i.e. offset 90 means +01:30. + * + * Time zones come in three flavors: the local time zone, as calculated by JavaScript Date, + * a fixed offset ("+01:30") without DST, or a IANA timezone ("Europe/Amsterdam") with DST + * applied depending on the time zone rules. + */ + export class TimeZone { + /** + * The local time zone for a given date. Note that + * the time zone varies with the date: amsterdam time for + * 2014-01-01 is +01:00 and amsterdam time for 2014-07-01 is +02:00 + */ + static local(): TimeZone; + /** + * The UTC time zone. + */ + static utc(): TimeZone; + /** + * Returns a time zone object from the cache. If it does not exist, it is created. + * @return The time zone with the given offset w.r.t. UTC in minutes, e.g. 90 for +01:30 + */ + static zone(offset: number): TimeZone; + /** + * Returns a time zone object from the cache. If it does not exist, it is created. + * @param s: Empty string for local time, a TZ database time zone name (e.g. Europe/Amsterdam) + * or an offset string (either +01:30, +0130, +01, Z). For a full list of names, see: + * https://en.wikipedia.org/wiki/List_of_tz_database_time_zones + */ + static zone(s: string): TimeZone; + /** + * The time zone identifier. Can be an offset "-01:30" or an + * IANA time zone name "Europe/Amsterdam", or "localtime" for + * the local time zone. + */ + name(): string; + /** + * The kind of time zone (Local/Offset/Proper) + */ + kind(): TimeZoneKind; + /** + * Equality operator. Maps zero offsets and different names for UTC onto + * each other. Other time zones are not mapped onto each other. + */ + equals(other: TimeZone): boolean; + /** + * Is this zone equivalent to UTC? + */ + isUtc(): boolean; + /** + * Calculate timezone offset from a UTC time. + * @param year local full year + * @param month local month 1-12 (note this deviates from JavaScript date) + * @param day local day of month 1-31 + * @param hour local hour 0-23 + * @param minute local minute 0-59 + * @param second local second 0-59 + * @param millisecond local millisecond 0-999 + * @return the offset of this time zone with respect to UTC at the given time. + */ + offsetForUtc(year: number, month: number, day: number, hour?: number, minute?: number, second?: number, millisecond?: number): number; + /** + * Calculate timezone offset from a zone-local time (NOT a UTC time). + * @param year local full year + * @param month local month 1-12 (note this deviates from JavaScript date) + * @param day local day of month 1-31 + * @param hour local hour 0-23 + * @param minute local minute 0-59 + * @param second local second 0-59 + * @param millisecond local millisecond 0-999 + * @return the offset of this time zone with respect to UTC at the given time. + */ + offsetForZone(year: number, month: number, day: number, hour?: number, minute?: number, second?: number, millisecond?: number): number; + /** + * Convenience function, takes values from a Javascript Date + * Calls offsetForUtc() with the contents of the date + * @param date: the date + * @param funcs: the set of functions to use: get() or getUTC() + */ + offsetForUtcDate(date: Date, funcs: DateFunctions): number; + /** + * Convenience function, takes values from a Javascript Date + * Calls offsetForUtc() with the contents of the date + * @param date: the date + * @param funcs: the set of functions to use: get() or getUTC() + */ + offsetForZoneDate(date: Date, funcs: DateFunctions): number; + /** + * The time zone identifier (normalized). + * Either "localtime", IANA name, or "+hh:mm" offset. + */ + toString(): string; + /** + * Convert an offset number into an offset string + * @param offset The offset in minutes from UTC e.g. 90 minutes + * @return the offset in ISO notation "+01:30" for +90 minutes + */ + static offsetToString(offset: number): string; + /** + * String to offset conversion. + * @param s Formats: "-01:00", "-0100", "-01", "Z" + * @return offset w.r.t. UTC in minutes + */ + static stringToOffset(s: string): number; + } + /** + * For testing purposes, we often need to manipulate what the current + * time is. This is an interface for a custom time source object + * so in tests you can use a custom time source. + */ + export interface TimeSource { + /** + * Return the current date+time as a javascript Date object + */ + now(): Date; + } + /** + * Default time source, returns actual time + */ + export class RealTimeSource implements TimeSource { + now(): Date; + } + /** + * Indicates how a Date object should be interpreted. + * Either we can take getYear(), getMonth() etc for our field + * values, or we can take getUTCYear() etc to do that. + */ + export enum DateFunctions { + /** + * Use the Date.getFullYear(), Date.getMonth(), ... functions. + */ + Get = 0, + /** + * Use the Date.getUTCFullYear(), Date.getUTCMonth(), ... functions. + */ + GetUTC = 1, + } + /** + * Day-of-week. Note the enum values correspond to JavaScript day-of-week: + * Sunday = 0, Monday = 1 etc + */ + export enum WeekDay { + Sunday = 0, + Monday = 1, + Tuesday = 2, + Wednesday = 3, + Thursday = 4, + Friday = 5, + Saturday = 6, + } + /** + * Our very own DateTime class which is time zone-aware + * and which can be mocked for testing purposes + */ + export class DateTime { + /** + * Actual time source in use. Setting this property allows to + * fake time in tests. DateTime.nowLocal() and DateTime.nowUtc() + * use this property for obtaining the current time. + */ + static timeSource: TimeSource; + /** + * Current date+time in local time (derived from DateTime.timeSource.now()). + */ + static nowLocal(): DateTime; + /** + * Current date+time in UTC time (derived from DateTime.timeSource.now()). + */ + static nowUtc(): DateTime; + /** + * Current date+time in the given time zone (derived from DateTime.timeSource.now()). + * @param timeZone The desired time zone. + */ + static now(timeZone: TimeZone): DateTime; + /** + * Constructor. Creates current time in local timezone. + */ + constructor(); + /** + * Constructor + * @param isoString String in ISO 8601 format. Instead of ISO time zone, + * it may include a space and then and IANA time zone. + * e.g. "2007-04-05T12:30:40.500" (no time zone, naive date) + * e.g. "2007-04-05T12:30:40.500+01:00" (UTC offset without daylight saving time) + * or "2007-04-05T12:30:40.500Z" (UTC) + * or "2007-04-05T12:30:40.500 Europe/Amsterdam" (IANA time zone, with daylight saving time if applicable) + * @param timeZone if given, the date in the string is assumed to be in this time zone. + * Note that it is NOT CONVERTED to the time zone. Useful + * for strings without a time zone + */ + constructor(isoString: string, timeZone?: TimeZone); + /** + * Constructor. You provide a date, then you say whether to take the + * date.getYear()/getXxx methods or the date.getUTCYear()/date.getUTCXxx methods, + * and then you state which time zone that date is in. + * + * @param date A date object. + * @param getters Specifies which set of Date getters contains the date in the given time zone: the + * Date.getXxx() methods or the Date.getUTCXxx() methods. + * @param timeZone The time zone that the given date is assumed to be in (may be null for unaware dates) + */ + constructor(date: Date, getFuncs: DateFunctions, timeZone?: TimeZone); + /** + * Constructor. Note that unlike JavaScript dates we require fields to be in normal ranges. + * Use the add(duration) or sub(duration) for arithmetic. + * @param year The full year (e.g. 2014) + * @param month The month [1-12] (note this deviates from JavaScript Date) + * @param day The day of the month [1-31] + * @param hour The hour of the day [0-24) + * @param minute The minute of the hour [0-59] + * @param second The second of the minute [0-59] + * @param millisecond The millisecond of the second [0-999] + * @param timeZone The time zone, or null (for unaware dates) + */ + constructor(year: number, month: number, day: number, hour?: number, minute?: number, second?: number, millisecond?: number, timeZone?: TimeZone); + /** + * Constructor + * @param unixTimestamp milliseconds since 1970-01-01T00:00:00.000 + * @param timeZone the time zone that the timestamp is assumed to be in (usually UTC). + */ + constructor(unixTimestamp: number, timeZone?: TimeZone); + /** + * @return a copy of this object + */ + clone(): DateTime; + /** + * @return The time zone that the date is in. May be null for unaware dates. + */ + zone(): TimeZone; + /** + * @return the offset w.r.t. UTC in minutes. Returns 0 for unaware dates and for UTC dates. + */ + offset(): number; + /** + * @return The full year e.g. 2014 + */ + year(): number; + /** + * @return The month 1-12 (note this deviates from JavaScript Date) + */ + month(): number; + /** + * @return The day of the month 1-31 + */ + day(): number; + /** + * @return The hour 0-23 + */ + hour(): number; + /** + * @return the minutes 0-59 + */ + minute(): number; + /** + * @return the seconds 0-59 + */ + second(): number; + /** + * @return the milliseconds 0-999 + */ + millisecond(): number; + /** + * @return the day-of-week (the enum values correspond to JavaScript + * week day numbers) + */ + weekDay(): WeekDay; + /** + * @return Milliseconds since 1970-01-01T00:00:00.000Z + */ + unixUtcMillis(): number; + /** + * @return The full year e.g. 2014 + */ + utcYear(): number; + /** + * @return The UTC month 1-12 (note this deviates from JavaScript Date) + */ + utcMonth(): number; + /** + * @return The UTC day of the month 1-31 + */ + utcDay(): number; + /** + * @return The UTC hour 0-23 + */ + utcHour(): number; + /** + * @return The UTC minutes 0-59 + */ + utcMinute(): number; + /** + * @return The UTC seconds 0-59 + */ + utcSecond(): number; + /** + * @return The UTC milliseconds 0-999 + */ + utcMillisecond(): number; + /** + * @return the UTC day-of-week (the enum values correspond to JavaScript + * week day numbers) + */ + utcWeekDay(): WeekDay; + /** + * Convert this date to the given time zone (in-place). + * Throws if this date does not have a time zone. + * @return this (for chaining) + */ + convert(zone?: TimeZone): DateTime; + /** + * Returns this date converted to the given time zone. + * Unaware dates can only be converted to unaware dates (clone) + * For unaware dates, an exception is thrown + * @param zone The new time zone. This may be null to create unaware date. + * @return The converted date + */ + toZone(zone?: TimeZone): DateTime; + /** + * Convert to JavaScript date with the zone time in the getX() methods. + * Unless the timezone is local, the Date.getUTCX() methods will NOT be correct. + */ + toDate(): Date; + /** + * Add a time duration. Note that this simply adds a number + * of milliseconds to UTC and converts back to zone(), + * so in the presence of e.g. leap seconds there may be a + * shift in the seconds field if you add an hour. + * There is not DST handling and no leap second handling. + * @return this + duration + */ + add(duration: Duration): DateTime; + /** + * Add an amount of time to UTC, taking leap seconds etc into account. + * Adding e.g. 1 hour will increment the utcHour() field + * date by one. In case of DST changes, the local hour() field + * may not increase or increase by 2 hours. So if you add a month, the + * local time may vary by an hour. There will not be a shift + * in seconds due to leap seconds. + */ + add(amount: number, unit: TimeUnit): DateTime; + /** + * Add an amount of time to the zone time, as regularly as possible. + * Adding e.g. 1 hour will increment the hour() field of the zone + * date by one. In case of DST changes, the utcHour() field may + * increase by 1 or increase by 2. Adding a day will leave the time portion + * intact. However, adding an hour around a forward DST change adds two hours, + * since there is a zone time (2AM in Holland) that does not exist. + */ + addLocal(amount: number, unit: TimeUnit): DateTime; + /** + * Same as add(-1*duration); + */ + sub(duration: Duration): DateTime; + /** + * Same as add(-1*amount, unit); + */ + sub(amount: number, unit: TimeUnit): DateTime; + /** + * Same as addLocal(-1*amount, unit); + */ + subLocal(amount: number, unit: TimeUnit): DateTime; + /** + * Time difference between two DateTimes + * @return this - other + */ + diff(other: DateTime): Duration; + /** + * @return True iff (this < other) + */ + lessThan(other: DateTime): boolean; + /** + * @return True iff (this <= other) + */ + lessEqual(other: DateTime): boolean; + /** + * @return True iff this and other represent the same time in UTC + */ + equals(other: DateTime): boolean; + /** + * @return True iff this and other represent the same time and + * have the same zone + */ + identical(other: DateTime): boolean; + /** + * @return True iff this > other + */ + greaterThan(other: DateTime): boolean; + /** + * @return True iff this >= other + */ + greaterEqual(other: DateTime): boolean; + /** + * Proper ISO 8601 format string with any IANA zone converted to ISO offset + * E.g. "2014-01-01T23:15:33+01:00" for Europe/Amsterdam + */ + toIsoString(): string; + /** + * Modified ISO 8601 format string with IANA name if applicable. + * E.g. "2014-01-01T23:15:33.000 Europe/Amsterdam" + */ + toString(): string; + /** + * Modified ISO 8601 format string in UTC without time zone info + */ + toUtcString(): string; + } + /** + * Specifies how the period should repeat across the day + * during DST changes. + */ + export enum PeriodDst { + /** + * Keep repeating in similar intervals measured in UTC, + * unaffected by Daylight Saving Time. + * E.g. a repetition of one hour will take one real hour + * every time, even in a time zone with DST. + * Leap seconds, leap days and month length + * differences will still make the intervals different. + */ + RegularIntervals = 0, + /** + * Ensure that the time at which the intervals occur stay + * at the same place in the day, local time. So e.g. + * a period of one day, starting at 8:05AM Europe/Amsterdam time + * will always start at 8:05 Europe/Amsterdam. This means that + * in UTC time, some intervals will be 25 hours and some + * 23 hours during DST changes. + * Another example: an hourly interval will be hourly in local time, + * skipping an hour in UTC for a DST backward change. + */ + RegularLocalTime = 1, + } + /** + * Convert a PeriodDst to a string: "regular intervals" or "regular local time" + */ + export function periodDstToString(p: PeriodDst): string; + /** + * Repeating time period: consists of a starting point and + * a time length. This class accounts for leap seconds and leap days. + */ + export class Period { + /** + * Constructor + * LIMITATION: if dst equals RegularLocalTime, and unit is Second, Minute or Hour, + * then the amount must be a factor of 24. So 120 seconds is allowed while 121 seconds is not. + * This is due to the enormous processing power required by these cases. They are not + * implemented and you will get an assert. + * + * @param start The start of the period. If the period is in Months or Years, and + * the day is 29 or 30 or 31, the results are maximised to end-of-month. + * @param amount The amount of units. + * @param unit The unit. + * @param dst Specifies how to handle Daylight Saving Time. Not relevant + * if the time zone of the start datetime does not have DST. + */ + constructor(start: DateTime, amount: number, unit: TimeUnit, dst: PeriodDst); + /** + * The start date + */ + start(): DateTime; + /** + * The amount of units + */ + amount(): number; + /** + * The unit + */ + unit(): TimeUnit; + /** + * The dst handling mode + */ + dst(): PeriodDst; + /** + * The first occurrence of the period greater than + * the given date. The given date need not be at a period boundary. + * Pre: the fromdate and startdate must either both have timezones or not + * @param fromDate: the date after which to return the next date + * @return the first date matching the period after fromDate, given + * in the same zone as the fromDate. + */ + findFirst(fromDate: DateTime): DateTime; + /** + * Returns the next timestamp in the period. The given timestamp must + * be at a period boundary, otherwise the answer is incorrect. + * This function has MUCH better performance than findFirst. + * Returns the datetime "count" times away from the given datetime. + * @param prev Boundary date. Must have a time zone (any time zone) iff the period start date has one. + * @param count Optional, must be >= 1 and whole. + * @return (prev + count * period), in the same timezone as prev. + */ + findNext(prev: DateTime, count?: number): DateTime; + /** + * Returns an ISO duration string + * P[n]Y[n]M[n]DT[n]H[n]M[n][.n]S or P[n]W + */ + toIsoString(): string; + /** + * A string representation e.g. + * "10 years, starting at 2014-03-01T12:00:00 Europe/Amsterdam keeping regular intervals". + */ + toString(): string; + } +} + diff --git a/timezonecomplete/timezonecomplete-1.4.6.d.ts b/timezonecomplete/timezonecomplete-1.4.6.d.ts index bd70278d5..afec37d0f 100644 --- a/timezonecomplete/timezonecomplete-1.4.6.d.ts +++ b/timezonecomplete/timezonecomplete-1.4.6.d.ts @@ -1,1004 +1,1004 @@ -// Type definitions for timezonecomplete 1.4.6 -// Project: https://github.com/SpiritIT/timezonecomplete -// Definitions by: Rogier Schouten -// Definitions: https://github.com/borisyankov/DefinitelyTyped -// Generated by dts-bundle v0.2.0 - -declare module 'timezonecomplete-1.4.6' { - import basics = require("__timezonecomplete/basics"); - export import TimeUnit = basics.TimeUnit; - export import WeekDay = basics.WeekDay; - export import isLeapYear = basics.isLeapYear; - export import daysInMonth = basics.daysInMonth; - export import daysInYear = basics.daysInYear; - export import dayOfYear = basics.dayOfYear; - export import lastWeekDayOfMonth = basics.lastWeekDayOfMonth; - export import weekDayOnOrAfter = basics.weekDayOnOrAfter; - export import weekDayOnOrBefore = basics.weekDayOnOrBefore; - import datetime = require("__timezonecomplete/datetime"); - export import DateTime = datetime.DateTime; - import duration = require("__timezonecomplete/duration"); - export import Duration = duration.Duration; - import javascript = require("__timezonecomplete/javascript"); - export import DateFunctions = javascript.DateFunctions; - import period = require("__timezonecomplete/period"); - export import Period = period.Period; - export import PeriodDst = period.PeriodDst; - export import periodDstToString = period.periodDstToString; - import timesource = require("__timezonecomplete/timesource"); - export import TimeSource = timesource.TimeSource; - export import RealTimeSource = timesource.RealTimeSource; - import timezone = require("__timezonecomplete/timezone"); - export import NormalizeOption = timezone.NormalizeOption; - export import TimeZoneKind = timezone.TimeZoneKind; - export import TimeZone = timezone.TimeZone; -} - -declare module '__timezonecomplete/basics' { - import javascript = require("__timezonecomplete/javascript"); - /** - * Day-of-week. Note the enum values correspond to JavaScript day-of-week: - * Sunday = 0, Monday = 1 etc - */ - export enum WeekDay { - Sunday = 0, - Monday = 1, - Tuesday = 2, - Wednesday = 3, - Thursday = 4, - Friday = 5, - Saturday = 6, - } - /** - * Time units - */ - export enum TimeUnit { - Second = 0, - Minute = 1, - Hour = 2, - Day = 3, - Week = 4, - Month = 5, - Year = 6, - } - /** - * @return True iff the given year is a leap year. - */ - export function isLeapYear(year: number): boolean; - /** - * The days in a given year - */ - export function daysInYear(year: number): number; - /** - * @param year The full year - * @param month The month 1-12 - * @return The number of days in the given month - */ - export function daysInMonth(year: number, month: number): number; - /** - * Returns the day of the year of the given date [0..365]. January first is 0. - * - * @param year The year e.g. 1986 - * @param month Month 1-12 - * @param day Day of month 1-31 - */ - export function dayOfYear(year: number, month: number, day: number): number; - /** - * Returns the last instance of the given weekday in the given month - * - * @param year The year - * @param month the month 1-12 - * @param weekDay the desired week day - * - * @return the last occurrence of the week day in the month - */ - export function lastWeekDayOfMonth(year: number, month: number, weekDay: WeekDay): number; - /** - * Returns the day-of-month that is on the given weekday and which is >= the given day. - * Throws if the month has no such day. - */ - export function weekDayOnOrAfter(year: number, month: number, day: number, weekDay: WeekDay): number; - /** - * Returns the day-of-month that is on the given weekday and which is <= the given day. - * Throws if the month has no such day. - */ - export function weekDayOnOrBefore(year: number, month: number, day: number, weekDay: WeekDay): number; - /** - * Convert a unix milli timestamp into a TimeT structure. - * This does NOT take leap seconds into account. - */ - export function unixToTimeNoLeapSecs(unixMillis: number): TimeStruct; - /** - * Convert a year, month, day etc into a unix milli timestamp. - * This does NOT take leap seconds into account. - * - * @param year Year e.g. 1970 - * @param month Month 1-12 - * @param day Day 1-31 - * @param hour Hour 0-23 - * @param minute Minute 0-59 - * @param second Second 0-59 (no leap seconds) - * @param milli Millisecond 0-999 - */ - export function timeToUnixNoLeapSecs(year?: number, month?: number, day?: number, hour?: number, minute?: number, second?: number, milli?: number): number; - /** - * Convert a TimeT structure into a unix milli timestamp. - * This does NOT take leap seconds into account. - */ - export function timeToUnixNoLeapSecs(tm: TimeStruct): number; - /** - * Return the day-of-week. - * This does NOT take leap seconds into account. - */ - export function weekDayNoLeapSecs(unixMillis: number): WeekDay; - /** - * Basic representation of a date and time - */ - export class TimeStruct { - /** - * Year, 1970-... - */ - year: number; - /** - * Month 1-12 - */ - month: number; - /** - * Day of month, 1-31 - */ - day: number; - /** - * Hour 0-23 - */ - hour: number; - /** - * Minute 0-59 - */ - minute: number; - /** - * Seconds, 0-59 - */ - second: number; - /** - * Milliseconds 0-999 - */ - milli: number; - /** - * Create a TimeStruct from a number of unix milliseconds - */ - static fromUnix(unixMillis: number): TimeStruct; - /** - * Create a TimeStruct from a JavaScript date - * - * @param d The date - * @param df Which functions to take (getX() or getUTCX()) - */ - static fromDate(d: Date, df: javascript.DateFunctions): TimeStruct; - /** - * Returns a TimeStruct from an ISO 8601 string WITHOUT time zone - */ - static fromString(s: string): TimeStruct; - /** - * Constructor - * - * @param year Year e.g. 1970 - * @param month Month 1-12 - * @param day Day 1-31 - * @param hour Hour 0-23 - * @param minute Minute 0-59 - * @param second Second 0-59 (no leap seconds) - * @param milli Millisecond 0-999 - */ - constructor(/** - * Year, 1970-... - */ - year?: number, /** - * Month 1-12 - */ - month?: number, /** - * Day of month, 1-31 - */ - day?: number, /** - * Hour 0-23 - */ - hour?: number, /** - * Minute 0-59 - */ - minute?: number, /** - * Seconds, 0-59 - */ - second?: number, /** - * Milliseconds 0-999 - */ - milli?: number); - /** - * Validate a TimeStruct, returns false if invalid. - */ - validate(): boolean; - /** - * The day-of-year 0-365 - */ - yearDay(): number; - /** - * Returns this time as a unix millisecond timestamp - * Does NOT take leap seconds into account. - */ - toUnixNoLeapSecs(): number; - /** - * Deep equals - */ - equals(other: TimeStruct): boolean; - /** - * < operator - */ - lessThan(other: TimeStruct): boolean; - clone(): TimeStruct; - valueOf(): number; - /** - * ISO 8601 string YYYY-MM-DDThh:mm:ss.nnn - */ - toString(): string; - inspect(): string; - } -} - -declare module '__timezonecomplete/datetime' { - import basics = require("__timezonecomplete/basics"); - import duration = require("__timezonecomplete/duration"); - import javascript = require("__timezonecomplete/javascript"); - import timesource = require("__timezonecomplete/timesource"); - import timezone = require("__timezonecomplete/timezone"); - /** - * DateTime class which is time zone-aware - * and which can be mocked for testing purposes. - */ - export class DateTime { - /** - * Actual time source in use. Setting this property allows to - * fake time in tests. DateTime.nowLocal() and DateTime.nowUtc() - * use this property for obtaining the current time. - */ - static timeSource: timesource.TimeSource; - /** - * Current date+time in local time (derived from DateTime.timeSource.now()). - */ - static nowLocal(): DateTime; - /** - * Current date+time in UTC time (derived from DateTime.timeSource.now()). - */ - static nowUtc(): DateTime; - /** - * Current date+time in the given time zone (derived from DateTime.timeSource.now()). - * @param timeZone The desired time zone. - */ - static now(timeZone: timezone.TimeZone): DateTime; - /** - * Constructor. Creates current time in local timezone. - */ - constructor(); - /** - * Constructor - * Non-existing local times are normalized by rounding up to the next DST offset. - * - * @param isoString String in ISO 8601 format. Instead of ISO time zone, - * it may include a space and then and IANA time zone. - * e.g. "2007-04-05T12:30:40.500" (no time zone, naive date) - * e.g. "2007-04-05T12:30:40.500+01:00" (UTC offset without daylight saving time) - * or "2007-04-05T12:30:40.500Z" (UTC) - * or "2007-04-05T12:30:40.500 Europe/Amsterdam" (IANA time zone, with daylight saving time if applicable) - * @param timeZone if given, the date in the string is assumed to be in this time zone. - * Note that it is NOT CONVERTED to the time zone. Useful - * for strings without a time zone - */ - constructor(isoString: string, timeZone?: timezone.TimeZone); - /** - * Constructor. You provide a date, then you say whether to take the - * date.getYear()/getXxx methods or the date.getUTCYear()/date.getUTCXxx methods, - * and then you state which time zone that date is in. - * Non-existing local times are normalized by rounding up to the next DST offset. - * Note that the Date class has bugs and inconsistencies when constructing them with times around - * DST changes. - * - * @param date A date object. - * @param getters Specifies which set of Date getters contains the date in the given time zone: the - * Date.getXxx() methods or the Date.getUTCXxx() methods. - * @param timeZone The time zone that the given date is assumed to be in (may be null for unaware dates) - */ - constructor(date: Date, getFuncs: javascript.DateFunctions, timeZone?: timezone.TimeZone); - /** - * Constructor. Note that unlike JavaScript dates we require fields to be in normal ranges. - * Use the add(duration) or sub(duration) for arithmetic. - * @param year The full year (e.g. 2014) - * @param month The month [1-12] (note this deviates from JavaScript Date) - * @param day The day of the month [1-31] - * @param hour The hour of the day [0-24) - * @param minute The minute of the hour [0-59] - * @param second The second of the minute [0-59] - * @param millisecond The millisecond of the second [0-999] - * @param timeZone The time zone, or null (for unaware dates) - */ - constructor(year: number, month: number, day: number, hour?: number, minute?: number, second?: number, millisecond?: number, timeZone?: timezone.TimeZone); - /** - * Constructor - * @param unixTimestamp milliseconds since 1970-01-01T00:00:00.000 - * @param timeZone the time zone that the timestamp is assumed to be in (usually UTC). - */ - constructor(unixTimestamp: number, timeZone?: timezone.TimeZone); - /** - * @return a copy of this object - */ - clone(): DateTime; - /** - * @return The time zone that the date is in. May be null for unaware dates. - */ - zone(): timezone.TimeZone; - /** - * @return the offset w.r.t. UTC in minutes. Returns 0 for unaware dates and for UTC dates. - */ - offset(): number; - /** - * @return The full year e.g. 2014 - */ - year(): number; - /** - * @return The month 1-12 (note this deviates from JavaScript Date) - */ - month(): number; - /** - * @return The day of the month 1-31 - */ - day(): number; - /** - * @return The hour 0-23 - */ - hour(): number; - /** - * @return the minutes 0-59 - */ - minute(): number; - /** - * @return the seconds 0-59 - */ - second(): number; - /** - * @return the milliseconds 0-999 - */ - millisecond(): number; - /** - * @return the day-of-week (the enum values correspond to JavaScript - * week day numbers) - */ - weekDay(): basics.WeekDay; - /** - * @return Milliseconds since 1970-01-01T00:00:00.000Z - */ - unixUtcMillis(): number; - /** - * @return The full year e.g. 2014 - */ - utcYear(): number; - /** - * @return The UTC month 1-12 (note this deviates from JavaScript Date) - */ - utcMonth(): number; - /** - * @return The UTC day of the month 1-31 - */ - utcDay(): number; - /** - * @return The UTC hour 0-23 - */ - utcHour(): number; - /** - * @return The UTC minutes 0-59 - */ - utcMinute(): number; - /** - * @return The UTC seconds 0-59 - */ - utcSecond(): number; - /** - * @return The UTC milliseconds 0-999 - */ - utcMillisecond(): number; - /** - * @return the UTC day-of-week (the enum values correspond to JavaScript - * week day numbers) - */ - utcWeekDay(): basics.WeekDay; - /** - * Convert this date to the given time zone (in-place). - * Throws if this date does not have a time zone. - * @return this (for chaining) - */ - convert(zone?: timezone.TimeZone): DateTime; - /** - * Returns this date converted to the given time zone. - * Unaware dates can only be converted to unaware dates (clone) - * Converting an unaware date to an aware date throws an exception. Use the constructor - * if you really need to do that. - * - * @param zone The new time zone. This may be null to create unaware date. - * @return The converted date - */ - toZone(zone?: timezone.TimeZone): DateTime; - /** - * Convert to JavaScript date with the zone time in the getX() methods. - * Unless the timezone is local, the Date.getUTCX() methods will NOT be correct. - * This is because Date calculates getUTCX() from getX() applying local time zone. - */ - toDate(): Date; - /** - * Add a time duration relative to UTC. Note that this simply adds a number - * of milliseconds to UTC and converts back to zone(), - * There is not DST handling. - * @return this + duration - */ - add(duration: duration.Duration): DateTime; - /** - * Add an amount of time relative to UTC, as regularly as possible. - * - * Adding e.g. 1 hour will increment the utcHour() field, adding 1 month - * increments the utcMonth() field. - * Adding an amount of units leaves lower units intact. E.g. - * adding a month will leave the day() field untouched if possible. - * - * Note adding Months or Years will clamp the date to the end-of-month if - * the start date was at the end of a month, i.e. contrary to JavaScript - * Date#setUTCMonth() it will not overflow into the next month - * - * In case of DST changes, the utc time fields are still untouched but local - * time fields may shift. - */ - add(amount: number, unit: basics.TimeUnit): DateTime; - /** - * Add an amount of time to the zone time, as regularly as possible. - * - * Adding e.g. 1 hour will increment the hour() field of the zone - * date by one. In case of DST changes, the time fields may additionally - * increase by the DST offset, if a non-existing local time would - * be reached otherwise. - * - * Adding a unit of time will leave lower-unit fields intact, unless the result - * would be a non-existing time. Then an extra DST offset is added. - * - * Note adding Months or Years will clamp the date to the end-of-month if - * the start date was at the end of a month, i.e. contrary to JavaScript - * Date#setUTCMonth() it will not overflow into the next month - */ - addLocal(amount: number, unit: basics.TimeUnit): DateTime; - /** - * Same as add(-1*duration); - */ - sub(duration: duration.Duration): DateTime; - /** - * Same as add(-1*amount, unit); - */ - sub(amount: number, unit: basics.TimeUnit): DateTime; - /** - * Same as addLocal(-1*amount, unit); - */ - subLocal(amount: number, unit: basics.TimeUnit): DateTime; - /** - * Time difference between two DateTimes - * @return this - other - */ - diff(other: DateTime): duration.Duration; - /** - * @return True iff (this < other) - */ - lessThan(other: DateTime): boolean; - /** - * @return True iff (this <= other) - */ - lessEqual(other: DateTime): boolean; - /** - * @return True iff this and other represent the same time in UTC - */ - equals(other: DateTime): boolean; - /** - * @return True iff this and other represent the same time and - * have the same zone - */ - identical(other: DateTime): boolean; - /** - * @return True iff this > other - */ - greaterThan(other: DateTime): boolean; - /** - * @return True iff this >= other - */ - greaterEqual(other: DateTime): boolean; - /** - * Proper ISO 8601 format string with any IANA zone converted to ISO offset - * E.g. "2014-01-01T23:15:33+01:00" for Europe/Amsterdam - */ - toIsoString(): string; - /** - * Modified ISO 8601 format string with IANA name if applicable. - * E.g. "2014-01-01T23:15:33.000 Europe/Amsterdam" - */ - toString(): string; - /** - * Used by util.inspect() - */ - inspect(): string; - /** - * Modified ISO 8601 format string in UTC without time zone info - */ - toUtcString(): string; - } -} - -declare module '__timezonecomplete/duration' { - /** - * Time duration. Create one e.g. like this: var d = Duration.hours(1). - * Note that time durations do not take leap seconds etc. into account: - * one hour is simply represented as 3600000 milliseconds. - */ - export class Duration { - /** - * Construct a time duration - * @param n Number of hours - * @return A duration of n hours - */ - static hours(n: number): Duration; - /** - * Construct a time duration - * @param n Number of minutes - * @return A duration of n minutes - */ - static minutes(n: number): Duration; - /** - * Construct a time duration - * @param n Number of seconds - * @return A duration of n seconds - */ - static seconds(n: number): Duration; - /** - * Construct a time duration - * @param n Number of milliseconds - * @return A duration of n milliseconds - */ - static milliseconds(n: number): Duration; - /** - * Construct a time duration of 0 - */ - constructor(); - /** - * Construct a time duration from a number of milliseconds - */ - constructor(milliseconds: number); - /** - * Construct a time duration from a string in format - * [-]h[:m[:s[.n]]] e.g. -01:00:30.501 - */ - constructor(input: string); - /** - * @return another instance of Duration with the same value. - */ - clone(): Duration; - /** - * The entire duration in milliseconds (negative or positive) - */ - milliseconds(): number; - /** - * The millisecond part of the duration (always positive) - * @return e.g. 400 for a -01:02:03.400 duration - */ - millisecond(): number; - /** - * The entire duration in seconds (negative or positive, fractional) - * @return e.g. 1.5 for a 1500 milliseconds duration - */ - seconds(): number; - /** - * The second part of the duration (always positive) - * @return e.g. 3 for a -01:02:03.400 duration - */ - second(): number; - /** - * The entire duration in minutes (negative or positive, fractional) - * @return e.g. 1.5 for a 90000 milliseconds duration - */ - minutes(): number; - /** - * The minute part of the duration (always positive) - * @return e.g. 2 for a -01:02:03.400 duration - */ - minute(): number; - /** - * The entire duration in hours (negative or positive, fractional) - * @return e.g. 1.5 for a 5400000 milliseconds duration - */ - hours(): number; - /** - * The hour part of the duration (always positive). - * Note that this part can exceed 23 hours, because for - * now, we do not have a days() function - * @return e.g. 25 for a -25:02:03.400 duration - */ - wholeHours(): number; - /** - * Sign - * @return "-" if the duration is negative - */ - sign(): string; - /** - * @return True iff (this < other) - */ - lessThan(other: Duration): boolean; - /** - * @return True iff this and other represent the same time duration - */ - equals(other: Duration): boolean; - /** - * @return True iff this > other - */ - greaterThan(other: Duration): boolean; - /** - * @return The minimum (most negative) of this and other - */ - min(other: Duration): Duration; - /** - * @return The maximum (most positive) of this and other - */ - max(other: Duration): Duration; - /** - * Multiply with a fixed number. - * @return a new Duration of (this * value) - */ - multiply(value: number): Duration; - /** - * Divide by a fixed number. - * @return a new Duration of (this / value) - */ - divide(value: number): Duration; - /** - * Add a duration. - * @return a new Duration of (this + value) - */ - add(value: Duration): Duration; - /** - * Subtract a duration. - * @return a new Duration of (this - value) - */ - sub(value: Duration): Duration; - /** - * String in [-]hh:mm:ss.nnn notation. All fields are - * always present except the sign. - */ - toFullString(): string; - /** - * String in [-]hh[:mm[:ss[.nnn]]] notation. Fields are - * added as necessary - */ - toString(): string; - /** - * Used by util.inspect() - */ - inspect(): string; - } -} - -declare module '__timezonecomplete/javascript' { - /** - * Indicates how a Date object should be interpreted. - * Either we can take getYear(), getMonth() etc for our field - * values, or we can take getUTCYear(), getUtcMonth() etc to do that. - */ - export enum DateFunctions { - /** - * Use the Date.getFullYear(), Date.getMonth(), ... functions. - */ - Get = 0, - /** - * Use the Date.getUTCFullYear(), Date.getUTCMonth(), ... functions. - */ - GetUTC = 1, - } -} - -declare module '__timezonecomplete/period' { - import basics = require("__timezonecomplete/basics"); - import datetime = require("__timezonecomplete/datetime"); - /** - * Specifies how the period should repeat across the day - * during DST changes. - */ - export enum PeriodDst { - /** - * Keep repeating in similar intervals measured in UTC, - * unaffected by Daylight Saving Time. - * E.g. a repetition of one hour will take one real hour - * every time, even in a time zone with DST. - * Leap seconds, leap days and month length - * differences will still make the intervals different. - */ - RegularIntervals = 0, - /** - * Ensure that the time at which the intervals occur stay - * at the same place in the day, local time. So e.g. - * a period of one day, starting at 8:05AM Europe/Amsterdam time - * will always start at 8:05 Europe/Amsterdam. This means that - * in UTC time, some intervals will be 25 hours and some - * 23 hours during DST changes. - * Another example: an hourly interval will be hourly in local time, - * skipping an hour in UTC for a DST backward change. - */ - RegularLocalTime = 1, - } - /** - * Convert a PeriodDst to a string: "regular intervals" or "regular local time" - */ - export function periodDstToString(p: PeriodDst): string; - /** - * Repeating time period: consists of a starting point and - * a time length. This class accounts for leap seconds and leap days. - */ - export class Period { - /** - * Constructor - * LIMITATION: if dst equals RegularLocalTime, and unit is Second, Minute or Hour, - * then the amount must be a factor of 24. So 120 seconds is allowed while 121 seconds is not. - * This is due to the enormous processing power required by these cases. They are not - * implemented and you will get an assert. - * - * @param start The start of the period. If the period is in Months or Years, and - * the day is 29 or 30 or 31, the results are maximised to end-of-month. - * @param amount The amount of units. - * @param unit The unit. - * @param dst Specifies how to handle Daylight Saving Time. Not relevant - * if the time zone of the start datetime does not have DST. - */ - constructor(start: datetime.DateTime, amount: number, unit: basics.TimeUnit, dst: PeriodDst); - /** - * The start date - */ - start(): datetime.DateTime; - /** - * The amount of units - */ - amount(): number; - /** - * The unit - */ - unit(): basics.TimeUnit; - /** - * The dst handling mode - */ - dst(): PeriodDst; - /** - * The first occurrence of the period greater than - * the given date. The given date need not be at a period boundary. - * Pre: the fromdate and startdate must either both have timezones or not - * @param fromDate: the date after which to return the next date - * @return the first date matching the period after fromDate, given - * in the same zone as the fromDate. - */ - findFirst(fromDate: datetime.DateTime): datetime.DateTime; - /** - * Returns the next timestamp in the period. The given timestamp must - * be at a period boundary, otherwise the answer is incorrect. - * This function has MUCH better performance than findFirst. - * Returns the datetime "count" times away from the given datetime. - * @param prev Boundary date. Must have a time zone (any time zone) iff the period start date has one. - * @param count Optional, must be >= 1 and whole. - * @return (prev + count * period), in the same timezone as prev. - */ - findNext(prev: datetime.DateTime, count?: number): datetime.DateTime; - /** - * Returns an ISO duration string e.g. - * 2014-01-01T12:00:00.000+01:00/P1H - * 2014-01-01T12:00:00.000+01:00/PT1M (one minute) - * 2014-01-01T12:00:00.000+01:00/P1M (one month) - */ - toIsoString(): string; - /** - * A string representation e.g. - * "10 years, starting at 2014-03-01T12:00:00 Europe/Amsterdam, keeping regular intervals". - */ - toString(): string; - /** - * Used by util.inspect() - */ - inspect(): string; - } -} - -declare module '__timezonecomplete/timesource' { - /** - * For testing purposes, we often need to manipulate what the current - * time is. This is an interface for a custom time source object - * so in tests you can use a custom time source. - */ - export interface TimeSource { - /** - * Return the current date+time as a javascript Date object - */ - now(): Date; - } - /** - * Default time source, returns actual time - */ - export class RealTimeSource implements TimeSource { - now(): Date; - } -} - -declare module '__timezonecomplete/timezone' { - import javascript = require("__timezonecomplete/javascript"); - /** - * The type of time zone - */ - export enum TimeZoneKind { - /** - * Local time offset as determined by JavaScript Date class. - */ - Local = 0, - /** - * Fixed offset from UTC, without DST. - */ - Offset = 1, - /** - * IANA timezone managed through Olsen TZ database. Includes - * DST if applicable. - */ - Proper = 2, - } - /** - * Option for TimeZone#normalizeLocal() - */ - export enum NormalizeOption { - /** - * Normalize non-existing times by ADDING the DST offset - */ - Up = 0, - /** - * Normalize non-existing times by SUBTRACTING the DST offset - */ - Down = 1, - } - /** - * Time zone. The object is immutable because it is cached: - * requesting a time zone twice yields the very same object. - * Note that we use time zone offsets inverted w.r.t. JavaScript Date.getTimezoneOffset(), - * i.e. offset 90 means +01:30. - * - * Time zones come in three flavors: the local time zone, as calculated by JavaScript Date, - * a fixed offset ("+01:30") without DST, or a IANA timezone ("Europe/Amsterdam") with DST - * applied depending on the time zone rules. - */ - export class TimeZone { - /** - * The local time zone for a given date. Note that - * the time zone varies with the date: amsterdam time for - * 2014-01-01 is +01:00 and amsterdam time for 2014-07-01 is +02:00 - */ - static local(): TimeZone; - /** - * The UTC time zone. - */ - static utc(): TimeZone; - /** - * Returns a time zone object from the cache. If it does not exist, it is created. - * @return The time zone with the given offset w.r.t. UTC in minutes, e.g. 90 for +01:30 - */ - static zone(offset: number): TimeZone; - /** - * Returns a time zone object from the cache. If it does not exist, it is created. - * @param s: Empty string for local time, a TZ database time zone name (e.g. Europe/Amsterdam) - * or an offset string (either +01:30, +0130, +01, Z). For a full list of names, see: - * https://en.wikipedia.org/wiki/List_of_tz_database_time_zones - */ - static zone(s: string): TimeZone; - /** - * Do not use this constructor, use the static - * TimeZone.zone() method instead. - * @param name NORMALIZED name, assumed to be correct - */ - constructor(name: string); - /** - * The time zone identifier. Can be an offset "-01:30" or an - * IANA time zone name "Europe/Amsterdam", or "localtime" for - * the local time zone. - */ - name(): string; - /** - * The kind of time zone (Local/Offset/Proper) - */ - kind(): TimeZoneKind; - /** - * Equality operator. Maps zero offsets and different names for UTC onto - * each other. Other time zones are not mapped onto each other. - */ - equals(other: TimeZone): boolean; - /** - * Is this zone equivalent to UTC? - */ - isUtc(): boolean; - /** - * Does this zone have Daylight Saving Time at all? - */ - hasDst(): boolean; - /** - * Calculate timezone offset from a UTC time. - * @param year local full year - * @param month local month 1-12 (note this deviates from JavaScript date) - * @param day local day of month 1-31 - * @param hour local hour 0-23 - * @param minute local minute 0-59 - * @param second local second 0-59 - * @param millisecond local millisecond 0-999 - * @return the offset of this time zone with respect to UTC at the given time, in minutes. - */ - offsetForUtc(year: number, month: number, day: number, hour?: number, minute?: number, second?: number, millisecond?: number): number; - /** - * Calculate timezone offset from a zone-local time (NOT a UTC time). - * @param year local full year - * @param month local month 1-12 (note this deviates from JavaScript date) - * @param day local day of month 1-31 - * @param hour local hour 0-23 - * @param minute local minute 0-59 - * @param second local second 0-59 - * @param millisecond local millisecond 0-999 - * @return the offset of this time zone with respect to UTC at the given time, in minutes. - */ - offsetForZone(year: number, month: number, day: number, hour?: number, minute?: number, second?: number, millisecond?: number): number; - /** - * Note: will be removed in version 2.0.0 - * - * Convenience function, takes values from a Javascript Date - * Calls offsetForUtc() with the contents of the date - * - * @param date: the date - * @param funcs: the set of functions to use: get() or getUTC() - */ - offsetForUtcDate(date: Date, funcs: javascript.DateFunctions): number; - /** - * Note: will be removed in version 2.0.0 - * - * Convenience function, takes values from a Javascript Date - * Calls offsetForUtc() with the contents of the date - * - * @param date: the date - * @param funcs: the set of functions to use: get() or getUTC() - */ - offsetForZoneDate(date: Date, funcs: javascript.DateFunctions): number; - /** - * Normalizes non-existing local times by adding a forward offset change. - * During a forward standard offset change or DST offset change, some amount of - * local time is skipped. Therefore, this amount of local time does not exist. - * This function adds the amount of forward change to any non-existing time. After all, - * this is probably what the user meant. - * - * @param localUnixMillis Unix timestamp in zone time - * @param opt (optional) Round up or down? Default: up - * - * @returns Unix timestamp in zone time, normalized. - */ - normalizeZoneTime(localUnixMillis: number, opt?: NormalizeOption): number; - /** - * The time zone identifier (normalized). - * Either "localtime", IANA name, or "+hh:mm" offset. - */ - toString(): string; - /** - * Used by util.inspect() - */ - inspect(): string; - /** - * Convert an offset number into an offset string - * @param offset The offset in minutes from UTC e.g. 90 minutes - * @return the offset in ISO notation "+01:30" for +90 minutes - */ - static offsetToString(offset: number): string; - /** - * String to offset conversion. - * @param s Formats: "-01:00", "-0100", "-01", "Z" - * @return offset w.r.t. UTC in minutes - */ - static stringToOffset(s: string): number; - } -} - +// Type definitions for timezonecomplete 1.4.6 +// Project: https://github.com/SpiritIT/timezonecomplete +// Definitions by: Rogier Schouten +// Definitions: https://github.com/borisyankov/DefinitelyTyped +// Generated by dts-bundle v0.2.0 + +declare module 'timezonecomplete-1.4.6' { + import basics = require("__timezonecomplete/basics"); + export import TimeUnit = basics.TimeUnit; + export import WeekDay = basics.WeekDay; + export import isLeapYear = basics.isLeapYear; + export import daysInMonth = basics.daysInMonth; + export import daysInYear = basics.daysInYear; + export import dayOfYear = basics.dayOfYear; + export import lastWeekDayOfMonth = basics.lastWeekDayOfMonth; + export import weekDayOnOrAfter = basics.weekDayOnOrAfter; + export import weekDayOnOrBefore = basics.weekDayOnOrBefore; + import datetime = require("__timezonecomplete/datetime"); + export import DateTime = datetime.DateTime; + import duration = require("__timezonecomplete/duration"); + export import Duration = duration.Duration; + import javascript = require("__timezonecomplete/javascript"); + export import DateFunctions = javascript.DateFunctions; + import period = require("__timezonecomplete/period"); + export import Period = period.Period; + export import PeriodDst = period.PeriodDst; + export import periodDstToString = period.periodDstToString; + import timesource = require("__timezonecomplete/timesource"); + export import TimeSource = timesource.TimeSource; + export import RealTimeSource = timesource.RealTimeSource; + import timezone = require("__timezonecomplete/timezone"); + export import NormalizeOption = timezone.NormalizeOption; + export import TimeZoneKind = timezone.TimeZoneKind; + export import TimeZone = timezone.TimeZone; +} + +declare module '__timezonecomplete/basics' { + import javascript = require("__timezonecomplete/javascript"); + /** + * Day-of-week. Note the enum values correspond to JavaScript day-of-week: + * Sunday = 0, Monday = 1 etc + */ + export enum WeekDay { + Sunday = 0, + Monday = 1, + Tuesday = 2, + Wednesday = 3, + Thursday = 4, + Friday = 5, + Saturday = 6, + } + /** + * Time units + */ + export enum TimeUnit { + Second = 0, + Minute = 1, + Hour = 2, + Day = 3, + Week = 4, + Month = 5, + Year = 6, + } + /** + * @return True iff the given year is a leap year. + */ + export function isLeapYear(year: number): boolean; + /** + * The days in a given year + */ + export function daysInYear(year: number): number; + /** + * @param year The full year + * @param month The month 1-12 + * @return The number of days in the given month + */ + export function daysInMonth(year: number, month: number): number; + /** + * Returns the day of the year of the given date [0..365]. January first is 0. + * + * @param year The year e.g. 1986 + * @param month Month 1-12 + * @param day Day of month 1-31 + */ + export function dayOfYear(year: number, month: number, day: number): number; + /** + * Returns the last instance of the given weekday in the given month + * + * @param year The year + * @param month the month 1-12 + * @param weekDay the desired week day + * + * @return the last occurrence of the week day in the month + */ + export function lastWeekDayOfMonth(year: number, month: number, weekDay: WeekDay): number; + /** + * Returns the day-of-month that is on the given weekday and which is >= the given day. + * Throws if the month has no such day. + */ + export function weekDayOnOrAfter(year: number, month: number, day: number, weekDay: WeekDay): number; + /** + * Returns the day-of-month that is on the given weekday and which is <= the given day. + * Throws if the month has no such day. + */ + export function weekDayOnOrBefore(year: number, month: number, day: number, weekDay: WeekDay): number; + /** + * Convert a unix milli timestamp into a TimeT structure. + * This does NOT take leap seconds into account. + */ + export function unixToTimeNoLeapSecs(unixMillis: number): TimeStruct; + /** + * Convert a year, month, day etc into a unix milli timestamp. + * This does NOT take leap seconds into account. + * + * @param year Year e.g. 1970 + * @param month Month 1-12 + * @param day Day 1-31 + * @param hour Hour 0-23 + * @param minute Minute 0-59 + * @param second Second 0-59 (no leap seconds) + * @param milli Millisecond 0-999 + */ + export function timeToUnixNoLeapSecs(year?: number, month?: number, day?: number, hour?: number, minute?: number, second?: number, milli?: number): number; + /** + * Convert a TimeT structure into a unix milli timestamp. + * This does NOT take leap seconds into account. + */ + export function timeToUnixNoLeapSecs(tm: TimeStruct): number; + /** + * Return the day-of-week. + * This does NOT take leap seconds into account. + */ + export function weekDayNoLeapSecs(unixMillis: number): WeekDay; + /** + * Basic representation of a date and time + */ + export class TimeStruct { + /** + * Year, 1970-... + */ + year: number; + /** + * Month 1-12 + */ + month: number; + /** + * Day of month, 1-31 + */ + day: number; + /** + * Hour 0-23 + */ + hour: number; + /** + * Minute 0-59 + */ + minute: number; + /** + * Seconds, 0-59 + */ + second: number; + /** + * Milliseconds 0-999 + */ + milli: number; + /** + * Create a TimeStruct from a number of unix milliseconds + */ + static fromUnix(unixMillis: number): TimeStruct; + /** + * Create a TimeStruct from a JavaScript date + * + * @param d The date + * @param df Which functions to take (getX() or getUTCX()) + */ + static fromDate(d: Date, df: javascript.DateFunctions): TimeStruct; + /** + * Returns a TimeStruct from an ISO 8601 string WITHOUT time zone + */ + static fromString(s: string): TimeStruct; + /** + * Constructor + * + * @param year Year e.g. 1970 + * @param month Month 1-12 + * @param day Day 1-31 + * @param hour Hour 0-23 + * @param minute Minute 0-59 + * @param second Second 0-59 (no leap seconds) + * @param milli Millisecond 0-999 + */ + constructor(/** + * Year, 1970-... + */ + year?: number, /** + * Month 1-12 + */ + month?: number, /** + * Day of month, 1-31 + */ + day?: number, /** + * Hour 0-23 + */ + hour?: number, /** + * Minute 0-59 + */ + minute?: number, /** + * Seconds, 0-59 + */ + second?: number, /** + * Milliseconds 0-999 + */ + milli?: number); + /** + * Validate a TimeStruct, returns false if invalid. + */ + validate(): boolean; + /** + * The day-of-year 0-365 + */ + yearDay(): number; + /** + * Returns this time as a unix millisecond timestamp + * Does NOT take leap seconds into account. + */ + toUnixNoLeapSecs(): number; + /** + * Deep equals + */ + equals(other: TimeStruct): boolean; + /** + * < operator + */ + lessThan(other: TimeStruct): boolean; + clone(): TimeStruct; + valueOf(): number; + /** + * ISO 8601 string YYYY-MM-DDThh:mm:ss.nnn + */ + toString(): string; + inspect(): string; + } +} + +declare module '__timezonecomplete/datetime' { + import basics = require("__timezonecomplete/basics"); + import duration = require("__timezonecomplete/duration"); + import javascript = require("__timezonecomplete/javascript"); + import timesource = require("__timezonecomplete/timesource"); + import timezone = require("__timezonecomplete/timezone"); + /** + * DateTime class which is time zone-aware + * and which can be mocked for testing purposes. + */ + export class DateTime { + /** + * Actual time source in use. Setting this property allows to + * fake time in tests. DateTime.nowLocal() and DateTime.nowUtc() + * use this property for obtaining the current time. + */ + static timeSource: timesource.TimeSource; + /** + * Current date+time in local time (derived from DateTime.timeSource.now()). + */ + static nowLocal(): DateTime; + /** + * Current date+time in UTC time (derived from DateTime.timeSource.now()). + */ + static nowUtc(): DateTime; + /** + * Current date+time in the given time zone (derived from DateTime.timeSource.now()). + * @param timeZone The desired time zone. + */ + static now(timeZone: timezone.TimeZone): DateTime; + /** + * Constructor. Creates current time in local timezone. + */ + constructor(); + /** + * Constructor + * Non-existing local times are normalized by rounding up to the next DST offset. + * + * @param isoString String in ISO 8601 format. Instead of ISO time zone, + * it may include a space and then and IANA time zone. + * e.g. "2007-04-05T12:30:40.500" (no time zone, naive date) + * e.g. "2007-04-05T12:30:40.500+01:00" (UTC offset without daylight saving time) + * or "2007-04-05T12:30:40.500Z" (UTC) + * or "2007-04-05T12:30:40.500 Europe/Amsterdam" (IANA time zone, with daylight saving time if applicable) + * @param timeZone if given, the date in the string is assumed to be in this time zone. + * Note that it is NOT CONVERTED to the time zone. Useful + * for strings without a time zone + */ + constructor(isoString: string, timeZone?: timezone.TimeZone); + /** + * Constructor. You provide a date, then you say whether to take the + * date.getYear()/getXxx methods or the date.getUTCYear()/date.getUTCXxx methods, + * and then you state which time zone that date is in. + * Non-existing local times are normalized by rounding up to the next DST offset. + * Note that the Date class has bugs and inconsistencies when constructing them with times around + * DST changes. + * + * @param date A date object. + * @param getters Specifies which set of Date getters contains the date in the given time zone: the + * Date.getXxx() methods or the Date.getUTCXxx() methods. + * @param timeZone The time zone that the given date is assumed to be in (may be null for unaware dates) + */ + constructor(date: Date, getFuncs: javascript.DateFunctions, timeZone?: timezone.TimeZone); + /** + * Constructor. Note that unlike JavaScript dates we require fields to be in normal ranges. + * Use the add(duration) or sub(duration) for arithmetic. + * @param year The full year (e.g. 2014) + * @param month The month [1-12] (note this deviates from JavaScript Date) + * @param day The day of the month [1-31] + * @param hour The hour of the day [0-24) + * @param minute The minute of the hour [0-59] + * @param second The second of the minute [0-59] + * @param millisecond The millisecond of the second [0-999] + * @param timeZone The time zone, or null (for unaware dates) + */ + constructor(year: number, month: number, day: number, hour?: number, minute?: number, second?: number, millisecond?: number, timeZone?: timezone.TimeZone); + /** + * Constructor + * @param unixTimestamp milliseconds since 1970-01-01T00:00:00.000 + * @param timeZone the time zone that the timestamp is assumed to be in (usually UTC). + */ + constructor(unixTimestamp: number, timeZone?: timezone.TimeZone); + /** + * @return a copy of this object + */ + clone(): DateTime; + /** + * @return The time zone that the date is in. May be null for unaware dates. + */ + zone(): timezone.TimeZone; + /** + * @return the offset w.r.t. UTC in minutes. Returns 0 for unaware dates and for UTC dates. + */ + offset(): number; + /** + * @return The full year e.g. 2014 + */ + year(): number; + /** + * @return The month 1-12 (note this deviates from JavaScript Date) + */ + month(): number; + /** + * @return The day of the month 1-31 + */ + day(): number; + /** + * @return The hour 0-23 + */ + hour(): number; + /** + * @return the minutes 0-59 + */ + minute(): number; + /** + * @return the seconds 0-59 + */ + second(): number; + /** + * @return the milliseconds 0-999 + */ + millisecond(): number; + /** + * @return the day-of-week (the enum values correspond to JavaScript + * week day numbers) + */ + weekDay(): basics.WeekDay; + /** + * @return Milliseconds since 1970-01-01T00:00:00.000Z + */ + unixUtcMillis(): number; + /** + * @return The full year e.g. 2014 + */ + utcYear(): number; + /** + * @return The UTC month 1-12 (note this deviates from JavaScript Date) + */ + utcMonth(): number; + /** + * @return The UTC day of the month 1-31 + */ + utcDay(): number; + /** + * @return The UTC hour 0-23 + */ + utcHour(): number; + /** + * @return The UTC minutes 0-59 + */ + utcMinute(): number; + /** + * @return The UTC seconds 0-59 + */ + utcSecond(): number; + /** + * @return The UTC milliseconds 0-999 + */ + utcMillisecond(): number; + /** + * @return the UTC day-of-week (the enum values correspond to JavaScript + * week day numbers) + */ + utcWeekDay(): basics.WeekDay; + /** + * Convert this date to the given time zone (in-place). + * Throws if this date does not have a time zone. + * @return this (for chaining) + */ + convert(zone?: timezone.TimeZone): DateTime; + /** + * Returns this date converted to the given time zone. + * Unaware dates can only be converted to unaware dates (clone) + * Converting an unaware date to an aware date throws an exception. Use the constructor + * if you really need to do that. + * + * @param zone The new time zone. This may be null to create unaware date. + * @return The converted date + */ + toZone(zone?: timezone.TimeZone): DateTime; + /** + * Convert to JavaScript date with the zone time in the getX() methods. + * Unless the timezone is local, the Date.getUTCX() methods will NOT be correct. + * This is because Date calculates getUTCX() from getX() applying local time zone. + */ + toDate(): Date; + /** + * Add a time duration relative to UTC. Note that this simply adds a number + * of milliseconds to UTC and converts back to zone(), + * There is not DST handling. + * @return this + duration + */ + add(duration: duration.Duration): DateTime; + /** + * Add an amount of time relative to UTC, as regularly as possible. + * + * Adding e.g. 1 hour will increment the utcHour() field, adding 1 month + * increments the utcMonth() field. + * Adding an amount of units leaves lower units intact. E.g. + * adding a month will leave the day() field untouched if possible. + * + * Note adding Months or Years will clamp the date to the end-of-month if + * the start date was at the end of a month, i.e. contrary to JavaScript + * Date#setUTCMonth() it will not overflow into the next month + * + * In case of DST changes, the utc time fields are still untouched but local + * time fields may shift. + */ + add(amount: number, unit: basics.TimeUnit): DateTime; + /** + * Add an amount of time to the zone time, as regularly as possible. + * + * Adding e.g. 1 hour will increment the hour() field of the zone + * date by one. In case of DST changes, the time fields may additionally + * increase by the DST offset, if a non-existing local time would + * be reached otherwise. + * + * Adding a unit of time will leave lower-unit fields intact, unless the result + * would be a non-existing time. Then an extra DST offset is added. + * + * Note adding Months or Years will clamp the date to the end-of-month if + * the start date was at the end of a month, i.e. contrary to JavaScript + * Date#setUTCMonth() it will not overflow into the next month + */ + addLocal(amount: number, unit: basics.TimeUnit): DateTime; + /** + * Same as add(-1*duration); + */ + sub(duration: duration.Duration): DateTime; + /** + * Same as add(-1*amount, unit); + */ + sub(amount: number, unit: basics.TimeUnit): DateTime; + /** + * Same as addLocal(-1*amount, unit); + */ + subLocal(amount: number, unit: basics.TimeUnit): DateTime; + /** + * Time difference between two DateTimes + * @return this - other + */ + diff(other: DateTime): duration.Duration; + /** + * @return True iff (this < other) + */ + lessThan(other: DateTime): boolean; + /** + * @return True iff (this <= other) + */ + lessEqual(other: DateTime): boolean; + /** + * @return True iff this and other represent the same time in UTC + */ + equals(other: DateTime): boolean; + /** + * @return True iff this and other represent the same time and + * have the same zone + */ + identical(other: DateTime): boolean; + /** + * @return True iff this > other + */ + greaterThan(other: DateTime): boolean; + /** + * @return True iff this >= other + */ + greaterEqual(other: DateTime): boolean; + /** + * Proper ISO 8601 format string with any IANA zone converted to ISO offset + * E.g. "2014-01-01T23:15:33+01:00" for Europe/Amsterdam + */ + toIsoString(): string; + /** + * Modified ISO 8601 format string with IANA name if applicable. + * E.g. "2014-01-01T23:15:33.000 Europe/Amsterdam" + */ + toString(): string; + /** + * Used by util.inspect() + */ + inspect(): string; + /** + * Modified ISO 8601 format string in UTC without time zone info + */ + toUtcString(): string; + } +} + +declare module '__timezonecomplete/duration' { + /** + * Time duration. Create one e.g. like this: var d = Duration.hours(1). + * Note that time durations do not take leap seconds etc. into account: + * one hour is simply represented as 3600000 milliseconds. + */ + export class Duration { + /** + * Construct a time duration + * @param n Number of hours + * @return A duration of n hours + */ + static hours(n: number): Duration; + /** + * Construct a time duration + * @param n Number of minutes + * @return A duration of n minutes + */ + static minutes(n: number): Duration; + /** + * Construct a time duration + * @param n Number of seconds + * @return A duration of n seconds + */ + static seconds(n: number): Duration; + /** + * Construct a time duration + * @param n Number of milliseconds + * @return A duration of n milliseconds + */ + static milliseconds(n: number): Duration; + /** + * Construct a time duration of 0 + */ + constructor(); + /** + * Construct a time duration from a number of milliseconds + */ + constructor(milliseconds: number); + /** + * Construct a time duration from a string in format + * [-]h[:m[:s[.n]]] e.g. -01:00:30.501 + */ + constructor(input: string); + /** + * @return another instance of Duration with the same value. + */ + clone(): Duration; + /** + * The entire duration in milliseconds (negative or positive) + */ + milliseconds(): number; + /** + * The millisecond part of the duration (always positive) + * @return e.g. 400 for a -01:02:03.400 duration + */ + millisecond(): number; + /** + * The entire duration in seconds (negative or positive, fractional) + * @return e.g. 1.5 for a 1500 milliseconds duration + */ + seconds(): number; + /** + * The second part of the duration (always positive) + * @return e.g. 3 for a -01:02:03.400 duration + */ + second(): number; + /** + * The entire duration in minutes (negative or positive, fractional) + * @return e.g. 1.5 for a 90000 milliseconds duration + */ + minutes(): number; + /** + * The minute part of the duration (always positive) + * @return e.g. 2 for a -01:02:03.400 duration + */ + minute(): number; + /** + * The entire duration in hours (negative or positive, fractional) + * @return e.g. 1.5 for a 5400000 milliseconds duration + */ + hours(): number; + /** + * The hour part of the duration (always positive). + * Note that this part can exceed 23 hours, because for + * now, we do not have a days() function + * @return e.g. 25 for a -25:02:03.400 duration + */ + wholeHours(): number; + /** + * Sign + * @return "-" if the duration is negative + */ + sign(): string; + /** + * @return True iff (this < other) + */ + lessThan(other: Duration): boolean; + /** + * @return True iff this and other represent the same time duration + */ + equals(other: Duration): boolean; + /** + * @return True iff this > other + */ + greaterThan(other: Duration): boolean; + /** + * @return The minimum (most negative) of this and other + */ + min(other: Duration): Duration; + /** + * @return The maximum (most positive) of this and other + */ + max(other: Duration): Duration; + /** + * Multiply with a fixed number. + * @return a new Duration of (this * value) + */ + multiply(value: number): Duration; + /** + * Divide by a fixed number. + * @return a new Duration of (this / value) + */ + divide(value: number): Duration; + /** + * Add a duration. + * @return a new Duration of (this + value) + */ + add(value: Duration): Duration; + /** + * Subtract a duration. + * @return a new Duration of (this - value) + */ + sub(value: Duration): Duration; + /** + * String in [-]hh:mm:ss.nnn notation. All fields are + * always present except the sign. + */ + toFullString(): string; + /** + * String in [-]hh[:mm[:ss[.nnn]]] notation. Fields are + * added as necessary + */ + toString(): string; + /** + * Used by util.inspect() + */ + inspect(): string; + } +} + +declare module '__timezonecomplete/javascript' { + /** + * Indicates how a Date object should be interpreted. + * Either we can take getYear(), getMonth() etc for our field + * values, or we can take getUTCYear(), getUtcMonth() etc to do that. + */ + export enum DateFunctions { + /** + * Use the Date.getFullYear(), Date.getMonth(), ... functions. + */ + Get = 0, + /** + * Use the Date.getUTCFullYear(), Date.getUTCMonth(), ... functions. + */ + GetUTC = 1, + } +} + +declare module '__timezonecomplete/period' { + import basics = require("__timezonecomplete/basics"); + import datetime = require("__timezonecomplete/datetime"); + /** + * Specifies how the period should repeat across the day + * during DST changes. + */ + export enum PeriodDst { + /** + * Keep repeating in similar intervals measured in UTC, + * unaffected by Daylight Saving Time. + * E.g. a repetition of one hour will take one real hour + * every time, even in a time zone with DST. + * Leap seconds, leap days and month length + * differences will still make the intervals different. + */ + RegularIntervals = 0, + /** + * Ensure that the time at which the intervals occur stay + * at the same place in the day, local time. So e.g. + * a period of one day, starting at 8:05AM Europe/Amsterdam time + * will always start at 8:05 Europe/Amsterdam. This means that + * in UTC time, some intervals will be 25 hours and some + * 23 hours during DST changes. + * Another example: an hourly interval will be hourly in local time, + * skipping an hour in UTC for a DST backward change. + */ + RegularLocalTime = 1, + } + /** + * Convert a PeriodDst to a string: "regular intervals" or "regular local time" + */ + export function periodDstToString(p: PeriodDst): string; + /** + * Repeating time period: consists of a starting point and + * a time length. This class accounts for leap seconds and leap days. + */ + export class Period { + /** + * Constructor + * LIMITATION: if dst equals RegularLocalTime, and unit is Second, Minute or Hour, + * then the amount must be a factor of 24. So 120 seconds is allowed while 121 seconds is not. + * This is due to the enormous processing power required by these cases. They are not + * implemented and you will get an assert. + * + * @param start The start of the period. If the period is in Months or Years, and + * the day is 29 or 30 or 31, the results are maximised to end-of-month. + * @param amount The amount of units. + * @param unit The unit. + * @param dst Specifies how to handle Daylight Saving Time. Not relevant + * if the time zone of the start datetime does not have DST. + */ + constructor(start: datetime.DateTime, amount: number, unit: basics.TimeUnit, dst: PeriodDst); + /** + * The start date + */ + start(): datetime.DateTime; + /** + * The amount of units + */ + amount(): number; + /** + * The unit + */ + unit(): basics.TimeUnit; + /** + * The dst handling mode + */ + dst(): PeriodDst; + /** + * The first occurrence of the period greater than + * the given date. The given date need not be at a period boundary. + * Pre: the fromdate and startdate must either both have timezones or not + * @param fromDate: the date after which to return the next date + * @return the first date matching the period after fromDate, given + * in the same zone as the fromDate. + */ + findFirst(fromDate: datetime.DateTime): datetime.DateTime; + /** + * Returns the next timestamp in the period. The given timestamp must + * be at a period boundary, otherwise the answer is incorrect. + * This function has MUCH better performance than findFirst. + * Returns the datetime "count" times away from the given datetime. + * @param prev Boundary date. Must have a time zone (any time zone) iff the period start date has one. + * @param count Optional, must be >= 1 and whole. + * @return (prev + count * period), in the same timezone as prev. + */ + findNext(prev: datetime.DateTime, count?: number): datetime.DateTime; + /** + * Returns an ISO duration string e.g. + * 2014-01-01T12:00:00.000+01:00/P1H + * 2014-01-01T12:00:00.000+01:00/PT1M (one minute) + * 2014-01-01T12:00:00.000+01:00/P1M (one month) + */ + toIsoString(): string; + /** + * A string representation e.g. + * "10 years, starting at 2014-03-01T12:00:00 Europe/Amsterdam, keeping regular intervals". + */ + toString(): string; + /** + * Used by util.inspect() + */ + inspect(): string; + } +} + +declare module '__timezonecomplete/timesource' { + /** + * For testing purposes, we often need to manipulate what the current + * time is. This is an interface for a custom time source object + * so in tests you can use a custom time source. + */ + export interface TimeSource { + /** + * Return the current date+time as a javascript Date object + */ + now(): Date; + } + /** + * Default time source, returns actual time + */ + export class RealTimeSource implements TimeSource { + now(): Date; + } +} + +declare module '__timezonecomplete/timezone' { + import javascript = require("__timezonecomplete/javascript"); + /** + * The type of time zone + */ + export enum TimeZoneKind { + /** + * Local time offset as determined by JavaScript Date class. + */ + Local = 0, + /** + * Fixed offset from UTC, without DST. + */ + Offset = 1, + /** + * IANA timezone managed through Olsen TZ database. Includes + * DST if applicable. + */ + Proper = 2, + } + /** + * Option for TimeZone#normalizeLocal() + */ + export enum NormalizeOption { + /** + * Normalize non-existing times by ADDING the DST offset + */ + Up = 0, + /** + * Normalize non-existing times by SUBTRACTING the DST offset + */ + Down = 1, + } + /** + * Time zone. The object is immutable because it is cached: + * requesting a time zone twice yields the very same object. + * Note that we use time zone offsets inverted w.r.t. JavaScript Date.getTimezoneOffset(), + * i.e. offset 90 means +01:30. + * + * Time zones come in three flavors: the local time zone, as calculated by JavaScript Date, + * a fixed offset ("+01:30") without DST, or a IANA timezone ("Europe/Amsterdam") with DST + * applied depending on the time zone rules. + */ + export class TimeZone { + /** + * The local time zone for a given date. Note that + * the time zone varies with the date: amsterdam time for + * 2014-01-01 is +01:00 and amsterdam time for 2014-07-01 is +02:00 + */ + static local(): TimeZone; + /** + * The UTC time zone. + */ + static utc(): TimeZone; + /** + * Returns a time zone object from the cache. If it does not exist, it is created. + * @return The time zone with the given offset w.r.t. UTC in minutes, e.g. 90 for +01:30 + */ + static zone(offset: number): TimeZone; + /** + * Returns a time zone object from the cache. If it does not exist, it is created. + * @param s: Empty string for local time, a TZ database time zone name (e.g. Europe/Amsterdam) + * or an offset string (either +01:30, +0130, +01, Z). For a full list of names, see: + * https://en.wikipedia.org/wiki/List_of_tz_database_time_zones + */ + static zone(s: string): TimeZone; + /** + * Do not use this constructor, use the static + * TimeZone.zone() method instead. + * @param name NORMALIZED name, assumed to be correct + */ + constructor(name: string); + /** + * The time zone identifier. Can be an offset "-01:30" or an + * IANA time zone name "Europe/Amsterdam", or "localtime" for + * the local time zone. + */ + name(): string; + /** + * The kind of time zone (Local/Offset/Proper) + */ + kind(): TimeZoneKind; + /** + * Equality operator. Maps zero offsets and different names for UTC onto + * each other. Other time zones are not mapped onto each other. + */ + equals(other: TimeZone): boolean; + /** + * Is this zone equivalent to UTC? + */ + isUtc(): boolean; + /** + * Does this zone have Daylight Saving Time at all? + */ + hasDst(): boolean; + /** + * Calculate timezone offset from a UTC time. + * @param year local full year + * @param month local month 1-12 (note this deviates from JavaScript date) + * @param day local day of month 1-31 + * @param hour local hour 0-23 + * @param minute local minute 0-59 + * @param second local second 0-59 + * @param millisecond local millisecond 0-999 + * @return the offset of this time zone with respect to UTC at the given time, in minutes. + */ + offsetForUtc(year: number, month: number, day: number, hour?: number, minute?: number, second?: number, millisecond?: number): number; + /** + * Calculate timezone offset from a zone-local time (NOT a UTC time). + * @param year local full year + * @param month local month 1-12 (note this deviates from JavaScript date) + * @param day local day of month 1-31 + * @param hour local hour 0-23 + * @param minute local minute 0-59 + * @param second local second 0-59 + * @param millisecond local millisecond 0-999 + * @return the offset of this time zone with respect to UTC at the given time, in minutes. + */ + offsetForZone(year: number, month: number, day: number, hour?: number, minute?: number, second?: number, millisecond?: number): number; + /** + * Note: will be removed in version 2.0.0 + * + * Convenience function, takes values from a Javascript Date + * Calls offsetForUtc() with the contents of the date + * + * @param date: the date + * @param funcs: the set of functions to use: get() or getUTC() + */ + offsetForUtcDate(date: Date, funcs: javascript.DateFunctions): number; + /** + * Note: will be removed in version 2.0.0 + * + * Convenience function, takes values from a Javascript Date + * Calls offsetForUtc() with the contents of the date + * + * @param date: the date + * @param funcs: the set of functions to use: get() or getUTC() + */ + offsetForZoneDate(date: Date, funcs: javascript.DateFunctions): number; + /** + * Normalizes non-existing local times by adding a forward offset change. + * During a forward standard offset change or DST offset change, some amount of + * local time is skipped. Therefore, this amount of local time does not exist. + * This function adds the amount of forward change to any non-existing time. After all, + * this is probably what the user meant. + * + * @param localUnixMillis Unix timestamp in zone time + * @param opt (optional) Round up or down? Default: up + * + * @returns Unix timestamp in zone time, normalized. + */ + normalizeZoneTime(localUnixMillis: number, opt?: NormalizeOption): number; + /** + * The time zone identifier (normalized). + * Either "localtime", IANA name, or "+hh:mm" offset. + */ + toString(): string; + /** + * Used by util.inspect() + */ + inspect(): string; + /** + * Convert an offset number into an offset string + * @param offset The offset in minutes from UTC e.g. 90 minutes + * @return the offset in ISO notation "+01:30" for +90 minutes + */ + static offsetToString(offset: number): string; + /** + * String to offset conversion. + * @param s Formats: "-01:00", "-0100", "-01", "Z" + * @return offset w.r.t. UTC in minutes + */ + static stringToOffset(s: string): number; + } +} + diff --git a/tspromise/tspromise-tests.ts b/tspromise/tspromise-tests.ts index 79903f0ce..fcb52212a 100644 --- a/tspromise/tspromise-tests.ts +++ b/tspromise/tspromise-tests.ts @@ -1,21 +1,21 @@ -/// - -import Promise = require('tspromise'); - -var MyFuncFunc = Promise.async((a: boolean, b: number) => { - console.log('[a] ' + a); - yield(Promise.waitAsync(1000)); - console.log('[b]' + b); -}); - -MyFuncFunc(true, 10); - -Promise.all([Promise.waitAsync(10), Promise.waitAsync(20)]).then(() => { - return new Promise((resolve, reject) => { - resolve('test'); - }); -}).then(() => { - throw (new Error()); -}).catch((e) => { - console.log(e.message); +/// + +import Promise = require('tspromise'); + +var MyFuncFunc = Promise.async((a: boolean, b: number) => { + console.log('[a] ' + a); + yield(Promise.waitAsync(1000)); + console.log('[b]' + b); +}); + +MyFuncFunc(true, 10); + +Promise.all([Promise.waitAsync(10), Promise.waitAsync(20)]).then(() => { + return new Promise((resolve, reject) => { + resolve('test'); + }); +}).then(() => { + throw (new Error()); +}).catch((e) => { + console.log(e.message); }); \ No newline at end of file diff --git a/typeahead/typeahead-tests.ts b/typeahead/typeahead-tests.ts index 1044fe3bf..3c8495f86 100644 --- a/typeahead/typeahead-tests.ts +++ b/typeahead/typeahead-tests.ts @@ -6,84 +6,50 @@ // declare var Hogan: string; -// Countries -// Prefetches data, stores it in localStorage, and searches it on the client -$('.example-countries .typeahead').typeahead({ - name: 'countries', - prefetch: '../data/countries.json', - limit: 10 +var substringMatcher = function (strs: any) { + return function findMatches(q: any, cb: any) { + var matches: any, substrRegex: any; + + // an array that will be populated with substring matches + matches = []; + + // regex used to determine if a string contains the substring `q` + substrRegex = new RegExp(q, 'i'); + + // iterate through the pool of strings and for any string that + // contains the substring `q`, add it to the `matches` array + $.each(strs, function (i, str) { + if (substrRegex.test(str)) { + // the typeahead jQuery plugin expects suggestions to a + // JavaScript object, refer to typeahead docs for more info + matches.push({ value: str }); + } }); -// Open Source Projects by Twitter -// Defines a custom template and template engine for rendering suggestions -$('.example-twitter-oss .typeahead').typeahead({ - name: 'twitter-oss', - prefetch: '../data/repos.json', - template: [ - '

{{language}}

', - '

{{name}}

', - '

{{description}}

' - ].join(''), - engine: Hogan -}); + cb(matches); + }; +}; -// Arabic Phrases -// Hardcoded list showing Right - To - Left(RTL) support -$('.example-arabic .typeahead').typeahead({ - name: 'arabic', - local: [ - "الإنجليزية", - "نعم", - "لا", - "مرحبا", - "کيف الحال؟", - "أهلا", - "مع السلامة", - "لا أتكلم العربية", - "لا أفهم", - "أنا جائع" - ] -}); +var states = ['Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California', + 'Colorado', 'Connecticut', 'Delaware', 'Florida', 'Georgia', 'Hawaii', + 'Idaho', 'Illinois', 'Indiana', 'Iowa', 'Kansas', 'Kentucky', 'Louisiana', + 'Maine', 'Maryland', 'Massachusetts', 'Michigan', 'Minnesota', + 'Mississippi', 'Missouri', 'Montana', 'Nebraska', 'Nevada', 'New Hampshire', + 'New Jersey', 'New Mexico', 'New York', 'North Carolina', 'North Dakota', + 'Ohio', 'Oklahoma', 'Oregon', 'Pennsylvania', 'Rhode Island', + 'South Carolina', 'South Dakota', 'Tennessee', 'Texas', 'Utah', 'Vermont', + 'Virginia', 'Washington', 'West Virginia', 'Wisconsin', 'Wyoming' +]; -// NBA and NHL Teams -// Two datasets that are prefetched, stored, and searched on the client -$('.example-sports .typeahead').typeahead([ - { - name: 'nba-teams', - prefetch: '../data/nba.json', - header: '

NBA Teams

' - }, - { - name: 'nhl-teams', - prefetch: '../data/nhl.json', - header: '

NHL Teams

' - } -]); - -// Best Picture Winners -// Prefetches some data then relies on remote requests for suggestions when prefetched data is insufficient -$('.example-films .typeahead').typeahead([ - { - name: 'best-picture-winners', - remote: '../data/films/queries/%QUERY.json', - prefetch: '../data/films/post_1960.json', - template: '

{{value}} – {{year}}

', - engine: Hogan - } -]); - -// Countries - Modified the first test here to add options -// Specifies options to display hint with a highlight and adds a minimum length restriction for search -// Prefetches data, stores it in localStorage, and searches it on the client -$('.example-countries .typeahead').typeahead({ +$('#the-basics .typeahead').typeahead({ hint: true, highlight: true, - minLength: 2 + minLength: 1 }, { - name: 'countries', - prefetch: '../data/countries.json', - limit: 10 + name: 'states', + displayKey: 'value', + source: substringMatcher(states) }); module valueTest { diff --git a/typeahead/typeahead.d.ts b/typeahead/typeahead.d.ts index bb8aaf31d..c2d50dfc4 100644 --- a/typeahead/typeahead.d.ts +++ b/typeahead/typeahead.d.ts @@ -1,53 +1,71 @@ -// Type definitions for typeahead.js 0.9.3 +// Type definitions for typeahead.js 0.10.4 // Project: http://twitter.github.io/typeahead.js/ -// Definitions by: Ivaylo Gochkov +// Definitions by: Ivaylo Gochkov , Gidon Junge // Definitions: https://github.com/borisyankov/DefinitelyTyped /// interface JQuery { - /** - * Turns an input[type="text"] element into a typeahead. - * - * @constructor - * @param dataset Single dataset - */ - typeahead(dataset: Twitter.Typeahead.Dataset): JQuery; - - /** - * Turns an input[type="text"] element into a typeahead. - * - * @constructor - * @param dataset Array of datasets - */ - typeahead(datasets: Twitter.Typeahead.Dataset[]): JQuery; /** * Destroys previously initialized typeaheads. This entails reverting * DOM modifications and removing event handlers. - * - * @constructor + * + * @constructor * @param methodName Method 'destroy' - */ + */ typeahead(methodName: 'destroy'): JQuery; /** - * Sets the current query of the typeahead. This is always preferable to - * using $("input.typeahead").val(query), which will result in unexpected - * behavior. To clear the query, simply set it to an empty string. + * Opens the dropdown menu of typeahead. Note that being open does not mean that the menu is visible. + * The menu is only visible when it is open and has content. * * @constructor - * @param methodName Method 'setQuery' - * @param query The query to be set + * @param methodName Method 'open' */ - typeahead(methodName: 'setQuery', query: string): JQuery; + typeahead(methodName: 'open'): JQuery; /** - * Accommodates the destroy and setQuery overloads. + * Closes the dropdown menu of typeahead. + * + * @constructor + * @param methodName Method 'close' + */ + typeahead(methodName: 'close'): JQuery; + + /** + * Returns the current value of the typeahead. + * The value is the text the user has entered into the input element. * * @constructor - * @param methodName Method name ('destroy' or 'setQuery') - * @param query The query to be set in case method 'setQuery' is used. + * @param methodName Method 'val' + */ + typeahead(methodName: 'val'): string; + + /** + * Sets the value of the typeahead. This should be used in place of jQuery#val. + * + * @constructor + * @param methodName Method 'val' + * @param query The value to be set + */ + typeahead(methodName: 'val', val: string): JQuery; + + /** + * Accommodates the val overload. + * + * @constructor + * @param methodName Method name ('val') + */ + typeahead(methodName: string): string; + + + /** + * Accommodates multiple overloads. + * + * @constructor + * @param methodName Method name + * @param query The query to be set in case method 'val' is used. */ typeahead(methodName: string, query: string): JQuery; @@ -57,20 +75,19 @@ interface JQuery { * * @constructor * @param options ('hint' or 'highlight' or 'minLength' all of which are optional) - * @param dataset Array of datasets + * @param datasets Array of datasets */ - typeahead(options: Twitter.Typeahead.Options, dataset: Twitter.Typeahead.Dataset): JQuery; + typeahead(options: Twitter.Typeahead.Options, datasets: Twitter.Typeahead.Dataset[]): JQuery; /** - * Returns the current value of the typeahead. The value is the text the user has entered into the input element. + * Accomodates specifying options such as hint and highlight. + * This is in correspondence to the examples mentioned in http://twitter.github.io/typeahead.js/examples/ + * + * @constructor + * @param options ('hint' or 'highlight' or 'minLength' all of which are optional) + * @param datasets One or more datasets passed in as arguments. */ - typeahead(methodName: 'val'): string; - typeahead(methodName: string): string; - - /** - * Sets the value of the typeahead. This should be used in place of jQuery#val. - */ - typeahead(methodName: 'val', value: string): JQuery; + typeahead(options: Twitter.Typeahead.Options, ... datasets: Twitter.Typeahead.Dataset[]): JQuery; } declare module Twitter.Typeahead { @@ -82,188 +99,70 @@ declare module Twitter.Typeahead { */ interface Dataset { /** - * The string used to identify the dataset. Used by typeahead.js - * to cache intelligently. + * The backing data source for suggestions. + * Expected to be a function with the signature (query, cb). + * It is expected that the function will compute the suggestion set (i.e. an array of JavaScript objects) for query and then invoke cb with said set. + * cb can be invoked synchronously or asynchronously. + * */ - name: string; - /** - * The key used to access the value of the datum in the datum object. - * Defaults to value. - */ - valueKey?: string; - /** - * The max number of suggestions from the dataset to display - * for a given query. Defaults to 5. - */ - limit?: number; - /** - * The template used to render suggestions. Can be a string or - * a precompiled template. If not provided, suggestions will render - * as their value contained in a

element (i.e.

value

). - */ - template?: any; - /** - * The template engine used to compile/render template if it is a - * string. Any engine can use used as long as it adheres to the - * expected API. Required if template is a string. - */ - engine?: string; - /** - * The header rendered before suggestions in the dropdown menu. - * Can be either a DOM element or HTML. - */ - header?: any; - /** - * The footer rendered after suggestions in the dropdown menu. - * Can be either a DOM element or HTML. - */ - footer?: any; - /** - * An array of datums or strings. - */ - local?: any[]; - /** - * Can be a URL to a JSON file containing an array of datums or, - * if more configurability is needed, a prefetch options object. - */ - prefetch?: any; - /** - * Can be a URL to fetch suggestions from when the data provided by - * local and prefetch is insufficient or, if more configurability is - * needed, a remote options object. - */ - remote?: any; - } + source: (query: string, cb: (result: any) => void) => void; /** - * Prefetched data is fetched and processed on initialization. - * If the browser supports localStorage, the processed data will be cached - * there to prevent additional network requests on subsequent page loads. - */ - interface PrefetchOptions { - /** - * A URL to a JSON file containing an array of datums. Required. + * The name of the dataset. + * This will be appended to tt-dataset- to form the class name of the containing DOM element. + * Must only consist of underscores, dashes, letters (a-z), and numbers. + * Defaults to a random number. */ - url: string; + name?: string; /** - * The time (in milliseconds) the prefetched data should be cached - * in localStorage. Defaults to 86400000 (1 day). + * For a given suggestion object, determines the string representation of it. + * This will be used when setting the value of the input control after a suggestion is selected. Can be either a key string or a function that transforms a suggestion object into a string. + * Defaults to value. */ - ttl?: number; + displayKey?: string; /** - * A function that transforms the response body into an array of datums. - * - * @param parsedResponse Response body + * A hash of templates to be used when rendering the dataset. + * Note a precompiled template is a function that takes a JavaScript object as its first argument and returns a HTML string. */ - filter?: (parsedResponse: any) => Datum[]; + templates?: Templates; } - /** - * Remote data is only used when the data provided by local and prefetch - * is insufficient. In order to prevent an obscene number of requests - * being made to remote endpoint, typeahead.js rate-limits remote requests. - */ - interface RemoteOptions { - /** - * A URL to make requests to when the data provided by local and - * prefetch is insufficient. Required. - */ - url: string; + + interface Templates { /** - * The type of data you're expecting from the server. Defaults to json. - * @see http://api.jquery.com/jQuery.ajax/ for more info. + * Rendered when 0 suggestions are available for the given query. + * Can be either a HTML string or a precompiled template. + * If it's a precompiled template, the passed in context will contain query */ - dataType?: string; + empty?: string; /** - * Determines whether or not the browser will cache responses. - * @see http://api.jquery.com/jQuery.ajax/ for more info. + * Rendered at the bottom of the dataset. + * Can be either a HTML string or a precompiled template. + * If it's a precompiled template, the passed in context will contain query and isEmpty. */ - cache?: boolean; + footer?: string; /** - * Sets a timeout for requests. - * @see http://api.jquery.com/jQuery.ajax/ for more info. + * Rendered at the top of the dataset. + * Can be either a HTML string or a precompiled template. + * If it's a precompiled template, the passed in context will contain query and isEmpty. */ - timeout?: number; + header?: string; /** - * The pattern in url that will be replaced with the user's query - * when a request is made. Defaults to %QUERY. + * Used to render a single suggestion. + * If set, this has to be a precompiled template. + * The associated suggestion object will serve as the context. + * Defaults to the value of displayKey wrapped in a p tag i.e.

{{value}}

. */ - wildcard?: string; + suggestion?: string; - /** - * Overrides the request URL. If set, no wildcard substitution will - * be performed on url. - * - * @param url Replacement URL - * @param uriEncodedQuery Encoded query - * @returns A valid URL - */ - replace?: (url: string, uriEncodedQuery: string) => string; - - /** - * The function used for rate-limiting network requests. - * Can be either 'debounce' or 'throttle'. Defaults to 'debounce'. - */ - rateLimitFn?: string; - - /** - * The time interval in milliseconds that will be used by rateLimitFn. - * Defaults to 300. - */ - rateLimitWait?: number; - - /** - * The max number of parallel requests typeahead.js can have pending. - * Defaults to 6. - */ - maxParallelRequests?: number; - - /** - * A pre-request callback. Can be used to set custom headers. - * @see http://api.jquery.com/jQuery.ajax/ for more info. - */ - beforeSend?: (jqXhr: JQueryXHR, settings: JQueryAjaxSettings) => void; - - /** - * Transforms the response body into an array of datums. - * - * @param parsedResponse Response body - */ - filter?: (parsedResponse: any) => Datum[]; } - /** - * The individual units that compose datasets are called datums. - * The canonical form of a datum is an object with a value property and - * a tokens property. - * - * For ease of use, datums can also be represented as a string. - * Strings found in place of datum objects are implicitly converted - * to a datum object. - * - * When datums are rendered as suggestions, the datum object is the - * context passed to the template engine. This means if you include any - * arbitrary properties in datum objects, those properties will be - * available to the template used to render suggestions. - */ - interface Datum { - /** - * The string that represents the underlying value of the datum - */ - value: string; - - /** - * A collection of single-word strings that aid typeahead.js in - * matching datums with a given query. - */ - tokens: string[]; - } /** * When initializing a typeahead, there are a number of options you can configure. diff --git a/zepto/zepto.d.ts b/zepto/zepto.d.ts index 3608ade9f..ba75e7556 100644 --- a/zepto/zepto.d.ts +++ b/zepto/zepto.d.ts @@ -1106,7 +1106,12 @@ interface ZeptoCollection { * @return **/ size(): number; - + + /** + * Get the number of elements in this collection. + **/ + length: number; + /** * Extract the subset of this array, starting at start index. If end is specified, extract up to but not including end index. * @param start