diff --git a/.changeset/itchy-moles-repair.md b/.changeset/itchy-moles-repair.md deleted file mode 100644 index 02abfee53..000000000 --- a/.changeset/itchy-moles-repair.md +++ /dev/null @@ -1,52 +0,0 @@ ---- -"@telegram-apps/sdk": minor ---- - -We realized that many developers might be using the SDK without knowing that some functionality they're using may not work. This is due to the non-strict `postEvent` function in the `init` function: - -```ts -import { init } from "@telegram-apps/sdk"; - -init({ - postEvent: "non-strict", -}); -``` - -Using the non-strict `postEvent` can lead to bugs that developers are unaware of. For example: - -```ts -backButton.onClick(() => { - // User clicked the button, navigate to a new page. - navigate("market"); -}); - -backButton.show(); -``` - -In this case, if the `show` method is unsupported, and the `postEvent` function is non-strict (not throwing an error, only using `console.warn`), the user could get stuck on the current screen without any indication to the developer. - -To prevent such scenarios, we now disallow non-strict `postEvent`. Only a custom `postEvent` function can be passed. This way, you can bypass the protection mechanism, but you'll be fully aware of the risks. This function can also be used to decorate the original `postEvent` from the SDK. - -Since we no longer allow non-strict actions, most component and utility methods now include the `isSupported` property. For example: - -```ts -import { backButton } from "@telegram-apps/sdk"; - -if (backButton.mount.isSupported()) { - backButton.mount(); - backButton.show(); -} -``` - -Calling the `mount` method without checking if it's supported may throw an error if the method is unsupported in the current Mini App version. - -Additionally, if a component has the `mount` method, many of its other methods now check if the component was mounted. If it wasn't, an error will be thrown. This behavior ensures that you are working with components within their intended lifecycle. - -For example, the following code will throw an error: - -```ts -import { backButton } from "@telegram-apps/sdk"; - -backButton.show(); -// TypedError('ERR_NOT_MOUNTED') will be thrown -``` diff --git a/.changeset/seven-poems-pretend.md b/.changeset/seven-poems-pretend.md deleted file mode 100644 index 8069fcf5a..000000000 --- a/.changeset/seven-poems-pretend.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@telegram-apps/bridge": minor ---- - -"Add web_app_share_to_story" to `supports` checks. diff --git a/packages/bridge/CHANGELOG.md b/packages/bridge/CHANGELOG.md index 6f23d7ec2..30f2a3b21 100644 --- a/packages/bridge/CHANGELOG.md +++ b/packages/bridge/CHANGELOG.md @@ -1,5 +1,11 @@ # @telegram-apps/bridge +## 1.3.0 + +### Minor Changes + +- 5346f76: "Add web_app_share_to_story" to `supports` checks. + ## 1.2.1 ### Patch Changes diff --git a/packages/bridge/package.json b/packages/bridge/package.json index 27b6f0d86..ba1c65231 100644 --- a/packages/bridge/package.json +++ b/packages/bridge/package.json @@ -1,6 +1,6 @@ { "name": "@telegram-apps/bridge", - "version": "1.2.1", + "version": "1.3.0", "description": "TypeScript package to provide communication layer between Mini App and Telegram application.", "author": "Vladislav Kibenko ", "homepage": "https://github.com/Telegram-Mini-Apps/telegram-apps#readme", diff --git a/packages/navigation/CHANGELOG.md b/packages/navigation/CHANGELOG.md index ccffc843a..1563e53a3 100644 --- a/packages/navigation/CHANGELOG.md +++ b/packages/navigation/CHANGELOG.md @@ -1,5 +1,12 @@ # @telegram-apps/navigation +## 1.0.4 + +### Patch Changes + +- Updated dependencies [5346f76] + - @telegram-apps/bridge@1.3.0 + ## 1.0.3 ### Patch Changes diff --git a/packages/navigation/package.json b/packages/navigation/package.json index c868b2aae..f190d8322 100644 --- a/packages/navigation/package.json +++ b/packages/navigation/package.json @@ -1,6 +1,6 @@ { "name": "@telegram-apps/navigation", - "version": "1.0.3", + "version": "1.0.4", "description": "Navigation functionality for Telegram Mini Apps.", "author": "Vladislav Kibenko ", "homepage": "https://github.com/Telegram-Mini-Apps/telegram-apps#readme", diff --git a/packages/sdk-react/CHANGELOG.md b/packages/sdk-react/CHANGELOG.md index 4af756c60..e85de936f 100644 --- a/packages/sdk-react/CHANGELOG.md +++ b/packages/sdk-react/CHANGELOG.md @@ -1,5 +1,12 @@ # @telegram-apps/sdk-react +## 2.0.7 + +### Patch Changes + +- Updated dependencies [34b2595] + - @telegram-apps/sdk@2.5.0 + ## 2.0.6 ### Patch Changes diff --git a/packages/sdk-react/package.json b/packages/sdk-react/package.json index 1dfa3bb0e..8c20e4356 100644 --- a/packages/sdk-react/package.json +++ b/packages/sdk-react/package.json @@ -1,6 +1,6 @@ { "name": "@telegram-apps/sdk-react", - "version": "2.0.6", + "version": "2.0.7", "description": "React bindings for Mini Apps client SDK. Contains hooks, components and other useful tools which allow usage of React along with Mini Apps client SDK.", "author": "Vladislav Kibenko ", "homepage": "https://github.com/Telegram-Mini-Apps/telegram-apps#readme", diff --git a/packages/sdk-solid/CHANGELOG.md b/packages/sdk-solid/CHANGELOG.md index 1aedf2700..b38228418 100644 --- a/packages/sdk-solid/CHANGELOG.md +++ b/packages/sdk-solid/CHANGELOG.md @@ -1,5 +1,12 @@ # @telegram-apps/sdk-solid +## 2.0.7 + +### Patch Changes + +- Updated dependencies [34b2595] + - @telegram-apps/sdk@2.5.0 + ## 2.0.6 ### Patch Changes diff --git a/packages/sdk-solid/package.json b/packages/sdk-solid/package.json index 2b8eab48a..b816a5e57 100644 --- a/packages/sdk-solid/package.json +++ b/packages/sdk-solid/package.json @@ -1,6 +1,6 @@ { "name": "@telegram-apps/sdk-solid", - "version": "2.0.6", + "version": "2.0.7", "description": "Solid JS bindings for Mini Apps client SDK.", "author": "Vladislav Kibenko ", "homepage": "https://github.com/Telegram-Mini-Apps/telegram-apps#readme", diff --git a/packages/sdk/CHANGELOG.md b/packages/sdk/CHANGELOG.md index 77bd59d33..18a2872ec 100644 --- a/packages/sdk/CHANGELOG.md +++ b/packages/sdk/CHANGELOG.md @@ -1,5 +1,64 @@ # @telegram-apps/sdk +## 2.5.0 + +### Minor Changes + +- 34b2595: We realized that many developers might be using the SDK without knowing that some functionality they're using may not work. This is due to the non-strict `postEvent` function in the `init` function: + + ```ts + import { init } from "@telegram-apps/sdk"; + + init({ + postEvent: "non-strict", + }); + ``` + + Using the non-strict `postEvent` can lead to bugs that developers are unaware of. For example: + + ```ts + backButton.onClick(() => { + // User clicked the button, navigate to a new page. + navigate("market"); + }); + + backButton.show(); + ``` + + In this case, if the `show` method is unsupported, and the `postEvent` function is non-strict (not throwing an error, only using `console.warn`), the user could get stuck on the current screen without any indication to the developer. + + To prevent such scenarios, we now disallow non-strict `postEvent`. Only a custom `postEvent` function can be passed. This way, you can bypass the protection mechanism, but you'll be fully aware of the risks. This function can also be used to decorate the original `postEvent` from the SDK. + + Since we no longer allow non-strict actions, most component and utility methods now include the `isSupported` property. For example: + + ```ts + import { backButton } from "@telegram-apps/sdk"; + + if (backButton.mount.isSupported()) { + backButton.mount(); + backButton.show(); + } + ``` + + Calling the `mount` method without checking if it's supported may throw an error if the method is unsupported in the current Mini App version. + + Additionally, if a component has the `mount` method, many of its other methods now check if the component was mounted. If it wasn't, an error will be thrown. This behavior ensures that you are working with components within their intended lifecycle. + + For example, the following code will throw an error: + + ```ts + import { backButton } from "@telegram-apps/sdk"; + + backButton.show(); + // TypedError('ERR_NOT_MOUNTED') will be thrown + ``` + +### Patch Changes + +- Updated dependencies [5346f76] + - @telegram-apps/bridge@1.3.0 + - @telegram-apps/navigation@1.0.4 + ## 2.4.1 ### Patch Changes diff --git a/packages/sdk/package.json b/packages/sdk/package.json index a5be84c35..30f324a18 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -1,6 +1,6 @@ { "name": "@telegram-apps/sdk", - "version": "2.4.1", + "version": "2.5.0", "description": "TypeScript Source Development Kit for Telegram Mini Apps client application.", "author": "Vladislav Kibenko ", "homepage": "https://github.com/Telegram-Mini-Apps/telegram-apps#readme",