1
1
import {
2
- backButton ,
3
- viewport ,
4
- themeParams ,
5
- miniApp ,
6
- initData ,
7
- $debug ,
8
- init as initSDK ,
9
- } from '@telegram-apps/sdk' ;
10
- import { mountMainButton } from " @/entities/main-button" ;
11
- import { mountBackButton } from " @/entities/back-button" ;
2
+ backButton ,
3
+ viewport ,
4
+ themeParams ,
5
+ miniApp ,
6
+ initData ,
7
+ $debug ,
8
+ init as initSDK ,
9
+ } from '@telegram-apps/sdk'
10
+ import { mountMainButton } from ' @/entities/main-button'
11
+ import { mountBackButton } from ' @/entities/back-button'
12
12
13
13
/**
14
14
* Initializes the application and configures its dependencies.
15
15
*/
16
16
export function init ( debug : boolean ) : void {
17
- // Set @telegram -apps/sdk-react debug mode.
18
- $debug . set ( debug ) ;
17
+ // Set @telegram -apps/sdk-react debug mode.
18
+ $debug . set ( debug )
19
19
20
- // Initialize special event handlers for Telegram Desktop, Android, iOS, etc.
21
- // Also, configure the package.
22
- initSDK ( ) ;
20
+ // Initialize special event handlers for Telegram Desktop, Android, iOS, etc.
21
+ // Also, configure the package.
22
+ initSDK ( )
23
23
24
- // Add Eruda if needed.
25
- debug && import ( 'eruda' )
26
- . then ( ( lib ) => lib . default . init ( ) )
27
- . catch ( console . error ) ;
24
+ // Add Eruda if needed.
25
+ debug &&
26
+ import ( 'eruda' ) . then ( ( lib ) => lib . default . init ( ) ) . catch ( console . error )
28
27
29
- // Check if all required components are supported.
30
- if ( ! backButton . isSupported ( ) || ! miniApp . isSupported ( ) ) {
31
- throw new Error ( 'ERR_NOT_SUPPORTED' ) ;
32
- }
28
+ // Check if all required components are supported.
29
+ if ( ! backButton . isSupported ( ) || ! miniApp . isSupported ( ) ) {
30
+ throw new Error ( 'ERR_NOT_SUPPORTED' )
31
+ }
33
32
34
- // Mount all components used in the project.
35
- mountMainButton ( )
36
- mountBackButton ( )
33
+ // Mount all components used in the project.
34
+ mountMainButton ( )
35
+ mountBackButton ( )
37
36
38
- miniApp . mount ( ) ;
39
- themeParams . mount ( ) ;
40
- initData . restore ( ) ;
41
- void viewport
42
- . mount ( )
43
- . catch ( e => {
44
- console . error ( 'Something went wrong mounting the viewport' , e ) ;
45
- } )
46
- . then ( ( ) => {
47
- viewport . bindCssVars ( ) ;
48
- } ) ;
37
+ miniApp . mount ( )
38
+ themeParams . mount ( )
39
+ initData . restore ( )
40
+ void viewport
41
+ . mount ( )
42
+ . catch ( ( e ) => {
43
+ console . error ( 'Something went wrong mounting the viewport' , e )
44
+ } )
45
+ . then ( ( ) => {
46
+ viewport . bindCssVars ( )
47
+ } )
49
48
50
- // Define components-related CSS variables.
51
- miniApp . bindCssVars ( ) ;
52
- themeParams . bindCssVars ( ) ;
53
- }
49
+ // Define components-related CSS variables.
50
+ miniApp . bindCssVars ( )
51
+ themeParams . bindCssVars ( )
52
+ }
0 commit comments