@telegram-apps/sdk
Version:
TypeScript Source Development Kit for Telegram Mini Apps client application.
73 lines (72 loc) • 3.17 kB
TypeScript
import { AbortablePromise } from 'better-promises';
import { RequestOptionsNoCapture } from '../../../types.js';
import { GetCssVarNameFn } from './types.js';
/**
* Creates CSS variables connected with the current theme parameters.
*
* By default, created CSS variables names are following the pattern "--tg-theme-{name}", where
* {name} is a theme parameters key name converted from snake case to kebab case.
*
* Default variables:
* - `--tg-theme-bg-color`
* - `--tg-theme-secondary-text-color`
*
* Variables are being automatically updated if theme parameters were changed.
*
* @param getCSSVarName - function, returning complete CSS variable name for the specified
* theme parameters key.
* @returns Function to stop updating variables.
* @throws {FunctionNotAvailableError} The environment is unknown
* @throws {FunctionNotAvailableError} The SDK is not initialized
* @throws {CSSVarsBoundError} CSS variables are already bound
* @throws {FunctionNotAvailableError} The parent component is not mounted
* @example Using no arguments
* if (bindCssVars.isAvailable()) {
* bindCssVars();
* }
* @example Using custom CSS vars generator
* if (bindCssVars.isAvailable()) {
* bindCssVars(key => `--my-prefix-${key}`);
* }
*/
export declare const bindCssVars: import('../../wrappers/wrapSafe.js').SafeWrapped<(getCSSVarName?: GetCssVarNameFn) => VoidFunction, false, never>;
/**
* Mounts the Theme Params component restoring its state.
* @throws {FunctionNotAvailableError} The environment is unknown
* @throws {FunctionNotAvailableError} The SDK is not initialized
* @throws {FunctionNotAvailableError} The function is not supported
* @deprecated Use `mountSync`.
* @example
* if (mount.isAvailable()) {
* await mount();
* }
*/
export declare const mount: import('../../wrappers/wrapSafe.js').SafeWrapped<(_options?: RequestOptionsNoCapture | undefined) => AbortablePromise<void>, false, never>;
/**
* @deprecated The initialization is synchronous. Use `mountSync`.
*/
export declare const isMounting: import('@telegram-apps/signals').Computed<boolean>;
/**
* @deprecated The initialization is synchronous. Use `mountSync`.
*/
export declare const mountPromise: import('@telegram-apps/signals').Computed<AbortablePromise<Partial<Record<string, `#${string}`>>> | undefined>;
/**
* @deprecated The initialization is synchronous. Use `mountSync`.
*/
export declare const mountError: import('@telegram-apps/signals').Computed<Error | undefined>;
export declare const _isMounted: import('@telegram-apps/signals').Signal<boolean>, isMounted: import('@telegram-apps/signals').Computed<boolean>;
/**
* Mounts the Theme Params component restoring its state.
* @throws {FunctionNotAvailableError} The environment is unknown
* @throws {FunctionNotAvailableError} The SDK is not initialized
* @throws {FunctionNotAvailableError} The function is not supported
* @example
* if (mountSync.isAvailable()) {
* mountSync();
* }
*/
export declare const mountSync: import('../../wrappers/wrapSafe.js').SafeWrapped<() => void, false, never>;
/**
* Unmounts the Theme Params component.
*/
export declare function unmount(): void;