Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some minor changes related to tma.js -> telegram-apps #389

Merged
merged 3 commits into from
Jul 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ can clone the repository using the Git command:

```bash
# Via SSH.
git clone [email protected]:Telegram-Mini-Apps/tma.js.git
git clone [email protected]:Telegram-Mini-Apps/telegram-apps.git
```

or

```bash
# Via HTTPS.
git clone https://github.com/Telegram-Mini-Apps/tma.js.git
git clone https://github.com/Telegram-Mini-Apps/telegram-apps.git
```

Once the repository is fetched, install project dependencies via [pnpm](https://pnpm.io/) (pnpm
Expand All @@ -31,7 +31,7 @@ pnpm i

## Trying Your Code

This project contains an already configured application that can use any `@tma.js` package located
This project contains an already configured application that can use any `@telegram-apps` package located
in the [packages](packages) folder. The application uses local versions of packages, not remote ones
presented in some registry. The local playground represents almost the default Vite TypeScript
application template with some additional tsconfig configuration, allowing the resolution of
Expand All @@ -53,7 +53,7 @@ automatically transpiled by Vite and executed by the browser.

As the local playground refers to the actual code, you can make any changes in the packages
directory to see the changes instantly. This will help you understand how the code you are going to
change in `@tma.js` packages will work after your proposed changes.
change in `@telegram-apps` packages will work after your proposed changes.

## After Changes Done

Expand Down
32 changes: 16 additions & 16 deletions MOTIVATION.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Motivation

This document describes the motivation that inspired us to create `@tma.js`.
This document describes the motivation that inspired us to create `@telegram-apps`.

Here is the list of problems, we found in the official SDK and decided to create our own:

Expand All @@ -27,11 +27,11 @@ development has advanced significantly beyond the ES5 standard and traditional J

### Solution

Despite the issues associated with IIFE, `@tma.js` is available in three formats: CommonJS (CJS),
Despite the issues associated with IIFE, `@telegram-apps` is available in three formats: CommonJS (CJS),
ECMAScript Modules (ESM), and IIFE. Developers have the flexibility to choose any of these formats,
and they can reap the benefits of selecting ESM.

All project packages are available on [npm.js](https://www.npmjs.com/org/tma.js) and can be
All project packages are available on [npm.js](https://www.npmjs.com/org/telegram-apps) and can be
installed in the standard manner via `npm i`, `pnpm i`, `yarn add`, etc.

## No Public Review
Expand All @@ -42,7 +42,7 @@ Additionally, developers are unable to report some problems in code or suggest a

### Solution

`@tma.js` uses GitHub as its codebase repository. Every developer can track changes made to any
`@telegram-apps` uses GitHub as its codebase repository. Every developer can track changes made to any
files and review them.

## Vanilla JavaScript
Expand All @@ -54,7 +54,7 @@ TypeScript, offering type support out of the box.

### Solution

`@tma.js` is written in TypeScript and doesn't require help of other packages to provide typings.
`@telegram-apps` is written in TypeScript and doesn't require help of other packages to provide typings.

## Possible Security Issues

Expand All @@ -78,7 +78,7 @@ this security mechanism, Telegram does it for them for "testing purposes".

### Solution

`@tma.js` does not disable any security mechanisms. If a developer needs to configure the list of
`@telegram-apps` does not disable any security mechanisms. If a developer needs to configure the list of
allowed parent iframe origins, the package provides corresponding methods.

## Mixed Code Quality
Expand All @@ -94,7 +94,7 @@ is happening in the code, which, in turn, makes it more challenging to contribut

### Solution

`@tma.js` code is extensively documented with various types of comments and documentation. The
`@telegram-apps` code is extensively documented with various types of comments and documentation. The
project follows well-established and widely
recognized [ESLint rules as described by Airbnb](https://github.com/airbnb/javascript). External
developers are welcome to explore the code and propose improvements.
Expand All @@ -108,7 +108,7 @@ here.

### Solution

`@tma.js` packages are built using Vite (Rollup), which minifies the code and provides ready-to-use
`@telegram-apps` packages are built using Vite (Rollup), which minifies the code and provides ready-to-use
libraries.

## Inconsistent Components State
Expand All @@ -130,7 +130,7 @@ So, the SDK lacks awareness of the actual state of components.

### Solution

`@tma.js` packages consistently provide the current component state.
`@telegram-apps` packages consistently provide the current component state.

## 1700 Lines of Code, Single File

Expand All @@ -139,7 +139,7 @@ way too hard, decreasing code understanding and external developers code contrib

### Solution

`@tma.js` packages are finely detailed, with each package being responsible for its specific part of
`@telegram-apps` packages are finely detailed, with each package being responsible for its specific part of
the platform and having an intuitive file structure.

## Unused Code
Expand Down Expand Up @@ -174,7 +174,7 @@ already a concern.

### Solution

`@tma.js` does not contain any code specifically oriented towards a distinct group of developers.
`@telegram-apps` does not contain any code specifically oriented towards a distinct group of developers.
The functionality it provides covers scenarios that all developers are likely to encounter.

## Implicit Methods Inactivity
Expand All @@ -195,12 +195,12 @@ platform versions and implement the corresponding functionality themselves.

### Solution

The `@tma.js/bridge` package offers utilities to verify whether a specific Telegram Mini Apps method
The `@telegram-apps/bridge` package offers utilities to verify whether a specific Telegram Mini Apps method
is supported in a specified platform version. This ensures that the developer can be confident the
method call will work as intended. It also allows checking if specified method **parameter** is
supported by specified version.

The `@tma.js/sdk` package provides higher-level components that make use of Telegram Mini Apps. Each
The `@telegram-apps/sdk` package provides higher-level components that make use of Telegram Mini Apps. Each
component has a special method, `supports`, which returns `true` if the component's method is
supported in the current platform version. By default, calling methods that are not supported in the
current platform version will result in an error. Nevertheless, this type of behavior is configurable.
Expand All @@ -219,7 +219,7 @@ initialization has been completed.

### Solution

`@tma.js` provides asynchronous initialization to ensure that developers are working with
`@telegram-apps` provides asynchronous initialization to ensure that developers are working with
components in their actual state. However, it does not restrict developers from implementing
their own initialization process.

Expand All @@ -237,7 +237,7 @@ configurable.

### Solution

CSS variables feature is configurable in `@tma.js` packages.
CSS variables feature is configurable in `@telegram-apps` packages.

## Forced Logs

Expand All @@ -247,4 +247,4 @@ to sending unnecessary logs to external services.

### Solution

`@tma.js/sdk` supports enabling and disabling lifecycle logs.
`@telegram-apps/sdk` supports enabling and disabling lifecycle logs.
88 changes: 44 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
[code-badge]: https://img.shields.io/badge/source-black?logo=github

# @tma.js
# @telegram-apps

[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)

Mono-repository, containing all the packages, connected with comfortable and safe TypeScript
development on Telegram Mini Apps platform. To learn more about specific packages, follow
their own [documentations](https://docs.telegram-mini-apps.com).

> ⚠️ Working with @tma.js packages, you must not install the SDK from Telegram presented by
> a single file - telegram-web-app.js. Using both @tma.js packages and telegram-web-app.js
> ⚠️ Working with @telegram-apps packages, you must not install the SDK from Telegram presented by
> a single file - telegram-web-app.js. Using both @telegram-apps packages and telegram-web-app.js
> will surely lead to bugs.

## Packages

[docs-badge]: https://img.shields.io/badge/documentation-a?logo=gitbook&logoColor=white&color=%23007AFF

### `@tma.js/sdk`
### `@telegram-apps/sdk`

[sdk-npm-badge]: https://img.shields.io/npm/v/@tma.js/sdk?logo=npm
[sdk-npm-badge]: https://img.shields.io/npm/v/@telegram-apps/sdk?logo=npm

[![docs-badge]](https://docs.telegram-mini-apps.com/packages/tma-js-sdk)
[![sdk-npm-badge]](https://npmjs.com/package/@tma.js/sdk)
![Size](https://img.shields.io/bundlephobia/minzip/@tma.js/sdk)
[![code-badge]](https://github.com/Telegram-Mini-Apps/tma.js/tree/master/packages/sdk)
[![docs-badge]](https://docs.telegram-mini-apps.com/packages/telegram-apps-sdk)
[![sdk-npm-badge]](https://npmjs.com/package/@telegram-apps/sdk)
![Size](https://img.shields.io/bundlephobia/minzip/@telegram-apps/sdk)
[![code-badge]](https://github.com/Telegram-Mini-Apps/telegram-apps/tree/master/packages/sdk)

Made from scratch TypeScript library for seamless communication with Telegram Mini Apps
functionality.
Expand All @@ -36,72 +36,72 @@ Before you begin using the SDK, we highly recommend familiarizing yourself with
Apps [documentation](https://docs.telegram-mini-apps.com/platform/about)
to grasp the fundamental concepts of the platform.

### `@tma.js/sdk-react`
### `@telegram-apps/sdk-react`

[sdk-react-npm-badge]: https://img.shields.io/npm/v/@tma.js/sdk-react?logo=npm
[sdk-react-npm-badge]: https://img.shields.io/npm/v/@telegram-apps/sdk-react?logo=npm

[![docs-badge]](https://docs.telegram-mini-apps.com/packages/tma-js-sdk-react)
[![sdk-react-npm-badge]](https://npmjs.com/package/@tma.js/sdk-react)
![Size](https://img.shields.io/bundlephobia/minzip/@tma.js/sdk-react)
[![code-badge]](https://github.com/Telegram-Mini-Apps/tma.js/tree/master/packages/sdk-react)
[![docs-badge]](https://docs.telegram-mini-apps.com/packages/telegram-apps-sdk-react)
[![sdk-react-npm-badge]](https://npmjs.com/package/@telegram-apps/sdk-react)
![Size](https://img.shields.io/bundlephobia/minzip/@telegram-apps/sdk-react)
[![code-badge]](https://github.com/Telegram-Mini-Apps/telegram-apps/tree/master/packages/sdk-react)

React JS bindings for [client SDK](https://docs.telegram-mini-apps.com/packages/tma-js-sdk). Includes
React JS bindings for [client SDK](https://docs.telegram-mini-apps.com/packages/telegram-apps-sdk). Includes
hooks, components and utilities for comfortable usage of React JS on the Telegram Mini Apps platform.

### `@tma.js/sdk-solid`
### `@telegram-apps/sdk-solid`

[sdk-solid-npm-badge]: https://img.shields.io/npm/v/@tma.js/sdk-solid?logo=npm
[sdk-solid-npm-badge]: https://img.shields.io/npm/v/@telegram-apps/sdk-solid?logo=npm

[![docs-badge]](https://docs.telegram-mini-apps.com/packages/tma-js-sdk-solid)
[![sdk-solid-npm-badge]](https://npmjs.com/package/@tma.js/sdk-solid)
![Size](https://img.shields.io/bundlephobia/minzip/@tma.js/sdk-solid)
[![code-badge]](https://github.com/Telegram-Mini-Apps/tma.js/tree/master/packages/sdk-solid)
[![docs-badge]](https://docs.telegram-mini-apps.com/packages/telegram-apps-sdk-solid)
[![sdk-solid-npm-badge]](https://npmjs.com/package/@telegram-apps/sdk-solid)
![Size](https://img.shields.io/bundlephobia/minzip/@telegram-apps/sdk-solid)
[![code-badge]](https://github.com/Telegram-Mini-Apps/telegram-apps/tree/master/packages/sdk-solid)

Solid JS bindings
for [client SDK](https://docs.telegram-mini-apps.com/packages/tma-js-sdk). Includes
for [client SDK](https://docs.telegram-mini-apps.com/packages/telegram-apps-sdk). Includes
hooks, components and utilities
for comfortable usage of Solid JS on the Telegram Mini Apps platform.

### `@tma.js/init-data-node`
### `@telegram-apps/init-data-node`

[init-data-node-npm-badge]: https://img.shields.io/npm/v/@tma.js/init-data-node?logo=npm
[init-data-node-npm-badge]: https://img.shields.io/npm/v/@telegram-apps/init-data-node?logo=npm

[![docs-badge]](https://docs.telegram-mini-apps.com/packages/tma-js-init-data-node)
[![init-data-node-npm-badge]](https://npmjs.com/package/@tma.js/init-data-node)
![Size](https://img.shields.io/bundlephobia/minzip/@tma.js/init-data-node)
[![code-badge]](https://github.com/Telegram-Mini-Apps/tma.js/tree/master/packages/init-data-node)
[![docs-badge]](https://docs.telegram-mini-apps.com/packages/telegram-apps-init-data-node)
[![init-data-node-npm-badge]](https://npmjs.com/package/@telegram-apps/init-data-node)
![Size](https://img.shields.io/bundlephobia/minzip/@telegram-apps/init-data-node)
[![code-badge]](https://github.com/Telegram-Mini-Apps/telegram-apps/tree/master/packages/init-data-node)

The package provides utilities to work with the initialization data of Telegram Mini Apps on the
server side. To learn more about the initialization data and its usage, please refer to
the [documentation](https://docs.telegram-mini-apps.com/platform/launch-parameters).

### `@tma.js/solid-router-integration`
### `@telegram-apps/solid-router-integration`

[solid-router-integration-npm-badge]: https://img.shields.io/npm/v/@tma.js/solid-router-integration?logo=npm
[solid-router-integration-npm-badge]: https://img.shields.io/npm/v/@telegram-apps/solid-router-integration?logo=npm

[![docs-badge]](https://docs.telegram-mini-apps.com/packages/tma-js-solid-router-integration)
[![solid-router-integration-npm-badge]](https://npmjs.com/package/@tma.js/solid-router-integration)
![Size](https://img.shields.io/bundlephobia/minzip/@tma.js/solid-router-integration)
[![code-badge]](https://github.com/Telegram-Mini-Apps/tma.js/tree/master/packages/solid-router-integration)
[![docs-badge]](https://docs.telegram-mini-apps.com/packages/telegram-apps-solid-router-integration)
[![solid-router-integration-npm-badge]](https://npmjs.com/package/@telegram-apps/solid-router-integration)
![Size](https://img.shields.io/bundlephobia/minzip/@telegram-apps/solid-router-integration)
[![code-badge]](https://github.com/Telegram-Mini-Apps/telegram-apps/tree/master/packages/solid-router-integration)

Telegram Mini Apps [Navigator](https://docs.telegram-mini-apps.com/packages/tma-js-sdk/navigation)
Telegram Mini Apps [Navigator](https://docs.telegram-mini-apps.com/packages/telegram-apps-sdk/navigation)
integration for [@solidjs/router](https://www.npmjs.com/package/@solidjs/router).

### `@tma.js/react-router-integration`
### `@telegram-apps/react-router-integration`

[react-router-integration-npm-badge]: https://img.shields.io/npm/v/@tma.js/react-router-integration?logo=npm
[react-router-integration-npm-badge]: https://img.shields.io/npm/v/@telegram-apps/react-router-integration?logo=npm

[![docs-badge]](https://docs.telegram-mini-apps.com/packages/tma-js-react-router-integration)
[![react-router-integration-npm-badge]](https://npmjs.com/package/@tma.js/react-router-integration)
![Size](https://img.shields.io/bundlephobia/minzip/@tma.js/react-router-integration)
[![code-badge]](https://github.com/Telegram-Mini-Apps/tma.js/tree/master/packages/react-router-integration)
[![docs-badge]](https://docs.telegram-mini-apps.com/packages/telegram-apps-react-router-integration)
[![react-router-integration-npm-badge]](https://npmjs.com/package/@telegram-apps/react-router-integration)
![Size](https://img.shields.io/bundlephobia/minzip/@telegram-apps/react-router-integration)
[![code-badge]](https://github.com/Telegram-Mini-Apps/telegram-apps/tree/master/packages/react-router-integration)

Telegram Mini Apps [Navigator](https://docs.telegram-mini-apps.com/packages/tma-js-sdk/navigation)
Telegram Mini Apps [Navigator](https://docs.telegram-mini-apps.com/packages/telegram-apps-sdk/navigation)
integration for [react-router-dom](https://www.npmjs.com/package/react-router-dom).

## Why not Telegram SDK

Why bother creating a project like `@tma.js` when there are existing solutions from the developers
Why bother creating a project like `@telegram-apps` when there are existing solutions from the developers
who own the platform? The answer is rather simple: the currently provided solution (SDK) does not
seem to meet the required minimum quality standards. Of course, the term 'quality' is rather
specific and subjective, but this section should make it more objective.
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/packages/telegram-apps-init-data-node.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ the [validation](../platform/init-data#validating) section of the documentation.
Here are some examples:

```ts
import { validate, sign } from '@tma.js/init-data-node';
import { validate, sign } from '@telegram-apps/init-data-node';

const secretTokenHashed = 'a5c609aa52f63cb5e6d8ceb6e4138726ea82bbc36bb786d64482d445ea38ee5f';
const initData =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const promptTemplate = createPrompt<Template, {}>(
return acc;
}, {
framework: 'react',
sdk: 'tmajs',
sdk: 'telegramApps',
language: 'ts',
});
}, []),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const sections: Section[] = [
title: 'SDK',
name: 'sdk',
choices: [
{ title: 'tma.js', value: 'tmajs', defaultChecked: true },
{ title: '@telegram-apps', value: 'telegramApps', defaultChecked: true },
{ title: 'Telegram SDK', value: 'tsdk' },
],
},
Expand Down
4 changes: 2 additions & 2 deletions packages/create-mini-app/src/templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function createRepository(name: string): TemplateRepository {

const settings = {
js: {
tmajs: {
telegramApps: {
react: 'reactjs-js-template',
solid: 'solidjs-js-template',
next: 'nextjs-js-template',
Expand All @@ -24,7 +24,7 @@ const settings = {
},
},
ts: {
tmajs: {
telegramApps: {
react: 'reactjs-template',
solid: 'solidjs-template',
next: 'nextjs-template',
Expand Down
2 changes: 1 addition & 1 deletion packages/create-mini-app/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ export interface Template {
}

export type Language = 'js' | 'ts';
export type SDK = 'tsdk' | 'tmajs';
export type SDK = 'tsdk' | 'telegramApps';
export type Framework = 'solid' | 'react' | 'next';
2 changes: 1 addition & 1 deletion packages/sdk/src/components/Invoice/Invoice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type { InvoiceState } from './types.js';
// TODO: Usage.

/**
* @see API: https://docs.telegram-mini-apps.com/packages/tma-js-sdk/components/invoice
* @see API: https://docs.telegram-mini-apps.com/packages/telegram-apps-sdk/components/invoice
*/
export class Invoice extends WithSupportsAndTrackableState<InvoiceState, 'open'> {
constructor(
Expand Down
4 changes: 2 additions & 2 deletions playgrounds/next/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Mini Apps platform using the following technologies and libraries:
- [Next.js](https://nextjs.org/)
- [TypeScript](https://www.typescriptlang.org/)
- [TON Connect](https://docs.ton.org/develop/dapps/ton-connect/overview)
- [@telegram-apps SDK](https://docs.telegram-mini-apps.com/packages/tma-js-sdk)
- [@telegram-apps SDK](https://docs.telegram-mini-apps.com/packages/telegram-apps-sdk)
- [Telegram UI](https://github.com/Telegram-Mini-Apps/TelegramUI)

> The template was created using [pnpm](https://pnpm.io/). Therefore, it is required to use
Expand Down Expand Up @@ -126,5 +126,5 @@ details.
## Useful Links

- [Platform documentation](https://docs.telegram-mini-apps.com/)
- [@telegram-apps/sdk-react documentation](https://docs.telegram-mini-apps.com/packages/tma-js-sdk-react)
- [@telegram-apps/sdk-react documentation](https://docs.telegram-mini-apps.com/packages/telegram-apps-sdk-react)
- [Telegram developers community chat](https://t.me/devs)
Loading
Loading