From 93246f9846f50b20c07eaebf63bf318eb856ee5d Mon Sep 17 00:00:00 2001 From: Vladislav Kibenko Date: Fri, 29 Sep 2023 23:46:21 +0300 Subject: [PATCH 1/8] feat(packages): implement @tma.js/navigation --- packages/navigation/.eslintrc.cjs | 3 + packages/navigation/LICENSE | 21 ++ packages/navigation/README.md | 32 +++ packages/navigation/jest.config.js | 20 ++ packages/navigation/package.json | 64 +++++ packages/navigation/rollup.config.js | 53 ++++ packages/navigation/src/Navigator.ts | 333 +++++++++++++++++++++++ packages/navigation/src/history.ts | 29 ++ packages/navigation/src/index.ts | 3 + packages/navigation/src/parsing.ts | 32 +++ packages/navigation/src/types.ts | 30 ++ packages/navigation/src/utils.ts | 77 ++++++ packages/navigation/tsconfig.build.json | 15 + packages/navigation/tsconfig.eslint.json | 10 + packages/navigation/tsconfig.json | 7 + 15 files changed, 729 insertions(+) create mode 100644 packages/navigation/.eslintrc.cjs create mode 100644 packages/navigation/LICENSE create mode 100644 packages/navigation/README.md create mode 100644 packages/navigation/jest.config.js create mode 100644 packages/navigation/package.json create mode 100644 packages/navigation/rollup.config.js create mode 100644 packages/navigation/src/Navigator.ts create mode 100644 packages/navigation/src/history.ts create mode 100644 packages/navigation/src/index.ts create mode 100644 packages/navigation/src/parsing.ts create mode 100644 packages/navigation/src/types.ts create mode 100644 packages/navigation/src/utils.ts create mode 100644 packages/navigation/tsconfig.build.json create mode 100644 packages/navigation/tsconfig.eslint.json create mode 100644 packages/navigation/tsconfig.json diff --git a/packages/navigation/.eslintrc.cjs b/packages/navigation/.eslintrc.cjs new file mode 100644 index 000000000..63d117348 --- /dev/null +++ b/packages/navigation/.eslintrc.cjs @@ -0,0 +1,3 @@ +module.exports = { + extends: ['custom/base'], +}; diff --git a/packages/navigation/LICENSE b/packages/navigation/LICENSE new file mode 100644 index 000000000..de6c2fd26 --- /dev/null +++ b/packages/navigation/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022 Vladislav Kibenko + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/navigation/README.md b/packages/navigation/README.md new file mode 100644 index 000000000..9b03ff6cb --- /dev/null +++ b/packages/navigation/README.md @@ -0,0 +1,32 @@ +# @tma.js/navigation + +[code-link]: https://github.com/Telegram-Mini-Apps/tma.js/tree/master/packages/navigation + +[code-badge]: https://img.shields.io/badge/source-black?logo=github + +[docs-link]: https://docs.telegram-mini-apps.com/docs/libraries/tma-js-navigation + +[docs-badge]: https://img.shields.io/badge/documentation-blue?logo=gitbook&logoColor=white + +[npm-link]: https://npmjs.com/package/@tma.js/navigation + +[npm-badge]: https://img.shields.io/npm/v/@tma.js/navigation?logo=npm + +[size-badge]: https://img.shields.io/bundlephobia/minzip/@tma.js/navigation + +[![npm-badge]][npm-link] +![size-badge] +[![docs-badge]][docs-link] +[![code-badge]][code-link] + +[//]: # (Package which provides utilities to simplify communication flow between) + +[//]: # (frontend and Telegram native applications. It also solves some across-platform) + +[//]: # (data difference problems to protect developers code and save their time.) + +[//]: # (This library is a part of TypeScript packages ecosystem around Telegram Web) + +[//]: # (Apps. You can learn more about this package in this) + +[//]: # ([documentation](https://docs.telegram-mini-apps.com/docs/libraries/tma-js-navigation).) diff --git a/packages/navigation/jest.config.js b/packages/navigation/jest.config.js new file mode 100644 index 000000000..099c4c018 --- /dev/null +++ b/packages/navigation/jest.config.js @@ -0,0 +1,20 @@ +import tsConfig from 'jest-config-custom/ts'; + +/** @type {import('ts-jest').JestConfigWithTsJest} */ +export default { + ...tsConfig, + testEnvironment: 'jsdom', + collectCoverage: true, + collectCoverageFrom: [ + 'src/**/*.ts', + '!src/**/index.ts', + ], + // coverageThreshold: { + // global: { + // branches: 90, + // functions: 90, + // lines: 90, + // statements: 0, + // }, + // }, +}; diff --git a/packages/navigation/package.json b/packages/navigation/package.json new file mode 100644 index 000000000..eaf801ae0 --- /dev/null +++ b/packages/navigation/package.json @@ -0,0 +1,64 @@ +{ + "name": "@tma.js/navigation", + "private": true, + "version": "0.0.0", + "description": "Custom router to be used in Telegram Mini Apps", + "author": "Vladislav Kibenko ", + "homepage": "https://github.com/Telegram-Mini-Apps/tma.js#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/Telegram-Mini-Apps/tma.js.git", + "directory": "packages/navigation" + }, + "bugs": { + "url": "https://github.com/Telegram-Mini-Apps/tma.js/issues" + }, + "keywords": [ + "telegram-mini-apps", + "navigation", + "typescript" + ], + "license": "MIT", + "type": "module", + "sideEffects": false, + "files": [ + "dist", + "src" + ], + "main": "dist/lib/index.cjs", + "browser": "dist/lib/browser.js", + "module": "dist/lib/index.mjs", + "types": "dist/types/index.d.ts", + "exports": { + ".": { + "types": "./dist/types/index.d.ts", + "import": "./dist/lib/index.mjs", + "require": "./dist/lib/index.cjs", + "default": "./dist/lib/index.cjs" + }, + "./*": { + "types": "./dist/types/*.d.ts", + "import": "./dist/lib/*.mjs", + "require": "./dist/lib/*.cjs", + "default": "./dist/lib/*.cjs" + } + }, + "scripts": { + "lint": "eslint -c .eslintrc.cjs src/**/* __tests__/**/*", + "build": "rimraf dist && rollup --config rollup.config.js" + }, + "dependencies": { + "@tma.js/bridge": "workspace:*", + "@tma.js/parsing": "workspace:*", + "@tma.js/event-emitter": "workspace:*", + "@tma.js/logger": "workspace:*" + }, + "devDependencies": { + "tsconfig": "workspace:*", + "eslint-config-custom": "workspace:*", + "jest-config-custom": "workspace:*" + }, + "publishConfig": { + "access": "public" + } +} diff --git a/packages/navigation/rollup.config.js b/packages/navigation/rollup.config.js new file mode 100644 index 000000000..24bf77f85 --- /dev/null +++ b/packages/navigation/rollup.config.js @@ -0,0 +1,53 @@ +import typescript from '@rollup/plugin-typescript'; +import terser from '@rollup/plugin-terser'; +import { defineConfig } from 'rollup'; +import { createRequire } from 'node:module'; +import { nodeResolve } from '@rollup/plugin-node-resolve'; + +const require = createRequire(import.meta.url); +const pkg = require('./package.json'); + +const input = 'src/index.ts'; + +const external = ['@tma.js/bridge', '@tma.js/logger', '@tma.js/event-emitter', '@tma.js/parsing']; + +export default [ + // CJS, ESM. + defineConfig({ + input, + output: [ + { file: pkg.main, format: 'commonjs', sourcemap: true }, + { file: pkg.module, format: 'esm', sourcemap: true }, + ], + external, + plugins: [typescript({ tsconfig: './tsconfig.build.json' }), terser()], + }), + + // Browser. + defineConfig({ + input, + output: { + file: pkg.browser, + format: 'iife', + name: '@tma.js/navigation', + sourcemap: true, + }, + plugins: [typescript({ tsconfig: './tsconfig.build.json' }), nodeResolve(), terser()], + }), + + // Types. + defineConfig({ + input, + output: { file: pkg.types }, + external, + plugins: [typescript({ + tsconfig: './tsconfig.build.json', + compilerOptions: { + declaration: true, + emitDeclarationOnly: true, + sourceMap: false, + inlineSources: false, + }, + }), terser()], + }), +]; diff --git a/packages/navigation/src/Navigator.ts b/packages/navigation/src/Navigator.ts new file mode 100644 index 000000000..43ebed640 --- /dev/null +++ b/packages/navigation/src/Navigator.ts @@ -0,0 +1,333 @@ +import { log } from '@tma.js/logger'; +import { EventEmitter } from '@tma.js/event-emitter'; +import { postEvent, on, off } from '@tma.js/bridge'; + +import { ensurePrefixSlash, formatSearch, mergePathnames, toPathname } from './utils.js'; +import { drop, go } from './history.js'; +import { parseAsHistoryCurrentState } from './parsing.js'; + +import type { + HistoryCurrentState, + HistoryEntry, + NavigatorEventsMap, + NavigatorOptions, + Pathname, +} from './types.js'; + +const CURSOR_VOID = 0; +const CURSOR_BACK = 1; +const CURSOR_FORWARD = 2; + +/** + * Represents a navigator which can be used in Telegram Mini Apps to provide stable routing. + */ +export class Navigator { + /** + * Attempts to create a navigator from the current browser history. This will properly work + * in case, the last time browser history was managed by some navigator. + * + * Method returns true in case, it was unable to create Navigator. + * @param options - options passed to constructor. + */ + static fromHistory(options?: NavigatorOptions): Navigator | null { + const state = parseAsHistoryCurrentState(window.history.state); + + return state ? new Navigator(state.history, state.cursor, options) : null; + } + + /** + * Creates navigator from current window location. + * @param options - options passed to constructor. + */ + static fromLocation(options?: NavigatorOptions): Navigator { + const { search, pathname } = new URL( + `${origin}${ensurePrefixSlash(window.location.hash.slice(1))}`, + ); + + return new Navigator([{ search, pathname: pathname as Pathname }], 0, options); + } + + private readonly ee = new EventEmitter(); + + private readonly debug: boolean; + + private isAttached = false; + + constructor( + private history: HistoryEntry[], + private cursor: number, + { debug = false }: NavigatorOptions = {}, + ) { + if (history.length === 0) { + throw new Error('History should not be empty'); + } + + if (history.length <= cursor) { + throw new Error('Cursor should be less than or equal to history length'); + } + + this.debug = debug; + } + + /** + * Logs a message in case, debug mode is enabled. + */ + private log(...args: any[]) { + if (this.debug) { + log('log', '[Navigator]', ...args); + } + } + + /** + * Creates browser history state associated with the current navigator state. + */ + private createCurrentState(): HistoryCurrentState { + return { cursor: this.cursor, history: this.history }; + } + + /** + * Synchronizes current navigator state with browser history. + */ + private async syncHistory(): Promise { + this.log('Synchronizing with browser history'); + + // Remove history change event listener to get rid of side effects related to possible + // future calls of history.go. + window.removeEventListener('popstate', this.onPopState); + + const hash = `#${this.path}`; + const currentState = this.createCurrentState(); + + // Drop the browser history and work with the clean one. + await drop(); + + // Actualize TMA BackButton state. + postEvent('web_app_setup_back_button', { is_visible: this.canGoBack() }); + + if (this.canGoBack() && this.canGoForward()) { + // We have both previous and next elements. History should be: + // [back, *current*, forward] + this.log('Setting up history: [back, current, forward]'); + + window.history.replaceState(CURSOR_BACK, ''); + window.history.pushState(currentState, '', hash); + window.history.pushState(CURSOR_FORWARD, ''); + await go(-1); + } else if (this.canGoBack()) { + // We have only previous element. History should be: + // [back, *current*] + this.log('Setting up history: [back, current]'); + + window.history.replaceState(CURSOR_BACK, ''); + window.history.pushState(currentState, '', hash); + } else if (this.canGoForward()) { + // We have only next element. History should be: + // [*current*, forward] + this.log('Setting up history: [current, forward]'); + + window.history.replaceState(currentState, hash); + window.history.pushState(CURSOR_FORWARD, ''); + await go(-1); + } else { + // We have no back and next elements. History should be: + // [void, *current*] + this.log('Setting up history: [void, current]'); + + window.history.replaceState(CURSOR_VOID, ''); + window.history.pushState(currentState, '', hash); + } + + window.addEventListener('popstate', this.onPopState); + } + + /** + * Returns true in case, we can move back from the current history element. + */ + private canGoBack(): boolean { + return this.cursor > 0; + } + + /** + * Returns true in case, we can move forward from the current history element. + */ + private canGoForward(): boolean { + return this.cursor !== this.history.length - 1; + } + + /** + * Converts externally specified history entry data to the history item. + * @param entry - entry data + */ + private entryToHistoryItem(entry: Partial = {}): HistoryEntry { + const { search = '', pathname = this.pathname } = entry; + + return { + pathname: pathname.startsWith('/') + // Full path from the root. Example: /a/b/c + ? toPathname(pathname) + // Otherwise, it's the relative path. We should merge it with the current one. + : mergePathnames(toPathname(pathname), this.pathname), + search: search || '', + }; + } + + /** + * Being called whenever "popstate" event occurs. + * @param state - event state. + */ + private onPopState = async ({ state }: PopStateEvent) => { + this.log('Received state', state); + + // There is only one case when state can be CURSOR_VOID - when history contains + // only one element. In this case, we should return user to the current history element. + if (state === CURSOR_VOID) { + window.history.forward(); + return; + } + + // User pressed Back button. + if (state === CURSOR_BACK) { + return this.setCursor(this.cursor - 1); + } + + // User pressed Forward button. + if (state === CURSOR_FORWARD) { + return this.setCursor(this.cursor + 1); + } + }; + + /** + * Sets new cursor and synchronizes current navigator state with browser history. + * @param value - next cursor value. + */ + private async setCursor(value: number): Promise { + const prevCursor = this.cursor; + this.cursor = value; + + this.log('Setting up cursor', prevCursor, '->', this.cursor); + + // Notify listeners about state change. + this.ee.emit('change', { pathname: this.pathname, search: this.search }); + + // Cursor did not change, but setCursor could be called after calling the replace method, what + // means, we should actualize current URL. + if (prevCursor === this.cursor) { + window.history.replaceState(this.createCurrentState(), '', `#${this.path}`); + return; + } + + return this.syncHistory(); + } + + /** + * Attaches current navigator to the browser history. + */ + async attach(): Promise { + if (this.isAttached) { + return; + } + this.isAttached = true; + + this.log('Attaching navigator', this); + on('back_button_pressed', this.back); + return this.syncHistory(); + } + + /** + * Goes back in history. + */ + back = (): Promise => this.go(-1); + + /** + * Detaches current navigator from the browser history. + */ + detach() { + this.log('Detaching navigator', this); + + // When detaching, we just remove all event listeners. + this.isAttached = false; + window.removeEventListener('popstate', this.onPopState); + off('back_button_pressed', this.back); + } + + /** + * Goes forward in history. + */ + forward(): Promise { + return this.go(1); + } + + /** + * Goes in history by specified delta. + * @param delta + */ + async go(delta = 0): Promise { + // Cursor should be in bounds: [0, this.history.length - 1]. + const cursor = Math.min( + this.history.length - 1, + Math.max(this.cursor + delta, 0), + ); + + return cursor === this.cursor ? undefined : this.setCursor(cursor); + } + + /** + * Adds new event listener. + */ + on = this.ee.on.bind(this.ee); + + /** + * Removes event listener. + */ + off = this.ee.off.bind(this.ee); + + /** + * Pushes new entry in history. It removes all history entries after the current one and + * inserts new one. + * @param entry - entry data. + */ + push(entry?: Partial): Promise { + // In case, current cursor refers not to the last one element in the history, we should + // remove everything after the cursor. + if (this.cursor !== this.history.length - 1) { + this.history = this.history.slice(0, this.cursor + 1); + } + + this.history.push(this.entryToHistoryItem(entry)); + this.log('Pushed new entry', this.history[this.history.length - 1]); + + return this.setCursor(this.cursor + 1); + } + + /** + * Returns current full path including pathname and query parameters. + */ + get path(): string { + return `${this.pathname}${formatSearch(this.search)}`; + } + + /** + * Returns current pathname. + */ + get pathname(): Pathname { + return this.history[this.cursor].pathname; + } + + /** + * Replaces current entry. + * @param entry - entry data. + */ + replace(entry?: Partial): Promise { + this.history[this.cursor] = this.entryToHistoryItem(entry); + this.log('Replace current entry with', this.history[this.cursor]); + + return this.setCursor(this.cursor); + } + + /** + * Returns current query parameters. + */ + get search(): string { + return this.history[this.cursor].search; + } +} diff --git a/packages/navigation/src/history.ts b/packages/navigation/src/history.ts new file mode 100644 index 000000000..6415e2af8 --- /dev/null +++ b/packages/navigation/src/history.ts @@ -0,0 +1,29 @@ +/** + * Performs window.history.go operation waiting for it to be completed. + * @param delta - history change delta. + */ +export function go(delta: number): Promise { + return delta === 0 ? Promise.resolve() : new Promise((res) => { + window.addEventListener('popstate', function listener() { + window.removeEventListener('popstate', listener); + res(); + }); + + window.history.go(delta); + }); +} + +/** + * Drops current browser history. + */ +export async function drop(): Promise { + if (window.history.length <= 1) { + return; + } + + // Push empty state to cut states we have no access to. After this, we will be sure, next + // call of history.go will move us to the first browser history entry. + window.history.pushState(null, ''); + + return go(1 - window.history.length); +} diff --git a/packages/navigation/src/index.ts b/packages/navigation/src/index.ts new file mode 100644 index 000000000..c39153054 --- /dev/null +++ b/packages/navigation/src/index.ts @@ -0,0 +1,3 @@ +export * from './Navigator.js'; +export * from './types.js'; +export * from './utils.js'; diff --git a/packages/navigation/src/parsing.ts b/packages/navigation/src/parsing.ts new file mode 100644 index 000000000..fb9baf3f7 --- /dev/null +++ b/packages/navigation/src/parsing.ts @@ -0,0 +1,32 @@ +import { array, json, number, string } from '@tma.js/parsing'; + +import { toPathname } from './utils.js'; + +import type { HistoryCurrentState, HistoryEntry, Pathname } from './types.js'; + +const parser = json({ + cursor: number(), + history: array().of(json({ + pathname: (value) => { + const formatted = string().parse(value); + + if (formatted === toPathname(formatted)) { + return formatted as Pathname; + } + throw new TypeError(`Unable to parse value "${formatted}" as RGB.`); + }, + search: string(), + })), +}); + +/** + * Attempts to parse value as HistoryCurrentState. + * @param value - value to parse. + */ +export function parseAsHistoryCurrentState(value: unknown): HistoryCurrentState | null { + try { + return parser.parse(value); + } catch (e) { + return null; + } +} diff --git a/packages/navigation/src/types.ts b/packages/navigation/src/types.ts new file mode 100644 index 000000000..979cc3dbb --- /dev/null +++ b/packages/navigation/src/types.ts @@ -0,0 +1,30 @@ +export type Pathname = `/${string}`; + +export interface HistoryEntry { + pathname: Pathname; + search: string; +} + +/** + * Browser history state which associates with navigator state. + */ +export interface HistoryCurrentState { + cursor: number; + history: HistoryEntry[]; +} + +export interface NavigatorOptions { + /** + * Should navigator display debug messages. + * @default false + */ + debug?: boolean; +} + +export interface NavigatorEventsMap { + /** + * Being called whenever current history changes. + * @param event - occurred event. + */ + change: (event: HistoryEntry) => void; +} diff --git a/packages/navigation/src/utils.ts b/packages/navigation/src/utils.ts new file mode 100644 index 000000000..4cea2880a --- /dev/null +++ b/packages/navigation/src/utils.ts @@ -0,0 +1,77 @@ +import type { Pathname } from './types.js'; + +/** + * Ensures that specified value contains slash in the beginning. + * @param value - value to check. + */ +export function ensurePrefixSlash(value: string): `/${string}` { + return value.startsWith('/') ? value as `/${string}` : `/${value}`; +} + +/** + * Converts passed to pathname + * @param value - value to convert. + */ +export function toPathname(value: string): Pathname { + const withSlash = ensurePrefixSlash(value); + + for (let i = 0; i < withSlash.length; i += 1) { + if (withSlash[i] === '?' || withSlash[i] === '#') { + return withSlash.slice(0, i) as Pathname; + } + } + + return withSlash; +} + +/** + * Merges 2 absolute path names into a single one. + * + * @example + * what: /a + * where: /b/c/d/e + * result: /b/c/d/a + * + * @example + * what: /a/m + * where: /b/c/d/e + * result: /b/c/a/m + * + * @example + * what: /a/b/c + * where: /b + * result: /a/b/c + * + * @param what + * @param where + */ +export function mergePathnames(what: Pathname, where: Pathname): Pathname { + const [, ...whatParts] = what.split('/'); + const [, ...whereParts] = where.split('/'); + + // Example. + // what: /a/b/c + // where: /b + // As long as "what" is bigger than "where" or has the same length, it fully overwrites the path. + if (whereParts.length - whatParts.length <= 0) { + return what; + } + + return ensurePrefixSlash([ + // Take all source parts, but not the last "what" parts length. We will replace them with + // "what" parts. + ...whereParts.slice(0, -whatParts.length), + ...whatParts, + ].join('/')); +} + +/** + * Formats specified string appending question mark before in case, its not empty. + * @param search - value to format. + */ +export function formatSearch(search: string): string { + if (search.startsWith('?')) { + return search; + } + return search ? `?${search}` : ''; +} diff --git a/packages/navigation/tsconfig.build.json b/packages/navigation/tsconfig.build.json new file mode 100644 index 000000000..c21cdee38 --- /dev/null +++ b/packages/navigation/tsconfig.build.json @@ -0,0 +1,15 @@ +{ + "extends": "tsconfig/base.json", + "compilerOptions": { + "lib": [ + "esnext", + "dom" + ], + "outDir": "dist", + "module": "ESNext", + "target": "ESNext" + }, + "include": [ + "src" + ] +} \ No newline at end of file diff --git a/packages/navigation/tsconfig.eslint.json b/packages/navigation/tsconfig.eslint.json new file mode 100644 index 000000000..3020c6044 --- /dev/null +++ b/packages/navigation/tsconfig.eslint.json @@ -0,0 +1,10 @@ +{ + "extends": [ + "./tsconfig.json" + ], + "include": [ + "src", + "__tests__", + "./*.js" + ] +} \ No newline at end of file diff --git a/packages/navigation/tsconfig.json b/packages/navigation/tsconfig.json new file mode 100644 index 000000000..0c7e3efd2 --- /dev/null +++ b/packages/navigation/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "./tsconfig.build.json", + "include": [ + "src", + "__tests__" + ] +} \ No newline at end of file From 65effed3efe85518eb89dea8a2e508dc0eb65f29 Mon Sep 17 00:00:00 2001 From: Vladislav Kibenko Date: Fri, 29 Sep 2023 23:47:00 +0300 Subject: [PATCH 2/8] feat(packages): implement @tma.js/logger --- packages/logger/.eslintrc.cjs | 6 ++ packages/logger/LICENSE | 21 +++++++ packages/logger/README.md | 28 +++++++++ .../{utils => logger}/__tests__/logging.ts | 0 packages/logger/jest.config.js | 20 +++++++ packages/logger/package.json | 58 +++++++++++++++++++ packages/logger/rollup.config.js | 35 +++++++++++ packages/logger/src/index.ts | 1 + packages/{utils => logger}/src/logging.ts | 0 packages/logger/tsconfig.build.json | 15 +++++ packages/logger/tsconfig.eslint.json | 10 ++++ packages/logger/tsconfig.json | 7 +++ 12 files changed, 201 insertions(+) create mode 100644 packages/logger/.eslintrc.cjs create mode 100644 packages/logger/LICENSE create mode 100644 packages/logger/README.md rename packages/{utils => logger}/__tests__/logging.ts (100%) create mode 100644 packages/logger/jest.config.js create mode 100644 packages/logger/package.json create mode 100644 packages/logger/rollup.config.js create mode 100644 packages/logger/src/index.ts rename packages/{utils => logger}/src/logging.ts (100%) create mode 100644 packages/logger/tsconfig.build.json create mode 100644 packages/logger/tsconfig.eslint.json create mode 100644 packages/logger/tsconfig.json diff --git a/packages/logger/.eslintrc.cjs b/packages/logger/.eslintrc.cjs new file mode 100644 index 000000000..dfb971d8a --- /dev/null +++ b/packages/logger/.eslintrc.cjs @@ -0,0 +1,6 @@ +module.exports = { + extends: ['custom/base'], + rules: { + 'no-console': 0, + }, +}; diff --git a/packages/logger/LICENSE b/packages/logger/LICENSE new file mode 100644 index 000000000..417b5feb6 --- /dev/null +++ b/packages/logger/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 Vladislav Kibenko + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/logger/README.md b/packages/logger/README.md new file mode 100644 index 000000000..b7ee43b43 --- /dev/null +++ b/packages/logger/README.md @@ -0,0 +1,28 @@ +# @tma.js/logger + +[npm-badge]: https://img.shields.io/npm/v/@tma.js/logger?logo=npm + +[npm-link]: https://npmjs.com/package/@tma.js/logger + +[size-badge]: https://img.shields.io/bundlephobia/minzip/@tma.js/logger + +[![NPM][npm-badge]][npm-link] +![Size][size-badge] + +Logger implementation used across @tma.js packages. + +This library is a part of TypeScript packages ecosystem around Telegram Web +Apps. To see full documentation and other libraries, please, visit +[this](https://docs.telegram-mini-apps.com/) link. + +## Installation + +```bash +npm i @tma.js/logger +``` + +or + +```bash +yarn add @tma.js/logger +``` diff --git a/packages/utils/__tests__/logging.ts b/packages/logger/__tests__/logging.ts similarity index 100% rename from packages/utils/__tests__/logging.ts rename to packages/logger/__tests__/logging.ts diff --git a/packages/logger/jest.config.js b/packages/logger/jest.config.js new file mode 100644 index 000000000..5d0e9e844 --- /dev/null +++ b/packages/logger/jest.config.js @@ -0,0 +1,20 @@ +import tsConfig from 'jest-config-custom/ts'; + +/** @type {import('ts-jest').JestConfigWithTsJest} */ +export default { + ...tsConfig, + testEnvironment: 'jsdom', + collectCoverage: true, + collectCoverageFrom: [ + 'src/**/*.ts', + '!src/**/index.ts', + ], + coverageThreshold: { + global: { + branches: 90, + functions: 90, + lines: 90, + statements: 0, + }, + }, +}; diff --git a/packages/logger/package.json b/packages/logger/package.json new file mode 100644 index 000000000..0f84fd1ea --- /dev/null +++ b/packages/logger/package.json @@ -0,0 +1,58 @@ +{ + "name": "@tma.js/logger", + "version": "0.0.0", + "description": "Logger implementation used across @tma.js packages.", + "author": "Vladislav Kibenko ", + "homepage": "https://github.com/Telegram-Mini-Apps/tma.js#readme", + "repository": { + "type": "git", + "url": "git@github.com:Telegram-Mini-Apps/tma.js.git", + "directory": "packages/logger" + }, + "bugs": { + "url": "https://github.com/Telegram-Mini-Apps/tma.js/issues" + }, + "keywords": [ + "telegram-mini-apps", + "logger", + "typescript" + ], + "license": "MIT", + "type": "module", + "sideEffects": false, + "files": [ + "dist", + "src" + ], + "main": "dist/lib/index.cjs", + "browser": "dist/lib/browser.js", + "module": "dist/lib/index.mjs", + "types": "dist/types/index.d.ts", + "exports": { + ".": { + "types": "./dist/types/index.d.ts", + "import": "./dist/lib/index.mjs", + "require": "./dist/lib/index.cjs", + "default": "./dist/lib/index.cjs" + }, + "./*": { + "types": "./dist/types/*.d.ts", + "import": "./dist/lib/*.mjs", + "require": "./dist/lib/*.cjs", + "default": "./dist/lib/*.cjs" + } + }, + "scripts": { + "test": "jest", + "lint": "eslint -c .eslintrc.cjs src/**/* __tests__/**/*", + "build": "rimraf dist && rollup --config rollup.config.js" + }, + "devDependencies": { + "tsconfig": "workspace:*", + "jest-config-custom": "workspace:*", + "eslint-config-custom": "workspace:*" + }, + "publishConfig": { + "access": "public" + } +} diff --git a/packages/logger/rollup.config.js b/packages/logger/rollup.config.js new file mode 100644 index 000000000..97e0a9fed --- /dev/null +++ b/packages/logger/rollup.config.js @@ -0,0 +1,35 @@ +import typescript from '@rollup/plugin-typescript'; +import terser from '@rollup/plugin-terser'; +import { defineConfig } from 'rollup'; +import { createRequire } from 'node:module'; + +const require = createRequire(import.meta.url); +const pkg = require('./package.json'); + +const input = 'src/index.ts'; + +export default [ + defineConfig({ + input, + output: [ + { file: pkg.main, format: 'commonjs', sourcemap: true }, + { file: pkg.browser, format: 'iife', name: '@tma.js/logger', sourcemap: true }, + { file: pkg.module, format: 'esm', sourcemap: true }, + ], + plugins: [typescript({ tsconfig: './tsconfig.build.json' }), terser()], + }), + + defineConfig({ + input, + output: { file: pkg.types }, + plugins: [typescript({ + tsconfig: './tsconfig.build.json', + compilerOptions: { + declaration: true, + emitDeclarationOnly: true, + sourceMap: false, + inlineSources: false, + }, + }), terser()], + }), +]; diff --git a/packages/logger/src/index.ts b/packages/logger/src/index.ts new file mode 100644 index 000000000..306b05038 --- /dev/null +++ b/packages/logger/src/index.ts @@ -0,0 +1 @@ +export * from './logging.js'; diff --git a/packages/utils/src/logging.ts b/packages/logger/src/logging.ts similarity index 100% rename from packages/utils/src/logging.ts rename to packages/logger/src/logging.ts diff --git a/packages/logger/tsconfig.build.json b/packages/logger/tsconfig.build.json new file mode 100644 index 000000000..c21cdee38 --- /dev/null +++ b/packages/logger/tsconfig.build.json @@ -0,0 +1,15 @@ +{ + "extends": "tsconfig/base.json", + "compilerOptions": { + "lib": [ + "esnext", + "dom" + ], + "outDir": "dist", + "module": "ESNext", + "target": "ESNext" + }, + "include": [ + "src" + ] +} \ No newline at end of file diff --git a/packages/logger/tsconfig.eslint.json b/packages/logger/tsconfig.eslint.json new file mode 100644 index 000000000..3020c6044 --- /dev/null +++ b/packages/logger/tsconfig.eslint.json @@ -0,0 +1,10 @@ +{ + "extends": [ + "./tsconfig.json" + ], + "include": [ + "src", + "__tests__", + "./*.js" + ] +} \ No newline at end of file diff --git a/packages/logger/tsconfig.json b/packages/logger/tsconfig.json new file mode 100644 index 000000000..0c7e3efd2 --- /dev/null +++ b/packages/logger/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "./tsconfig.build.json", + "include": [ + "src", + "__tests__" + ] +} \ No newline at end of file From 2f052c2b1f8a6347f565f9d69655f89f03570dea Mon Sep 17 00:00:00 2001 From: Vladislav Kibenko Date: Fri, 29 Sep 2023 23:58:00 +0300 Subject: [PATCH 3/8] feat(packages): rename to tma.js. Update docs, links and deps --- apps/react-sdk-example/package.json | 2 +- apps/react-sdk-example/src/Root.tsx | 2 +- apps/solid-sdk-example/package.json | 2 +- apps/solid-sdk-example/src/Root.tsx | 2 +- packages/bridge/CHANGELOG.md | 4 +- packages/bridge/README.md | 14 +-- packages/bridge/package.json | 23 +++-- packages/bridge/rollup.config.js | 4 +- packages/bridge/src/env.ts | 2 +- packages/bridge/src/events/emitter.ts | 8 +- packages/bridge/src/events/events.ts | 28 +++--- packages/bridge/src/events/onTelegramEvent.ts | 2 +- packages/bridge/src/events/parsing.ts | 2 +- packages/bridge/src/events/payloads.ts | 2 +- packages/bridge/src/globals.ts | 2 +- packages/bridge/src/methods/params.ts | 46 +++++----- packages/bridge/src/request.ts | 4 +- packages/bridge/src/supports.ts | 2 +- packages/colors/CHANGELOG.md | 2 +- packages/colors/README.md | 16 ++-- packages/colors/package.json | 12 ++- packages/event-emitter/CHANGELOG.md | 2 +- packages/event-emitter/README.md | 14 +-- packages/event-emitter/package.json | 14 ++- packages/event-emitter/rollup.config.js | 2 +- packages/event-emitter/src/types.ts | 2 +- packages/init-data-node/CHANGELOG.md | 2 +- packages/init-data-node/README.md | 14 +-- packages/init-data-node/package.json | 18 ++-- packages/init-data-node/rollup.config.js | 2 +- packages/init-data-node/src/index.ts | 2 +- packages/init-data/CHANGELOG.md | 2 +- packages/init-data/README.md | 14 +-- packages/init-data/package.json | 17 ++-- packages/init-data/rollup.config.js | 6 +- packages/init-data/src/parsing.ts | 2 +- packages/init-data/src/types.ts | 6 +- packages/parsing/CHANGELOG.md | 2 +- packages/parsing/README.md | 14 +-- packages/parsing/package.json | 16 ++-- packages/parsing/rollup.config.js | 6 +- packages/parsing/src/ValueParser.ts | 2 +- packages/parsing/src/parsers.ts | 2 +- packages/parsing/src/shared.ts | 2 +- packages/sdk-react/CHANGELOG.md | 2 +- packages/sdk-react/README.md | 14 +-- packages/sdk-react/package.json | 16 ++-- packages/sdk-react/rollup.config.js | 6 +- .../sdk-react/src/lib/back-button/types.ts | 2 +- .../src/lib/closing-behavior/types.ts | 2 +- packages/sdk-react/src/lib/cloud-storage.tsx | 2 +- .../src/lib/haptic-feedback/types.ts | 2 +- packages/sdk-react/src/lib/hooks.ts | 2 +- packages/sdk-react/src/lib/init-data/types.ts | 2 +- .../sdk-react/src/lib/launch-params/types.ts | 2 +- .../src/lib/launch-params/useLaunchParams.ts | 2 +- .../sdk-react/src/lib/main-button/types.ts | 2 +- packages/sdk-react/src/lib/popup/types.ts | 2 +- .../sdk-react/src/lib/qr-scanner/types.ts | 2 +- .../sdk-react/src/lib/theme-params/types.ts | 2 +- packages/sdk-react/src/lib/viewport/types.ts | 2 +- packages/sdk-react/src/lib/web-app/types.ts | 2 +- .../sdk-react/src/provider/SDKProvider.tsx | 2 +- packages/sdk-react/src/provider/types.ts | 2 +- packages/sdk-solid/CHANGELOG.md | 2 +- packages/sdk-solid/README.md | 14 +-- packages/sdk-solid/package.json | 16 ++-- packages/sdk-solid/src/SDKProvider.tsx | 2 +- packages/sdk-solid/src/index.ts | 2 +- packages/sdk-solid/src/types.ts | 2 +- packages/sdk/CHANGELOG.md | 2 +- packages/sdk/README.md | 12 +-- .../__tests__/components/Popup/Popup.test.ts | 2 +- .../sdk/__tests__/components/WebApp/WebApp.ts | 2 +- packages/sdk/package.json | 20 ++--- packages/sdk/rollup.config.js | 14 +-- .../src/components/BackButton/BackButton.ts | 6 +- .../ClosingBehaviour/ClosingBehaviour.ts | 4 +- .../components/CloudStorage/CloudStorage.ts | 6 +- .../HapticFeedback/HapticFeedback.ts | 4 +- .../sdk/src/components/InitData/InitData.ts | 4 +- .../src/components/MainButton/MainButton.ts | 6 +- .../sdk/src/components/MainButton/types.ts | 2 +- packages/sdk/src/components/Popup/Popup.ts | 6 +- packages/sdk/src/components/Popup/utils.ts | 2 +- .../sdk/src/components/QRScanner/QRScanner.ts | 6 +- .../src/components/ThemeParams/ThemeParams.ts | 8 +- .../sdk/src/components/ThemeParams/types.ts | 2 +- .../sdk/src/components/Viewport/Viewport.ts | 4 +- packages/sdk/src/components/WebApp/WebApp.ts | 8 +- packages/sdk/src/components/WebApp/types.ts | 4 +- .../sdk/src/init/creators/createBackButton.ts | 2 +- .../init/creators/createClosingBehavior.ts | 2 +- .../sdk/src/init/creators/createMainButton.ts | 4 +- .../sdk/src/init/creators/createPostEvent.ts | 4 +- .../sdk/src/init/creators/createViewport.ts | 2 +- .../sdk/src/init/creators/createWebApp.ts | 4 +- packages/sdk/src/init/css.ts | 2 +- packages/sdk/src/init/init.ts | 4 +- packages/sdk/src/init/types.ts | 2 +- packages/sdk/src/launch-params.ts | 4 +- packages/sdk/src/state/State.ts | 2 +- packages/sdk/src/storage.ts | 4 +- packages/sdk/src/supports.ts | 8 +- packages/sdk/src/theme-params.ts | 4 +- packages/sdk/src/types.ts | 2 +- packages/util-types/CHANGELOG.md | 2 +- packages/util-types/README.md | 16 ++-- packages/util-types/package.json | 12 ++- packages/utils/CHANGELOG.md | 2 +- packages/utils/README.md | 14 +-- packages/utils/package.json | 15 ++-- packages/utils/rollup.config.js | 2 +- packages/utils/src/index.ts | 1 - pnpm-lock.yaml | 90 +++++++++++++------ 115 files changed, 397 insertions(+), 383 deletions(-) diff --git a/apps/react-sdk-example/package.json b/apps/react-sdk-example/package.json index 98d41bc60..cae582fbd 100644 --- a/apps/react-sdk-example/package.json +++ b/apps/react-sdk-example/package.json @@ -12,7 +12,7 @@ "dependencies": { "react": "^18.2.0", "react-dom": "^18.2.0", - "@twa.js/sdk-react": "workspace:*" + "@tma.js/sdk-react": "workspace:*" }, "devDependencies": { "@types/react": "^18.2.15", diff --git a/apps/react-sdk-example/src/Root.tsx b/apps/react-sdk-example/src/Root.tsx index 8b739f060..2c21a0d3b 100644 --- a/apps/react-sdk-example/src/Root.tsx +++ b/apps/react-sdk-example/src/Root.tsx @@ -1,5 +1,5 @@ import { PropsWithChildren, useMemo } from 'react'; -import { SDKProvider, useSDK, useInitData } from '@twa.js/sdk-react'; +import { SDKProvider, useSDK, useInitData } from '@tma.js/sdk-react'; /** * Displays current application init data. diff --git a/apps/solid-sdk-example/package.json b/apps/solid-sdk-example/package.json index a981d4d8e..8911bc09d 100644 --- a/apps/solid-sdk-example/package.json +++ b/apps/solid-sdk-example/package.json @@ -24,7 +24,7 @@ "vite-plugin-solid": "^2.7.0" }, "dependencies": { - "@twa.js/sdk-solid": "workspace:*", + "@tma.js/sdk-solid": "workspace:*", "solid-js": "^1.7.6" } } diff --git a/apps/solid-sdk-example/src/Root.tsx b/apps/solid-sdk-example/src/Root.tsx index 95c0c5a82..da8e35238 100644 --- a/apps/solid-sdk-example/src/Root.tsx +++ b/apps/solid-sdk-example/src/Root.tsx @@ -1,5 +1,5 @@ import { createMemo, Switch, Match, ParentProps } from 'solid-js'; -import { SDKProvider, useSDK, useSDKContext } from '@twa.js/sdk-solid'; +import { SDKProvider, useSDK, useSDKContext } from '@tma.js/sdk-solid'; /** * Displays current application init data. diff --git a/packages/bridge/CHANGELOG.md b/packages/bridge/CHANGELOG.md index 2e05902cd..c200f3918 100644 --- a/packages/bridge/CHANGELOG.md +++ b/packages/bridge/CHANGELOG.md @@ -1,4 +1,4 @@ -# @twa.js/bridge +# @tma.js/bridge ## 1.3.1 @@ -16,7 +16,7 @@ - Updated dependencies [53d1717] - Updated dependencies [251c527] - - @twa.js/utils@0.5.1 + - @tma.js/utils@0.5.1 - @twa.js/event-emitter@0.0.1 - @twa.js/util-types@0.0.1 - @twa.js/parsing@0.0.1 diff --git a/packages/bridge/README.md b/packages/bridge/README.md index baab4279b..e1805de1f 100644 --- a/packages/bridge/README.md +++ b/packages/bridge/README.md @@ -1,18 +1,18 @@ -# @twa.js/bridge +# @tma.js/bridge -[code-link]: https://github.com/Telegram-Web-Apps/twa.js/tree/master/packages/bridge +[code-link]: https://github.com/Telegram-Web-Apps/tma.js/tree/master/packages/bridge [code-badge]: https://img.shields.io/badge/source-black?logo=github -[docs-link]: https://docs.twa.dev/docs/libraries/twa-js-bridge +[docs-link]: https://docs.telegram-mini-apps.com/docs/libraries/twa-js-bridge [docs-badge]: https://img.shields.io/badge/documentation-blue?logo=gitbook&logoColor=white -[npm-link]: https://npmjs.com/package/@twa.js/bridge +[npm-link]: https://npmjs.com/package/@tma.js/bridge -[npm-badge]: https://img.shields.io/npm/v/@twa.js/bridge?logo=npm +[npm-badge]: https://img.shields.io/npm/v/@tma.js/bridge?logo=npm -[size-badge]: https://img.shields.io/bundlephobia/minzip/@twa.js/bridge +[size-badge]: https://img.shields.io/bundlephobia/minzip/@tma.js/bridge [![npm-badge]][npm-link] ![size-badge] @@ -25,4 +25,4 @@ data difference problems to protect developers code and save their time. This library is a part of TypeScript packages ecosystem around Telegram Web Apps. You can learn more about this package in this -[documentation](https://docs.twa.dev/docs/libraries/twa-js-bridge). +[documentation](https://docs.telegram-mini-apps.com/docs/libraries/twa-js-bridge). diff --git a/packages/bridge/package.json b/packages/bridge/package.json index f40dacd1b..961d75e8f 100644 --- a/packages/bridge/package.json +++ b/packages/bridge/package.json @@ -1,21 +1,19 @@ { - "name": "@twa.js/bridge", + "name": "@tma.js/bridge", "version": "1.3.1", "description": "Communication layer between Telegram and frontend applications.", "author": "Vladislav Kibenko ", - "homepage": "https://github.com/Telegram-Web-Apps/twa.js#readme", + "homepage": "https://github.com/Telegram-Mini-Apps/tma.js#readme", "repository": { "type": "git", - "url": "git+https://github.com/Telegram-Web-Apps/twa.js.git", + "url": "git+https://github.com/Telegram-Mini-Apps/tma.js.git", "directory": "packages/bridge" }, "bugs": { - "url": "https://github.com/Telegram-Web-Apps/twa.js/issues" + "url": "https://github.com/Telegram-Mini-Apps/tma.js/issues" }, "keywords": [ - "telegram", - "telegram-web-apps", - "twa", + "telegram-mini-apps", "typescript", "bridge", "webview" @@ -51,11 +49,12 @@ "build": "rimraf dist && rollup --config rollup.config.js" }, "dependencies": { - "@twa.js/utils": "workspace:*", - "@twa.js/event-emitter": "workspace:*", - "@twa.js/colors": "workspace:*", - "@twa.js/parsing": "workspace:*", - "@twa.js/util-types": "workspace:*" + "@tma.js/utils": "workspace:*", + "@tma.js/logger": "workspace:*", + "@tma.js/event-emitter": "workspace:*", + "@tma.js/colors": "workspace:*", + "@tma.js/parsing": "workspace:*", + "@tma.js/util-types": "workspace:*" }, "devDependencies": { "tsconfig": "workspace:*", diff --git a/packages/bridge/rollup.config.js b/packages/bridge/rollup.config.js index 27a181a98..f78e9fe55 100644 --- a/packages/bridge/rollup.config.js +++ b/packages/bridge/rollup.config.js @@ -9,7 +9,7 @@ const pkg = require('./package.json'); const input = 'src/index.ts'; -const external = ['@twa.js/utils', '@twa.js/parsing', '@twa.js/event-emitter']; +const external = ['@tma.js/utils', '@tma.js/parsing', '@tma.js/event-emitter', '@tma.js/logger']; export default [ // CJS, ESM. @@ -29,7 +29,7 @@ export default [ output: { file: pkg.browser, format: 'iife', - name: 'TwaBridge', + name: '@tma.js/bridge', sourcemap: true, }, plugins: [typescript({ tsconfig: './tsconfig.build.json' }), nodeResolve(), terser()], diff --git a/packages/bridge/src/env.ts b/packages/bridge/src/env.ts index 83f44daf4..8f078b92f 100644 --- a/packages/bridge/src/env.ts +++ b/packages/bridge/src/env.ts @@ -1,4 +1,4 @@ -import { isRecord } from '@twa.js/utils'; +import { isRecord } from '@tma.js/utils'; type AnyFunc = (...args: unknown[]) => unknown; diff --git a/packages/bridge/src/events/emitter.ts b/packages/bridge/src/events/emitter.ts index d2c454b04..6187d529e 100644 --- a/packages/bridge/src/events/emitter.ts +++ b/packages/bridge/src/events/emitter.ts @@ -1,5 +1,5 @@ -import { EventEmitter as UtilEventEmitter } from '@twa.js/event-emitter'; -import { string } from '@twa.js/parsing'; +import { EventEmitter as UtilEventEmitter } from '@tma.js/event-emitter'; +import { string } from '@tma.js/parsing'; import { log } from '../globals.js'; import { @@ -33,7 +33,7 @@ export function createEmitter(): EventEmitter { // Desktop version of Telegram is sometimes not sending the viewport_changed // event. For example, when main button is shown. That's why we should // add our own listener to make sure, viewport information is always fresh. - // Issue: https://github.com/Telegram-Web-Apps/twa.js/issues/10 + // Issue: https://github.com/Telegram-Web-Apps/tma.js/issues/10 window.addEventListener('resize', () => { emitter.emit('viewport_changed', { width: window.innerWidth, @@ -58,7 +58,7 @@ export function createEmitter(): EventEmitter { case 'popup_closed': // FIXME: Payloads are different on different platforms. - // Issue: https://github.com/Telegram-Web-Apps/twa.js/issues/2 + // Issue: https://github.com/Telegram-Web-Apps/tma.js/issues/2 if ( // Sent on desktop. eventData === undefined diff --git a/packages/bridge/src/events/events.ts b/packages/bridge/src/events/events.ts index 31ed3b2d4..af2b654dd 100644 --- a/packages/bridge/src/events/events.ts +++ b/packages/bridge/src/events/events.ts @@ -3,8 +3,8 @@ import type { EventName as UtilEventName, EventListener as UtilEventListener, EventParams as UtilEventParams, AnySubscribeListener, -} from '@twa.js/event-emitter'; -import type { IsNever, Not } from '@twa.js/util-types'; +} from '@tma.js/event-emitter'; +import type { IsNever, Not } from '@tma.js/util-types'; import type { ClipboardTextReceivedPayload, @@ -20,19 +20,19 @@ import type { /** * Map where key is known event name, and value is its listener. - * @see Documentation https://docs.twa.dev/docs/apps-communication/events + * @see Documentation https://docs.telegram-mini-apps.com/docs/apps-communication/events */ export interface Events { /** * User clicked back button. - * @see https://docs.twa.dev/docs/apps-communication/events#back_button_pressed + * @see https://docs.telegram-mini-apps.com/docs/apps-communication/events#back_button_pressed */ back_button_pressed: () => void; /** * Text was extracted from clipboard. * @param payload - event information. - * @see https://docs.twa.dev/docs/apps-communication/events#clipboard_text_received + * @see https://docs.telegram-mini-apps.com/docs/apps-communication/events#clipboard_text_received */ clipboard_text_received: (payload: ClipboardTextReceivedPayload) => void; @@ -46,13 +46,13 @@ export interface Events { /** * Invoice was closed. * @param payload - invoice close information. - * @see https://docs.twa.dev/docs/apps-communication/events#invoice_closed + * @see https://docs.telegram-mini-apps.com/docs/apps-communication/events#invoice_closed */ invoice_closed: (payload: InvoiceClosedPayload) => void; /** * User clicked main button. - * @see https://docs.twa.dev/docs/apps-communication/events#main_button_pressed + * @see https://docs.telegram-mini-apps.com/docs/apps-communication/events#main_button_pressed */ main_button_pressed: () => void; @@ -66,32 +66,32 @@ export interface Events { /** * Popup was closed. * @param payload - popup close information. - * @see https://docs.twa.dev/docs/apps-communication/events#main_button_pressed + * @see https://docs.telegram-mini-apps.com/docs/apps-communication/events#main_button_pressed */ popup_closed: (payload: PopupClosedPayload) => void; /** * Data from QR was extracted. - * @see https://docs.twa.dev/docs/apps-communication/events#qr_text_received + * @see https://docs.telegram-mini-apps.com/docs/apps-communication/events#qr_text_received */ qr_text_received: (payload: QrTextReceivedPayload) => void; /** * QR scanner was closed. - * @see https://docs.twa.dev/docs/apps-communication/events#scan_qr_popup_closed + * @see https://docs.telegram-mini-apps.com/docs/apps-communication/events#scan_qr_popup_closed */ scan_qr_popup_closed: () => void; /** * Telegram requested to update current application style. * @param html - `style` tag inner HTML. - * @see https://docs.twa.dev/docs/apps-communication/events#set_custom_style + * @see https://docs.telegram-mini-apps.com/docs/apps-communication/events#set_custom_style */ set_custom_style: (html: string) => void; /** * Occurs when the Settings item in context menu is pressed. - * @see https://docs.twa.dev/docs/apps-communication/events#settings_button_pressed + * @see https://docs.telegram-mini-apps.com/docs/apps-communication/events#settings_button_pressed */ settings_button_pressed: () => void; @@ -99,14 +99,14 @@ export interface Events { * Occurs whenever theme settings are changed in the user's Telegram app * (including switching to night mode). * @param payload - theme information. - * @see https://docs.twa.dev/docs/apps-communication/events#theme_changed + * @see https://docs.telegram-mini-apps.com/docs/apps-communication/events#theme_changed */ theme_changed: (payload: ThemeChangedPayload) => void; /** * Viewport was changed. * @param payload - viewport information. - * @see https://docs.twa.dev/docs/apps-communication/events#viewport_changed + * @see https://docs.telegram-mini-apps.com/docs/apps-communication/events#viewport_changed */ viewport_changed: (payload: ViewportChangedPayload) => void; diff --git a/packages/bridge/src/events/onTelegramEvent.ts b/packages/bridge/src/events/onTelegramEvent.ts index 522f73632..6dd7c3fcc 100644 --- a/packages/bridge/src/events/onTelegramEvent.ts +++ b/packages/bridge/src/events/onTelegramEvent.ts @@ -1,4 +1,4 @@ -import { json, string } from '@twa.js/parsing'; +import { json, string } from '@tma.js/parsing'; /** * Extracts event data from native application event. diff --git a/packages/bridge/src/events/parsing.ts b/packages/bridge/src/events/parsing.ts index 04805042d..62ef0729d 100644 --- a/packages/bridge/src/events/parsing.ts +++ b/packages/bridge/src/events/parsing.ts @@ -4,7 +4,7 @@ import { boolean, json, rgb, -} from '@twa.js/parsing'; +} from '@tma.js/parsing'; import type { ClipboardTextReceivedPayload, CustomMethodInvokedPayload, diff --git a/packages/bridge/src/events/payloads.ts b/packages/bridge/src/events/payloads.ts index d4fe503e6..c8731570a 100644 --- a/packages/bridge/src/events/payloads.ts +++ b/packages/bridge/src/events/payloads.ts @@ -1,4 +1,4 @@ -import type { RGB } from '@twa.js/colors'; +import type { RGB } from '@tma.js/colors'; import type { RequestId } from '../shared.js'; diff --git a/packages/bridge/src/globals.ts b/packages/bridge/src/globals.ts index d995f8c4a..46e49a726 100644 --- a/packages/bridge/src/globals.ts +++ b/packages/bridge/src/globals.ts @@ -1,4 +1,4 @@ -import { log as utilLog } from '@twa.js/utils'; +import { log as utilLog } from '@tma.js/logger'; let currentDebug = false; let currentTargetOrigin = 'https://web.telegram.org'; diff --git a/packages/bridge/src/methods/params.ts b/packages/bridge/src/methods/params.ts index 82eaf2be6..3de57fc20 100644 --- a/packages/bridge/src/methods/params.ts +++ b/packages/bridge/src/methods/params.ts @@ -1,5 +1,5 @@ -import type { RGB } from '@twa.js/colors'; -import type { IsNever, Not, UnionKeys } from '@twa.js/util-types'; +import type { RGB } from '@tma.js/colors'; +import type { IsNever, Not, UnionKeys } from '@tma.js/util-types'; import type { PopupParams } from './popup.js'; import type { AnyHapticFeedbackParams } from './haptic.js'; @@ -19,40 +19,40 @@ type CreateParams

