mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-06-04 19:42:46 +08:00
[sockjs] Delete sockjs, rename sockjs-node to sockjs, add tslint.json
@types/sockjs-node was impossible to use since the actual name of the package it's meant for on npm is sockjs, not sockjs-node. @types/sockjs already existed, however it was the type declaration file for an old version of sockjs-client, which already has its own up-to-date type declaration file under @types/sockjs-client. Fixes #17112
This commit is contained in:
56
types/sockjs-node/index.d.ts
vendored
56
types/sockjs-node/index.d.ts
vendored
@@ -1,56 +0,0 @@
|
||||
// Type definitions for sockjs-node 0.3.x
|
||||
// Project: https://github.com/sockjs/sockjs-node
|
||||
// Definitions by: Phil McCloghry-Laing <https://github.com/pmccloghrylaing>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
|
||||
import http = require('http');
|
||||
|
||||
export interface ServerOptions {
|
||||
sockjs_url?: string;
|
||||
prefix?: string;
|
||||
response_limit?: number;
|
||||
websocket?: boolean;
|
||||
jsessionid?: any;
|
||||
log?: (severity: string, message: string) => void;
|
||||
heartbeat_delay?: number;
|
||||
disconnect_delay?: number;
|
||||
}
|
||||
|
||||
export declare function createServer(options?: ServerOptions): Server;
|
||||
|
||||
export interface Server extends NodeJS.EventEmitter {
|
||||
installHandlers(server: http.Server, options?: ServerOptions): any;
|
||||
|
||||
on(event: 'connection', listener: (conn: Connection) => any): this;
|
||||
on(event: string, listener: Function): this;
|
||||
}
|
||||
|
||||
export interface Connection extends NodeJS.ReadWriteStream {
|
||||
remoteAddress: string;
|
||||
remotePort: number;
|
||||
address: {
|
||||
[key: string]: {
|
||||
address: string;
|
||||
port: number;
|
||||
};
|
||||
};
|
||||
headers: {
|
||||
[key: string]: string;
|
||||
};
|
||||
url: string;
|
||||
pathname: string;
|
||||
prefix: string;
|
||||
protocol: string;
|
||||
readyState: number;
|
||||
id: string;
|
||||
|
||||
close(code?: string, reason?: string): boolean;
|
||||
destroy(): void;
|
||||
|
||||
on(event: 'data', listener: (message: string) => any): this;
|
||||
on(event: 'close', listener: () => void): this;
|
||||
on(event: string, listener: Function): this;
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"sockjs-node-tests.ts"
|
||||
]
|
||||
}
|
||||
94
types/sockjs/index.d.ts
vendored
94
types/sockjs/index.d.ts
vendored
@@ -1,59 +1,55 @@
|
||||
// Type definitions for SockJS 0.3.x
|
||||
// Project: https://github.com/sockjs/sockjs-client
|
||||
// Definitions by: Emil Ivanov <https://github.com/vladev>
|
||||
// Type definitions for sockjs 0.3
|
||||
// Project: https://github.com/sockjs/sockjs-node
|
||||
// Definitions by: Phil McCloghry-Laing <https://github.com/pmccloghrylaing>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export as namespace SockJS;
|
||||
export = SockJS;
|
||||
/// <reference types="node" />
|
||||
|
||||
interface SockJSSimpleEvent {
|
||||
type: string;
|
||||
toString(): string;
|
||||
import http = require('http');
|
||||
|
||||
export interface ServerOptions {
|
||||
sockjs_url?: string;
|
||||
prefix?: string;
|
||||
response_limit?: number;
|
||||
websocket?: boolean;
|
||||
jsessionid?: any;
|
||||
log?(severity: string, message: string): void;
|
||||
heartbeat_delay?: number;
|
||||
disconnect_delay?: number;
|
||||
}
|
||||
|
||||
interface SJSOpenEvent extends SockJSSimpleEvent, Event {
|
||||
type: string;
|
||||
export function createServer(options?: ServerOptions): Server;
|
||||
|
||||
export interface Server extends NodeJS.EventEmitter {
|
||||
installHandlers(server: http.Server, options?: ServerOptions): any;
|
||||
|
||||
on(event: 'connection', listener: (conn: Connection) => any): this;
|
||||
on(event: string, listener: Function): this;
|
||||
}
|
||||
|
||||
interface SJSCloseEvent extends SockJSSimpleEvent, CloseEvent {
|
||||
code: number;
|
||||
reason: string;
|
||||
wasClean: boolean;
|
||||
type: string;
|
||||
}
|
||||
export interface Connection extends NodeJS.ReadWriteStream {
|
||||
remoteAddress: string;
|
||||
remotePort: number;
|
||||
address: {
|
||||
[key: string]: {
|
||||
address: string;
|
||||
port: number;
|
||||
};
|
||||
};
|
||||
headers: {
|
||||
[key: string]: string;
|
||||
};
|
||||
url: string;
|
||||
pathname: string;
|
||||
prefix: string;
|
||||
protocol: string;
|
||||
readyState: number;
|
||||
id: string;
|
||||
|
||||
interface SJSMessageEvent extends SockJSSimpleEvent, MessageEvent {
|
||||
data: string;
|
||||
type: string;
|
||||
}
|
||||
close(code?: string, reason?: string): boolean;
|
||||
destroy(): void;
|
||||
|
||||
interface SockJS extends WebSocket {
|
||||
protocol: string;
|
||||
readyState: number;
|
||||
onopen: (ev: SJSOpenEvent) => any;
|
||||
onmessage: (ev: SJSMessageEvent) => any;
|
||||
onclose: (ev: SJSCloseEvent) => any;
|
||||
send(data: any): void;
|
||||
close(code?: number, reason?: string): void;
|
||||
OPEN: number;
|
||||
CLOSING: number;
|
||||
CONNECTING: number;
|
||||
CLOSED: number;
|
||||
on(event: 'data', listener: (message: string) => any): this;
|
||||
on(event: 'close', listener: () => void): this;
|
||||
on(event: string, listener: Function): this;
|
||||
}
|
||||
|
||||
declare var SockJS: {
|
||||
prototype: SockJS;
|
||||
new (url: string, _reserved?: any, options?: {
|
||||
debug?: boolean;
|
||||
devel?: boolean;
|
||||
protocols_whitelist?: string[];
|
||||
server?: string;
|
||||
rtt?: number;
|
||||
rto?: number;
|
||||
info?: {
|
||||
websocket?: boolean;
|
||||
cookie_needed?: boolean;
|
||||
null_origin?: boolean;
|
||||
};
|
||||
}): SockJS;
|
||||
};
|
||||
@@ -1,16 +1,16 @@
|
||||
import sockjs = require("sockjs-node");
|
||||
import http = require("http");
|
||||
import stream = require("stream");
|
||||
import * as sockjs from 'sockjs';
|
||||
import * as http from 'http';
|
||||
import * as stream from 'stream';
|
||||
|
||||
var server: sockjs.Server,
|
||||
serverOptions: sockjs.ServerOptions = {};
|
||||
let server: sockjs.Server;
|
||||
let serverOptions: sockjs.ServerOptions = {};
|
||||
|
||||
// createServer method
|
||||
server = sockjs.createServer();
|
||||
server = sockjs.createServer(serverOptions);
|
||||
|
||||
// installHandlers method
|
||||
var httpServer: http.Server = http.createServer();
|
||||
let httpServer: http.Server = http.createServer();
|
||||
server.installHandlers(httpServer);
|
||||
server.installHandlers(httpServer, serverOptions);
|
||||
|
||||
@@ -23,21 +23,21 @@ serverOptions.websocket = true;
|
||||
serverOptions.jsessionid = true;
|
||||
serverOptions.jsessionid = () => true;
|
||||
|
||||
serverOptions.log = (severity: any, message: any) => { };
|
||||
serverOptions.log = (severity: string, message: string) => { };
|
||||
serverOptions.heartbeat_delay = 25000;
|
||||
serverOptions.disconnect_delay = 5000;
|
||||
|
||||
// Connection
|
||||
var connection: sockjs.Connection;
|
||||
let connection: sockjs.Connection;
|
||||
|
||||
// on('connection') passes a sockJS connection
|
||||
server.on('connection', (conn: any) => {
|
||||
server.on('connection', (conn: sockjs.Connection) => {
|
||||
connection = conn;
|
||||
conn = connection;
|
||||
});
|
||||
|
||||
// connection is a ReadWriteStream
|
||||
var connectionAsReadWrite: NodeJS.ReadWriteStream = connection;
|
||||
let connectionAsReadWrite: NodeJS.ReadWriteStream = connection;
|
||||
|
||||
connection.on('data', (message: string) => { });
|
||||
connection.on('close', () => { });
|
||||
@@ -2,8 +2,7 @@
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
@@ -17,6 +16,7 @@
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts"
|
||||
"index.d.ts",
|
||||
"sockjs-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
6
types/sockjs/tslint.json
Normal file
6
types/sockjs/tslint.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"ban-types": false
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user