import * as i0 from '@angular/core'; import { ApplicationRef, InjectionToken, ModuleWithProviders, EnvironmentProviders } from '@angular/core'; import { ManagerOptions, Socket } from 'socket.io-client'; import { Observable } from 'rxjs'; import { EventsMap, DefaultEventsMap, ReservedOrUserEventNames, ReservedOrUserListener, EventParams, EventNames } from '@socket.io/component-emitter'; export { DefaultEventsMap, EventNames, EventParams, EventsMap, ReservedOrUserEventNames, ReservedOrUserListener } from '@socket.io/component-emitter'; /** Config interface */ interface SocketIoConfig { url: string; /** * Options * References: * https://socket.io/docs/v4/client-options */ options?: Partial; } type IoSocket = Socket; type First = T extends [infer F, ...infer L] ? F : any; type Last = T extends [...infer H, infer L] ? L : any; type AllButLast = T extends [...infer H, infer L] ? H : any[]; type FirstArg = T extends (arg: infer Param) => infer Result ? Param : any; type DisconnectDescription = Error | { description: string; context?: unknown; }; interface SocketReservedEvents { connect: () => void; connect_error: (err: Error) => void; disconnect: (reason: Socket.DisconnectReason, description?: DisconnectDescription) => void; } type IgnoredWrapperEvents = 'receiveBuffer' | 'sendBuffer'; type WrappedSocketIface = { [K in Exclude]: IoSocket[K] extends (...args: any[]) => IoSocket ? (...args: Parameters) => Wrapper : IoSocket[K] extends IoSocket ? Wrapper : IoSocket[K]; }; declare class WrappedSocket implements WrappedSocketIface { private config; private appRef; private readonly subscribersCounter; private readonly eventObservables$; private readonly namespaces; readonly ioSocket: IoSocket; private readonly emptyConfig; constructor(config: SocketIoConfig, appRef: ApplicationRef); get auth(): Socket['auth']; set auth(value: Socket['auth']); /** readonly access to io manager */ get io(): Socket['io']; /** alias to connect */ get open(): WrappedSocket['connect']; /** alias to disconnect */ get close(): WrappedSocket['disconnect']; /** * Gets a WrappedSocket for the given namespace. * * @note if an existing socket exists for the given namespace, it will be reused. * * @param namespace the namespace to create a new socket based on the current config. * If empty or `/`, then the current instance is returned. * @returns a socket that is bound to the given namespace. If namespace is empty or `/`, * then `this` is returned, otherwise another instance is returned, creating * it if it's the first use of such namespace. */ of(namespace: string): WrappedSocket; on>(eventName: Ev, callback: ReservedOrUserListener): this; once>(eventName: Ev, callback: ReservedOrUserListener): this; connect(): this; disconnect(): this; emit, Ev extends EventNames = EventNames>(eventName: Ev, ...args: Ep): this; send(..._args: any[]): this; emitWithAck, Ev extends EventNames = EventNames>(eventName: Ev, ...args: AllButLast): Promise>>; removeListener>(eventName?: Ev, callback?: ReservedOrUserListener): this; removeAllListeners>(eventName?: Ev): this; fromEvent>, Ev extends ReservedOrUserEventNames = ReservedOrUserEventNames>(eventName: Ev): Observable; fromOneTimeEvent, Ev extends ReservedOrUserEventNames = ReservedOrUserEventNames>(eventName: Ev): Promise; listeners>(eventName: Ev): ReservedOrUserListener[]; hasListeners>(eventName: Ev): boolean; listenersAny(): ((...args: any[]) => void)[]; listenersAnyOutgoing(): ((...args: any[]) => void)[]; off>(eventName?: Ev, listener?: ReservedOrUserListener): this; offAny(callback?: (event: string, ...args: any[]) => void): this; offAnyOutgoing(callback?: (event: string, ...args: any[]) => void): this; onAny(callback: (event: string, ...args: any[]) => void): this; onAnyOutgoing(callback: (event: string, ...args: any[]) => void): this; prependAny(callback: (event: string, ...args: any[]) => void): this; prependAnyOutgoing(callback: (event: string | symbol, ...args: any[]) => void): this; timeout(value: number): this; get volatile(): this; get active(): Socket['active']; get connected(): Socket['connected']; get disconnected(): Socket['disconnected']; get recovered(): Socket['recovered']; get id(): Socket['id']; compress(value: boolean): this; } declare const SOCKET_CONFIG_TOKEN: InjectionToken; declare class SocketIoModule { static forRoot(config: SocketIoConfig): ModuleWithProviders; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵmod: i0.ɵɵNgModuleDeclaration; static ɵinj: i0.ɵɵInjectorDeclaration; } declare const provideSocketIo: (config: SocketIoConfig) => EnvironmentProviders; export { SOCKET_CONFIG_TOKEN, WrappedSocket as Socket, SocketIoModule, provideSocketIo }; export type { AllButLast, First, FirstArg, Last, SocketIoConfig };