@ztimson/momentum
Version:
Client library for momentum
63 lines • 2.19 kB
TypeScript
import { Momentum } from './momentum';
import { PathEventEmitter } from './core';
export type Platform = 'windows' | 'android' | 'ios' | 'mac' | 'linux' | 'unknown';
/** Handle device settings */
export declare class Client extends PathEventEmitter {
protected momentum: Momentum;
private captcha;
private installTimeout;
private nativePwaPrompt?;
private pendingInstall;
private speed;
private updating;
get actorType(): 'unknown' | 'human' | 'bot';
get captchaScore(): number;
/** Check for updates */
readonly updateReady: Promise<boolean>;
/** Check if PWA can be installed */
get canInstall(): boolean;
/** Running inside a container */
get isApp(): boolean;
/** Running inside an electron app */
get isElectron(): boolean;
/** Headless client without access to DOM */
get isHeadless(): boolean;
/** Running inside an iframe */
get isIframe(): boolean;
/** Running on a mobile device */
get isMobile(): boolean;
private _isPwa?;
/** Running as a PWA */
get isPwa(): boolean;
private _platform?;
/** Get the current platform type */
get platform(): Platform;
get storage(): boolean;
constructor(momentum: Momentum);
/**
* Inject the client theme settings, meta tags & PWA prompt
* @param opts Injection options: reload - use cached settings or reload; pwa - disabled auto pwa prompt
* @return {Promise<void>} Resolves on completion
*/
inject(opts?: {
install?: boolean;
reload?: boolean;
}): Promise<{
[key: string]: any;
}>;
/**
* Get current network speed
* @param {boolean} format false = number (bytes-per-second), true = formated string
* @returns {Promise<number | string>}
*/
networkSpeed(format: true): Promise<string>;
networkSpeed(format?: false): Promise<number>;
/**
* Create an installation prompt popup
* @param platform Platform specific prompt, leave blank to auto-detect
*/
install(platform?: Platform): Promise<unknown>;
/** Update service worker & other tabs */
update(): void;
}
//# sourceMappingURL=client.d.ts.map