diff --git a/clients/ts/signalr-protocol-msgpack/spec/BinaryMessageFormatter.spec.ts b/clients/ts/signalr-protocol-msgpack/spec/BinaryMessageFormatter.spec.ts index 1b229cc577..529ddfc567 100644 --- a/clients/ts/signalr-protocol-msgpack/spec/BinaryMessageFormatter.spec.ts +++ b/clients/ts/signalr-protocol-msgpack/spec/BinaryMessageFormatter.spec.ts @@ -1,20 +1,20 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -import { BinaryMessageFormat } from "../src/BinaryMessageFormat" +import { BinaryMessageFormat } from "../src/BinaryMessageFormat"; describe("Binary Message Formatter", () => { ([ - [[], []], - [[0x00], [ new Uint8Array([])]], - [[0x01, 0xff], [ new Uint8Array([0xff])]], + [[], [] as Uint8Array[]], + [[0x00], [ new Uint8Array([])] as Uint8Array[]], + [[0x01, 0xff], [ new Uint8Array([0xff])] as Uint8Array[]], [[0x01, 0xff, - 0x01, 0x7f], [ new Uint8Array([0xff]), new Uint8Array([0x7f])]], - ] as [number[], Uint8Array[]][]).forEach(([payload, expected_messages]) => { + 0x01, 0x7f], [ new Uint8Array([0xff]), new Uint8Array([0x7f])] as Uint8Array[]], + ] as Array<[number[], Uint8Array[]]>).forEach(([payload, expectedMessages]) => { it(`should parse '${payload}' correctly`, () => { - let messages = BinaryMessageFormat.parse(new Uint8Array(payload).buffer); - expect(messages).toEqual(expected_messages); - }) + const messages = BinaryMessageFormat.parse(new Uint8Array(payload).buffer); + expect(messages).toEqual(expectedMessages); + }); }); ([ @@ -26,34 +26,34 @@ describe("Binary Message Formatter", () => { [[0x80, 0x80, 0x80, 0x80, 0x08], new Error("Messages bigger than 2GB are not supported.")], [[0x80, 0x80, 0x80, 0x80, 0x80], new Error("Messages bigger than 2GB are not supported.")], [[0x02, 0x00], new Error("Incomplete message.")], - [[0xff, 0xff, 0xff, 0xff, 0x07], new Error("Incomplete message.")] - ] as [number[], Error][]).forEach(([payload, expected_error]) => { + [[0xff, 0xff, 0xff, 0xff, 0x07], new Error("Incomplete message.")], + ] as Array<[number[], Error]>).forEach(([payload, expectedError]) => { it(`should fail to parse '${payload}'`, () => { - expect(() => BinaryMessageFormat.parse(new Uint8Array(payload).buffer)).toThrow(expected_error); - }) + expect(() => BinaryMessageFormat.parse(new Uint8Array(payload).buffer)).toThrow(expectedError); + }); }); ([ [[], [0x00]], [[0x20], [0x01, 0x20]], - ] as [number[], number[]][]).forEach(([input, expected_payload]) => { + ] as Array<[number[], number[]]>).forEach(([input, expectedPayload]) => { it(`should write '${input}'`, () => { - let actual = new Uint8Array(BinaryMessageFormat.write(new Uint8Array(input))); - let expected = new Uint8Array(expected_payload); + const actual = new Uint8Array(BinaryMessageFormat.write(new Uint8Array(input))); + const expected = new Uint8Array(expectedPayload); expect(actual).toEqual(expected); - }) + }); }); - ([0x0000, 0x0001, 0x007f, 0x0080, 0x3fff, 0x4000, 0xc0de] as number[]).forEach(size => { + ([0x0000, 0x0001, 0x007f, 0x0080, 0x3fff, 0x4000, 0xc0de] as number[]).forEach((size) => { it(`messages should be roundtrippable (message size: '${size}')`, () => { const message = []; for (let i = 0; i < size; i++) { message.push(i & 0xff); } - var payload = new Uint8Array(message); + const payload = new Uint8Array(message); expect(payload).toEqual(BinaryMessageFormat.parse(BinaryMessageFormat.write(payload))[0]); - }) + }); }); -}); \ No newline at end of file +}); diff --git a/clients/ts/signalr-protocol-msgpack/src/MessagePackHubProtocol.ts b/clients/ts/signalr-protocol-msgpack/src/MessagePackHubProtocol.ts index 0fe9b698b0..9722783551 100644 --- a/clients/ts/signalr-protocol-msgpack/src/MessagePackHubProtocol.ts +++ b/clients/ts/signalr-protocol-msgpack/src/MessagePackHubProtocol.ts @@ -1,9 +1,11 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -import { CompletionMessage, HubMessage, IHubProtocol, ILogger, InvocationMessage, LogLevel, MessageHeaders, MessageType, NullLogger, StreamInvocationMessage, StreamItemMessage, TransferFormat } from "@aspnet/signalr"; import { Buffer } from "buffer"; import * as msgpack5 from "msgpack5"; + +import { CompletionMessage, HubMessage, IHubProtocol, ILogger, InvocationMessage, LogLevel, MessageHeaders, MessageType, NullLogger, StreamInvocationMessage, StreamItemMessage, TransferFormat } from "@aspnet/signalr"; + import { BinaryMessageFormat } from "./BinaryMessageFormat"; export class MessagePackHubProtocol implements IHubProtocol { diff --git a/clients/ts/signalr/spec/Common.ts b/clients/ts/signalr/spec/Common.ts index 2653cd00a6..ae3479ba8b 100644 --- a/clients/ts/signalr/spec/Common.ts +++ b/clients/ts/signalr/spec/Common.ts @@ -1,7 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -import { HttpTransportType, ITransport } from "../src/ITransport"; +import { HttpTransportType } from "../src/ITransport"; export function eachTransport(action: (transport: HttpTransportType) => void) { const transportTypes = [ diff --git a/clients/ts/signalr/spec/HubConnection.spec.ts b/clients/ts/signalr/spec/HubConnection.spec.ts index 4e17b1bba4..a73ead1e33 100644 --- a/clients/ts/signalr/spec/HubConnection.spec.ts +++ b/clients/ts/signalr/spec/HubConnection.spec.ts @@ -5,7 +5,7 @@ import { HubConnection } from "../src/HubConnection"; import { IConnection } from "../src/IConnection"; import { HubMessage, IHubProtocol, MessageType } from "../src/IHubProtocol"; import { ILogger, LogLevel } from "../src/ILogger"; -import { HttpTransportType, ITransport, TransferFormat } from "../src/ITransport"; +import { TransferFormat } from "../src/ITransport"; import { JsonHubProtocol } from "../src/JsonHubProtocol"; import { NullLogger } from "../src/Loggers"; import { IStreamSubscriber } from "../src/Stream"; diff --git a/clients/ts/signalr/spec/HubConnectionBuilder.spec.ts b/clients/ts/signalr/spec/HubConnectionBuilder.spec.ts index 1adbe925cd..e9f4c5a7aa 100644 --- a/clients/ts/signalr/spec/HubConnectionBuilder.spec.ts +++ b/clients/ts/signalr/spec/HubConnectionBuilder.spec.ts @@ -1,10 +1,9 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -import { HubConnectionBuilder } from "../src/HubConnectionBuilder"; - import { HttpRequest, HttpResponse } from "../src/HttpClient"; import { HubConnection } from "../src/HubConnection"; +import { HubConnectionBuilder } from "../src/HubConnectionBuilder"; import { IHttpConnectionOptions } from "../src/IHttpConnectionOptions"; import { HubMessage, IHubProtocol } from "../src/IHubProtocol"; import { ILogger, LogLevel } from "../src/ILogger"; diff --git a/clients/ts/signalr/spec/TextMessageFormatter.spec.ts b/clients/ts/signalr/spec/TextMessageFormat.spec.ts similarity index 96% rename from clients/ts/signalr/spec/TextMessageFormatter.spec.ts rename to clients/ts/signalr/spec/TextMessageFormat.spec.ts index e4a8eccd45..92c9e2f845 100644 --- a/clients/ts/signalr/spec/TextMessageFormatter.spec.ts +++ b/clients/ts/signalr/spec/TextMessageFormat.spec.ts @@ -3,7 +3,7 @@ import { TextMessageFormat } from "../src/TextMessageFormat"; -describe("Text Message Formatter", () => { +describe("TextMessageFormat", () => { ([ ["\u001e", [""]], ["\u001e\u001e", ["", ""]], diff --git a/clients/ts/signalr/spec/Utils.ts b/clients/ts/signalr/spec/Utils.ts index 15b630d930..937f85808b 100644 --- a/clients/ts/signalr/spec/Utils.ts +++ b/clients/ts/signalr/spec/Utils.ts @@ -58,4 +58,4 @@ export class PromiseSource { public reject(reason?: any) { this.rejecter(reason); } -} \ No newline at end of file +} diff --git a/clients/ts/signalr/src/HandshakeProtocol.ts b/clients/ts/signalr/src/HandshakeProtocol.ts index 7c79151123..ba6906ef5f 100644 --- a/clients/ts/signalr/src/HandshakeProtocol.ts +++ b/clients/ts/signalr/src/HandshakeProtocol.ts @@ -1,4 +1,6 @@ -import { ILogger, LogLevel } from "./ILogger"; +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + import { TextMessageFormat } from "./TextMessageFormat"; export interface HandshakeRequestMessage { diff --git a/clients/ts/signalr/src/HubConnection.ts b/clients/ts/signalr/src/HubConnection.ts index 875217ded9..6c4e804687 100644 --- a/clients/ts/signalr/src/HubConnection.ts +++ b/clients/ts/signalr/src/HubConnection.ts @@ -2,15 +2,11 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. import { HandshakeProtocol, HandshakeRequestMessage, HandshakeResponseMessage } from "./HandshakeProtocol"; -import { HttpConnection } from "./HttpConnection"; import { IConnection } from "./IConnection"; -import { CancelInvocationMessage, CompletionMessage, HubMessage, IHubProtocol, InvocationMessage, MessageType, StreamInvocationMessage, StreamItemMessage } from "./IHubProtocol"; +import { CancelInvocationMessage, CompletionMessage, IHubProtocol, InvocationMessage, MessageType, StreamInvocationMessage, StreamItemMessage } from "./IHubProtocol"; import { ILogger, LogLevel } from "./ILogger"; -import { JsonHubProtocol } from "./JsonHubProtocol"; -import { NullLogger } from "./Loggers"; import { IStreamResult } from "./Stream"; -import { TextMessageFormat } from "./TextMessageFormat"; -import { Arg, createLogger, Subject } from "./Utils"; +import { Arg, Subject } from "./Utils"; const DEFAULT_TIMEOUT_IN_MS: number = 30 * 1000; diff --git a/clients/ts/signalr/src/IHubProtocol.ts b/clients/ts/signalr/src/IHubProtocol.ts index f98609f976..ee30cc182c 100644 --- a/clients/ts/signalr/src/IHubProtocol.ts +++ b/clients/ts/signalr/src/IHubProtocol.ts @@ -1,9 +1,9 @@ -import { ILogger } from "./ILogger"; -import { TransferFormat } from "./ITransport"; - -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +import { ILogger } from "./ILogger"; +import { TransferFormat } from "./ITransport"; + export const enum MessageType { Invocation = 1, StreamItem = 2, diff --git a/clients/ts/signalr/src/ITransport.ts b/clients/ts/signalr/src/ITransport.ts index 7868f7a436..84e52bc205 100644 --- a/clients/ts/signalr/src/ITransport.ts +++ b/clients/ts/signalr/src/ITransport.ts @@ -1,8 +1,6 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -import { IConnection } from "./IConnection"; - export enum HttpTransportType { WebSockets, ServerSentEvents, diff --git a/clients/ts/signalr/src/JsonHubProtocol.ts b/clients/ts/signalr/src/JsonHubProtocol.ts index dd3d86fb7f..261d7c290c 100644 --- a/clients/ts/signalr/src/JsonHubProtocol.ts +++ b/clients/ts/signalr/src/JsonHubProtocol.ts @@ -1,7 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -import { CloseMessage, CompletionMessage, HubMessage, IHubProtocol, InvocationMessage, MessageType, PingMessage, StreamItemMessage } from "./IHubProtocol"; +import { CompletionMessage, HubMessage, IHubProtocol, InvocationMessage, MessageType, StreamItemMessage } from "./IHubProtocol"; import { ILogger, LogLevel } from "./ILogger"; import { TransferFormat } from "./ITransport"; import { NullLogger } from "./Loggers";