import { WsError } from './errors.js'; import { SubscriptionBuilder, Subscription } from './subscription.js'; import { ShortFormStream } from './short-form.js'; import type { SubscriptionType } from './types/enums.js'; import type { SubscriptionFilters, WsOptions } from './types/ws.js'; import type { ShortFormInterval, ShortFormOptions } from './types/short-form.js'; type SystemHandler = (arg: T) => void; export declare class PolyNodeWS { private readonly apiKey; private readonly wsUrl; private readonly options; private socket; private readonly subscriptions; private readonly pendingSubscriptions; private subCounter; private subscriberId; private reconnectAttempts; private reconnectTimer; private intentionalClose; private connected; private _onConnect; private _onDisconnect; private _onReconnect; private _onError; private _onHeartbeat; constructor(apiKey: string, wsUrl: string, options?: WsOptions); get isConnected(): boolean; onConnect(handler: SystemHandler): this; onDisconnect(handler: SystemHandler): this; onReconnect(handler: SystemHandler): this; onError(handler: SystemHandler): this; onHeartbeat(handler: SystemHandler): this; /** Start a subscription builder for the given type. */ subscribe(type: SubscriptionType): SubscriptionBuilder; /** * Subscribe to short-form crypto markets (5m, 15m, 1h) with auto-rotation. * * Discovers current window markets via Gamma API, subscribes for settlement * events, and automatically rotates to the next window at expiry. * * @example * ```ts * const stream = ws.shortForm('15m', { coins: ['btc', 'eth'] }); * stream.on('settlement', (e) => console.log(e)); * stream.on('rotation', (r) => console.log('New window:', r.markets.length, 'markets')); * ``` */ shortForm(interval: ShortFormInterval, options?: ShortFormOptions): ShortFormStream; /** @internal Send subscribe and wait for ack. */ _subscribe(type: SubscriptionType, filters: SubscriptionFilters): Promise; /** @internal Unsubscribe a specific subscription or all. */ _unsubscribe(subscriptionId?: string): void; /** Unsubscribe all subscriptions. */ unsubscribeAll(): void; /** Connect to the WebSocket server. Called automatically on first subscribe. */ connect(): Promise; /** Close the connection. Stops auto-reconnect. */ disconnect(): void; private _ensureConnected; private _connect; private _send; private _handleMessage; private _routeEvent; private _scheduleReconnect; private _resubscribeAll; } export {}; //# sourceMappingURL=ws.d.ts.map