From 6cde0f908bbf056c17ad7e12f1f5894b63101df9 Mon Sep 17 00:00:00 2001 From: Martin Gjoshevski Date: Fri, 8 Sep 2017 22:24:26 +0200 Subject: [PATCH 01/13] Added type definitions for signalr-no-jquery --- types/signalr-no-jquery/index.d.ts | 57 +++++++++++++++++++ .../signalr-no-jquery-tests.ts | 14 +++++ types/signalr-no-jquery/tsconfig.json | 23 ++++++++ 3 files changed, 94 insertions(+) create mode 100644 types/signalr-no-jquery/index.d.ts create mode 100644 types/signalr-no-jquery/signalr-no-jquery-tests.ts create mode 100644 types/signalr-no-jquery/tsconfig.json diff --git a/types/signalr-no-jquery/index.d.ts b/types/signalr-no-jquery/index.d.ts new file mode 100644 index 0000000000..5244b3f5c8 --- /dev/null +++ b/types/signalr-no-jquery/index.d.ts @@ -0,0 +1,57 @@ +// Type definitions for signalr-no-jquery v0.1.8 +// Project: https://github.com/DVLP/signalr-no-jquery/ +// Definitions by: Martin Gjoshevski +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +export function hubConnection(url?:string, options?: Options):Connection; + +export function signalR(url?: string, qs?: any, logging?: any): any; + +interface Connection { + proxies: { [hubName: string]: any }; + transport: { name: string, supportsKeepAlive: () => boolean }; + /** + * Creates a new proxy object for the given hub connection that can be used to invoke + * methods on server hubs and handle client method invocation requests from the server. + * + * @param hubName The name of the hub on the server to create the proxy for. + */ + createHubProxy(hubName: string): Proxy; + + start(options:any, callback:any):any +} + +interface Proxy { + state: any; + connection: Connection; + hubName: string; + init(connection: Connection, hubName: string): void; + hasSubscriptions(): boolean; + /** + * Wires up a callback to be invoked when a invocation request is received from the server hub. + * + * @param eventName The name of the hub event to register the callback for. + * @param callback The callback to be invoked. + */ + on(eventName: string, callback: (...msg: any[]) => void): Proxy; + /** + * Removes the callback invocation request from the server hub for the given event name. + * + * @param eventName The name of the hub event to unregister the callback for. + * @param callback The callback to be invoked. + */ + off(eventName: string, callback: (...msg: any[]) => void): Proxy; + /** + * Invokes a server hub method with the given arguments. + * + * @param methodName The name of the server hub method. + */ + invoke(methodName: string, ...args: any[]): Promise; +} + +interface Options { + qs?: string; + logging?: boolean; + useDefaultPath?: boolean; +} diff --git a/types/signalr-no-jquery/signalr-no-jquery-tests.ts b/types/signalr-no-jquery/signalr-no-jquery-tests.ts new file mode 100644 index 0000000000..8a9ed3bde0 --- /dev/null +++ b/types/signalr-no-jquery/signalr-no-jquery-tests.ts @@ -0,0 +1,14 @@ +import { hubConnection } from 'signalr-no-jquery'; + +const connection = hubConnection('http://[address]:[port]'); +const hubProxy = connection.createHubProxy('hubNameString'); + +// set up event listeners i.e. for incoming "message" event +hubProxy.on('message', function(message) { + console.log(message); +}); + +// connect +connection.start({ jsonp: true }) +.done(function(){ console.log('Now connected, connection ID=' + connection.id); }) +.fail(function(){ console.log('Could not connect'); }); \ No newline at end of file diff --git a/types/signalr-no-jquery/tsconfig.json b/types/signalr-no-jquery/tsconfig.json new file mode 100644 index 0000000000..ce6cbedc80 --- /dev/null +++ b/types/signalr-no-jquery/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "signalr-no-jquery-tests.ts" + ] +} \ No newline at end of file From 5fe7948768e4da733bce53b4f7354b6b93624f24 Mon Sep 17 00:00:00 2001 From: Martin Gjoshevski Date: Fri, 8 Sep 2017 22:42:35 +0200 Subject: [PATCH 02/13] add missing property --- types/signalr-no-jquery/index.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/types/signalr-no-jquery/index.d.ts b/types/signalr-no-jquery/index.d.ts index 5244b3f5c8..fc09c0d9be 100644 --- a/types/signalr-no-jquery/index.d.ts +++ b/types/signalr-no-jquery/index.d.ts @@ -9,6 +9,7 @@ export function hubConnection(url?:string, options?: Options):Connection; export function signalR(url?: string, qs?: any, logging?: any): any; interface Connection { + id: string; proxies: { [hubName: string]: any }; transport: { name: string, supportsKeepAlive: () => boolean }; /** @@ -19,7 +20,7 @@ interface Connection { */ createHubProxy(hubName: string): Proxy; - start(options:any, callback:any):any + start(options?:any, callback?:any):any } interface Proxy { From 1aa0fd4e1a0d378e62de1fb2ae6d8c3c6e51d552 Mon Sep 17 00:00:00 2001 From: Martin Gjoshevski Date: Fri, 8 Sep 2017 22:46:16 +0200 Subject: [PATCH 03/13] add tslint file --- types/signalr-no-jquery/tslint.json | 1 + 1 file changed, 1 insertion(+) create mode 100644 types/signalr-no-jquery/tslint.json diff --git a/types/signalr-no-jquery/tslint.json b/types/signalr-no-jquery/tslint.json new file mode 100644 index 0000000000..2750cc0197 --- /dev/null +++ b/types/signalr-no-jquery/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } \ No newline at end of file From 4b7d8537cb1fe440f5495215a67ebcdcb14e5688 Mon Sep 17 00:00:00 2001 From: Martin Gjoshevski Date: Fri, 8 Sep 2017 22:50:41 +0200 Subject: [PATCH 04/13] change to arrow functions --- types/signalr-no-jquery/signalr-no-jquery-tests.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/types/signalr-no-jquery/signalr-no-jquery-tests.ts b/types/signalr-no-jquery/signalr-no-jquery-tests.ts index 8a9ed3bde0..b3f2aaab16 100644 --- a/types/signalr-no-jquery/signalr-no-jquery-tests.ts +++ b/types/signalr-no-jquery/signalr-no-jquery-tests.ts @@ -2,13 +2,13 @@ import { hubConnection } from 'signalr-no-jquery'; const connection = hubConnection('http://[address]:[port]'); const hubProxy = connection.createHubProxy('hubNameString'); - + // set up event listeners i.e. for incoming "message" event -hubProxy.on('message', function(message) { +hubProxy.on('message', (message) => { console.log(message); }); // connect connection.start({ jsonp: true }) -.done(function(){ console.log('Now connected, connection ID=' + connection.id); }) -.fail(function(){ console.log('Could not connect'); }); \ No newline at end of file +.done(()=>{ console.log('Now connected, connection ID=' + connection.id); }) +.fail(()=>{ console.log('Could not connect'); }); From 1295112456a555c552a93f413024cfe42f4fb696 Mon Sep 17 00:00:00 2001 From: Martin Gjoshevski Date: Fri, 8 Sep 2017 22:58:36 +0200 Subject: [PATCH 05/13] fixing formating issues --- types/signalr-no-jquery/signalr-no-jquery-tests.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/types/signalr-no-jquery/signalr-no-jquery-tests.ts b/types/signalr-no-jquery/signalr-no-jquery-tests.ts index b3f2aaab16..3ca788368b 100644 --- a/types/signalr-no-jquery/signalr-no-jquery-tests.ts +++ b/types/signalr-no-jquery/signalr-no-jquery-tests.ts @@ -7,8 +7,8 @@ const hubProxy = connection.createHubProxy('hubNameString'); hubProxy.on('message', (message) => { console.log(message); }); - + // connect connection.start({ jsonp: true }) -.done(()=>{ console.log('Now connected, connection ID=' + connection.id); }) -.fail(()=>{ console.log('Could not connect'); }); + .done( () => { console.log('Now connected, connection ID=' + connection.id); }) + .fail( () =>{ console.log('Could not connect'); }); From f11b30afda4a757d91dd63351b69efe982aabef1 Mon Sep 17 00:00:00 2001 From: Martin Gjoshevski Date: Fri, 8 Sep 2017 23:05:04 +0200 Subject: [PATCH 06/13] formating fix --- types/signalr-no-jquery/signalr-no-jquery-tests.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/signalr-no-jquery/signalr-no-jquery-tests.ts b/types/signalr-no-jquery/signalr-no-jquery-tests.ts index 3ca788368b..1074608daf 100644 --- a/types/signalr-no-jquery/signalr-no-jquery-tests.ts +++ b/types/signalr-no-jquery/signalr-no-jquery-tests.ts @@ -10,5 +10,5 @@ hubProxy.on('message', (message) => { // connect connection.start({ jsonp: true }) - .done( () => { console.log('Now connected, connection ID=' + connection.id); }) - .fail( () =>{ console.log('Could not connect'); }); + .done(() => { console.log('Now connected, connection ID=' + connection.id); }) + .fail(() => { console.log('Could not connect'); }); \ No newline at end of file From 68dd4e4407bf5a89dcb90e87530e4d4c141ef58c Mon Sep 17 00:00:00 2001 From: Martin Gjoshevski Date: Fri, 8 Sep 2017 23:15:37 +0200 Subject: [PATCH 07/13] allignc commencts and add spaces --- types/signalr-no-jquery/index.d.ts | 12 ++++++------ types/signalr-no-jquery/signalr-no-jquery-tests.ts | 3 ++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/types/signalr-no-jquery/index.d.ts b/types/signalr-no-jquery/index.d.ts index fc09c0d9be..571133e053 100644 --- a/types/signalr-no-jquery/index.d.ts +++ b/types/signalr-no-jquery/index.d.ts @@ -4,7 +4,7 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 -export function hubConnection(url?:string, options?: Options):Connection; +export function hubConnection(url?: string, options?: Options): Connection; export function signalR(url?: string, qs?: any, logging?: any): any; @@ -12,7 +12,7 @@ interface Connection { id: string; proxies: { [hubName: string]: any }; transport: { name: string, supportsKeepAlive: () => boolean }; - /** + /** * Creates a new proxy object for the given hub connection that can be used to invoke * methods on server hubs and handle client method invocation requests from the server. * @@ -20,7 +20,7 @@ interface Connection { */ createHubProxy(hubName: string): Proxy; - start(options?:any, callback?:any):any + start(options?: any, callback?: any): any; } interface Proxy { @@ -29,21 +29,21 @@ interface Proxy { hubName: string; init(connection: Connection, hubName: string): void; hasSubscriptions(): boolean; - /** + /** * Wires up a callback to be invoked when a invocation request is received from the server hub. * * @param eventName The name of the hub event to register the callback for. * @param callback The callback to be invoked. */ on(eventName: string, callback: (...msg: any[]) => void): Proxy; - /** + /** * Removes the callback invocation request from the server hub for the given event name. * * @param eventName The name of the hub event to unregister the callback for. * @param callback The callback to be invoked. */ off(eventName: string, callback: (...msg: any[]) => void): Proxy; - /** + /** * Invokes a server hub method with the given arguments. * * @param methodName The name of the server hub method. diff --git a/types/signalr-no-jquery/signalr-no-jquery-tests.ts b/types/signalr-no-jquery/signalr-no-jquery-tests.ts index 1074608daf..0cfb2cf2bb 100644 --- a/types/signalr-no-jquery/signalr-no-jquery-tests.ts +++ b/types/signalr-no-jquery/signalr-no-jquery-tests.ts @@ -11,4 +11,5 @@ hubProxy.on('message', (message) => { // connect connection.start({ jsonp: true }) .done(() => { console.log('Now connected, connection ID=' + connection.id); }) - .fail(() => { console.log('Could not connect'); }); \ No newline at end of file + .fail(() => { console.log('Could not connect'); }); + \ No newline at end of file From 57add47127b2ef66f99089f6a95f4f03befe7693 Mon Sep 17 00:00:00 2001 From: Martin Gjoshevski Date: Fri, 8 Sep 2017 23:33:56 +0200 Subject: [PATCH 08/13] formating --- types/signalr-no-jquery/index.d.ts | 6 +++++- types/signalr-no-jquery/signalr-no-jquery-tests.ts | 1 - 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/types/signalr-no-jquery/index.d.ts b/types/signalr-no-jquery/index.d.ts index 571133e053..de40bcb13a 100644 --- a/types/signalr-no-jquery/index.d.ts +++ b/types/signalr-no-jquery/index.d.ts @@ -11,7 +11,11 @@ export function signalR(url?: string, qs?: any, logging?: any): any; interface Connection { id: string; proxies: { [hubName: string]: any }; - transport: { name: string, supportsKeepAlive: () => boolean }; + transport: { + name: string, + supportsKeepAlive: () => boolean + }; + /** * Creates a new proxy object for the given hub connection that can be used to invoke * methods on server hubs and handle client method invocation requests from the server. diff --git a/types/signalr-no-jquery/signalr-no-jquery-tests.ts b/types/signalr-no-jquery/signalr-no-jquery-tests.ts index 0cfb2cf2bb..041e3605f2 100644 --- a/types/signalr-no-jquery/signalr-no-jquery-tests.ts +++ b/types/signalr-no-jquery/signalr-no-jquery-tests.ts @@ -12,4 +12,3 @@ hubProxy.on('message', (message) => { connection.start({ jsonp: true }) .done(() => { console.log('Now connected, connection ID=' + connection.id); }) .fail(() => { console.log('Could not connect'); }); - \ No newline at end of file From 23aed26b861a2995a9e5e8aa1c62ad46318d6fdc Mon Sep 17 00:00:00 2001 From: Martin Gjoshevski Date: Fri, 8 Sep 2017 23:45:28 +0200 Subject: [PATCH 09/13] add exports --- types/signalr-no-jquery/index.d.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/types/signalr-no-jquery/index.d.ts b/types/signalr-no-jquery/index.d.ts index de40bcb13a..67673da92e 100644 --- a/types/signalr-no-jquery/index.d.ts +++ b/types/signalr-no-jquery/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for signalr-no-jquery v0.1.8 +// Type definitions for signalr-no-jquery 0.1.8 // Project: https://github.com/DVLP/signalr-no-jquery/ // Definitions by: Martin Gjoshevski // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -8,14 +8,14 @@ export function hubConnection(url?: string, options?: Options): Connection; export function signalR(url?: string, qs?: any, logging?: any): any; -interface Connection { +export interface Connection { id: string; proxies: { [hubName: string]: any }; - transport: { - name: string, - supportsKeepAlive: () => boolean + transport: { + name: string, + supportsKeepAlive: () => boolean }; - + /** * Creates a new proxy object for the given hub connection that can be used to invoke * methods on server hubs and handle client method invocation requests from the server. @@ -27,7 +27,7 @@ interface Connection { start(options?: any, callback?: any): any; } -interface Proxy { +export interface Proxy { state: any; connection: Connection; hubName: string; @@ -55,7 +55,7 @@ interface Proxy { invoke(methodName: string, ...args: any[]): Promise; } -interface Options { +export interface Options { qs?: string; logging?: boolean; useDefaultPath?: boolean; From 00eef195af4369cd5a20db4ce37cc2a061660559 Mon Sep 17 00:00:00 2001 From: Martin Gjoshevski Date: Sat, 9 Sep 2017 07:19:02 +0200 Subject: [PATCH 10/13] remove patch version --- types/signalr-no-jquery/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/signalr-no-jquery/index.d.ts b/types/signalr-no-jquery/index.d.ts index 67673da92e..5f76e9835f 100644 --- a/types/signalr-no-jquery/index.d.ts +++ b/types/signalr-no-jquery/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for signalr-no-jquery 0.1.8 +// Type definitions for signalr-no-jquery 0.1 // Project: https://github.com/DVLP/signalr-no-jquery/ // Definitions by: Martin Gjoshevski // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -13,7 +13,7 @@ export interface Connection { proxies: { [hubName: string]: any }; transport: { name: string, - supportsKeepAlive: () => boolean + supportsKeepAlive?: () => boolean }; /** From 155843e3cffd155b4059645363c58e15c2d531eb Mon Sep 17 00:00:00 2001 From: Martin Gjoshevski Date: Sat, 9 Sep 2017 07:26:14 +0200 Subject: [PATCH 11/13] declare function handler --- types/signalr-no-jquery/index.d.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/types/signalr-no-jquery/index.d.ts b/types/signalr-no-jquery/index.d.ts index 5f76e9835f..352f1aac89 100644 --- a/types/signalr-no-jquery/index.d.ts +++ b/types/signalr-no-jquery/index.d.ts @@ -13,7 +13,7 @@ export interface Connection { proxies: { [hubName: string]: any }; transport: { name: string, - supportsKeepAlive?: () => boolean + supportsKeepAlive:SupportsKeepAliveHandler }; /** @@ -60,3 +60,5 @@ export interface Options { logging?: boolean; useDefaultPath?: boolean; } + +declare type SupportsKeepAliveHandler = () => boolean; From 9b873b18539a9f4d36709af4da5a13705031ce75 Mon Sep 17 00:00:00 2001 From: Martin Gjoshevski Date: Sat, 9 Sep 2017 07:31:55 +0200 Subject: [PATCH 12/13] add missing empty space --- types/signalr-no-jquery/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/signalr-no-jquery/index.d.ts b/types/signalr-no-jquery/index.d.ts index 352f1aac89..772f6268b5 100644 --- a/types/signalr-no-jquery/index.d.ts +++ b/types/signalr-no-jquery/index.d.ts @@ -13,7 +13,7 @@ export interface Connection { proxies: { [hubName: string]: any }; transport: { name: string, - supportsKeepAlive:SupportsKeepAliveHandler + supportsKeepAlive: SupportsKeepAliveHandler }; /** @@ -61,4 +61,4 @@ export interface Options { useDefaultPath?: boolean; } -declare type SupportsKeepAliveHandler = () => boolean; +export declare type SupportsKeepAliveHandler = () => boolean; From 189ecd9bce3416a792745f3c2723f9ad7b83fe08 Mon Sep 17 00:00:00 2001 From: Martin Gjoshevski Date: Sat, 9 Sep 2017 07:35:25 +0200 Subject: [PATCH 13/13] remove unnecessary declare --- types/signalr-no-jquery/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/signalr-no-jquery/index.d.ts b/types/signalr-no-jquery/index.d.ts index 772f6268b5..55d4c6eddb 100644 --- a/types/signalr-no-jquery/index.d.ts +++ b/types/signalr-no-jquery/index.d.ts @@ -61,4 +61,4 @@ export interface Options { useDefaultPath?: boolean; } -export declare type SupportsKeepAliveHandler = () => boolean; +export type SupportsKeepAliveHandler = () => boolean;