@apiteam/twa-bridge 0.0.2-beta.3 → 0.0.2-beta.4

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.
package/README.md ADDED
@@ -0,0 +1,42 @@
1
+ ## SDK
2
+ [![npm version](https://img.shields.io/npm/v/@apiteam/twa-bridge)](https://www.npmjs.com/package/@apiteam/twa-bridge)
3
+
4
+ npm package for [Telegram Web Apps (TWA)](https://core.telegram.org/bots/webapps) SDK.
5
+
6
+ ```
7
+ npm i @apiteam/twa-bridge
8
+ ```
9
+
10
+ ### Motivation
11
+ Telegram distributes SDK via [link](https://core.telegram.org/bots/webapps#initializing-web-apps). It's kinda old fashion way to work with a library:
12
+
13
+ ```html
14
+ <html lang="en">
15
+ <head>
16
+ <title>TWA</title>
17
+ <meta charset="UTF-8">
18
+ <script src="https://telegram.org/js/telegram-web-app.js"></script>
19
+ <script>
20
+ window.Telegram.WebApp.showPopup({ message: 'message' });
21
+ </script>
22
+ </head>
23
+ <body></body>
24
+ </html>
25
+ ```
26
+
27
+ This package allows to work with SDK as with a npm package:
28
+
29
+ ```js
30
+ import { bridgeOpenPopup } from '@apiteam/twa-bridge'
31
+
32
+ bridgeOpenPopup({ message: 'message' })
33
+ ```
34
+
35
+ And yes, it supports TS.
36
+
37
+ ### Solid
38
+ ```js
39
+ import { createIsViewportChanged } from '@apiteam/twa-bridge/solid'
40
+
41
+ const viewport = createIsViewportChanged()
42
+ ```