@telegram-apps/sdk
Version:
TypeScript Source Development Kit for Telegram Mini Apps client application.
62 lines (61 loc) • 2.86 kB
TypeScript
import { AbortablePromise } from 'better-promises';
import { ShowOptions } from './types.js';
/**
* Signal indicating if popups are supported.
*/
export declare const isSupported: import('@telegram-apps/signals').Computed<boolean>;
/**
* @deprecated Deprecated for consistence naming, to be removed in the next major update. Use
* `show` instead.
*/
export declare const open: import('../../wrappers/wrapSafe.js').SafeWrapped<(options: ShowOptions) => AbortablePromise<string | null>, true, never>;
/**
* @deprecated Deprecated for consistence naming, to be removed in the next major update. Use
* `showPromise` instead.
*/
declare const openPromise: import('@telegram-apps/signals').Computed<AbortablePromise<string | null> | undefined>;
/**
* @deprecated Deprecated for consistence naming, to be removed in the next major update. Use
* `isShown` instead.
*/
declare const isOpened: import('@telegram-apps/signals').Computed<boolean>;
/**
* @deprecated Deprecated for consistence naming, to be removed in the next major update. Use
* `showError` instead.
*/
declare const openError: import('@telegram-apps/signals').Computed<Error | undefined>;
export { openPromise, isOpened, openError };
/**
* A method that shows a native popup described by the `params` argument.
* The promise will be resolved when the popup is closed. Resolved value will have
* an identifier of the pressed button.
*
* If a user clicked outside the popup or clicked the top right popup close
* button, null will be resolved.
*
* @param options - popup parameters.
* @since Mini Apps v6.2
* @throws {InvalidArgumentsError} Invalid title
* @throws {InvalidArgumentsError} Invalid message
* @throws {InvalidArgumentsError} Invalid buttons count
* @throws {InvalidArgumentsError} Invalid button id length
* @throws {InvalidArgumentsError} Invalid button text length
* @throws {ConcurrentCallError} A popup is already opened
* @throws {FunctionNotAvailableError} The environment is unknown
* @throws {FunctionNotAvailableError} The SDK is not initialized
* @throws {FunctionNotAvailableError} The function is not supported
* @example
* if (open.isAvailable()) {
* const buttonId = await open({
* title: 'Confirm action',
* message: 'Do you really want to buy this burger?',
* buttons: [
* { id: 'yes', text: 'Yes' },
* { id: 'no', type: 'destructive', text: 'No' },
* ],
* });
* }
*/
export declare const show: import('../../wrappers/wrapSafe.js').SafeWrapped<(options: ShowOptions) => AbortablePromise<string | null>, true, never>;
export declare const showPromise: import('@telegram-apps/signals').Computed<AbortablePromise<string | null> | undefined>, isShown: import('@telegram-apps/signals').Computed<boolean>;
export declare const showError: import('@telegram-apps/signals').Computed<Error | undefined>;