@types/pusher-js
Advanced tools
Comparing version 3.0.30 to 4.2.0
@@ -1,28 +0,29 @@ | ||
// Type definitions for pusher-js 3.0.0 | ||
// Type definitions for pusher-js 4.2 | ||
// Project: https://github.com/pusher/pusher-js | ||
// Definitions by: Qubo <https://github.com/tkqubo> | ||
// Lance Ivy <https://github.com/cainlevy> | ||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
declare namespace pusher { | ||
interface PusherStatic { | ||
logToConsole: boolean; | ||
log: (msg: string) => void; | ||
new (apiKey: string, config?: Config): Pusher; | ||
} | ||
interface Pusher { | ||
interface Pusher extends EventsDispatcher { | ||
channel(name: string): Channel; | ||
allChannels(): Channel[]; | ||
connect(): void; | ||
disconnect(): void; | ||
subscribe(name: string): Channel; | ||
subscribeAll(): void; | ||
unsubscribe(name: string): void; | ||
channel(name: string): Channel; | ||
allChannels(): Channel[]; | ||
bind(eventName: string, callback: Function): Pusher; | ||
bind_all(callback: Function): Pusher; | ||
disconnect(): void; | ||
isEncrypted(): boolean; | ||
key: string; | ||
config: Config; //TODO: add GlobalConfig typings | ||
channels: any; //TODO: Type this | ||
config: Config; // TODO: add GlobalConfig typings | ||
channels: any; // TODO: Type this | ||
global_emitter: EventsDispatcher; | ||
sessionID: number; | ||
timeline: any; //TODO: Type this | ||
timeline: any; // TODO: Type this | ||
connection: ConnectionManager; | ||
@@ -46,3 +47,3 @@ } | ||
*/ | ||
authTransport?: string; | ||
authTransport?: 'ajax' | 'jsonp'; | ||
@@ -55,2 +56,6 @@ /** | ||
/** | ||
* If you need custom authorization behavior you can provide your own authorizer function as follows: | ||
*/ | ||
authorizer?: Authorizer; | ||
@@ -62,5 +67,5 @@ /** | ||
/** | ||
* Disables stats collection, so that connection metrics are not submitted to Pusher’s servers. | ||
* Disables stats collection, so that connection metrics are not submitted to Pusher’s servers. These stats | ||
* are used for internal monitoring only and they do not affect the account stats. | ||
*/ | ||
@@ -75,5 +80,4 @@ disableStats?: boolean; | ||
*/ | ||
enabledTransports?: string[]; | ||
enabledTransports?: Transport[]; | ||
/** | ||
@@ -85,3 +89,3 @@ * Specified which transports must not be used by Pusher to establish a connection. | ||
*/ | ||
disabledTransports?: string[]; | ||
disabledTransports?: Transport[]; | ||
@@ -107,2 +111,3 @@ /** | ||
wsHost?: string; | ||
wsPath?: string; | ||
wsPort?: number; | ||
@@ -115,2 +120,4 @@ wssPort?: number; | ||
type Transport = 'ws' | 'wss' | 'xhr_streaming' | 'xhr_polling' | 'sockjs'; | ||
interface AuthConfig { | ||
@@ -121,11 +128,23 @@ params?: { [key: string]: any }; | ||
interface GenericEventsDispatcher<Self extends EventsDispatcher> extends EventsDispatcher { | ||
bind(eventName: string, callback: Function, context?: any): Self; | ||
bind_all(callback: Function): Self; | ||
unbind(eventName?: string, callback?: Function, context?: any): Self; | ||
unbind_all(eventName?: string, callback?: Function): Self; | ||
emit(eventName: string, data?: any): Self; | ||
interface AuthInfo { | ||
auth: string; | ||
channel_data?: string; | ||
} | ||
interface Channel extends GenericEventsDispatcher<Channel> { | ||
type Authorizer = (channel: Channel, options: Config) => { | ||
authorize: (socketId: string, callback: (errored: boolean, authInfo?: AuthInfo) => void) => void; | ||
}; | ||
type EventCallback = (context: any, data: any) => void; | ||
interface EventsDispatcher { | ||
bind(eventName: string, callback: EventCallback, context?: any): this; | ||
bind_global(callback: EventCallback): this; | ||
unbind(eventName?: string | null, callback?: EventCallback | null, context?: any): this; | ||
unbind_global(callback?: EventCallback): this; | ||
unbind_all(): this; | ||
emit(eventName: string, data?: any): this; | ||
} | ||
interface Channel extends EventsDispatcher { | ||
/** Triggers an event */ | ||
@@ -138,4 +157,2 @@ trigger(eventName: string, data?: any): boolean; | ||
* Authenticates the connection as a member of the channel. | ||
* @param {String} socketId | ||
* @param {Function} callback | ||
*/ | ||
@@ -145,18 +162,10 @@ authorize(socketId: string, callback: (data: any) => void): void; | ||
interface EventsDispatcher { | ||
bind(eventName: string, callback: Function, context?: any): EventsDispatcher; | ||
bind_all(callback: Function): EventsDispatcher; | ||
unbind(eventName?: string, callback?: Function, context?: any): EventsDispatcher; | ||
unbind_all(eventName?: string, callback?: Function): EventsDispatcher; | ||
emit(eventName: string, data?: any): EventsDispatcher; | ||
} | ||
interface ConnectionManager extends GenericEventsDispatcher<ConnectionManager> { | ||
interface ConnectionManager extends EventsDispatcher { | ||
key: string; | ||
options: any; //TODO: Timeline.js | ||
options: any; // TODO: Timeline.js | ||
state: string; | ||
socket_id: string; | ||
connection: any; //TODO: Type this | ||
connection: any; // TODO: Type this | ||
encrypted: boolean; | ||
timeline: any; //TODO: Type this | ||
timeline: any; // TODO: Type this | ||
connectionCallbacks: { | ||
@@ -180,3 +189,3 @@ message: (message: string) => void; | ||
retry: () => void; | ||
connected: (handshake: any) => void; //TODO: Type this | ||
connected: (handshake: any) => void; // TODO: Type this | ||
}; | ||
@@ -192,11 +201,6 @@ /** | ||
* Sends raw data. | ||
* @param {String} data | ||
*/ | ||
send(data: string): boolean; | ||
/** Sends an event. | ||
* | ||
* @param {String} name | ||
* @param {String} data | ||
* @param {String} [channel] | ||
* @returns {Boolean} whether message was sent or not | ||
/** | ||
* Sends an event. | ||
*/ | ||
@@ -218,21 +222,16 @@ send_event(name: string, data: string, channel: string): boolean; | ||
* Resulting object containts two fields - id and info. | ||
* | ||
* @param {Number} id | ||
* @return {Object} member's info or null | ||
*/ | ||
get(id: number): T; | ||
get(id: string): null | T; | ||
/** | ||
* Calls back for each member in unspecified order. | ||
* | ||
* @param {Function} callback | ||
*/ | ||
each(callback: (member: any) => void): void; | ||
members: { [id: number]: UserInfo<T> }; | ||
each(callback: (member: Member<T>) => void): void; | ||
members: { [id: string]: Member<T> }; | ||
count: number; | ||
myID: number; | ||
me: UserInfo<T>; | ||
myID: string; | ||
me: Member<T>; | ||
} | ||
interface UserInfo<T> { | ||
id: number; | ||
interface Member<T> { | ||
id: string; | ||
info: T; | ||
@@ -239,0 +238,0 @@ } |
{ | ||
"name": "@types/pusher-js", | ||
"version": "3.0.30", | ||
"version": "4.2.0", | ||
"description": "TypeScript definitions for pusher-js", | ||
@@ -11,2 +11,7 @@ "license": "MIT", | ||
"githubUsername": "tkqubo" | ||
}, | ||
{ | ||
"name": "Lance Ivy", | ||
"url": "https://github.com/cainlevy", | ||
"githubUsername": "cainlevy" | ||
} | ||
@@ -21,4 +26,4 @@ ], | ||
"dependencies": {}, | ||
"typesPublisherContentHash": "073d56893a852ef4f839d150a963f6ef1130b19d3d665a50ca14621f835cb029", | ||
"typesPublisherContentHash": "ad1ad14552c2dfe88f62ff29ffed760fef40b83a103373bfaab94d76e6e99567", | ||
"typeScriptVersion": "2.0" | ||
} |
@@ -11,3 +11,3 @@ # Installation | ||
Additional Details | ||
* Last updated: Wed, 15 Nov 2017 18:09:03 GMT | ||
* Last updated: Thu, 15 Mar 2018 23:17:55 GMT | ||
* Dependencies: none | ||
@@ -17,2 +17,2 @@ * Global values: Pusher | ||
# Credits | ||
These definitions were written by Qubo <https://github.com/tkqubo>. | ||
These definitions were written by Qubo <https://github.com/tkqubo>, Lance Ivy <https://github.com/cainlevy>. |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10257