From 36576707565df21d7a823d636882ae438b990190 Mon Sep 17 00:00:00 2001 From: Michel Salib Date: Fri, 6 Dec 2013 18:49:43 +0100 Subject: [PATCH 01/17] Add Angular UI Router definitions - Move angular-ui definitions to its own folder - Add self to readme - Add some tests for angular-ui-router --- README.md | 1 + angular-ui/angular-ui-router-tests.ts | 57 ++++++++++++++++++ angular-ui/angular-ui-router.d.ts | 83 +++++++++++++++++++++++++++ 3 files changed, 141 insertions(+) create mode 100644 angular-ui/angular-ui-router-tests.ts create mode 100644 angular-ui/angular-ui-router.d.ts diff --git a/README.md b/README.md index e0454a6b9..b326634e0 100755 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ List of Definitions * [Add To Home Screen] (http://cubiq.org/add-to-home-screen) (by [James Wilkins] (http://www.codeplex.com/site/users/view/jamesnw)) * [AmCharts](http://www.amcharts.com/) (by [Covobonomo](https://github.com/covobonomo/)) * [AngularJS](http://angularjs.org) (by [Diego Vilar](https://github.com/diegovilar)) ([wiki](https://github.com/borisyankov/DefinitelyTyped/wiki/AngularJS-Definitions-Usage-Notes)) +* [AngularUI](http://angular-ui.github.io/) (by [Michel Salib](https://github.com/michelsalib)) * [AppFramework](http://app-framework-software.intel.com/) (by [Kyo Ago](https://github.com/kyo-ago)) * [Arbiter](http://arbiterjs.com/) (by [Arash Shakery](https://github.com/arash16)) * [async](https://github.com/caolan/async) (by [Boris Yankov](https://github.com/borisyankov)) diff --git a/angular-ui/angular-ui-router-tests.ts b/angular-ui/angular-ui-router-tests.ts new file mode 100644 index 000000000..3d7ce3b5c --- /dev/null +++ b/angular-ui/angular-ui-router-tests.ts @@ -0,0 +1,57 @@ +/// + +var myApp = angular.module('testModule'); + + +myApp.config(( + $stateProvider: ng.ui.IStateProvider, + $urlRouterProvider: ng.ui.IUrlRouterProvider) => { + // + // For any unmatched url, redirect to /state1 + $urlRouterProvider.otherwise("/state1"); + // + // Now set up the states + $stateProvider + .state('state1', { + url: "/state1", + templateUrl: "partials/state1.html" + }) + .state('state1.list', { + url: "/list", + templateUrl: "partials/state1.list.html", + controller: function($scope) { + $scope.items = ["A", "List", "Of", "Items"]; + } + }) + .state('state2', { + url: "/state2", + templateUrl: "partials/state2.html" + }) + .state('state2.list', { + url: "/list", + templateUrl: "partials/state2.list.html", + controller: function($scope) { + $scope.things = ["A", "Set", "Of", "Things"]; + } + }).state('index', { + url: "", + views: { + "viewA": { template: "index.viewA" }, + "viewB": { template: "index.viewB" } + } + }) + .state('route1', { + url: "/route1", + views: { + "viewA": { template: "route1.viewA" }, + "viewB": { template: "route1.viewB" } + } + }) + .state('route2', { + url: "/route2", + views: { + "viewA": { template: "route2.viewA" }, + "viewB": { template: "route2.viewB" } + } + }); +}); \ No newline at end of file diff --git a/angular-ui/angular-ui-router.d.ts b/angular-ui/angular-ui-router.d.ts new file mode 100644 index 000000000..1046b1cb2 --- /dev/null +++ b/angular-ui/angular-ui-router.d.ts @@ -0,0 +1,83 @@ +// Type definitions for Angular JS 1.1.5+ (ui.router module) +// Project: https://github.com/angular-ui/ui-router +// Definitions by: Michel Salib +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module ng.ui { + + interface IState { + template?: any; + templateUrl?: any; + templateProvider?: () => string; + controller?: any; + controllerProvider?: any; + resolve?: {}; + url?: string; + params?: any[]; + views?: {}; + abstract?: boolean; + onEnter?: Function; + onExit?: Function; + data?: any; + } + + interface IStateProvider extends IServiceProvider { + state(name:string, config:IState): IStateProvider; + decorator(name?: string, decorator?: (state: IState, parent: Function) => any): any; + } + + interface IUrlMatcher { + concat(pattern: string): IUrlMatcher; + exec(path: string, searchParams: {}): {}; + } + + interface IUrlMatcherFactory { + compile(pattern: string): IUrlMatcher; + isMatcher(o: any): boolean; + parameters(): string[]; + format(values: {}): string; + } + + interface IUrlRouterProvider extends IServiceProvider { + when(whenPath: string, toPath: string): IUrlRouterProvider; + when(whenPath: RegExp, toPath: string): IUrlRouterProvider; + when(whenPath: IUrlMatcher, toPath: string): IUrlRouterProvider; + otherwise(path: string): IUrlRouterProvider; + otherwise(path: Function): IUrlRouterProvider; + rule(handler: Function): IUrlRouterProvider; + } + + interface IStateOptions { + location?: any; + inherit?: boolean; + relative?: IState; + notify?: boolean; + } + + interface IHrefOptions { + lossy?: boolean; + inherit?: boolean; + relative?: IState; + absolute?: boolean; + } + + interface IStateService { + go(to: string, params?: {}, options?: IStateOptions): void; + transitionTo(state: string, params?: {}, updateLocation?: boolean): void; + transitionTo(state: string, params?: {}, options?: IStateOptions): void; + includes(state: string, params?: {}): boolean; + is(state:string, params?: {}): boolean; + is(state: IState, params?: {}): boolean; + href(state: IState, params?: {}, options?: IHrefOptions): string; + href(state: string, params?: {}, options?: IHrefOptions): string; + get(state: string): IState; + get(): IState[]; + current: IState; + } + + interface IStateParamsService { + [key: string]: any; + } +} From 20065c967aef90c3add16eded398a27f0ab69240 Mon Sep 17 00:00:00 2001 From: Paul Loyd Date: Fri, 6 Dec 2013 22:08:07 +0400 Subject: [PATCH 02/17] Rename Timer to NodeTimer --- node/node.d.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/node/node.d.ts b/node/node.d.ts index a57fb96d1..4c8c043d3 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -15,10 +15,10 @@ declare var global: any; declare var __filename: string; declare var __dirname: string; -declare function setTimeout(callback: (...args: any[]) => void , ms: number , ...args: any[]): Timer; -declare function clearTimeout(timeoutId: Timer): void; -declare function setInterval(callback: (...args: any[]) => void , ms: number , ...args: any[]): Timer; -declare function clearInterval(intervalId: Timer): void; +declare function setTimeout(callback: (...args: any[]) => void , ms: number , ...args: any[]): NodeTimer; +declare function clearTimeout(timeoutId: NodeTimer): void; +declare function setInterval(callback: (...args: any[]) => void , ms: number , ...args: any[]): NodeTimer; +declare function clearInterval(intervalId: NodeTimer): void; declare function setImmediate(callback: (...args: any[]) => void , ...args: any[]): any; declare function clearImmediate(immediateId: any): void; @@ -198,7 +198,7 @@ interface NodeBuffer { INSPECT_MAX_BYTES: number; } -interface Timer { +interface NodeTimer { ref() : void; unref() : void; } From 3454ad17a9f1cd4947805e07d6482ba50cdba288 Mon Sep 17 00:00:00 2001 From: Michel Salib Date: Mon, 9 Dec 2013 12:06:58 +0100 Subject: [PATCH 03/17] Angular UI states have a name attribute This is not documenting, but a name attribute is exposed, and is very useful. --- angular-ui/angular-ui-router.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/angular-ui/angular-ui-router.d.ts b/angular-ui/angular-ui-router.d.ts index 1046b1cb2..4c16742a5 100644 --- a/angular-ui/angular-ui-router.d.ts +++ b/angular-ui/angular-ui-router.d.ts @@ -8,6 +8,7 @@ declare module ng.ui { interface IState { + name?: string; template?: any; templateUrl?: any; templateProvider?: () => string; From dcc0906c4a84b46a6d671195303b846421412487 Mon Sep 17 00:00:00 2001 From: Michel Salib Date: Mon, 9 Dec 2013 12:16:37 +0100 Subject: [PATCH 04/17] StateService also exposes current params --- angular-ui/angular-ui-router.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/angular-ui/angular-ui-router.d.ts b/angular-ui/angular-ui-router.d.ts index 4c16742a5..7f9c3869b 100644 --- a/angular-ui/angular-ui-router.d.ts +++ b/angular-ui/angular-ui-router.d.ts @@ -76,6 +76,7 @@ declare module ng.ui { get(state: string): IState; get(): IState[]; current: IState; + params: IStateParamsService; } interface IStateParamsService { From cf2ab210314c2ceac96e7e2f6fa724fc59d483f2 Mon Sep 17 00:00:00 2001 From: Lars Corneliussen Date: Mon, 9 Dec 2013 14:56:57 +0100 Subject: [PATCH 05/17] _.chain(T[]).keys() should be a Chain not Chain --- underscore/underscore.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/underscore/underscore.d.ts b/underscore/underscore.d.ts index db37d6ae0..4382f7bea 100644 --- a/underscore/underscore.d.ts +++ b/underscore/underscore.d.ts @@ -2707,7 +2707,7 @@ interface _Chain { * Wrapped type `object`. * @see _.keys **/ - keys(): _Chain; + keys(): _Chain; /** * Wrapped type `object`. From 858341fc3f163dd78f5a668f6e5462151da7ef65 Mon Sep 17 00:00:00 2001 From: Paul Loyd Date: Fri, 6 Dec 2013 22:08:07 +0400 Subject: [PATCH 06/17] Rename Timer to NodeTimer --- node/node.d.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/node/node.d.ts b/node/node.d.ts index a57fb96d1..4c8c043d3 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -15,10 +15,10 @@ declare var global: any; declare var __filename: string; declare var __dirname: string; -declare function setTimeout(callback: (...args: any[]) => void , ms: number , ...args: any[]): Timer; -declare function clearTimeout(timeoutId: Timer): void; -declare function setInterval(callback: (...args: any[]) => void , ms: number , ...args: any[]): Timer; -declare function clearInterval(intervalId: Timer): void; +declare function setTimeout(callback: (...args: any[]) => void , ms: number , ...args: any[]): NodeTimer; +declare function clearTimeout(timeoutId: NodeTimer): void; +declare function setInterval(callback: (...args: any[]) => void , ms: number , ...args: any[]): NodeTimer; +declare function clearInterval(intervalId: NodeTimer): void; declare function setImmediate(callback: (...args: any[]) => void , ...args: any[]): any; declare function clearImmediate(immediateId: any): void; @@ -198,7 +198,7 @@ interface NodeBuffer { INSPECT_MAX_BYTES: number; } -interface Timer { +interface NodeTimer { ref() : void; unref() : void; } From effe8b1c71263d3411ab60a7775bc98c85177299 Mon Sep 17 00:00:00 2001 From: Paul Loyd Date: Mon, 9 Dec 2013 19:05:49 +0400 Subject: [PATCH 07/17] Add undocumented but useful fields to WebSocket-Node --- websocket/websocket.d.ts | 254 ++++++++++++++++++++++++++++----------- 1 file changed, 181 insertions(+), 73 deletions(-) diff --git a/websocket/websocket.d.ts b/websocket/websocket.d.ts index 7dbd9a67c..d3b139222 100644 --- a/websocket/websocket.d.ts +++ b/websocket/websocket.d.ts @@ -11,7 +11,52 @@ declare module "websocket" { import net = require('net'); import url = require('url'); - export interface IServerConfig { + export interface IStringified { + toString: (...args: any[]) => string; + } + + export interface IConfig { + /** + * The maximum allowed received frame size in bytes. + * Single frame messages will also be limited to this maximum. + */ + maxReceivedFrameSize?: number; + + /** The maximum allowed aggregate message size (for fragmented messages) in bytes */ + maxReceivedMessageSize?: number; + + /** + * Whether or not to fragment outgoing messages. If true, messages will be + * automatically fragmented into chunks of up to `fragmentationThreshold` bytes. + * @default true + */ + fragmentOutgoingMessages?: boolean; + + /** + * The maximum size of a frame in bytes before it is automatically fragmented. + * @default 16KiB + */ + fragmentationThreshold?: number; + + /** + * If true, fragmented messages will be automatically assembled and the full + * message will be emitted via a `message` event. If false, each frame will be + * emitted on the `connection` object via a `frame` event and the application + * will be responsible for aggregating multiple fragmented frames. Single-frame + * messages will emit a `message` event in addition to the `frame` event. + * @default true + */ + assembleFragments?: boolean; + + /** + * The number of milliseconds to wait after sending a close frame for an + * `acknowledgement` to come back before giving up and just closing the socket. + * @default 5000 + */ + closeTimeout?: number; + } + + export interface IServerConfig extends IConfig { /** The http server instance to attach to */ httpServer: http.Server; @@ -28,19 +73,6 @@ declare module "websocket" { */ maxReceivedMessageSize?: number; - /** - * Whether or not to fragment outgoing messages. If true, messages will be - * automatically fragmented into chunks of up to `fragmentationThreshold` bytes. - * @default true - */ - fragmentOutgoingMessages?: boolean; - - /** - * The maximum size of a frame in bytes before it is automatically fragmented. - * @default 16KiB - */ - fragmentationThreshold?: number; - /** * If true, the server will automatically send a ping to all clients every * `keepaliveInterval` milliseconds. Each client has an independent `keepalive` @@ -72,16 +104,6 @@ declare module "websocket" { */ keepaliveGracePeriod?: number; - /** - * If true, fragmented messages will be automatically assembled and the full - * message will be emitted via a `message` event. If false, each frame will be - * emitted on the `connection` object via a `frame` event and the application - * will be responsible for aggregating multiple fragmented frames. Single-frame - * messages will emit a `message` event in addition to the `frame` event. - * @default true - */ - assembleFragments?: boolean; - /** * If this is true, websocket connections will be accepted regardless of the path * and protocol specified by the client. The protocol accepted will be the first @@ -90,13 +112,6 @@ declare module "websocket" { */ autoAcceptConnections?: boolean; - /** - * The number of milliseconds to wait after sending a close frame for an - * `acknowledgement` to come back before giving up and just closing the socket. - * @default 5000 - */ - closeTimeout?: number; - /** * The Nagle Algorithm makes more efficient use of network resources by introducing a * small delay before sending small packets so that multiple messages can be batched @@ -107,8 +122,19 @@ declare module "websocket" { } export class server extends events.EventEmitter { + config: IServerConfig; + connections: connection[]; + constructor(serverConfig?: IServerConfig); + /** Send binary message for each connection */ + broadcast(data: NodeBuffer): void; + /** Send UTF-8 message for each connection */ + broadcast(data: IStringified): void; + /** Send binary message for each connection */ + broadcastBytes(data: NodeBuffer): void; + /** Send UTF-8 message for each connection */ + broadcastUTF(data: IStringified): void; /** Attach the `server` instance to a Node http.Server instance */ mount(serverConfig: IServerConfig): void; @@ -135,6 +161,22 @@ declare module "websocket" { addListener(event: 'close', cb: (connection: connection, reason: number, desc: string) => void): server; } + export interface ICookie { + name: string; + value: string; + path?: string; + domain?: string; + expires?: Date; + maxage?: number; + secure?: boolean; + httponly?: boolean; + } + + export interface IExtension { + name: string; + value: string; + } + export class request extends events.EventEmitter { /** A reference to the original Node HTTP request object */ httpRequest: http.ClientRequest; @@ -142,6 +184,8 @@ declare module "websocket" { host: string; /** A string containing the path that was requested by the client */ resource: string; + /** `Sec-WebSocket-Key` */ + key: string; /** Parsed resource, including the query string parameters */ resourceURL: url.Url; @@ -163,6 +207,9 @@ declare module "websocket" { /** An array containing a list of extensions requested by the client */ requestedExtensions: any[]; + cookies: ICookie[]; + socket: net.NodeSocket; + /** * List of strings that indicate the subprotocols the client would like to speak. * The server should select the best one that it can support from the list and @@ -171,6 +218,7 @@ declare module "websocket" { * converted to lower case. */ requestedProtocols: string[]; + protocolFullCaseMap: {[key: string]: string}; constructor(socket: net.NodeSocket, httpRequest: http.ClientRequest, config: IServerConfig); @@ -181,7 +229,7 @@ declare module "websocket" { * * @param [acceptedProtocol] case-insensitive value that was requested by the client */ - accept(acceptedProtocol?: string, allowedOrigin?: string, cookies?: any[]): connection; + accept(acceptedProtocol?: string, allowedOrigin?: string, cookies?: ICookie[]): connection; /** * Reject connection. @@ -206,6 +254,48 @@ declare module "websocket" { binaryData?: NodeBuffer; } + export interface IBufferList extends events.EventEmitter { + encoding: string; + length: number; + write(buf: NodeBuffer): boolean; + end(buf: NodeBuffer): void; + + /** + * For each buffer, perform some action. + * If fn's result is a true value, cut out early. + */ + forEach(fn: (buf: NodeBuffer) => boolean): void; + + /** Create a single buffer out of all the chunks */ + join(start: number, end: number): NodeBuffer; + + /** Join all the chunks to existing buffer */ + joinInto(buf: NodeBuffer, offset: number, start: number, end: number): NodeBuffer; + + /** + * Advance the buffer stream by `n` bytes. + * If `n` the aggregate advance offset passes the end of the buffer list, + * operations such as `take` will return empty strings until enough data is pushed. + */ + advance(n: number): IBufferList; + + /** + * Take `n` bytes from the start of the buffers. + * If there are less than `n` bytes in all the buffers or `n` is undefined, + * returns the entire concatenated buffer string. + */ + take(n: number, encoding?: string): any; + take(encoding?: string): any; + + // Events + on(event: string, listener: () => void): IBufferList; + on(event: 'advance', cb: (n: number) => void): IBufferList; + on(event: 'write', cb: (buf: NodeBuffer) => void): IBufferList; + addListener(event: string, listener: () => void): IBufferList; + addListener(event: 'advance', cb: (n: number) => void): IBufferList; + addListener(event: 'write', cb: (buf: NodeBuffer) => void): IBufferList; + } + class connection extends events.EventEmitter { static CLOSE_REASON_NORMAL: number; static CLOSE_REASON_GOING_AWAY: number; @@ -237,9 +327,26 @@ declare module "websocket" { */ protocol: string; + config: IConfig; socket: net.NodeSocket; + maskOutgoingPackets: boolean; + maskBytes: NodeBuffer; + frameHeader: NodeBuffer; + bufferList: IBufferList; + currentFrame: frame; + fragmentationSize: number; + frameQueue: frame[]; + state: string; + waitingForCloseResponse: boolean; + closeTimeout: number; + assembleFragments: number; + maxReceivedMessageSize: number; + outputPaused: boolean; + bytesWaitingToFlush: number; + socketHadError: boolean; + /** An array of extensions that were negotiated for this connection */ - extensions: any[]; + extensions: IExtension[]; /** * The IP address of the remote peer as a string. In the case of a server, @@ -254,8 +361,8 @@ declare module "websocket" { /** Whether or not the connection is still connected. Read-only */ connected: boolean; - constructor(socket: net.NodeSocket, extensions: any[], protocol: string, - maskOutgoingPackets: boolean, config: IServerConfig); + constructor(socket: net.NodeSocket, extensions: IExtension[], protocol: string, + maskOutgoingPackets: boolean, config: IConfig); /** * Close the connection. A close frame will be sent to the remote peer indicating @@ -276,7 +383,7 @@ declare module "websocket" { * peer. If `config.fragmentOutgoingMessages` is true the message may be sent as * multiple fragments if it exceeds `config.fragmentationThreshold` bytes. */ - sendUTF(data: {toString: (...args: any[]) => string}): void; + sendUTF(data: IStringified): void; /** * Immediately sends the specified Node Buffer object as a Binary WebSocket message @@ -287,11 +394,11 @@ declare module "websocket" { /** Auto-detect the data type and send UTF-8 or Binary message */ send(data: NodeBuffer): void; - send(data: {toString: (...args: any[]) => string}): void; + send(data: IStringified): void; /** Sends a ping frame. Ping frames must not exceed 125 bytes in length. */ ping(data: NodeBuffer): void; - ping(data: {toString: (...args: any[]) => string}): void; + ping(data: IStringified): void; /** * Sends a pong frame. Pong frames may be sent unsolicited and such pong frames will @@ -310,6 +417,18 @@ declare module "websocket" { */ sendFrame(frame: frame): void; + /** Set or reset the `keepalive` timer when data is received */ + setKeepaliveTimer(): void; + setGracePeriodTimer(): void; + setCloseTimer(): void; + clearCloseTimer(): void; + processFrame(frame: frame): void; + fragmentAndSend(frame: frame, cb?: (err: Error) => void): void; + sendCloseFrame(reasonCode: number, reasonText: string, force: boolean): void; + sendCloseFrame(): void; + sendFrame(frame: frame, force: boolean, cb?: (msg: string) => void): void; + sendFrame(frame: frame, cb?: (msg: string) => void): void; + // Events on(event: string, listener: () => void): connection; on(event: 'message', cb: (data: IMessage) => void): connection; @@ -376,9 +495,22 @@ declare module "websocket" { * Even text frames are sent with a Buffer providing the binary payload data. */ binaryPayload: NodeBuffer; + + maskBytes: NodeBuffer; + frameHeader: NodeBuffer; + config: IConfig; + maxReceivedFrameSize: number; + protocolError: boolean; + frameTooLarge: boolean; + invalidCloseFrameLength: boolean; + closeStatus: number; + + addData(bufferList: IBufferList): boolean; + throwAwayPayload(bufferList: IBufferList): boolean; + toBuffer(nullMask: boolean): NodeBuffer; } - export interface IClientConfig { + export interface IClientConfig extends IConfig { /** * Which version of the WebSocket protocol to use when making the connection. * Currently supported values are 8 and 13. This option will be removed once the @@ -387,54 +519,30 @@ declare module "websocket" { * the name of the Origin header. * @default 13 */ - webSocketVersion: number; + webSocketVersion?: number; /** * The maximum allowed received frame size in bytes. * Single frame messages will also be limited to this maximum. * @default 1MiB */ - maxReceivedFrameSize: number; + maxReceivedFrameSize?: number; /** * The maximum allowed aggregate message size (for fragmented messages) in bytes. * @default 8MiB */ - maxReceivedMessageSize: number; - - /** - * Whether or not to fragment outgoing messages. If true, messages will be - * automatically fragmented into chunks of up to `fragmentationThreshold` bytes. - * @default true - */ - fragmentOutgoingMessages: boolean; - - /** - * The maximum size of a frame in bytes before it is automatically fragmented. - * @default 16KiB - */ - fragmentationThreshold: number; - - /** - * If true, fragmented messages will be automatically assembled and the full message - * will be emitted via a `message` event. If false, each frame will be emitted on - * the `connection` object via a `frame` event and the application will be responsible - * for aggregating multiple fragmented frames. Single-frame messages will emit - * a `message` event in addition to the `frame` event. Most users will want to - * leave this set to true. - * @default true - */ - assembleFragments: boolean; - - /** - * The number of milliseconds to wait after sending a close frame for - * an acknowledgement to come back before giving up and just closing the socket. - * @default 5000 - */ - closeTimeout: number; + maxReceivedMessageSize?: number; } class client extends events.EventEmitter { + protocols: string[]; + origin: string; + url: url.Url; + secure: boolean; + socket: net.NodeSocket; + response: http.ClientResponse; + constructor(clientConfig?: IClientConfig); /** From 4ca422a18c3de7f6d2a19bf3b6937a796820efdb Mon Sep 17 00:00:00 2001 From: gandjustas Date: Mon, 9 Dec 2013 23:34:57 +0400 Subject: [PATCH 08/17] Added SP.Publishing and SP.DocumentManagement; Checked for TS 0.9.5 --- sharepoint/SharePoint.d.ts | 465 ++++++++++++++++++++++++++++++++++++- 1 file changed, 459 insertions(+), 6 deletions(-) diff --git a/sharepoint/SharePoint.d.ts b/sharepoint/SharePoint.d.ts index 4671ba19e..9f872afaf 100644 --- a/sharepoint/SharePoint.d.ts +++ b/sharepoint/SharePoint.d.ts @@ -1600,9 +1600,14 @@ declare module SP { constructor(clientObject: SP.ClientObject, propertyName: string, comparisonOperator: string, valueToCompare: any); constructor(clientObject: SP.ClientObject, propertyName: string, comparisonOperator: string, valueToCompare: any, allowAllActions: boolean); } - export class ClientResult { - get_value(): any; - setValue(value: any): void; + //export class ClientResult { + // get_value(): any; + // setValue(value: any): void; + // constructor(); + //} + export class ClientResult { + get_value(): T; + setValue(value: T): void; constructor(); } export class BooleanResult { @@ -1637,8 +1642,8 @@ declare module SP { get_value(): any; constructor(); } - export class ClientDictionaryResultHandler { - constructor(dict: SP.ClientResult); + export class ClientDictionaryResultHandler { + constructor(dict: SP.ClientResult); } export class ClientUtility { static urlPathEncodeForXmlHttpRequest(url: string): string; @@ -6744,6 +6749,53 @@ declare module SP { } } +declare module SP { + export module DocumentSet { + export class DocumentSet extends ClientObject { + static create(context: ClientContext, parentFolder: Folder, name: string, ctid: ContentTypeId): StringResult; + } + } + + export module Video { + export class EmbedCodeConfiguration extends ClientValueObject { + public get_autoPlay(): boolean; + public set_autoPlay(value: boolean): boolean; + + public get_displayTitle(): boolean; + public set_displayTitle(value: boolean): boolean; + + public get_linkToOwnerProfilePage(): boolean; + public set_linkToOwnerProfilePage(value: boolean): boolean; + + public get_linkToVideoHomePage(): boolean; + public set_linkToVideoHomePage(value: boolean): boolean; + + public get_loop(): boolean; + public set_loop(value: boolean): boolean; + + public get_pixelHeight(): number; + public set_pixelHeight(value: number): number; + + public get_pixelWidth(): number; + public set_pixelWidth(value: number): number; + + public get_startTime(): number; + public set_startTime(value: number): number; + + public get_previewImagePath(): string; + public set_previewImagePath(value: string): string; + } + + export class VideoSet extends DocumentSet.DocumentSet { + static createVideo(context: ClientContext, parentFolder: Folder, name: string, ctid: ContentTypeId): StringResult; + static uploadVideo(context: ClientContext, list: List, fileName: string, file: any[], overwriteIfExists: boolean, parentFolderPath: string): StringResult; + static getEmbedCode(context: ClientContext, videoPath: string, properties: EmbedCodeConfiguration): StringResult; + static migrateVideo(context: ClientContext, videoFile: File): SP.ListItem; + } + } +} + + declare module SP { export module UI { export module ApplicationPages { @@ -8013,7 +8065,7 @@ declare module SP.WorkflowServices { getDesignerActions(web: SP.Web): SP.StringResult; /** Returns an XML representation of a collection of XAML class signatures for workflow definitions. @param lastChanges Date time value representing the latest changes; class signatures older than this time are excluded from the result set. */ - getActivitySignatures(lastChanged: string): SP.ClientResult; + getActivitySignatures(lastChanged: string): SP.ClientResult; /** Saves a SharePoint workflow definition to the workflow store. */ saveDefinition(definition: WorkflowDefinition): SP.GuidResult; /** Validates the specified activity against workflow definitions in the workflow store. */ @@ -8231,6 +8283,407 @@ declare module SP.WorkflowServices { } + + +declare module SP { + export module Publishing { + export class PublishingWeb extends ClientObject { + static getPublishingWeb(context: ClientContext, web: Web): PublishingWeb; + + public get_web(): Web; + public addPublishingPage(pageInformation: PublishingPageInformation): PublishingPage; + } + + export class PublishingPageInformation extends ClientValueObject { + + public get_folder(): Folder; + public set_folder(value: Folder): Folder; + + public get_name(): string; + public set_name(value: string): string; + + public get_pageLayoutListItem(): ListItem; + public set_pageLayoutListItem(value: ListItem): ListItem; + } + + export class PublishingPage extends ScheduledItem { + static getPublishingPage(context: ClientContext, sourceListItem: ListItem): PublishingPage; + public addFriendlyUrl(friendlyUrlSegment: string, editableParent: Navigation.NavigationTermSetItem, doAddToNavigation: boolean): StringResult; + } + + export class ScheduledItem extends ClientObject { + public get_listItem(): ListItem; + + public get_startDate(): Date; + public set_startDate(value: Date): Date; + + public get_endDate(): Date; + public set_endDate(value: Date): Date; + + public schedule(approvalComment: string): void; + } + + export class PublishingSite extends ClientObject { + static createPageLayout(context: ClientContext, parameters: PageLayoutCreationInformation): void; + } + + export class PageLayoutCreationInformation extends ClientValueObject { + public get_web(): Web; + public set_web(value: Web): Web; + + public get_associatedContentTypeId(): string; + public set_associatedContentTypeId(value: string): string; + + public get_masterPageUrl(): string; + public set_masterPageUrl(value: string): string; + + public get_newPageLayoutNameWithoutExtension(): string; + public set_newPageLayoutNameWithoutExtension(value: string): string; + + public get_newPageLayoutEditablePath(): string; + public set_newPageLayoutEditablePath(value: string): string; + } + + export class SiteServicesAddins { + static getSettings(context: ClientContext, addinId: Guid): AddinSettings; + static setSettings(context: ClientContext, addin: AddinSettings): void; + static deleteSettings(context: ClientContext, addinId: Guid): void; + + static getPlugin(context: ClientContext, pluginName: string): AddinPlugin; + static setPlugin(context: ClientContext, addin: AddinPlugin): void; + static deletePlugin(context: ClientContext, pluginName: string): void; + } + + export class AddinSettings extends ClientObject { + constructor(ctx: ClientContext, id: Guid); + + public get_id(): Guid; + + public get_title(): string; + public set_title(value: string): string; + + public get_description(): string; + public set_description(value: string): string; + + public get_enabled(): boolean; + public set_enabled(value: boolean): boolean; + + public get_namespace(): boolean; + public set_namespace(value: boolean): boolean; + + public get_headScript(): string; + public set_headScript(value: string): string; + + public get_htmlStartBody(): string; + public set_htmlStartBody(value: string): string; + + public get_htmlEndBody(): string; + public set_htmlEndBody(value: string): string; + + public get_metaTagPagePropertyMappings(): { [key: string]: string }; + public set_metaTagPagePropertyMappings(value: { [key: string]: string }): { [key: string]: string }; + + } + + export class AddinPlugin extends ClientObject { + constructor(ctx: ClientContext); + + public get_description(): string; + public set_description(value: string): string; + + public get_markup(): string; + public set_markup(value: string): string; + + public get_title(): string; + public set_title(value: string): string; + } + + + export class DesignPackage { + static install(context: ClientContext, site: Site, info: DesignPackageInfo, path: string): void; + static uninstall(context: ClientContext, site: Site, info: DesignPackageInfo): void; + static apply(context: ClientContext, site: Site, info: DesignPackageInfo): void; + static exportEnterprise(context: ClientContext, site: Site, includeSearchConfiguration: boolean): ClientResult; + static exportSmallBusiness(context: ClientContext, site: Site, packageName: string, includeSearchConfiguration: boolean): ClientResult; + } + + export class DesignPackageInfo extends ClientValueObject { + public get_packageName(): string; + public set_packageName(value: string): string; + + public get_packageGuid(): Guid; + public set_packageGuid(value: Guid): Guid; + + public get_majorVersion(): number; + public set_majorVersion(value: number): number; + + public get_minorVersion(): number; + public set_minorVersion(value: number): number; + } + + export class SiteImageRenditions { + static getRenditions(context: ClientContext): ImageRendition[]; + static setRenditions(context: ClientContext, renditions: ImageRendition[]): void; + } + + export class ImageRendition extends ClientValueObject { + public get_id(): number; + public get_version(): number; + + public get_name(): string; + public set_name(value: string): string; + + public get_width(): number; + public set_width(value: number): number; + + public get_height(): number; + public set_height(value: number): number; + } + + export class Variations extends ClientObject { + static getLabels(context: ClientContext): ClientObjectList; + static getPeerUrl(context: ClientContext, currentUrl: string, labelTitle: string): StringResult; + static updateListItems(context: ClientContext, listId: Guid, itemIds: number[]): void; + } + + export class VariationLabel extends ClientObject { + public get_displayName(): string; + public set_displayName(value: string): string; + + public get_isSource(): boolean; + public set_isSource(value: boolean): boolean; + + public get_language(): string; + public set_language(value: string): string; + + public get_locale(): string; + public set_locale(value: string): string; + + public get_title(): string; + public set_title(value: string): string; + + public get_topWebUrl(): string; + public set_topWebUrl(value: string): string; + } + + export class CustomizableString extends ClientObject { + public get_defaultValue(): string; + + public get_value(): string; + public set_value(value: string): string; + + public get_usesDefaultValue(): boolean; + public set_usesDefaultValue(value: boolean): boolean; + + } + + + export module Navigation { + export enum NavigationLinkType { + root, + friendlyUrl, + simpleLink + } + + export enum StandardNavigationSource { + unknown, + portalProvider, + taxonomyProvider, + inheritFromParentWeb + } + + export class NavigationTermSetItem extends ClientObject { + public get_id(): Guid; + + public get_isReadOnly(): boolean; + + public get_linkType(): NavigationLinkType; + public set_linkType(value: NavigationLinkType): NavigationLinkType; + + public get_targetUrlForChildTerms(): CustomizableString; + + public get_catalogTargetUrlForChildTerms(): CustomizableString; + + public get_taxonomyName(): string; + + public get_title(): CustomizableString; + + public get_terms(): NavigationTermCollection; + + public get_view(): NavigationTermSetView; + + public createTerm(termName: string, linkType: NavigationLinkType, termId: Guid); + + public getTaxonomyTermStore(): Taxonomy.TermStore; + + public getResolvedDisplayUrl(browserQueryString: string): StringResult; + } + + export class NavigationTermCollection extends ClientObjectCollection { + + } + + export class NavigationTerm extends NavigationTermSetItem { + public get_associatedFolderUrl(): string; + public set_associatedFolderUrl(value: string): string; + + public get_catalogTargetUrl(): CustomizableString; + + public get_categoryImageUrl(): string; + public set_categoryImageUrl(value: string): string; + + public get_excludedProviders(): NavigationTermProviderNameCollection; + + public get_excludeFromCurrentNavigation(): boolean; + public set_excludeFromCurrentNavigation(value: boolean): boolean; + + public get_excludeFromGlobalNavigation(): boolean; + public set_excludeFromGlobalNavigation(value: boolean): boolean; + + public get_friendlyUrlSegment(): CustomizableString; + + public get_hoverText(): string; + public set_hoverText(value: string): string; + + public get_isDeprecated(): boolean; + public get_isPinned(): boolean; + public get_isPinnedRoot(): boolean; + + public get_parent(): NavigationTerm; + + public get_simpleLinkUrl(): string; + + public set_simpleLinkUrl(value: string): string; + + public get_targetUrl(): CustomizableString; + + public get_termSet(): NavigationTermSet; + + public getAsEditable(taxonomySession: Taxonomy.TaxonomySession): NavigationTerm; + + public getWithNewView(newView: NavigationTermSetView): NavigationTerm; + + public getResolvedTargetUrl(browserQueryString: string, remainingUrlSegments: string[]): StringResult; + + public getResolvedTargetUrlWithoutQuery(): StringResult; + + public getResolvedAssociatedFolderUrl(): StringResult; + + public getWebRelativeFriendlyUrl(); StringResult; + + public getAllParentTerms(): NavigationTermCollection; + + public getTaxonomyTerm(): Taxonomy.Term; + + public move(newParent: NavigationTermSetItem): void; + + public deleteObject(): void; + + static getAsResolvedByWeb(context: ClientContext, term: Taxonomy.Term, web: Web, siteMapProviderName: string): NavigationTerm; + static getAsResolvedByView(context: ClientContext, term: Taxonomy.Term, view: NavigationTermSetView): NavigationTerm; + } + + + export class NavigationTermSet extends NavigationTermSetItem { + public get_isNavigationTermSet(): boolean; + public set_isNavigationTermSet(value: boolean): boolean; + + public get_lcid(): number; + + public get_loadedFromPersistedData(): boolean; + + public get_termGroupId(): Guid; + public get_termStoreId(): Guid; + + public getAsEditable(taxonomySession: Taxonomy.TaxonomySession): NavigationTermSet; + + public getWithNewView(newView: NavigationTermSetView): NavigationTermSet; + + public getTaxonomyTermSet(): Taxonomy.TermSet; + + public getAllTerms(): NavigationTermCollection; + + public findTermForUrl(usr: string): NavigationTerm; + + static getAsResolvedByWeb(context: ClientContext, termSet: Taxonomy.TermSet, web: Web, siteMapProviderName: string): NavigationTermSet; + static getAsResolvedByView(context: ClientContext, termSet: Taxonomy.TermSet, view: NavigationTermSetView): NavigationTermSet; + } + + + export class NavigationTermProviderNameCollection extends ClientObjectCollection { + public Add(item: string): void; + public Clear(): void; + public Remove(item: string): BooleanResult; + } + + export class NavigationTermSetView extends ClientObject { + constructor(context: ClientContext, web: Web, siteMapProviderName: string); + + public get_excludeDeprecatedTerms(): boolean; + public set_excludeDeprecatedTerms(value: boolean): boolean; + + public get_excludeTermsByPermissions(): boolean; + public set_excludeTermsByPermissions(value: boolean): boolean; + + public get_excludeTermsByProvider(): boolean; + public set_excludeTermsByProvider(value: boolean): boolean; + + public get_serverRelativeSiteUrl(): string; + + public get_serverRelativeWebUrl(): string; + + public get_siteMapProviderName(): string; + public set_siteMapProviderName(value: string): string; + + public get_webId(): Guid; + public get_webTitle(): string; + + public getCopy(): NavigationTermSetView; + + static createEmptyInstance(context: ClientContext): NavigationTermSetView; + } + + export class TaxonomyNavigation { + static getWebNavigationSettings(context: ClientContext, web: Web): WebNavigationSettings; + static getTermSetForWeb(context: ClientContext, web: Web, siteMapProviderName: string, includeInheritedSettings: boolean): NavigationTermSet; + static setCrawlAsFriendlyUrlPage(context: ClientContext, navigationTerm, crawlAsFriendlyUrlPage): BooleanResult; + static getNavigationLcidForWeb(context: ClientContext, web: Web): IntResult; + static flushSiteFromCache(context: ClientContext, site: Site): void; + static flushWebFromCache(context: ClientContext, web: Web): void; + static flushTermSetFromCache(context: ClientContext, webForPermissions, termStoreId: Guid, termSetId: Guid): void; + } + + export class WebNavigationSettings extends ClientObject { + constructor(context: ClientContext, web: Web); + + public get_addNewPagesToNavigation(): boolean; + public set_addNewPagesToNavigation(value: boolean): boolean; + + public get_createFriendlyUrlsForNewPages(): boolean; + public set_createFriendlyUrlsForNewPages(value: boolean): boolean; + + public get_currentNavigation(): StandardNavigationSettings; + public get_globalNavigation(): StandardNavigationSettings; + + public update(taxonomySession: Taxonomy.TaxonomySession): void; + public resetToDefaults(): void; + } + + export class StandardNavigationSettings extends ClientObject { + public get_termSetId(): Guid; + public set_termSetId(value: Guid): Guid; + + public get_termStoreId(): Guid; + public set_termStoreId(value: Guid): Guid; + + public get_source(): StandardNavigationSource; + + public set_source(value: StandardNavigationSource): StandardNavigationSource; + } + + } + } +} declare class SPClientAutoFill { static MenuOptionType: { Option: number; From c94dcde7911531813eaa068e928d95e4deb552a3 Mon Sep 17 00:00:00 2001 From: Christiaan Rakowski Date: Wed, 4 Dec 2013 08:58:49 +0100 Subject: [PATCH 09/17] straight up copy --- iscroll/iscroll-5-lite.d.ts | 48 +++++++++++++++++++++++ iscroll/iscroll-5-tests.ts | 31 +++++++++++++++ iscroll/iscroll-5.d.ts | 76 +++++++++++++++++++++++++++++++++++++ 3 files changed, 155 insertions(+) create mode 100644 iscroll/iscroll-5-lite.d.ts create mode 100644 iscroll/iscroll-5-tests.ts create mode 100644 iscroll/iscroll-5.d.ts diff --git a/iscroll/iscroll-5-lite.d.ts b/iscroll/iscroll-5-lite.d.ts new file mode 100644 index 000000000..1cd83b1dd --- /dev/null +++ b/iscroll/iscroll-5-lite.d.ts @@ -0,0 +1,48 @@ +// Type definitions for iScroll Lite 4.1 +// Project: http://cubiq.org/iscroll-4 +// Definitions by: Boris Yankov and Christiaan Rakowski +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +interface iScrollEvent { + (e: Event): void; +} + +interface iScrollOptions { + hScroll?: boolean; + vScroll?: boolean; + x?: number; + y?: number; + bounce?: boolean; + bounceLock?: boolean; + momentum?: boolean; + lockDirection?: boolean; + useTransform?: boolean; + useTransition?: boolean; + + // Events + onRefresh?: iScrollEvent; + onBeforeScrollStart?: iScrollEvent; + onScrollStart?: iScrollEvent; + onBeforeScrollMove?: iScrollEvent; + onScrollMove?: iScrollEvent; + onBeforeScrollEnd?: iScrollEvent; + onScrollEnd?: iScrollEvent; + onTouchEnd?: iScrollEvent; + onDestroy?: iScrollEvent; +} + +declare class iScroll { + + constructor (element: string, options?: iScrollOptions); + constructor (element: HTMLElement, options?: iScrollOptions); + + destroy(): void; + refresh(): void; + scrollTo(x: number, y: number, time?: number, relative?: boolean): void; + scrollToElement(element: string, time?: number): void; + scrollToElement(element: HTMLElement, time?: number): void; + disable(): void; + enable(): void; + stop(): void; +} diff --git a/iscroll/iscroll-5-tests.ts b/iscroll/iscroll-5-tests.ts new file mode 100644 index 000000000..773b62acf --- /dev/null +++ b/iscroll/iscroll-5-tests.ts @@ -0,0 +1,31 @@ +/// + +var myScroll1 = new iScroll('wrapper'); +var myScroll2 = new iScroll('wrapper', { hScrollbar: false, vScrollbar: false }); +var myScroll3= new iScroll('wrapper', { + snap: true, + momentum: false, + hScrollbar: false, + vScrollbar: false +}); +var myScroll4 = new iScroll('wrapper', { + snap: 'li', + momentum: false, + hScrollbar: false, + vScrollbar: false +}); +var myScroll6 = new iScroll('wrapper', { scrollbarClass: 'myScrollbar' }); + +myScroll1.refresh(); +myScroll1.scrollTo(0, 100); +myScroll1.scrollTo(0, 100, 200); +myScroll1.scrollTo(0, 100, 200, true); + +myScroll1.scrollToElement('selectedElement'); +myScroll1.scrollToElement('selectedElement', 250); + +myScroll1.scrollToElement(document.getElementById('selectedElement')); +myScroll1.scrollToElement(document.getElementById('selectedElement'), 250); + +var myScroll7 = new iScroll(document.getElementById('wrapper')); +var myScroll8 = new iScroll(document.getElementById('wrapper'), { scrollbarClass: 'myScrollbar' }); \ No newline at end of file diff --git a/iscroll/iscroll-5.d.ts b/iscroll/iscroll-5.d.ts new file mode 100644 index 000000000..34234c00a --- /dev/null +++ b/iscroll/iscroll-5.d.ts @@ -0,0 +1,76 @@ +// Type definitions for iScroll 4.2 +// Project: http://cubiq.org/iscroll-4 +// Definitions by: Boris Yankov and Christiaan Rakowski +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +interface iScrollEvent { + (e: Event): void; +} + +interface iScrollOptions { + hScroll?: boolean; + vScroll?: boolean; + x?: number; + y?: number; + bounce?: boolean; + bounceLock?: boolean; + momentum?: boolean; + lockDirection?: boolean; + useTransform?: boolean; + useTransition?: boolean; + topOffset?: number; + checkDOMChanges?: boolean; + handleClick?: boolean; + + // Scrollbar + hScrollbar?: boolean; + vScrollbar?: boolean; + fixedScrollbar?: boolean; + hideScrollbar?: boolean; + fadeScrollbar?: boolean; + scrollbarClass?: string; + + // Zoom + zoom?: boolean; + zoomMin?: number; + zoomMax?: number; + doubleTapZoom?: number; + wheelAction?: string; + + // Snap + snap?: any; + snapThreshold?: number; + + // Events + onRefresh?: iScrollEvent; + onBeforeScrollStart?: iScrollEvent; + onScrollStart?: iScrollEvent; + onBeforeScrollMove?: iScrollEvent; + onScrollMove?: iScrollEvent; + onBeforeScrollEnd?: iScrollEvent; + onScrollEnd?: iScrollEvent; + onTouchEnd?: iScrollEvent; + onDestroy?: iScrollEvent; + onZoomStart?: iScrollEvent; + onZoom?: iScrollEvent; + onZoomEnd?: iScrollEvent; +} + +declare class iScroll { + + constructor (element: string, options?: iScrollOptions); + constructor (element: HTMLElement, options?: iScrollOptions); + + destroy(): void; + refresh(): void; + scrollTo(x: number, y: number, time?: number, relative?: boolean): void; + scrollToElement(element: string, time?: number): void; + scrollToElement(element: HTMLElement, time?: number): void; + scrollToPage(pageX: number, pageY: number, time?: number): void; + disable(): void; + enable(): void; + stop(): void; + zoom(x: number, y: number, scale: number, time?: number): void; + isReady(): boolean; +} From 93240145a84580ea88dce844ff9e477c9c287acc Mon Sep 17 00:00:00 2001 From: Christiaan Rakowski Date: Tue, 10 Dec 2013 11:14:44 +0100 Subject: [PATCH 10/17] changed iScroll to IScroll, removed old events from options and added the .on method --- iscroll/iscroll-5-lite.d.ts | 67 +++++++++----------- iscroll/iscroll-5-tests.ts | 21 ++++--- iscroll/iscroll-5.d.ts | 118 ++++++++++++++++-------------------- 3 files changed, 91 insertions(+), 115 deletions(-) diff --git a/iscroll/iscroll-5-lite.d.ts b/iscroll/iscroll-5-lite.d.ts index 1cd83b1dd..5324aecba 100644 --- a/iscroll/iscroll-5-lite.d.ts +++ b/iscroll/iscroll-5-lite.d.ts @@ -1,48 +1,35 @@ -// Type definitions for iScroll Lite 4.1 -// Project: http://cubiq.org/iscroll-4 -// Definitions by: Boris Yankov and Christiaan Rakowski +// Type definitions for iScroll Lite 5 +// Project: http://cubiq.org/iscroll-5-ready-for-beta-test +// Definitions by: Christiaan Rakowski // Definitions: https://github.com/borisyankov/DefinitelyTyped - -interface iScrollEvent { - (e: Event): void; -} - -interface iScrollOptions { - hScroll?: boolean; - vScroll?: boolean; - x?: number; - y?: number; - bounce?: boolean; - bounceLock?: boolean; - momentum?: boolean; - lockDirection?: boolean; - useTransform?: boolean; - useTransition?: boolean; - - // Events - onRefresh?: iScrollEvent; - onBeforeScrollStart?: iScrollEvent; - onScrollStart?: iScrollEvent; - onBeforeScrollMove?: iScrollEvent; - onScrollMove?: iScrollEvent; - onBeforeScrollEnd?: iScrollEvent; - onScrollEnd?: iScrollEvent; - onTouchEnd?: iScrollEvent; - onDestroy?: iScrollEvent; +interface IScrollOptions { + hScroll?: boolean; + vScroll?: boolean; + x?: number; + y?: number; + bounce?: boolean; + bounceLock?: boolean; + momentum?: boolean; + lockDirection?: boolean; + useTransform?: boolean; + useTransition?: boolean; } declare class iScroll { - constructor (element: string, options?: iScrollOptions); - constructor (element: HTMLElement, options?: iScrollOptions); + constructor (element: string, options?: IScrollOptions); + constructor (element: HTMLElement, options?: IScrollOptions); - destroy(): void; - refresh(): void; - scrollTo(x: number, y: number, time?: number, relative?: boolean): void; - scrollToElement(element: string, time?: number): void; - scrollToElement(element: HTMLElement, time?: number): void; - disable(): void; - enable(): void; - stop(): void; + destroy(): void; + refresh(): void; + scrollTo(x: number, y: number, time?: number, relative?: boolean): void; + scrollToElement(element: string, time?: number): void; + scrollToElement(element: HTMLElement, time?: number): void; + disable(): void; + enable(): void; + stop(): void; + + // Events + on: (type: string, fn: () => void) => void; } diff --git a/iscroll/iscroll-5-tests.ts b/iscroll/iscroll-5-tests.ts index 773b62acf..e05761e71 100644 --- a/iscroll/iscroll-5-tests.ts +++ b/iscroll/iscroll-5-tests.ts @@ -1,20 +1,23 @@ -/// +/// -var myScroll1 = new iScroll('wrapper'); -var myScroll2 = new iScroll('wrapper', { hScrollbar: false, vScrollbar: false }); -var myScroll3= new iScroll('wrapper', { +var myScroll1 = new IScroll('#wrapper'); +var myScroll2 = new IScroll('#wrapper', { hScrollbar: false, vScrollbar: false }); +var myScroll3 = new IScroll('#wrapper', { snap: true, momentum: false, hScrollbar: false, vScrollbar: false }); -var myScroll4 = new iScroll('wrapper', { +var myScroll4 = new IScroll('#wrapper', { snap: 'li', momentum: false, hScrollbar: false, vScrollbar: false }); -var myScroll6 = new iScroll('wrapper', { scrollbarClass: 'myScrollbar' }); +var myScroll6 = new IScroll('#wrapper', { scrollbarClass: 'myScrollbar' }); +var myScroll7 = new IScroll('#wrapper', { bounceEasing: 'elastic', bounceTime: 1200 }); + +var myScroll8 = new IScroll('#wrapper', { eventPassthrough: true, scrollX: true, scrollY: false, preventDefault: false }); myScroll1.refresh(); myScroll1.scrollTo(0, 100); @@ -27,5 +30,7 @@ myScroll1.scrollToElement('selectedElement', 250); myScroll1.scrollToElement(document.getElementById('selectedElement')); myScroll1.scrollToElement(document.getElementById('selectedElement'), 250); -var myScroll7 = new iScroll(document.getElementById('wrapper')); -var myScroll8 = new iScroll(document.getElementById('wrapper'), { scrollbarClass: 'myScrollbar' }); \ No newline at end of file +myScroll2.on('scrollStart', function () { console.log('scroll started'); }); + +var myScroll9 = new IScroll(document.getElementById('wrapper')); +var myScroll10 = new IScroll(document.getElementById('wrapper'), { scrollbarClass: 'myScrollbar' }); \ No newline at end of file diff --git a/iscroll/iscroll-5.d.ts b/iscroll/iscroll-5.d.ts index 34234c00a..ded858ecb 100644 --- a/iscroll/iscroll-5.d.ts +++ b/iscroll/iscroll-5.d.ts @@ -1,76 +1,60 @@ -// Type definitions for iScroll 4.2 -// Project: http://cubiq.org/iscroll-4 -// Definitions by: Boris Yankov and Christiaan Rakowski +// Type definitions for iScroll 5 +// Project: http://cubiq.org/iscroll-5-ready-for-beta-test +// Definitions by: Christiaan Rakowski // Definitions: https://github.com/borisyankov/DefinitelyTyped +interface IScrollOptions { + hScroll?: boolean; + vScroll?: boolean; + x?: number; + y?: number; + bounce?: boolean; + bounceLock?: boolean; + momentum?: boolean; + lockDirection?: boolean; + useTransform?: boolean; + useTransition?: boolean; + topOffset?: number; + checkDOMChanges?: boolean; + handleClick?: boolean; -interface iScrollEvent { - (e: Event): void; + // Scrollbar + hScrollbar?: boolean; + vScrollbar?: boolean; + fixedScrollbar?: boolean; + hideScrollbar?: boolean; + fadeScrollbar?: boolean; + scrollbarClass?: string; + + // Zoom + zoom?: boolean; + zoomMin?: number; + zoomMax?: number; + doubleTapZoom?: number; + wheelAction?: string; + + // Snap + snap?: any; + snapThreshold?: number; } -interface iScrollOptions { - hScroll?: boolean; - vScroll?: boolean; - x?: number; - y?: number; - bounce?: boolean; - bounceLock?: boolean; - momentum?: boolean; - lockDirection?: boolean; - useTransform?: boolean; - useTransition?: boolean; - topOffset?: number; - checkDOMChanges?: boolean; - handleClick?: boolean; +declare class IScroll { - // Scrollbar - hScrollbar?: boolean; - vScrollbar?: boolean; - fixedScrollbar?: boolean; - hideScrollbar?: boolean; - fadeScrollbar?: boolean; - scrollbarClass?: string; + constructor (element: string, options?: IScrollOptions); + constructor (element: HTMLElement, options?: IScrollOptions); - // Zoom - zoom?: boolean; - zoomMin?: number; - zoomMax?: number; - doubleTapZoom?: number; - wheelAction?: string; + destroy(): void; + refresh(): void; + scrollTo(x: number, y: number, time?: number, relative?: boolean): void; + scrollToElement(element: string, time?: number): void; + scrollToElement(element: HTMLElement, time?: number): void; + scrollToPage(pageX: number, pageY: number, time?: number): void; + disable(): void; + enable(): void; + stop(): void; + zoom(x: number, y: number, scale: number, time?: number): void; + isReady(): boolean; - // Snap - snap?: any; - snapThreshold?: number; - - // Events - onRefresh?: iScrollEvent; - onBeforeScrollStart?: iScrollEvent; - onScrollStart?: iScrollEvent; - onBeforeScrollMove?: iScrollEvent; - onScrollMove?: iScrollEvent; - onBeforeScrollEnd?: iScrollEvent; - onScrollEnd?: iScrollEvent; - onTouchEnd?: iScrollEvent; - onDestroy?: iScrollEvent; - onZoomStart?: iScrollEvent; - onZoom?: iScrollEvent; - onZoomEnd?: iScrollEvent; -} - -declare class iScroll { - - constructor (element: string, options?: iScrollOptions); - constructor (element: HTMLElement, options?: iScrollOptions); - - destroy(): void; - refresh(): void; - scrollTo(x: number, y: number, time?: number, relative?: boolean): void; - scrollToElement(element: string, time?: number): void; - scrollToElement(element: HTMLElement, time?: number): void; - scrollToPage(pageX: number, pageY: number, time?: number): void; - disable(): void; - enable(): void; - stop(): void; - zoom(x: number, y: number, scale: number, time?: number): void; - isReady(): boolean; + // Events + on: (type: string, fn: () => void) => void; } From 62c6f39a5ac2d57fda00b9145530492952365024 Mon Sep 17 00:00:00 2001 From: Christiaan Rakowski Date: Tue, 10 Dec 2013 14:10:19 +0100 Subject: [PATCH 11/17] added some new options, needs verification --- iscroll/iscroll-5-lite.d.ts | 10 +++++++--- iscroll/iscroll-5.d.ts | 37 ++++++++++++++++++++++++++++++++++--- 2 files changed, 41 insertions(+), 6 deletions(-) diff --git a/iscroll/iscroll-5-lite.d.ts b/iscroll/iscroll-5-lite.d.ts index 5324aecba..2aef0ce39 100644 --- a/iscroll/iscroll-5-lite.d.ts +++ b/iscroll/iscroll-5-lite.d.ts @@ -4,8 +4,12 @@ // Definitions: https://github.com/borisyankov/DefinitelyTyped interface IScrollOptions { - hScroll?: boolean; - vScroll?: boolean; + //hScroll?: boolean; + //vScroll?: boolean; + + scrollX?: boolean; + scrollY?: boolean; + x?: number; y?: number; bounce?: boolean; @@ -13,7 +17,7 @@ interface IScrollOptions { momentum?: boolean; lockDirection?: boolean; useTransform?: boolean; - useTransition?: boolean; + useTransition?: boolean; } declare class iScroll { diff --git a/iscroll/iscroll-5.d.ts b/iscroll/iscroll-5.d.ts index ded858ecb..abd793027 100644 --- a/iscroll/iscroll-5.d.ts +++ b/iscroll/iscroll-5.d.ts @@ -4,8 +4,8 @@ // Definitions: https://github.com/borisyankov/DefinitelyTyped interface IScrollOptions { - hScroll?: boolean; - vScroll?: boolean; + //hScroll?: boolean; + //vScroll?: boolean; x?: number; y?: number; bounce?: boolean; @@ -33,9 +33,40 @@ interface IScrollOptions { doubleTapZoom?: number; wheelAction?: string; - // Snap + + ///String or boolean snap?: any; snapThreshold?: number; + + //new in IScroll 5? + + resizeIndicator?: boolean; + mouseWheelSpeed?: number; + startX?: number; + startY?: number; + scrollX?: boolean; + scrollY?: boolean; + directionLockThreshold?: number; + + bounceTime?: number; + + ///String or function + bounceEasing?: any; + + preventDefault?: boolean; + preventDefaultException?: boolean; + + HWCompositing?: boolean; + + freeScroll?: boolean; + + resizePolling?: number; + tap?: boolean; + click?: boolean; + invertWheelDirection?: boolean; + + ///Boolean or string + eventPassthrough?: any; } declare class IScroll { From 44161fb6f73deb80cfecbc6cca01682fe6716987 Mon Sep 17 00:00:00 2001 From: Natan Vivo Date: Tue, 10 Dec 2013 11:19:06 -0200 Subject: [PATCH 12/17] Added missing overloads, backbone collections convert raw objects into models on add/reset. --- backbone/backbone.d.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/backbone/backbone.d.ts b/backbone/backbone.d.ts index e05150c64..25b431453 100644 --- a/backbone/backbone.d.ts +++ b/backbone/backbone.d.ts @@ -158,7 +158,9 @@ declare module Backbone { comparator(compare: Model, to?: Model): any; add(model: Model, options?: AddOptions): Collection; + add(model: any, options?: AddOptions): Collection; add(models: Model[], options?: AddOptions): Collection; + add(models: any[], options?: AddOptions): Collection; at(index: number): Model; get(id: any): Model; create(attributes: any, options?: ModelSaveOptions): Model; @@ -168,6 +170,7 @@ declare module Backbone { remove(model: Model, options?: Silenceable): Model; remove(models: Model[], options?: Silenceable): Model[]; reset(models?: Model[], options?: Silenceable): Model[]; + reset(models?: any[], options?: Silenceable): Model[]; shift(options?: Silenceable): Model; sort(options?: Silenceable): Collection; unshift(model: Model, options?: AddOptions): Model; From 0f6f7db51cfd0e013e47313df25deffef471d978 Mon Sep 17 00:00:00 2001 From: Romano Lindano Date: Tue, 10 Dec 2013 14:56:31 +0100 Subject: [PATCH 13/17] Angular scenario typings. --- angularjs/angular-scenario.d.ts | 41 ++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/angularjs/angular-scenario.d.ts b/angularjs/angular-scenario.d.ts index 8dd605f7d..54711bbb4 100644 --- a/angularjs/angular-scenario.d.ts +++ b/angularjs/angular-scenario.d.ts @@ -3,10 +3,13 @@ // Definitions by: [RomanoLindano] // Definitions: https://github.com/borisyankov/DefinitelyTyped -declare module angularScenario { - export interface AngularModel { +declare module ng { + export interface IAngularStatic { scenario: any; } +} + +declare module angularScenario { export interface RunFunction { (functionToRun: any): any; @@ -46,25 +49,25 @@ declare module angularScenario { reload(): void; window(): testWindow; location(): testLocation; - } - + } + export interface Matchers { toEqual(value: any): void; - toBe(value: any): void; - toBeDefined(): void; - toBeTruthy(): void; - toBeFalsy(): void; - toMatch(regularExpression: any): void; - toBeNull(): void; + toBe(value: any): void; + toBeDefined(): void; + toBeTruthy(): void; + toBeFalsy(): void; + toMatch(regularExpression: any): void; + toBeNull(): void; toContain(value: any): void; - toBeLessThan(value: any): void; - toBeGreaterThan(value: any): void; + toBeLessThan(value: any): void; + toBeGreaterThan(value: any): void; } - export interface CustomMatchers extends Matchers{ + export interface CustomMatchers extends Matchers { } - export interface Expect extends CustomMatchers { + export interface Expect extends CustomMatchers { not(): angularScenario.CustomMatchers; } @@ -92,12 +95,12 @@ declare module angularScenario { export interface Select { option(value: any): any; option(...listOfValues: any[]): any; - } + } export interface Element { count(): Future; click(): any; - query(callback: (selectedDOMElements: any[], callbackWhenDone: (objNull: any, futureValue: any) => any) =>any): any; + query(callback: (selectedDOMElements: any[], callbackWhenDone: (objNull: any, futureValue: any) => any) => any): any; val(): Future; text(): Future; html(): Future; @@ -111,7 +114,7 @@ declare module angularScenario { scrollLeft(): Future; scrollTop(): Future; offset(): Future; - + val(value: any): void; text(value: any): void; html(value: any): void; @@ -137,10 +140,12 @@ declare module angularScenario { } declare var describe: angularScenario.RunFunctionWithDescription; +declare var ddescribe: angularScenario.RunFunctionWithDescription; declare var xdescribe: angularScenario.RunFunctionWithDescription; declare var beforeEach: angularScenario.RunFunction; declare var afterEach: angularScenario.RunFunction; declare var it: angularScenario.RunFunctionWithDescription; +declare var iit: angularScenario.RunFunctionWithDescription; declare var xit: angularScenario.RunFunctionWithDescription; declare var pause: angularScenario.PauseFunction; declare var sleep: angularScenario.SleepFunction; @@ -152,4 +157,4 @@ declare function input(ngModelBinding: string): angularScenario.Input; declare function repeater(selector: string, repeaterDescription?: string): angularScenario.Repeater; declare function select(ngModelBinding: string): angularScenario.Select; declare function element(selector: string, elementDescription?: string): angularScenario.Element; -declare var angular: angularScenario.AngularModel; +declare var angular: ng.IAngularStatic; From e01f25822c7af49e54533640be3ce62d5b41f8c3 Mon Sep 17 00:00:00 2001 From: Stan Thomas Date: Tue, 10 Dec 2013 17:17:15 +0000 Subject: [PATCH 14/17] TS 0.9.5 support: add definition for rest arguments in jQuery.on() to support optional parameters passed via jQuery.trigger(). --- jquery/jquery.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index 4b8e9f49c..2bd9beecc 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -1204,9 +1204,9 @@ interface JQuery { * Attach an event handler function for one or more events to the selected elements. * * @param events One or more space-separated event types and optional namespaces, such as "click" or "keydown.myPlugin". - * @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false. + * @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false. Rest parameter args is for optional parameters passed to jQuery.trigger(). Note that the actual parameters on the event handler function must be marked as optional (? syntax). */ - on(events: string, handler: (eventObject: JQueryEventObject) => any): JQuery; + on(events: string, handler: (eventObject: JQueryEventObject, ...args: any[]) => any): JQuery; /** * Attach an event handler function for one or more events to the selected elements. * From fe87c6bbae08f8edb2a12cc6876ea10615623d48 Mon Sep 17 00:00:00 2001 From: Christiaan Rakowski Date: Tue, 10 Dec 2013 20:33:09 +0100 Subject: [PATCH 15/17] changes iScroll to IScroll in lite.d.ts --- iscroll/iscroll-5-lite.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iscroll/iscroll-5-lite.d.ts b/iscroll/iscroll-5-lite.d.ts index 2aef0ce39..f22ae6f89 100644 --- a/iscroll/iscroll-5-lite.d.ts +++ b/iscroll/iscroll-5-lite.d.ts @@ -20,7 +20,7 @@ interface IScrollOptions { useTransition?: boolean; } -declare class iScroll { +declare class IScroll { constructor (element: string, options?: IScrollOptions); constructor (element: HTMLElement, options?: IScrollOptions); From d47d1f0994e6e321ec7fb3bf0608659c01c2af45 Mon Sep 17 00:00:00 2001 From: Igor Oleinikov Date: Wed, 11 Dec 2013 01:02:56 +0400 Subject: [PATCH 16/17] rx.js: added definition for experimental functions --- rx.js/rx.js.experimental.d.ts | 288 ++++++++++++++++++++++++++++++++++ 1 file changed, 288 insertions(+) create mode 100644 rx.js/rx.js.experimental.d.ts diff --git a/rx.js/rx.js.experimental.d.ts b/rx.js/rx.js.experimental.d.ts new file mode 100644 index 000000000..a43788b87 --- /dev/null +++ b/rx.js/rx.js.experimental.d.ts @@ -0,0 +1,288 @@ +// Type definitions for RxJS/Experimental +// Project: https://github.com/Reactive-Extensions/RxJS/ +// Definitions by: Igor Oleinikov +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module Rx { + + interface IObservable { + /** + * Returns an observable sequence that is the result of invoking the selector on the source sequence, without sharing subscriptions. + * This operator allows for a fluent style of writing queries that use the same sequence multiple times. + * + * @param selector Selector function which can use the source sequence as many times as needed, without sharing subscriptions to the source sequence. + * @returns An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function. + */ + let(selector: (source: IObservable) => IObservable): IObservable; + + /** + * Returns an observable sequence that is the result of invoking the selector on the source sequence, without sharing subscriptions. + * This operator allows for a fluent style of writing queries that use the same sequence multiple times. + * + * @param selector Selector function which can use the source sequence as many times as needed, without sharing subscriptions to the source sequence. + * @returns An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function. + */ + letBind(selector: (source: IObservable) => IObservable): IObservable; + + /** + * Repeats source as long as condition holds emulating a do while loop. + * @param condition The condition which determines if the source will be repeated. + * @returns An observable sequence which is repeated as long as the condition holds. + */ + doWhile(condition: () => boolean): IObservable; + + /** + * Expands an observable sequence by recursively invoking selector. + * + * @param selector Selector function to invoke for each produced element, resulting in another sequence to which the selector will be invoked recursively again. + * @param [scheduler] Scheduler on which to perform the expansion. If not provided, this defaults to the current thread scheduler. + * @returns An observable sequence containing all the elements produced by the recursive expansion. + */ + expand(selector: (item: T) => IObservable, scheduler?: IScheduler): IObservable; + + /** + * Runs two observable sequences in parallel and combines their last elemenets. + * + * @param second Second observable sequence. + * @param resultSelector Result selector function to invoke with the last elements of both sequences. + * @returns An observable sequence with the result of calling the selector function with the last elements of both input sequences. + */ + forkJoin(second: IObservable, resultSelector: (left: T, right: TSecond) => TResult): IObservable; + + /** + * Comonadic bind operator. + * @param selector A transform function to apply to each element. + * @param [scheduler] Scheduler used to execute the operation. If not specified, defaults to the ImmediateScheduler. + * @returns An observable sequence which results from the comonadic bind operation. + */ + manySelect(selector: (item: IObservable, index: number, source: IObservable) => TResult, scheduler?: IScheduler): IObservable; + } + + interface Observable { + /** + * Determines whether an observable collection contains values. There is an alias for this method called 'ifThen' for browsers (condition: () => boolean, thenSource: IObservable, elseSource: IObservable): IObservable; + + /** + * Determines whether an observable collection contains values. There is an alias for this method called 'ifThen' for browsers (condition: () => boolean, thenSource: IObservable, scheduler?: IScheduler): IObservable; + + /** + * Determines whether an observable collection contains values. There is an alias for this method called 'ifThen' for browsers (condition: () => boolean, thenSource: IObservable, elseSource: IObservable): IObservable; + + /** + * Determines whether an observable collection contains values. There is an alias for this method called 'ifThen' for browsers (condition: () => boolean, thenSource: IObservable, scheduler?: IScheduler): IObservable; + + /** + * Concatenates the observable sequences obtained by running the specified result selector for each element in source. + * There is an alias for this method called 'forIn' for browsers (sources: T[], resultSelector: (item: T) => IObservable): IObservable; + + /** + * Concatenates the observable sequences obtained by running the specified result selector for each element in source. + * There is an alias for this method called 'forIn' for browsers (sources: T[], resultSelector: (item: T) => IObservable): IObservable; + + /** + * Repeats source as long as condition holds emulating a while loop. + * There is an alias for this method called 'whileDo' for browsers (condition: () => boolean, source: IObservable): IObservable; + + /** + * Repeats source as long as condition holds emulating a while loop. + * There is an alias for this method called 'whileDo' for browsers (condition: () => boolean, source: IObservable): IObservable; + + /** + * Uses selector to determine which source in sources to use. + * There is an alias 'switchCase' for browsers (selector: () => string, sources: { [key: string]: IObservable; }, elseSource: IObservable): IObservable; + + /** + * Uses selector to determine which source in sources to use. + * There is an alias 'switchCase' for browsers (selector: () => string, sources: { [key: string]: IObservable; }, scheduler?: IScheduler): IObservable; + + /** + * Uses selector to determine which source in sources to use. + * There is an alias 'switchCase' for browsers (selector: () => number, sources: { [key: number]: IObservable; }, elseSource: IObservable): IObservable; + + /** + * Uses selector to determine which source in sources to use. + * There is an alias 'switchCase' for browsers (selector: () => number, sources: { [key: number]: IObservable; }, scheduler?: IScheduler): IObservable; + + /** + * Uses selector to determine which source in sources to use. + * There is an alias 'switchCase' for browsers (selector: () => string, sources: { [key: string]: IObservable; }, elseSource: IObservable): IObservable; + + /** + * Uses selector to determine which source in sources to use. + * There is an alias 'switchCase' for browsers (selector: () => string, sources: { [key: string]: IObservable; }, scheduler?: IScheduler): IObservable; + + /** + * Uses selector to determine which source in sources to use. + * There is an alias 'switchCase' for browsers (selector: () => number, sources: { [key: number]: IObservable; }, elseSource: IObservable): IObservable; + + /** + * Uses selector to determine which source in sources to use. + * There is an alias 'switchCase' for browsers (selector: () => number, sources: { [key: number]: IObservable; }, scheduler?: IScheduler): IObservable; + + /** + * Runs all observable sequences in parallel and collect their last elements. + * + * @example + * res = Rx.Observable.forkJoin([obs1, obs2]); + * @param sources Array of source sequences. + * @returns An observable sequence with an array collecting the last elements of all the input sequences. + */ + forkJoin(sources: IObservable[]): IObservable; + + /** + * Runs all observable sequences in parallel and collect their last elements. + * + * @example + * res = Rx.Observable.forkJoin(obs1, obs2, ...); + * @param args Source sequences. + * @returns An observable sequence with an array collecting the last elements of all the input sequences. + */ + forkJoin(...args: IObservable[]): IObservable; + } +} From 4dea8bf7d2e8c44f3dfb1d12295d892972f158e7 Mon Sep 17 00:00:00 2001 From: Igor Oleinikov Date: Wed, 11 Dec 2013 02:01:37 +0400 Subject: [PATCH 17/17] rx.js: added TS compiler parameters to experimental definitions --- rx.js/rx.js.experimental.d.ts.tscparams | 1 + 1 file changed, 1 insertion(+) create mode 100644 rx.js/rx.js.experimental.d.ts.tscparams diff --git a/rx.js/rx.js.experimental.d.ts.tscparams b/rx.js/rx.js.experimental.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/rx.js/rx.js.experimental.d.ts.tscparams @@ -0,0 +1 @@ +""