Skip to content

Commit

Permalink
include automatically generated declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
James Lees committed Feb 11, 2020
1 parent fcfb007 commit 255e7d7
Show file tree
Hide file tree
Showing 116 changed files with 1,208 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"compilerOptions": {
"sourceMap": true,
"module": "es6",
"declaration": false,
"declaration": true,
"declarationDir": "types",
"target": "es3",
"removeComments": true,
"moduleResolution": "node",
Expand Down
15 changes: 15 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import Pusher from './src/core/pusher'
import { Authorizer, AuthOptions, AuthorizerGenerator } from './src/core/auth/options';
import { Options } from './src/core/options'
import Channel from './src/core/channels/channel';
import Runtime from './src/runtimes/interface'

export {
Options,
AuthOptions,
AuthorizerGenerator,
Authorizer,
Channel,
Runtime,
}
export default Pusher
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export declare var Dependencies: {};
4 changes: 4 additions & 0 deletions types/spec/javascripts/helpers/pusher_integration_class.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import Pusher from '../../../src/core/pusher';
export default class PusherIntegration extends Pusher {
static Integration: any;
}
8 changes: 8 additions & 0 deletions types/src/core/auth/auth_transports.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import AbstractRuntime from 'runtimes/interface';
interface AuthTransport {
(context: AbstractRuntime, socketId: string, callback: Function): void;
}
interface AuthTransports {
[index: string]: AuthTransport;
}
export { AuthTransport, AuthTransports };
16 changes: 16 additions & 0 deletions types/src/core/auth/options.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import Channel from '../channels/channel';
export interface AuthOptions {
params: any;
headers: any;
}
export interface Authorizer {
authorize(socketId: string, callback: Function): any;
}
export interface AuthorizerGenerator {
(channel: Channel, options: AuthorizerOptions): Authorizer;
}
export interface AuthorizerOptions {
authTransport: 'ajax' | 'jsonp';
auth: AuthOptions;
authorizer: AuthorizerGenerator;
}
13 changes: 13 additions & 0 deletions types/src/core/auth/pusher_authorizer.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import Channel from '../channels/channel';
import { AuthTransports } from './auth_transports';
import { AuthOptions, AuthorizerOptions, Authorizer } from './options';
export default class PusherAuthorizer implements Authorizer {
static authorizers: AuthTransports;
channel: Channel;
type: string;
options: AuthorizerOptions;
authOptions: AuthOptions;
constructor(channel: Channel, options: AuthorizerOptions);
composeQuery(socketId: string): string;
authorize(socketId: string, callback: Function): any;
}
1 change: 1 addition & 0 deletions types/src/core/base64.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default function encode(s: any): string;
20 changes: 20 additions & 0 deletions types/src/core/channels/channel.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { default as EventsDispatcher } from '../events/dispatcher';
import Pusher from '../pusher';
import { PusherEvent } from '../connection/protocol/message-types';
export default class Channel extends EventsDispatcher {
name: string;
pusher: Pusher;
subscribed: boolean;
subscriptionPending: boolean;
subscriptionCancelled: boolean;
constructor(name: string, pusher: Pusher);
authorize(socketId: string, callback: Function): any;
trigger(event: string, data: any): boolean;
disconnect(): void;
handleEvent(event: PusherEvent): void;
handleSubscriptionSucceededEvent(event: PusherEvent): void;
subscribe(): void;
unsubscribe(): void;
cancelSubscription(): void;
reinstateSubscription(): void;
}
5 changes: 5 additions & 0 deletions types/src/core/channels/channel_table.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Channel from './channel';
interface ChannelTable {
[index: string]: Channel;
}
export default ChannelTable;
12 changes: 12 additions & 0 deletions types/src/core/channels/channels.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Channel from './channel';
import ChannelTable from './channel_table';
import Pusher from '../pusher';
export default class Channels {
channels: ChannelTable;
constructor();
add(name: string, pusher: Pusher): Channel;
all(): Channel[];
find(name: string): Channel;
remove(name: string): Channel;
disconnect(): void;
}
11 changes: 11 additions & 0 deletions types/src/core/channels/encrypted_channel.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import PrivateChannel from './private_channel';
import Dispatcher from '../events/dispatcher';
import { PusherEvent } from '../connection/protocol/message-types';
export default class EncryptedChannel extends PrivateChannel {
key: Uint8Array;
authorize(socketId: string, callback: Function): void;
trigger(event: string, data: any): boolean;
handleEvent(event: PusherEvent): void;
private handleEncryptedEvent;
emitJSON(eventName: string, data?: any): Dispatcher;
}
14 changes: 14 additions & 0 deletions types/src/core/channels/members.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export default class Members {
members: any;
count: number;
myID: any;
me: any;
constructor();
get(id: string): any;
each(callback: Function): void;
setMyID(id: string): void;
onSubscription(subscriptionData: any): void;
addMember(memberData: any): any;
removeMember(memberData: any): any;
reset(): void;
}
4 changes: 4 additions & 0 deletions types/src/core/channels/metadata.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
interface Metadata {
user_id?: string;
}
export default Metadata;
13 changes: 13 additions & 0 deletions types/src/core/channels/presence_channel.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import PrivateChannel from './private_channel';
import Members from './members';
import Pusher from '../pusher';
import { PusherEvent } from '../connection/protocol/message-types';
export default class PresenceChannel extends PrivateChannel {
members: Members;
constructor(name: string, pusher: Pusher);
authorize(socketId: string, callback: Function): void;
handleEvent(event: PusherEvent): void;
handleInternalEvent(event: PusherEvent): void;
handleSubscriptionSucceededEvent(event: PusherEvent): void;
disconnect(): void;
}
4 changes: 4 additions & 0 deletions types/src/core/channels/private_channel.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import Channel from './channel';
export default class PrivateChannel extends Channel {
authorize(socketId: string, callback: Function): any;
}
20 changes: 20 additions & 0 deletions types/src/core/config.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export declare var getGlobalConfig: () => {
wsHost: string;
wsPort: number;
wssPort: number;
wsPath: string;
httpHost: string;
httpPort: number;
httpsPort: number;
httpPath: string;
statsHost: string;
authEndpoint: string;
authTransport: string;
activityTimeout: number;
pongTimeout: number;
unavailableTimeout: number;
};
export declare var getClusterConfig: (clusterName: any) => {
wsHost: string;
httpHost: string;
};
18 changes: 18 additions & 0 deletions types/src/core/connection/callbacks.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import HandshakePayload from './handshake/handshake_payload';
import Action from './protocol/action';
export interface ErrorCallbacks {
tls_only: (result: Action | HandshakePayload) => void;
refused: (result: Action | HandshakePayload) => void;
backoff: (result: Action | HandshakePayload) => void;
retry: (result: Action | HandshakePayload) => void;
}
export interface HandshakeCallbacks {
connected: (handshake: HandshakePayload) => void;
}
export interface ConnectionCallbacks {
message: (message: any) => void;
ping: () => void;
activity: () => void;
error: (error: any) => void;
closed: () => void;
}
16 changes: 16 additions & 0 deletions types/src/core/connection/connection.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { default as EventsDispatcher } from '../events/dispatcher';
import TransportConnection from '../transports/transport_connection';
import Socket from '../socket';
export default class Connection extends EventsDispatcher implements Socket {
id: string;
transport: TransportConnection;
activityTimeout: number;
constructor(id: string, transport: TransportConnection);
handlesActivityChecks(): boolean;
send(data: any): boolean;
send_event(name: string, data: any, channel?: string): boolean;
ping(): void;
close(): void;
private bindListeners;
private handleCloseEvent;
}
50 changes: 50 additions & 0 deletions types/src/core/connection/connection_manager.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { default as EventsDispatcher } from '../events/dispatcher';
import { OneOffTimer as Timer } from '../utils/timers';
import Connection from './connection';
import Strategy from '../strategies/strategy';
import StrategyRunner from '../strategies/strategy_runner';
import Timeline from '../timeline/timeline';
import ConnectionManagerOptions from './connection_manager_options';
import { ErrorCallbacks, HandshakeCallbacks, ConnectionCallbacks } from './callbacks';
export default class ConnectionManager extends EventsDispatcher {
key: string;
options: ConnectionManagerOptions;
state: string;
connection: Connection;
usingTLS: boolean;
timeline: Timeline;
socket_id: string;
unavailableTimer: Timer;
activityTimer: Timer;
retryTimer: Timer;
activityTimeout: number;
strategy: Strategy;
runner: StrategyRunner;
errorCallbacks: ErrorCallbacks;
handshakeCallbacks: HandshakeCallbacks;
connectionCallbacks: ConnectionCallbacks;
constructor(key: string, options: any);
connect(): void;
send(data: any): boolean;
send_event(name: string, data: any, channel?: string): boolean;
disconnect(): void;
isUsingTLS(): boolean;
private startConnecting;
private abortConnecting;
private disconnectInternally;
private updateStrategy;
private retryIn;
private clearRetryTimer;
private setUnavailableTimer;
private clearUnavailableTimer;
private sendActivityCheck;
private resetActivityCheck;
private stopActivityCheck;
private buildConnectionCallbacks;
private buildHandshakeCallbacks;
private buildErrorCallbacks;
private setConnection;
private abandonConnection;
private updateState;
private shouldRetry;
}
10 changes: 10 additions & 0 deletions types/src/core/connection/connection_manager_options.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Timeline from '../timeline/timeline';
import Strategy from '../strategies/strategy';
interface ConnectionManagerOptions {
timeline: Timeline;
getStrategy: (StrategyOptions: any) => Strategy;
unavailableTimeout: number;
pongTimeout: number;
activityTimeout: number;
}
export default ConnectionManagerOptions;
8 changes: 8 additions & 0 deletions types/src/core/connection/handshake/handshake_payload.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import TransportConnection from '../../transports/transport_connection';
import Action from '../protocol/action';
import Connection from '../connection';
interface HandshakePayload extends Action {
transport: TransportConnection;
connection?: Connection;
}
export default HandshakePayload;
12 changes: 12 additions & 0 deletions types/src/core/connection/handshake/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import TransportConnection from '../../transports/transport_connection';
export default class Handshake {
transport: TransportConnection;
callback: (HandshakePayload: any) => void;
onMessage: Function;
onClosed: Function;
constructor(transport: TransportConnection, callback: (HandshakePayload: any) => void);
close(): void;
private bindListeners;
private unbindListeners;
private finish;
}
7 changes: 7 additions & 0 deletions types/src/core/connection/protocol/action.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
interface Action {
action: string;
id?: string;
activityTimeout?: number;
error?: any;
}
export default Action;
7 changes: 7 additions & 0 deletions types/src/core/connection/protocol/message-types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
interface PusherEvent {
event: string;
channel?: string;
data?: any;
user_id?: string;
}
export { PusherEvent };
10 changes: 10 additions & 0 deletions types/src/core/connection/protocol/protocol.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Action from './action';
import { PusherEvent } from './message-types';
declare const Protocol: {
decodeMessage: (messageEvent: MessageEvent) => PusherEvent;
encodeMessage: (event: PusherEvent) => string;
processHandshake: (messageEvent: MessageEvent) => Action;
getCloseAction: (closeEvent: any) => string;
getCloseError: (closeEvent: any) => any;
};
export default Protocol;
23 changes: 23 additions & 0 deletions types/src/core/defaults.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
export interface DefaultConfig {
VERSION: string;
PROTOCOL: number;
host: string;
ws_port: number;
wss_port: number;
ws_path: string;
sockjs_host: string;
sockjs_http_port: number;
sockjs_https_port: number;
sockjs_path: string;
stats_host: string;
channel_auth_endpoint: string;
channel_auth_transport: string;
activity_timeout: number;
pong_timeout: number;
unavailable_timeout: number;
cdn_http?: string;
cdn_https?: string;
dependency_suffix?: string;
}
declare var Defaults: DefaultConfig;
export default Defaults;
21 changes: 21 additions & 0 deletions types/src/core/errors.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export declare class BadEventName extends Error {
constructor(msg?: string);
}
export declare class RequestTimedOut extends Error {
constructor(msg?: string);
}
export declare class TransportPriorityTooLow extends Error {
constructor(msg?: string);
}
export declare class TransportClosed extends Error {
constructor(msg?: string);
}
export declare class UnsupportedFeature extends Error {
constructor(msg?: string);
}
export declare class UnsupportedTransport extends Error {
constructor(msg?: string);
}
export declare class UnsupportedStrategy extends Error {
constructor(msg?: string);
}
5 changes: 5 additions & 0 deletions types/src/core/events/callback.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
interface Callback {
fn: Function;
context: any;
}
export default Callback;
11 changes: 11 additions & 0 deletions types/src/core/events/callback_registry.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import Callback from './callback';
import CallbackTable from './callback_table';
export default class CallbackRegistry {
_callbacks: CallbackTable;
constructor();
get(name: string): Callback[];
add(name: string, callback: Function, context: any): void;
remove(name?: string, callback?: Function, context?: any): void;
private removeCallback;
private removeAllCallbacks;
}
Loading

0 comments on commit 255e7d7

Please sign in to comment.