import * as i0 from '@angular/core'; import { OnDestroy, InjectionToken, EnvironmentProviders } from '@angular/core'; import { Observable, SchedulerLike } from 'rxjs'; /** * Instance of this interface is used to report current connection status. */ interface ConnectionState { /** * "True" if browser has network connection. Determined by Window objects "online" / "offline" events. */ hasNetworkConnection: boolean; /** * "True" if browser has Internet access. Determined by heartbeat system which periodically makes request to heartbeat Url. */ hasInternetAccess: boolean; } /** * Instance of this interface could be used to configure "ConnectionService". */ interface ConnectionServiceOptions { /** * Controls the Internet connectivity heartbeat system. Default value is 'true'. */ enableHeartbeat?: boolean; /** * Url used for checking Internet connectivity, heartbeat system periodically makes "HEAD" requests to this URL to determine Internet * connection status. Default value is "//api.ipify.org/". */ heartbeatUrl?: string; /** * Callback function to used for executing heartbeat requests. Defaults to HttpClient.request(...) function. */ heartbeatExecutor?: (options?: ConnectionServiceOptions) => Observable; /** * Interval used to check Internet connectivity specified in milliseconds. Default value is "30000". */ heartbeatInterval?: number; /** * Interval used to retry Internet connectivity checks when an error is detected (when no Internet connection). Default value is "1000". */ heartbeatRetryInterval?: number; /** * HTTP method used for requesting heartbeat Url. Default is 'head'. */ requestMethod?: 'get' | 'post' | 'head' | 'options'; } /** * InjectionToken for specifing ConnectionService options. */ declare const ConnectionServiceOptionsToken: InjectionToken; /** * InjectionToken to override the RxJS `SchedulerLike` used internally for `timer()`/`debounceTime()` operations * (heartbeat polling, retry delay, and state-change debouncing). Not needed for normal application use — defaults * to RxJS's `asyncScheduler` when not provided. Primarily useful in unit tests, where providing a `TestScheduler` * (from `rxjs/testing`) allows advancing virtual time synchronously instead of waiting on real timers, without * requiring `zone.js`'s `fakeAsync`/`tick`. */ declare const ConnectionServiceSchedulerToken: InjectionToken; declare class ConnectionService implements OnDestroy { private static DEFAULT_OPTIONS; private stateChangeEventEmitter; private stateChangeEventSubscription; private currentState; /** * Reactive (Signal) representation of the current connection state. Prefer this over `monitor()` in modern * Angular applications that use signals for change detection. Updates whenever the network / internet status changes. */ private readonly stateSignal; /** * Read-only Signal exposing the current connection state. Equivalent (dual API) to subscribing to `monitor()`. */ readonly state: i0.Signal; private offlineSubscription; private onlineSubscription; private httpSubscription; private serviceOptions; private readonly windowRef; private readonly http; private readonly scheduler; /** * Current ConnectionService options. Notice that changing values of the returned object has not effect on service execution. * You should use "updateOptions" function. */ get options(): ConnectionServiceOptions; constructor(); private checkInternetState; private checkNetworkState; private emitEvent; ngOnDestroy(): void; /** * Monitor Network & Internet connection status by subscribing to this observer. If you set "reportCurrentState" to "false" then * function will not report current status of the connections when initially subscribed. * @param reportCurrentState Report current state when initial subscription. Default is "true" */ monitor(reportCurrentState?: boolean): Observable; /** * Update options of the service. You could specify partial options object. Values that are not specified will use default / previous * option values. * @param options Partial option values. */ updateOptions(options: Partial): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } /** * Registers `ConnectionService` and its dependencies (HttpClient) with the application's environment injector. * This is the recommended, standalone-friendly way to set up the library, replacing `ConnectionServiceModule`. * * @example * ```ts * export const appConfig: ApplicationConfig = { * providers: [ * provideConnectionService({ heartbeatUrl: '/assets/ping.json' }), * ], * }; * ``` * @param options Optional partial configuration for `ConnectionService`. */ declare function provideConnectionService(options?: ConnectionServiceOptions): EnvironmentProviders; /** * @deprecated Use `provideConnectionService()` instead. */ declare class ConnectionServiceModule { static ɵfac: i0.ɵɵFactoryDeclaration; static ɵmod: i0.ɵɵNgModuleDeclaration; static ɵinj: i0.ɵɵInjectorDeclaration; } export { ConnectionService, ConnectionServiceModule, ConnectionServiceOptionsToken, ConnectionServiceSchedulerToken, provideConnectionService }; export type { ConnectionServiceOptions, ConnectionState }; //# sourceMappingURL=ngx-connection-service.d.ts.map