Update TS docs for docs.microsoft.com generation (#2605)

This commit is contained in:
BrennanConroy 2018-08-07 13:36:10 -07:00 committed by GitHub
parent 7d4df89025
commit fc8979aeca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 98 additions and 76 deletions

View File

@ -6,6 +6,7 @@
// it's a very new API right now.
// Not exported from index.
/** @private */
export class AbortController implements AbortSignal {
private isAborted: boolean = false;
public onabort: () => void;

View File

@ -9,7 +9,7 @@ export class HttpError extends Error {
/** The HTTP status code represented by this error. */
public statusCode: number;
/** Constructs a new instance of {@link HttpError}.
/** Constructs a new instance of {@link @aspnet/signalr.HttpError}.
*
* @param {string} errorMessage A descriptive error message.
* @param {number} statusCode The HTTP status code represented by this error.
@ -30,7 +30,7 @@ export class TimeoutError extends Error {
// tslint:disable-next-line:variable-name
private __proto__: Error;
/** Constructs a new instance of {@link TimeoutError}.
/** Constructs a new instance of {@link @aspnet/signalr.TimeoutError}.
*
* @param {string} errorMessage A descriptive error message.
*/

View File

@ -3,15 +3,18 @@
import { TextMessageFormat } from "./TextMessageFormat";
/** @private */
export interface HandshakeRequestMessage {
readonly protocol: string;
readonly version: number;
}
/** @private */
export interface HandshakeResponseMessage {
readonly error: string;
}
/** @private */
export class HandshakeProtocol {
// Handshake request is always JSON
public writeHandshakeRequest(handshakeRequest: HandshakeRequestMessage): string {

View File

@ -31,20 +31,20 @@ export interface HttpRequest {
/** Represents an HTTP response. */
export class HttpResponse {
/** Constructs a new instance of {@link HttpResponse} with the specified status code.
/** Constructs a new instance of {@link @aspnet/signalr.HttpResponse} with the specified status code.
*
* @param {number} statusCode The status code of the response.
*/
constructor(statusCode: number);
/** Constructs a new instance of {@link HttpResponse} with the specified status code and message.
/** Constructs a new instance of {@link @aspnet/signalr.HttpResponse} with the specified status code and message.
*
* @param {number} statusCode The status code of the response.
* @param {string} statusText The status message of the response.
*/
constructor(statusCode: number, statusText: string);
/** Constructs a new instance of {@link HttpResponse} with the specified status code, message and string content.
/** Constructs a new instance of {@link @aspnet/signalr.HttpResponse} with the specified status code, message and string content.
*
* @param {number} statusCode The status code of the response.
* @param {string} statusText The status message of the response.
@ -52,7 +52,7 @@ export class HttpResponse {
*/
constructor(statusCode: number, statusText: string, content: string);
/** Constructs a new instance of {@link HttpResponse} with the specified status code, message and binary content.
/** Constructs a new instance of {@link @aspnet/signalr.HttpResponse} with the specified status code, message and binary content.
*
* @param {number} statusCode The status code of the response.
* @param {string} statusText The status message of the response.
@ -71,18 +71,18 @@ export class HttpResponse {
* This class provides an abstraction over an HTTP client so that a different implementation can be provided on different platforms.
*/
export abstract class HttpClient {
/** Issues an HTTP GET request to the specified URL, returning a Promise that resolves with an {@link HttpResponse} representing the result.
/** Issues an HTTP GET request to the specified URL, returning a Promise that resolves with an {@link @aspnet/signalr.HttpResponse} representing the result.
*
* @param {string} url The URL for the request.
* @returns {Promise<HttpResponse>} A Promise that resolves with an {@link HttpResponse} describing the response, or rejects with an Error indicating a failure.
* @returns {Promise<HttpResponse>} A Promise that resolves with an {@link @aspnet/signalr.HttpResponse} describing the response, or rejects with an Error indicating a failure.
*/
public get(url: string): Promise<HttpResponse>;
/** Issues an HTTP GET request to the specified URL, returning a Promise that resolves with an {@link HttpResponse} representing the result.
/** Issues an HTTP GET request to the specified URL, returning a Promise that resolves with an {@link @aspnet/signalr.HttpResponse} representing the result.
*
* @param {string} url The URL for the request.
* @param {HttpRequest} options Additional options to configure the request. The 'url' field in this object will be overridden by the url parameter.
* @returns {Promise<HttpResponse>} A Promise that resolves with an {@link HttpResponse} describing the response, or rejects with an Error indicating a failure.
* @returns {Promise<HttpResponse>} A Promise that resolves with an {@link @aspnet/signalr.HttpResponse} describing the response, or rejects with an Error indicating a failure.
*/
public get(url: string, options: HttpRequest): Promise<HttpResponse>;
public get(url: string, options?: HttpRequest): Promise<HttpResponse> {
@ -93,18 +93,18 @@ export abstract class HttpClient {
});
}
/** Issues an HTTP POST request to the specified URL, returning a Promise that resolves with an {@link HttpResponse} representing the result.
/** Issues an HTTP POST request to the specified URL, returning a Promise that resolves with an {@link @aspnet/signalr.HttpResponse} representing the result.
*
* @param {string} url The URL for the request.
* @returns {Promise<HttpResponse>} A Promise that resolves with an {@link HttpResponse} describing the response, or rejects with an Error indicating a failure.
* @returns {Promise<HttpResponse>} A Promise that resolves with an {@link @aspnet/signalr.HttpResponse} describing the response, or rejects with an Error indicating a failure.
*/
public post(url: string): Promise<HttpResponse>;
/** Issues an HTTP POST request to the specified URL, returning a Promise that resolves with an {@link HttpResponse} representing the result.
/** Issues an HTTP POST request to the specified URL, returning a Promise that resolves with an {@link @aspnet/signalr.HttpResponse} representing the result.
*
* @param {string} url The URL for the request.
* @param {HttpRequest} options Additional options to configure the request. The 'url' field in this object will be overridden by the url parameter.
* @returns {Promise<HttpResponse>} A Promise that resolves with an {@link HttpResponse} describing the response, or rejects with an Error indicating a failure.
* @returns {Promise<HttpResponse>} A Promise that resolves with an {@link @aspnet/signalr.HttpResponse} describing the response, or rejects with an Error indicating a failure.
*/
public post(url: string, options: HttpRequest): Promise<HttpResponse>;
public post(url: string, options?: HttpRequest): Promise<HttpResponse> {
@ -115,18 +115,18 @@ export abstract class HttpClient {
});
}
/** Issues an HTTP DELETE request to the specified URL, returning a Promise that resolves with an {@link HttpResponse} representing the result.
/** Issues an HTTP DELETE request to the specified URL, returning a Promise that resolves with an {@link @aspnet/signalr.HttpResponse} representing the result.
*
* @param {string} url The URL for the request.
* @returns {Promise<HttpResponse>} A Promise that resolves with an {@link HttpResponse} describing the response, or rejects with an Error indicating a failure.
* @returns {Promise<HttpResponse>} A Promise that resolves with an {@link @aspnet/signalr.HttpResponse} describing the response, or rejects with an Error indicating a failure.
*/
public delete(url: string): Promise<HttpResponse>;
/** Issues an HTTP DELETE request to the specified URL, returning a Promise that resolves with an {@link HttpResponse} representing the result.
/** Issues an HTTP DELETE request to the specified URL, returning a Promise that resolves with an {@link @aspnet/signalr.HttpResponse} representing the result.
*
* @param {string} url The URL for the request.
* @param {HttpRequest} options Additional options to configure the request. The 'url' field in this object will be overridden by the url parameter.
* @returns {Promise<HttpResponse>} A Promise that resolves with an {@link HttpResponse} describing the response, or rejects with an Error indicating a failure.
* @returns {Promise<HttpResponse>} A Promise that resolves with an {@link @aspnet/signalr.HttpResponse} describing the response, or rejects with an Error indicating a failure.
*/
public delete(url: string, options: HttpRequest): Promise<HttpResponse>;
public delete(url: string, options?: HttpRequest): Promise<HttpResponse> {
@ -137,19 +137,19 @@ export abstract class HttpClient {
});
}
/** Issues an HTTP request to the specified URL, returning a {@link Promise} that resolves with an {@link HttpResponse} representing the result.
/** Issues an HTTP request to the specified URL, returning a {@link Promise} that resolves with an {@link @aspnet/signalr.HttpResponse} representing the result.
*
* @param {HttpRequest} request An {@link HttpRequest} describing the request to send.
* @param {HttpRequest} request An {@link @aspnet/signalr.HttpRequest} describing the request to send.
* @returns {Promise<HttpResponse>} A Promise that resolves with an HttpResponse describing the response, or rejects with an Error indicating a failure.
*/
public abstract send(request: HttpRequest): Promise<HttpResponse>;
}
/** Default implementation of {@link HttpClient}. */
/** Default implementation of {@link @aspnet/signalr.HttpClient}. */
export class DefaultHttpClient extends HttpClient {
private readonly logger: ILogger;
/** Creates a new instance of the {@link DefaultHttpClient}, using the provided {@link ILogger} to log messages. */
/** Creates a new instance of the {@link @aspnet/signalr.DefaultHttpClient}, using the provided {@link @aspnet/signalr.ILogger} to log messages. */
public constructor(logger: ILogger) {
super();
this.logger = logger;

View File

@ -11,12 +11,14 @@ import { ServerSentEventsTransport } from "./ServerSentEventsTransport";
import { Arg, createLogger } from "./Utils";
import { WebSocketTransport } from "./WebSocketTransport";
/** @private */
const enum ConnectionState {
Connecting,
Connected,
Disconnected,
}
/** @private */
export interface INegotiateResponse {
connectionId?: string;
availableTransports?: IAvailableTransport[];
@ -24,6 +26,7 @@ export interface INegotiateResponse {
accessToken?: string;
}
/** @private */
export interface IAvailableTransport {
transport: keyof typeof HttpTransportType;
transferFormats: Array<keyof typeof TransferFormat>;
@ -31,6 +34,7 @@ export interface IAvailableTransport {
const MAX_REDIRECTS = 100;
/** @private */
export class HttpConnection implements IConnection {
private connectionState: ConnectionState;
private baseUrl: string;

View File

@ -237,11 +237,11 @@ export class HubConnection {
/** Removes the specified handler for the specified hub method.
*
* You must pass the exact same Function instance as was previously passed to {@link on}. Passing a different instance (even if the function
* You must pass the exact same Function instance as was previously passed to {@link @aspnet/signalr.HubConnection.on}. Passing a different instance (even if the function
* body is the same) will not remove the handler.
*
* @param {string} methodName The name of the method to remove handlers for.
* @param {Function} method The handler to remove. This must be the same Function instance as the one passed to {@link on}.
* @param {Function} method The handler to remove. This must be the same Function instance as the one passed to {@link @aspnet/signalr.HubConnection.on}.
*/
public off(methodName: string, method: (...args: any[]) => void): void;
public off(methodName: string, method?: (...args: any[]) => void): void {

View File

@ -11,7 +11,7 @@ import { JsonHubProtocol } from "./JsonHubProtocol";
import { NullLogger } from "./Loggers";
import { Arg, ConsoleLogger } from "./Utils";
/** A builder for configuring {@link HubConnection} instances. */
/** A builder for configuring {@link @aspnet/signalr.HubConnection} instances. */
export class HubConnectionBuilder {
/** @internal */
public protocol: IHubProtocol;
@ -22,17 +22,17 @@ export class HubConnectionBuilder {
/** @internal */
public logger: ILogger;
/** Configures console logging for the {@link HubConnection}.
/** Configures console logging for the {@link @aspnet/signalr.HubConnection}.
*
* @param {LogLevel} logLevel The minimum level of messages to log. Anything at this level, or a more severe level, will be logged.
* @returns The {@link HubConnectionBuilder} instance, for chaining.
* @returns The {@link @aspnet/signalr.HubConnectionBuilder} instance, for chaining.
*/
public configureLogging(logLevel: LogLevel): HubConnectionBuilder;
/** Configures custom logging for the {@link HubConnection}.
/** Configures custom logging for the {@link @aspnet/signalr.HubConnection}.
*
* @param {ILogger} logger An object implementing the {@link ILogger} interface, which will be used to write all log messages.
* @returns The {@link HubConnectionBuilder} instance, for chaining.
* @param {ILogger} logger An object implementing the {@link @aspnet/signalr.ILogger} interface, which will be used to write all log messages.
* @returns The {@link @aspnet/signalr.HubConnectionBuilder} instance, for chaining.
*/
public configureLogging(logger: ILogger): HubConnectionBuilder;
public configureLogging(logging: LogLevel | ILogger): HubConnectionBuilder {
@ -47,28 +47,28 @@ export class HubConnectionBuilder {
return this;
}
/** Configures the {@link HubConnection} to use HTTP-based transports to connect to the specified URL.
/** Configures the {@link @aspnet/signalr.HubConnection} to use HTTP-based transports to connect to the specified URL.
*
* The transport will be selected automatically based on what the server and client support.
*
* @param {string} url The URL the connection will use.
* @returns The {@link HubConnectionBuilder} instance, for chaining.
* @returns The {@link @aspnet/signalr.HubConnectionBuilder} instance, for chaining.
*/
public withUrl(url: string): HubConnectionBuilder;
/** Configures the {@link HubConnection} to use the specified HTTP-based transport to connect to the specified URL.
/** Configures the {@link @aspnet/signalr.HubConnection} to use the specified HTTP-based transport to connect to the specified URL.
*
* @param {string} url The URL the connection will use.
* @param {HttpTransportType} transportType The specific transport to use.
* @returns The {@link HubConnectionBuilder} instance, for chaining.
* @returns The {@link @aspnet/signalr.HubConnectionBuilder} instance, for chaining.
*/
public withUrl(url: string, transportType: HttpTransportType): HubConnectionBuilder;
/** Configures the {@link HubConnection} to use HTTP-based transports to connect to the specified URL.
/** Configures the {@link @aspnet/signalr.HubConnection} to use HTTP-based transports to connect to the specified URL.
*
* @param {string} url The URL the connection will use.
* @param {IHttpConnectionOptions} options An options object used to configure the connection.
* @returns The {@link HubConnectionBuilder} instance, for chaining.
* @returns The {@link @aspnet/signalr.HubConnectionBuilder} instance, for chaining.
*/
public withUrl(url: string, options: IHttpConnectionOptions): HubConnectionBuilder;
public withUrl(url: string, transportTypeOrOptions?: IHttpConnectionOptions | HttpTransportType): HubConnectionBuilder {
@ -89,9 +89,9 @@ export class HubConnectionBuilder {
return this;
}
/** Configures the {@link HubConnection} to use the specified Hub Protocol.
/** Configures the {@link @aspnet/signalr.HubConnection} to use the specified Hub Protocol.
*
* @param {IHubProtocol} protocol The {@link IHubProtocol} implementation to use.
* @param {IHubProtocol} protocol The {@link @aspnet/signalr.IHubProtocol} implementation to use.
*/
public withHubProtocol(protocol: IHubProtocol): HubConnectionBuilder {
Arg.isRequired(protocol, "protocol");
@ -100,9 +100,9 @@ export class HubConnectionBuilder {
return this;
}
/** Creates a {@link HubConnection} from the configuration options specified in this builder.
/** Creates a {@link @aspnet/signalr.HubConnection} from the configuration options specified in this builder.
*
* @returns {HubConnection} The configured {@link HubConnection}.
* @returns {HubConnection} The configured {@link @aspnet/signalr.HubConnection}.
*/
public build(): HubConnection {
// If httpConnectionOptions has a logger, use it. Otherwise, override it with the one

View File

@ -3,6 +3,7 @@
import { TransferFormat } from "./ITransport";
/** @private */
export interface IConnection {
readonly features: any;

View File

@ -5,18 +5,18 @@ import { HttpClient } from "./HttpClient";
import { ILogger, LogLevel } from "./ILogger";
import { HttpTransportType, ITransport } from "./ITransport";
/** Options provided to the 'withUrl' method on {@link HubConnectionBuilder} to configure options for the HTTP-based transports. */
/** Options provided to the 'withUrl' method on {@link @aspnet/signalr.HubConnectionBuilder} to configure options for the HTTP-based transports. */
export interface IHttpConnectionOptions {
/** An {@link HttpClient} that will be used to make HTTP requests. */
/** An {@link @aspnet/signalr.HttpClient} that will be used to make HTTP requests. */
httpClient?: HttpClient;
/** An {@link HttpTransportType} value specifying the transport to use for the connection. */
/** An {@link @aspnet/signalr.HttpTransportType} value specifying the transport to use for the connection. */
transport?: HttpTransportType | ITransport;
/** Configures the logger used for logging.
*
* Provide an {@link ILogger} instance, and log messages will be logged via that instance. Alternatively, provide a value from
* the {@link LogLevel} enumeration and a default logger which logs to the Console will be configured to log messages of the specified
* Provide an {@link @aspnet/signalr.ILogger} instance, and log messages will be logged via that instance. Alternatively, provide a value from
* the {@link @aspnet/signalr.LogLevel} enumeration and a default logger which logs to the Console will be configured to log messages of the specified
* level (or higher).
*/
logger?: ILogger | LogLevel;
@ -35,7 +35,7 @@ export interface IHttpConnectionOptions {
/** A boolean indicating if negotiation should be skipped.
*
* Negotiation can only be skipped when the {@link transport} property is set to 'HttpTransportType.WebSockets'.
* Negotiation can only be skipped when the {@link @aspnet/signalr.IHttpConnectionOptions.transport} property is set to 'HttpTransportType.WebSockets'.
*/
skipNegotiation?: boolean;
}

View File

@ -6,19 +6,19 @@ import { TransferFormat } from "./ITransport";
/** Defines the type of a Hub Message. */
export enum MessageType {
/** Indicates the message is an Invocation message and implements the {@link InvocationMessage} interface. */
/** Indicates the message is an Invocation message and implements the {@link @aspnet/signalr.InvocationMessage} interface. */
Invocation = 1,
/** Indicates the message is a StreamItem message and implements the {@link StreamItemMessage} interface. */
/** Indicates the message is a StreamItem message and implements the {@link @aspnet/signalr.StreamItemMessage} interface. */
StreamItem = 2,
/** Indicates the message is a Completion message and implements the {@link CompletionMessage} interface. */
/** Indicates the message is a Completion message and implements the {@link @aspnet/signalr.CompletionMessage} interface. */
Completion = 3,
/** Indicates the message is a Stream Invocation message and implements the {@link StreamInvocationMessage} interface. */
/** Indicates the message is a Stream Invocation message and implements the {@link @aspnet/signalr.StreamInvocationMessage} interface. */
StreamInvocation = 4,
/** Indicates the message is a Cancel Invocation message and implements the {@link CancelInvocationMessage} interface. */
/** Indicates the message is a Cancel Invocation message and implements the {@link @aspnet/signalr.CancelInvocationMessage} interface. */
CancelInvocation = 5,
/** Indicates the message is a Ping message and implements the {@link PingMessage} interface. */
/** Indicates the message is a Ping message and implements the {@link @aspnet/signalr.PingMessage} interface. */
Ping = 6,
/** Indicates the message is a Close message and implements the {@link CloseMessage} interface. */
/** Indicates the message is a Close message and implements the {@link @aspnet/signalr.CloseMessage} interface. */
Close = 7,
}
@ -40,24 +40,25 @@ export type HubMessage =
/** Defines properties common to all Hub messages. */
export interface HubMessageBase {
/** A {@link MessageType} value indicating the type of this message. */
/** A {@link @aspnet/signalr.MessageType} value indicating the type of this message. */
readonly type: MessageType;
}
/** Defines properties common to all Hub messages relating to a specific invocation. */
export interface HubInvocationMessage extends HubMessageBase {
/** A {@link MessageHeaders} dictionary containing headers attached to the message. */
/** A {@link @aspnet/signalr.MessageHeaders} dictionary containing headers attached to the message. */
readonly headers?: MessageHeaders;
/** The ID of the invocation relating to this message.
*
* This is expected to be present for {@link StreamInvocationMessage} and {@link CompletionMessage}. It may
* be 'undefined' for an {@link InvocationMessage} if the sender does not expect a response.
* This is expected to be present for {@link @aspnet/signalr.StreamInvocationMessage} and {@link @aspnet/signalr.CompletionMessage}. It may
* be 'undefined' for an {@link @aspnet/signalr.InvocationMessage} if the sender does not expect a response.
*/
readonly invocationId?: string;
}
/** A hub message representing a non-streaming invocation. */
export interface InvocationMessage extends HubInvocationMessage {
/** @inheritDoc */
readonly type: MessageType.Invocation;
/** The target method name. */
readonly target: string;
@ -98,12 +99,12 @@ export interface CompletionMessage extends HubInvocationMessage {
readonly invocationId: string;
/** The error produced by the invocation, if any.
*
* Either {@link error} or {@link result} must be defined, but not both.
* Either {@link @aspnet/signalr.CompletionMessage.error} or {@link @aspnet/signalr.CompletionMessage.result} must be defined, but not both.
*/
readonly error?: string;
/** The result produced by the invocation, if any.
*
* Either {@link error} or {@link result} must be defined, but not both.
* Either {@link @aspnet/signalr.CompletionMessage.error} or {@link @aspnet/signalr.CompletionMessage.result} must be defined, but not both.
*/
readonly result?: any;
}
@ -116,7 +117,7 @@ export interface PingMessage extends HubMessageBase {
/** A hub message indicating that the sender is closing the connection.
*
* If {@link error} is defined, the sender is closing the connection due to an error.
* If {@link @aspnet/signalr.CloseMessage.error} is defined, the sender is closing the connection due to an error.
*/
export interface CloseMessage extends HubMessageBase {
/** @inheritDoc */
@ -142,21 +143,21 @@ export interface IHubProtocol {
readonly name: string;
/** The version of the protocol. */
readonly version: number;
/** The {@link TransferFormat} of the protocol. */
/** The {@link @aspnet/signalr.TransferFormat} of the protocol. */
readonly transferFormat: TransferFormat;
/** Creates an array of {@link HubMessage} objects from the specified serialized representation.
/** Creates an array of {@link @aspnet/signalr.HubMessage} objects from the specified serialized representation.
*
* If {@link transferFormat} is 'Text', the {@link input} parameter must be a string, otherwise it must be an ArrayBuffer.
* If {@link @aspnet/signalr.IHubProtocol.transferFormat} is 'Text', the `input` parameter must be a string, otherwise it must be an ArrayBuffer.
*
* @param {string | ArrayBuffer} input A string, or ArrayBuffer containing the serialized representation.
* @param {ILogger} logger A logger that will be used to log messages that occur during parsing.
*/
parseMessages(input: string | ArrayBuffer, logger: ILogger): HubMessage[];
/** Writes the specified {@link HubMessage} to a string or ArrayBuffer and returns it.
/** Writes the specified {@link @aspnet/signalr.HubMessage} to a string or ArrayBuffer and returns it.
*
* If {@link transferFormat} is 'Text', the result of this method will be a string, otherwise it will be an ArrayBuffer.
* If {@link @aspnet/signalr.IHubProtocol.transferFormat} is 'Text', the result of this method will be a string, otherwise it will be an ArrayBuffer.
*
* @param {HubMessage} message The message to write.
* @returns {string | ArrayBuffer} A string or ArrayBuffer containing the serialized representation of the message.

View File

@ -19,7 +19,7 @@ export enum TransferFormat {
/** Specifies that only text data will be transmitted over the connection. */
Text = 1,
/** Specifies that binary data will be transmitted over the connection. */
Binary,
Binary = 2,
}
/** An abstraction over the behavior of transports. This is designed to support the framework and not intended for use by applications. */

View File

@ -20,7 +20,7 @@ export class JsonHubProtocol implements IHubProtocol {
/** @inheritDoc */
public readonly transferFormat: TransferFormat = TransferFormat.Text;
/** Creates an array of {@link HubMessage} objects from the specified serialized representation.
/** Creates an array of {@link @aspnet/signalr.HubMessage} objects from the specified serialized representation.
*
* @param {string} input A string containing the serialized representation.
* @param {ILogger} logger A logger that will be used to log messages that occur during parsing.
@ -75,7 +75,7 @@ export class JsonHubProtocol implements IHubProtocol {
return hubMessages;
}
/** Writes the specified {@link HubMessage} to a string and returns it.
/** Writes the specified {@link @aspnet/signalr.HubMessage} to a string and returns it.
*
* @param {HubMessage} message The message to write.
* @returns {string} A string containing the serialized representation of the message.

View File

@ -5,7 +5,7 @@ import { ILogger, LogLevel } from "./ILogger";
/** A logger that does nothing when log messages are sent to it. */
export class NullLogger implements ILogger {
/** The singleton instance of the {@link NullLogger}. */
/** The singleton instance of the {@link @aspnet/signalr.NullLogger}. */
public static instance: ILogger = new NullLogger();
private constructor() {}

View File

@ -11,6 +11,7 @@ import { Arg, getDataDetail, sendMessage } from "./Utils";
const SHUTDOWN_TIMEOUT = 5 * 1000;
// Not exported from 'index', this type is internal.
/** @private */
export class LongPollingTransport implements ITransport {
private readonly httpClient: HttpClient;
private readonly accessTokenFactory: () => string | Promise<string>;

View File

@ -6,6 +6,7 @@ import { ILogger, LogLevel } from "./ILogger";
import { ITransport, TransferFormat } from "./ITransport";
import { Arg, getDataDetail, sendMessage } from "./Utils";
/** @private */
export class ServerSentEventsTransport implements ITransport {
private readonly httpClient: HttpClient;
private readonly accessTokenFactory: () => string | Promise<string>;

View File

@ -12,18 +12,18 @@
* @typeparam T The type of the items being sent by the server.
*/
export interface IStreamSubscriber<T> {
/** A boolean that will be set by the {@link IStreamResult} when the stream is closed. */
/** A boolean that will be set by the {@link @aspnet/signalr.IStreamResult} when the stream is closed. */
closed?: boolean;
/** Called by the framework when a new item is available. */
next(value: T): void;
/** Called by the framework when an error has occurred.
*
* After this method is called, no additional methods on the {@link IStreamSubscriber} will be called.
* After this method is called, no additional methods on the {@link @aspnet/signalr.IStreamSubscriber} will be called.
*/
error(err: any): void;
/** Called by the framework when the end of the stream is reached.
*
* After this method is called, no additional methods on the {@link IStreamSubscriber} will be called.
* After this method is called, no additional methods on the {@link @aspnet/signalr.IStreamSubscriber} will be called.
*/
complete(): void;
}
@ -33,19 +33,19 @@ export interface IStreamSubscriber<T> {
* @typeparam T The type of the items being sent by the server.
*/
export interface IStreamResult<T> {
/** Attaches a {@link IStreamSubscriber}, which will be invoked when new items are available from the stream.
/** Attaches a {@link @aspnet/signalr.IStreamSubscriber}, which will be invoked when new items are available from the stream.
*
* @param {IStreamSubscriber<T>} observer The subscriber to attach.
* @returns {ISubscription<T>} A subscription that can be disposed to terminate the stream and stop calling methods on the {@link IStreamSubscriber}.
* @returns {ISubscription<T>} A subscription that can be disposed to terminate the stream and stop calling methods on the {@link @aspnet/signalr.IStreamSubscriber}.
*/
subscribe(subscriber: IStreamSubscriber<T>): ISubscription<T>;
}
/** An interface that allows an {@link IStreamSubscriber} to be disconnected from a stream.
/** An interface that allows an {@link @aspnet/signalr.IStreamSubscriber} to be disconnected from a stream.
*
* @typeparam T The type of the items being sent by the server.
*/
export interface ISubscription<T> {
/** Disconnects the {@link IStreamSubscriber} associated with this subscription from the stream. */
/** Disconnects the {@link @aspnet/signalr.IStreamSubscriber} associated with this subscription from the stream. */
dispose(): void;
}

View File

@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Not exported from index
/** @private */
export class TextMessageFormat {
public static RecordSeparatorCode = 0x1e;
public static RecordSeparator = String.fromCharCode(TextMessageFormat.RecordSeparatorCode);

View File

@ -6,6 +6,7 @@ import { ILogger, LogLevel } from "./ILogger";
import { NullLogger } from "./Loggers";
import { IStreamResult, IStreamSubscriber, ISubscription } from "./Stream";
/** @private */
export class Arg {
public static isRequired(val: any, name: string): void {
if (val === null || val === undefined) {
@ -21,6 +22,7 @@ export class Arg {
}
}
/** @private */
export function getDataDetail(data: any, includeContent: boolean): string {
let length: string = null;
if (data instanceof ArrayBuffer) {
@ -37,6 +39,7 @@ export function getDataDetail(data: any, includeContent: boolean): string {
return length;
}
/** @private */
export function formatArrayBuffer(data: ArrayBuffer): string {
const view = new Uint8Array(data);
@ -51,6 +54,7 @@ export function formatArrayBuffer(data: ArrayBuffer): string {
return str.substr(0, str.length - 1);
}
/** @private */
export async function sendMessage(logger: ILogger, transportName: string, httpClient: HttpClient, url: string, accessTokenFactory: () => string | Promise<string>, content: string | ArrayBuffer, logMessageContent: boolean): Promise<void> {
let headers;
const token = await accessTokenFactory();
@ -70,6 +74,7 @@ export async function sendMessage(logger: ILogger, transportName: string, httpCl
logger.log(LogLevel.Trace, `(${transportName} transport) request complete. Response status: ${response.statusCode}.`);
}
/** @private */
export function createLogger(logger?: ILogger | LogLevel) {
if (logger === undefined) {
return new ConsoleLogger(LogLevel.Information);
@ -86,6 +91,7 @@ export function createLogger(logger?: ILogger | LogLevel) {
return new ConsoleLogger(logger as LogLevel);
}
/** @private */
export class Subject<T> implements IStreamResult<T> {
public observers: Array<IStreamSubscriber<T>>;
public cancelCallback: () => Promise<void>;
@ -123,6 +129,7 @@ export class Subject<T> implements IStreamResult<T> {
}
}
/** @private */
export class SubjectSubscription<T> implements ISubscription<T> {
private subject: Subject<T>;
private observer: IStreamSubscriber<T>;
@ -144,6 +151,7 @@ export class SubjectSubscription<T> implements ISubscription<T> {
}
}
/** @private */
export class ConsoleLogger implements ILogger {
private readonly minimumLogLevel: LogLevel;

View File

@ -5,6 +5,7 @@ import { ILogger, LogLevel } from "./ILogger";
import { ITransport, TransferFormat } from "./ITransport";
import { Arg, getDataDetail } from "./Utils";
/** @private */
export class WebSocketTransport implements ITransport {
private readonly logger: ILogger;
private readonly accessTokenFactory: () => string | Promise<string>;