/* eslint-disable no-console */ /* eslint-disable promise/prefer-await-to-then */ import { backButton, $debug as debugSDK, initData, init as initSDK, miniApp, } from '@telegram-apps/sdk-react'; /** * Initializes the application and configures its dependencies. */ export function init(debug: boolean): void { // Set @telegram-apps/sdk-react debug mode. if (debug) debugSDK.set(debug); // Initialize special event handlers for Telegram Desktop, Android, iOS, etc. // Also, configure the package. initSDK(); // Mount all components used in the project. if (backButton.isSupported()) backButton.mount(); miniApp.mount(); initData.restore(); // Add Eruda if needed. if (debug) import('eruda').then((library) => library.default.init()).catch(console.error); }