mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-05-29 15:44:31 +00:00
Remove <reference path="../xxx/xxx.d.ts"> from definitions files and replace it with import * as Xxx from "xxx" or <reference types="xxx"/>
This commit is contained in:
256
angular-websocket/angular-websocket.d.ts
vendored
256
angular-websocket/angular-websocket.d.ts
vendored
@@ -3,155 +3,157 @@
|
||||
// Definitions by: Nick Veys <https://github.com/nickveys>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path='../angularjs/angular.d.ts' />
|
||||
import * as ng from "angular";
|
||||
|
||||
declare namespace angular.websocket {
|
||||
|
||||
/**
|
||||
* Options available to be specified for IWebSocketProvider.
|
||||
*/
|
||||
type IWebSocketConfigOptions = {
|
||||
scope?: ng.IScope;
|
||||
rootScopeFailOver?: boolean;
|
||||
useApplyAsync?: boolean;
|
||||
initialTimeout?: number;
|
||||
maxTimeout?: number;
|
||||
binaryType?: "blob" | "arraybuffer";
|
||||
reconnectIfNotNormalClose?: boolean;
|
||||
}
|
||||
interface IWebSocketProvider {
|
||||
/**
|
||||
* Creates and opens an IWebSocket instance.
|
||||
*
|
||||
* @param url url to connect to
|
||||
* @return websocket instance
|
||||
*/
|
||||
(url: string, protocols?: string | string[] | IWebSocketConfigOptions, options?: IWebSocketConfigOptions): IWebSocket;
|
||||
}
|
||||
|
||||
/** Options available to be specified for IWebSocket.onMessage */
|
||||
type IWebSocketMessageOptions = {
|
||||
declare module "angular" {
|
||||
namespace websocket {
|
||||
|
||||
/**
|
||||
* If specified, only messages that match the filter will cause the message event
|
||||
* to be fired.
|
||||
* Options available to be specified for IWebSocketProvider.
|
||||
*/
|
||||
filter?: string | RegExp;
|
||||
type IWebSocketConfigOptions = {
|
||||
scope?: ng.IScope;
|
||||
rootScopeFailOver?: boolean;
|
||||
useApplyAsync?: boolean;
|
||||
initialTimeout?: number;
|
||||
maxTimeout?: number;
|
||||
binaryType?: "blob" | "arraybuffer";
|
||||
reconnectIfNotNormalClose?: boolean;
|
||||
}
|
||||
interface IWebSocketProvider {
|
||||
/**
|
||||
* Creates and opens an IWebSocket instance.
|
||||
*
|
||||
* @param url url to connect to
|
||||
* @return websocket instance
|
||||
*/
|
||||
(url: string, protocols?: string | string[] | IWebSocketConfigOptions, options?: IWebSocketConfigOptions): IWebSocket;
|
||||
}
|
||||
|
||||
/** If true, each message handled will safely call `$rootScope.$digest()`. */
|
||||
autoApply?: boolean;
|
||||
}
|
||||
/** Options available to be specified for IWebSocket.onMessage */
|
||||
type IWebSocketMessageOptions = {
|
||||
|
||||
/** Type corresponding to onMessage callbaks stored in $Websocket#onMessageCallbacks instance. */
|
||||
type IWebSocketMessageHandler = {
|
||||
fn: (evt: MessageEvent) => void;
|
||||
pattern: string | RegExp;
|
||||
autoApply: boolean;
|
||||
}
|
||||
/**
|
||||
* If specified, only messages that match the filter will cause the message event
|
||||
* to be fired.
|
||||
*/
|
||||
filter?: string | RegExp;
|
||||
|
||||
/** Type corresponding to items stored in $WebSocket#sendQueue instance. */
|
||||
type IWebSocketQueueItem = {
|
||||
message: any;
|
||||
defered: ng.IPromise<void>;
|
||||
}
|
||||
/** If true, each message handled will safely call `$rootScope.$digest()`. */
|
||||
autoApply?: boolean;
|
||||
}
|
||||
|
||||
interface IWebSocket {
|
||||
/** Type corresponding to onMessage callbaks stored in $Websocket#onMessageCallbacks instance. */
|
||||
type IWebSocketMessageHandler = {
|
||||
fn: (evt: MessageEvent) => void;
|
||||
pattern: string | RegExp;
|
||||
autoApply: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a callback to be executed each time a socket connection is opened for
|
||||
* this instance.
|
||||
*
|
||||
* @param event event object
|
||||
* @returns this instance, for method chaining
|
||||
*/
|
||||
onOpen(callback: (event: Event) => void): IWebSocket;
|
||||
/** Type corresponding to items stored in $WebSocket#sendQueue instance. */
|
||||
type IWebSocketQueueItem = {
|
||||
message: any;
|
||||
defered: ng.IPromise<void>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a callback to be executed each time a socket connection is closed for
|
||||
* this instance.
|
||||
*
|
||||
* @param event event object
|
||||
* @returns this instance, for method chaining
|
||||
*/
|
||||
onClose(callback: (event: CloseEvent) => void): IWebSocket;
|
||||
interface IWebSocket {
|
||||
|
||||
/**
|
||||
* Adds a callback to be executed each time a socket connection is closed for
|
||||
* this instance.
|
||||
*
|
||||
* @param event event object
|
||||
* @returns this instance, for method chaining
|
||||
*/
|
||||
onError(callback: (event: Event) => void): IWebSocket;
|
||||
/**
|
||||
* Adds a callback to be executed each time a socket connection is opened for
|
||||
* this instance.
|
||||
*
|
||||
* @param event event object
|
||||
* @returns this instance, for method chaining
|
||||
*/
|
||||
onOpen(callback: (event: Event) => void): IWebSocket;
|
||||
|
||||
/**
|
||||
* Adds a callback to be executed each time a socket connection has an error for
|
||||
* this instance.
|
||||
*
|
||||
* @param event event object
|
||||
* @returns this instance, for method chaining
|
||||
*/
|
||||
onMessage(callback: (event: MessageEvent) => void, options?: IWebSocketMessageOptions): IWebSocket;
|
||||
/**
|
||||
* Adds a callback to be executed each time a socket connection is closed for
|
||||
* this instance.
|
||||
*
|
||||
* @param event event object
|
||||
* @returns this instance, for method chaining
|
||||
*/
|
||||
onClose(callback: (event: CloseEvent) => void): IWebSocket;
|
||||
|
||||
/**
|
||||
* Closes the underlying socket, as long as no data is still being sent from the client.
|
||||
*
|
||||
* @param force if `true`, force close even if data is still being sent
|
||||
* @returns this instance, for method chaining
|
||||
*/
|
||||
close(force?: boolean): IWebSocket;
|
||||
/**
|
||||
* Adds a callback to be executed each time a socket connection is closed for
|
||||
* this instance.
|
||||
*
|
||||
* @param event event object
|
||||
* @returns this instance, for method chaining
|
||||
*/
|
||||
onError(callback: (event: Event) => void): IWebSocket;
|
||||
|
||||
/**
|
||||
* Adds data to a queue, and attempts to send if the socket is ready.
|
||||
*
|
||||
* @param data data to send, if this is an object, it will be stringified before sending
|
||||
*/
|
||||
send(data: string | {}): ng.IPromise<any>;
|
||||
/**
|
||||
* Adds a callback to be executed each time a socket connection has an error for
|
||||
* this instance.
|
||||
*
|
||||
* @param event event object
|
||||
* @returns this instance, for method chaining
|
||||
*/
|
||||
onMessage(callback: (event: MessageEvent) => void, options?: IWebSocketMessageOptions): IWebSocket;
|
||||
|
||||
/**
|
||||
* WebSocket instance.
|
||||
*/
|
||||
socket: WebSocket;
|
||||
/**
|
||||
* Closes the underlying socket, as long as no data is still being sent from the client.
|
||||
*
|
||||
* @param force if `true`, force close even if data is still being sent
|
||||
* @returns this instance, for method chaining
|
||||
*/
|
||||
close(force?: boolean): IWebSocket;
|
||||
|
||||
/**
|
||||
* Queue of send calls to be made on socket when socket is able to receive data.
|
||||
*/
|
||||
sendQueue: IWebSocketQueueItem[];
|
||||
/**
|
||||
* Adds data to a queue, and attempts to send if the socket is ready.
|
||||
*
|
||||
* @param data data to send, if this is an object, it will be stringified before sending
|
||||
*/
|
||||
send(data: string | {}): ng.IPromise<any>;
|
||||
|
||||
/**
|
||||
* List of callbacks to be executed when the socket is opened.
|
||||
*/
|
||||
onOpenCallbacks: ((evt: Event) => void)[];
|
||||
/**
|
||||
* WebSocket instance.
|
||||
*/
|
||||
socket: WebSocket;
|
||||
|
||||
/**
|
||||
* List of callbacks to be executed when a message is received from the socket.
|
||||
*/
|
||||
onMessageCallbacks: IWebSocketMessageHandler[];
|
||||
/**
|
||||
* Queue of send calls to be made on socket when socket is able to receive data.
|
||||
*/
|
||||
sendQueue: IWebSocketQueueItem[];
|
||||
|
||||
/**
|
||||
* List of callbacks to be executed when an error is received from the socket.
|
||||
*/
|
||||
onErrorCallbacks: ((evt: Event) => void)[];
|
||||
/**
|
||||
* List of callbacks to be executed when the socket is opened.
|
||||
*/
|
||||
onOpenCallbacks: ((evt: Event) => void)[];
|
||||
|
||||
/**
|
||||
* List of callbacks to be executed when the socket is closed.
|
||||
*/
|
||||
onCloseCallbacks: ((evt: CloseEvent) => void)[];
|
||||
/**
|
||||
* List of callbacks to be executed when a message is received from the socket.
|
||||
*/
|
||||
onMessageCallbacks: IWebSocketMessageHandler[];
|
||||
|
||||
/**
|
||||
* Returns either the readyState value from the underlying WebSocket instance
|
||||
* or a proprietary value representing the internal state
|
||||
*/
|
||||
readyState: number;
|
||||
/**
|
||||
* List of callbacks to be executed when an error is received from the socket.
|
||||
*/
|
||||
onErrorCallbacks: ((evt: Event) => void)[];
|
||||
|
||||
/**
|
||||
* The initial timeout.
|
||||
*/
|
||||
initialTimeout: number;
|
||||
/**
|
||||
* List of callbacks to be executed when the socket is closed.
|
||||
*/
|
||||
onCloseCallbacks: ((evt: CloseEvent) => void)[];
|
||||
|
||||
/**
|
||||
* Maximun timeout used to determine reconnection delay.
|
||||
*/
|
||||
maxTimeout: number;
|
||||
/**
|
||||
* Returns either the readyState value from the underlying WebSocket instance
|
||||
* or a proprietary value representing the internal state
|
||||
*/
|
||||
readyState: number;
|
||||
|
||||
/**
|
||||
* The initial timeout.
|
||||
*/
|
||||
initialTimeout: number;
|
||||
|
||||
/**
|
||||
* Maximun timeout used to determine reconnection delay.
|
||||
*/
|
||||
maxTimeout: number;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user