@tma.js/sdk 0.12.7 → 0.12.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -19,7 +19,7 @@ type InitDataState = {
19
19
  };
20
20
 
21
21
  /**
22
- * Class which is responsible for displaying Web Apps init data.
22
+ * Class which is responsible for displaying Mini Apps init data.
23
23
  */
24
24
  export class InitData {
25
25
  private readonly state: State<InitDataState>;
@@ -63,18 +63,17 @@ export class InitData {
63
63
  }
64
64
 
65
65
  /**
66
- * Date after which a message can be sent via the answerWebAppQuery
67
- * method.
68
- * @see https://core.telegram.org/bots/api#answerwebappquery
66
+ * Date after which a message can be sent via the
67
+ * [answerWebAppQuery](https://core.telegram.org/bots/api#answerwebappquery) method.
69
68
  */
70
69
  get canSendAfter(): Date | null {
71
70
  return this.state.get('canSendAfter');
72
71
  }
73
72
 
74
73
  /**
75
- * An object containing data about the chat where the bot was
76
- * launched via the attachment menu. Returned for supergroups, channels and
77
- * group chats – only for Web Apps launched via the attachment menu.
74
+ * An object containing data about the chat where the bot was launched via the attachment
75
+ * menu. Returned for supergroups, channels and group chats – only for Mini Apps launched via
76
+ * the attachment menu.
78
77
  */
79
78
  get chat(): Chat | null {
80
79
  return this.state.get('chat');
@@ -88,8 +87,8 @@ export class InitData {
88
87
  }
89
88
 
90
89
  /**
91
- * A global identifier indicating the chat from which Mini App was
92
- * opened. Returned only for applications opened by direct link.
90
+ * A global identifier indicating the chat from which Mini App was opened. Returned only for
91
+ * applications opened by direct link.
93
92
  */
94
93
  get chatInstance(): ChatType | null {
95
94
  return this.state.get('chatInstance');
@@ -105,7 +104,7 @@ export class InitData {
105
104
  }
106
105
 
107
106
  /**
108
- * A unique identifier for the Web App session, required for sending
107
+ * A unique identifier for the Mini App session, required for sending
109
108
  * messages via the `answerWebAppQuery` method.
110
109
  * @see https://core.telegram.org/bots/api#answerwebappquery
111
110
  */
@@ -116,7 +115,7 @@ export class InitData {
116
115
  /**
117
116
  * An object containing data about the chat partner of the current
118
117
  * user in the chat where the bot was launched via the attachment menu.
119
- * Returned only for private chats and only for Web Apps launched
118
+ * Returned only for private chats and only for Mini Apps launched
120
119
  * via the attachment menu.
121
120
  */
122
121
  get receiver(): User | null {
@@ -125,7 +124,7 @@ export class InitData {
125
124
 
126
125
  /**
127
126
  * The value of the `startattach` parameter, passed via link. Only
128
- * returned for Web Apps when launched from the attachment menu via link.
127
+ * returned for Mini Apps when launched from the attachment menu via link.
129
128
  */
130
129
  get startParam(): string | null {
131
130
  return this.state.get('startParam');
@@ -9,7 +9,7 @@ import type { MainButtonEventListener, MainButtonEvents, MainButtonState } from
9
9
 
10
10
  /**
11
11
  * Controls the main button, which is displayed at the bottom
12
- * of the Web App in the Telegram interface.
12
+ * of the Mini App in the Telegram interface.
13
13
  */
14
14
  export class MainButton {
15
15
  private readonly ee = new EventEmitter<MainButtonEvents>();
@@ -175,8 +175,8 @@ export class MainButton {
175
175
  };
176
176
 
177
177
  /**
178
- * Shows the button. Note that opening the Web App from the attachment
179
- * menu hides the main button until the user interacts with the Web App
178
+ * Shows the button. Note that opening the Mini App from the attachment
179
+ * menu hides the main button until the user interacts with the Mini App
180
180
  * interface.
181
181
  *
182
182
  * Returns current button instance for chaining.
@@ -72,7 +72,7 @@ export class Viewport {
72
72
 
73
73
  /**
74
74
  * Returns initialized instance of Viewport which is synchronized with
75
- * its actual state in Web Apps.
75
+ * its actual state in Mini Apps.
76
76
  * @param options - method options.
77
77
  */
78
78
  static async synced(options: RequestOptions = {}): Promise<Viewport> {
@@ -104,12 +104,12 @@ export class Viewport {
104
104
  }
105
105
 
106
106
  /**
107
- * The current height of the visible area of the Web App.
107
+ * The current height of the visible area of the Mini App.
108
108
  *
109
- * The application can display just the top part of the Web App, with its
109
+ * The application can display just the top part of the Mini App, with its
110
110
  * lower part remaining outside the screen area. From this position, the
111
- * user can "pull" the Web App to its maximum height, while the bot can do
112
- * the same by calling `expand` method. As the position of the Web App
111
+ * user can "pull" the Mini App to its maximum height, while the bot can do
112
+ * the same by calling `expand` method. As the position of the Mini App
113
113
  * changes, the current height value of the visible area will be updated
114
114
  * in real time.
115
115
  *
@@ -128,18 +128,18 @@ export class Viewport {
128
128
  }
129
129
 
130
130
  /**
131
- * The height of the visible area of the Web App in its last stable state.
131
+ * The height of the visible area of the Mini App in its last stable state.
132
132
  *
133
- * The application can display just the top part of the Web App, with its
133
+ * The application can display just the top part of the Mini App, with its
134
134
  * lower part remaining outside the screen area. From this position,
135
- * the user can "pull" the Web App to its maximum height, while the bot can
135
+ * the user can "pull" the Mini App to its maximum height, while the bot can
136
136
  * do the same by calling `expand` method.
137
137
  *
138
138
  * Unlike the value of `height`, the value of `stableHeight`
139
- * does not change as the position of the Web App changes with user
139
+ * does not change as the position of the Mini App changes with user
140
140
  * gestures or during animations. The value of `stableHeight`
141
141
  * will be updated after all gestures and animations are completed and
142
- * the Web App reaches its final size.
142
+ * the Mini App reaches its final size.
143
143
  *
144
144
  * @see init
145
145
  * @see expand
@@ -150,8 +150,8 @@ export class Viewport {
150
150
  }
151
151
 
152
152
  /**
153
- * Returns true if the Web App is expanded to the maximum available height.
154
- * Otherwise, if the Web App occupies part of the screen and can be expanded
153
+ * Returns true if the Mini App is expanded to the maximum available height.
154
+ * Otherwise, if the Mini App occupies part of the screen and can be expanded
155
155
  * to the full height using `expand` method.
156
156
  * @see expand
157
157
  */
@@ -167,8 +167,8 @@ export class Viewport {
167
167
  }
168
168
 
169
169
  /**
170
- * A method that expands the Web App to the maximum available height. To
171
- * find out if the Web App is expanded to the maximum height, refer to the
170
+ * A method that expands the Mini App to the maximum available height. To
171
+ * find out if the Mini App is expanded to the maximum height, refer to the
172
172
  * value of the `isExpanded`.
173
173
  * @see isExpanded
174
174
  */
@@ -20,7 +20,7 @@ import type { ColorScheme } from '../../types.js';
20
20
  import type { WebAppEvents, WebAppHeaderColor, WebAppState } from './types.js';
21
21
 
22
22
  /**
23
- * Provides common Web Apps functionality not covered by other system
23
+ * Provides common Mini Apps functionality not covered by other system
24
24
  * components.
25
25
  */
26
26
  export class WebApp {
@@ -70,7 +70,7 @@ export class WebApp {
70
70
  }
71
71
 
72
72
  /**
73
- * Closes the Web App.
73
+ * Closes the Mini App.
74
74
  */
75
75
  close(): void {
76
76
  this.postEvent('web_app_close');
@@ -85,7 +85,7 @@ export class WebApp {
85
85
 
86
86
  /**
87
87
  * Returns true if passed version is more than or equal to current
88
- * Web App version.
88
+ * Mini App version.
89
89
  * @param version - compared version.
90
90
  */
91
91
  isVersionAtLeast(version: Version): boolean {
@@ -93,10 +93,10 @@ export class WebApp {
93
93
  }
94
94
 
95
95
  /**
96
- * Opens a link in an external browser. The Web App will not be closed.
96
+ * Opens a link in an external browser. The Mini App will not be closed.
97
97
  *
98
98
  * Note that this method can be called only in response to the user
99
- * interaction with the Web App interface (e.g. click inside the Web App
99
+ * interaction with the Mini App interface (e.g. click inside the Mini App
100
100
  * or on the main button).
101
101
  * @param url - URL to be opened.
102
102
  * @param tryInstantView
@@ -118,7 +118,7 @@ export class WebApp {
118
118
  }
119
119
 
120
120
  /**
121
- * Opens a Telegram link inside Telegram app. The Web App will be closed.
121
+ * Opens a Telegram link inside Telegram app. The Mini App will be closed.
122
122
  * It expects passing link in full format, with hostname "t.me".
123
123
  * @param url - URL to be opened.
124
124
  * @throws {Error} URL has not allowed hostname.
@@ -179,18 +179,18 @@ export class WebApp {
179
179
  off = this.ee.off.bind(this.ee);
180
180
 
181
181
  /**
182
- * Returns current Web App platform.
182
+ * Returns current Mini App platform.
183
183
  */
184
184
  get platform(): Platform {
185
185
  return this.currentPlatform;
186
186
  }
187
187
 
188
188
  /**
189
- * Informs the Telegram app that the Web App is ready to be displayed.
189
+ * Informs the Telegram app that the Mini App is ready to be displayed.
190
190
  *
191
191
  * It is recommended to call this method as early as possible, as soon as
192
192
  * all essential interface elements loaded. Once this method called,
193
- * the loading placeholder is hidden and the Web App shown.
193
+ * the loading placeholder is hidden and the Mini App shown.
194
194
  *
195
195
  * If the method not called, the placeholder will be hidden only when
196
196
  * the page fully loaded.
@@ -242,10 +242,10 @@ export class WebApp {
242
242
  /**
243
243
  * A method used to send data to the bot. When this method called, a
244
244
  * service message sent to the bot containing the data of the
245
- * length up to 4096 bytes, and the Web App closed. See the field
245
+ * length up to 4096 bytes, and the Mini App closed. See the field
246
246
  * `web_app_data` in the class Message.
247
247
  *
248
- * This method is only available for Web Apps launched via a Keyboard button.
248
+ * This method is only available for Mini Apps launched via a Keyboard button.
249
249
  * @param data - data to send to bot.
250
250
  * @throws {Error} data has incorrect size.
251
251
  */
@@ -302,7 +302,7 @@ export class WebApp {
302
302
  supportsParam: SupportsFunc<'setHeaderColor.color' | 'openLink.tryInstantView'>;
303
303
 
304
304
  /**
305
- * Current Web App version. This property is used by other components to check if
305
+ * Current Mini App version. This property is used by other components to check if
306
306
  * some functionality is available on current device.
307
307
  */
308
308
  get version(): Version {
package/src/env.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { retrieveLaunchParams } from './launch-params.js';
2
2
 
3
3
  /**
4
- * Returns true in case, current environment is Telegram Web Apps.
4
+ * Returns true in case, current environment is Telegram Mini Apps.
5
5
  *
6
6
  * `isTWA` utilizes such function as `retrieveLaunchParams`, which attempts to retrieve
7
7
  * launch parameters from the current environment.
@@ -3,7 +3,7 @@
3
3
  */
4
4
  export class MethodNotSupportedError extends Error {
5
5
  constructor(method: string, version: string) {
6
- super(`Method "${method}" is not supported in the Web Apps version ${version}.`);
6
+ super(`Method "${method}" is not supported in the Mini Apps version ${version}.`);
7
7
  Object.setPrototypeOf(this, MethodNotSupportedError.prototype);
8
8
  }
9
9
  }
@@ -3,7 +3,7 @@
3
3
  */
4
4
  export class ParameterUnsupportedError extends Error {
5
5
  constructor(method: string, param: string, version: string) {
6
- super(`Parameter "${param}" in method "${method}" is not supported in the Web Apps version ${version}.`);
6
+ super(`Parameter "${param}" in method "${method}" is not supported in the Mini Apps version ${version}.`);
7
7
  Object.setPrototypeOf(this, ParameterUnsupportedError.prototype);
8
8
  }
9
9
  }
@@ -9,7 +9,7 @@ import { getStorageValue, saveStorageValue } from '../../storage.js';
9
9
  * Creates Viewport instance using last locally saved data also saving each state in
10
10
  * the storage.
11
11
  * @param isPageReload - was current page reloaded.
12
- * @param platform - Telegram Web Apps platform name.
12
+ * @param platform - Telegram Mini Apps platform name.
13
13
  * @param postEvent - Bridge postEvent function
14
14
  */
15
15
  export async function createViewport(
@@ -14,7 +14,7 @@ import type { CreateRequestIdFunc } from '../../types.js';
14
14
  * @param isPageReload - was current page reloaded.
15
15
  * @param backgroundColor - web app background color.
16
16
  * @param version - platform version.
17
- * @param platform - Telegram Web Apps platform name.
17
+ * @param platform - Telegram Mini Apps platform name.
18
18
  * @param createRequestId - function which generates request identifiers.
19
19
  * @param postEvent - Bridge postEvent function
20
20
  */
package/src/init/css.ts CHANGED
@@ -58,7 +58,7 @@ function createThemeVariables(themeParams: ThemeParams): void {
58
58
  }
59
59
 
60
60
  /**
61
- * Creates CSS variables based on Web App background and header colors with
61
+ * Creates CSS variables based on Mini App background and header colors with
62
62
  * theme parameters.
63
63
  * @param webApp - WebApp instance.
64
64
  * @param themeParams - theme parameters.
package/src/init/init.ts CHANGED
@@ -93,7 +93,7 @@ async function actualInit(options: InitOptions = {}): Promise<InitResult> {
93
93
  setTargetOrigin(targetOrigin);
94
94
  }
95
95
 
96
- // Get Web App launch params and save them to session storage, so they will be accessible from
96
+ // Get Mini App launch params and save them to session storage, so they will be accessible from
97
97
  // anywhere.
98
98
  const launchParamsFromStorage = retrieveFromStorage();
99
99
  const launchParams = optionsLaunchParams instanceof URLSearchParams || typeof optionsLaunchParams === 'string'
package/src/init/types.ts CHANGED
@@ -83,7 +83,7 @@ export interface InitOptions {
83
83
 
84
84
  /**
85
85
  * Should SDK throw an error in case, unsupported by current version of
86
- * Web App method was called. It is highly recommended not to disable this
86
+ * Mini App method was called. It is highly recommended not to disable this
87
87
  * feature as long as it helps developer to find issues related to usage
88
88
  * of unsupported methods.
89
89
  *