= never> = { /** * Describes list of events and their parameters that could be posted by * Bridge. - * @see https://docs.twa.dev/docs/apps-communication/methods + * @see https://docs.telegram-mini-apps.com/docs/apps-communication/methods */ export interface MethodsParams { /** * Notifies parent iframe about current frame is ready. - * @see https://docs.twa.dev/docs/apps-communication/methods#iframe_ready + * @see https://docs.telegram-mini-apps.com/docs/apps-communication/methods#iframe_ready * @since 6.0 */ iframe_ready: CreateParams; /** * Closes WebApp. - * @see https://docs.twa.dev/docs/apps-communication/methods#web_app_close + * @see https://docs.telegram-mini-apps.com/docs/apps-communication/methods#web_app_close * @since 6.0 */ web_app_close: CreateParams; /** * Closes QR scanner. - * @see https://docs.twa.dev/docs/apps-communication/methods#web_app_close_scan_qr_popup + * @see https://docs.telegram-mini-apps.com/docs/apps-communication/methods#web_app_close_scan_qr_popup * @since 6.4 */ web_app_close_scan_qr_popup: CreateParams; /** * Sends data to bot. - * @see https://docs.twa.dev/docs/apps-communication/methods#web_app_data_send + * @see https://docs.telegram-mini-apps.com/docs/apps-communication/methods#web_app_data_send * @since 6.0 */ web_app_data_send: CreateParams<{ data: string }>; /** * Expands Web App. - * @see https://docs.twa.dev/docs/apps-communication/methods#web_app_expand + * @see https://docs.telegram-mini-apps.com/docs/apps-communication/methods#web_app_expand * @since 6.0 */ web_app_expand: CreateParams; @@ -65,14 +65,14 @@ export interface MethodsParams { /** * Opens new invoice. - * @see https://docs.twa.dev/docs/apps-communication/methods#web_app_open_invoice + * @see https://docs.telegram-mini-apps.com/docs/apps-communication/methods#web_app_open_invoice * @since 6.1 */ web_app_open_invoice: CreateParams<{ slug: string }>; /** * Opens link in default browser. Doesn't close application. - * @see https://docs.twa.dev/docs/apps-communication/methods#web_app_open_link + * @see https://docs.telegram-mini-apps.com/docs/apps-communication/methods#web_app_open_link * @since 6.0 */ web_app_open_link: CreateParams<{ @@ -89,35 +89,35 @@ export interface MethodsParams { /** * Opens new popup. - * @see https://docs.twa.dev/docs/apps-communication/methods#web_app_open_popup + * @see https://docs.telegram-mini-apps.com/docs/apps-communication/methods#web_app_open_popup * @since 6.2 */ web_app_open_popup: CreateParams; /** * Opens QR scanner. - * @see https://docs.twa.dev/docs/apps-communication/methods#web_app_open_scan_qr_popup + * @see https://docs.telegram-mini-apps.com/docs/apps-communication/methods#web_app_open_scan_qr_popup * @since 6.4 */ web_app_open_scan_qr_popup: CreateParams<{ text?: string }>; /** * Opens link which has format like "https://t.me/*". - * @see https://docs.twa.dev/docs/apps-communication/methods#web_app_open_tg_link + * @see https://docs.telegram-mini-apps.com/docs/apps-communication/methods#web_app_open_tg_link * @since 6.1 */ web_app_open_tg_link: CreateParams<{ path_full: string }>; /** * Reads text from clipboard. - * @see https://docs.twa.dev/docs/apps-communication/methods#web_app_read_text_from_clipboard + * @see https://docs.telegram-mini-apps.com/docs/apps-communication/methods#web_app_read_text_from_clipboard * @since 6.4 */ web_app_read_text_from_clipboard: CreateParams<{ req_id: RequestId }>; /** * Notifies Telegram about current application is ready to be shown. - * @see https://docs.twa.dev/docs/apps-communication/methods#web_app_ready + * @see https://docs.telegram-mini-apps.com/docs/apps-communication/methods#web_app_ready * @since 6.0 */ web_app_ready: CreateParams; @@ -130,14 +130,14 @@ export interface MethodsParams { /** * Requests current theme from Telegram. - * @see https://docs.twa.dev/docs/apps-communication/methods#web_app_request_theme + * @see https://docs.telegram-mini-apps.com/docs/apps-communication/methods#web_app_request_theme * @since 6.0 */ web_app_request_theme: CreateParams; /** * Requests current viewport information from Telegram. - * @see https://docs.twa.dev/docs/apps-communication/methods#web_app_request_viewport + * @see https://docs.telegram-mini-apps.com/docs/apps-communication/methods#web_app_request_viewport * @since 6.0 */ web_app_request_viewport: CreateParams; @@ -150,14 +150,14 @@ export interface MethodsParams { /** * Updates current background color. - * @see https://docs.twa.dev/docs/apps-communication/methods#web_app_set_background_color + * @see https://docs.telegram-mini-apps.com/docs/apps-communication/methods#web_app_set_background_color * @since 6.1 */ web_app_set_background_color: CreateParams<{ color: string }>; /** * Updates current header color. - * @see https://docs.twa.dev/docs/apps-communication/methods#web_app_set_header_color + * @see https://docs.telegram-mini-apps.com/docs/apps-communication/methods#web_app_set_header_color * @since 6.1 */ web_app_set_header_color: CreateParams< @@ -171,21 +171,21 @@ export interface MethodsParams { /** * Updates current information about back button. - * @see https://docs.twa.dev/docs/apps-communication/methods#web_app_setup_back_button + * @see https://docs.telegram-mini-apps.com/docs/apps-communication/methods#web_app_setup_back_button * @since 6.1 */ web_app_setup_back_button: CreateParams<{ is_visible: boolean }>; /** * Changes current closing confirmation requirement status. - * @see https://docs.twa.dev/docs/apps-communication/methods#web_app_setup_closing_behavior + * @see https://docs.telegram-mini-apps.com/docs/apps-communication/methods#web_app_setup_closing_behavior * @since 6.0 */ web_app_setup_closing_behavior: CreateParams<{ need_confirmation: boolean }>; /** * Updates current information about main button. - * @see https://docs.twa.dev/docs/apps-communication/methods#web_app_setup_main_button + * @see https://docs.telegram-mini-apps.com/docs/apps-communication/methods#web_app_setup_main_button * @since 6.0 */ web_app_setup_main_button: CreateParams<{ @@ -199,7 +199,7 @@ export interface MethodsParams { /** * Generates haptic feedback event. - * @see https://docs.twa.dev/docs/apps-communication/methods#web_app_trigger_haptic_feedback + * @see https://docs.telegram-mini-apps.com/docs/apps-communication/methods#web_app_trigger_haptic_feedback * @since 6.1 */ web_app_trigger_haptic_feedback: CreateParams; diff --git a/packages/bridge/src/request.ts b/packages/bridge/src/request.ts index 6d77b0825..2b0d71cbd 100644 --- a/packages/bridge/src/request.ts +++ b/packages/bridge/src/request.ts @@ -1,6 +1,6 @@ -import { withTimeout, isRecord } from '@twa.js/utils'; +import { withTimeout, isRecord } from '@tma.js/utils'; -import type { And, If, IsNever } from '@twa.js/util-types'; +import type { And, If, IsNever } from '@tma.js/util-types'; import { postEvent as defaultPostEvent, type PostEvent } from './methods/postEvent.js'; import { on, type EventName, type EventParams, type EventHasParams } from './events/index.js'; diff --git a/packages/bridge/src/supports.ts b/packages/bridge/src/supports.ts index d7b7e9f65..357904416 100644 --- a/packages/bridge/src/supports.ts +++ b/packages/bridge/src/supports.ts @@ -1,4 +1,4 @@ -import { compareVersions, type Version } from '@twa.js/utils'; +import { compareVersions, type Version } from '@tma.js/utils'; import type { HasCheckSupportMethodParam, diff --git a/packages/colors/CHANGELOG.md b/packages/colors/CHANGELOG.md index 322d5ca96..22662fb7c 100644 --- a/packages/colors/CHANGELOG.md +++ b/packages/colors/CHANGELOG.md @@ -1,4 +1,4 @@ -# @twa.js/colors +# @tma.js/colors ## 0.0.1 diff --git a/packages/colors/README.md b/packages/colors/README.md index da063440c..5e7cfedbd 100644 --- a/packages/colors/README.md +++ b/packages/colors/README.md @@ -1,28 +1,28 @@ -# @twa.js/colors +# @tma.js/colors -[npm-badge]: https://img.shields.io/npm/v/@twa.js/colors?logo=npm +[npm-badge]: https://img.shields.io/npm/v/@tma.js/colors?logo=npm -[npm-link]: https://npmjs.com/package/@twa.js/colors +[npm-link]: https://npmjs.com/package/@tma.js/colors -[size-badge]: https://img.shields.io/bundlephobia/minzip/@twa.js/colors +[size-badge]: https://img.shields.io/bundlephobia/minzip/@tma.js/colors [![NPM][npm-badge]][npm-link] ![Size][size-badge] -Color utilities used across @twa.js packages. +Color utilities used across @tma.js packages. This library is a part of TypeScript packages ecosystem around Telegram Web Apps. To see full documentation and other libraries, please, visit -[this](https://docs.twa.dev/) link. +[this](https://docs.telegram-mini-apps.com/) link. ## Installation ```bash -npm i @twa.js/colors +npm i @tma.js/colors ``` or ```bash -yarn add @twa.js/colors +yarn add @tma.js/colors ``` diff --git a/packages/colors/package.json b/packages/colors/package.json index 2f14eaf39..f7c60ec10 100644 --- a/packages/colors/package.json +++ b/packages/colors/package.json @@ -1,21 +1,19 @@ { - "name": "@twa.js/colors", + "name": "@tma.js/colors", "version": "0.0.1", "description": "Utilities connected with colors.", "author": "Vladislav Kibenko ", - "homepage": "https://github.com/Telegram-Web-Apps/twa.js#readme", + "homepage": "https://github.com/Telegram-Mini-Apps/tma.js#readme", "repository": { "type": "git", - "url": "git@github.com:Telegram-Web-Apps/twa.js.git", + "url": "git@github.com:Telegram-Mini-Apps/tma.js.git", "directory": "packages/colors" }, "bugs": { - "url": "https://github.com/Telegram-Web-Apps/twa.js/issues" + "url": "https://github.com/Telegram-Mini-Apps/tma.js/issues" }, "keywords": [ - "telegram-web-apps", - "telegram", - "twa", + "telegram-mini-apps", "typescript" ], "license": "MIT", diff --git a/packages/event-emitter/CHANGELOG.md b/packages/event-emitter/CHANGELOG.md index 3f2fe9f14..bd8c666c9 100644 --- a/packages/event-emitter/CHANGELOG.md +++ b/packages/event-emitter/CHANGELOG.md @@ -1,4 +1,4 @@ -# @twa.js/event-emitter +# @tma.js/event-emitter ## 0.0.1 diff --git a/packages/event-emitter/README.md b/packages/event-emitter/README.md index da90e28f0..d557f6bed 100644 --- a/packages/event-emitter/README.md +++ b/packages/event-emitter/README.md @@ -1,10 +1,10 @@ -# @twa.js/event-emitter +# @tma.js/event-emitter -[npm-badge]: https://img.shields.io/npm/v/@twa.js/event-emitter?logo=npm +[npm-badge]: https://img.shields.io/npm/v/@tma.js/event-emitter?logo=npm -[npm-link]: https://npmjs.com/package/@twa.js/event-emitter +[npm-link]: https://npmjs.com/package/@tma.js/event-emitter -[size-badge]: https://img.shields.io/bundlephobia/minzip/@twa.js/event-emitter +[size-badge]: https://img.shields.io/bundlephobia/minzip/@tma.js/event-emitter [![NPM][npm-badge]][npm-link] ![Size][size-badge] @@ -13,16 +13,16 @@ Telegram Mini Apps custom Event Emitter implementation. This library is a part of TypeScript packages ecosystem around Telegram Web Apps. To see full documentation and other libraries, please, visit -[this](https://docs.twa.dev/) link. +[this](https://docs.telegram-mini-apps.com/) link. ## Installation ```bash -npm i @twa.js/event-emitter +npm i @tma.js/event-emitter ``` or ```bash -yarn add @twa.js/event-emitter +yarn add @tma.js/event-emitter ``` diff --git a/packages/event-emitter/package.json b/packages/event-emitter/package.json index e0320ea18..8cfa79258 100644 --- a/packages/event-emitter/package.json +++ b/packages/event-emitter/package.json @@ -1,21 +1,19 @@ { - "name": "@twa.js/event-emitter", + "name": "@tma.js/event-emitter", "version": "0.0.1", "description": "Event emitter class implementation.", "author": "Vladislav Kibenko ", - "homepage": "https://github.com/Telegram-Web-Apps/twa.js#readme", + "homepage": "https://github.com/Telegram-Mini-Apps/tma.js#readme", "repository": { "type": "git", - "url": "git@github.com:Telegram-Web-Apps/twa.js.git", + "url": "git@github.com:Telegram-Mini-Apps/tma.js.git", "directory": "packages/event-emitter" }, "bugs": { - "url": "https://github.com/Telegram-Web-Apps/twa.js/issues" + "url": "https://github.com/Telegram-Mini-Apps/tma.js/issues" }, "keywords": [ - "telegram-web-apps", - "telegram", - "twa", + "telegram-mini-apps", "typescript" ], "license": "MIT", @@ -49,7 +47,7 @@ "build": "rimraf dist && rollup --config rollup.config.js" }, "dependencies": { - "@twa.js/util-types": "workspace:*" + "@tma.js/util-types": "workspace:*" }, "devDependencies": { "tsconfig": "workspace:*", diff --git a/packages/event-emitter/rollup.config.js b/packages/event-emitter/rollup.config.js index 87fd6e78f..8d5be25de 100644 --- a/packages/event-emitter/rollup.config.js +++ b/packages/event-emitter/rollup.config.js @@ -25,7 +25,7 @@ export default [ output: { file: pkg.browser, format: 'iife', - name: 'TwaEventEmitter', + name: '@tma.js/event-emitter', sourcemap: true, }, plugins: [typescript({ tsconfig: './tsconfig.build.json' }), nodeResolve(), terser()], diff --git a/packages/event-emitter/src/types.ts b/packages/event-emitter/src/types.ts index d9079abf3..fc3c80299 100644 --- a/packages/event-emitter/src/types.ts +++ b/packages/event-emitter/src/types.ts @@ -1,4 +1,4 @@ -import type { IsNever } from '@twa.js/util-types'; +import type { IsNever } from '@tma.js/util-types'; /** * Function accepting the list of passed arguments and returning nothing. diff --git a/packages/init-data-node/CHANGELOG.md b/packages/init-data-node/CHANGELOG.md index a8d844f87..11da10a79 100644 --- a/packages/init-data-node/CHANGELOG.md +++ b/packages/init-data-node/CHANGELOG.md @@ -1,4 +1,4 @@ -# @twa.js/init-data-node +# @tma.js/init-data-node ## 0.0.11 diff --git a/packages/init-data-node/README.md b/packages/init-data-node/README.md index e1e2fdb96..0ddd431bf 100644 --- a/packages/init-data-node/README.md +++ b/packages/init-data-node/README.md @@ -1,18 +1,18 @@ -# @twa.js/init-data-node +# @tma.js/init-data-node [code-badge]: https://img.shields.io/badge/source-black?logo=github -[code-link]: https://github.com/Telegram-Web-Apps/twa.js/tree/master/packages/init-data-node +[code-link]: https://github.com/Telegram-Mini-Apps/tma.js/tree/master/packages/init-data-node -[docs-link]: https://docs.twa.dev/docs/libraries/twa-js-init-data-node +[docs-link]: https://docs.telegram-mini-apps.com/docs/libraries/tma-js-init-data-node [docs-badge]: https://img.shields.io/badge/documentation-blue?logo=gitbook&logoColor=white -[npm-link]: https://npmjs.com/package/@twa.js/init-data-node +[npm-link]: https://npmjs.com/package/@tma.js/init-data-node -[npm-badge]: https://img.shields.io/npm/v/@twa.js/init-data-node?logo=npm +[npm-badge]: https://img.shields.io/npm/v/@tma.js/init-data-node?logo=npm -[size-badge]: https://img.shields.io/bundlephobia/minzip/@twa.js/init-data-node +[size-badge]: https://img.shields.io/bundlephobia/minzip/@tma.js/init-data-node [![NPM][npm-badge]][npm-link] ![Size][size-badge] @@ -24,4 +24,4 @@ allows init data validation and parsing, works in NodeJS. This library is a part of TypeScript packages ecosystem around Telegram Web Apps. You can learn more about this package in this -[documentation](https://docs.twa.dev/docs/libraries/twa-js-init-data-node). +[documentation](https://docs.telegram-mini-apps.com/docs/libraries/tma-js-init-data-node). diff --git a/packages/init-data-node/package.json b/packages/init-data-node/package.json index f2a7707e8..d9bd4a286 100644 --- a/packages/init-data-node/package.json +++ b/packages/init-data-node/package.json @@ -1,22 +1,22 @@ { - "name": "@twa.js/init-data-node", + "name": "@tma.js/init-data-node", "version": "0.0.11", "description": "TypeScript Node library to operate with Telegram init data.", "author": "Vladislav Kibenko ", - "homepage": "https://github.com/Telegram-Web-Apps/twa.js#readme", + "homepage": "https://github.com/Telegram-Mini-Apps/tma.js#readme", "repository": { "type": "git", - "url": "git@github.com:Telegram-Web-Apps/twa.js.git", + "url": "git@github.com:Telegram-Mini-Apps/tma.js.git", "directory": "packages/init-data-node" }, "bugs": { - "url": "https://github.com/Telegram-Web-Apps/twa.js/issues" + "url": "https://github.com/Telegram-Mini-Apps/tma.js/issues" }, "keywords": [ - "telegram", - "telegram-web-apps", - "twa", - "init-data" + "telegram-mini-apps", + "init-data", + "node", + "typescript" ], "license": "MIT", "type": "module", @@ -49,7 +49,7 @@ "build": "rimraf dist && rollup --config rollup.config.js" }, "dependencies": { - "@twa.js/init-data": "workspace:*" + "@tma.js/init-data": "workspace:*" }, "devDependencies": { "@types/node": "^16.0.0", diff --git a/packages/init-data-node/rollup.config.js b/packages/init-data-node/rollup.config.js index 1420e3538..7292475a3 100644 --- a/packages/init-data-node/rollup.config.js +++ b/packages/init-data-node/rollup.config.js @@ -7,7 +7,7 @@ const require = createRequire(import.meta.url); const pkg = require('./package.json'); const input = 'src/index.ts'; -const external = ['@twa.js/init-data', 'crypto', 'url']; +const external = ['@tma.js/init-data', 'crypto', 'url']; export default [ defineConfig({ diff --git a/packages/init-data-node/src/index.ts b/packages/init-data-node/src/index.ts index cdfe42ea8..1659fe2e1 100644 --- a/packages/init-data-node/src/index.ts +++ b/packages/init-data-node/src/index.ts @@ -1,3 +1,3 @@ -export * from '@twa.js/init-data'; +export * from '@tma.js/init-data'; export * from './validation.js'; diff --git a/packages/init-data/CHANGELOG.md b/packages/init-data/CHANGELOG.md index 1308f389e..a788822da 100644 --- a/packages/init-data/CHANGELOG.md +++ b/packages/init-data/CHANGELOG.md @@ -1,4 +1,4 @@ -# @twa.js/init-data +# @tma.js/init-data ## 0.2.13 diff --git a/packages/init-data/README.md b/packages/init-data/README.md index b32208260..48dfe66c8 100644 --- a/packages/init-data/README.md +++ b/packages/init-data/README.md @@ -1,18 +1,18 @@ -# @twa.js/init-data +# @tma.js/init-data -[code-link]: https://github.com/Telegram-Web-Apps/twa.js/tree/master/packages/init-data +[code-link]: https://github.com/Telegram-Mini-Apps/tma.js/tree/master/packages/init-data [code-badge]: https://img.shields.io/badge/source-black?logo=github -[docs-link]: https://docs.twa.dev/docs/libraries/twa-js-init-data +[docs-link]: https://docs.telegram-mini-apps.com/docs/libraries/tma-js-init-data [docs-badge]: https://img.shields.io/badge/documentation-blue?logo=gitbook&logoColor=white -[npm-link]: https://npmjs.com/package/@twa.js/init-data +[npm-link]: https://npmjs.com/package/@tma.js/init-data -[npm-badge]: https://img.shields.io/npm/v/@twa.js/init-data?logo=npm +[npm-badge]: https://img.shields.io/npm/v/@tma.js/init-data?logo=npm -[size-badge]: https://img.shields.io/bundlephobia/minzip/@twa.js/init-data +[size-badge]: https://img.shields.io/bundlephobia/minzip/@tma.js/init-data [![npm-badge]][npm-link] @@ -25,4 +25,4 @@ allows init data parsing, works in browser only. This library is a part of TypeScript packages ecosystem around Telegram Web Apps. You can learn more about this package in this -[documentation](https://docs.twa.dev/docs/libraries/twa-js-init-data). +[documentation](https://docs.telegram-mini-apps.com/docs/libraries/tma-js-init-data). diff --git a/packages/init-data/package.json b/packages/init-data/package.json index 349161d6a..33f589b5b 100644 --- a/packages/init-data/package.json +++ b/packages/init-data/package.json @@ -1,22 +1,21 @@ { - "name": "@twa.js/init-data", + "name": "@tma.js/init-data", "version": "0.2.13", "description": "Frontend TypeScript library to make work with Web Apps init data easier.", "author": "Vladislav Kibenko ", - "homepage": "https://github.com/Telegram-Web-Apps/twa.js#readme", + "homepage": "https://github.com/Telegram-Mini-Apps/tma.js#readme", "repository": { "type": "git", - "url": "git@github.com:Telegram-Web-Apps/twa.js.git", + "url": "git@github.com:Telegram-Mini-Apps/tma.js.git", "directory": "packages/init-data" }, "bugs": { - "url": "https://github.com/Telegram-Web-Apps/twa.js/issues" + "url": "https://github.com/Telegram-Mini-Apps/tma.js/issues" }, "keywords": [ - "telegram", - "telegram-web-apps", - "twa", - "init-data" + "telegram-mini-apps", + "init-data", + "typescript" ], "license": "MIT", "type": "module", @@ -49,7 +48,7 @@ "build": "rimraf dist && rollup --config rollup.config.js" }, "dependencies": { - "@twa.js/parsing": "workspace:*" + "@tma.js/parsing": "workspace:*" }, "devDependencies": { "tsconfig": "workspace:*", diff --git a/packages/init-data/rollup.config.js b/packages/init-data/rollup.config.js index 2faa75f4c..e92d4d56f 100644 --- a/packages/init-data/rollup.config.js +++ b/packages/init-data/rollup.config.js @@ -17,7 +17,7 @@ export default [ { file: pkg.main, format: 'commonjs', sourcemap: true }, { file: pkg.module, format: 'esm', sourcemap: true }, ], - external: ['@twa.js/parsing'], + external: ['@tma.js/parsing'], plugins: [typescript({ tsconfig }), terser()], }), @@ -26,7 +26,7 @@ export default [ output: { file: pkg.browser, format: 'iife', - name: 'TwaInitData', + name: '@tma.js/init-data', sourcemap: true, }, plugins: [typescript({ tsconfig }), nodeResolve(), terser()], @@ -35,7 +35,7 @@ export default [ defineConfig({ input, output: { file: pkg.types }, - external: ['@twa.js/parsing'], + external: ['@tma.js/parsing'], plugins: [typescript({ tsconfig, compilerOptions: { diff --git a/packages/init-data/src/parsing.ts b/packages/init-data/src/parsing.ts index 1bad749b7..431a78d33 100644 --- a/packages/init-data/src/parsing.ts +++ b/packages/init-data/src/parsing.ts @@ -6,7 +6,7 @@ import { boolean, date, type AnyParser, -} from '@twa.js/parsing'; +} from '@tma.js/parsing'; import type { InitData, User } from './types.js'; diff --git a/packages/init-data/src/types.ts b/packages/init-data/src/types.ts index 656c75595..7a82eb544 100644 --- a/packages/init-data/src/types.ts +++ b/packages/init-data/src/types.ts @@ -1,6 +1,6 @@ /** * Describes user information. - * @see https://docs.twa.dev/docs/launch-params/init-data#user + * @see https://docs.telegram-mini-apps.com/docs/launch-params/init-data#user */ export interface User { /** @@ -50,7 +50,7 @@ export interface User { /** * Describes chat information. - * @see https://docs.twa.dev/docs/launch-params/init-data#chat + * @see https://docs.telegram-mini-apps.com/docs/launch-params/init-data#chat */ export interface Chat { /** @@ -82,7 +82,7 @@ export interface Chat { /** * Describes parsed initial data sent from Web App. - * @see https://docs.twa.dev/docs/launch-params/init-data#parameters-list + * @see https://docs.telegram-mini-apps.com/docs/launch-params/init-data#parameters-list */ export interface InitData { /** diff --git a/packages/parsing/CHANGELOG.md b/packages/parsing/CHANGELOG.md index 75e97c67c..bf62ba0c8 100644 --- a/packages/parsing/CHANGELOG.md +++ b/packages/parsing/CHANGELOG.md @@ -1,4 +1,4 @@ -# @twa.js/parsing +# @tma.js/parsing ## 0.0.1 diff --git a/packages/parsing/README.md b/packages/parsing/README.md index c7cd8d877..17232783a 100644 --- a/packages/parsing/README.md +++ b/packages/parsing/README.md @@ -1,10 +1,10 @@ -# @twa.js/parsing +# @tma.js/parsing -[npm-badge]: https://img.shields.io/npm/v/@twa.js/parsing?logo=npm +[npm-badge]: https://img.shields.io/npm/v/@tma.js/parsing?logo=npm -[npm-link]: https://npmjs.com/package/@twa.js/parsing +[npm-link]: https://npmjs.com/package/@tma.js/parsing -[size-badge]: https://img.shields.io/bundlephobia/minzip/@twa.js/parsing +[size-badge]: https://img.shields.io/bundlephobia/minzip/@tma.js/parsing [![NPM][npm-badge]][npm-link] ![Size][size-badge] @@ -13,16 +13,16 @@ Set of parsing utilities used by other languages of ecosystem. This library is a part of TypeScript packages ecosystem around Telegram Web Apps. To see full documentation and other libraries, please, visit -[this](https://docs.twa.dev/) link. +[this](https://docs.telegram-mini-apps.com/) link. ## Installation ```bash -npm i @twa.js/parsing +npm i @tma.js/parsing ``` or ```bash -yarn add @twa.js/parsing +yarn add @tma.js/parsing ``` diff --git a/packages/parsing/package.json b/packages/parsing/package.json index e5524ebef..c45f2f111 100644 --- a/packages/parsing/package.json +++ b/packages/parsing/package.json @@ -1,21 +1,19 @@ { - "name": "@twa.js/parsing", + "name": "@tma.js/parsing", "version": "0.0.1", "description": "Utilities made to parse different types of data.", "author": "Vladislav Kibenko ", - "homepage": "https://github.com/Telegram-Web-Apps/twa.js#readme", + "homepage": "https://github.com/Telegram-Mini-Apps/tma.js#readme", "repository": { "type": "git", - "url": "git@github.com:Telegram-Web-Apps/twa.js.git", + "url": "git@github.com:Telegram-Mini-Apps/tma.js.git", "directory": "packages/parsing" }, "bugs": { - "url": "https://github.com/Telegram-Web-Apps/twa.js/issues" + "url": "https://github.com/Telegram-Mini-Apps/tma.js/issues" }, "keywords": [ - "telegram-web-apps", - "telegram", - "twa", + "telegram-mini-apps", "typescript" ], "license": "MIT", @@ -49,8 +47,8 @@ "build": "rimraf dist && rollup --config rollup.config.js" }, "dependencies": { - "@twa.js/util-types": "workspace:*", - "@twa.js/colors": "workspace:*" + "@tma.js/util-types": "workspace:*", + "@tma.js/colors": "workspace:*" }, "devDependencies": { "tsconfig": "workspace:*", diff --git a/packages/parsing/rollup.config.js b/packages/parsing/rollup.config.js index e284be662..fd5c41252 100644 --- a/packages/parsing/rollup.config.js +++ b/packages/parsing/rollup.config.js @@ -16,7 +16,7 @@ export default [ { file: pkg.main, format: 'commonjs', sourcemap: true }, { file: pkg.module, format: 'esm', sourcemap: true }, ], - external: ['@twa.js/colors'], + external: ['@tma.js/colors'], plugins: [typescript({ tsconfig: './tsconfig.build.json' }), terser()], }), @@ -26,7 +26,7 @@ export default [ output: { file: pkg.browser, format: 'iife', - name: 'TwaParsing', + name: '@tma.js/parsing', sourcemap: true, }, plugins: [typescript({ tsconfig: './tsconfig.build.json' }), nodeResolve(), terser()], @@ -35,7 +35,7 @@ export default [ defineConfig({ input, output: { file: pkg.types }, - external: ['@twa.js/colors'], + external: ['@tma.js/colors'], plugins: [typescript({ tsconfig: './tsconfig.build.json', compilerOptions: { diff --git a/packages/parsing/src/ValueParser.ts b/packages/parsing/src/ValueParser.ts index 82e3dfb0d..fe3901207 100644 --- a/packages/parsing/src/ValueParser.ts +++ b/packages/parsing/src/ValueParser.ts @@ -1,4 +1,4 @@ -import type { HasUndefined, If } from '@twa.js/util-types'; +import type { HasUndefined, If } from '@tma.js/util-types'; import type { AllowedGetDefault, GetDefaultFunc, IsEmptyFunc, Parser } from './shared.js'; diff --git a/packages/parsing/src/parsers.ts b/packages/parsing/src/parsers.ts index efcb88bce..d90a1305d 100644 --- a/packages/parsing/src/parsers.ts +++ b/packages/parsing/src/parsers.ts @@ -1,4 +1,4 @@ -import { toRGB, type RGB } from '@twa.js/colors'; +import { toRGB, type RGB } from '@tma.js/colors'; import { ValueParser } from './ValueParser.js'; import { ArrayValueParser } from './ArrayValueParser.js'; diff --git a/packages/parsing/src/shared.ts b/packages/parsing/src/shared.ts index 0b8373009..2af17f5f1 100644 --- a/packages/parsing/src/shared.ts +++ b/packages/parsing/src/shared.ts @@ -1,4 +1,4 @@ -import type { And, HasUndefined, If, IsOptional, Not, Or } from '@twa.js/util-types'; +import type { And, HasUndefined, If, IsOptional, Not, Or } from '@tma.js/util-types'; /** * Represents any known parser. diff --git a/packages/sdk-react/CHANGELOG.md b/packages/sdk-react/CHANGELOG.md index 7ced69396..60eb33fb9 100644 --- a/packages/sdk-react/CHANGELOG.md +++ b/packages/sdk-react/CHANGELOG.md @@ -1,4 +1,4 @@ -# @twa.js/sdk-react +# @tma.js/sdk-react ## 0.4.2 diff --git a/packages/sdk-react/README.md b/packages/sdk-react/README.md index 9cfac9922..507fbaf2f 100644 --- a/packages/sdk-react/README.md +++ b/packages/sdk-react/README.md @@ -1,18 +1,18 @@ -# @twa.js/sdk-react +# @tma.js/sdk-react [code-badge]: https://img.shields.io/badge/source-black?logo=github -[code-link]: https://github.com/Telegram-Web-Apps/twa.js/tree/master/packages/sdk-react +[code-link]: https://github.com/Telegram-Mini-Apps/tma.js/tree/master/packages/sdk-react -[docs-link]: https://docs.twa.dev/docs/libraries/twa-js-sdk-react +[docs-link]: https://docs.telegram-mini-apps.com/docs/libraries/tma-js-sdk-react [docs-badge]: https://img.shields.io/badge/documentation-blue?logo=gitbook&logoColor=white -[npm-link]: https://npmjs.com/package/@twa.js/sdk-react +[npm-link]: https://npmjs.com/package/@tma.js/sdk-react -[npm-badge]: https://img.shields.io/npm/v/@twa.js/sdk-react?logo=npm +[npm-badge]: https://img.shields.io/npm/v/@tma.js/sdk-react?logo=npm -[size-badge]: https://img.shields.io/bundlephobia/minzip/@twa.js/sdk-react +[size-badge]: https://img.shields.io/bundlephobia/minzip/@tma.js/sdk-react [![NPM][npm-badge]][npm-link] ![Size][size-badge] @@ -25,4 +25,4 @@ Tracks SDK components changes out of box. This library is a part of TypeScript packages ecosystem around Telegram Web Apps. You can learn more about this package in this -[documentation](https://docs.twa.dev/docs/libraries/twa-js-sdk-react). +[documentation](https://docs.telegram-mini-apps.com/docs/libraries/tma-js-sdk-react). diff --git a/packages/sdk-react/package.json b/packages/sdk-react/package.json index 531b8f28c..ac4db2716 100644 --- a/packages/sdk-react/package.json +++ b/packages/sdk-react/package.json @@ -1,22 +1,20 @@ { - "name": "@twa.js/sdk-react", + "name": "@tma.js/sdk-react", "version": "0.4.2", "description": "React bindings for Web Apps client SDK. Contains hooks, components and other useful tools which allow usage of React along with Web Apps client SDK.", "author": "Vladislav Kibenko ", - "homepage": "https://github.com/Telegram-Web-Apps/twa.js#readme", + "homepage": "https://github.com/Telegram-Mini-Apps/tma.js#readme", "repository": { "type": "git", - "url": "git@github.com:Telegram-Web-Apps/twa.js.git", + "url": "git@github.com:Telegram-Mini-Apps/tma.js.git", "directory": "packages/sdk-react" }, "bugs": { - "url": "https://github.com/Telegram-Web-Apps/twa.js/issues" + "url": "https://github.com/Telegram-Mini-Apps/tma.js/issues" }, "keywords": [ - "telegram", - "telegram-web-apps", + "telegram-mini-apps", "typescript", - "twa", "sdk", "react" ], @@ -59,8 +57,8 @@ } }, "dependencies": { - "@twa.js/bridge": "workspace:*", - "@twa.js/sdk": "workspace:*" + "@tma.js/bridge": "workspace:*", + "@tma.js/sdk": "workspace:*" }, "devDependencies": { "tsconfig": "workspace:*", diff --git a/packages/sdk-react/rollup.config.js b/packages/sdk-react/rollup.config.js index 40addcd22..6c46231b3 100644 --- a/packages/sdk-react/rollup.config.js +++ b/packages/sdk-react/rollup.config.js @@ -16,7 +16,7 @@ export default [ { file: pkg.main, format: 'commonjs', sourcemap: true }, { file: pkg.module, format: 'esm', sourcemap: true }, ], - external: ['@twa.js/sdk', '@twa.js/bridge', 'react'], + external: ['@tma.js/sdk', '@tma.js/bridge', 'react'], plugins: [typescript(), terser()], }), @@ -25,7 +25,7 @@ export default [ output: { file: pkg.browser, format: 'iife', - name: 'TwaSDKReact', + name: '@tma.js/sdk-react', globals: { react: 'React' }, sourcemap: true, }, @@ -36,7 +36,7 @@ export default [ defineConfig({ input, output: { file: pkg.types }, - external: ['@twa.js/sdk', '@twa.js/bridge', 'react'], + external: ['@tma.js/sdk', '@tma.js/bridge', 'react'], plugins: [typescript({ compilerOptions: { declaration: true, diff --git a/packages/sdk-react/src/lib/back-button/types.ts b/packages/sdk-react/src/lib/back-button/types.ts index 2ef141560..3294af771 100644 --- a/packages/sdk-react/src/lib/back-button/types.ts +++ b/packages/sdk-react/src/lib/back-button/types.ts @@ -1 +1 @@ -export type { BackButton } from '@twa.js/sdk'; +export type { BackButton } from '@tma.js/sdk'; diff --git a/packages/sdk-react/src/lib/closing-behavior/types.ts b/packages/sdk-react/src/lib/closing-behavior/types.ts index e5e51e0ab..fc754bfa7 100644 --- a/packages/sdk-react/src/lib/closing-behavior/types.ts +++ b/packages/sdk-react/src/lib/closing-behavior/types.ts @@ -1 +1 @@ -export type { ClosingBehaviour } from '@twa.js/sdk'; +export type { ClosingBehaviour } from '@tma.js/sdk'; diff --git a/packages/sdk-react/src/lib/cloud-storage.tsx b/packages/sdk-react/src/lib/cloud-storage.tsx index 0c4366fc3..1ffba96c5 100644 --- a/packages/sdk-react/src/lib/cloud-storage.tsx +++ b/packages/sdk-react/src/lib/cloud-storage.tsx @@ -1,6 +1,6 @@ import React, { type ComponentType } from 'react'; -import type { CloudStorage } from '@twa.js/sdk'; +import type { CloudStorage } from '@tma.js/sdk'; import { useUnit } from '../provider/index.js'; diff --git a/packages/sdk-react/src/lib/haptic-feedback/types.ts b/packages/sdk-react/src/lib/haptic-feedback/types.ts index 117a365a0..a250f4c3e 100644 --- a/packages/sdk-react/src/lib/haptic-feedback/types.ts +++ b/packages/sdk-react/src/lib/haptic-feedback/types.ts @@ -1 +1 @@ -export type { HapticFeedback } from '@twa.js/sdk'; +export type { HapticFeedback } from '@tma.js/sdk'; diff --git a/packages/sdk-react/src/lib/hooks.ts b/packages/sdk-react/src/lib/hooks.ts index fccf031ef..9ba2dda09 100644 --- a/packages/sdk-react/src/lib/hooks.ts +++ b/packages/sdk-react/src/lib/hooks.ts @@ -1,5 +1,5 @@ import { useCallback, useState, useEffect } from 'react'; -import type { PostEvent } from '@twa.js/sdk/types'; +import type { PostEvent } from '@tma.js/sdk/types'; import { useUnit } from '../provider/index.js'; interface Trackable { diff --git a/packages/sdk-react/src/lib/init-data/types.ts b/packages/sdk-react/src/lib/init-data/types.ts index c0736d9ca..3b9624b52 100644 --- a/packages/sdk-react/src/lib/init-data/types.ts +++ b/packages/sdk-react/src/lib/init-data/types.ts @@ -1 +1 @@ -export type { InitData } from '@twa.js/sdk'; +export type { InitData } from '@tma.js/sdk'; diff --git a/packages/sdk-react/src/lib/launch-params/types.ts b/packages/sdk-react/src/lib/launch-params/types.ts index 924c4a2c0..29c43e9e4 100644 --- a/packages/sdk-react/src/lib/launch-params/types.ts +++ b/packages/sdk-react/src/lib/launch-params/types.ts @@ -1 +1 @@ -export type { LaunchParams } from '@twa.js/sdk'; +export type { LaunchParams } from '@tma.js/sdk'; diff --git a/packages/sdk-react/src/lib/launch-params/useLaunchParams.ts b/packages/sdk-react/src/lib/launch-params/useLaunchParams.ts index 750a7c0a7..4976ff0b7 100644 --- a/packages/sdk-react/src/lib/launch-params/useLaunchParams.ts +++ b/packages/sdk-react/src/lib/launch-params/useLaunchParams.ts @@ -1,5 +1,5 @@ import { useMemo } from 'react'; -import { retrieveLaunchParams } from '@twa.js/sdk'; +import { retrieveLaunchParams } from '@tma.js/sdk'; import type { LaunchParams } from './types.js'; diff --git a/packages/sdk-react/src/lib/main-button/types.ts b/packages/sdk-react/src/lib/main-button/types.ts index 7c5be07b3..6ef7f1612 100644 --- a/packages/sdk-react/src/lib/main-button/types.ts +++ b/packages/sdk-react/src/lib/main-button/types.ts @@ -1 +1 @@ -export type { MainButton } from '@twa.js/sdk'; +export type { MainButton } from '@tma.js/sdk'; diff --git a/packages/sdk-react/src/lib/popup/types.ts b/packages/sdk-react/src/lib/popup/types.ts index 6ebb2fd95..664d83664 100644 --- a/packages/sdk-react/src/lib/popup/types.ts +++ b/packages/sdk-react/src/lib/popup/types.ts @@ -1 +1 @@ -export type { Popup } from '@twa.js/sdk'; +export type { Popup } from '@tma.js/sdk'; diff --git a/packages/sdk-react/src/lib/qr-scanner/types.ts b/packages/sdk-react/src/lib/qr-scanner/types.ts index b9028d853..932d46146 100644 --- a/packages/sdk-react/src/lib/qr-scanner/types.ts +++ b/packages/sdk-react/src/lib/qr-scanner/types.ts @@ -1 +1 @@ -export type { QRScanner } from '@twa.js/sdk'; +export type { QRScanner } from '@tma.js/sdk'; diff --git a/packages/sdk-react/src/lib/theme-params/types.ts b/packages/sdk-react/src/lib/theme-params/types.ts index a87c3e060..c9336e606 100644 --- a/packages/sdk-react/src/lib/theme-params/types.ts +++ b/packages/sdk-react/src/lib/theme-params/types.ts @@ -1 +1 @@ -export type { ThemeParams } from '@twa.js/sdk'; +export type { ThemeParams } from '@tma.js/sdk'; diff --git a/packages/sdk-react/src/lib/viewport/types.ts b/packages/sdk-react/src/lib/viewport/types.ts index 4bf9ec2ff..b1d5d5cbc 100644 --- a/packages/sdk-react/src/lib/viewport/types.ts +++ b/packages/sdk-react/src/lib/viewport/types.ts @@ -1 +1 @@ -export type { Viewport } from '@twa.js/sdk'; +export type { Viewport } from '@tma.js/sdk'; diff --git a/packages/sdk-react/src/lib/web-app/types.ts b/packages/sdk-react/src/lib/web-app/types.ts index 44825f990..52de37538 100644 --- a/packages/sdk-react/src/lib/web-app/types.ts +++ b/packages/sdk-react/src/lib/web-app/types.ts @@ -1 +1 @@ -export type { WebApp } from '@twa.js/sdk'; +export type { WebApp } from '@tma.js/sdk'; diff --git a/packages/sdk-react/src/provider/SDKProvider.tsx b/packages/sdk-react/src/provider/SDKProvider.tsx index 38414e4a7..985198218 100644 --- a/packages/sdk-react/src/provider/SDKProvider.tsx +++ b/packages/sdk-react/src/provider/SDKProvider.tsx @@ -5,7 +5,7 @@ import React, { useState, type PropsWithChildren, } from 'react'; -import { init, type InitOptions } from '@twa.js/sdk'; +import { init, type InitOptions } from '@tma.js/sdk'; import { sdkContext } from './context.js'; import type { SDKComponents, SDKContext } from './types.js'; diff --git a/packages/sdk-react/src/provider/types.ts b/packages/sdk-react/src/provider/types.ts index 1d2717f7c..a74a1d8bc 100644 --- a/packages/sdk-react/src/provider/types.ts +++ b/packages/sdk-react/src/provider/types.ts @@ -1,4 +1,4 @@ -import type { InitResult } from '@twa.js/sdk'; +import type { InitResult } from '@tma.js/sdk'; /** * List of provided SDK components. diff --git a/packages/sdk-solid/CHANGELOG.md b/packages/sdk-solid/CHANGELOG.md index 58b202799..9e4ef43dc 100644 --- a/packages/sdk-solid/CHANGELOG.md +++ b/packages/sdk-solid/CHANGELOG.md @@ -1,4 +1,4 @@ -# @twa.js/sdk-solid +# @tma.js/sdk-solid ## 0.1.2 diff --git a/packages/sdk-solid/README.md b/packages/sdk-solid/README.md index e47fcbfb4..7942aacd4 100644 --- a/packages/sdk-solid/README.md +++ b/packages/sdk-solid/README.md @@ -1,18 +1,18 @@ -# @twa.js/sdk-solid +# @tma.js/sdk-solid [code-badge]: https://img.shields.io/badge/source-black?logo=github -[code-link]: https://github.com/Telegram-Web-Apps/twa.js/tree/master/packages/sdk-solid +[code-link]: https://github.com/Telegram-Mini-Apps/tma.js/tree/master/packages/sdk-solid -[docs-link]: https://docs.twa.dev/docs/libraries/twa-js-sdk-solid +[docs-link]: https://docs.telegram-mini-apps.com/docs/libraries/tma-js-sdk-solid [docs-badge]: https://img.shields.io/badge/documentation-blue?logo=gitbook&logoColor=white -[npm-link]: https://npmjs.com/package/@twa.js/sdk-solid +[npm-link]: https://npmjs.com/package/@tma.js/sdk-solid -[npm-badge]: https://img.shields.io/npm/v/@twa.js/sdk-solid?logo=npm +[npm-badge]: https://img.shields.io/npm/v/@tma.js/sdk-solid?logo=npm -[size-badge]: https://img.shields.io/bundlephobia/minzip/@twa.js/sdk-solid +[size-badge]: https://img.shields.io/bundlephobia/minzip/@tma.js/sdk-solid [![NPM][npm-badge]][npm-link] ![Size][size-badge] @@ -21,4 +21,4 @@ Solid JS bindings for client SDK. Contains hooks, components and other useful tools which allow usage of Solid JS along with Web Apps client SDK. Tracks SDK components changes out of box. -This library is a part of TypeScript packages ecosystem around Telegram Web Apps. You can learn more about this package in this [documentation](https://docs.twa.dev/docs/libraries/twa-js-sdk-solid). +This library is a part of TypeScript packages ecosystem around Telegram Web Apps. You can learn more about this package in this [documentation](https://docs.telegram-mini-apps.com/docs/libraries/tma-js-sdk-solid). diff --git a/packages/sdk-solid/package.json b/packages/sdk-solid/package.json index e3854fcfb..9b439e03c 100644 --- a/packages/sdk-solid/package.json +++ b/packages/sdk-solid/package.json @@ -1,22 +1,20 @@ { - "name": "@twa.js/sdk-solid", + "name": "@tma.js/sdk-solid", "version": "0.1.2", "description": "Solid JS bindings for Web Apps client SDK.", "author": "Vladislav Kibenko ", - "homepage": "https://github.com/Telegram-Web-Apps/twa.js#readme", + "homepage": "https://github.com/Telegram-Mini-Apps/tma.js#readme", "repository": { "type": "git", - "url": "git@github.com:Telegram-Web-Apps/twa.js.git", + "url": "git@github.com:Telegram-Mini-Apps/tma.js.git", "directory": "packages/sdk-solid" }, "bugs": { - "url": "https://github.com/Telegram-Web-Apps/twa.js/issues" + "url": "https://github.com/Telegram-Mini-Apps/tma.js/issues" }, "keywords": [ - "telegram", - "telegram-web-apps", + "telegram-mini-apps", "typescript", - "twa", "sdk", "solidjs" ], @@ -54,8 +52,8 @@ "build": "rimraf dist && rollup --config rollup.config.js" }, "dependencies": { - "@twa.js/utils": "workspace:*", - "@twa.js/sdk": "workspace:*" + "@tma.js/utils": "workspace:*", + "@tma.js/sdk": "workspace:*" }, "peerDependencies": { "solid-js": "^1.0.0" diff --git a/packages/sdk-solid/src/SDKProvider.tsx b/packages/sdk-solid/src/SDKProvider.tsx index a32e9b16d..79f679f8b 100644 --- a/packages/sdk-solid/src/SDKProvider.tsx +++ b/packages/sdk-solid/src/SDKProvider.tsx @@ -1,5 +1,5 @@ import { createMemo, createResource, ParentProps } from 'solid-js'; -import { init } from '@twa.js/sdk'; +import { init } from '@tma.js/sdk'; import { SDKContext } from './context.js'; import type { SDKInitOptions } from './types.js'; diff --git a/packages/sdk-solid/src/index.ts b/packages/sdk-solid/src/index.ts index 4dd59bf83..0bef9df9d 100644 --- a/packages/sdk-solid/src/index.ts +++ b/packages/sdk-solid/src/index.ts @@ -3,4 +3,4 @@ export * from './hooks.js'; export * from './SDKProvider.jsx'; export * from './types.js'; export * from './useSDK.js'; -export { classNames, mergeClassNames } from '@twa.js/utils'; +export { classNames, mergeClassNames } from '@tma.js/utils'; diff --git a/packages/sdk-solid/src/types.ts b/packages/sdk-solid/src/types.ts index f5b4afc60..ba9520050 100644 --- a/packages/sdk-solid/src/types.ts +++ b/packages/sdk-solid/src/types.ts @@ -1,4 +1,4 @@ -import type { InitResult, InitOptions } from '@twa.js/sdk'; +import type { InitResult, InitOptions } from '@tma.js/sdk'; import { Accessor } from 'solid-js'; export type SDKInitOptions = InitOptions; diff --git a/packages/sdk/CHANGELOG.md b/packages/sdk/CHANGELOG.md index 497da3254..ece97fd2f 100644 --- a/packages/sdk/CHANGELOG.md +++ b/packages/sdk/CHANGELOG.md @@ -1,4 +1,4 @@ -# @twa.js/sdk +# @tma.js/sdk ## 0.11.2 diff --git a/packages/sdk/README.md b/packages/sdk/README.md index 602de3b48..8dbd41f5b 100644 --- a/packages/sdk/README.md +++ b/packages/sdk/README.md @@ -1,18 +1,18 @@ -# @twa.js/sdk +# @tma.js/sdk [code-badge]: https://img.shields.io/badge/source-black?logo=github [code-link]: https://github.com/Telegram-Mini-Apps/tma.js/tree/master/packages/sdk -[docs-link]: https://docs.twa.dev/docs/libraries/twa-js-sdk +[docs-link]: https://docs.telegram-mini-apps.com/docs/libraries/tma-js-sdk [docs-badge]: https://img.shields.io/badge/documentation-blue?logo=gitbook&logoColor=white -[npm-link]: https://npmjs.com/package/@twa.js/sdk +[npm-link]: https://npmjs.com/package/@tma.js/sdk -[npm-badge]: https://img.shields.io/npm/v/@twa.js/sdk?logo=npm +[npm-badge]: https://img.shields.io/npm/v/@tma.js/sdk?logo=npm -[size-badge]: https://img.shields.io/bundlephobia/minzip/@twa.js/sdk +[size-badge]: https://img.shields.io/bundlephobia/minzip/@tma.js/sdk [![NPM][npm-badge]][npm-link] ![Size][size-badge] @@ -26,4 +26,4 @@ functionality. This library is a part of TypeScript packages ecosystem around Telegram Web Apps. You can learn more about this package in this -[documentation](https://docs.twa.dev/docs/libraries/twa-js-sdk/about). \ No newline at end of file +[documentation](https://docs.telegram-mini-apps.com/docs/libraries/tma-js-sdk/about). \ No newline at end of file diff --git a/packages/sdk/__tests__/components/Popup/Popup.test.ts b/packages/sdk/__tests__/components/Popup/Popup.test.ts index 0a17fa312..2df6b5eb2 100644 --- a/packages/sdk/__tests__/components/Popup/Popup.test.ts +++ b/packages/sdk/__tests__/components/Popup/Popup.test.ts @@ -1,6 +1,6 @@ // import {emitDesktopEvent, mockDesktop} from '../../../tests'; // import { Popup } from './Popup'; -// import {Bridge} from '@twa.js/bridge'; +// import {Bridge} from '@tma.js/bridge'; // import {PopupParams} from './types'; // import {preparePopupParams} from './utils'; diff --git a/packages/sdk/__tests__/components/WebApp/WebApp.ts b/packages/sdk/__tests__/components/WebApp/WebApp.ts index 22835b124..be7d15bec 100644 --- a/packages/sdk/__tests__/components/WebApp/WebApp.ts +++ b/packages/sdk/__tests__/components/WebApp/WebApp.ts @@ -1,4 +1,4 @@ -import type { RGB } from '@twa.js/colors'; +import type { RGB } from '@tma.js/colors'; import { WebApp } from '../../../src/index.js'; diff --git a/packages/sdk/package.json b/packages/sdk/package.json index 80e97e9d3..e3072c78a 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -1,5 +1,5 @@ { - "name": "@twa.js/sdk", + "name": "@tma.js/sdk", "version": "0.11.2", "description": "TypeScript Source Development Kit for Telegram Web Apps client application.", "author": "Vladislav Kibenko ", @@ -13,9 +13,7 @@ "url": "https://github.com/Telegram-Mini-Apps/tma.js/issues" }, "keywords": [ - "telegram", - "telegram-web-apps", - "twa", + "telegram-mini-apps", "typescript", "sdk" ], @@ -50,13 +48,13 @@ "build": "rimraf dist && rollup --config rollup.config.js" }, "dependencies": { - "@twa.js/bridge": "workspace:*", - "@twa.js/colors": "workspace:*", - "@twa.js/init-data": "workspace:*", - "@twa.js/utils": "workspace:*", - "@twa.js/util-types": "workspace:*", - "@twa.js/parsing": "workspace:*", - "@twa.js/event-emitter": "workspace:*" + "@tma.js/bridge": "workspace:*", + "@tma.js/colors": "workspace:*", + "@tma.js/init-data": "workspace:*", + "@tma.js/utils": "workspace:*", + "@tma.js/util-types": "workspace:*", + "@tma.js/parsing": "workspace:*", + "@tma.js/event-emitter": "workspace:*" }, "devDependencies": { "tsconfig": "workspace:*", diff --git a/packages/sdk/rollup.config.js b/packages/sdk/rollup.config.js index f0dfaa8bd..4e59c1622 100644 --- a/packages/sdk/rollup.config.js +++ b/packages/sdk/rollup.config.js @@ -9,12 +9,12 @@ const pkg = require('./package.json'); const input = 'src/index.ts'; const external = [ - '@twa.js/utils', - '@twa.js/init-data', - '@twa.js/bridge', - '@twa.js/parsing', - '@twa.js/colors', - '@twa.js/event-emitter', + '@tma.js/utils', + '@tma.js/init-data', + '@tma.js/bridge', + '@tma.js/parsing', + '@tma.js/colors', + '@tma.js/event-emitter', ]; export default [ @@ -33,7 +33,7 @@ export default [ output: { file: pkg.browser, format: 'iife', - name: 'TwaSDK', + name: '@tma.js/sdk', sourcemap: true, }, plugins: [typescript({ tsconfig: './tsconfig.build.json' }), nodeResolve(), terser()], diff --git a/packages/sdk/src/components/BackButton/BackButton.ts b/packages/sdk/src/components/BackButton/BackButton.ts index 0f32f5729..f2bffe4b0 100644 --- a/packages/sdk/src/components/BackButton/BackButton.ts +++ b/packages/sdk/src/components/BackButton/BackButton.ts @@ -1,7 +1,7 @@ -import { EventEmitter } from '@twa.js/event-emitter'; -import { on, off, postEvent as defaultPostEvent, type PostEvent } from '@twa.js/bridge'; +import { EventEmitter } from '@tma.js/event-emitter'; +import { on, off, postEvent as defaultPostEvent, type PostEvent } from '@tma.js/bridge'; -import type { Version } from '@twa.js/utils'; +import type { Version } from '@tma.js/utils'; import { createSupportsFunc, type SupportsFunc } from '../../supports.js'; import { State } from '../../state/index.js'; diff --git a/packages/sdk/src/components/ClosingBehaviour/ClosingBehaviour.ts b/packages/sdk/src/components/ClosingBehaviour/ClosingBehaviour.ts index cdfa1d858..72e8c216c 100644 --- a/packages/sdk/src/components/ClosingBehaviour/ClosingBehaviour.ts +++ b/packages/sdk/src/components/ClosingBehaviour/ClosingBehaviour.ts @@ -1,5 +1,5 @@ -import { EventEmitter } from '@twa.js/event-emitter'; -import { postEvent as defaultPostEvent, type PostEvent } from '@twa.js/bridge'; +import { EventEmitter } from '@tma.js/event-emitter'; +import { postEvent as defaultPostEvent, type PostEvent } from '@tma.js/bridge'; import { State } from '../../state/index.js'; diff --git a/packages/sdk/src/components/CloudStorage/CloudStorage.ts b/packages/sdk/src/components/CloudStorage/CloudStorage.ts index 2dffdd8e0..35c9c222a 100644 --- a/packages/sdk/src/components/CloudStorage/CloudStorage.ts +++ b/packages/sdk/src/components/CloudStorage/CloudStorage.ts @@ -2,10 +2,10 @@ import { postEvent as defaultPostEvent, request, type RequestOptions, -} from '@twa.js/bridge'; -import { array, json, string } from '@twa.js/parsing'; +} from '@tma.js/bridge'; +import { array, json, string } from '@tma.js/parsing'; -import type { Version } from '@twa.js/utils'; +import type { Version } from '@tma.js/utils'; import { createSupportsFunc, type SupportsFunc } from '../../supports.js'; diff --git a/packages/sdk/src/components/HapticFeedback/HapticFeedback.ts b/packages/sdk/src/components/HapticFeedback/HapticFeedback.ts index 900e25d65..9c00902c1 100644 --- a/packages/sdk/src/components/HapticFeedback/HapticFeedback.ts +++ b/packages/sdk/src/components/HapticFeedback/HapticFeedback.ts @@ -1,10 +1,10 @@ -import type { Version } from '@twa.js/utils'; +import type { Version } from '@tma.js/utils'; import { postEvent as defaultPostEvent, type PostEvent, type ImpactHapticFeedbackStyle, type NotificationHapticFeedbackType, -} from '@twa.js/bridge'; +} from '@tma.js/bridge'; import { createSupportsFunc, type SupportsFunc } from '../../supports.js'; diff --git a/packages/sdk/src/components/InitData/InitData.ts b/packages/sdk/src/components/InitData/InitData.ts index 4807fbdc3..6783220ce 100644 --- a/packages/sdk/src/components/InitData/InitData.ts +++ b/packages/sdk/src/components/InitData/InitData.ts @@ -1,9 +1,9 @@ -import type { HasUndefined, If } from '@twa.js/util-types'; +import type { HasUndefined, If } from '@tma.js/util-types'; import type { Chat, InitData as InitDataType, User, -} from '@twa.js/init-data'; +} from '@tma.js/init-data'; import { State } from '../../state/index.js'; diff --git a/packages/sdk/src/components/MainButton/MainButton.ts b/packages/sdk/src/components/MainButton/MainButton.ts index f89569a45..79a19b06b 100644 --- a/packages/sdk/src/components/MainButton/MainButton.ts +++ b/packages/sdk/src/components/MainButton/MainButton.ts @@ -1,7 +1,7 @@ -import { EventEmitter } from '@twa.js/event-emitter'; -import { on, off, postEvent as defaultPostEvent, type PostEvent } from '@twa.js/bridge'; +import { EventEmitter } from '@tma.js/event-emitter'; +import { on, off, postEvent as defaultPostEvent, type PostEvent } from '@tma.js/bridge'; -import type { RGB } from '@twa.js/colors'; +import type { RGB } from '@tma.js/colors'; import { State } from '../../state/index.js'; diff --git a/packages/sdk/src/components/MainButton/types.ts b/packages/sdk/src/components/MainButton/types.ts index 3fe96b982..bb08764ab 100644 --- a/packages/sdk/src/components/MainButton/types.ts +++ b/packages/sdk/src/components/MainButton/types.ts @@ -1,4 +1,4 @@ -import type { RGB } from '@twa.js/colors'; +import type { RGB } from '@tma.js/colors'; import type { StateEvents } from '../../state/index.js'; diff --git a/packages/sdk/src/components/Popup/Popup.ts b/packages/sdk/src/components/Popup/Popup.ts index c160d9003..5b3ae46a0 100644 --- a/packages/sdk/src/components/Popup/Popup.ts +++ b/packages/sdk/src/components/Popup/Popup.ts @@ -1,7 +1,7 @@ -import { EventEmitter } from '@twa.js/event-emitter'; -import { postEvent as defaultPostEvent, request, type PostEvent } from '@twa.js/bridge'; +import { EventEmitter } from '@tma.js/event-emitter'; +import { postEvent as defaultPostEvent, request, type PostEvent } from '@tma.js/bridge'; -import type { Version } from '@twa.js/utils'; +import type { Version } from '@tma.js/utils'; import { preparePopupParams } from './utils.js'; import { createSupportsFunc, type SupportsFunc } from '../../supports.js'; diff --git a/packages/sdk/src/components/Popup/utils.ts b/packages/sdk/src/components/Popup/utils.ts index bb1c4b756..c7a5a29af 100644 --- a/packages/sdk/src/components/Popup/utils.ts +++ b/packages/sdk/src/components/Popup/utils.ts @@ -1,4 +1,4 @@ -import type { PopupButton, PopupParams as BridgePopupParams } from '@twa.js/bridge'; +import type { PopupButton, PopupParams as BridgePopupParams } from '@tma.js/bridge'; import type { PopupParams } from './types.js'; diff --git a/packages/sdk/src/components/QRScanner/QRScanner.ts b/packages/sdk/src/components/QRScanner/QRScanner.ts index f2967dd65..451f98303 100644 --- a/packages/sdk/src/components/QRScanner/QRScanner.ts +++ b/packages/sdk/src/components/QRScanner/QRScanner.ts @@ -1,7 +1,7 @@ -import { EventEmitter } from '@twa.js/event-emitter'; -import { postEvent as defaultPostEvent, request, type PostEvent } from '@twa.js/bridge'; +import { EventEmitter } from '@tma.js/event-emitter'; +import { postEvent as defaultPostEvent, request, type PostEvent } from '@tma.js/bridge'; -import type { Version } from '@twa.js/utils'; +import type { Version } from '@tma.js/utils'; import { createSupportsFunc, type SupportsFunc } from '../../supports.js'; import { State } from '../../state/index.js'; diff --git a/packages/sdk/src/components/ThemeParams/ThemeParams.ts b/packages/sdk/src/components/ThemeParams/ThemeParams.ts index 9b4496021..7fbf6cb1a 100644 --- a/packages/sdk/src/components/ThemeParams/ThemeParams.ts +++ b/packages/sdk/src/components/ThemeParams/ThemeParams.ts @@ -1,8 +1,8 @@ -import { EventEmitter } from '@twa.js/event-emitter'; -import { on, request, type RequestOptions } from '@twa.js/bridge'; -import { isColorDark } from '@twa.js/colors'; +import { EventEmitter } from '@tma.js/event-emitter'; +import { on, request, type RequestOptions } from '@tma.js/bridge'; +import { isColorDark } from '@tma.js/colors'; -import type { RGB } from '@twa.js/colors'; +import type { RGB } from '@tma.js/colors'; import { parseThemeParams, type ThemeParamsType } from '../../theme-params.js'; import { State } from '../../state/index.js'; diff --git a/packages/sdk/src/components/ThemeParams/types.ts b/packages/sdk/src/components/ThemeParams/types.ts index 905d21b51..3fbe70a4d 100644 --- a/packages/sdk/src/components/ThemeParams/types.ts +++ b/packages/sdk/src/components/ThemeParams/types.ts @@ -1,4 +1,4 @@ -import type { HasUndefined, If } from '@twa.js/util-types'; +import type { HasUndefined, If } from '@tma.js/util-types'; import type { ThemeParamsType } from '../../theme-params.js'; import type { StateEvents } from '../../state/index.js'; diff --git a/packages/sdk/src/components/Viewport/Viewport.ts b/packages/sdk/src/components/Viewport/Viewport.ts index 8d26b7458..fa0598921 100644 --- a/packages/sdk/src/components/Viewport/Viewport.ts +++ b/packages/sdk/src/components/Viewport/Viewport.ts @@ -1,5 +1,5 @@ -import { EventEmitter } from '@twa.js/event-emitter'; -import { on, postEvent as defaultPostEvent, request, type RequestOptions, type PostEvent } from '@twa.js/bridge'; +import { EventEmitter } from '@tma.js/event-emitter'; +import { on, postEvent as defaultPostEvent, request, type RequestOptions, type PostEvent } from '@tma.js/bridge'; import { State } from '../../state/index.js'; diff --git a/packages/sdk/src/components/WebApp/WebApp.ts b/packages/sdk/src/components/WebApp/WebApp.ts index e9dfb353f..8491c8938 100644 --- a/packages/sdk/src/components/WebApp/WebApp.ts +++ b/packages/sdk/src/components/WebApp/WebApp.ts @@ -1,6 +1,6 @@ -import { EventEmitter } from '@twa.js/event-emitter'; -import { compareVersions, type Version } from '@twa.js/utils'; -import { isRGB, isColorDark, type RGB } from '@twa.js/colors'; +import { EventEmitter } from '@tma.js/event-emitter'; +import { compareVersions, type Version } from '@tma.js/utils'; +import { isRGB, isColorDark, type RGB } from '@tma.js/colors'; import { postEvent as defaultPostEvent, supports, @@ -9,7 +9,7 @@ import { type WriteAccessRequestedStatus, type InvoiceStatus, type PostEvent, -} from '@twa.js/bridge'; +} from '@tma.js/bridge'; import { formatURL } from '../../url.js'; import { State } from '../../state/index.js'; diff --git a/packages/sdk/src/components/WebApp/types.ts b/packages/sdk/src/components/WebApp/types.ts index 7cb215538..e77fcec95 100644 --- a/packages/sdk/src/components/WebApp/types.ts +++ b/packages/sdk/src/components/WebApp/types.ts @@ -1,5 +1,5 @@ -import type { RGB } from '@twa.js/colors'; -import type { HeaderColorKey } from '@twa.js/bridge'; +import type { RGB } from '@tma.js/colors'; +import type { HeaderColorKey } from '@tma.js/bridge'; import type { StateEvents } from '../../state/index.js'; diff --git a/packages/sdk/src/init/creators/createBackButton.ts b/packages/sdk/src/init/creators/createBackButton.ts index c6bd20ca5..1c9420547 100644 --- a/packages/sdk/src/init/creators/createBackButton.ts +++ b/packages/sdk/src/init/creators/createBackButton.ts @@ -1,4 +1,4 @@ -import type { PostEvent } from '@twa.js/bridge'; +import type { PostEvent } from '@tma.js/bridge'; import { BackButton } from '../../components/index.js'; diff --git a/packages/sdk/src/init/creators/createClosingBehavior.ts b/packages/sdk/src/init/creators/createClosingBehavior.ts index 1f6892884..562284e5d 100644 --- a/packages/sdk/src/init/creators/createClosingBehavior.ts +++ b/packages/sdk/src/init/creators/createClosingBehavior.ts @@ -1,4 +1,4 @@ -import type { PostEvent } from '@twa.js/bridge'; +import type { PostEvent } from '@tma.js/bridge'; import { ClosingBehaviour } from '../../components/index.js'; diff --git a/packages/sdk/src/init/creators/createMainButton.ts b/packages/sdk/src/init/creators/createMainButton.ts index 85ddf76b9..83198ed96 100644 --- a/packages/sdk/src/init/creators/createMainButton.ts +++ b/packages/sdk/src/init/creators/createMainButton.ts @@ -1,5 +1,5 @@ -import type { RGB } from '@twa.js/colors'; -import type { PostEvent } from '@twa.js/bridge'; +import type { RGB } from '@tma.js/colors'; +import type { PostEvent } from '@tma.js/bridge'; import { MainButton } from '../../components/index.js'; diff --git a/packages/sdk/src/init/creators/createPostEvent.ts b/packages/sdk/src/init/creators/createPostEvent.ts index 4b2373ff4..96081c2d9 100644 --- a/packages/sdk/src/init/creators/createPostEvent.ts +++ b/packages/sdk/src/init/creators/createPostEvent.ts @@ -3,8 +3,8 @@ import { postEvent as defaultPostEvent, detectSupportParams, type PostEvent, -} from '@twa.js/bridge'; -import { isRecord } from '@twa.js/utils'; +} from '@tma.js/bridge'; +import { isRecord } from '@tma.js/utils'; import { MethodNotSupportedError, ParameterUnsupportedError } from '../../errors/index.js'; diff --git a/packages/sdk/src/init/creators/createViewport.ts b/packages/sdk/src/init/creators/createViewport.ts index 450c75d46..ed6e301ad 100644 --- a/packages/sdk/src/init/creators/createViewport.ts +++ b/packages/sdk/src/init/creators/createViewport.ts @@ -1,4 +1,4 @@ -import type { PostEvent } from '@twa.js/bridge'; +import type { PostEvent } from '@tma.js/bridge'; import { Viewport } from '../../components/index.js'; diff --git a/packages/sdk/src/init/creators/createWebApp.ts b/packages/sdk/src/init/creators/createWebApp.ts index a219c0e96..98a83a50c 100644 --- a/packages/sdk/src/init/creators/createWebApp.ts +++ b/packages/sdk/src/init/creators/createWebApp.ts @@ -1,5 +1,5 @@ -import type { RGB } from '@twa.js/colors'; -import type { PostEvent } from '@twa.js/bridge'; +import type { RGB } from '@tma.js/colors'; +import type { PostEvent } from '@tma.js/bridge'; import { WebApp } from '../../components/index.js'; diff --git a/packages/sdk/src/init/css.ts b/packages/sdk/src/init/css.ts index 10104fdd5..0d6440fe9 100644 --- a/packages/sdk/src/init/css.ts +++ b/packages/sdk/src/init/css.ts @@ -1,4 +1,4 @@ -import type { RGB } from '@twa.js/colors'; +import type { RGB } from '@tma.js/colors'; import type { ThemeParams, WebApp, Viewport } from '../components/index.js'; import type { InitCSSVarsOption, InitCSSVarsSpecificOption } from './types.js'; diff --git a/packages/sdk/src/init/init.ts b/packages/sdk/src/init/init.ts index b0db54b29..ebdcae36d 100644 --- a/packages/sdk/src/init/init.ts +++ b/packages/sdk/src/init/init.ts @@ -3,8 +3,8 @@ import { setDebug, setTargetOrigin, on, -} from '@twa.js/bridge'; -import { withTimeout } from '@twa.js/utils'; +} from '@tma.js/bridge'; +import { withTimeout } from '@tma.js/utils'; import { CloudStorage, diff --git a/packages/sdk/src/init/types.ts b/packages/sdk/src/init/types.ts index 05abdec7b..47a5b32b0 100644 --- a/packages/sdk/src/init/types.ts +++ b/packages/sdk/src/init/types.ts @@ -1,4 +1,4 @@ -import type { PostEvent } from '@twa.js/bridge'; +import type { PostEvent } from '@tma.js/bridge'; import type { BackButton, diff --git a/packages/sdk/src/launch-params.ts b/packages/sdk/src/launch-params.ts index b60f507eb..dbdf41337 100644 --- a/packages/sdk/src/launch-params.ts +++ b/packages/sdk/src/launch-params.ts @@ -1,5 +1,5 @@ -import { searchParams, string } from '@twa.js/parsing'; -import { initData, type InitData } from '@twa.js/init-data'; +import { searchParams, string } from '@tma.js/parsing'; +import { initData, type InitData } from '@tma.js/init-data'; import { parseThemeParams, type ThemeParamsType } from './theme-params.js'; import { saveStorageValue, getStorageValue } from './storage.js'; diff --git a/packages/sdk/src/state/State.ts b/packages/sdk/src/state/State.ts index 4f2faa1d7..0119d6154 100644 --- a/packages/sdk/src/state/State.ts +++ b/packages/sdk/src/state/State.ts @@ -1,4 +1,4 @@ -import type { EventEmitter } from '@twa.js/event-emitter'; +import type { EventEmitter } from '@tma.js/event-emitter'; import type { StateEvents, StringKeys } from './types.js'; diff --git a/packages/sdk/src/storage.ts b/packages/sdk/src/storage.ts index f9ba1374c..6df5bf9a2 100644 --- a/packages/sdk/src/storage.ts +++ b/packages/sdk/src/storage.ts @@ -1,5 +1,5 @@ -import type { HeaderColorKey } from '@twa.js/bridge'; -import type { RGB } from '@twa.js/colors'; +import type { HeaderColorKey } from '@tma.js/bridge'; +import type { RGB } from '@tma.js/colors'; /** * Describes storage keys and according values. diff --git a/packages/sdk/src/supports.ts b/packages/sdk/src/supports.ts index 1f05d9167..0bb980b10 100644 --- a/packages/sdk/src/supports.ts +++ b/packages/sdk/src/supports.ts @@ -1,10 +1,10 @@ -import type { Version } from '@twa.js/utils'; +import type { Version } from '@tma.js/utils'; import { supports, type MethodName, type HasCheckSupportMethodName, type HasCheckSupportMethodParam, -} from '@twa.js/bridge'; +} from '@tma.js/bridge'; export type SupportsFunc = (method: M) => boolean; @@ -37,8 +37,8 @@ export function createSupportsParamFunc

( schema: Record, ): SupportsFunc

{ return (method) => { - const [twaMethod, param] = schema[method]; + const [tmaMethod, param] = schema[method]; - return supports(twaMethod, param, version); + return supports(tmaMethod, param, version); }; } diff --git a/packages/sdk/src/theme-params.ts b/packages/sdk/src/theme-params.ts index e5513ba95..6d7d2068e 100644 --- a/packages/sdk/src/theme-params.ts +++ b/packages/sdk/src/theme-params.ts @@ -1,6 +1,6 @@ -import { json, rgb } from '@twa.js/parsing'; +import { json, rgb } from '@tma.js/parsing'; -import type { RGB } from '@twa.js/colors'; +import type { RGB } from '@tma.js/colors'; /** * Application theme parameters. Defines palette used by the Telegram application. diff --git a/packages/sdk/src/types.ts b/packages/sdk/src/types.ts index 839f21e71..010015599 100644 --- a/packages/sdk/src/types.ts +++ b/packages/sdk/src/types.ts @@ -1,4 +1,4 @@ -import type { PostEvent as BridgePostEvent } from '@twa.js/bridge'; +import type { PostEvent as BridgePostEvent } from '@tma.js/bridge'; export type PostEvent = BridgePostEvent; diff --git a/packages/util-types/CHANGELOG.md b/packages/util-types/CHANGELOG.md index 48759ca99..0cc086f7d 100644 --- a/packages/util-types/CHANGELOG.md +++ b/packages/util-types/CHANGELOG.md @@ -1,4 +1,4 @@ -# @twa.js/util-types +# @tma.js/util-types ## 0.0.1 diff --git a/packages/util-types/README.md b/packages/util-types/README.md index 1206ffa11..d9f34b97c 100644 --- a/packages/util-types/README.md +++ b/packages/util-types/README.md @@ -1,28 +1,28 @@ -# @twa.js/util-types +# @tma.js/util-types -[npm-badge]: https://img.shields.io/npm/v/@twa.js/util-types?logo=npm +[npm-badge]: https://img.shields.io/npm/v/@tma.js/util-types?logo=npm -[npm-link]: https://npmjs.com/package/@twa.js/util-types +[npm-link]: https://npmjs.com/package/@tma.js/util-types -[size-badge]: https://img.shields.io/bundlephobia/minzip/@twa.js/util-types +[size-badge]: https://img.shields.io/bundlephobia/minzip/@tma.js/util-types [![NPM][npm-badge]][npm-link] ![Size][size-badge] -Utility types used across @twa.js packages. +Utility types used across @tma.js packages. This library is a part of TypeScript packages ecosystem around Telegram Web Apps. To see full documentation and other libraries, please, visit -[this](https://docs.twa.dev/) link. +[this](https://docs.telegram-mini-apps.com/) link. ## Installation ```bash -npm i @twa.js/util-types +npm i @tma.js/util-types ``` or ```bash -yarn add @twa.js/util-types +yarn add @tma.js/util-types ``` diff --git a/packages/util-types/package.json b/packages/util-types/package.json index 25afc7818..a84e49f59 100644 --- a/packages/util-types/package.json +++ b/packages/util-types/package.json @@ -1,21 +1,19 @@ { - "name": "@twa.js/util-types", + "name": "@tma.js/util-types", "version": "0.0.1", "description": "Utility types.", "author": "Vladislav Kibenko ", - "homepage": "https://github.com/Telegram-Web-Apps/twa.js#readme", + "homepage": "https://github.com/Telegram-Mini-Apps/tma.js#readme", "repository": { "type": "git", - "url": "git@github.com:Telegram-Web-Apps/twa.js.git", + "url": "git@github.com:Telegram-Mini-Apps/tma.js.git", "directory": "packages/util-types" }, "bugs": { - "url": "https://github.com/Telegram-Web-Apps/twa.js/issues" + "url": "https://github.com/Telegram-Mini-Apps/tma.js/issues" }, "keywords": [ - "telegram-web-apps", - "telegram", - "twa", + "telegram-mini-apps", "typescript" ], "license": "MIT", diff --git a/packages/utils/CHANGELOG.md b/packages/utils/CHANGELOG.md index f897b0dc9..6fff9a3e9 100644 --- a/packages/utils/CHANGELOG.md +++ b/packages/utils/CHANGELOG.md @@ -1,4 +1,4 @@ -# @twa.js/utils +# @tma.js/utils ## 0.5.1 diff --git a/packages/utils/README.md b/packages/utils/README.md index 5a29720bc..dcf21ca8f 100644 --- a/packages/utils/README.md +++ b/packages/utils/README.md @@ -1,10 +1,10 @@ -# @twa.js/utils +# @tma.js/utils -[npm-badge]: https://img.shields.io/npm/v/@twa.js/utils?logo=npm +[npm-badge]: https://img.shields.io/npm/v/@tma.js/utils?logo=npm -[npm-link]: https://npmjs.com/package/@twa.js/utils +[npm-link]: https://npmjs.com/package/@tma.js/utils -[size-badge]: https://img.shields.io/bundlephobia/minzip/@twa.js/utils +[size-badge]: https://img.shields.io/bundlephobia/minzip/@tma.js/utils [![NPM][npm-badge]][npm-link] ![Size][size-badge] @@ -15,16 +15,16 @@ find provided functionality useful in other contexts. This library is a part of TypeScript packages ecosystem around Telegram Web Apps. To see full documentation and other libraries, please, visit -[this](https://docs.twa.dev/) link. +[this](https://docs.telegram-mini-apps.com/) link. ## Installation ```bash -npm i @twa.js/utils +npm i @tma.js/utils ``` or ```bash -yarn add @twa.js/utils +yarn add @tma.js/utils ``` diff --git a/packages/utils/package.json b/packages/utils/package.json index 9cf5fd2c1..0f05e0ffd 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,21 +1,19 @@ { - "name": "@twa.js/utils", + "name": "@tma.js/utils", "version": "0.5.1", "description": "Web Apps core TypeScript utilities reused by other packages of ecosystem.", "author": "Vladislav Kibenko ", - "homepage": "https://github.com/Telegram-Web-Apps/twa.js#readme", + "homepage": "https://github.com/Telegram-Mini-Apps/tma.js#readme", "repository": { "type": "git", - "url": "git@github.com:Telegram-Web-Apps/twa.js.git", + "url": "git@github.com:Telegram-Mini-Apps/tma.js.git", "directory": "packages/utils" }, "bugs": { - "url": "https://github.com/Telegram-Web-Apps/twa.js/issues" + "url": "https://github.com/Telegram-Mini-Apps/tma.js/issues" }, "keywords": [ - "telegram-web-apps", - "telegram", - "twa", + "telegram-mini-apps", "typescript" ], "license": "MIT", @@ -48,9 +46,6 @@ "lint": "eslint -c .eslintrc.cjs src/**/* __tests__/**/*", "build": "rimraf dist && rollup --config rollup.config.js" }, - "dependencies": { - "@twa.js/util-types": "workspace:*" - }, "devDependencies": { "tsconfig": "workspace:*", "jest-config-custom": "workspace:*", diff --git a/packages/utils/rollup.config.js b/packages/utils/rollup.config.js index 24601a46e..6ca2ed445 100644 --- a/packages/utils/rollup.config.js +++ b/packages/utils/rollup.config.js @@ -13,7 +13,7 @@ export default [ input, output: [ { file: pkg.main, format: 'commonjs', sourcemap: true }, - { file: pkg.browser, format: 'iife', name: 'TwaUtils', sourcemap: true }, + { file: pkg.browser, format: 'iife', name: '@tma.js/utils', sourcemap: true }, { file: pkg.module, format: 'esm', sourcemap: true }, ], plugins: [typescript({ tsconfig: './tsconfig.build.json' }), terser()], diff --git a/packages/utils/src/index.ts b/packages/utils/src/index.ts index 5d8e100ae..3b5185715 100644 --- a/packages/utils/src/index.ts +++ b/packages/utils/src/index.ts @@ -1,5 +1,4 @@ export * from './styles/index.js'; -export * from './logging.js'; export * from './validation.js'; export * from './version.js'; export * from './withTimeout.js'; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a529ef0e8..1cecd4a1a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -108,7 +108,7 @@ importers: apps/react-sdk-example: dependencies: - '@twa.js/sdk-react': + '@tma.js/sdk-react': specifier: workspace:* version: link:../../packages/sdk-react react: @@ -136,7 +136,7 @@ importers: apps/solid-sdk-example: dependencies: - '@twa.js/sdk-solid': + '@tma.js/sdk-solid': specifier: workspace:* version: link:../../packages/sdk-solid solid-js: @@ -176,19 +176,22 @@ importers: packages/bridge: dependencies: - '@twa.js/colors': + '@tma.js/colors': specifier: workspace:* version: link:../colors - '@twa.js/event-emitter': + '@tma.js/event-emitter': specifier: workspace:* version: link:../event-emitter - '@twa.js/parsing': + '@tma.js/logger': + specifier: workspace:* + version: link:../logger + '@tma.js/parsing': specifier: workspace:* version: link:../parsing - '@twa.js/util-types': + '@tma.js/util-types': specifier: workspace:* version: link:../util-types - '@twa.js/utils': + '@tma.js/utils': specifier: workspace:* version: link:../utils devDependencies: @@ -231,7 +234,7 @@ importers: packages/event-emitter: dependencies: - '@twa.js/util-types': + '@tma.js/util-types': specifier: workspace:* version: link:../util-types devDependencies: @@ -247,7 +250,7 @@ importers: packages/init-data: dependencies: - '@twa.js/parsing': + '@tma.js/parsing': specifier: workspace:* version: link:../parsing devDependencies: @@ -263,7 +266,7 @@ importers: packages/init-data-node: dependencies: - '@twa.js/init-data': + '@tma.js/init-data': specifier: workspace:* version: link:../init-data devDependencies: @@ -289,12 +292,49 @@ importers: specifier: ^29.6.4 version: 29.6.4(@babel/core@7.22.20) + packages/logger: + devDependencies: + eslint-config-custom: + specifier: workspace:* + version: link:../eslint-config-custom + jest-config-custom: + specifier: workspace:* + version: link:../jest-config-custom + tsconfig: + specifier: workspace:* + version: link:../tsconfig + + packages/navigation: + dependencies: + '@tma.js/bridge': + specifier: workspace:* + version: link:../bridge + '@tma.js/event-emitter': + specifier: workspace:* + version: link:../event-emitter + '@tma.js/logger': + specifier: workspace:* + version: link:../logger + '@tma.js/parsing': + specifier: workspace:* + version: link:../parsing + devDependencies: + eslint-config-custom: + specifier: workspace:* + version: link:../eslint-config-custom + jest-config-custom: + specifier: workspace:* + version: link:../jest-config-custom + tsconfig: + specifier: workspace:* + version: link:../tsconfig + packages/parsing: dependencies: - '@twa.js/colors': + '@tma.js/colors': specifier: workspace:* version: link:../colors - '@twa.js/util-types': + '@tma.js/util-types': specifier: workspace:* version: link:../util-types devDependencies: @@ -310,25 +350,25 @@ importers: packages/sdk: dependencies: - '@twa.js/bridge': + '@tma.js/bridge': specifier: workspace:* version: link:../bridge - '@twa.js/colors': + '@tma.js/colors': specifier: workspace:* version: link:../colors - '@twa.js/event-emitter': + '@tma.js/event-emitter': specifier: workspace:* version: link:../event-emitter - '@twa.js/init-data': + '@tma.js/init-data': specifier: workspace:* version: link:../init-data - '@twa.js/parsing': + '@tma.js/parsing': specifier: workspace:* version: link:../parsing - '@twa.js/util-types': + '@tma.js/util-types': specifier: workspace:* version: link:../util-types - '@twa.js/utils': + '@tma.js/utils': specifier: workspace:* version: link:../utils devDependencies: @@ -344,10 +384,10 @@ importers: packages/sdk-react: dependencies: - '@twa.js/bridge': + '@tma.js/bridge': specifier: workspace:* version: link:../bridge - '@twa.js/sdk': + '@tma.js/sdk': specifier: workspace:* version: link:../sdk '@types/react': @@ -366,10 +406,10 @@ importers: packages/sdk-solid: dependencies: - '@twa.js/sdk': + '@tma.js/sdk': specifier: workspace:* version: link:../sdk - '@twa.js/utils': + '@tma.js/utils': specifier: workspace:* version: link:../utils solid-js: @@ -395,10 +435,6 @@ importers: version: link:../tsconfig packages/utils: - dependencies: - '@twa.js/util-types': - specifier: workspace:* - version: link:../util-types devDependencies: eslint-config-custom: specifier: workspace:* From 5a45fb7f0fe538846c05c58ef8bed08a8aa27710 Mon Sep 17 00:00:00 2001 From: Vladislav Kibenko Date: Fri, 29 Sep 2023 23:58:31 +0300 Subject: [PATCH 4/8] docs(changeset): Implement new package --- .changeset/tough-deers-relate.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/tough-deers-relate.md diff --git a/.changeset/tough-deers-relate.md b/.changeset/tough-deers-relate.md new file mode 100644 index 000000000..6bb07223c --- /dev/null +++ b/.changeset/tough-deers-relate.md @@ -0,0 +1,5 @@ +--- +"@tma.js/logger": patch +--- + +Implement new package From f1d2932608836a1aaf07420a2f5f4cd13af819b1 Mon Sep 17 00:00:00 2001 From: Vladislav Kibenko Date: Fri, 29 Sep 2023 23:58:53 +0300 Subject: [PATCH 5/8] docs(changeset): Implement new package --- .changeset/odd-falcons-listen.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/odd-falcons-listen.md diff --git a/.changeset/odd-falcons-listen.md b/.changeset/odd-falcons-listen.md new file mode 100644 index 000000000..dc92b7b10 --- /dev/null +++ b/.changeset/odd-falcons-listen.md @@ -0,0 +1,5 @@ +--- +"@tma.js/navigation": patch +--- + +Implement new package From 21c46322c38adc90f9c203b5a6cee9556c860a99 Mon Sep 17 00:00:00 2001 From: Vladislav Kibenko Date: Fri, 29 Sep 2023 23:59:31 +0300 Subject: [PATCH 6/8] docs(changeset): Update docs URLs. Rename packages to @tma.js. Update deps --- .changeset/small-spoons-listen.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .changeset/small-spoons-listen.md diff --git a/.changeset/small-spoons-listen.md b/.changeset/small-spoons-listen.md new file mode 100644 index 000000000..b49bf1c8a --- /dev/null +++ b/.changeset/small-spoons-listen.md @@ -0,0 +1,17 @@ +--- +"@tma.js/init-data-node": patch +"react-sdk-example": patch +"solid-sdk-example": patch +"@tma.js/event-emitter": patch +"@tma.js/util-types": patch +"@tma.js/init-data": patch +"@tma.js/sdk-react": patch +"@tma.js/sdk-solid": patch +"@tma.js/parsing": patch +"@tma.js/bridge": patch +"@tma.js/colors": patch +"@tma.js/utils": patch +"@tma.js/sdk": patch +--- + +Update docs URLs. Rename packages to @tma.js. Update deps From b9d14f628a94e0916092ae8b734b18376d139073 Mon Sep 17 00:00:00 2001 From: Vladislav Kibenko Date: Sat, 30 Sep 2023 00:06:45 +0300 Subject: [PATCH 7/8] chore(eslint): fix lint command --- packages/navigation/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/navigation/package.json b/packages/navigation/package.json index eaf801ae0..bb7758f79 100644 --- a/packages/navigation/package.json +++ b/packages/navigation/package.json @@ -44,7 +44,7 @@ } }, "scripts": { - "lint": "eslint -c .eslintrc.cjs src/**/* __tests__/**/*", + "lint": "eslint -c .eslintrc.cjs src/**/*", "build": "rimraf dist && rollup --config rollup.config.js" }, "dependencies": { From 2ace5294028a1a74e05051cb178902f185b40ee1 Mon Sep 17 00:00:00 2001 From: Vladislav Kibenko Date: Sat, 30 Sep 2023 00:17:36 +0300 Subject: [PATCH 8/8] chore(docs): make changes related to platform rename --- .../docs/apps-communication/how-it-works.md | 2 +- apps/docs/docs/guides/creating-new-app.md | 4 +- apps/docs/docs/introduction/about-platform.md | 2 +- apps/docs/docs/launch-params/about.md | 2 +- apps/docs/docs/libraries/init-data-golang.md | 12 +- .../{twa-js-bridge.mdx => tma-js-bridge.mdx} | 28 +-- ...ata-node.mdx => tma-js-init-data-node.mdx} | 16 +- ...-js-init-data.mdx => tma-js-init-data.mdx} | 14 +- ...-js-sdk-react.mdx => tma-js-sdk-react.mdx} | 30 +-- ...-js-sdk-solid.mdx => tma-js-sdk-solid.mdx} | 28 +-- .../docs/libraries/tma-js-sdk/_category_.json | 4 + .../{twa-js-sdk => tma-js-sdk}/about.mdx | 26 +-- .../components/_category_.json | 0 .../components/back-button.mdx | 2 +- .../components/closing-behaviour.mdx | 2 +- .../components/haptic-feedback.mdx | 2 +- .../components/init-data.md | 6 +- .../components/main-button.mdx | 2 +- .../components/popup.mdx | 2 +- .../components/qr-scanner.mdx | 2 +- .../components/theme-params.mdx | 6 +- .../components/viewport.mdx | 6 +- .../components/web-app.mdx | 2 +- apps/docs/docs/libraries/twa-dev-bridge.mdx | 196 ----------------- .../docs/libraries/twa-js-sdk/_category_.json | 4 - apps/docs/docs/supported-applications.md | 4 +- apps/docs/docusaurus.config.js | 8 +- .../current/apps-communication/events.mdx | 2 +- .../apps-communication/how-it-works.md | 6 +- .../current/apps-communication/methods.mdx | 2 +- .../functionality/closing-behavior.mdx | 2 +- .../current/functionality/haptic-feedback.md | 2 +- .../current/guides/creating-new-app.md | 6 +- .../current/introduction/about-platform.md | 4 +- .../introduction/required-technologies.md | 2 +- .../current/introduction/usage.md | 2 +- .../current/launch-params/about.md | 4 +- .../current/libraries/init-data-golang.md | 12 +- .../{twa-js-bridge.mdx => tma-js-bridge.mdx} | 24 +-- ...ata-node.mdx => tma-js-init-data-node.mdx} | 16 +- ...-js-init-data.mdx => tma-js-init-data.mdx} | 12 +- ...-js-sdk-react.mdx => tma-js-sdk-react.mdx} | 28 +-- ...-js-sdk-solid.mdx => tma-js-sdk-solid.mdx} | 26 +-- .../libraries/tma-js-sdk/_category_.json | 4 + .../{twa-js-sdk => tma-js-sdk}/about.mdx | 28 +-- .../components/back-button.mdx | 2 +- .../components/closing-behaviour.mdx | 2 +- .../components/haptic-feedback.mdx | 2 +- .../components/init-data.md | 6 +- .../components/main-button.mdx | 2 +- .../components/popup.mdx | 2 +- .../components/qr-scanner.mdx | 2 +- .../components/theme-params.mdx | 6 +- .../components/viewport.mdx | 6 +- .../components/web-app.mdx | 4 +- .../current/libraries/twa-dev-bridge.mdx | 197 ------------------ .../libraries/twa-js-sdk/_category_.json | 4 - .../current/supported-applications.md | 2 +- .../current/ui/viewport.mdx | 2 +- .../ru/docusaurus-theme-classic/footer.json | 2 +- 60 files changed, 221 insertions(+), 614 deletions(-) rename apps/docs/docs/libraries/{twa-js-bridge.mdx => tma-js-bridge.mdx} (82%) rename apps/docs/docs/libraries/{twa-js-init-data-node.mdx => tma-js-init-data-node.mdx} (70%) rename apps/docs/docs/libraries/{twa-js-init-data.mdx => tma-js-init-data.mdx} (79%) rename apps/docs/docs/libraries/{twa-js-sdk-react.mdx => tma-js-sdk-react.mdx} (91%) rename apps/docs/docs/libraries/{twa-js-sdk-solid.mdx => tma-js-sdk-solid.mdx} (77%) create mode 100644 apps/docs/docs/libraries/tma-js-sdk/_category_.json rename apps/docs/docs/libraries/{twa-js-sdk => tma-js-sdk}/about.mdx (90%) rename apps/docs/docs/libraries/{twa-js-sdk => tma-js-sdk}/components/_category_.json (100%) rename apps/docs/docs/libraries/{twa-js-sdk => tma-js-sdk}/components/back-button.mdx (95%) rename apps/docs/docs/libraries/{twa-js-sdk => tma-js-sdk}/components/closing-behaviour.mdx (94%) rename apps/docs/docs/libraries/{twa-js-sdk => tma-js-sdk}/components/haptic-feedback.mdx (97%) rename apps/docs/docs/libraries/{twa-js-sdk => tma-js-sdk}/components/init-data.md (89%) rename apps/docs/docs/libraries/{twa-js-sdk => tma-js-sdk}/components/main-button.mdx (98%) rename apps/docs/docs/libraries/{twa-js-sdk => tma-js-sdk}/components/popup.mdx (96%) rename apps/docs/docs/libraries/{twa-js-sdk => tma-js-sdk}/components/qr-scanner.mdx (95%) rename apps/docs/docs/libraries/{twa-js-sdk => tma-js-sdk}/components/theme-params.mdx (92%) rename apps/docs/docs/libraries/{twa-js-sdk => tma-js-sdk}/components/viewport.mdx (95%) rename apps/docs/docs/libraries/{twa-js-sdk => tma-js-sdk}/components/web-app.mdx (98%) delete mode 100644 apps/docs/docs/libraries/twa-dev-bridge.mdx delete mode 100644 apps/docs/docs/libraries/twa-js-sdk/_category_.json rename apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/{twa-js-bridge.mdx => tma-js-bridge.mdx} (91%) rename apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/{twa-js-init-data-node.mdx => tma-js-init-data-node.mdx} (78%) rename apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/{twa-js-init-data.mdx => tma-js-init-data.mdx} (81%) rename apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/{twa-js-sdk-react.mdx => tma-js-sdk-react.mdx} (93%) rename apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/{twa-js-sdk-solid.mdx => tma-js-sdk-solid.mdx} (82%) create mode 100644 apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/tma-js-sdk/_category_.json rename apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/{twa-js-sdk => tma-js-sdk}/about.mdx (87%) rename apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/{twa-js-sdk => tma-js-sdk}/components/back-button.mdx (96%) rename apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/{twa-js-sdk => tma-js-sdk}/components/closing-behaviour.mdx (95%) rename apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/{twa-js-sdk => tma-js-sdk}/components/haptic-feedback.mdx (98%) rename apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/{twa-js-sdk => tma-js-sdk}/components/init-data.md (92%) rename apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/{twa-js-sdk => tma-js-sdk}/components/main-button.mdx (98%) rename apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/{twa-js-sdk => tma-js-sdk}/components/popup.mdx (97%) rename apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/{twa-js-sdk => tma-js-sdk}/components/qr-scanner.mdx (97%) rename apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/{twa-js-sdk => tma-js-sdk}/components/theme-params.mdx (94%) rename apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/{twa-js-sdk => tma-js-sdk}/components/viewport.mdx (97%) rename apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/{twa-js-sdk => tma-js-sdk}/components/web-app.mdx (95%) delete mode 100644 apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/twa-dev-bridge.mdx delete mode 100644 apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/twa-js-sdk/_category_.json diff --git a/apps/docs/docs/apps-communication/how-it-works.md b/apps/docs/docs/apps-communication/how-it-works.md index 9f87461b8..2dc1bb115 100644 --- a/apps/docs/docs/apps-communication/how-it-works.md +++ b/apps/docs/docs/apps-communication/how-it-works.md @@ -12,7 +12,7 @@ environment for the Web App. For developers, it is enough to know, that this environment is web-based, but nevertheless, each of them has its own communication way between the Telegram application and Web App. -To be more accurate, Telegram Web Apps is not new technology even in the world +To be more accurate, Telegram Mini Apps is not new technology even in the world of Telegram. Messenger already has such technology as Telegram Games, which is, internally, almost the same platform as Web Apps. At least, it uses the same way of communication with the front-end app. diff --git a/apps/docs/docs/guides/creating-new-app.md b/apps/docs/docs/guides/creating-new-app.md index 7a9a82cba..d2b219cda 100644 --- a/apps/docs/docs/guides/creating-new-app.md +++ b/apps/docs/docs/guides/creating-new-app.md @@ -1,7 +1,7 @@ # Creating new app In this article, we will delve into the process of developing a new application on the -Telegram Web Apps platform, we will find out exactly what actions need to be performed to create it, +Telegram Mini Apps platform, we will find out exactly what actions need to be performed to create it, as well as give advice on improving the process of creating an application. The process of creating an application usually consists of the following basic steps: @@ -31,7 +31,7 @@ bots, the bot [BotFather](https://t.me/botfather) and use the command `/newbot`, then go through the proposed process, specifying all the necessary data. When the bot is created, it is required then to use the command `/newapp` and again go -through the procedure of creating another entity - the Telegram Web Apps application, +through the procedure of creating another entity - the Telegram Mini Apps application, linking it to the Telegram bot. From now on, the created application will be available via a direct link of the form `https://t.me/{mybot}/{myapp}`. diff --git a/apps/docs/docs/introduction/about-platform.md b/apps/docs/docs/introduction/about-platform.md index ac6d68104..d1e052c73 100644 --- a/apps/docs/docs/introduction/about-platform.md +++ b/apps/docs/docs/introduction/about-platform.md @@ -4,7 +4,7 @@ sidebar_position: 1 # About platform -Telegram Web Apps is a technology created by developers of the famous messenger +Telegram Mini Apps is a technology created by developers of the famous messenger Telegram. The main it’s purpose is to provide developers more flexible communication channel with Telegram users. diff --git a/apps/docs/docs/launch-params/about.md b/apps/docs/docs/launch-params/about.md index 205120f5a..4bf71355a 100644 --- a/apps/docs/docs/launch-params/about.md +++ b/apps/docs/docs/launch-params/about.md @@ -49,7 +49,7 @@ Telegram to the TWA application. ### `tgWebAppVersion` -The current Telegram Web Apps version used by the native application. This +The current Telegram Mini Apps version used by the native application. This parameter is important to use, for example, before calling the TWA [methods](../apps-communication/methods.mdx) to make sure, they are supported. diff --git a/apps/docs/docs/libraries/init-data-golang.md b/apps/docs/docs/libraries/init-data-golang.md index b80f94860..3c5361ecb 100644 --- a/apps/docs/docs/libraries/init-data-golang.md +++ b/apps/docs/docs/libraries/init-data-golang.md @@ -4,12 +4,12 @@ sidebar_position: 100 # init-data-golang -The package provides utilities to work with the initialization data of Telegram Web Apps. To learn more about the initialization data and its usage, please refer to the [documentation](../launch-params/init-data.mdx). +The package provides utilities to work with the initialization data of Telegram Mini Apps. To learn more about the initialization data and its usage, please refer to the [documentation](../launch-params/init-data.mdx). ## Installation ```bash -go get github.com/telegram-web-apps/init-data-golang +go get github.com/telegram-mini-apps/init-data-golang ``` ## Validation @@ -21,7 +21,7 @@ package main import ( "fmt" - "github.com/Telegram-Web-Apps/init-data-golang" + "github.com/Telegram-Mini-Apps/init-data-golang" "time" ) @@ -50,7 +50,7 @@ package main import ( "fmt" - "github.com/Telegram-Web-Apps/init-data-golang" + "github.com/Telegram-Mini-Apps/init-data-golang" ) func main() { @@ -73,7 +73,7 @@ package main import ( "fmt" - "github.com/Telegram-Web-Apps/init-data-golang" + "github.com/Telegram-Mini-Apps/init-data-golang" "time" ) @@ -101,4 +101,4 @@ func main() { ## GoDoc -To see GoDoc documentation, visit [this link](https://pkg.go.dev/github.com/telegram-web-apps/init-data-golang). \ No newline at end of file +To see GoDoc documentation, visit [this link](https://pkg.go.dev/github.com/telegram-mini-apps/init-data-golang). \ No newline at end of file diff --git a/apps/docs/docs/libraries/twa-js-bridge.mdx b/apps/docs/docs/libraries/tma-js-bridge.mdx similarity index 82% rename from apps/docs/docs/libraries/twa-js-bridge.mdx rename to apps/docs/docs/libraries/tma-js-bridge.mdx index 0c534c06c..1fd43b27f 100644 --- a/apps/docs/docs/libraries/twa-js-bridge.mdx +++ b/apps/docs/docs/libraries/tma-js-bridge.mdx @@ -1,11 +1,11 @@ --- -sidebar_label: "@twa.js/bridge" +sidebar_label: "@tma.js/bridge" sidebar_position: 1 --- -# @twa.js/bridge +# @tma.js/bridge - + The package provides utilities to simplify communication between web applications and the Telegram native application. It also addresses cross-platform data differences, safeguarding developers' code and saving their time. @@ -13,14 +13,14 @@ Developers can utilize this package to create their software development kit (SD ## Installation - + ## Calling methods -To call the Telegram Web Apps methods, you should use `postEvent` function: +To call the Telegram Mini Apps methods, you should use `postEvent` function: ```typescript -import { postEvent } from '@twa.js/bridge'; +import { postEvent } from '@tma.js/bridge'; postEvent('web_app_setup_back_button', {is_visible: true}); ``` @@ -34,7 +34,7 @@ This function automatically finds the correct way to send this event based on th To start working with events, we could use `on` and `off` functions. Here is how basic `on` function usage looks like: ```typescript -import { on } from '@twa.js/bridge'; +import { on } from '@tma.js/bridge'; // Start listening to "viewport_changed" event. Returned value // is a function, which removes this event listener. @@ -49,7 +49,7 @@ removeListener(); To stop listening to events, you could alternatively use `off` function: ```typescript -import { on, off, EventListener } from '@twa.js/bridge'; +import { on, off, EventListener } from '@tma.js/bridge'; const listener: EventListener<'viewport_changed'> = payload => { console.log('Viewport changed:', payload); @@ -68,7 +68,7 @@ To listen to all events sent from the native Telegram application, we utilize such functions as `subscribe` and `unsubscribe`: ```typescript -import { subscribe, unsubscribe, GlobalEventListener } from '@twa.js/bridge'; +import { subscribe, unsubscribe, GlobalEventListener } from '@tma.js/bridge'; const listener: GlobalEventListener = (event, data) => { console.log('Received event', event, 'with data', data); @@ -83,10 +83,10 @@ unsubscribe(listener); ## Checking method support -`postEvent` function itself is not checking if specified method supported by current native Telegram application. To do this, we could use `supports` function which accepts Telegram Web Apps method name and current platform version: +`postEvent` function itself is not checking if specified method supported by current native Telegram application. To do this, we could use `supports` function which accepts Telegram Mini Apps method name and current platform version: ```typescript -import { supports } from '@twa.js/bridge'; +import { supports } from '@tma.js/bridge'; supports('web_app_trigger_haptic_feedback', '6.0'); // false supports('web_app_trigger_haptic_feedback', '6.1'); // true @@ -105,7 +105,7 @@ messages related to events handling. To change debug mode, use `setDebug` function: ```typescript -import { setDebug } from '@twa.js/bridge'; +import { setDebug } from '@tma.js/bridge'; setDebug(true); ``` @@ -115,7 +115,7 @@ setDebug(true); If the package is being used in a browser environment (iframe), we employ the function `window.parent.postMessage`. This function requires specifying the target origin to ensure events are only sent to trusted parent iframes. By default, the package utilizes `https://web.telegram.org` as the origin. To enable event transmission to other origins, you should utilize the `setTargetOrigin` function: ```typescript -import { setTargetOrigin } from '@twa.js/bridge'; +import { setTargetOrigin } from '@tma.js/bridge'; setTargetOrigin('https://myendpoint.org'); ``` @@ -128,4 +128,4 @@ It is strongly recommended not to override this value as long as it could lead t ## Higher-level control -As long as the package provides only low-level control, we recommend using [SDK](./twa-js-sdk/about.mdx) which implements package methods. It also provides additional some automatic parameters checks, more intuitive method names, and easier usage. \ No newline at end of file +As long as the package provides only low-level control, we recommend using [SDK](./tma-js-sdk/about.mdx) which implements package methods. It also provides additional some automatic parameters checks, more intuitive method names, and easier usage. \ No newline at end of file diff --git a/apps/docs/docs/libraries/twa-js-init-data-node.mdx b/apps/docs/docs/libraries/tma-js-init-data-node.mdx similarity index 70% rename from apps/docs/docs/libraries/twa-js-init-data-node.mdx rename to apps/docs/docs/libraries/tma-js-init-data-node.mdx index b94c34e5b..d647d80b9 100644 --- a/apps/docs/docs/libraries/twa-js-init-data-node.mdx +++ b/apps/docs/docs/libraries/tma-js-init-data-node.mdx @@ -1,36 +1,36 @@ --- -sidebar_label: "@twa.js/init-data-node" +sidebar_label: "@tma.js/init-data-node" sidebar_position: 3 --- -# @twa.js/init-data-node +# @tma.js/init-data-node - + -The package provides utilities to work with the initialization data of Telegram Web Apps on the server side. To learn more about the initialization data and its usage, please refer to the [documentation](../launch-params/init-data.mdx). +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](../launch-params/init-data.mdx). :::note -This package extends the functionality of [`@twa.js/init-data`](twa-js-init-data), including all its types and utilities. Therefore, there is no need to install both packages separately. +This package extends the functionality of [`@tma.js/init-data`](tma-js-init-data), including all its types and utilities. Therefore, there is no need to install both packages separately. ::: ## Installation - + ## Usage ### Parsing -You can learn more about parsing utilities in [`@twa.js/init-data`](twa-js-init-data#parsing) documentation. +You can learn more about parsing utilities in [`@tma.js/init-data`](tma-js-init-data#parsing) documentation. ### Validation To validate the signature of the initialization data, the `validate` function is used. It expects the initialization data to be passed in raw format (search parameters) and throws an error in certain cases. ```typescript -import { validate } from '@twa.js/init-data-node'; +import { validate } from '@tma.js/init-data-node'; const secretToken = '5768337691:AAH5YkoiEuPk8-FZa32hStHTqXiLPtAEhx8'; const initData = diff --git a/apps/docs/docs/libraries/twa-js-init-data.mdx b/apps/docs/docs/libraries/tma-js-init-data.mdx similarity index 79% rename from apps/docs/docs/libraries/twa-js-init-data.mdx rename to apps/docs/docs/libraries/tma-js-init-data.mdx index dbc5ef508..052332356 100644 --- a/apps/docs/docs/libraries/twa-js-init-data.mdx +++ b/apps/docs/docs/libraries/tma-js-init-data.mdx @@ -1,17 +1,17 @@ --- -sidebar_label: "@twa.js/init-data" +sidebar_label: "@tma.js/init-data" sidebar_position: 2 --- -# @twa.js/init-data +# @tma.js/init-data - + -The package provides utilities to work with the initialization data of Telegram Web Apps on the client side. To learn more about the initialization data and its usage, please refer to the [documentation](../launch-params/init-data.mdx). +The package provides utilities to work with the initialization data of Telegram Mini Apps on the client side. To learn more about the initialization data and its usage, please refer to the [documentation](../launch-params/init-data.mdx). ## Installation - + ## Usage @@ -20,7 +20,7 @@ The package provides utilities to work with the initialization data of Telegram This library includes the function `initData`, which can extract initialization data information from query parameters. Here is an example of its usage: ```typescript -import { initData } from '@twa.js/init-data'; +import { initData } from '@tma.js/init-data'; // Let's imagine, we have init data in a raw format like this. Web Apps are // sending it in the exact same format. @@ -55,4 +55,4 @@ The function extracts the required parameters and automatically validates their ### Validation -We have moved the validation utilities to a separate [TypeScript package](twa-js-init-data-node.mdx). These utilities are only needed on the server side, as there is no need to validate initialization data on the client side. +We have moved the validation utilities to a separate [TypeScript package](tma-js-init-data-node.mdx). These utilities are only needed on the server side, as there is no need to validate initialization data on the client side. diff --git a/apps/docs/docs/libraries/twa-js-sdk-react.mdx b/apps/docs/docs/libraries/tma-js-sdk-react.mdx similarity index 91% rename from apps/docs/docs/libraries/twa-js-sdk-react.mdx rename to apps/docs/docs/libraries/tma-js-sdk-react.mdx index 4389dc715..9d735d7dc 100644 --- a/apps/docs/docs/libraries/twa-js-sdk-react.mdx +++ b/apps/docs/docs/libraries/tma-js-sdk-react.mdx @@ -1,31 +1,31 @@ --- -sidebar_label: "@twa.js/sdk-react" +sidebar_label: "@tma.js/sdk-react" sidebar_position: 5 --- -# @twa.js/sdk-react +# @tma.js/sdk-react -React bindings for the [client SDK](twa-js-sdk/about). It includes hooks, components, and other useful tools that enable the use of React alongside the Web Apps client SDK. It automatically tracks changes to SDK components. +React bindings for the [client SDK](tma-js-sdk/about). It includes hooks, components, and other useful tools that enable the use of React alongside the Web Apps client SDK. It automatically tracks changes to SDK components. - + ## Installation -Before anything else, it is assumed that you have already installed the `react` package, as it is a peer dependency of this package. The installation of the SDK itself is not required, as it is already included in `@twa.js/sdk-react`. +Before anything else, it is assumed that you have already installed the `react` package, as it is a peer dependency of this package. The installation of the SDK itself is not required, as it is already included in `@tma.js/sdk-react`. - + ## Initialization ### Using SDK provider -According to the `@twa.js/sdk` [documentation](twa-js-sdk/about), it consists of a set of components that are not initialized by default. Developers are responsible for creating these components themselves. However, the SDK provides the `init` function, which simplifies the process of creating the components and using the standard TWA flow. It handles all the necessary steps for developers. +According to the `@tma.js/sdk` [documentation](tma-js-sdk/about), it consists of a set of components that are not initialized by default. Developers are responsible for creating these components themselves. However, the SDK provides the `init` function, which simplifies the process of creating the components and using the standard TWA flow. It handles all the necessary steps for developers. To make the SDK functionality available to the application and allow the initialization of newly created components, we need to use the `SDKProvider` component. ```typescript jsx import React from 'react'; -import { SDKProvider } from '@twa.js/sdk-react'; +import { SDKProvider } from '@tma.js/sdk-react'; function Root() { return ( @@ -36,11 +36,11 @@ function Root() { } ``` -Internally, the `SDKProvider` utilizes the `init` function from `@twa.js/sdk`. It accepts an optional list of parameters through the `initOptions` property, which is described [here](twa-js-sdk/about#init). +Internally, the `SDKProvider` utilizes the `init` function from `@tma.js/sdk`. It accepts an optional list of parameters through the `initOptions` property, which is described [here](tma-js-sdk/about#init). ```typescript jsx import React from 'react'; -import { SDKProvider, InitOptions } from '@twa.js/sdk-react'; +import { SDKProvider, InitOptions } from '@tma.js/sdk-react'; /** * Root component for the whole project. @@ -68,7 +68,7 @@ By using the `SDKProvider` component, the child elements are able to utilize the ```typescript jsx import React from 'react'; -import { SDKProvider, SDKContext, useSDK, withSDK } from '@twa.js/sdk-react'; +import { SDKProvider, SDKContext, useSDK, withSDK } from '@tma.js/sdk-react'; function App() { const sdk = useSDK(); @@ -105,7 +105,7 @@ Let's enhance the previous example and introduce crucial logic associated with t ```typescript jsx import React, { PropsWithChildren, useEffect } from 'react'; -import { SDKProvider, useSDK, useBackButton, useWebApp } from '@twa.js/sdk-react'; +import { SDKProvider, useSDK, useBackButton, useWebApp } from '@tma.js/sdk-react'; /** * Part of the application which doesn't know anything about SDK initialization @@ -189,7 +189,7 @@ Once the initialization is successfully completed, developers should call the `w ```typescript jsx import React, { useEffect } from 'react'; -import { useWebApp } from '@twa.js/sdk-react'; +import { useWebApp } from '@tma.js/sdk-react'; function App() { const webApp = useWebApp(); @@ -212,7 +212,7 @@ To retrieve Web App launch parameters, the `useLaunchParams` hook (or the `withL ```typescript jsx import React from 'react'; -import { useLaunchParams, withLaunchParams, LaunchParams } from '@twa.js/sdk-react'; +import { useLaunchParams, withLaunchParams, LaunchParams } from '@tma.js/sdk-react'; function DisplayLaunchParams() { const launchParams = useLaunchParams(); @@ -241,7 +241,7 @@ function DisplayLaunchParamsPure({launchParams}: Props) { const DisplayLaunchParamsWrapped = withLaunchParams(DisplayLaunchParams); ``` -It will return the result of the [`retrieveLaunchParams`](twa-js-sdk/about#launch-parameters) function. +It will return the result of the [`retrieveLaunchParams`](tma-js-sdk/about#launch-parameters) function. ### Other diff --git a/apps/docs/docs/libraries/twa-js-sdk-solid.mdx b/apps/docs/docs/libraries/tma-js-sdk-solid.mdx similarity index 77% rename from apps/docs/docs/libraries/twa-js-sdk-solid.mdx rename to apps/docs/docs/libraries/tma-js-sdk-solid.mdx index 9a528e40a..a1a98b9b3 100644 --- a/apps/docs/docs/libraries/twa-js-sdk-solid.mdx +++ b/apps/docs/docs/libraries/tma-js-sdk-solid.mdx @@ -1,30 +1,30 @@ --- -sidebar_label: "@twa.js/sdk-solid" +sidebar_label: "@tma.js/sdk-solid" sidebar_position: 6 --- -# @twa.js/sdk-solid +# @tma.js/sdk-solid -Solid JS bindings for [client SDK](twa-js-sdk/about). Includes hooks, components and utilities for comfortable usage of Solid JS on the Telegram Web Apps platform. +Solid JS bindings for [client SDK](tma-js-sdk/about). Includes hooks, components and utilities for comfortable usage of Solid JS on the Telegram Mini Apps platform. - + ## Installation -Before anything else, it is assumed that you have already installed the `solid-js` package, as it is a peer dependency of this package. The installation of the SDK itself is not required, as it is already included in `@twa.js/sdk-solid`. +Before anything else, it is assumed that you have already installed the `solid-js` package, as it is a peer dependency of this package. The installation of the SDK itself is not required, as it is already included in `@tma.js/sdk-solid`. - + ## Usage ### SDKProvider -According to the `@twa.js/sdk` [documentation](twa-js-sdk/about), it consists of a set of components that are not initialized by default. Developers are responsible for creating these components themselves. However, the SDK provides the `init` function, which simplifies the process of creating the components and using the standard TWA flow. It handles all the necessary steps for developers. +According to the `@tma.js/sdk` [documentation](tma-js-sdk/about), it consists of a set of components that are not initialized by default. Developers are responsible for creating these components themselves. However, the SDK provides the `init` function, which simplifies the process of creating the components and using the standard TWA flow. It handles all the necessary steps for developers. To make the SDK functionality available to the application and allow the initialization of newly created components, we need to use the `SDKProvider` component. ```typescript jsx -import { SDKProvider } from '@twa.js/sdk-solid'; +import { SDKProvider } from '@tma.js/sdk-solid'; function Root() { return ( @@ -35,10 +35,10 @@ function Root() { } ``` -Internally, the `SDKProvider` utilizes the `init` function from `@twa.js/sdk`. It accepts an optional list of parameters through the `initOptions` property, which is described [here](twa-js-sdk/about#init). +Internally, the `SDKProvider` utilizes the `init` function from `@tma.js/sdk`. It accepts an optional list of parameters through the `initOptions` property, which is described [here](tma-js-sdk/about#init). ```typescript jsx -import { SDKProvider, SDKInitOptions } from '@twa.js/sdk-solid'; +import { SDKProvider, SDKInitOptions } from '@tma.js/sdk-solid'; function Root() { const options: SDKInitOptions = { @@ -62,7 +62,7 @@ Most of the time, there is no need to use `initOptions` unless you have specific By using the `SDKProvider` component, the child elements are able to utilize the `useSDK` hook to access core SDK information. ```typescript jsx -import { SDKProvider, useSDKContext } from '@twa.js/sdk-solid'; +import { SDKProvider, useSDKContext } from '@tma.js/sdk-solid'; function App() { const sdk = useSDKContext(); @@ -93,7 +93,7 @@ Hook `useSDK` is used to gain access to provided SDK components. ```typescript jsx title="Usage example" import { createMemo, Switch, Match, ParentProps } from 'solid-js'; -import { SDKProvider, useSDK, useSDKContext } from '@twa.js/sdk-solid'; +import { SDKProvider, useSDK, useSDKContext } from '@tma.js/sdk-solid'; function App() { const sdk = useSDK(); @@ -125,7 +125,7 @@ function DisplayGate(props: ParentProps) {

SDK was unable to initialize. Probably, current application is being used - not in Telegram Web Apps environment. + not in Telegram Mini Apps environment.

{errorMessage()}

@@ -151,4 +151,4 @@ function Root() { ## Complete example -[Code](https://github.com/Telegram-Web-Apps/twa.js/blob/master/apps/solid-sdk-example/src/Root.tsx) and package usage example could be found in [monorepo](https://github.com/Telegram-Web-Apps/twa.js/tree/master/apps/solid-sdk-example). \ No newline at end of file +[Code](https://github.com/Telegram-Mini-Apps/tma.js/blob/master/apps/solid-sdk-example/src/Root.tsx) and package usage example could be found in [monorepo](https://github.com/Telegram-Mini-Apps/tma.js/tree/master/apps/solid-sdk-example). \ No newline at end of file diff --git a/apps/docs/docs/libraries/tma-js-sdk/_category_.json b/apps/docs/docs/libraries/tma-js-sdk/_category_.json new file mode 100644 index 000000000..bfb64699d --- /dev/null +++ b/apps/docs/docs/libraries/tma-js-sdk/_category_.json @@ -0,0 +1,4 @@ +{ + "label": "@tma.js/sdk", + "position": 4 +} \ No newline at end of file diff --git a/apps/docs/docs/libraries/twa-js-sdk/about.mdx b/apps/docs/docs/libraries/tma-js-sdk/about.mdx similarity index 90% rename from apps/docs/docs/libraries/twa-js-sdk/about.mdx rename to apps/docs/docs/libraries/tma-js-sdk/about.mdx index 3e4190da4..6c2624c10 100644 --- a/apps/docs/docs/libraries/twa-js-sdk/about.mdx +++ b/apps/docs/docs/libraries/tma-js-sdk/about.mdx @@ -3,19 +3,19 @@ sidebar_position: 1 sidebar_label: "About" --- -# @twa.js/sdk +# @tma.js/sdk - + -Made from scratch TypeScript library for seamless communication with Telegram Web Apps functionality. +Made from scratch TypeScript library for seamless communication with Telegram Mini Apps functionality. -The code of this library is designed to simplify the process of developers interacting with Telegram Web Apps. It consists of several individual components, each responsible for a specific aspect of the Telegram Web Apps ecosystem. +The code of this library is designed to simplify the process of developers interacting with Telegram Mini Apps. It consists of several individual components, each responsible for a specific aspect of the Telegram Mini Apps ecosystem. Before you begin using the SDK, we highly recommend familiarizing yourself with the Web Apps [documentation](../../introduction/about-platform.md) to grasp the fundamental concepts of the platform. ## Installation - + ## Initialization @@ -24,7 +24,7 @@ According to the design of this package, the developer has complete control over To simplify the developer's workflow, the package includes a special function called `init`. This function returns instances of the initialized components, making it easier for developers to work with the package. ```typescript -import { init } from '@twa.js/sdk'; +import { init } from '@tma.js/sdk'; init().then(components => { const { mainButton, viewport } = components; @@ -45,7 +45,7 @@ init().then(components => { The `init` function has the ability to accept options, which are specified as an object in the first argument of the function. Each option and the options object itself are optional. ```typescript -import { init } from '@twa.js/sdk'; +import { init } from '@tma.js/sdk'; init(options); ``` @@ -81,7 +81,7 @@ Theme parameters variables: #### `targetOrigin: string` -Updates the global target origin, which is used by the bridge's `postEvent` function. This restricts the list of parent iframes that are allowed to receive data from the current application. To learn more about this option, please refer to the [documentation](../twa-js-bridge#target-origin). +Updates the global target origin, which is used by the bridge's `postEvent` function. This restricts the list of parent iframes that are allowed to receive data from the current application. To learn more about this option, please refer to the [documentation](../tma-js-bridge#target-origin). #### `timeout: number` @@ -96,7 +96,7 @@ The launch parameters are the initial parameters passed to the Web App. You can Developers can retrieve the launch parameters by using the `retrieveLaunchParams` function. This function parses the parameters that begin with the `tgWebApp` prefix. ```typescript -import { retrieveLaunchParams } from '@twa.js/sdk'; +import { retrieveLaunchParams } from '@tma.js/sdk'; console.log(retrieveLaunchParams()); @@ -125,10 +125,10 @@ This function needs no SDK initialization or something like that. It attempts to ## Detecting current environment -Sometimes, it can be useful to check if the current environment is Telegram Web Apps. To determine whether an application is running in Telegram Web Apps, a developer could utilize the `isTWA` function: +Sometimes, it can be useful to check if the current environment is Telegram Mini Apps. To determine whether an application is running in Telegram Mini Apps, a developer could utilize the `isTWA` function: ```typescript -import { isTWA } from '@twa.js/sdk'; +import { isTWA } from '@tma.js/sdk'; console.log(isTWA()); // true or false ``` @@ -152,7 +152,7 @@ To avoid potential problems, developers can rely on the package's `init` functio Component instances use the common way of events listening through the `on` and `off` functions. Here is the example with the `BackButton` component: ```typescript -import { BackButton } from '@twa.js/sdk'; +import { BackButton } from '@tma.js/sdk'; const backButton = new BackButton(...); @@ -168,7 +168,7 @@ You can find the list of supported events in components own documentations. Almost each component is capable of checking whether its method is supported by the current Web Apps version or not. To check if some methods are supported, developer should use the component instance `supports()` function. For example: ```typescript -import { BackButton } from '@twa.js/sdk'; +import { BackButton } from '@tma.js/sdk'; let backButton = new BackButton('6.0'); console.log(backButton.supports('show')); // false diff --git a/apps/docs/docs/libraries/twa-js-sdk/components/_category_.json b/apps/docs/docs/libraries/tma-js-sdk/components/_category_.json similarity index 100% rename from apps/docs/docs/libraries/twa-js-sdk/components/_category_.json rename to apps/docs/docs/libraries/tma-js-sdk/components/_category_.json diff --git a/apps/docs/docs/libraries/twa-js-sdk/components/back-button.mdx b/apps/docs/docs/libraries/tma-js-sdk/components/back-button.mdx similarity index 95% rename from apps/docs/docs/libraries/twa-js-sdk/components/back-button.mdx rename to apps/docs/docs/libraries/tma-js-sdk/components/back-button.mdx index 4a724b5e6..3ad52c289 100644 --- a/apps/docs/docs/libraries/twa-js-sdk/components/back-button.mdx +++ b/apps/docs/docs/libraries/tma-js-sdk/components/back-button.mdx @@ -5,7 +5,7 @@ Controls the back button displayed in the header of the Web App in the Telegram ## Initialization ```typescript -import { BackButton } from '@twa.js/sdk'; +import { BackButton } from '@tma.js/sdk'; const backButton = new BackButton('6.3'); ``` diff --git a/apps/docs/docs/libraries/twa-js-sdk/components/closing-behaviour.mdx b/apps/docs/docs/libraries/tma-js-sdk/components/closing-behaviour.mdx similarity index 94% rename from apps/docs/docs/libraries/twa-js-sdk/components/closing-behaviour.mdx rename to apps/docs/docs/libraries/tma-js-sdk/components/closing-behaviour.mdx index e9444b667..d220dac30 100644 --- a/apps/docs/docs/libraries/twa-js-sdk/components/closing-behaviour.mdx +++ b/apps/docs/docs/libraries/tma-js-sdk/components/closing-behaviour.mdx @@ -5,7 +5,7 @@ Controls the application closing behavior. There is more information about this ## Initialization ```typescript -import { ClosingBehaviour } from '@twa.js/sdk'; +import { ClosingBehaviour } from '@tma.js/sdk'; const closingBehaviour = new ClosingBehaviour(); ``` diff --git a/apps/docs/docs/libraries/twa-js-sdk/components/haptic-feedback.mdx b/apps/docs/docs/libraries/tma-js-sdk/components/haptic-feedback.mdx similarity index 97% rename from apps/docs/docs/libraries/twa-js-sdk/components/haptic-feedback.mdx rename to apps/docs/docs/libraries/tma-js-sdk/components/haptic-feedback.mdx index 6e6e7c56a..e4fb0249a 100644 --- a/apps/docs/docs/libraries/twa-js-sdk/components/haptic-feedback.mdx +++ b/apps/docs/docs/libraries/tma-js-sdk/components/haptic-feedback.mdx @@ -5,7 +5,7 @@ Controls the haptic feedback. It allows calling different types of haptic notifi ## Initialization ```typescript -import { HapticFeedback } from '@twa.js/sdk'; +import { HapticFeedback } from '@tma.js/sdk'; const haptic = new HapticFeedback('6.3'); ``` diff --git a/apps/docs/docs/libraries/twa-js-sdk/components/init-data.md b/apps/docs/docs/libraries/tma-js-sdk/components/init-data.md similarity index 89% rename from apps/docs/docs/libraries/twa-js-sdk/components/init-data.md rename to apps/docs/docs/libraries/tma-js-sdk/components/init-data.md index d6d907968..69b29b21c 100644 --- a/apps/docs/docs/libraries/twa-js-sdk/components/init-data.md +++ b/apps/docs/docs/libraries/tma-js-sdk/components/init-data.md @@ -1,7 +1,7 @@ # `InitData` -[user-ref]: https://github.com/Telegram-Web-Apps/twa/blob/master/packages/init-data/src/types.ts#L5 -[chat-ref]: https://github.com/Telegram-Web-Apps/twa/blob/master/packages/init-data/src/types.ts#L55 +[user-ref]: https://github.com/Telegram-Mini-Apps/tma.js/blob/master/packages/init-data/src/types.ts#L5 +[chat-ref]: https://github.com/Telegram-Mini-Apps/tma.js/blob/master/packages/init-data/src/types.ts#L55 The component which is responsible for displaying the Web Apps init data. There is more information about init data in this [documentation](../../../launch-params/init-data.mdx). @@ -11,7 +11,7 @@ The component which is responsible for displaying the Web Apps init data. There This class represents object with readonly properties. To create its new instance, a developer could use the class constructor as follows: ```typescript -import { InitData } from '@twa.js/sdk'; +import { InitData } from '@tma.js/sdk'; const authDate = new Date(); const hash = 'myhash'; diff --git a/apps/docs/docs/libraries/twa-js-sdk/components/main-button.mdx b/apps/docs/docs/libraries/tma-js-sdk/components/main-button.mdx similarity index 98% rename from apps/docs/docs/libraries/twa-js-sdk/components/main-button.mdx rename to apps/docs/docs/libraries/tma-js-sdk/components/main-button.mdx index e548a7aac..848a937f9 100644 --- a/apps/docs/docs/libraries/twa-js-sdk/components/main-button.mdx +++ b/apps/docs/docs/libraries/tma-js-sdk/components/main-button.mdx @@ -5,7 +5,7 @@ The component which controls the main button, which is displayed at the bottom o ## Initialization ```typescript -import { BackButton } from '@twa.js/sdk'; +import { BackButton } from '@tma.js/sdk'; const mainButton = new MainButton('#000000', '#ffffff'); ``` diff --git a/apps/docs/docs/libraries/twa-js-sdk/components/popup.mdx b/apps/docs/docs/libraries/tma-js-sdk/components/popup.mdx similarity index 96% rename from apps/docs/docs/libraries/twa-js-sdk/components/popup.mdx rename to apps/docs/docs/libraries/tma-js-sdk/components/popup.mdx index 174de7bea..d314b5017 100644 --- a/apps/docs/docs/libraries/twa-js-sdk/components/popup.mdx +++ b/apps/docs/docs/libraries/tma-js-sdk/components/popup.mdx @@ -5,7 +5,7 @@ The component which controls the currently displayed application popup. It allow ## Initialization ```typescript -import { Popup } from '@twa.js/sdk'; +import { Popup } from '@tma.js/sdk'; const popup = new Popup('6.3'); ``` diff --git a/apps/docs/docs/libraries/twa-js-sdk/components/qr-scanner.mdx b/apps/docs/docs/libraries/tma-js-sdk/components/qr-scanner.mdx similarity index 95% rename from apps/docs/docs/libraries/twa-js-sdk/components/qr-scanner.mdx rename to apps/docs/docs/libraries/tma-js-sdk/components/qr-scanner.mdx index ab1902bd9..15657fa4e 100644 --- a/apps/docs/docs/libraries/twa-js-sdk/components/qr-scanner.mdx +++ b/apps/docs/docs/libraries/tma-js-sdk/components/qr-scanner.mdx @@ -5,7 +5,7 @@ The component which provides the QR scanner functionality. ## Initialization ```typescript -import { QRScanner } from '@twa.js/sdk'; +import { QRScanner } from '@tma.js/sdk'; const scanner = new QRScanner('6.3'); ``` diff --git a/apps/docs/docs/libraries/twa-js-sdk/components/theme-params.mdx b/apps/docs/docs/libraries/tma-js-sdk/components/theme-params.mdx similarity index 92% rename from apps/docs/docs/libraries/twa-js-sdk/components/theme-params.mdx rename to apps/docs/docs/libraries/tma-js-sdk/components/theme-params.mdx index 8bc800e34..c2fc8048a 100644 --- a/apps/docs/docs/libraries/twa-js-sdk/components/theme-params.mdx +++ b/apps/docs/docs/libraries/tma-js-sdk/components/theme-params.mdx @@ -5,7 +5,7 @@ The component which contains an information about currently used theme by the ap ## Initialization ```typescript -import { ThemeParams } from '@twa.js/sdk'; +import { ThemeParams } from '@tma.js/sdk'; const themeParams = new ThemeParams({ backgroundColor: '#ffaabb', @@ -23,7 +23,7 @@ const themeParams = new ThemeParams({ To get the actual theme parameters information, developer could use the `request()` static method: ```typescript -import { ThemeParams } from '@twa.js/sdk'; +import { ThemeParams } from '@tma.js/sdk'; ThemeParams.request().then(console.log); @@ -36,7 +36,7 @@ ThemeParams.request().then(console.log); The `ThemeParams` is capable of returning an instance of `ThemeParams` which is synchronized with its actual state in the Telegram application. To get it, use static the `synced()` method: ```typescript -import { ThemeParams } from '@twa.js/sdk'; +import { ThemeParams } from '@tma.js/sdk'; const themeParams = await ThemeParams.synced(); ``` diff --git a/apps/docs/docs/libraries/twa-js-sdk/components/viewport.mdx b/apps/docs/docs/libraries/tma-js-sdk/components/viewport.mdx similarity index 95% rename from apps/docs/docs/libraries/twa-js-sdk/components/viewport.mdx rename to apps/docs/docs/libraries/tma-js-sdk/components/viewport.mdx index 2e9c55ec6..231675cf0 100644 --- a/apps/docs/docs/libraries/twa-js-sdk/components/viewport.mdx +++ b/apps/docs/docs/libraries/tma-js-sdk/components/viewport.mdx @@ -5,7 +5,7 @@ The component which contains an information about the current Web App device vie ## Initialization ```typescript -import { Viewport } from '@twa.js/sdk'; +import { Viewport } from '@tma.js/sdk'; // Specify height, width, stable height and expansion status. const viewport = new Viewport(390, 365, 300, false); @@ -24,7 +24,7 @@ Please note that the refresh rate of this value is not sufficient to smoothly fo To get actual viewport information, you could use static `request()` function: ```typescript -import { Viewport } from '@twa.js/sdk'; +import { Viewport } from '@tma.js/sdk'; Viewport.request().then(console.log); @@ -37,7 +37,7 @@ Viewport.request().then(console.log); Class is capable of returning instance of `Viewport` which is synchronized with its actual state in Telegram application. To get it, use static `synced()` method: ```typescript -import { Viewport } from '@twa.js/sdk'; +import { Viewport } from '@tma.js/sdk'; const viewport = await Viewport.synced(); diff --git a/apps/docs/docs/libraries/twa-js-sdk/components/web-app.mdx b/apps/docs/docs/libraries/tma-js-sdk/components/web-app.mdx similarity index 98% rename from apps/docs/docs/libraries/twa-js-sdk/components/web-app.mdx rename to apps/docs/docs/libraries/tma-js-sdk/components/web-app.mdx index 58dd07e34..7a3e447b4 100644 --- a/apps/docs/docs/libraries/twa-js-sdk/components/web-app.mdx +++ b/apps/docs/docs/libraries/tma-js-sdk/components/web-app.mdx @@ -5,7 +5,7 @@ The component which provides the common Web Apps functionality not covered by ot ## Initialization ```typescript -import { WebApp } from '@twa.js/sdk'; +import { WebApp } from '@tma.js/sdk'; // Specify Web Apps version, platform name, header color key // and background color. diff --git a/apps/docs/docs/libraries/twa-dev-bridge.mdx b/apps/docs/docs/libraries/twa-dev-bridge.mdx deleted file mode 100644 index 1cce0f455..000000000 --- a/apps/docs/docs/libraries/twa-dev-bridge.mdx +++ /dev/null @@ -1,196 +0,0 @@ ---- -sidebar_label: "@twa-dev/bridge" -sidebar_position: 100 ---- - -# @twa-dev/bridge - - - -The package provides utilities to simplify communication between web -applications and the Telegram native application. It also addresses -cross-platform data differences, safeguarding developers' code and saving their time. - -Developers can utilize this package to create their software development -kit (SDK), as it offers the utmost level of control over -cross-application communication. - -## Installation - - - -## Init - -The `Bridge` component has a relatively simple API. Its primary purpose is -to provide a communication layer between the Telegram native and client -applications, allowing you to invoke native methods and receive events from -the Telegram application. - -To start using Bridge, simply utilize its static `init` function: - -```typescript -import {Bridge} from '@twa-dev/bridge'; - -const bridge = Bridge.init(); -``` - -This function will append special handler to global window object, which is -used by Telegram native application and make this instance work correctly. - -:::info - -You can use `Bridge.init()` as many times as required. This will not make -any effect on already created `Bridge` instances. - -::: - -### Debugging - -`Bridge` supports debug mode which outputs additional log messages into the -console. By default, this mode is disabled. To enable it, it is required to -pass the `debug: true` option while creating a new `Bridge` instance. - -```typescript -import {Bridge} from '@twa-dev/bridge'; - -const bridge = Bridge.init({debug: true}); -``` - -Or in case when an instance already exists, just change its `debug` property -to `true`: - -```typescript -import {Bridge} from '@twa-dev/bridge'; - -const bridge = Bridge.init({debug: true}); -bridge.debug = true; -``` - -### Target origin - -If the current bridge instance is being used in a browser environment (iframe), -we employ the function `window.parent.postMessage`. This function requires -specifying the target origin to ensure events are only sent to trusted -parent iframes. By default, the bridge utilizes `https://web.telegram.org` -as the origin. To enable event transmission to other origins, you should -utilize the `targetOrigin` option: - -```typescript -const unsafeBridge = Bridge.init({targetOrigin: '*'}); -// or -const safeBridge = Bridge.init({targetOrigin: 'https://myendpoint.org'}); -``` - -It is strongly recommended not to override this value as long as it could lead -to security issues. Specify this value only for test purposes. - -## Calling methods - -### With `Bridge` - -To call Web Apps methods, it is enough to call `Bridge`s `postEvent` method. -This method automatically finds a correct way of sending events which depends -on the current environment. Let's take a look at a simple example: - -```typescript -import {Bridge} from '@twa-dev/bridge'; - -const bridge = Bridge.init(); - -// Close current application. -bridge.postEvent('web_app_close'); -``` - -Some methods don't require parameters and can be called without an additional -second parameter representing the event payload. But some events do require it: - -```typescript -import {Bridge} from '@twa-dev/bridge'; - -const bridge = Bridge.init(); - -// Open new popup. -bridge.postEvent('web_app_open_popup', { - title: 'Web Apps Notification', - message: 'I love Web Apps', - buttons: [{type: 'ok', id: 'ok'}] -}); -``` - -### Without `Bridge` - -This package allows calling methods without creating a new `Bridge` instance. -To perform this action, you should use the `postEvent` function which has the -same type as `bridge.postEvent` (actually, the bridge uses the `postEvent` -function internally): - -```typescript -import {postEvent} from '@twa-dev/bridge'; - -postEvent('web_app_setup_back_button', {is_visible: true}); -``` - -Nevertheless, sometimes you need to handle events sent from the native app -emitted as a response to the called method. For example, you would like to -call the `web_app_request_theme` method. As a result, the native app will -emit a `theme_changed` event. Using the default bridge init flow, this event -will be captured by the bridge instance. We can't say the same about the bare -`postEvent` function, so, do not forget about the response event (if it exists) -handling process. - -## Listening to events - -Events tracking is rather simple thing too. For this purpose, we could -use such methods as `on` and `subscribe`. To remove event listeners, we -use `off` and `unsubscribe`: - -```typescript -import {BridgeEventListener, BridgeEventName, Bridge} from '@twa-dev/bridge'; - -const bridge = Bridge.init(); -const listener: BridgeEventListener<'viewport_changed'> = payload => { - console.log('Viewport changed:', payload) -}; -const subListener = (event: BridgeEventName, ...args: any[]) => { - console.log('Event was called:', event, ...args); -}; - -// Add event listener. -bridge.on('viewport_changed', listener); - -// Add listener for all events. -bridge.subscribe(subListener); - -// Remove event listeners. -bridge.off('viewport_changed', listener); -bridge.unsubscribe(subListener); -``` - -## Checking method support - -Bridge itself does not check if the Web Apps method is supported by the current -version of the platform. To check, if the method is supported, you could use -the `supports` function: - -```typescript -import {supports} from '@twa-dev/bridge'; - -supports('web_app_trigger_haptic_feedback', '6.0'); // false -supports('web_app_trigger_haptic_feedback', '6.1'); // true -``` - -:::tip - -It is recommended to use this function before calling Web Apps methods to -prevent applications from stalling and other unexpected behavior. - -::: - -[//]: # (## Higher-level control) - -[//]: # () -[//]: # (As long as the bridge provides only low-level control, we recommend using) - -[//]: # ([SDK](twa-js-sdk/about) which implements bridge methods. It also provides) - -[//]: # (additional parameter checks, more intuitive method names, and easier usage.) \ No newline at end of file diff --git a/apps/docs/docs/libraries/twa-js-sdk/_category_.json b/apps/docs/docs/libraries/twa-js-sdk/_category_.json deleted file mode 100644 index b1abf2e72..000000000 --- a/apps/docs/docs/libraries/twa-js-sdk/_category_.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "label": "@twa.js/sdk", - "position": 4 -} \ No newline at end of file diff --git a/apps/docs/docs/supported-applications.md b/apps/docs/docs/supported-applications.md index 2967e9583..53e2a7fbf 100644 --- a/apps/docs/docs/supported-applications.md +++ b/apps/docs/docs/supported-applications.md @@ -4,7 +4,7 @@ sidebar_position: 3 # Supported applications -Currently, Telegram Web Apps is presented on the wide list of Telegram +Currently, Telegram Mini Apps is presented on the wide list of Telegram applications: - [Telegram Android](https://github.com/DrKLO/Telegram) `android`; @@ -13,6 +13,6 @@ applications: - [Telegram Desktop](https://github.com/telegramdesktop/tdesktop) `tdesktop`; - [Telegram Web Z](https://github.com/Ajaxy/telegram-tt) `webz`. -Other applications either don't have implementation for Telegram Web Apps, or +Other applications either don't have implementation for Telegram Mini Apps, or support it too poorly. This will probably be useful in the next sections of the documentation. diff --git a/apps/docs/docusaurus.config.js b/apps/docs/docusaurus.config.js index 17a643e92..3b6eb6762 100644 --- a/apps/docs/docusaurus.config.js +++ b/apps/docs/docusaurus.config.js @@ -7,7 +7,7 @@ const darkCodeTheme = require('prism-react-renderer/themes/dracula'); /** @type {import('@docusaurus/types').Config} */ const config = { title: 'Telegram Mini Apps documentation', - tagline: 'Documentation by Telegram Web Apps enthusiasts covering all aspects of development on the platform. Provides lowest level information, guides and useful links.', + tagline: 'Documentation by Telegram Mini Apps enthusiasts covering all aspects of development on the platform. Provides lowest level information, guides and useful links.', favicon: 'img/favicon.ico', // Set the production url of your site here @@ -19,7 +19,7 @@ const config = { // GitHub pages deployment config. // If you aren't using GitHub pages, you don't need these. organizationName: 'telegram-mini-apps', - projectName: 'twa.js', // Usually your repo name. + projectName: 'tma.js', // Usually your repo name. trailingSlash: false, deploymentBranch: 'gh-pages-docs', @@ -41,7 +41,7 @@ const config = { ({ docs: { sidebarPath: require.resolve('./sidebars.js'), - editUrl: 'https://github.com/telegram-mini-apps/twa.js/tree/master/', + editUrl: 'https://github.com/telegram-mini-apps/tma.js/tree/master/', }, blog: false, }), @@ -74,7 +74,7 @@ const config = { type: 'localeDropdown', position: 'right', }, { - href: 'https://github.com/twa-dev/docs', + href: 'https://github.com/Telegram-Mini-Apps/tma.js/tree/master/apps/docs', position: 'right', html: 'GitHub', }], diff --git a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/apps-communication/events.mdx b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/apps-communication/events.mdx index 785881bb1..bf198caa0 100644 --- a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/apps-communication/events.mdx +++ b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/apps-communication/events.mdx @@ -97,7 +97,7 @@ type ReceiveEvent = (eventType: string, eventData: unknown) => void; Эта секция содержит список событий, отправляемых нативным приложением Telegram: их наименования, параметры и описание. Заголовок секции указывает -на минимальную версию Telegram Web Apps, начиная с которой вложенные события +на минимальную версию Telegram Mini Apps, начиная с которой вложенные события могут отправляться. ### v6.0 diff --git a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/apps-communication/how-it-works.md b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/apps-communication/how-it-works.md index b24dc4071..076b7e7d0 100644 --- a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/apps-communication/how-it-works.md +++ b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/apps-communication/how-it-works.md @@ -4,7 +4,7 @@ sidebar_position: 1 # Как это устроено -Для того чтобы понять как устроена функциональность Telegram Web Apps, мы должны +Для того чтобы понять как устроена функциональность Telegram Mini Apps, мы должны начать с изучения процесса взаимодействия нативного приложения Telegram с приложением TWA. @@ -13,10 +13,10 @@ sidebar_position: 1 знать, что эта среда является веб-средой, но, тем не менее, каждая из них предоставляет свой способ коммуникации с нативным приложением. -Чтобы быть более точным, с технической точки зрения Telegram Web Apps - это не +Чтобы быть более точным, с технической точки зрения Telegram Mini Apps - это не новая технология в мире Telegram. Мессенджер уже имеет такую разработку как Telegram Games, которая поверхностно является почти такой же платформой как -Telegram Web Apps. По крайней мере она использует такой же способ +Telegram Mini Apps. По крайней мере она использует такой же способ взаимодействия с нативным приложением. ## Методы и события diff --git a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/apps-communication/methods.mdx b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/apps-communication/methods.mdx index 3fe6647b6..cb8233c43 100644 --- a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/apps-communication/methods.mdx +++ b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/apps-communication/methods.mdx @@ -89,7 +89,7 @@ window.external.notify(JSON.stringify({ :::caution В случае, если приложение TWA пытается вызвать метод, неподдерживаемый -текущей версией Telegram Web Apps, ничего не произойдет. Нативное приложение +текущей версией Telegram Mini Apps, ничего не произойдет. Нативное приложение никак не сигнализирует о том, что вызван неизвестный метод. Это необходимо учитывать в случае кажущейся некорректной работы метода. diff --git a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/functionality/closing-behavior.mdx b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/functionality/closing-behavior.mdx index 91c23ccb5..6f8a00236 100644 --- a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/functionality/closing-behavior.mdx +++ b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/functionality/closing-behavior.mdx @@ -10,7 +10,7 @@ sidebar_position: 2 начала страницы, после чего неосторожным движением сдвинет шторку с приложением вниз. -Telegram Web Apps предоставляет разработчику возможность +Telegram Mini Apps предоставляет разработчику возможность запросить подтверждение закрытия приложения у пользователя и убедиться, что он действительно хочет это сделать. diff --git a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/functionality/haptic-feedback.md b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/functionality/haptic-feedback.md index d85a94128..1f4cbcaee 100644 --- a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/functionality/haptic-feedback.md +++ b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/functionality/haptic-feedback.md @@ -8,7 +8,7 @@ sidebar_position: 3 которые позволяют пользователю взаимодействовать с функционалом приложения. Такими компонентами обычно являются всплывающие окна, кнопки и многие другие. -Telegram Web Apps предоставляет возможность разработчику уведомлять о +Telegram Mini Apps предоставляет возможность разработчику уведомлять о каких-либо процессах и уведомлениях не только визуально (например, при помощи показа всплывающего) окна, но и физически. Такой механизм принято называть тактильным откликом, и, говоря простыми словами, он заключается diff --git a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/guides/creating-new-app.md b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/guides/creating-new-app.md index 672a25528..1254587d7 100644 --- a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/guides/creating-new-app.md +++ b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/guides/creating-new-app.md @@ -1,7 +1,7 @@ # Создание приложения В этой статье мы углубимся в процесс разработки нового приложения на платформе -Telegram Web Apps, выясним, какие именно действия необходимо произвести, +Telegram Mini Apps, выясним, какие именно действия необходимо произвести, чтобы его создать, а также озвучим советы по улучшению процесса создания приложения. @@ -29,13 +29,13 @@ IP напрямую. В production-среде можно указывать то ## Создание приложения в BotFather -Так как приложения Telegram Web Apps технически привязаны к ботам Telegram, +Так как приложения Telegram Mini Apps технически привязаны к ботам Telegram, сперва необходимо создать бота Telegram. Для этого необходимо найти отца всех ботов, бота [BotFather](https://t.me/botfather) и воспользоваться командой `/newbot`, после чего пройти предлагаемый процесс, указав все необходимые данные. Когда бот создан, тут же необходимо использовать команду `/newapp` и снова пройти -процедуру создания уже другой сущности - приложения Telegram Web Apps, +процедуру создания уже другой сущности - приложения Telegram Mini Apps, привязывая его к боту Telegram. С этого момента созданное приложение будет доступно по прямой ссылке вида `https://t.me/{mybot}/{myapp}`. diff --git a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/introduction/about-platform.md b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/introduction/about-platform.md index f91ad4fbf..869401457 100644 --- a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/introduction/about-platform.md +++ b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/introduction/about-platform.md @@ -4,11 +4,11 @@ sidebar_position: 1 # О платформе -Telegram Web Apps это технология, созданная разработчиками такого известного +Telegram Mini Apps это технология, созданная разработчиками такого известного мессенджера как Telegram. Главная её задача - предоставить сторонним разработчикам более гибкий способ коммуникации с пользователями Telegram. -Это может быть не интуитивно понятно, но TWA (Telegram Web Apps), это не +Это может быть не интуитивно понятно, но TWA (Telegram Mini Apps), это не самостоятельные приложения. Технически эта технология является дополнением для такой уже известной разработки Telegram как Telegram Bots. По этой причине на данный момент создание приложения TWA без создания Telegram бота невозможно. diff --git a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/introduction/required-technologies.md b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/introduction/required-technologies.md index 455a9c196..295c41905 100644 --- a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/introduction/required-technologies.md +++ b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/introduction/required-technologies.md @@ -4,7 +4,7 @@ sidebar_position: 3 # Стек технологий -Перед началом разработки на платформе Telegram Web Apps, важно знать как +Перед началом разработки на платформе Telegram Mini Apps, важно знать как устроена платформа с технической точки зрения. Исходя из этого разработчик сможет выбрать язык разработки и необходимый стек технологий. diff --git a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/introduction/usage.md b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/introduction/usage.md index 6c98f98d2..031666ea2 100644 --- a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/introduction/usage.md +++ b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/introduction/usage.md @@ -16,7 +16,7 @@ sidebar_position: 2 функциональная составляющая. Текущая реализация ботов является "консолеподобной", что подходит больше для разработчиков, нежели чем для обычных пользователей. Эта проблема как раз и решается при помощи использования -Telegram Web Apps. +Telegram Mini Apps. Использование TWA открывает доступ разработчикам к созданию более дружелюбных по отношению к пользователю интерфейсов, а также к созданию более комплексных diff --git a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/launch-params/about.md b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/launch-params/about.md index db9555eb5..76c3cb92f 100644 --- a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/launch-params/about.md +++ b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/launch-params/about.md @@ -15,7 +15,7 @@ sidebar_position: 1 локальных способов передачи данных является указание их в адресной строке приложения. Таким образом и вызываемый сервер и загружаемое приложение будут иметь какие-либо заранее известные данные. Собственно, этим же -способом пользуется и технология Telegram Web Apps. +способом пользуется и технология Telegram Mini Apps. Нативное приложение Telegram передает список этих параметров в 2-ух частях URL: @@ -78,7 +78,7 @@ https://t.me/mybot/myapp?startapp=command #### `tgWebAppVersion` -Текущая версия Telegram Web Apps, используемая нативным приложением. Этот +Текущая версия Telegram Mini Apps, используемая нативным приложением. Этот параметр важно использовать, например, перед вызовом [методов](../apps-communication/methods.mdx) для того, чтобы убедиться, что текущая diff --git a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/init-data-golang.md b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/init-data-golang.md index 9ac357216..a744f8e8a 100644 --- a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/init-data-golang.md +++ b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/init-data-golang.md @@ -1,11 +1,11 @@ # init-data-golang -Пакет, который предоставляет утилиты для работы с данными инициализации Telegram Web Apps. Чтобы узнать больше о данных инициализации и их использовании, пожалуйста, обратитесь к [документации](../launch-params/init-data.mdx). +Пакет, который предоставляет утилиты для работы с данными инициализации Telegram Mini Apps. Чтобы узнать больше о данных инициализации и их использовании, пожалуйста, обратитесь к [документации](../launch-params/init-data.mdx). ## Установка ```bash -go get github.com/telegram-web-apps/init-data-golang +go get github.com/telegram-mini-apps/init-data-golang ``` ## Валидация @@ -17,7 +17,7 @@ package main import ( "fmt" - "github.com/Telegram-Web-Apps/init-data-golang" + "github.com/Telegram-Mini-Apps/init-data-golang" "time" ) @@ -46,7 +46,7 @@ package main import ( "fmt" - "github.com/Telegram-Web-Apps/init-data-golang" + "github.com/Telegram-Mini-Apps/init-data-golang" ) func main() { @@ -69,7 +69,7 @@ package main import ( "fmt" - "github.com/Telegram-Web-Apps/init-data-golang" + "github.com/Telegram-Mini-Apps/init-data-golang" "time" ) @@ -96,4 +96,4 @@ func main() { ## GoDoc -Для просмотра GoDoc документации, перейдите по [этой ссылке](https://pkg.go.dev/github.com/telegram-web-apps/init-data-golang). \ No newline at end of file +Для просмотра GoDoc документации, перейдите по [этой ссылке](https://pkg.go.dev/github.com/telegram-mini-apps/init-data-golang). \ No newline at end of file diff --git a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/twa-js-bridge.mdx b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/tma-js-bridge.mdx similarity index 91% rename from apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/twa-js-bridge.mdx rename to apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/tma-js-bridge.mdx index 54bae851a..fb5f19f21 100644 --- a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/twa-js-bridge.mdx +++ b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/tma-js-bridge.mdx @@ -1,6 +1,6 @@ -# @twa.js/bridge +# @tma.js/bridge - + Пакет, который предоставляет утилиты для упрощения процесса взаимодействия между веб-приложениями и нативным приложением Telegram. Он также решает кросс-платформенные проблемы наличия разницы в данных, сокращая время на решение известных проблем. @@ -8,14 +8,14 @@ ## Установка - + ## Вызов методов -Для того чтобы вызвать методы Telegram Web Apps, необходимо использовать функцию `postEvent`: +Для того чтобы вызвать методы Telegram Mini Apps, необходимо использовать функцию `postEvent`: ```typescript -import { postEvent } from '@twa.js/bridge'; +import { postEvent } from '@tma.js/bridge'; postEvent('web_app_setup_back_button', { is_visible: true }); ``` @@ -29,7 +29,7 @@ postEvent('web_app_setup_back_button', { is_visible: true }); Для начала работы с событиями можно использовать такие методы как `on` и `off`. Вот как выглядит базовое использование функции `on`: ```typescript -import { on } from '@twa.js/bridge'; +import { on } from '@tma.js/bridge'; // Начинаем прослушивать событие "viewport_changed". Возвращаемое // значение является функцией, которая удаляет добавленного @@ -45,7 +45,7 @@ removeListener(); Для остановки прослушивания событий можно также использовать функцию `off`: ```typescript -import { on, off, EventListener } from '@twa.js/bridge'; +import { on, off, EventListener } from '@tma.js/bridge'; const listener: EventListener<'viewport_changed'> = payload => { console.log('Viewport changed:', payload); @@ -63,7 +63,7 @@ off('viewport_changed', listener); Для работы сразу со всеми события от нативного приложения Telegram можно использовать такие функции как `subscribe` и `unsubscribe`: ```typescript -import { subscribe, unsubscribe, GlobalEventListener } from '@twa.js/bridge'; +import { subscribe, unsubscribe, GlobalEventListener } from '@tma.js/bridge'; const listener: GlobalEventListener = (event, data) => { console.log('Received event', event, 'with data', data); @@ -81,7 +81,7 @@ unsubscribe(listener); Сама по себе функция `postEvent` не проверяет, поддерживается ли указанный метод текущим нативным приложением Telegram. Для этого используется такая функция как `supports`, которая принимает наименование необходимого метода и текущую векрсию платформы: ```typescript -import {supports} from '@twa.js/bridge'; +import {supports} from '@tma.js/bridge'; supports('web_app_trigger_haptic_feedback', '6.0'); // false supports('web_app_trigger_haptic_feedback', '6.1'); // true @@ -98,7 +98,7 @@ supports('web_app_trigger_haptic_feedback', '6.1'); // true Пакет поддерживает включение режима отладки, который приводит к выводу сообщений, связанных с внутренними процессами пакета. Для изменения режима отладки необходимо использовать функцию `setDebug`: ```typescript -import { setDebug } from '@twa.js/bridge'; +import { setDebug } from '@tma.js/bridge'; setDebug(true); ``` @@ -108,7 +108,7 @@ setDebug(true); В случае, если пакет используется в барузерной среде (iframe), для вызова метода он использут такую функцию как `window.parent.postMessage`. Этот метод требует указания target origin, который предотвращает отправку данных недоверенным родительским фреймам. По умолчанию, пакет использует значение равное `https://web.telegram.org`. Для того чтобы разрешить передачу данных другим фреймам, используйте функцию `setTargetOrigin`: ```typescript -import { setTargetOrigin } from '@twa.js/bridge'; +import { setTargetOrigin } from '@tma.js/bridge'; setTargetOrigin('https://myendpoint.org'); ``` @@ -121,4 +121,4 @@ setTargetOrigin('https://myendpoint.org'); ## Более верхне-уровневый контроль -Ввиду того что пакет предоставляет только низкоуровневый контроль для работы с данными, рекомендуется использовать [SDK](./twa-js-sdk/about.mdx), который в свою очередь использует методы текущего пакета. SDK предоставляет дополнительные проверки параметров, более интуитивные наименования методов, а также более простое использование. +Ввиду того что пакет предоставляет только низкоуровневый контроль для работы с данными, рекомендуется использовать [SDK](./tma-js-sdk/about.mdx), который в свою очередь использует методы текущего пакета. SDK предоставляет дополнительные проверки параметров, более интуитивные наименования методов, а также более простое использование. diff --git a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/twa-js-init-data-node.mdx b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/tma-js-init-data-node.mdx similarity index 78% rename from apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/twa-js-init-data-node.mdx rename to apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/tma-js-init-data-node.mdx index 34986eecc..9fd1d04e0 100644 --- a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/twa-js-init-data-node.mdx +++ b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/tma-js-init-data-node.mdx @@ -1,36 +1,36 @@ --- -sidebar_label: "@twa.js/init-data-node" +sidebar_label: "@tma.js/init-data-node" sidebar_position: 4 --- -# @twa.js/init-data-node +# @tma.js/init-data-node - + -Пакет, который предоставляет утилиты для работы с данными инициализации Telegram Web Apps на серверной стороне. Чтобы узнать больше о данных инициализации и их использовании, пожалуйста, обратитесь к [документации](../launch-params/init-data.mdx). +Пакет, который предоставляет утилиты для работы с данными инициализации Telegram Mini Apps на серверной стороне. Чтобы узнать больше о данных инициализации и их использовании, пожалуйста, обратитесь к [документации](../launch-params/init-data.mdx). :::note -Этот пакет расширяет функциональность библиотеки [`@twa.js/init-data`](twa-js-init-data), включая все её типы и утилиты. Таким образом, нет необходимости устанавливать оба пакета отдельно. +Этот пакет расширяет функциональность библиотеки [`@tma.js/init-data`](tma-js-init-data), включая все её типы и утилиты. Таким образом, нет необходимости устанавливать оба пакета отдельно. ::: ## Установка - + ## Использование ### Парсинг -You can learn more about parsing utilities in [`@twa.js/init-data`](twa-js-init-data#парсинг) documentation. +You can learn more about parsing utilities in [`@tma.js/init-data`](tma-js-init-data#парсинг) documentation. ### Валидация Для проверки подписи данных инициализации используется функция `validate`. Она ожидает, что данные инициализации будут переданы в сыром формате и в определенных случаях выдает ошибку. ```typescript -import { validate } from '@twa.js/init-data-node'; +import { validate } from '@tma.js/init-data-node'; const secretToken = '5768337691:AAH5YkoiEuPk8-FZa32hStHTqXiLPtAEhx8'; const initData = diff --git a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/twa-js-init-data.mdx b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/tma-js-init-data.mdx similarity index 81% rename from apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/twa-js-init-data.mdx rename to apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/tma-js-init-data.mdx index 535d10d98..03df2b664 100644 --- a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/twa-js-init-data.mdx +++ b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/tma-js-init-data.mdx @@ -1,12 +1,12 @@ -# @twa.js/init-data +# @tma.js/init-data - + -Пакет, который предоставляет утилиты для работы с данными инициализации Telegram Web Apps на клиентской стороне. Чтобы узнать больше о данных инициализации и их использовании, пожалуйста, обратитесь к [документации](../launch-params/init-data.mdx). +Пакет, который предоставляет утилиты для работы с данными инициализации Telegram Mini Apps на клиентской стороне. Чтобы узнать больше о данных инициализации и их использовании, пожалуйста, обратитесь к [документации](../launch-params/init-data.mdx). ## Установка - + ## Использование @@ -15,7 +15,7 @@ Эта библиотека включает в себя функцию `initData`, которая может извлекать информацию о данных инициализации из параметров запроса. Вот пример её использования: ```typescript -import { initData } from '@twa.js/init-data'; +import { initData } from '@tma.js/init-data'; // Представим, что мы имеем данные инициализации в сыром формате. Telegram отправляет // их именно в таком формате: @@ -50,5 +50,5 @@ console.log(initData(new URLSearchParams(initDataString))); ### Валидация -Мы переместили утилиты проверки в отдельный [пакет TypeScript](twa-js-init-data-node.mdx). Эти утилиты необходимы только на стороне сервера, так как нет необходимости проверять данные +Мы переместили утилиты проверки в отдельный [пакет TypeScript](tma-js-init-data-node.mdx). Эти утилиты необходимы только на стороне сервера, так как нет необходимости проверять данные инициализации на стороне клиента. diff --git a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/twa-js-sdk-react.mdx b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/tma-js-sdk-react.mdx similarity index 93% rename from apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/twa-js-sdk-react.mdx rename to apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/tma-js-sdk-react.mdx index f891953e8..6d8fc1b36 100644 --- a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/twa-js-sdk-react.mdx +++ b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/tma-js-sdk-react.mdx @@ -1,26 +1,26 @@ -# @twa.js/sdk-react +# @tma.js/sdk-react -Привязки React для [клиентского SDK](twa-js-sdk/about). Включают в себя хуки, компоненты и другие полезные инструменты, которые позволяют использовать React вместе с клиентским SDK для веб-приложений. Автоматически отслеживает изменения в компонентах SDK. +Привязки React для [клиентского SDK](tma-js-sdk/about). Включают в себя хуки, компоненты и другие полезные инструменты, которые позволяют использовать React вместе с клиентским SDK для веб-приложений. Автоматически отслеживает изменения в компонентах SDK. - + ## Установка -Прежде всего, предполагается, что вы уже установили пакет `react`, поскольку он является обязательной зависимостью этого пакета. Установка самого SDK не требуется, так как он уже включен в `@twa.js/sdk-react`. +Прежде всего, предполагается, что вы уже установили пакет `react`, поскольку он является обязательной зависимостью этого пакета. Установка самого SDK не требуется, так как он уже включен в `@tma.js/sdk-react`. - + ## Инициализация ### Использование провайдера SDK -Согласно [документации](twa-js-sdk/about) `@twa.js/sdk`, она состоит из набора компонентов, которые не инициализируются по умолчанию, разработчики должны делать это самостоятельно. Однако SDK предоставляет функцию `init`, которая упрощает процесс создания компонентов и использования стандартного алгоритма работы TWA. Она выполняет все необходимые действия для разработчиков. +Согласно [документации](tma-js-sdk/about) `@tma.js/sdk`, она состоит из набора компонентов, которые не инициализируются по умолчанию, разработчики должны делать это самостоятельно. Однако SDK предоставляет функцию `init`, которая упрощает процесс создания компонентов и использования стандартного алгоритма работы TWA. Она выполняет все необходимые действия для разработчиков. Чтобы сделать функциональность SDK доступной для приложения и разрешить инициализацию вновь созданных компонентов, нам нужно использовать компонент `SDKProvider`. ```typescript jsx import React from 'react'; -import { SDKProvider } from '@twa.js/sdk-react'; +import { SDKProvider } from '@tma.js/sdk-react'; function Root() { return ( @@ -31,11 +31,11 @@ function Root() { } ``` -Внутри, `SDKProvider` использует функцию `init` из `@twa.js/sdk`. Она принимает опциональный список параметров при помощи свойства `initOptions`, описанного [здесь](twa-js-sdk/about#init). +Внутри, `SDKProvider` использует функцию `init` из `@tma.js/sdk`. Она принимает опциональный список параметров при помощи свойства `initOptions`, описанного [здесь](tma-js-sdk/about#init). ```typescript jsx import React from 'react'; -import { SDKProvider, InitOptions } from '@twa.js/sdk-react'; +import { SDKProvider, InitOptions } from '@tma.js/sdk-react'; /** * Корневой компонент всего проекта. @@ -63,7 +63,7 @@ export function Root() { ```typescript jsx import React from 'react'; -import { SDKProvider, SDKContext, useSDK, withSDK } from '@twa.js/sdk-react'; +import { SDKProvider, SDKContext, useSDK, withSDK } from '@tma.js/sdk-react'; function App() { const sdk = useSDK(); @@ -100,7 +100,7 @@ function Root() { ```typescript jsx import React, { PropsWithChildren, useEffect } from 'react'; -import { SDKProvider, useSDK, useBackButton, useWebApp } from '@twa.js/sdk-react'; +import { SDKProvider, useSDK, useBackButton, useWebApp } from '@tma.js/sdk-react'; /** * Часть приложения, которая ничего не знает об инициализации SDK. Она должна @@ -180,7 +180,7 @@ export function Root() { Как только инициализация будет успешно завершена, разработчики должны вызвать функцию `webApp.ready`. Эта функция уведомляет приложение Telegram о том, что текущее веб-приложение готово к отображению. ```typescript jsx -import { useWebApp } from '@twa.js/sdk-react'; +import { useWebApp } from '@tma.js/sdk-react'; import React, { useEffect } from 'react'; function App() { @@ -204,7 +204,7 @@ function App() { ```typescript jsx import React from 'react'; -import { useLaunchParams, withLaunchParams, LaunchParams } from '@twa.js/sdk-react'; +import { useLaunchParams, withLaunchParams, LaunchParams } from '@tma.js/sdk-react'; function DisplayLaunchParams() { const launchParams = useLaunchParams(); @@ -233,7 +233,7 @@ function DisplayLaunchParamsPure({ launchParams }: Props) { const DisplayLaunchParamsWrapped = withLaunchParams(DisplayLaunchParams); ``` -Этот хук вернет результат выполнения функции [`retrieveLaunchParams`](twa-js-sdk/about#launch-parameters) +Этот хук вернет результат выполнения функции [`retrieveLaunchParams`](tma-js-sdk/about#launch-parameters) ### Прочее diff --git a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/twa-js-sdk-solid.mdx b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/tma-js-sdk-solid.mdx similarity index 82% rename from apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/twa-js-sdk-solid.mdx rename to apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/tma-js-sdk-solid.mdx index 0536a2fad..99019c208 100644 --- a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/twa-js-sdk-solid.mdx +++ b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/tma-js-sdk-solid.mdx @@ -1,25 +1,25 @@ -# @twa.js/sdk-solid +# @tma.js/sdk-solid -Биндинги Solid JS для [клиентского SDK](twa-js-sdk/about). Включает в себя хуки, компоненты и утилиты для комфортного использования Solid JS в рамках платформы Telegram Web Apps. +Биндинги Solid JS для [клиентского SDK](tma-js-sdk/about). Включает в себя хуки, компоненты и утилиты для комфортного использования Solid JS в рамках платформы Telegram Mini Apps. - + ## Установка -Прежде всего, предполагается, что вы уже установили пакет `solid-js`, поскольку он является обязательной зависимостью этого пакета. Установка самого SDK не требуется, так как он уже включен в `@twa.js/sdk-solid`. +Прежде всего, предполагается, что вы уже установили пакет `solid-js`, поскольку он является обязательной зависимостью этого пакета. Установка самого SDK не требуется, так как он уже включен в `@tma.js/sdk-solid`. - + ## Использование ### SDKProvider -Согласно [документации](twa-js-sdk/about) `@twa.js/sdk`, она состоит из набора компонентов, которые не инициализируются по умолчанию, разработчики должны делать это самостоятельно. Однако SDK предоставляет функцию `init`, которая упрощает процесс создания компонентов и использования стандартного алгоритма работы TWA. Она выполняет все необходимые действия для разработчиков. +Согласно [документации](tma-js-sdk/about) `@tma.js/sdk`, она состоит из набора компонентов, которые не инициализируются по умолчанию, разработчики должны делать это самостоятельно. Однако SDK предоставляет функцию `init`, которая упрощает процесс создания компонентов и использования стандартного алгоритма работы TWA. Она выполняет все необходимые действия для разработчиков. Чтобы сделать функциональность SDK доступной для приложения и разрешить инициализацию вновь созданных компонентов, нам нужно использовать компонент `SDKProvider`. ```typescript jsx -import { SDKProvider } from '@twa.js/sdk-solid'; +import { SDKProvider } from '@tma.js/sdk-solid'; function Root() { return ( @@ -30,10 +30,10 @@ function Root() { } ``` -Внутри, `SDKProvider` использует функцию `init` из `@twa.js/sdk`. Она принимает опциональный список параметров при помощи свойства `initOptions`, описанного [здесь](twa-js-sdk/about#init). +Внутри, `SDKProvider` использует функцию `init` из `@tma.js/sdk`. Она принимает опциональный список параметров при помощи свойства `initOptions`, описанного [здесь](tma-js-sdk/about#init). ```typescript jsx -import { SDKProvider, SDKInitOptions } from '@twa.js/sdk-solid'; +import { SDKProvider, SDKInitOptions } from '@tma.js/sdk-solid'; function Root() { const options: SDKInitOptions = { @@ -57,7 +57,7 @@ function Root() { Используя компонент `SDKProvider`, дочерние компоненты могут использовать хук `useSDK` для доступа к основной информации SDK. ```typescript jsx -import { SDKProvider, useSDKContext } from '@twa.js/sdk-solid'; +import { SDKProvider, useSDKContext } from '@tma.js/sdk-solid'; function App() { const sdk = useSDKContext(); @@ -88,7 +88,7 @@ function Root() { ```typescript jsx title="Пример использования" import { createMemo, Switch, Match, ParentProps } from 'solid-js'; -import { SDKProvider, useSDK, useSDKContext } from '@twa.js/sdk-solid'; +import { SDKProvider, useSDK, useSDKContext } from '@tma.js/sdk-solid'; function App() { const sdk = useSDK(); @@ -119,7 +119,7 @@ function DisplayGate(props: ParentProps) {

SDK was unable to initialize. Probably, current application is being used - not in Telegram Web Apps environment. + not in Telegram Mini Apps environment.

{errorMessage()}

@@ -145,4 +145,4 @@ function Root() { ## Полноценный пример -[Пример кода](https://github.com/Telegram-Web-Apps/twa.js/blob/master/apps/solid-sdk-example/src/Root.tsx) и использования данного пакета можно найти в [моно-репозитории](https://github.com/Telegram-Web-Apps/twa.js/tree/master/apps/solid-sdk-example). \ No newline at end of file +[Пример кода](https://github.com/Telegram-Mini-Apps/tma.js/blob/master/apps/solid-sdk-example/src/Root.tsx) и использования данного пакета можно найти в [моно-репозитории](https://github.com/Telegram-Mini-Apps/tma.js/tree/master/apps/solid-sdk-example). \ No newline at end of file diff --git a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/tma-js-sdk/_category_.json b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/tma-js-sdk/_category_.json new file mode 100644 index 000000000..bfb64699d --- /dev/null +++ b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/tma-js-sdk/_category_.json @@ -0,0 +1,4 @@ +{ + "label": "@tma.js/sdk", + "position": 4 +} \ No newline at end of file diff --git a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/twa-js-sdk/about.mdx b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/tma-js-sdk/about.mdx similarity index 87% rename from apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/twa-js-sdk/about.mdx rename to apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/tma-js-sdk/about.mdx index 92ed56d7f..1e51ca376 100644 --- a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/twa-js-sdk/about.mdx +++ b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/tma-js-sdk/about.mdx @@ -3,17 +3,17 @@ sidebar_position: 1 sidebar_label: "Основная информация" --- -# @twa.js/sdk +# @tma.js/sdk - + -Библиотека, предназначенная упростить взаимодействие с функционалом платформы Telegram Web Apps, которая предоставляет небольшой набор компонентов, каждый из которых ответственен за свою часть утилит платформы. +Библиотека, предназначенная упростить взаимодействие с функционалом платформы Telegram Mini Apps, которая предоставляет небольшой набор компонентов, каждый из которых ответственен за свою часть утилит платформы. Перед использованием SDK рекомендуется ознакомиться с документацией [платформы](../../introduction/about-platform.md), для укрепления своих знаний о ней, а также для улучшения понимания устройства библиотеки. ## Установка - + ## Инициализация @@ -22,7 +22,7 @@ sidebar_label: "Основная информация" Для упрощения этого процесса SDK предоставляет такую функцию как `init`, которая возвращает инициализированные и готовые к работе экземпляры всех компонентов. Так как процесс инициализации является асинхронным, функция возвращает `Promise` с объектом, в котором представлены все инициализированные компоненты SDK: ```typescript -import { init } from '@twa.js/sdk'; +import { init } from '@tma.js/sdk'; init().then(components => { const { mainButton, viewport } = components; @@ -43,7 +43,7 @@ init().then(components => { Функция `init` принимает объект, представляющий собой опции инициализации. Каждая поле в этом объекте является опциональным, равно как и сам объект: ```typescript -import {init} from '@twa.js/sdk'; +import {init} from '@tma.js/sdk'; init(options); ``` @@ -58,7 +58,7 @@ init(options); #### `checkCompat: boolean` -Включает режим, при котором вызовы методов Telegram Web Apps, не поддерживаемых текущей версией устройства приведут к выбросу ошибки. Этот режим рекомендован к использованию и включен по умолчанию. +Включает режим, при котором вызовы методов Telegram Mini Apps, не поддерживаемых текущей версией устройства приведут к выбросу ошибки. Этот режим рекомендован к использованию и включен по умолчанию. #### `cssVars: boolean` @@ -81,7 +81,7 @@ init(options); #### `targetOrigin: string` -Задает глобальный target origin, который используется функцией `postEvent` пакета bridge. Это значение ограничивает список родительских iframe, которым разрешено получать информацию от текущего веб-приложения. Подробнее об этой опции можно узнать в [этой документации](../twa-js-bridge#target-origin). +Задает глобальный target origin, который используется функцией `postEvent` пакета bridge. Это значение ограничивает список родительских iframe, которым разрешено получать информацию от текущего веб-приложения. Подробнее об этой опции можно узнать в [этой документации](../tma-js-bridge#target-origin). #### `timeout: number` @@ -96,7 +96,7 @@ init(options); Разработчики могут получить параметры запуска при помощи вызова функции `retrieveLaunchParams`. Эта функция обрабатывает все query-параметры, который начинаются с префикса `tgWebApp`. ```typescript -import { retrieveLaunchParams } from '@twa.js/sdk'; +import { retrieveLaunchParams } from '@tma.js/sdk'; console.log(retrieveLaunchParams()); @@ -125,10 +125,10 @@ console.log(retrieveLaunchParams()); ## Определение текущей среды -Иногда возникают случаи, когда необходимо проверить, является ли текущая среда Telegram Web Apps. Для определения случаев, когда текущей средой является TWA, разработчик может использовать функцию `isTWA`: +Иногда возникают случаи, когда необходимо проверить, является ли текущая среда Telegram Mini Apps. Для определения случаев, когда текущей средой является TWA, разработчик может использовать функцию `isTWA`: ```typescript -import { isTWA } from '@twa.js/sdk'; +import { isTWA } from '@tma.js/sdk'; console.log(isTWA()); // true или false ``` @@ -152,7 +152,7 @@ console.log(isTWA()); // true или false Экземпляры компонентов используют стандартный способ прослушивания событий при помощи методов `on` и `off`. Пример использования на компоненте `BackButton`: ```typescript -import { BackButton } from '@twa.js/sdk'; +import { BackButton } from '@tma.js/sdk'; const backButton = new BackButton(...); @@ -168,7 +168,7 @@ backButton.on('click', () => { Практически каждый компонент обладает возможность проверки поддержки своих методов. Для того чтобы проверить, поддерживается ли метод, разработчик должен использовать метод экземпляра `supports()`. Например: ```typescript -import { BackButton } from '@twa.js/sdk'; +import { BackButton } from '@tma.js/sdk'; let backButton = new BackButton('6.0'); console.log(backButton.supports('show')); // false @@ -177,6 +177,6 @@ backButton = new BackButton('6.3'); console.log(backButton.supports('hide')); // true ``` -Этот метод рекомендуется использовать перед вызовом методов Telegram Web Apps, так как только в таком случае разработчик может быть уверен, что он будет выполнен как это требуется. +Этот метод рекомендуется использовать перед вызовом методов Telegram Mini Apps, так как только в таком случае разработчик может быть уверен, что он будет выполнен как это требуется. Список поддерживаемых методов для проверки также описан в документации к каждому компоненту. diff --git a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/twa-js-sdk/components/back-button.mdx b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/tma-js-sdk/components/back-button.mdx similarity index 96% rename from apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/twa-js-sdk/components/back-button.mdx rename to apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/tma-js-sdk/components/back-button.mdx index 1d4a246f9..6f7af5431 100644 --- a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/twa-js-sdk/components/back-button.mdx +++ b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/tma-js-sdk/components/back-button.mdx @@ -5,7 +5,7 @@ ## Инициализация ```typescript -import { BackButton } from '@twa.js/sdk'; +import { BackButton } from '@tma.js/sdk'; const backButton = new BackButton('6.3'); ``` diff --git a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/twa-js-sdk/components/closing-behaviour.mdx b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/tma-js-sdk/components/closing-behaviour.mdx similarity index 95% rename from apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/twa-js-sdk/components/closing-behaviour.mdx rename to apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/tma-js-sdk/components/closing-behaviour.mdx index c1a01ec83..d78cbc265 100644 --- a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/twa-js-sdk/components/closing-behaviour.mdx +++ b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/tma-js-sdk/components/closing-behaviour.mdx @@ -5,7 +5,7 @@ ## Инициализация ```typescript -import { ClosingBehaviour } from '@twa.js/sdk'; +import { ClosingBehaviour } from '@tma.js/sdk'; const closingBehaviour = new ClosingBehaviour(); ``` diff --git a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/twa-js-sdk/components/haptic-feedback.mdx b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/tma-js-sdk/components/haptic-feedback.mdx similarity index 98% rename from apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/twa-js-sdk/components/haptic-feedback.mdx rename to apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/tma-js-sdk/components/haptic-feedback.mdx index 49fd9de10..c794d09f1 100644 --- a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/twa-js-sdk/components/haptic-feedback.mdx +++ b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/tma-js-sdk/components/haptic-feedback.mdx @@ -5,7 +5,7 @@ ## Инициализация ```typescript -import { HapticFeedback } from '@twa.js/sdk'; +import { HapticFeedback } from '@tma.js/sdk'; const haptic = new HapticFeedback('6.3'); ``` diff --git a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/twa-js-sdk/components/init-data.md b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/tma-js-sdk/components/init-data.md similarity index 92% rename from apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/twa-js-sdk/components/init-data.md rename to apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/tma-js-sdk/components/init-data.md index c5af8ba63..8f3b71be0 100644 --- a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/twa-js-sdk/components/init-data.md +++ b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/tma-js-sdk/components/init-data.md @@ -1,7 +1,7 @@ # `InitData` -[user-ref]: https://github.com/Telegram-Web-Apps/twa/blob/master/packages/init-data/src/types.ts#L5 -[chat-ref]: https://github.com/Telegram-Web-Apps/twa/blob/master/packages/init-data/src/types.ts#L55 +[user-ref]: https://github.com/Telegram-Mini-Apps/tma/blob/master/packages/init-data/src/types.ts#L5 +[chat-ref]: https://github.com/Telegram-Mini-Apps/tma/blob/master/packages/init-data/src/types.ts#L55 Компонент, ответственный за отображение данных инициализации приложения. Более подробно про данные инициализации можно прочитать в [документации](../../../launch-params/init-data.mdx). @@ -10,7 +10,7 @@ Этот класс представляет собой объект со свойствами, доступными только для чтения. Для создания его экземпляра разработчик может использовать конструктор: ```typescript -import { InitData } from '@twa.js/sdk'; +import { InitData } from '@tma.js/sdk'; const authDate = new Date(); const hash = 'myhash'; diff --git a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/twa-js-sdk/components/main-button.mdx b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/tma-js-sdk/components/main-button.mdx similarity index 98% rename from apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/twa-js-sdk/components/main-button.mdx rename to apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/tma-js-sdk/components/main-button.mdx index 32a1296f8..40793ab77 100644 --- a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/twa-js-sdk/components/main-button.mdx +++ b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/tma-js-sdk/components/main-button.mdx @@ -5,7 +5,7 @@ ## Инициализация ```typescript -import { BackButton } from '@twa.js/sdk'; +import { BackButton } from '@tma.js/sdk'; const mainButton = new MainButton('#000000', '#ffffff'); ``` diff --git a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/twa-js-sdk/components/popup.mdx b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/tma-js-sdk/components/popup.mdx similarity index 97% rename from apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/twa-js-sdk/components/popup.mdx rename to apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/tma-js-sdk/components/popup.mdx index f4c9ded11..39b31bfb9 100644 --- a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/twa-js-sdk/components/popup.mdx +++ b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/tma-js-sdk/components/popup.mdx @@ -5,7 +5,7 @@ ## Инициализация ```typescript -import { Popup } from '@twa.js/sdk'; +import { Popup } from '@tma.js/sdk'; const popup = new Popup('6.3'); ``` diff --git a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/twa-js-sdk/components/qr-scanner.mdx b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/tma-js-sdk/components/qr-scanner.mdx similarity index 97% rename from apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/twa-js-sdk/components/qr-scanner.mdx rename to apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/tma-js-sdk/components/qr-scanner.mdx index 0b85a1e40..d6f688ed4 100644 --- a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/twa-js-sdk/components/qr-scanner.mdx +++ b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/tma-js-sdk/components/qr-scanner.mdx @@ -5,7 +5,7 @@ ## Инициализация ```typescript -import { QRScanner } from '@twa.js/sdk'; +import { QRScanner } from '@tma.js/sdk'; const scanner = new QRScanner('6.3'); ``` diff --git a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/twa-js-sdk/components/theme-params.mdx b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/tma-js-sdk/components/theme-params.mdx similarity index 94% rename from apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/twa-js-sdk/components/theme-params.mdx rename to apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/tma-js-sdk/components/theme-params.mdx index 9b75d37f1..175bd1e52 100644 --- a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/twa-js-sdk/components/theme-params.mdx +++ b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/tma-js-sdk/components/theme-params.mdx @@ -5,7 +5,7 @@ ## Инициализация ```typescript -import { ThemeParams } from '@twa.js/sdk'; +import { ThemeParams } from '@tma.js/sdk'; const themeParams = new ThemeParams({ backgroundColor: '#ffaabb', @@ -23,7 +23,7 @@ const themeParams = new ThemeParams({ Для получения актуальных параметров темы, разработчик может использовать статичный метод `request()`: ```typescript -import { ThemeParams } from '@twa.js/sdk'; +import { ThemeParams } from '@tma.js/sdk'; ThemeParams.request().then(console.log); @@ -36,7 +36,7 @@ ThemeParams.request().then(console.log); Класс `ThemeParams` имеет возможность создания экземпляра, свойства которого будут синхронизированы с их актуальным состоянием в приложении Telegram. Для получения такого экземпляра используется статичный метод `synced()`: ```typescript -import { ThemeParams } from '@twa.js/sdk'; +import { ThemeParams } from '@tma.js/sdk'; const themeParams = await ThemeParams.synced(); ``` diff --git a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/twa-js-sdk/components/viewport.mdx b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/tma-js-sdk/components/viewport.mdx similarity index 97% rename from apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/twa-js-sdk/components/viewport.mdx rename to apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/tma-js-sdk/components/viewport.mdx index 17f7d459c..5277339c8 100644 --- a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/twa-js-sdk/components/viewport.mdx +++ b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/tma-js-sdk/components/viewport.mdx @@ -5,7 +5,7 @@ ## Инициализация ```typescript -import { Viewport } from '@twa.js/sdk'; +import { Viewport } from '@tma.js/sdk'; // Указываем высоту, ширину, стабильную высоту, а так же статус // раскрытия вьюпорта. @@ -25,7 +25,7 @@ const viewport = new Viewport(390, 365, 300, false); Для получения актуальных данных вьюпорта, разработчик может использовать статичный метод `request()`: ```typescript -import { Viewport } from '@twa.js/sdk'; +import { Viewport } from '@tma.js/sdk'; Viewport.request().then(console.log); @@ -38,7 +38,7 @@ Viewport.request().then(console.log); Класс `Viewport` имеет возможность создания экземпляра, свойства которого будут синхронизированы с их актуальным состоянием в приложении Telegram. Для получения такого экземпляра используется статичный метод `synced()`: ```typescript -import { Viewport } from '@twa.js/sdk'; +import { Viewport } from '@tma.js/sdk'; const viewport = await Viewport.synced(); diff --git a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/twa-js-sdk/components/web-app.mdx b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/tma-js-sdk/components/web-app.mdx similarity index 95% rename from apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/twa-js-sdk/components/web-app.mdx rename to apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/tma-js-sdk/components/web-app.mdx index d62b55d0b..06f4565b4 100644 --- a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/twa-js-sdk/components/web-app.mdx +++ b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/tma-js-sdk/components/web-app.mdx @@ -1,11 +1,11 @@ # `WebApp` -Компонент, который предоставляет доступ к функциональности Telegram Web Apps общего назначения. +Компонент, который предоставляет доступ к функциональности Telegram Mini Apps общего назначения. ## Инициализация ```typescript -import { WebApp } from '@twa.js/sdk'; +import { WebApp } from '@tma.js/sdk'; // Указываем версию платформы, наименование, ключ цвета // заголовка и цвет фона. diff --git a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/twa-dev-bridge.mdx b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/twa-dev-bridge.mdx deleted file mode 100644 index d6f097910..000000000 --- a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/twa-dev-bridge.mdx +++ /dev/null @@ -1,197 +0,0 @@ -# @twa-dev/bridge - - - -Пакет, который предоставляет утилиты для упрощения процесса взаимодействия -между веб-приложениями и нативным приложением Telegram. Он также решает -кросс-платформенные проблемы наличия разницы в данных, сокращая время на -решение известных проблем. - -Разработчики могут использовать данный пакет для создания собственных SDK, так -как он предоставляет сугубо минимальный низкоуровневый контроль. - -## Установка - - - -## Инициализация - -Компонент `Bridge` имеет сравнительно простой API. Главная его цель -заключается в предоставлении слоя для взаимодействия между текущим -веб-приложением и нативными приложением Telegram. Он позволяет вызывать -нативные методы, а также получать события от приложения Telegram. - -Для создания этого компонента, необходимо использовать статичный метод `init`: - -```typescript -import {Bridge} from '@twa-dev/bridge'; - -const bridge = Bridge.init(); -``` - -Данный метод создаст специальный обработчик события и поместит его в -глобальный объект `window`. Этот обработчик используется Telegram для -передачи информации о каких-либо событиях. - -:::info - -Метод `Bridge.init()` можно использовать столько раз, сколько потребуется. Его -запуск не окажет влияния на уже созданные экземпляры `Bridge`. - -::: - -### Отладка - -`Bridge` поддерживает режим отладки, который выводит дополнительные сообщения -в консоль. По умолчанию, этот режим отключен. Чтобы его включить, необходимо -передать свойство `debug: true` при создании экземпляра `Bridge`. - -```typescript -import {Bridge} from '@twa-dev/bridge'; - -const bridge = Bridge.init({debug: true}); -``` - -В случае, когда экземпляр `Bridge` уже был создан, достаточно просто изменить -его свойство `debug` на `true`: - -```typescript -import {Bridge} from '@twa-dev/bridge'; - -const bridge = Bridge.init({debug: true}); -bridge.debug = true; -``` - -### Target origin - -В случае, если текущий экземпляр `Bridge` используется в Telegram Web, он -использует такую функцию как `window.parent.postMessage`. Эта функция требует -передачи `target origin`, который позволяет предостеречь текущее приложение -от отправки недостоверному родительскому iframe-у. По умолчанию, используется -значение `https://web.telegram.org`. Для его изменения необходимо использовать -опцию `targetOrigin`: - -```typescript -const unsafeBridge = Bridge.init({targetOrigin: '*'}); -// or -const safeBridge = Bridge.init({targetOrigin: 'https://myendpoint.org'}); -``` - -:::tip - -Не рекомендуется изменять это значение в production окружении, т.к. в противном -случае это может привести к проблемам с безопасностью. Указывайте это значение -только в целях тестирования, либо избегайте использования wildcard `*`. - -::: - -## Вызов методов - -### С экземпляром `Bridge` - -Для вызова методов Telegram Web Apps, достаточно использовать метод -`Bridge.postEvent`. Этот метод автоматически находит подходящий способ для -отправки события исходя из текущей среды. Простой пример: - -```typescript -import {Bridge} from '@twa-dev/bridge'; - -const bridge = Bridge.init(); - -// Закрываем текущее приложение. -bridge.postEvent('web_app_close'); -``` - -Некоторые методы не требуют параметров и могут быть вызваны без указания второго -аргумента, который представляет собой опции для этого события. Пример -вызова метода с опциями: - -```typescript -import {Bridge} from '@twa-dev/bridge'; - -const bridge = Bridge.init(); - -// Показываем всплывающее окно. -bridge.postEvent('web_app_open_popup', { - title: 'Web Apps Notification', - message: 'I love Web Apps', - buttons: [{type: 'ok', id: 'ok'}] -}); -``` - -### Без экземпляра `Bridge` - -Этот модуль позволяет вызывать методы Telegram Web Apps без использования -экземпляра `Bridge`. Для выполнения этого действия необходимо использовать -функцию `postEvent`, которая по функциональности совпадает с функцией, -описанной в предыдущем разделе (вообще, `Bridge.postEvent` использует -`postEvent`): - -```typescript -import {postEvent} from '@twa-dev/bridge'; - -postEvent('web_app_setup_back_button', {is_visible: true}); -``` - -Тем не менее иногда необходимо обрабатывать события, вызываемые методами. -Например, вы могли бы вызвать метод `web_app_request_theme`. Как результат, -нативное приложение Telegram создаст событие `theme_changed`, которое -необходимо отловить. Для этого варианта одной этой функции будет недостаточно -и придется использовать `Bridge`. - -## Прослушивание событий - -Процесс прослушивания событий также является достаточном простым. Для этого -мы используем такие методы как `on` и `subscribe`. Чтобы перестать прослушивать -события, мы используем `off` и `unsubscribe`: - -```typescript -import {BridgeEventListener, BridgeEventName, Bridge} from '@twa-dev/bridge'; - -const bridge = Bridge.init(); -const listener: BridgeEventListener<'viewport_changed'> = payload => { - console.log('Viewport changed:', payload) -}; -const subListener = (event: BridgeEventName, ...args: any[]) => { - console.log('Event was called:', event, ...args); -}; - -// Добавить слушатель на специфичное событие. -bridge.on('viewport_changed', listener); - -// Добавить слушатель на все события. -bridge.subscribe(subListener); - -// Примеры удаления слушателей. -bridge.off('viewport_changed', listener); -bridge.unsubscribe(subListener); -``` - -## Проверка поддержки метода - -Сам по себе компонент `Bridge` не проверяет, поддерживается ли метод -Web Apps текущей версией платформы. Для того чтобы проверить, поддерживается -ли метод, можно использовать функцию `supports`: - -```typescript -import {supports} from '@twa-dev/bridge'; - -supports('web_app_trigger_haptic_feedback', '6.0'); // false -supports('web_app_trigger_haptic_feedback', '6.1'); // true -``` - -:::tip - -Рекомендуется всегда использовать эту функцию перед вызовом методов Web Apps. -В противном случае приложение может иметь неожидаемое поведение. - -::: - -[//]: # (## Higher-level control) - -[//]: # () -[//]: # (As long as the bridge provides only low-level control, we recommend using) - -[//]: # ([SDK](twa-js-sdk/about) which implements bridge methods. It also provides) - -[//]: # (additional parameter checks, more intuitive method names, and easier usage.) \ No newline at end of file diff --git a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/twa-js-sdk/_category_.json b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/twa-js-sdk/_category_.json deleted file mode 100644 index b1abf2e72..000000000 --- a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/libraries/twa-js-sdk/_category_.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "label": "@twa.js/sdk", - "position": 4 -} \ No newline at end of file diff --git a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/supported-applications.md b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/supported-applications.md index d4e2dbee7..f61b73760 100644 --- a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/supported-applications.md +++ b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/supported-applications.md @@ -4,7 +4,7 @@ sidebar_position: 3 # Поддерживаемые приложения -На данный момент технология Telegram Web Apps представлена на достаточно +На данный момент технология Telegram Mini Apps представлена на достаточно широком списке приложений Telegram: - [Telegram Android](https://github.com/DrKLO/Telegram) `android`; diff --git a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/ui/viewport.mdx b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/ui/viewport.mdx index dff067184..6d897bd67 100644 --- a/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/ui/viewport.mdx +++ b/apps/docs/i18n/ru/docusaurus-plugin-content-docs/current/ui/viewport.mdx @@ -4,7 +4,7 @@ sidebar_position: 4 # Видимая область -Технология Telegram Web Apps позволяет отображать приложение разработчика +Технология Telegram Mini Apps позволяет отображать приложение разработчика на разных платформах, что приводит к увеличению списка возможных устройств пользователей. Учитывая этот факт, важно понимать, что одно устройство может сильно отличаться от другого, и когда на ПК оно всегда будет занимать всю diff --git a/apps/docs/i18n/ru/docusaurus-theme-classic/footer.json b/apps/docs/i18n/ru/docusaurus-theme-classic/footer.json index 9758a6d04..5d99a4635 100644 --- a/apps/docs/i18n/ru/docusaurus-theme-classic/footer.json +++ b/apps/docs/i18n/ru/docusaurus-theme-classic/footer.json @@ -1,6 +1,6 @@ { "copyright": { - "message": "Разработано энтузиастами Telegram Web Apps @ 2023", + "message": "Разработано энтузиастами Telegram Mini Apps @ 2023", "description": "The footer copyright" } }