Catalog npm
Back to packageRELEASE DETAILS

0.0.2

npm

4nm

TypeScript reimplementation of Telegram's official library for communicating with Telegram Web Apps.

telegramtelegram-web-appstwa
Published27 Sept 2022
Direct dependencies5
Transitive dependenciesNot calculated

README

Current package documentation

Telegram Web Apps Client SDK

TypeScript reimplementation of Telegram's official library for communicating with Telegram Web Apps.

⚠️ This library is not the same library created by Telegram developers but with types. It contains similar code, but differs a bit in some moments. Please, refer to documentation in code to avoid problems.

Motivation

  • Currently, official implementation supports usage only through global window object that is not modern and not that comfortable as importing this library as npm package. Nevertheless, it does not mean, this use case should not exist. Some applications may not support modern way of using packages and as a result, the only one possible solution for them is usage through window object;
  • Library is written in JavaScript without usage of JSDoc. Modern libraries are now developed with TypeScript which allows developers to know the types they are currently working with;
  • Library contains almost no comments. So, most of the time, it is harder to understand current code flow;

Installation

npm

npm i twa-client-sdk

yarn

yarn add twa-client-sdk

Usage

Library contains 2 global components which are commonly used in Web Apps. They are webView and webApp. These variables are instances of WebView and WebApp which are created by library itself. In case, there is some specific application algorithm, its is allowed to create these instance by yourself and initialise, but we recommend using variables which are stored in library.

One of the main important parts of SDK lifecycle is its initialization. As long as webView and webApp initially have default values, you have to fill them with usage of current environment (internally, init scripts read data from global window object).

For this purpose, usage of function init is required:

import {init} from 'twa-client-sdk';

// Initialise library.
init();

// Now, we can safely use variables `webView` and `webApp`.

"# eex"

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 5

Native requirements
5 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
commitizen
Environment
{
  "local_name": "commitizen",
  "alias": false,
  "peer_metadata": null
}
^4.2.5development
cz-conventional-changelog
Environment
{
  "local_name": "cz-conventional-changelog",
  "alias": false,
  "peer_metadata": null
}
3.3.0development
npm-run-all
Environment
{
  "local_name": "npm-run-all",
  "alias": false,
  "peer_metadata": null
}
^4.1.5development
standard-version
Environment
{
  "local_name": "standard-version",
  "alias": false,
  "peer_metadata": null
}
^9.5.0development
typescript
Environment
{
  "local_name": "typescript",
  "alias": false,
  "peer_metadata": null
}
^4.8.3development

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "integrity": "sha512-DLZNiBOEXBnd2zKurvaAyQNpDzAK8dKc5APLQH2TdtXwpaXDNXTI2pmscG501SQJxQKSJEhdXPxNW10cMWUGPw==",
  "shasum": "7a9467e8e4a0bb14527ba3d7006798cb15c7461d",
  "tarball": "https://registry.npmjs.org/4nm/-/4nm-0.0.2.tgz",
  "fileCount": 53,
  "unpackedSize": 75254,
  "signatures": [
    {
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
      "sig": "MEQCIE9P3/J2/q5zx0BS8eTh+9Az+EOZwUuHcchnRX8eTM1eAiA74ivmSErP+egD0LBO6UaL93QL9WoLrgBu5dW7cCYMSw=="
    }
  ],
  "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjMprwACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrLJBAAiFPkCatCvZf577Lz7MvOg+7mhhl7jwrwjM4FSFVW5J8wMoFf\r\n6os1LizmntxmaobdyPLa2ohzz/I6vXsKMgSslFDezeo4YEzskDV9yW/73Ymh\r\nDYKOlBKmI4dFS6DRuAxXe1sglvQxcfEc/vRp1eyO/VudXYEJ5DTtEn6Mc5ji\r\njQ5S0Sg15pb9PVWmblvSVBb9vL3aA41jroPuWtroCNjuQBZyLjo7dHBjoO4G\r\n8KIF9WGOoaZvZN6nrJHI9WAFGX7AHRqrsJecwlUEUpZ0C8KyuYt6J75weKLb\r\n1/qwAHFQOyVOi267OoTf9vC/EVvnVU5Dps80cNqZJ01jppPCGEX9r0uGnzcp\r\nk5tVo/xpg1UtN0Z0et4gSkjCpQQgbMXWlnCT7gwSqZkHBPhFw4nKPSIOUCbz\r\nezVLmvSlVLg0WP87aUjLd5+PLItLRjn7153FCqDgMLDvgOGQyYorKAb/tp6W\r\naHf4TC2RVlKRN3Tg0IJimNV75cG/tS3z/Nk32X51evOUGr1dlnUb0Q9MfAMo\r\n2S2kuf2z1Kv4om8y29MNGFp8WWNPg1fgIa1YQA4zN2pTFWa8uPTS3aN8ZTjZ\r\nkLEUgjgfPAWb8pQw91J9/P7X9snGGXVqAh2hZge0PSMuaV/JzxVJi3ti6eAh\r\n5U7xFAMAgbWoOFaMsUlZ+dirTEtolYOduq4=\r\n=4WMX\r\n-----END PGP SIGNATURE-----\r\n"
}

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 20:13 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:e075ce801c093ee2fe275e310f68d87ae2c2803793eb926df2ed5bbae81c5fa4

Other collected versions

View all collected versions →