From 0e89fccc1e5c455072e54508b8f6bfeef6afab08 Mon Sep 17 00:00:00 2001 From: Vladislav Kibenko Date: Wed, 13 Mar 2024 15:04:46 +0300 Subject: [PATCH 1/3] refactor(exports): get rid of barrel files --- packages/sdk/src/back-button/index.ts | 2 - .../sdk/src/bridge/env/hasExternalNotify.ts | 2 +- .../sdk/src/bridge/env/hasWebviewProxy.ts | 2 +- packages/sdk/src/bridge/env/index.ts | 2 - .../bridge/errors/MethodUnsupportedError.ts | 4 +- .../errors/ParameterUnsupportedError.ts | 4 +- packages/sdk/src/bridge/errors/index.ts | 2 - .../sdk/src/bridge/events/createEmitter.ts | 24 +- packages/sdk/src/bridge/events/events.ts | 31 +- packages/sdk/src/bridge/events/index.ts | 9 - .../sdk/src/bridge/events/onTelegramEvent.ts | 2 +- .../events/parsers/clipboardTextReceived.ts | 5 +- .../events/parsers/customMethodInvoked.ts | 5 +- .../sdk/src/bridge/events/parsers/index.ts | 9 - .../bridge/events/parsers/invoiceClosed.ts | 3 +- .../bridge/events/parsers/phoneRequested.ts | 3 +- .../src/bridge/events/parsers/popupClosed.ts | 3 +- .../bridge/events/parsers/qrTextReceived.ts | 3 +- .../bridge/events/parsers/theme-changed.ts | 6 +- .../bridge/events/parsers/viewportChanged.ts | 4 +- .../events/parsers/writeAccessRequested.ts | 3 +- .../sdk/src/bridge/events/singletonEmitter.ts | 4 +- packages/sdk/src/bridge/index.ts | 7 - packages/sdk/src/bridge/invokeCustomMethod.ts | 4 +- .../methods/__tests__/createPostEvent.ts | 4 +- .../src/bridge/methods/__tests__/postEvent.ts | 2 +- .../sdk/src/bridge/methods/createPostEvent.ts | 9 +- .../sdk/src/bridge/methods/custom-methods.ts | 2 +- packages/sdk/src/bridge/methods/index.ts | 6 - packages/sdk/src/bridge/methods/methods.ts | 7 +- packages/sdk/src/bridge/methods/postEvent.ts | 6 +- packages/sdk/src/bridge/parseMessage.ts | 3 +- packages/sdk/src/bridge/request.ts | 35 +- packages/sdk/src/classnames/index.ts | 2 - .../sdk/src/classnames/mergeClassNames.ts | 6 +- packages/sdk/src/closing-behavior/index.ts | 2 - packages/sdk/src/cloud-storage/index.ts | 1 - packages/sdk/src/colors/index.ts | 5 - .../back-button/BackButton.ts | 19 +- .../back-button/__tests__/BackButton.ts | 0 .../src/{ => components}/back-button/types.ts | 4 +- .../closing-behavior/ClosingBehavior.ts | 13 +- .../__tests__/ClosingBehavior.ts | 0 .../closing-behavior/types.ts | 2 +- .../cloud-storage/CloudStorage.ts | 25 +- .../haptic-feedback/HapticFeedback.ts | 20 +- .../__tests__/HapticFeedback.ts | 0 .../{ => components}/init-data/InitData.ts | 0 .../init-data/__tests__/InitData.ts | 0 .../init-data/__tests__/chatParser.ts | 0 .../init-data/__tests__/initDataParser.ts | 0 .../init-data/__tests__/parseInitData.ts | 0 .../init-data/__tests__/userParser.ts | 0 .../{ => components}/init-data/chatParser.ts | 6 +- .../init-data/initDataParser.ts | 6 +- .../init-data/parseInitData.ts | 0 .../src/{ => components}/init-data/types.ts | 0 .../{ => components}/init-data/userParser.ts | 6 +- .../src/{ => components}/invoice/Invoice.ts | 30 +- .../sdk/src/{ => components}/invoice/types.ts | 2 +- .../main-button/MainButton.ts | 16 +- .../main-button/__tests__/MainButton.ts | 0 .../src/{ => components}/main-button/types.ts | 6 +- .../src/{ => components}/mini-app/MiniApp.ts | 50 +- .../mini-app/__tests__/MiniApp.ts | 6 +- .../mini-app/contactParser.ts | 6 +- .../src/{ => components}/mini-app/types.ts | 11 +- .../sdk/src/{ => components}/popup/Popup.ts | 26 +- .../{ => components}/popup/__tests__/Popup.ts | 0 .../popup/__tests__/preparePopupParams.ts | 0 .../popup/preparePopupParams.ts | 2 +- .../sdk/src/{ => components}/popup/types.ts | 2 +- .../{ => components}/qr-scanner/QRScanner.ts | 27 +- .../src/{ => components}/qr-scanner/types.ts | 2 +- .../settings-button/SettingsButton.ts | 19 +- .../{ => components}/settings-button/types.ts | 0 .../theme-params/ThemeParams.ts | 11 +- .../theme-params/__tests__/keys.ts | 0 .../__tests__/parseThemeParams.ts | 0 .../__tests__/serializeThemeParams.ts | 0 .../__tests__/themeParamsParser.ts | 0 .../src/{ => components}/theme-params/keys.ts | 0 .../theme-params/parseThemeParams.ts | 0 .../theme-params/requestThemeParams.ts | 3 +- .../theme-params/serializeThemeParams.ts | 2 +- .../theme-params/themeParamsParser.ts | 8 +- .../{ => components}/theme-params/types.ts | 4 +- .../sdk/src/{ => components}/utils/Utils.ts | 22 +- .../src/{ => components}/viewport/Viewport.ts | 18 +- .../__tests__/isStableViewportPlatform.ts | 0 .../viewport/__tests__/utils.ts | 0 .../viewport/isStableViewportPlatform.ts | 2 +- .../viewport/requestViewport.ts | 3 +- .../src/{ => components}/viewport/types.ts | 4 +- .../src/{ => components}/viewport/utils.ts | 0 .../src/css/__tests__/bindMiniAppCSSVars.ts | 4 +- .../sdk/src/css/__tests__/bindThemeCSSVars.ts | 2 +- .../src/css/__tests__/bindViewportCSSVars.ts | 2 +- packages/sdk/src/css/bindMiniAppCSSVars.ts | 8 +- packages/sdk/src/css/bindThemeCSSVars.ts | 2 +- packages/sdk/src/css/bindViewportCSSVars.ts | 2 +- packages/sdk/src/css/index.ts | 4 - packages/sdk/src/event-emitter/index.ts | 2 - packages/sdk/src/event-emitter/types.ts | 2 +- packages/sdk/src/globals.ts | 2 +- packages/sdk/src/haptic-feedback/index.ts | 1 - packages/sdk/src/index.ts | 440 ++++++++++-------- packages/sdk/src/init-data/index.ts | 6 - packages/sdk/src/init/catchCustomStyles.ts | 2 +- .../init/creators/__tests__/createViewport.ts | 4 +- .../sdk/src/init/creators/createBackButton.ts | 4 +- .../init/creators/createClosingBehavior.ts | 4 +- .../sdk/src/init/creators/createMainButton.ts | 6 +- .../sdk/src/init/creators/createMiniApp.ts | 10 +- .../init/creators/createRequestIdGenerator.ts | 2 +- .../src/init/creators/createSettingsButton.ts | 4 +- .../src/init/creators/createThemeParams.ts | 3 +- .../sdk/src/init/creators/createViewport.ts | 14 +- packages/sdk/src/init/creators/index.ts | 8 - packages/sdk/src/init/css/index.ts | 1 - .../sdk/src/init/css/processCSSVarsOption.ts | 10 +- packages/sdk/src/init/index.ts | 2 - packages/sdk/src/init/init.ts | 44 +- packages/sdk/src/init/types.ts | 32 +- packages/sdk/src/invoice/index.ts | 2 - packages/sdk/src/launch-params/index.ts | 10 - .../src/launch-params/launchParamsParser.ts | 9 +- .../src/launch-params/retrieveLaunchData.ts | 2 +- .../launch-params/serializeLaunchParams.ts | 2 +- packages/sdk/src/launch-params/types.ts | 6 +- packages/sdk/src/logger/index.ts | 1 - packages/sdk/src/main-button/index.ts | 2 - packages/sdk/src/mini-app/index.ts | 2 - packages/sdk/src/misc/index.ts | 5 - packages/sdk/src/misc/isTMA.ts | 2 +- .../navigation/HashNavigator/HashNavigator.ts | 8 +- .../sdk/src/navigation/HashNavigator/index.ts | 2 - .../sdk/src/navigation/HashNavigator/types.ts | 3 +- .../sdk/src/navigation/Navigator/Navigator.ts | 2 +- .../sdk/src/navigation/Navigator/index.ts | 2 - packages/sdk/src/navigation/index.ts | 4 - packages/sdk/src/parsing/ValueParser.ts | 2 +- .../src/parsing/__tests__/ArrayValueParser.ts | 2 +- .../sdk/src/parsing/__tests__/toRecord.ts | 2 +- packages/sdk/src/parsing/index.ts | 10 - packages/sdk/src/parsing/parsers/index.ts | 8 - packages/sdk/src/parsing/parsers/rgb.ts | 4 +- packages/sdk/src/popup/index.ts | 2 - packages/sdk/src/qr-scanner/index.ts | 2 - packages/sdk/src/settings-button/index.ts | 2 - packages/sdk/src/state/State.ts | 4 +- packages/sdk/src/state/index.ts | 2 - packages/sdk/src/state/types.ts | 2 +- packages/sdk/src/storage.ts | 4 +- .../sdk/src/supports/__tests__/supports.ts | 8 +- .../sdk/src/supports/createSupportsFunc.ts | 4 +- .../src/supports/createSupportsParamFunc.ts | 4 +- packages/sdk/src/supports/index.ts | 4 - packages/sdk/src/supports/supports.ts | 8 +- packages/sdk/src/supports/types.ts | 3 + packages/sdk/src/theme-params/index.ts | 6 - .../sdk/src/timeout/__tests__/withTimeout.ts | 4 +- packages/sdk/src/timeout/index.ts | 4 - packages/sdk/src/types/index.ts | 6 - packages/sdk/src/types/methods.ts | 2 +- packages/sdk/src/utils/index.ts | 1 - packages/sdk/src/version/compareVersions.ts | 4 +- packages/sdk/src/version/index.ts | 2 - packages/sdk/src/version/types.ts | 1 + packages/sdk/src/viewport/index.ts | 4 - packages/sdk/vite.config.ts | 24 +- 171 files changed, 680 insertions(+), 762 deletions(-) delete mode 100644 packages/sdk/src/back-button/index.ts delete mode 100644 packages/sdk/src/bridge/env/index.ts delete mode 100644 packages/sdk/src/bridge/errors/index.ts delete mode 100644 packages/sdk/src/bridge/events/index.ts delete mode 100644 packages/sdk/src/bridge/events/parsers/index.ts delete mode 100644 packages/sdk/src/bridge/index.ts delete mode 100644 packages/sdk/src/bridge/methods/index.ts delete mode 100644 packages/sdk/src/classnames/index.ts delete mode 100644 packages/sdk/src/closing-behavior/index.ts delete mode 100644 packages/sdk/src/cloud-storage/index.ts delete mode 100644 packages/sdk/src/colors/index.ts rename packages/sdk/src/{ => components}/back-button/BackButton.ts (77%) rename packages/sdk/src/{ => components}/back-button/__tests__/BackButton.ts (100%) rename packages/sdk/src/{ => components}/back-button/types.ts (71%) rename packages/sdk/src/{ => components}/closing-behavior/ClosingBehavior.ts (76%) rename packages/sdk/src/{ => components}/closing-behavior/__tests__/ClosingBehavior.ts (100%) rename packages/sdk/src/{ => components}/closing-behavior/types.ts (85%) rename packages/sdk/src/{ => components}/cloud-storage/CloudStorage.ts (84%) rename packages/sdk/src/{ => components}/haptic-feedback/HapticFeedback.ts (80%) rename packages/sdk/src/{ => components}/haptic-feedback/__tests__/HapticFeedback.ts (100%) rename packages/sdk/src/{ => components}/init-data/InitData.ts (100%) rename packages/sdk/src/{ => components}/init-data/__tests__/InitData.ts (100%) rename packages/sdk/src/{ => components}/init-data/__tests__/chatParser.ts (100%) rename packages/sdk/src/{ => components}/init-data/__tests__/initDataParser.ts (100%) rename packages/sdk/src/{ => components}/init-data/__tests__/parseInitData.ts (100%) rename packages/sdk/src/{ => components}/init-data/__tests__/userParser.ts (100%) rename packages/sdk/src/{ => components}/init-data/chatParser.ts (60%) rename packages/sdk/src/{ => components}/init-data/initDataParser.ts (76%) rename packages/sdk/src/{ => components}/init-data/parseInitData.ts (100%) rename packages/sdk/src/{ => components}/init-data/types.ts (100%) rename packages/sdk/src/{ => components}/init-data/userParser.ts (75%) rename packages/sdk/src/{ => components}/invoice/Invoice.ts (77%) rename packages/sdk/src/{ => components}/invoice/types.ts (81%) rename packages/sdk/src/{ => components}/main-button/MainButton.ts (92%) rename packages/sdk/src/{ => components}/main-button/__tests__/MainButton.ts (100%) rename packages/sdk/src/{ => components}/main-button/types.ts (76%) rename packages/sdk/src/{ => components}/mini-app/MiniApp.ts (87%) rename packages/sdk/src/{ => components}/mini-app/__tests__/MiniApp.ts (95%) rename packages/sdk/src/{ => components}/mini-app/contactParser.ts (63%) rename packages/sdk/src/{ => components}/mini-app/types.ts (66%) rename packages/sdk/src/{ => components}/popup/Popup.ts (75%) rename packages/sdk/src/{ => components}/popup/__tests__/Popup.ts (100%) rename packages/sdk/src/{ => components}/popup/__tests__/preparePopupParams.ts (100%) rename packages/sdk/src/{ => components}/popup/preparePopupParams.ts (97%) rename packages/sdk/src/{ => components}/popup/types.ts (96%) rename packages/sdk/src/{ => components}/qr-scanner/QRScanner.ts (74%) rename packages/sdk/src/{ => components}/qr-scanner/types.ts (82%) rename packages/sdk/src/{ => components}/settings-button/SettingsButton.ts (76%) rename packages/sdk/src/{ => components}/settings-button/types.ts (100%) rename packages/sdk/src/{ => components}/theme-params/ThemeParams.ts (89%) rename packages/sdk/src/{ => components}/theme-params/__tests__/keys.ts (100%) rename packages/sdk/src/{ => components}/theme-params/__tests__/parseThemeParams.ts (100%) rename packages/sdk/src/{ => components}/theme-params/__tests__/serializeThemeParams.ts (100%) rename packages/sdk/src/{ => components}/theme-params/__tests__/themeParamsParser.ts (100%) rename packages/sdk/src/{ => components}/theme-params/keys.ts (100%) rename packages/sdk/src/{ => components}/theme-params/parseThemeParams.ts (100%) rename packages/sdk/src/{ => components}/theme-params/requestThemeParams.ts (78%) rename packages/sdk/src/{ => components}/theme-params/serializeThemeParams.ts (90%) rename packages/sdk/src/{ => components}/theme-params/themeParamsParser.ts (68%) rename packages/sdk/src/{ => components}/theme-params/types.ts (88%) rename packages/sdk/src/{ => components}/utils/Utils.ts (82%) rename packages/sdk/src/{ => components}/viewport/Viewport.ts (91%) rename packages/sdk/src/{ => components}/viewport/__tests__/isStableViewportPlatform.ts (100%) rename packages/sdk/src/{ => components}/viewport/__tests__/utils.ts (100%) rename packages/sdk/src/{ => components}/viewport/isStableViewportPlatform.ts (84%) rename packages/sdk/src/{ => components}/viewport/requestViewport.ts (83%) rename packages/sdk/src/{ => components}/viewport/types.ts (78%) rename packages/sdk/src/{ => components}/viewport/utils.ts (100%) delete mode 100644 packages/sdk/src/css/index.ts delete mode 100644 packages/sdk/src/event-emitter/index.ts delete mode 100644 packages/sdk/src/haptic-feedback/index.ts delete mode 100644 packages/sdk/src/init-data/index.ts delete mode 100644 packages/sdk/src/init/creators/index.ts delete mode 100644 packages/sdk/src/init/css/index.ts delete mode 100644 packages/sdk/src/init/index.ts delete mode 100644 packages/sdk/src/invoice/index.ts delete mode 100644 packages/sdk/src/launch-params/index.ts delete mode 100644 packages/sdk/src/logger/index.ts delete mode 100644 packages/sdk/src/main-button/index.ts delete mode 100644 packages/sdk/src/mini-app/index.ts delete mode 100644 packages/sdk/src/misc/index.ts delete mode 100644 packages/sdk/src/navigation/HashNavigator/index.ts delete mode 100644 packages/sdk/src/navigation/Navigator/index.ts delete mode 100644 packages/sdk/src/navigation/index.ts delete mode 100644 packages/sdk/src/parsing/index.ts delete mode 100644 packages/sdk/src/parsing/parsers/index.ts delete mode 100644 packages/sdk/src/popup/index.ts delete mode 100644 packages/sdk/src/qr-scanner/index.ts delete mode 100644 packages/sdk/src/settings-button/index.ts delete mode 100644 packages/sdk/src/state/index.ts delete mode 100644 packages/sdk/src/supports/index.ts delete mode 100644 packages/sdk/src/theme-params/index.ts delete mode 100644 packages/sdk/src/timeout/index.ts delete mode 100644 packages/sdk/src/types/index.ts delete mode 100644 packages/sdk/src/utils/index.ts delete mode 100644 packages/sdk/src/version/index.ts delete mode 100644 packages/sdk/src/viewport/index.ts diff --git a/packages/sdk/src/back-button/index.ts b/packages/sdk/src/back-button/index.ts deleted file mode 100644 index fed5b7b76..000000000 --- a/packages/sdk/src/back-button/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './BackButton.js'; -export * from './types.js'; diff --git a/packages/sdk/src/bridge/env/hasExternalNotify.ts b/packages/sdk/src/bridge/env/hasExternalNotify.ts index be5d2e183..cd3aefccd 100644 --- a/packages/sdk/src/bridge/env/hasExternalNotify.ts +++ b/packages/sdk/src/bridge/env/hasExternalNotify.ts @@ -1,4 +1,4 @@ -import { isRecord } from '../../misc/index.js'; +import { isRecord } from '../../misc/isRecord.js'; type WithExternalNotify = T & { external: { diff --git a/packages/sdk/src/bridge/env/hasWebviewProxy.ts b/packages/sdk/src/bridge/env/hasWebviewProxy.ts index 591232675..7dd3f985d 100644 --- a/packages/sdk/src/bridge/env/hasWebviewProxy.ts +++ b/packages/sdk/src/bridge/env/hasWebviewProxy.ts @@ -1,4 +1,4 @@ -import { isRecord } from '../../misc/index.js'; +import { isRecord } from '../../misc/isRecord.js'; type WithWebviewProxy = T & { TelegramWebviewProxy: { diff --git a/packages/sdk/src/bridge/env/index.ts b/packages/sdk/src/bridge/env/index.ts deleted file mode 100644 index b93325fcc..000000000 --- a/packages/sdk/src/bridge/env/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './hasExternalNotify.js'; -export * from './hasWebviewProxy.js'; diff --git a/packages/sdk/src/bridge/errors/MethodUnsupportedError.ts b/packages/sdk/src/bridge/errors/MethodUnsupportedError.ts index 0956f6f51..c2ca5a41a 100644 --- a/packages/sdk/src/bridge/errors/MethodUnsupportedError.ts +++ b/packages/sdk/src/bridge/errors/MethodUnsupportedError.ts @@ -1,5 +1,5 @@ -import type { Version } from '../../version/index.js'; -import type { MiniAppsMethodName } from '../methods/index.js'; +import type { Version } from '../../version/types.js'; +import type { MiniAppsMethodName } from '../methods/methods.js'; /** * Error thrown in case, unsupported method was called. diff --git a/packages/sdk/src/bridge/errors/ParameterUnsupportedError.ts b/packages/sdk/src/bridge/errors/ParameterUnsupportedError.ts index fbd4c509a..ae639ea28 100644 --- a/packages/sdk/src/bridge/errors/ParameterUnsupportedError.ts +++ b/packages/sdk/src/bridge/errors/ParameterUnsupportedError.ts @@ -1,5 +1,5 @@ -import type { Version } from '../../version/index.js'; -import type { MiniAppsMethodName } from '../methods/index.js'; +import type { Version } from '../../version/types.js'; +import type { MiniAppsMethodName } from '../methods/methods.js'; /** * Error thrown in case, unsupported parameter was used. diff --git a/packages/sdk/src/bridge/errors/index.ts b/packages/sdk/src/bridge/errors/index.ts deleted file mode 100644 index d0224616f..000000000 --- a/packages/sdk/src/bridge/errors/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './MethodUnsupportedError.js'; -export * from './ParameterUnsupportedError.js'; diff --git a/packages/sdk/src/bridge/events/createEmitter.ts b/packages/sdk/src/bridge/events/createEmitter.ts index b151f42b4..283f83e04 100644 --- a/packages/sdk/src/bridge/events/createEmitter.ts +++ b/packages/sdk/src/bridge/events/createEmitter.ts @@ -1,19 +1,17 @@ import type { MiniAppsEventEmitter, MiniAppsEventName } from './events.js'; import { onTelegramEvent } from './onTelegramEvent.js'; -import { - clipboardTextReceived, - customMethodInvoked, - invoiceClosed, - phoneRequested, - popupClosed, - qrTextReceived, - themeChanged, - viewportChanged, - writeAccessRequested, -} from './parsers/index.js'; -import { EventEmitter } from '../../event-emitter/index.js'; +import { clipboardTextReceived } from './parsers/clipboardTextReceived.js'; +import { customMethodInvoked } from './parsers/customMethodInvoked.js'; +import { invoiceClosed } from './parsers/invoiceClosed.js'; +import { phoneRequested } from './parsers/phoneRequested.js'; +import { popupClosed } from './parsers/popupClosed.js'; +import { qrTextReceived } from './parsers/qrTextReceived.js'; +import { themeChanged } from './parsers/theme-changed.js'; +import { viewportChanged } from './parsers/viewportChanged.js'; +import { writeAccessRequested } from './parsers/writeAccessRequested.js'; +import { EventEmitter } from '../../event-emitter/EventEmitter.js'; import { logger } from '../../globals.js'; -import { string } from '../../parsing/index.js'; +import { string } from '../../parsing/parsers/string.js'; /** * Returns event emitter which could be safely used, to process events from diff --git a/packages/sdk/src/bridge/events/events.ts b/packages/sdk/src/bridge/events/events.ts index f545cc695..594ef1172 100644 --- a/packages/sdk/src/bridge/events/events.ts +++ b/packages/sdk/src/bridge/events/events.ts @@ -1,21 +1,16 @@ -import type { - ClipboardTextReceivedPayload, - CustomMethodInvokedPayload, - InvoiceClosedPayload, - PhoneRequestedPayload, - PopupClosedPayload, - QrTextReceivedPayload, - ThemeChangedPayload, - ViewportChangedPayload, - WriteAccessRequestedPayload, -} from './parsers/index.js'; -import type { - AnySubscribeListener, - EventEmitter, - EventListener, - EventParams, -} from '../../event-emitter/index.js'; -import type { IsNever, Not } from '../../types/index.js'; +import type { ClipboardTextReceivedPayload } from './parsers/clipboardTextReceived.js'; +import type { CustomMethodInvokedPayload } from './parsers/customMethodInvoked.js'; +import type { InvoiceClosedPayload } from './parsers/invoiceClosed.js'; +import type { PhoneRequestedPayload } from './parsers/phoneRequested.js'; +import type { PopupClosedPayload } from './parsers/popupClosed.js'; +import type { QrTextReceivedPayload } from './parsers/qrTextReceived.js'; +import type { ThemeChangedPayload } from './parsers/theme-changed.js'; +import type { ViewportChangedPayload } from './parsers/viewportChanged.js'; +import type { WriteAccessRequestedPayload } from './parsers/writeAccessRequested.js'; +import type { EventEmitter } from '../../event-emitter/EventEmitter.js'; +import type { AnySubscribeListener, EventListener, EventParams } from '../../event-emitter/types.js'; +import type { Not } from '../../types/logical.js'; +import type { IsNever } from '../../types/utils.js'; /** * Map where key is known event name, and value is its listener. diff --git a/packages/sdk/src/bridge/events/index.ts b/packages/sdk/src/bridge/events/index.ts deleted file mode 100644 index a529e719a..000000000 --- a/packages/sdk/src/bridge/events/index.ts +++ /dev/null @@ -1,9 +0,0 @@ -export * from './createEmitter.js'; -export * from './events.js'; -export * from './off.js'; -export * from './on.js'; -export * from './once.js'; -export * from './parsers/index.js'; -export * from './singletonEmitter.js'; -export * from './subscribe.js'; -export * from './unsubscribe.js'; diff --git a/packages/sdk/src/bridge/events/onTelegramEvent.ts b/packages/sdk/src/bridge/events/onTelegramEvent.ts index 05579535b..27752899d 100644 --- a/packages/sdk/src/bridge/events/onTelegramEvent.ts +++ b/packages/sdk/src/bridge/events/onTelegramEvent.ts @@ -1,4 +1,4 @@ -import { parseMessage } from '../../bridge/parseMessage.js'; +import { parseMessage } from '../parseMessage.js'; /** * Emits event sent from Telegram native application like it was sent in diff --git a/packages/sdk/src/bridge/events/parsers/clipboardTextReceived.ts b/packages/sdk/src/bridge/events/parsers/clipboardTextReceived.ts index 227856a65..150fd86c6 100644 --- a/packages/sdk/src/bridge/events/parsers/clipboardTextReceived.ts +++ b/packages/sdk/src/bridge/events/parsers/clipboardTextReceived.ts @@ -1,5 +1,6 @@ -import { json, string } from '../../../parsing/index.js'; -import type { RequestId } from '../../../types/index.js'; +import { json } from '../../../parsing/parsers/json.js'; +import { string } from '../../../parsing/parsers/string.js'; +import type { RequestId } from '../../../types/request-id.js'; export interface ClipboardTextReceivedPayload { /** diff --git a/packages/sdk/src/bridge/events/parsers/customMethodInvoked.ts b/packages/sdk/src/bridge/events/parsers/customMethodInvoked.ts index e7ac1399d..9f6d00956 100644 --- a/packages/sdk/src/bridge/events/parsers/customMethodInvoked.ts +++ b/packages/sdk/src/bridge/events/parsers/customMethodInvoked.ts @@ -1,5 +1,6 @@ -import { json, string } from '../../../parsing/index.js'; -import type { RequestId } from '../../../types/index.js'; +import { json } from '../../../parsing/parsers/json.js'; +import { string } from '../../../parsing/parsers/string.js'; +import type { RequestId } from '../../../types/request-id.js'; export interface CustomMethodInvokedPayload { /** diff --git a/packages/sdk/src/bridge/events/parsers/index.ts b/packages/sdk/src/bridge/events/parsers/index.ts deleted file mode 100644 index 812202ded..000000000 --- a/packages/sdk/src/bridge/events/parsers/index.ts +++ /dev/null @@ -1,9 +0,0 @@ -export * from './clipboardTextReceived.js'; -export * from './customMethodInvoked.js'; -export * from './invoiceClosed.js'; -export * from './phoneRequested.js'; -export * from './popupClosed.js'; -export * from './qrTextReceived.js'; -export * from './theme-changed.js'; -export * from './viewportChanged.js'; -export * from './writeAccessRequested.js'; diff --git a/packages/sdk/src/bridge/events/parsers/invoiceClosed.ts b/packages/sdk/src/bridge/events/parsers/invoiceClosed.ts index 08e7a2a32..87fc44111 100644 --- a/packages/sdk/src/bridge/events/parsers/invoiceClosed.ts +++ b/packages/sdk/src/bridge/events/parsers/invoiceClosed.ts @@ -1,4 +1,5 @@ -import { json, string } from '../../../parsing/index.js'; +import { json } from '../../../parsing/parsers/json.js'; +import { string } from '../../../parsing/parsers/string.js'; export type InvoiceStatus = | 'paid' diff --git a/packages/sdk/src/bridge/events/parsers/phoneRequested.ts b/packages/sdk/src/bridge/events/parsers/phoneRequested.ts index 449d601ce..2b5ce3720 100644 --- a/packages/sdk/src/bridge/events/parsers/phoneRequested.ts +++ b/packages/sdk/src/bridge/events/parsers/phoneRequested.ts @@ -1,4 +1,5 @@ -import { json, string } from '../../../parsing/index.js'; +import { json } from '../../../parsing/parsers/json.js'; +import { string } from '../../../parsing/parsers/string.js'; export type PhoneRequestedStatus = 'sent' | 'cancelled' | string; diff --git a/packages/sdk/src/bridge/events/parsers/popupClosed.ts b/packages/sdk/src/bridge/events/parsers/popupClosed.ts index 417299d90..2fd90f4ce 100644 --- a/packages/sdk/src/bridge/events/parsers/popupClosed.ts +++ b/packages/sdk/src/bridge/events/parsers/popupClosed.ts @@ -1,4 +1,5 @@ -import { json, string } from '../../../parsing/index.js'; +import { json } from '../../../parsing/parsers/json.js'; +import { string } from '../../../parsing/parsers/string.js'; export interface PopupClosedPayload { /** diff --git a/packages/sdk/src/bridge/events/parsers/qrTextReceived.ts b/packages/sdk/src/bridge/events/parsers/qrTextReceived.ts index 65db0e872..cbbfccdd1 100644 --- a/packages/sdk/src/bridge/events/parsers/qrTextReceived.ts +++ b/packages/sdk/src/bridge/events/parsers/qrTextReceived.ts @@ -1,4 +1,5 @@ -import { json, string } from '../../../parsing/index.js'; +import { json } from '../../../parsing/parsers/json.js'; +import { string } from '../../../parsing/parsers/string.js'; export interface QrTextReceivedPayload { /** diff --git a/packages/sdk/src/bridge/events/parsers/theme-changed.ts b/packages/sdk/src/bridge/events/parsers/theme-changed.ts index b1ec34894..c50e3d287 100644 --- a/packages/sdk/src/bridge/events/parsers/theme-changed.ts +++ b/packages/sdk/src/bridge/events/parsers/theme-changed.ts @@ -1,5 +1,7 @@ -import type { RGB } from '../../../colors/index.js'; -import { json, rgb, toRecord } from '../../../parsing/index.js'; +import type { RGB } from '../../../colors/types.js'; +import { json } from '../../../parsing/parsers/json.js'; +import { rgb } from '../../../parsing/parsers/rgb.js'; +import { toRecord } from '../../../parsing/toRecord.js'; export interface ThemeChangedPayload { /** diff --git a/packages/sdk/src/bridge/events/parsers/viewportChanged.ts b/packages/sdk/src/bridge/events/parsers/viewportChanged.ts index 3a408b893..9494afd68 100644 --- a/packages/sdk/src/bridge/events/parsers/viewportChanged.ts +++ b/packages/sdk/src/bridge/events/parsers/viewportChanged.ts @@ -1,4 +1,6 @@ -import { boolean, json, number } from '../../../parsing/index.js'; +import { boolean } from '../../../parsing/parsers/boolean.js'; +import { json } from '../../../parsing/parsers/json.js'; +import { number } from '../../../parsing/parsers/number.js'; export interface ViewportChangedPayload { /** diff --git a/packages/sdk/src/bridge/events/parsers/writeAccessRequested.ts b/packages/sdk/src/bridge/events/parsers/writeAccessRequested.ts index e48f1cee9..5b2139f54 100644 --- a/packages/sdk/src/bridge/events/parsers/writeAccessRequested.ts +++ b/packages/sdk/src/bridge/events/parsers/writeAccessRequested.ts @@ -1,4 +1,5 @@ -import { json, string } from '../../../parsing/index.js'; +import { json } from '../../../parsing/parsers/json.js'; +import { string } from '../../../parsing/parsers/string.js'; export type WriteAccessRequestedStatus = 'allowed' | string; diff --git a/packages/sdk/src/bridge/events/singletonEmitter.ts b/packages/sdk/src/bridge/events/singletonEmitter.ts index 58c39223f..52bc8941f 100644 --- a/packages/sdk/src/bridge/events/singletonEmitter.ts +++ b/packages/sdk/src/bridge/events/singletonEmitter.ts @@ -1,5 +1,5 @@ -import { createEmitter } from '../../bridge/events/createEmitter.js'; -import type { MiniAppsEventEmitter } from '../../bridge/index.js'; +import { createEmitter } from './createEmitter.js'; +import type { MiniAppsEventEmitter } from './events.js'; const CACHED_EMITTER = 'telegram-mini-apps-cached-emitter'; diff --git a/packages/sdk/src/bridge/index.ts b/packages/sdk/src/bridge/index.ts deleted file mode 100644 index 1c49dc6e0..000000000 --- a/packages/sdk/src/bridge/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -export * from './env/index.js'; -export * from './errors/index.js'; -export * from './events/index.js'; -export * from './methods/index.js'; -export * from './invokeCustomMethod.js'; -export * from './parseMessage.js'; -export * from './request.js'; diff --git a/packages/sdk/src/bridge/invokeCustomMethod.ts b/packages/sdk/src/bridge/invokeCustomMethod.ts index feb8f4f30..7282b9724 100644 --- a/packages/sdk/src/bridge/invokeCustomMethod.ts +++ b/packages/sdk/src/bridge/invokeCustomMethod.ts @@ -1,6 +1,6 @@ -import type { CustomMethodName, CustomMethodParams } from './methods/index.js'; +import type { CustomMethodName, CustomMethodParams } from './methods/custom-methods.js'; import { request } from './request.js'; -import type { ExecuteWithOptions } from '../types/index.js'; +import type { ExecuteWithOptions } from '../types/methods.js'; /** * Invokes known custom method. Returns method execution result. diff --git a/packages/sdk/src/bridge/methods/__tests__/createPostEvent.ts b/packages/sdk/src/bridge/methods/__tests__/createPostEvent.ts index b9dee1dd6..d7ecf4a3b 100644 --- a/packages/sdk/src/bridge/methods/__tests__/createPostEvent.ts +++ b/packages/sdk/src/bridge/methods/__tests__/createPostEvent.ts @@ -1,9 +1,9 @@ import { expect, it, vi } from 'vitest'; -import { createPostEvent } from '../../index'; +import { createPostEvent } from '../createPostEvent'; import * as postEventModule from '../postEvent'; -vi.mock('../../bridge/methods/postEvent.js', () => ({ +vi.mock('../postEvent', () => ({ postEvent: vi.fn(), })); diff --git a/packages/sdk/src/bridge/methods/__tests__/postEvent.ts b/packages/sdk/src/bridge/methods/__tests__/postEvent.ts index 90e6897b6..525224b4d 100644 --- a/packages/sdk/src/bridge/methods/__tests__/postEvent.ts +++ b/packages/sdk/src/bridge/methods/__tests__/postEvent.ts @@ -8,7 +8,7 @@ import { } from 'vitest'; import { setTargetOrigin } from '../../../globals'; -import { postEvent } from '../../index'; +import { postEvent } from '../postEvent'; let windowSpy: SpyInstance<[], Window & typeof globalThis>; diff --git a/packages/sdk/src/bridge/methods/createPostEvent.ts b/packages/sdk/src/bridge/methods/createPostEvent.ts index 7e1284135..3855df319 100644 --- a/packages/sdk/src/bridge/methods/createPostEvent.ts +++ b/packages/sdk/src/bridge/methods/createPostEvent.ts @@ -1,8 +1,9 @@ import { type PostEvent, postEvent } from './postEvent.js'; -import { isRecord } from '../../misc/index.js'; -import { supports } from '../../supports/index.js'; -import type { Version } from '../../version/index.js'; -import { MethodUnsupportedError, ParameterUnsupportedError } from '../errors/index.js'; +import { isRecord } from '../../misc/isRecord.js'; +import { supports } from '../../supports/supports.js'; +import type { Version } from '../../version/types.js'; +import { MethodUnsupportedError } from '../errors/MethodUnsupportedError.js'; +import { ParameterUnsupportedError } from '../errors/ParameterUnsupportedError.js'; /** * Creates function which checks if specified method and parameters are supported. In case, diff --git a/packages/sdk/src/bridge/methods/custom-methods.ts b/packages/sdk/src/bridge/methods/custom-methods.ts index 5f67e9801..ed7d49eb1 100644 --- a/packages/sdk/src/bridge/methods/custom-methods.ts +++ b/packages/sdk/src/bridge/methods/custom-methods.ts @@ -1,4 +1,4 @@ -import type { RequestId } from '../../types/index.js'; +import type { RequestId } from '../../types/request-id.js'; interface CreateInvokeCustomMethodParams { /** diff --git a/packages/sdk/src/bridge/methods/index.ts b/packages/sdk/src/bridge/methods/index.ts deleted file mode 100644 index f4f00991e..000000000 --- a/packages/sdk/src/bridge/methods/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -export * from './createPostEvent.js'; -export * from './custom-methods.js'; -export * from './haptic.js'; -export * from './methods.js'; -export * from './popup.js'; -export * from './postEvent.js'; diff --git a/packages/sdk/src/bridge/methods/methods.ts b/packages/sdk/src/bridge/methods/methods.ts index 6c9da2254..e23d2e94f 100644 --- a/packages/sdk/src/bridge/methods/methods.ts +++ b/packages/sdk/src/bridge/methods/methods.ts @@ -1,8 +1,11 @@ import type { AnyInvokeCustomMethodParams } from './custom-methods.js'; import type { AnyHapticFeedbackParams } from './haptic.js'; import type { PopupParams } from './popup.js'; -import type { RGB } from '../../colors/index.js'; -import type { IsNever, Not, RequestId, UnionKeys } from '../../types/index.js'; +import type { RGB } from '../../colors/types.js'; +import type { Not } from '../../types/logical.js'; +import type { RequestId } from '../../types/request-id.js'; +import type { UnionKeys } from '../../types/unions.js'; +import type { IsNever } from '../../types/utils.js'; /** * Color key which could be used to update header color. diff --git a/packages/sdk/src/bridge/methods/postEvent.ts b/packages/sdk/src/bridge/methods/postEvent.ts index 1ebae9d72..0c0fbe099 100644 --- a/packages/sdk/src/bridge/methods/postEvent.ts +++ b/packages/sdk/src/bridge/methods/postEvent.ts @@ -6,10 +6,8 @@ import type { } from './methods.js'; import { logger, targetOrigin as globalTargetOrigin } from '../../globals.js'; import { isIframe } from '../../misc/isIframe.js'; -import { - hasExternalNotify, - hasWebviewProxy, -} from '../env/index.js'; +import { hasExternalNotify } from '../env/hasExternalNotify.js'; +import { hasWebviewProxy } from '../env/hasWebviewProxy.js'; interface PostEventOptions { /** diff --git a/packages/sdk/src/bridge/parseMessage.ts b/packages/sdk/src/bridge/parseMessage.ts index 9bf3f87db..000fed0af 100644 --- a/packages/sdk/src/bridge/parseMessage.ts +++ b/packages/sdk/src/bridge/parseMessage.ts @@ -1,4 +1,5 @@ -import { json, string } from '../parsing/index.js'; +import { json } from '../parsing/parsers/json.js'; +import { string } from '../parsing/parsers/string.js'; /** * Message format used in communication between client and Telegram applications. diff --git a/packages/sdk/src/bridge/request.ts b/packages/sdk/src/bridge/request.ts index f8eb50ad3..006e67be6 100644 --- a/packages/sdk/src/bridge/request.ts +++ b/packages/sdk/src/bridge/request.ts @@ -1,20 +1,21 @@ -import { - type MiniAppsEventHasParams, - type MiniAppsEventName, - type MiniAppsEventParams, - on, -} from './events/index.js'; -import { - type MiniAppsEmptyMethodName, - type MiniAppsMethodAcceptParams, - type MiniAppsMethodName, - type MiniAppsMethodParams, - type MiniAppsNonEmptyMethodName, - postEvent as defaultPostEvent, -} from './methods/index.js'; -import { isRecord } from '../misc/index.js'; -import { withTimeout } from '../timeout/index.js'; -import type { And, ExecuteWithOptions, If, IsNever } from '../types/index.js'; +import type { + MiniAppsEventHasParams, + MiniAppsEventName, + MiniAppsEventParams, +} from './events/events.js'; +import { on } from './events/on.js'; +import type { + MiniAppsEmptyMethodName, + MiniAppsMethodAcceptParams, + MiniAppsMethodName, + MiniAppsMethodParams, MiniAppsNonEmptyMethodName, +} from './methods/methods.js'; +import { postEvent as defaultPostEvent } from './methods/postEvent.js'; +import { isRecord } from '../misc/isRecord.js'; +import { withTimeout } from '../timeout/withTimeout.js'; +import type { And, If } from '../types/logical.js'; +import type { ExecuteWithOptions } from '../types/methods.js'; +import type { IsNever } from '../types/utils.js'; /** * Names of methods, which require passing "req_id" parameter. diff --git a/packages/sdk/src/classnames/index.ts b/packages/sdk/src/classnames/index.ts deleted file mode 100644 index 051dbd762..000000000 --- a/packages/sdk/src/classnames/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './classNames.js'; -export * from './mergeClassNames.js'; diff --git a/packages/sdk/src/classnames/mergeClassNames.ts b/packages/sdk/src/classnames/mergeClassNames.ts index 00a7ea3e2..b9b874860 100644 --- a/packages/sdk/src/classnames/mergeClassNames.ts +++ b/packages/sdk/src/classnames/mergeClassNames.ts @@ -1,8 +1,8 @@ import { classNames } from './classNames.js'; -import { isRecord } from '../misc/index.js'; -import type { UnionOptionalKeys, UnionRequiredKeys } from '../types/index.js'; +import { isRecord } from '../misc/isRecord.js'; +import type { UnionOptionalKeys, UnionRequiredKeys } from '../types/unions.js'; -type MergeClassNames = +export type MergeClassNames = // Removes all types from union which will be ignored by the mergeClassNames function. Exclude extends infer Union ? { diff --git a/packages/sdk/src/closing-behavior/index.ts b/packages/sdk/src/closing-behavior/index.ts deleted file mode 100644 index 130d62a3f..000000000 --- a/packages/sdk/src/closing-behavior/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './ClosingBehavior.js'; -export * from './types.js'; diff --git a/packages/sdk/src/cloud-storage/index.ts b/packages/sdk/src/cloud-storage/index.ts deleted file mode 100644 index 7647c4a3f..000000000 --- a/packages/sdk/src/cloud-storage/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './CloudStorage.js'; diff --git a/packages/sdk/src/colors/index.ts b/packages/sdk/src/colors/index.ts deleted file mode 100644 index 38427c3ef..000000000 --- a/packages/sdk/src/colors/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export * from './isColorDark.js'; -export * from './isRGB.js'; -export * from './isRGBShort.js'; -export * from './toRGB.js'; -export * from './types.js'; diff --git a/packages/sdk/src/back-button/BackButton.ts b/packages/sdk/src/components/back-button/BackButton.ts similarity index 77% rename from packages/sdk/src/back-button/BackButton.ts rename to packages/sdk/src/components/back-button/BackButton.ts index 15a0bad8e..ef4aba2a9 100644 --- a/packages/sdk/src/back-button/BackButton.ts +++ b/packages/sdk/src/components/back-button/BackButton.ts @@ -1,14 +1,13 @@ import type { BackButtonEvents, BackButtonState } from './types.js'; -import { - off, - on, - type PostEvent, - postEvent as defaultPostEvent, -} from '../bridge/index.js'; -import { EventEmitter } from '../event-emitter/index.js'; -import { State } from '../state/index.js'; -import { createSupportsFunc, type SupportsFunc } from '../supports/index.js'; -import type { Version } from '../version/index.js'; +import { off } from '../../bridge/events/off.js'; +import { on } from '../../bridge/events/on.js'; +import type { PostEvent } from '../../bridge/methods/postEvent.js'; +import { postEvent as defaultPostEvent } from '../../bridge/methods/postEvent.js'; +import { EventEmitter } from '../../event-emitter/EventEmitter.js'; +import { State } from '../../state/State.js'; +import { createSupportsFunc } from '../../supports/createSupportsFunc.js'; +import type { SupportsFunc } from '../../supports/types.js'; +import type { Version } from '../../version/types.js'; type Emitter = EventEmitter; diff --git a/packages/sdk/src/back-button/__tests__/BackButton.ts b/packages/sdk/src/components/back-button/__tests__/BackButton.ts similarity index 100% rename from packages/sdk/src/back-button/__tests__/BackButton.ts rename to packages/sdk/src/components/back-button/__tests__/BackButton.ts diff --git a/packages/sdk/src/back-button/types.ts b/packages/sdk/src/components/back-button/types.ts similarity index 71% rename from packages/sdk/src/back-button/types.ts rename to packages/sdk/src/components/back-button/types.ts index 29acca328..f4a2965cc 100644 --- a/packages/sdk/src/back-button/types.ts +++ b/packages/sdk/src/components/back-button/types.ts @@ -1,5 +1,5 @@ -import type { MiniAppsEventListener } from '../bridge/index.js'; -import type { StateEvents } from '../state/index.js'; +import type { MiniAppsEventListener } from '../../bridge/events/events.js'; +import type { StateEvents } from '../../state/types.js'; export interface BackButtonState { isVisible: boolean; diff --git a/packages/sdk/src/closing-behavior/ClosingBehavior.ts b/packages/sdk/src/components/closing-behavior/ClosingBehavior.ts similarity index 76% rename from packages/sdk/src/closing-behavior/ClosingBehavior.ts rename to packages/sdk/src/components/closing-behavior/ClosingBehavior.ts index 6d4544c1b..99734110a 100644 --- a/packages/sdk/src/closing-behavior/ClosingBehavior.ts +++ b/packages/sdk/src/components/closing-behavior/ClosingBehavior.ts @@ -2,11 +2,12 @@ import type { ClosingBehaviorEvents, ClosingBehaviorState, } from './types.js'; -import { type PostEvent, postEvent as defaultPostEvent } from '../bridge/index.js'; -import { EventEmitter } from '../event-emitter/index.js'; -import { State } from '../state/index.js'; +import type { PostEvent } from '../../bridge/methods/postEvent.js'; +import { postEvent as defaultPostEvent } from '../../bridge/methods/postEvent.js'; +import { EventEmitter } from '../../event-emitter/EventEmitter.js'; +import { State } from '../../state/State.js'; -type ClosingBehaviorEventEmitter = EventEmitter; +type Emitter = EventEmitter; /** * Component responsible for controlling current closing confirmation @@ -56,10 +57,10 @@ export class ClosingBehavior { /** * Adds new event listener. */ - on: ClosingBehaviorEventEmitter['on'] = this.ee.on.bind(this.ee); + on: Emitter['on'] = this.ee.on.bind(this.ee); /** * Removes event listener. */ - off: ClosingBehaviorEventEmitter['off'] = this.ee.off.bind(this.ee); + off: Emitter['off'] = this.ee.off.bind(this.ee); } diff --git a/packages/sdk/src/closing-behavior/__tests__/ClosingBehavior.ts b/packages/sdk/src/components/closing-behavior/__tests__/ClosingBehavior.ts similarity index 100% rename from packages/sdk/src/closing-behavior/__tests__/ClosingBehavior.ts rename to packages/sdk/src/components/closing-behavior/__tests__/ClosingBehavior.ts diff --git a/packages/sdk/src/closing-behavior/types.ts b/packages/sdk/src/components/closing-behavior/types.ts similarity index 85% rename from packages/sdk/src/closing-behavior/types.ts rename to packages/sdk/src/components/closing-behavior/types.ts index 3d964b53b..cc88d68c8 100644 --- a/packages/sdk/src/closing-behavior/types.ts +++ b/packages/sdk/src/components/closing-behavior/types.ts @@ -1,4 +1,4 @@ -import type { StateEvents } from '../state/index.js'; +import type { StateEvents } from '../../state/types.js'; export interface ClosingBehaviorState { isConfirmationNeeded: boolean; diff --git a/packages/sdk/src/cloud-storage/CloudStorage.ts b/packages/sdk/src/components/cloud-storage/CloudStorage.ts similarity index 84% rename from packages/sdk/src/cloud-storage/CloudStorage.ts rename to packages/sdk/src/components/cloud-storage/CloudStorage.ts index 5fcaef28a..20ad6a364 100644 --- a/packages/sdk/src/cloud-storage/CloudStorage.ts +++ b/packages/sdk/src/components/cloud-storage/CloudStorage.ts @@ -1,18 +1,13 @@ -import { - invokeCustomMethod, - postEvent as defaultPostEvent, -} from '../bridge/index.js'; -import { - array, - json, - string, -} from '../parsing/index.js'; -import { - createSupportsFunc, - type SupportsFunc, -} from '../supports/index.js'; -import type { CreateRequestIdFunc, ExecuteWithTimeout } from '../types/index.js'; -import type { Version } from '../version/index.js'; +import { invokeCustomMethod } from '../../bridge/invokeCustomMethod.js'; +import { postEvent as defaultPostEvent } from '../../bridge/methods/postEvent.js'; +import { array } from '../../parsing/parsers/array.js'; +import { json } from '../../parsing/parsers/json.js'; +import { string } from '../../parsing/parsers/string.js'; +import { createSupportsFunc } from '../../supports/createSupportsFunc.js'; +import type { SupportsFunc } from '../../supports/types.js'; +import type { ExecuteWithTimeout } from '../../types/methods.js'; +import type { CreateRequestIdFunc } from '../../types/request-id.js'; +import type { Version } from '../../version/types.js'; function objectFromKeys(keys: K[], value: V): Record { return keys.reduce>((acc, key) => { diff --git a/packages/sdk/src/haptic-feedback/HapticFeedback.ts b/packages/sdk/src/components/haptic-feedback/HapticFeedback.ts similarity index 80% rename from packages/sdk/src/haptic-feedback/HapticFeedback.ts rename to packages/sdk/src/components/haptic-feedback/HapticFeedback.ts index cdae6542a..74daad360 100644 --- a/packages/sdk/src/haptic-feedback/HapticFeedback.ts +++ b/packages/sdk/src/components/haptic-feedback/HapticFeedback.ts @@ -1,14 +1,12 @@ -import { - type ImpactHapticFeedbackStyle, - type NotificationHapticFeedbackType, - type PostEvent, - postEvent as defaultPostEvent, -} from '../bridge/index.js'; -import { - createSupportsFunc, - type SupportsFunc, -} from '../supports/index.js'; -import type { Version } from '../version/index.js'; +import type { + ImpactHapticFeedbackStyle, + NotificationHapticFeedbackType, +} from '../../bridge/methods/haptic.js'; +import type { PostEvent } from '../../bridge/methods/postEvent.js'; +import { postEvent as defaultPostEvent } from '../../bridge/methods/postEvent.js'; +import { createSupportsFunc } from '../../supports/createSupportsFunc.js'; +import type { SupportsFunc } from '../../supports/types.js'; +import type { Version } from '../../version/types.js'; /** * Class which controls haptic feedback. It allows calling different types of diff --git a/packages/sdk/src/haptic-feedback/__tests__/HapticFeedback.ts b/packages/sdk/src/components/haptic-feedback/__tests__/HapticFeedback.ts similarity index 100% rename from packages/sdk/src/haptic-feedback/__tests__/HapticFeedback.ts rename to packages/sdk/src/components/haptic-feedback/__tests__/HapticFeedback.ts diff --git a/packages/sdk/src/init-data/InitData.ts b/packages/sdk/src/components/init-data/InitData.ts similarity index 100% rename from packages/sdk/src/init-data/InitData.ts rename to packages/sdk/src/components/init-data/InitData.ts diff --git a/packages/sdk/src/init-data/__tests__/InitData.ts b/packages/sdk/src/components/init-data/__tests__/InitData.ts similarity index 100% rename from packages/sdk/src/init-data/__tests__/InitData.ts rename to packages/sdk/src/components/init-data/__tests__/InitData.ts diff --git a/packages/sdk/src/init-data/__tests__/chatParser.ts b/packages/sdk/src/components/init-data/__tests__/chatParser.ts similarity index 100% rename from packages/sdk/src/init-data/__tests__/chatParser.ts rename to packages/sdk/src/components/init-data/__tests__/chatParser.ts diff --git a/packages/sdk/src/init-data/__tests__/initDataParser.ts b/packages/sdk/src/components/init-data/__tests__/initDataParser.ts similarity index 100% rename from packages/sdk/src/init-data/__tests__/initDataParser.ts rename to packages/sdk/src/components/init-data/__tests__/initDataParser.ts diff --git a/packages/sdk/src/init-data/__tests__/parseInitData.ts b/packages/sdk/src/components/init-data/__tests__/parseInitData.ts similarity index 100% rename from packages/sdk/src/init-data/__tests__/parseInitData.ts rename to packages/sdk/src/components/init-data/__tests__/parseInitData.ts diff --git a/packages/sdk/src/init-data/__tests__/userParser.ts b/packages/sdk/src/components/init-data/__tests__/userParser.ts similarity index 100% rename from packages/sdk/src/init-data/__tests__/userParser.ts rename to packages/sdk/src/components/init-data/__tests__/userParser.ts diff --git a/packages/sdk/src/init-data/chatParser.ts b/packages/sdk/src/components/init-data/chatParser.ts similarity index 60% rename from packages/sdk/src/init-data/chatParser.ts rename to packages/sdk/src/components/init-data/chatParser.ts index 2d5c3b1cb..eeecb55ac 100644 --- a/packages/sdk/src/init-data/chatParser.ts +++ b/packages/sdk/src/components/init-data/chatParser.ts @@ -1,6 +1,8 @@ import type { Chat } from './types.js'; -import type { ValueParser } from '../parsing/index.js'; -import { json, number, string } from '../parsing/index.js'; +import { json } from '../../parsing/parsers/json.js'; +import { number } from '../../parsing/parsers/number.js'; +import { string } from '../../parsing/parsers/string.js'; +import type { ValueParser } from '../../parsing/ValueParser.js'; /** * Returns parser used to parse chat data. diff --git a/packages/sdk/src/init-data/initDataParser.ts b/packages/sdk/src/components/init-data/initDataParser.ts similarity index 76% rename from packages/sdk/src/init-data/initDataParser.ts rename to packages/sdk/src/components/init-data/initDataParser.ts index 3f25cfe37..bd97292dd 100644 --- a/packages/sdk/src/init-data/initDataParser.ts +++ b/packages/sdk/src/components/init-data/initDataParser.ts @@ -1,7 +1,11 @@ import { chatParser } from './chatParser.js'; import type { InitDataParsed } from './types.js'; import { userParser } from './userParser.js'; -import { date, number, searchParams, string, type ValueParser } from '../parsing/index.js'; +import { date } from '../../parsing/parsers/date.js'; +import { number } from '../../parsing/parsers/number.js'; +import { searchParams } from '../../parsing/parsers/searchParams.js'; +import { string } from '../../parsing/parsers/string.js'; +import type { ValueParser } from '../../parsing/ValueParser.js'; /** * Returns parser used to parse init data, presented as search params. diff --git a/packages/sdk/src/init-data/parseInitData.ts b/packages/sdk/src/components/init-data/parseInitData.ts similarity index 100% rename from packages/sdk/src/init-data/parseInitData.ts rename to packages/sdk/src/components/init-data/parseInitData.ts diff --git a/packages/sdk/src/init-data/types.ts b/packages/sdk/src/components/init-data/types.ts similarity index 100% rename from packages/sdk/src/init-data/types.ts rename to packages/sdk/src/components/init-data/types.ts diff --git a/packages/sdk/src/init-data/userParser.ts b/packages/sdk/src/components/init-data/userParser.ts similarity index 75% rename from packages/sdk/src/init-data/userParser.ts rename to packages/sdk/src/components/init-data/userParser.ts index f0fc10bbd..d59d15822 100644 --- a/packages/sdk/src/init-data/userParser.ts +++ b/packages/sdk/src/components/init-data/userParser.ts @@ -1,5 +1,9 @@ import type { User } from './types.js'; -import { boolean, json, number, string, type ValueParser } from '../parsing/index.js'; +import { boolean } from '../../parsing/parsers/boolean.js'; +import { json } from '../../parsing/parsers/json.js'; +import { number } from '../../parsing/parsers/number.js'; +import { string } from '../../parsing/parsers/string.js'; +import type { ValueParser } from '../../parsing/ValueParser.js'; /** * Returns parser used to parse user data. diff --git a/packages/sdk/src/invoice/Invoice.ts b/packages/sdk/src/components/invoice/Invoice.ts similarity index 77% rename from packages/sdk/src/invoice/Invoice.ts rename to packages/sdk/src/components/invoice/Invoice.ts index 9bd80fca1..5eb8b6f9c 100644 --- a/packages/sdk/src/invoice/Invoice.ts +++ b/packages/sdk/src/components/invoice/Invoice.ts @@ -1,19 +1,15 @@ import type { InvoiceEvents, InvoiceState } from './types.js'; -import { - type InvoiceStatus, - type PostEvent, - postEvent as defaultPostEvent, - request, -} from '../bridge/index.js'; -import { EventEmitter } from '../event-emitter/index.js'; -import { State } from '../state/index.js'; -import { - createSupportsFunc, - type SupportsFunc, -} from '../supports/index.js'; -import type { Version } from '../version/index.js'; - -type InvoiceEventEmitter = EventEmitter; +import type { InvoiceStatus } from '../../bridge/events/parsers/invoiceClosed.js'; +import type { PostEvent } from '../../bridge/methods/postEvent.js'; +import { postEvent as defaultPostEvent } from '../../bridge/methods/postEvent.js'; +import { request } from '../../bridge/request.js'; +import { EventEmitter } from '../../event-emitter/EventEmitter.js'; +import { State } from '../../state/State.js'; +import { createSupportsFunc } from '../../supports/createSupportsFunc.js'; +import type { SupportsFunc } from '../../supports/types.js'; +import type { Version } from '../../version/types.js'; + +type Emitter = EventEmitter; /** * Extracts invoice slug from URL. @@ -67,12 +63,12 @@ export class Invoice { /** * Adds new event listener. */ - on: InvoiceEventEmitter['on'] = this.ee.on.bind(this.ee); + on: Emitter['on'] = this.ee.on.bind(this.ee); /** * Removes event listener. */ - off: InvoiceEventEmitter['off'] = this.ee.off.bind(this.ee); + off: Emitter['off'] = this.ee.off.bind(this.ee); /** * Opens an invoice using its slug. diff --git a/packages/sdk/src/invoice/types.ts b/packages/sdk/src/components/invoice/types.ts similarity index 81% rename from packages/sdk/src/invoice/types.ts rename to packages/sdk/src/components/invoice/types.ts index 4453f8a32..dd9fc66ff 100644 --- a/packages/sdk/src/invoice/types.ts +++ b/packages/sdk/src/components/invoice/types.ts @@ -1,4 +1,4 @@ -import type { StateEvents } from '../state/index.js'; +import type { StateEvents } from '../../state/types.js'; export interface InvoiceState { isOpened: boolean; diff --git a/packages/sdk/src/main-button/MainButton.ts b/packages/sdk/src/components/main-button/MainButton.ts similarity index 92% rename from packages/sdk/src/main-button/MainButton.ts rename to packages/sdk/src/components/main-button/MainButton.ts index 268afaada..875e63edc 100644 --- a/packages/sdk/src/main-button/MainButton.ts +++ b/packages/sdk/src/components/main-button/MainButton.ts @@ -4,15 +4,13 @@ import type { MainButtonProps, MainButtonState, } from './types.js'; -import { - off, - on, - type PostEvent, - postEvent as defaultPostEvent, -} from '../bridge/index.js'; -import type { RGB } from '../colors/index.js'; -import { EventEmitter } from '../event-emitter/index.js'; -import { State } from '../state/index.js'; +import { off } from '../../bridge/events/off.js'; +import { on } from '../../bridge/events/on.js'; +import type { PostEvent } from '../../bridge/methods/postEvent.js'; +import { postEvent as defaultPostEvent } from '../../bridge/methods/postEvent.js'; +import type { RGB } from '../../colors/types.js'; +import { EventEmitter } from '../../event-emitter/EventEmitter.js'; +import { State } from '../../state/State.js'; type Emitter = EventEmitter; diff --git a/packages/sdk/src/main-button/__tests__/MainButton.ts b/packages/sdk/src/components/main-button/__tests__/MainButton.ts similarity index 100% rename from packages/sdk/src/main-button/__tests__/MainButton.ts rename to packages/sdk/src/components/main-button/__tests__/MainButton.ts diff --git a/packages/sdk/src/main-button/types.ts b/packages/sdk/src/components/main-button/types.ts similarity index 76% rename from packages/sdk/src/main-button/types.ts rename to packages/sdk/src/components/main-button/types.ts index fdc5e2efd..74a2484f5 100644 --- a/packages/sdk/src/main-button/types.ts +++ b/packages/sdk/src/components/main-button/types.ts @@ -1,6 +1,6 @@ -import type { PostEvent } from '../bridge/index.js'; -import type { RGB } from '../colors/index.js'; -import type { StateEvents } from '../state/index.js'; +import type { PostEvent } from '../../bridge/methods/postEvent.js'; +import type { RGB } from '../../colors/types.js'; +import type { StateEvents } from '../../state/types.js'; export interface MainButtonParams { backgroundColor?: RGB; diff --git a/packages/sdk/src/mini-app/MiniApp.ts b/packages/sdk/src/components/mini-app/MiniApp.ts similarity index 87% rename from packages/sdk/src/mini-app/MiniApp.ts rename to packages/sdk/src/components/mini-app/MiniApp.ts index 247e0c8e0..3d4e46b65 100644 --- a/packages/sdk/src/mini-app/MiniApp.ts +++ b/packages/sdk/src/components/mini-app/MiniApp.ts @@ -4,31 +4,27 @@ import type { MiniAppHeaderColor, MiniAppProps, MiniAppState, RequestedContact, } from './types.js'; -import { - invokeCustomMethod, - type PhoneRequestedStatus, - type PostEvent, - postEvent as defaultPostEvent, - request, - type SwitchInlineQueryChatType, - type WriteAccessRequestedStatus, -} from '../bridge/index.js'; -import { - isColorDark, - isRGB, - type RGB, -} from '../colors/index.js'; -import { EventEmitter } from '../event-emitter/index.js'; -import { State } from '../state/index.js'; -import { - createSupportsFunc, - createSupportsParamFunc, - type SupportsFunc, -} from '../supports/index.js'; -import { sleep, withTimeout } from '../timeout/index.js'; -import type { CreateRequestIdFunc, ExecuteWithTimeout } from '../types/index.js'; - -type MiniAppEventEmitter = EventEmitter; +import type { PhoneRequestedStatus } from '../../bridge/events/parsers/phoneRequested.js'; +import type { WriteAccessRequestedStatus } from '../../bridge/events/parsers/writeAccessRequested.js'; +import { invokeCustomMethod } from '../../bridge/invokeCustomMethod.js'; +import type { SwitchInlineQueryChatType } from '../../bridge/methods/methods.js'; +import type { PostEvent } from '../../bridge/methods/postEvent.js'; +import { postEvent as defaultPostEvent } from '../../bridge/methods/postEvent.js'; +import { request } from '../../bridge/request.js'; +import { isColorDark } from '../../colors/isColorDark.js'; +import { isRGB } from '../../colors/isRGB.js'; +import type { RGB } from '../../colors/types.js'; +import { EventEmitter } from '../../event-emitter/EventEmitter.js'; +import { State } from '../../state/State.js'; +import { createSupportsFunc } from '../../supports/createSupportsFunc.js'; +import { createSupportsParamFunc } from '../../supports/createSupportsParamFunc.js'; +import type { SupportsFunc } from '../../supports/types.js'; +import { sleep } from '../../timeout/sleep.js'; +import { withTimeout } from '../../timeout/withTimeout.js'; +import type { ExecuteWithTimeout } from '../../types/methods.js'; +import type { CreateRequestIdFunc } from '../../types/request-id.js'; + +type Emitter = EventEmitter; /** * Provides common Mini Apps functionality not covered by other system components. @@ -156,12 +152,12 @@ export class MiniApp { /** * Adds new event listener. */ - on: MiniAppEventEmitter['on'] = this.ee.on.bind(this.ee); + on: Emitter['on'] = this.ee.on.bind(this.ee); /** * Removes event listener. */ - off: MiniAppEventEmitter['off'] = this.ee.off.bind(this.ee); + off: Emitter['off'] = this.ee.off.bind(this.ee); /** * Informs the Telegram app that the Mini App is ready to be displayed. diff --git a/packages/sdk/src/mini-app/__tests__/MiniApp.ts b/packages/sdk/src/components/mini-app/__tests__/MiniApp.ts similarity index 95% rename from packages/sdk/src/mini-app/__tests__/MiniApp.ts rename to packages/sdk/src/components/mini-app/__tests__/MiniApp.ts index 93f87199c..c6b7f08fe 100644 --- a/packages/sdk/src/mini-app/__tests__/MiniApp.ts +++ b/packages/sdk/src/components/mini-app/__tests__/MiniApp.ts @@ -1,10 +1,10 @@ import { describe, expect, it, vi } from 'vitest'; -import type { PostEvent } from '../../bridge'; -import type { RGB } from '../../colors'; -import { createRequestIdGenerator } from '../../init/creators'; import { MiniApp } from '../MiniApp'; import type { MiniAppHeaderColor } from '../types'; +import { RGB } from '../../../colors/types'; +import { PostEvent } from '../../../bridge/methods/postEvent'; +import { createRequestIdGenerator } from '../../../init/creators/createRequestIdGenerator'; interface CreateWebAppOptions { backgroundColor?: RGB; diff --git a/packages/sdk/src/mini-app/contactParser.ts b/packages/sdk/src/components/mini-app/contactParser.ts similarity index 63% rename from packages/sdk/src/mini-app/contactParser.ts rename to packages/sdk/src/components/mini-app/contactParser.ts index a9a388977..a0067d986 100644 --- a/packages/sdk/src/mini-app/contactParser.ts +++ b/packages/sdk/src/components/mini-app/contactParser.ts @@ -1,5 +1,9 @@ import type { RequestedContact } from './types.js'; -import { date, json, number, searchParams, string } from '../parsing/index.js'; +import { date } from '../../parsing/parsers/date.js'; +import { json } from '../../parsing/parsers/json.js'; +import { number } from '../../parsing/parsers/number.js'; +import { searchParams } from '../../parsing/parsers/searchParams.js'; +import { string } from '../../parsing/parsers/string.js'; export const contactParser = searchParams({ contact: json({ diff --git a/packages/sdk/src/mini-app/types.ts b/packages/sdk/src/components/mini-app/types.ts similarity index 66% rename from packages/sdk/src/mini-app/types.ts rename to packages/sdk/src/components/mini-app/types.ts index fecc7677a..93132b54d 100644 --- a/packages/sdk/src/mini-app/types.ts +++ b/packages/sdk/src/components/mini-app/types.ts @@ -1,8 +1,9 @@ -import type { HeaderColorKey, PostEvent } from '../bridge/index.js'; -import type { RGB } from '../colors/index.js'; -import type { StateEvents } from '../state/index.js'; -import type { CreateRequestIdFunc } from '../types/index.js'; -import type { Version } from '../version/index.js'; +import type { HeaderColorKey } from '../../bridge/methods/methods.js'; +import type { PostEvent } from '../../bridge/methods/postEvent.js'; +import type { RGB } from '../../colors/types.js'; +import type { StateEvents } from '../../state/types.js'; +import type { CreateRequestIdFunc } from '../../types/request-id.js'; +import type { Version } from '../../version/types.js'; export interface MiniAppProps { headerColor: MiniAppHeaderColor; diff --git a/packages/sdk/src/popup/Popup.ts b/packages/sdk/src/components/popup/Popup.ts similarity index 75% rename from packages/sdk/src/popup/Popup.ts rename to packages/sdk/src/components/popup/Popup.ts index bef3e2422..d88678a01 100644 --- a/packages/sdk/src/popup/Popup.ts +++ b/packages/sdk/src/components/popup/Popup.ts @@ -1,19 +1,15 @@ import { preparePopupParams } from './preparePopupParams.js'; import type { OpenPopupOptions, PopupEvents, PopupState } from './types.js'; -import { - type PostEvent, - postEvent as defaultPostEvent, - request, -} from '../bridge/index.js'; -import { EventEmitter } from '../event-emitter/index.js'; -import { State } from '../state/index.js'; -import { - createSupportsFunc, - type SupportsFunc, -} from '../supports/index.js'; -import type { Version } from '../version/index.js'; +import type { PostEvent } from '../../bridge/methods/postEvent.js'; +import { postEvent as defaultPostEvent } from '../../bridge/methods/postEvent.js'; +import { request } from '../../bridge/request.js'; +import { EventEmitter } from '../../event-emitter/EventEmitter.js'; +import { State } from '../../state/State.js'; +import { createSupportsFunc } from '../../supports/createSupportsFunc.js'; +import type { SupportsFunc } from '../../supports/types.js'; +import type { Version } from '../../version/types.js'; -type PopupEventEmitter = EventEmitter; +type Emitter = EventEmitter; /** * Controls currently displayed application popup. It allows developers to @@ -46,12 +42,12 @@ export class Popup { /** * Adds new event listener. */ - on: PopupEventEmitter['on'] = this.ee.on.bind(this.ee); + on: Emitter['on'] = this.ee.on.bind(this.ee); /** * Removes event listener. */ - off: PopupEventEmitter['off'] = this.ee.off.bind(this.ee); + off: Emitter['off'] = this.ee.off.bind(this.ee); /** * A method that shows a native popup described by the `params` argument. diff --git a/packages/sdk/src/popup/__tests__/Popup.ts b/packages/sdk/src/components/popup/__tests__/Popup.ts similarity index 100% rename from packages/sdk/src/popup/__tests__/Popup.ts rename to packages/sdk/src/components/popup/__tests__/Popup.ts diff --git a/packages/sdk/src/popup/__tests__/preparePopupParams.ts b/packages/sdk/src/components/popup/__tests__/preparePopupParams.ts similarity index 100% rename from packages/sdk/src/popup/__tests__/preparePopupParams.ts rename to packages/sdk/src/components/popup/__tests__/preparePopupParams.ts diff --git a/packages/sdk/src/popup/preparePopupParams.ts b/packages/sdk/src/components/popup/preparePopupParams.ts similarity index 97% rename from packages/sdk/src/popup/preparePopupParams.ts rename to packages/sdk/src/components/popup/preparePopupParams.ts index 0ab5ac943..56d59f1f4 100644 --- a/packages/sdk/src/popup/preparePopupParams.ts +++ b/packages/sdk/src/components/popup/preparePopupParams.ts @@ -1,5 +1,5 @@ import type { OpenPopupOptions } from './types.js'; -import type { PopupButton, PopupParams as BridgePopupParams } from '../bridge/index.js'; +import type { PopupButton, PopupParams as BridgePopupParams } from '../../bridge/methods/popup.js'; /** * Prepares popup parameters before sending them to native app. diff --git a/packages/sdk/src/popup/types.ts b/packages/sdk/src/components/popup/types.ts similarity index 96% rename from packages/sdk/src/popup/types.ts rename to packages/sdk/src/components/popup/types.ts index d5dc5bfc6..e746e4df1 100644 --- a/packages/sdk/src/popup/types.ts +++ b/packages/sdk/src/components/popup/types.ts @@ -1,4 +1,4 @@ -import type { StateEvents } from '../state/index.js'; +import type { StateEvents } from '../../state/types.js'; export interface PopupState { isOpened: boolean; diff --git a/packages/sdk/src/qr-scanner/QRScanner.ts b/packages/sdk/src/components/qr-scanner/QRScanner.ts similarity index 74% rename from packages/sdk/src/qr-scanner/QRScanner.ts rename to packages/sdk/src/components/qr-scanner/QRScanner.ts index 36ee2bc5d..51d07fb60 100644 --- a/packages/sdk/src/qr-scanner/QRScanner.ts +++ b/packages/sdk/src/components/qr-scanner/QRScanner.ts @@ -1,18 +1,15 @@ import type { QRScannerEvents, QRScannerState } from './types.js'; -import { - type PostEvent, - postEvent as defaultPostEvent, - request, -} from '../bridge/index.js'; -import { EventEmitter } from '../event-emitter/index.js'; -import { State } from '../state/index.js'; -import { - createSupportsFunc, - type SupportsFunc, -} from '../supports/index.js'; -import type { Version } from '../version/index.js'; +import type { PostEvent } from '../../bridge/methods/postEvent.js'; +import { postEvent as defaultPostEvent } from '../../bridge/methods/postEvent.js'; +import { request } from '../../bridge/request.js'; +import { EventEmitter } from '../../event-emitter/EventEmitter.js'; +import { State } from '../../state/State.js'; +import { createSupportsFunc } from '../../supports/createSupportsFunc.js'; +import type { SupportsFunc } from '../../supports/types.js'; +import type { Version } from '../../version/types.js'; + +type Emitter = EventEmitter; -type QRScannerEventEmitter = EventEmitter; /** * Provides QR scanner functionality. */ @@ -81,12 +78,12 @@ export class QRScanner { /** * Adds new event listener. */ - on: QRScannerEventEmitter['on'] = this.ee.on.bind(this.ee); + on: Emitter['on'] = this.ee.on.bind(this.ee); /** * Removes event listener. */ - off: QRScannerEventEmitter['off'] = this.ee.off.bind(this.ee); + off: Emitter['off'] = this.ee.off.bind(this.ee); /** * Checks if specified method is supported by current component. diff --git a/packages/sdk/src/qr-scanner/types.ts b/packages/sdk/src/components/qr-scanner/types.ts similarity index 82% rename from packages/sdk/src/qr-scanner/types.ts rename to packages/sdk/src/components/qr-scanner/types.ts index f56791395..828c33bc2 100644 --- a/packages/sdk/src/qr-scanner/types.ts +++ b/packages/sdk/src/components/qr-scanner/types.ts @@ -1,4 +1,4 @@ -import type { StateEvents } from '../state/index.js'; +import type { StateEvents } from '../../state/types.js'; export interface QRScannerState { isOpened: boolean; diff --git a/packages/sdk/src/settings-button/SettingsButton.ts b/packages/sdk/src/components/settings-button/SettingsButton.ts similarity index 76% rename from packages/sdk/src/settings-button/SettingsButton.ts rename to packages/sdk/src/components/settings-button/SettingsButton.ts index de75208fc..5a13a39c4 100644 --- a/packages/sdk/src/settings-button/SettingsButton.ts +++ b/packages/sdk/src/components/settings-button/SettingsButton.ts @@ -1,14 +1,13 @@ import type { SettingsButtonEvents, SettingsButtonState } from './types.js'; -import { - off, - on, - type PostEvent, - postEvent as defaultPostEvent, -} from '../bridge/index.js'; -import { EventEmitter } from '../event-emitter/index.js'; -import { State } from '../state/index.js'; -import { createSupportsFunc, type SupportsFunc } from '../supports/index.js'; -import type { Version } from '../version/index.js'; +import { off } from '../../bridge/events/off.js'; +import { on } from '../../bridge/events/on.js'; +import type { PostEvent } from '../../bridge/methods/postEvent.js'; +import { postEvent as defaultPostEvent } from '../../bridge/methods/postEvent.js'; +import { EventEmitter } from '../../event-emitter/EventEmitter.js'; +import { State } from '../../state/State.js'; +import { createSupportsFunc } from '../../supports/createSupportsFunc.js'; +import type { SupportsFunc } from '../../supports/types.js'; +import type { Version } from '../../version/types.js'; type Emitter = EventEmitter; diff --git a/packages/sdk/src/settings-button/types.ts b/packages/sdk/src/components/settings-button/types.ts similarity index 100% rename from packages/sdk/src/settings-button/types.ts rename to packages/sdk/src/components/settings-button/types.ts diff --git a/packages/sdk/src/theme-params/ThemeParams.ts b/packages/sdk/src/components/theme-params/ThemeParams.ts similarity index 89% rename from packages/sdk/src/theme-params/ThemeParams.ts rename to packages/sdk/src/components/theme-params/ThemeParams.ts index fc6c1a462..e107a5933 100644 --- a/packages/sdk/src/theme-params/ThemeParams.ts +++ b/packages/sdk/src/components/theme-params/ThemeParams.ts @@ -4,11 +4,12 @@ import type { ThemeParamsParsed, ThemeParamsState, } from './types.js'; -import type { RemoveListenerFn } from '../bridge/index.js'; -import { on } from '../bridge/index.js'; -import { isColorDark, type RGB } from '../colors/index.js'; -import { EventEmitter } from '../event-emitter/index.js'; -import { State } from '../state/index.js'; +import type { RemoveListenerFn } from '../../bridge/events/on.js'; +import { on } from '../../bridge/events/on.js'; +import { isColorDark } from '../../colors/isColorDark.js'; +import type { RGB } from '../../colors/types.js'; +import { EventEmitter } from '../../event-emitter/EventEmitter.js'; +import { State } from '../../state/State.js'; type Emitter = EventEmitter; diff --git a/packages/sdk/src/theme-params/__tests__/keys.ts b/packages/sdk/src/components/theme-params/__tests__/keys.ts similarity index 100% rename from packages/sdk/src/theme-params/__tests__/keys.ts rename to packages/sdk/src/components/theme-params/__tests__/keys.ts diff --git a/packages/sdk/src/theme-params/__tests__/parseThemeParams.ts b/packages/sdk/src/components/theme-params/__tests__/parseThemeParams.ts similarity index 100% rename from packages/sdk/src/theme-params/__tests__/parseThemeParams.ts rename to packages/sdk/src/components/theme-params/__tests__/parseThemeParams.ts diff --git a/packages/sdk/src/theme-params/__tests__/serializeThemeParams.ts b/packages/sdk/src/components/theme-params/__tests__/serializeThemeParams.ts similarity index 100% rename from packages/sdk/src/theme-params/__tests__/serializeThemeParams.ts rename to packages/sdk/src/components/theme-params/__tests__/serializeThemeParams.ts diff --git a/packages/sdk/src/theme-params/__tests__/themeParamsParser.ts b/packages/sdk/src/components/theme-params/__tests__/themeParamsParser.ts similarity index 100% rename from packages/sdk/src/theme-params/__tests__/themeParamsParser.ts rename to packages/sdk/src/components/theme-params/__tests__/themeParamsParser.ts diff --git a/packages/sdk/src/theme-params/keys.ts b/packages/sdk/src/components/theme-params/keys.ts similarity index 100% rename from packages/sdk/src/theme-params/keys.ts rename to packages/sdk/src/components/theme-params/keys.ts diff --git a/packages/sdk/src/theme-params/parseThemeParams.ts b/packages/sdk/src/components/theme-params/parseThemeParams.ts similarity index 100% rename from packages/sdk/src/theme-params/parseThemeParams.ts rename to packages/sdk/src/components/theme-params/parseThemeParams.ts diff --git a/packages/sdk/src/theme-params/requestThemeParams.ts b/packages/sdk/src/components/theme-params/requestThemeParams.ts similarity index 78% rename from packages/sdk/src/theme-params/requestThemeParams.ts rename to packages/sdk/src/components/theme-params/requestThemeParams.ts index 877312952..1bf05f91f 100644 --- a/packages/sdk/src/theme-params/requestThemeParams.ts +++ b/packages/sdk/src/components/theme-params/requestThemeParams.ts @@ -1,6 +1,7 @@ import { parseThemeParams } from './parseThemeParams.js'; import type { ThemeParamsParsed } from './types.js'; -import { request, type RequestOptions } from '../bridge/index.js'; +import type { RequestOptions } from '../../bridge/request.js'; +import { request } from '../../bridge/request.js'; /** * Requests current theme parameters from the Telegram application. diff --git a/packages/sdk/src/theme-params/serializeThemeParams.ts b/packages/sdk/src/components/theme-params/serializeThemeParams.ts similarity index 90% rename from packages/sdk/src/theme-params/serializeThemeParams.ts rename to packages/sdk/src/components/theme-params/serializeThemeParams.ts index 3fabb5db4..42c8f332b 100644 --- a/packages/sdk/src/theme-params/serializeThemeParams.ts +++ b/packages/sdk/src/components/theme-params/serializeThemeParams.ts @@ -1,6 +1,6 @@ import { keyToExternal } from './keys.js'; import type { ThemeParamsParsed } from './types.js'; -import type { RGB } from '../colors/index.js'; +import type { RGB } from '../../colors/types.js'; /** * Serializes theme parameters to representation sent from the Telegram application. diff --git a/packages/sdk/src/theme-params/themeParamsParser.ts b/packages/sdk/src/components/theme-params/themeParamsParser.ts similarity index 68% rename from packages/sdk/src/theme-params/themeParamsParser.ts rename to packages/sdk/src/components/theme-params/themeParamsParser.ts index 7f9e1c28c..0a144ac16 100644 --- a/packages/sdk/src/theme-params/themeParamsParser.ts +++ b/packages/sdk/src/components/theme-params/themeParamsParser.ts @@ -1,11 +1,11 @@ import { keyToLocal } from './keys.js'; import type { ThemeParamsParsed } from './types.js'; -import type { ValueParserGenerator } from '../parsing/index.js'; +import type { ValueParserGenerator } from '../../parsing/createValueParserGenerator.js'; import { createValueParserGenerator, - rgb, - toRecord, -} from '../parsing/index.js'; +} from '../../parsing/createValueParserGenerator.js'; +import { rgb } from '../../parsing/parsers/rgb.js'; +import { toRecord } from '../../parsing/toRecord.js'; // eslint-disable-next-line max-len export const themeParamsParser: ValueParserGenerator = createValueParserGenerator( diff --git a/packages/sdk/src/theme-params/types.ts b/packages/sdk/src/components/theme-params/types.ts similarity index 88% rename from packages/sdk/src/theme-params/types.ts rename to packages/sdk/src/components/theme-params/types.ts index c46ba892b..255feaa56 100644 --- a/packages/sdk/src/theme-params/types.ts +++ b/packages/sdk/src/components/theme-params/types.ts @@ -1,5 +1,5 @@ -import type { RGB } from '../colors/index.js'; -import type { StateEvents } from '../state/index.js'; +import type { RGB } from '../../colors/types.js'; +import type { StateEvents } from '../../state/types.js'; export type ThemeParamsKey = | 'accentTextColor' diff --git a/packages/sdk/src/utils/Utils.ts b/packages/sdk/src/components/utils/Utils.ts similarity index 82% rename from packages/sdk/src/utils/Utils.ts rename to packages/sdk/src/components/utils/Utils.ts index 2327aa967..e2ed38e8e 100644 --- a/packages/sdk/src/utils/Utils.ts +++ b/packages/sdk/src/components/utils/Utils.ts @@ -1,16 +1,12 @@ -import { - type PostEvent, - postEvent as defaultPostEvent, - request, -} from '../bridge/index.js'; -import { - createSupportsFunc, - createSupportsParamFunc, - supports, - type SupportsFunc, -} from '../supports/index.js'; -import type { CreateRequestIdFunc } from '../types/index.js'; -import type { Version } from '../version/index.js'; +import type { PostEvent } from '../../bridge/methods/postEvent.js'; +import { postEvent as defaultPostEvent } from '../../bridge/methods/postEvent.js'; +import { request } from '../../bridge/request.js'; +import { createSupportsFunc } from '../../supports/createSupportsFunc.js'; +import { createSupportsParamFunc } from '../../supports/createSupportsParamFunc.js'; +import { supports } from '../../supports/supports.js'; +import type { SupportsFunc } from '../../supports/types.js'; +import type { CreateRequestIdFunc } from '../../types/request-id.js'; +import type { Version } from '../../version/types.js'; /** * Provides common Mini Apps functionality not covered by other system components. diff --git a/packages/sdk/src/viewport/Viewport.ts b/packages/sdk/src/components/viewport/Viewport.ts similarity index 91% rename from packages/sdk/src/viewport/Viewport.ts rename to packages/sdk/src/components/viewport/Viewport.ts index 50b74f05d..ba5df5d31 100644 --- a/packages/sdk/src/viewport/Viewport.ts +++ b/packages/sdk/src/components/viewport/Viewport.ts @@ -5,17 +5,13 @@ import type { ViewportState, } from './types.js'; import { truncate } from './utils.js'; -import type { - PostEvent, - RemoveListenerFn, - RequestOptions, -} from '../bridge/index.js'; -import { - on, - postEvent as defaultPostEvent, -} from '../bridge/index.js'; -import { EventEmitter } from '../event-emitter/index.js'; -import { State } from '../state/index.js'; +import type { RemoveListenerFn } from '../../bridge/events/on.js'; +import { on } from '../../bridge/events/on.js'; +import type { PostEvent } from '../../bridge/methods/postEvent.js'; +import { postEvent as defaultPostEvent } from '../../bridge/methods/postEvent.js'; +import type { RequestOptions } from '../../bridge/request.js'; +import { EventEmitter } from '../../event-emitter/EventEmitter.js'; +import { State } from '../../state/State.js'; type Emitter = EventEmitter; diff --git a/packages/sdk/src/viewport/__tests__/isStableViewportPlatform.ts b/packages/sdk/src/components/viewport/__tests__/isStableViewportPlatform.ts similarity index 100% rename from packages/sdk/src/viewport/__tests__/isStableViewportPlatform.ts rename to packages/sdk/src/components/viewport/__tests__/isStableViewportPlatform.ts diff --git a/packages/sdk/src/viewport/__tests__/utils.ts b/packages/sdk/src/components/viewport/__tests__/utils.ts similarity index 100% rename from packages/sdk/src/viewport/__tests__/utils.ts rename to packages/sdk/src/components/viewport/__tests__/utils.ts diff --git a/packages/sdk/src/viewport/isStableViewportPlatform.ts b/packages/sdk/src/components/viewport/isStableViewportPlatform.ts similarity index 84% rename from packages/sdk/src/viewport/isStableViewportPlatform.ts rename to packages/sdk/src/components/viewport/isStableViewportPlatform.ts index 1b5c814cc..27640239c 100644 --- a/packages/sdk/src/viewport/isStableViewportPlatform.ts +++ b/packages/sdk/src/components/viewport/isStableViewportPlatform.ts @@ -1,4 +1,4 @@ -import type { Platform } from '../types/index.js'; +import type { Platform } from '../../types/platform.js'; /** * Returns true if specified platform has stable viewport. Stable means not changing from time to diff --git a/packages/sdk/src/viewport/requestViewport.ts b/packages/sdk/src/components/viewport/requestViewport.ts similarity index 83% rename from packages/sdk/src/viewport/requestViewport.ts rename to packages/sdk/src/components/viewport/requestViewport.ts index 24d516a60..b815cc06d 100644 --- a/packages/sdk/src/viewport/requestViewport.ts +++ b/packages/sdk/src/components/viewport/requestViewport.ts @@ -1,4 +1,5 @@ -import { request, type RequestOptions } from '../bridge/index.js'; +import type { RequestOptions } from '../../bridge/request.js'; +import { request } from '../../bridge/request.js'; export interface RequestViewportResult { height: number; diff --git a/packages/sdk/src/viewport/types.ts b/packages/sdk/src/components/viewport/types.ts similarity index 78% rename from packages/sdk/src/viewport/types.ts rename to packages/sdk/src/components/viewport/types.ts index a54d9eed9..f1bbdd319 100644 --- a/packages/sdk/src/viewport/types.ts +++ b/packages/sdk/src/components/viewport/types.ts @@ -1,5 +1,5 @@ -import type { PostEvent } from '../bridge/index.js'; -import type { StateEvents } from '../state/index.js'; +import type { PostEvent } from '../../bridge/methods/postEvent.js'; +import type { StateEvents } from '../../state/types.js'; export interface ViewportProps { height: number; diff --git a/packages/sdk/src/viewport/utils.ts b/packages/sdk/src/components/viewport/utils.ts similarity index 100% rename from packages/sdk/src/viewport/utils.ts rename to packages/sdk/src/components/viewport/utils.ts diff --git a/packages/sdk/src/css/__tests__/bindMiniAppCSSVars.ts b/packages/sdk/src/css/__tests__/bindMiniAppCSSVars.ts index 0a7848937..3859f2680 100644 --- a/packages/sdk/src/css/__tests__/bindMiniAppCSSVars.ts +++ b/packages/sdk/src/css/__tests__/bindMiniAppCSSVars.ts @@ -1,8 +1,8 @@ import { expect, vi, it, SpyInstance, afterEach, beforeAll, describe } from 'vitest'; -import { ThemeParams } from '../../theme-params'; import { dispatchWindowMessageEvent } from '../../../test-utils/dispatchWindowMessageEvent'; import { bindMiniAppCSSVars } from '../bindMiniAppCSSVars'; -import { MiniApp } from '../../mini-app'; +import { MiniApp } from '../../components/mini-app/MiniApp'; +import { ThemeParams } from '../../components/theme-params/ThemeParams'; let setCSSPropertySpy: SpyInstance<[string, string, string?], void>; diff --git a/packages/sdk/src/css/__tests__/bindThemeCSSVars.ts b/packages/sdk/src/css/__tests__/bindThemeCSSVars.ts index fa780d572..8832f0cc5 100644 --- a/packages/sdk/src/css/__tests__/bindThemeCSSVars.ts +++ b/packages/sdk/src/css/__tests__/bindThemeCSSVars.ts @@ -1,7 +1,7 @@ import { expect, vi, it, SpyInstance, afterEach, beforeAll } from 'vitest'; import { bindThemeCSSVars } from '../bindThemeCSSVars'; -import { ThemeParams } from '../../theme-params'; import { dispatchWindowMessageEvent } from '../../../test-utils/dispatchWindowMessageEvent'; +import { ThemeParams } from '../../components/theme-params/ThemeParams'; let setCSSPropertySpy: SpyInstance<[string, string, string?], void>; diff --git a/packages/sdk/src/css/__tests__/bindViewportCSSVars.ts b/packages/sdk/src/css/__tests__/bindViewportCSSVars.ts index 4de803af4..20eb6edf8 100644 --- a/packages/sdk/src/css/__tests__/bindViewportCSSVars.ts +++ b/packages/sdk/src/css/__tests__/bindViewportCSSVars.ts @@ -1,7 +1,7 @@ import { expect, vi, it, SpyInstance, afterEach, beforeAll } from 'vitest'; import { bindViewportCSSVars } from '../bindViewportCSSVars'; -import { Viewport } from '../../viewport'; import { dispatchWindowMessageEvent } from '../../../test-utils/dispatchWindowMessageEvent'; +import { Viewport } from '../../components/viewport/Viewport'; let setCSSPropertySpy: SpyInstance<[string, string, string?], void>; diff --git a/packages/sdk/src/css/bindMiniAppCSSVars.ts b/packages/sdk/src/css/bindMiniAppCSSVars.ts index 2e679d259..92d3bd477 100644 --- a/packages/sdk/src/css/bindMiniAppCSSVars.ts +++ b/packages/sdk/src/css/bindMiniAppCSSVars.ts @@ -1,7 +1,7 @@ -import { isRGB } from '../colors/index.js'; -import { setCSSVar } from '../css/setCSSVar.js'; -import type { MiniApp } from '../mini-app/index.js'; -import type { ThemeParams } from '../theme-params/index.js'; +import { setCSSVar } from './setCSSVar.js'; +import { isRGB } from '../colors/isRGB.js'; +import type { MiniApp } from '../components/mini-app/MiniApp.js'; +import type { ThemeParams } from '../components/theme-params/ThemeParams.js'; /** * Creates CSS variables connected with WebApp background and header colors based on diff --git a/packages/sdk/src/css/bindThemeCSSVars.ts b/packages/sdk/src/css/bindThemeCSSVars.ts index ba0415376..451a7b87d 100644 --- a/packages/sdk/src/css/bindThemeCSSVars.ts +++ b/packages/sdk/src/css/bindThemeCSSVars.ts @@ -1,5 +1,5 @@ import { setCSSVar } from './setCSSVar.js'; -import type { ThemeParams } from '../theme-params/index.js'; +import type { ThemeParams } from '../components/theme-params/ThemeParams.js'; /** * Creates CSS variables connected with theme parameters. Created CSS variables names are diff --git a/packages/sdk/src/css/bindViewportCSSVars.ts b/packages/sdk/src/css/bindViewportCSSVars.ts index 9c008f87a..b465fae04 100644 --- a/packages/sdk/src/css/bindViewportCSSVars.ts +++ b/packages/sdk/src/css/bindViewportCSSVars.ts @@ -1,5 +1,5 @@ import { setCSSVar } from './setCSSVar.js'; -import type { Viewport } from '../viewport/index.js'; +import type { Viewport } from '../components/viewport/Viewport.js'; /** * Accepts Viewport instance and sets CSS variables connected with viewport diff --git a/packages/sdk/src/css/index.ts b/packages/sdk/src/css/index.ts deleted file mode 100644 index d24ca69c4..000000000 --- a/packages/sdk/src/css/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './bindMiniAppCSSVars.js'; -export * from './bindThemeCSSVars.js'; -export * from './bindViewportCSSVars.js'; -export * from './setCSSVar.js'; diff --git a/packages/sdk/src/event-emitter/index.ts b/packages/sdk/src/event-emitter/index.ts deleted file mode 100644 index ca79b1519..000000000 --- a/packages/sdk/src/event-emitter/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './EventEmitter.js'; -export * from './types.js'; diff --git a/packages/sdk/src/event-emitter/types.ts b/packages/sdk/src/event-emitter/types.ts index dfea34aa7..a50c87c50 100644 --- a/packages/sdk/src/event-emitter/types.ts +++ b/packages/sdk/src/event-emitter/types.ts @@ -1,4 +1,4 @@ -import type { IsNever } from '../types/index.js'; +import type { IsNever } from '../types/utils.js'; /** * Function accepting the list of passed arguments and returning nothing. diff --git a/packages/sdk/src/globals.ts b/packages/sdk/src/globals.ts index 2350020fb..a582cc3b2 100644 --- a/packages/sdk/src/globals.ts +++ b/packages/sdk/src/globals.ts @@ -1,4 +1,4 @@ -import { Logger } from './logger/index.js'; +import { Logger } from './logger/Logger.js'; let currentTargetOrigin = 'https://web.telegram.org'; diff --git a/packages/sdk/src/haptic-feedback/index.ts b/packages/sdk/src/haptic-feedback/index.ts deleted file mode 100644 index 31c17f6a6..000000000 --- a/packages/sdk/src/haptic-feedback/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './HapticFeedback.js'; diff --git a/packages/sdk/src/index.ts b/packages/sdk/src/index.ts index c11e6845b..35986fa04 100644 --- a/packages/sdk/src/index.ts +++ b/packages/sdk/src/index.ts @@ -1,190 +1,258 @@ +/** + * Bridge. + */ +export { createPostEvent } from './bridge/methods/createPostEvent.js'; +export { invokeCustomMethod } from './bridge/invokeCustomMethod.js'; +export { on } from './bridge/events/on.js'; +export { off } from './bridge/events/off.js'; +export { once } from './bridge/events/once.js'; +export { parseMessage } from './bridge/parseMessage.js'; +export { postEvent, type PostEvent } from './bridge/methods/postEvent.js'; +export { request, type RequestOptions, type RequestOptionsAdvanced } from './bridge/request.js'; +export { subscribe } from './bridge/events/subscribe.js'; +export { unsubscribe } from './bridge/events/unsubscribe.js'; +export { MethodUnsupportedError } from './bridge/errors/MethodUnsupportedError.js'; +export { ParameterUnsupportedError } from './bridge/errors/ParameterUnsupportedError.js'; +export type { + HeaderColorKey, + MiniAppsEmptyMethodName, + MiniAppsMethodAcceptParams, + MiniAppsMethodName, + MiniAppsMethodParams, + MiniAppsMethods, + MiniAppsNonEmptyMethodName, + SwitchInlineQueryChatType, +} from './bridge/methods/methods.js'; +export type { InvoiceStatus } from './bridge/events/parsers/invoiceClosed.js'; +export type { + ImpactHapticFeedbackStyle, + NotificationHapticFeedbackType, +} from './bridge/methods/haptic.js'; +export type { + MiniAppsEventEmitter, MiniAppsEventHasParams, + MiniAppsEventListener, + MiniAppsEventName, + MiniAppsEventParams, MiniAppsEvents, MiniAppsGlobalEventListener, +} from './bridge/events/events.js'; +export type { PhoneRequestedStatus } from './bridge/events/parsers/phoneRequested.js'; +export type { WriteAccessRequestedStatus } from './bridge/events/parsers/writeAccessRequested.js'; + +/** + * Classnames. + */ +export { classNames } from './classnames/classNames.js'; +export { mergeClassNames } from './classnames/mergeClassNames.js'; + +/** + * Colors. + */ +export { isRGB } from './colors/isRGB.js'; +export { isRGBShort } from './colors/isRGBShort.js'; +export { isColorDark } from './colors/isColorDark.js'; +export { toRGB } from './colors/toRGB.js'; +export type { RGB, RGBShort } from './colors/types.js'; + +/** + * Components. + */ + +// Closing behavior +export { ClosingBehavior } from './components/closing-behavior/ClosingBehavior.js'; +export type { + ClosingBehaviorEventListener, + ClosingBehaviorEventName, + ClosingBehaviorEvents, +} from './components/closing-behavior/types.js'; + +// Cloud storage. +export { CloudStorage } from './components/cloud-storage/CloudStorage.js'; + +// HapticFeedback. +export { HapticFeedback } from './components/haptic-feedback/HapticFeedback.js'; + +// Init data. +export { chatParser } from './components/init-data/chatParser.js'; +export { InitData } from './components/init-data/InitData.js'; +export { initDataParser } from './components/init-data/initDataParser.js'; +export { parseInitData } from './components/init-data/parseInitData.js'; +export { userParser } from './components/init-data/userParser.js'; +export type { Chat, User, ChatType, InitDataParsed } from './components/init-data/types.js'; + +// Invoice. +export { Invoice } from './components/invoice/Invoice.js'; +export type { + InvoiceState, + InvoiceEventListener, + InvoiceEventName, + InvoiceEvents, +} from './components/invoice/types.js'; + +// Main button. +export { MainButton } from './components/main-button/MainButton.js'; +export type { + MainButtonParams, + MainButtonEvents, + MainButtonEventListener, + MainButtonEventName, + MainButtonProps, +} from './components/main-button/types.js'; + +// Mini app. +export { MiniApp } from './components/mini-app/MiniApp.js'; +export type { + MiniAppHeaderColor, + MiniAppProps, + MiniAppEvents, + MiniAppEventListener, + MiniAppEventName, +} from './components/mini-app/types.js'; + +// Popup. +export { Popup } from './components/popup/Popup.js'; +export type { + PopupEventName, + PopupEventListener, + OpenPopupOptions, + OpenPopupOptionsButton, + PopupEvents, +} from './components/popup/types.js'; + +// QR scanner. +export { QRScanner } from './components/qr-scanner/QRScanner.js'; +export type { + QRScannerEvents, + QRScannerEventListener, + QRScannerEventName, +} from './components/qr-scanner/types.js'; + +// Settings button. +export { SettingsButton } from './components/settings-button/SettingsButton.js'; +export type { + SettingsButtonEventListener, + SettingsButtonEventName, + SettingsButtonEvents, +} from './components/settings-button/types.js'; + +// Theme params. +export { parseThemeParams } from './components/theme-params/parseThemeParams.js'; +export { requestThemeParams } from './components/theme-params/requestThemeParams.js'; +export { serializeThemeParams } from './components/theme-params/serializeThemeParams.js'; +export { themeParamsParser } from './components/theme-params/themeParamsParser.js'; +export { ThemeParams } from './components/theme-params/ThemeParams.js'; +export type { + ThemeParamsEventListener, + ThemeParamsEventName, + ThemeParamsKey, + ThemeParamsEvents, + ThemeParamsParsed, +} from './components/theme-params/types.js'; + +// Utils. +export { Utils } from './components/utils/Utils.js'; + +// Viewport. +export { isStableViewportPlatform } from './components/viewport/isStableViewportPlatform.js'; export { - BackButton, - type BackButtonEventName, - type BackButtonEventListener, -} from './back-button/index.js'; -export { - createPostEvent, - invokeCustomMethod, - on, - off, - once, - parseMessage, - postEvent, - request, - subscribe, - unsubscribe, - MethodUnsupportedError, - ParameterUnsupportedError, - type HeaderColorKey, - type InvoiceStatus, - type ImpactHapticFeedbackStyle, - type MiniAppsMethodName, - type MiniAppsEventName, - type MiniAppsEventParams, - type MiniAppsEventListener, - type MiniAppsGlobalEventListener, - type MiniAppsEmptyMethodName, - type MiniAppsMethodAcceptParams, - type MiniAppsMethodParams, - type MiniAppsNonEmptyMethodName, - type MiniAppsMethods, - type MiniAppsEventEmitter, - type MiniAppsEventHasParams, - type MiniAppsEvents, - type NotificationHapticFeedbackType, - type PhoneRequestedStatus, - type PostEvent, - type RequestOptions, - type RequestOptionsAdvanced, - type SwitchInlineQueryChatType, - type WriteAccessRequestedStatus, -} from './bridge/index.js'; -export { classNames, mergeClassNames } from './classnames/index.js'; -export { - ClosingBehavior, - type ClosingBehaviorEventListener, - type ClosingBehaviorEventName, - type ClosingBehaviorEvents, -} from './closing-behavior/index.js'; -export { CloudStorage } from './cloud-storage/index.js'; -export { - isRGB, - isRGBShort, - isColorDark, - toRGB, - type RGB, - type RGBShort, -} from './colors/index.js'; -export { - setCSSVar, - bindMiniAppCSSVars, - bindThemeCSSVars, - bindViewportCSSVars, -} from './css/index.js'; -export { HapticFeedback } from './haptic-feedback/index.js'; -export { - init, - type InitOptions, - type InitResult, -} from './init/index.js'; -export { - chatParser, - InitData, - initDataParser, - parseInitData, - userParser, - type Chat, - type ChatType, - type InitDataParsed, - type User, -} from './init-data/index.js'; -export { - Invoice, - type InvoiceEvents, - type InvoiceEventListener, - type InvoiceEventName, -} from './invoice/index.js'; -export { - launchParamsParser, - parseLaunchParams, - retrieveLaunchData, - retrieveLaunchParams, - serializeLaunchParams, - type LaunchParams, - type LaunchData, -} from './launch-params/index.js'; -export { - MainButton, - type MainButtonParams, - type MainButtonProps, - type MainButtonEvents, - type MainButtonEventName, - type MainButtonEventListener, -} from './main-button/index.js'; -export { - MiniApp, - type MiniAppHeaderColor, - type MiniAppEventName, - type MiniAppEventListener, - type MiniAppEvents, - type MiniAppProps, -} from './mini-app/index.js'; -export { - isTMA, - isRecord, - isIframe, - isPageReload, -} from './misc/index.js'; -export { - getHash, - HashNavigator, - Navigator, - type NavigationEntry, - type NavigatorConEntry, - type NavigatorOptions, - type HashNavigatorOptions, - type HashNavigatorEventsMap, - type HashNavigatorEventListener, - type HashNavigatorEventName, -} from './navigation/index.js'; -export { - boolean, - searchParams, - string, - rgb, - array, - date, - json, - number, - ParseError, - ParseSchemaFieldError, -} from './parsing/index.js'; -export { - Popup, - type PopupEventName, - type PopupEventListener, - type PopupEvents, - type OpenPopupOptions, - type OpenPopupOptionsButton, -} from './popup/index.js'; -export { - QRScanner, - type QRScannerEventListener, - type QRScannerEventName, - type QRScannerEvents, -} from './qr-scanner/index.js'; -export { - SettingsButton, - type SettingsButtonEventName, - type SettingsButtonEventListener, - type SettingsButtonEvents, -} from './settings-button/index.js'; -export { supports } from './supports/index.js'; -export { - parseThemeParams, - requestThemeParams, - serializeThemeParams, - themeParamsParser, - ThemeParams, - type ThemeParamsEventListener, - type ThemeParamsEventName, - type ThemeParamsEvents, - type ThemeParamsKey, - type ThemeParamsParsed, -} from './theme-params/index.js'; -export { withTimeout, TimeoutError, isTimeoutError } from './timeout/index.js'; -export type { RequestId, CreateRequestIdFunc } from './types/index.js'; -export { Utils } from './utils/index.js'; -export { compareVersions, type Version } from './version/index.js'; -export { - isStableViewportPlatform, requestViewport, - Viewport, type RequestViewportResult, - type ViewportProps, - type ViewportEventName, - type ViewportEventListener, - type ViewportEvents, -} from './viewport/index.js'; +} from './components/viewport/requestViewport.js'; +export { Viewport } from './components/viewport/Viewport.js'; +export type { + ViewportProps, + ViewportEventListener, + ViewportEventName, + ViewportEvents, +} from './components/viewport/types.js'; + +/** + * CSS. + */ +export { setCSSVar } from './css/setCSSVar.js'; +export { bindMiniAppCSSVars } from './css/bindMiniAppCSSVars.js'; +export { bindThemeCSSVars } from './css/bindThemeCSSVars.js'; +export { bindViewportCSSVars } from './css/bindViewportCSSVars.js'; + +/** + * Init. + */ +export { init } from './init/init.js'; +export type { InitOptions, InitResult } from './init/types.js'; + +/** + * Launch params. + */ +export { launchParamsParser } from './launch-params/launchParamsParser.js'; +export { parseLaunchParams } from './launch-params/parseLaunchParams.js'; +export { retrieveLaunchParams } from './launch-params/retrieveLaunchParams.js'; +export { retrieveLaunchData } from './launch-params/retrieveLaunchData.js'; +export { serializeLaunchParams } from './launch-params/serializeLaunchParams.js'; +export type { LaunchParams } from './launch-params/types.js'; +export type { LaunchData } from './launch-params/types.js'; + +/** + * Misc. + */ +export { isTMA } from './misc/isTMA.js'; +export { isRecord } from './misc/isRecord.js'; +export { isIframe } from './misc/isIframe.js'; +export { isPageReload } from './misc/isPageReload.js'; + +/** + * Navigation. + */ +export { getHash } from './navigation/getHash.js'; +export { HashNavigator } from './navigation/HashNavigator/HashNavigator.js'; +export { Navigator } from './navigation/Navigator/Navigator.js'; +export type { + NavigationEntry, + NavigatorConEntry, + NavigatorOptions, +} from './navigation/Navigator/types.js'; +export type { + HashNavigatorOptions, + HashNavigatorEventListener, + HashNavigatorEventsMap, + HashNavigatorEventName, +} from './navigation/HashNavigator/types.js'; + +/** + * Parsing. + */ +export { boolean } from './parsing/parsers/boolean.js'; +export { searchParams } from './parsing/parsers/searchParams.js'; +export { string } from './parsing/parsers/string.js'; +export { rgb } from './parsing/parsers/rgb.js'; +export { array } from './parsing/parsers/array.js'; +export { date } from './parsing/parsers/date.js'; +export { json } from './parsing/parsers/json.js'; +export { number } from './parsing/parsers/number.js'; +export { ParseError } from './parsing/ParseError.js'; +export { ParseSchemaFieldError } from './parsing/ParseSchemaFieldError.js'; + +/** + * Supports. + */ +export { supports } from './supports/supports.js'; + +/** + * Timeout. + */ +export { withTimeout } from './timeout/withTimeout.js'; +export { TimeoutError } from './timeout/TimeoutError.js'; +export { isTimeoutError } from './timeout/isTimeoutError.js'; + +/** + * Types. + */ +export type { RequestId, CreateRequestIdFunc } from './types/request-id.js'; + +/** + * Version. + */ +export { compareVersions } from './version/compareVersions.js'; +export type { Version } from './version/types.js'; + +/** + * Globals. + */ export { setTargetOrigin, setDebug } from './globals.js'; diff --git a/packages/sdk/src/init-data/index.ts b/packages/sdk/src/init-data/index.ts deleted file mode 100644 index 6327efbae..000000000 --- a/packages/sdk/src/init-data/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -export * from './chatParser.js'; -export * from './InitData.js'; -export * from './initDataParser.js'; -export * from './parseInitData.js'; -export * from './types.js'; -export * from './userParser.js'; diff --git a/packages/sdk/src/init/catchCustomStyles.ts b/packages/sdk/src/init/catchCustomStyles.ts index 08b1cba98..c0a340ddb 100644 --- a/packages/sdk/src/init/catchCustomStyles.ts +++ b/packages/sdk/src/init/catchCustomStyles.ts @@ -1,4 +1,4 @@ -import { on } from '../bridge/index.js'; +import { on } from '../bridge/events/on.js'; /** * Creates style html element which contains styles sent from the Telegram application. diff --git a/packages/sdk/src/init/creators/__tests__/createViewport.ts b/packages/sdk/src/init/creators/__tests__/createViewport.ts index d64e95365..cadc478c7 100644 --- a/packages/sdk/src/init/creators/__tests__/createViewport.ts +++ b/packages/sdk/src/init/creators/__tests__/createViewport.ts @@ -3,10 +3,10 @@ import type { SpyInstance } from 'vitest'; import { afterEach, expect, it, vi } from 'vitest'; import { createWindow } from '../../../../test-utils/createWindow'; -import { requestViewport } from '../../../viewport/requestViewport'; import { createViewport } from '../createViewport'; +import { requestViewport } from '../../../components/viewport/requestViewport'; -vi.mock('../../../viewport/requestViewport', () => { +vi.mock('../../../components/viewport/requestViewport', () => { return { requestViewport: vi.fn(), }; diff --git a/packages/sdk/src/init/creators/createBackButton.ts b/packages/sdk/src/init/creators/createBackButton.ts index 4e100ec3e..b0b504fea 100644 --- a/packages/sdk/src/init/creators/createBackButton.ts +++ b/packages/sdk/src/init/creators/createBackButton.ts @@ -1,5 +1,5 @@ -import { BackButton } from '../../back-button/index.js'; -import type { PostEvent } from '../../bridge/index.js'; +import type { PostEvent } from '../../bridge/methods/postEvent.js'; +import { BackButton } from '../../components/back-button/BackButton.js'; import { getStorageValue, saveStorageValue } from '../../storage.js'; /** diff --git a/packages/sdk/src/init/creators/createClosingBehavior.ts b/packages/sdk/src/init/creators/createClosingBehavior.ts index f6ffe2920..e3e2fb088 100644 --- a/packages/sdk/src/init/creators/createClosingBehavior.ts +++ b/packages/sdk/src/init/creators/createClosingBehavior.ts @@ -1,5 +1,5 @@ -import type { PostEvent } from '../../bridge/index.js'; -import { ClosingBehavior } from '../../closing-behavior/index.js'; +import type { PostEvent } from '../../bridge/methods/postEvent.js'; +import { ClosingBehavior } from '../../components/closing-behavior/ClosingBehavior.js'; import { getStorageValue, saveStorageValue } from '../../storage.js'; /** diff --git a/packages/sdk/src/init/creators/createMainButton.ts b/packages/sdk/src/init/creators/createMainButton.ts index b14a1f712..76c15f498 100644 --- a/packages/sdk/src/init/creators/createMainButton.ts +++ b/packages/sdk/src/init/creators/createMainButton.ts @@ -1,6 +1,6 @@ -import type { PostEvent } from '../../bridge/index.js'; -import type { RGB } from '../../colors/index.js'; -import { MainButton } from '../../main-button/index.js'; +import type { PostEvent } from '../../bridge/methods/postEvent.js'; +import type { RGB } from '../../colors/types.js'; +import { MainButton } from '../../components/main-button/MainButton.js'; import { getStorageValue, saveStorageValue } from '../../storage.js'; /** diff --git a/packages/sdk/src/init/creators/createMiniApp.ts b/packages/sdk/src/init/creators/createMiniApp.ts index 9103e2965..b32d94bee 100644 --- a/packages/sdk/src/init/creators/createMiniApp.ts +++ b/packages/sdk/src/init/creators/createMiniApp.ts @@ -1,9 +1,9 @@ -import type { PostEvent } from '../../bridge/index.js'; -import type { RGB } from '../../colors/index.js'; -import { MiniApp } from '../../mini-app/index.js'; +import type { PostEvent } from '../../bridge/methods/postEvent.js'; +import type { RGB } from '../../colors/types.js'; +import { MiniApp } from '../../components/mini-app/MiniApp.js'; import { getStorageValue, saveStorageValue } from '../../storage.js'; -import type { CreateRequestIdFunc } from '../../types/index.js'; -import type { Version } from '../../version/index.js'; +import type { CreateRequestIdFunc } from '../../types/request-id.js'; +import type { Version } from '../../version/types.js'; /** * Creates MiniApp instance using last locally saved data also saving each state in diff --git a/packages/sdk/src/init/creators/createRequestIdGenerator.ts b/packages/sdk/src/init/creators/createRequestIdGenerator.ts index 4f3217edf..aa4030da8 100644 --- a/packages/sdk/src/init/creators/createRequestIdGenerator.ts +++ b/packages/sdk/src/init/creators/createRequestIdGenerator.ts @@ -1,4 +1,4 @@ -import type { CreateRequestIdFunc } from '../../types/index.js'; +import type { CreateRequestIdFunc } from '../../types/request-id.js'; /** * Creates function which generated request identifiers. diff --git a/packages/sdk/src/init/creators/createSettingsButton.ts b/packages/sdk/src/init/creators/createSettingsButton.ts index e15b85757..9732ba40b 100644 --- a/packages/sdk/src/init/creators/createSettingsButton.ts +++ b/packages/sdk/src/init/creators/createSettingsButton.ts @@ -1,5 +1,5 @@ -import type { PostEvent } from '../../bridge/index.js'; -import { SettingsButton } from '../../settings-button/index.js'; +import type { PostEvent } from '../../bridge/methods/postEvent.js'; +import { SettingsButton } from '../../components/settings-button/SettingsButton.js'; import { getStorageValue, saveStorageValue } from '../../storage.js'; /** diff --git a/packages/sdk/src/init/creators/createThemeParams.ts b/packages/sdk/src/init/creators/createThemeParams.ts index f4ec009f6..daa8e5e63 100644 --- a/packages/sdk/src/init/creators/createThemeParams.ts +++ b/packages/sdk/src/init/creators/createThemeParams.ts @@ -1,4 +1,5 @@ -import { ThemeParams, type ThemeParamsParsed } from '../../theme-params/index.js'; +import { ThemeParams } from '../../components/theme-params/ThemeParams.js'; +import type { ThemeParamsParsed } from '../../components/theme-params/types.js'; /** * Creates synced instance of ThemeParams. diff --git a/packages/sdk/src/init/creators/createViewport.ts b/packages/sdk/src/init/creators/createViewport.ts index 6e566eeaf..78180bd88 100644 --- a/packages/sdk/src/init/creators/createViewport.ts +++ b/packages/sdk/src/init/creators/createViewport.ts @@ -1,12 +1,10 @@ -import type { PostEvent } from '../../bridge/index.js'; +import type { PostEvent } from '../../bridge/methods/postEvent.js'; +import { isStableViewportPlatform } from '../../components/viewport/isStableViewportPlatform.js'; +import { requestViewport } from '../../components/viewport/requestViewport.js'; +import type { ViewportProps } from '../../components/viewport/types.js'; +import { Viewport } from '../../components/viewport/Viewport.js'; import { getStorageValue, saveStorageValue } from '../../storage.js'; -import type { Platform } from '../../types/index.js'; -import { - isStableViewportPlatform, - requestViewport, - Viewport, - type ViewportProps, -} from '../../viewport/index.js'; +import type { Platform } from '../../types/platform.js'; /** * Creates new bound instance of the Viewport component. diff --git a/packages/sdk/src/init/creators/index.ts b/packages/sdk/src/init/creators/index.ts deleted file mode 100644 index b49383b23..000000000 --- a/packages/sdk/src/init/creators/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -export * from './createBackButton.js'; -export * from './createClosingBehavior.js'; -export * from './createMainButton.js'; -export * from './createMiniApp.js'; -export * from './createRequestIdGenerator.js'; -export * from './createSettingsButton.js'; -export * from './createThemeParams.js'; -export * from './createViewport.js'; diff --git a/packages/sdk/src/init/css/index.ts b/packages/sdk/src/init/css/index.ts deleted file mode 100644 index a41a875a8..000000000 --- a/packages/sdk/src/init/css/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './processCSSVarsOption.js'; diff --git a/packages/sdk/src/init/css/processCSSVarsOption.ts b/packages/sdk/src/init/css/processCSSVarsOption.ts index f36355992..f39d1c593 100644 --- a/packages/sdk/src/init/css/processCSSVarsOption.ts +++ b/packages/sdk/src/init/css/processCSSVarsOption.ts @@ -1,7 +1,9 @@ -import { bindMiniAppCSSVars, bindThemeCSSVars, bindViewportCSSVars } from '../../css/index.js'; -import type { MiniApp } from '../../mini-app/index.js'; -import type { ThemeParams } from '../../theme-params/index.js'; -import type { Viewport } from '../../viewport/index.js'; +import type { MiniApp } from '../../components/mini-app/MiniApp.js'; +import type { ThemeParams } from '../../components/theme-params/ThemeParams.js'; +import type { Viewport } from '../../components/viewport/Viewport.js'; +import { bindMiniAppCSSVars } from '../../css/bindMiniAppCSSVars.js'; +import { bindThemeCSSVars } from '../../css/bindThemeCSSVars.js'; +import { bindViewportCSSVars } from '../../css/bindViewportCSSVars.js'; import type { InitCSSVarsOption, InitCSSVarsSpecificOption } from '../types.js'; /** diff --git a/packages/sdk/src/init/index.ts b/packages/sdk/src/init/index.ts deleted file mode 100644 index 476f3cc72..000000000 --- a/packages/sdk/src/init/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './init.js'; -export * from './types.js'; diff --git a/packages/sdk/src/init/init.ts b/packages/sdk/src/init/init.ts index 76ebd8ae9..2de5911d7 100644 --- a/packages/sdk/src/init/init.ts +++ b/packages/sdk/src/init/init.ts @@ -1,26 +1,26 @@ +import { catchCustomStyles } from './catchCustomStyles.js'; +import { createBackButton } from './creators/createBackButton.js'; +import { createClosingBehavior } from './creators/createClosingBehavior.js'; +import { createMainButton } from './creators/createMainButton.js'; +import { createMiniApp } from './creators/createMiniApp.js'; +import { createRequestIdGenerator } from './creators/createRequestIdGenerator.js'; +import { createSettingsButton } from './creators/createSettingsButton.js'; +import { createThemeParams } from './creators/createThemeParams.js'; +import { createViewport } from './creators/createViewport.js'; +import { processCSSVars } from './css/processCSSVarsOption.js'; import type { InitOptions, InitResult } from './types.js'; -import { createPostEvent, on } from '../bridge/index.js'; -import { CloudStorage } from '../cloud-storage/index.js'; -import { HapticFeedback } from '../haptic-feedback/index.js'; -import { catchCustomStyles } from '../init/catchCustomStyles.js'; -import { - createBackButton, - createClosingBehavior, - createMainButton, - createMiniApp, - createRequestIdGenerator, - createSettingsButton, - createThemeParams, - createViewport, -} from '../init/creators/index.js'; -import { processCSSVars } from '../init/css/index.js'; -import { InitData } from '../init-data/index.js'; -import { Invoice } from '../invoice/index.js'; -import { retrieveLaunchParams } from '../launch-params/index.js'; -import { isIframe, isPageReload } from '../misc/index.js'; -import { Popup } from '../popup/index.js'; -import { QRScanner } from '../qr-scanner/index.js'; -import { Utils } from '../utils/index.js'; +import { on } from '../bridge/events/on.js'; +import { createPostEvent } from '../bridge/methods/createPostEvent.js'; +import { CloudStorage } from '../components/cloud-storage/CloudStorage.js'; +import { HapticFeedback } from '../components/haptic-feedback/HapticFeedback.js'; +import { InitData } from '../components/init-data/InitData.js'; +import { Invoice } from '../components/invoice/Invoice.js'; +import { Popup } from '../components/popup/Popup.js'; +import { QRScanner } from '../components/qr-scanner/QRScanner.js'; +import { Utils } from '../components/utils/Utils.js'; +import { retrieveLaunchParams } from '../launch-params/retrieveLaunchParams.js'; +import { isIframe } from '../misc/isIframe.js'; +import { isPageReload } from '../misc/isPageReload.js'; type ComputedInitResult = O extends { async: true } | { complete: true } ? Promise diff --git a/packages/sdk/src/init/types.ts b/packages/sdk/src/init/types.ts index 9704d0f0e..4b4830b34 100644 --- a/packages/sdk/src/init/types.ts +++ b/packages/sdk/src/init/types.ts @@ -1,19 +1,19 @@ -import type { BackButton } from '../back-button/index.js'; -import type { PostEvent } from '../bridge/index.js'; -import type { ClosingBehavior } from '../closing-behavior/index.js'; -import type { CloudStorage } from '../cloud-storage/index.js'; -import type { HapticFeedback } from '../haptic-feedback/index.js'; -import type { InitData } from '../init-data/index.js'; -import type { Invoice } from '../invoice/index.js'; -import type { MainButton } from '../main-button/index.js'; -import type { MiniApp } from '../mini-app/index.js'; -import type { Popup } from '../popup/index.js'; -import type { QRScanner } from '../qr-scanner/index.js'; -import type { SettingsButton } from '../settings-button/index.js'; -import type { ThemeParams } from '../theme-params/index.js'; -import type { CreateRequestIdFunc } from '../types/index.js'; -import type { Utils } from '../utils/index.js'; -import type { Viewport } from '../viewport/index.js'; +import type { PostEvent } from '../bridge/methods/postEvent.js'; +import type { BackButton } from '../components/back-button/BackButton.js'; +import type { ClosingBehavior } from '../components/closing-behavior/ClosingBehavior.js'; +import type { CloudStorage } from '../components/cloud-storage/CloudStorage.js'; +import type { HapticFeedback } from '../components/haptic-feedback/HapticFeedback.js'; +import type { InitData } from '../components/init-data/InitData.js'; +import type { Invoice } from '../components/invoice/Invoice.js'; +import type { MainButton } from '../components/main-button/MainButton.js'; +import type { MiniApp } from '../components/mini-app/MiniApp.js'; +import type { Popup } from '../components/popup/Popup.js'; +import type { QRScanner } from '../components/qr-scanner/QRScanner.js'; +import type { SettingsButton } from '../components/settings-button/SettingsButton.js'; +import type { ThemeParams } from '../components/theme-params/ThemeParams.js'; +import type { Utils } from '../components/utils/Utils.js'; +import type { Viewport } from '../components/viewport/Viewport.js'; +import type { CreateRequestIdFunc } from '../types/request-id.js'; export interface InitResult { backButton: BackButton; diff --git a/packages/sdk/src/invoice/index.ts b/packages/sdk/src/invoice/index.ts deleted file mode 100644 index f43be9cef..000000000 --- a/packages/sdk/src/invoice/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './Invoice.js'; -export * from './types.js'; diff --git a/packages/sdk/src/launch-params/index.ts b/packages/sdk/src/launch-params/index.ts deleted file mode 100644 index a5f1e6fda..000000000 --- a/packages/sdk/src/launch-params/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -export * from './launchParamsParser.js'; -export * from './parseLaunchParams.js'; -export * from './retrieveFromLocation.js'; -export * from './retrieveFromPerformance.js'; -export * from './retrieveFromUrl.js'; -export * from './retrieveLaunchData.js'; -export * from './retrieveLaunchParams.js'; -export * from './serializeLaunchParams.js'; -export * from './storage.js'; -export * from './types.js'; diff --git a/packages/sdk/src/launch-params/launchParamsParser.ts b/packages/sdk/src/launch-params/launchParamsParser.ts index 7f7ceee08..bfa2ebfce 100644 --- a/packages/sdk/src/launch-params/launchParamsParser.ts +++ b/packages/sdk/src/launch-params/launchParamsParser.ts @@ -1,7 +1,10 @@ import type { LaunchParams } from './types.js'; -import { initDataParser } from '../init-data/index.js'; -import { boolean, searchParams, string, type ValueParser } from '../parsing/index.js'; -import { themeParamsParser } from '../theme-params/index.js'; +import { initDataParser } from '../components/init-data/initDataParser.js'; +import { themeParamsParser } from '../components/theme-params/themeParamsParser.js'; +import { boolean } from '../parsing/parsers/boolean.js'; +import { searchParams } from '../parsing/parsers/searchParams.js'; +import { string } from '../parsing/parsers/string.js'; +import type { ValueParser } from '../parsing/ValueParser.js'; /** * Returns parser used to parse launch params. diff --git a/packages/sdk/src/launch-params/retrieveLaunchData.ts b/packages/sdk/src/launch-params/retrieveLaunchData.ts index 9fc94e543..79bd5469f 100644 --- a/packages/sdk/src/launch-params/retrieveLaunchData.ts +++ b/packages/sdk/src/launch-params/retrieveLaunchData.ts @@ -1,6 +1,6 @@ import { retrieveLaunchParams } from './retrieveLaunchParams.js'; import type { LaunchData } from './types.js'; -import { isPageReload } from '../misc/index.js'; +import { isPageReload } from '../misc/isPageReload.js'; /** * Returns launch data information. Function ignores passed options in case, it was already diff --git a/packages/sdk/src/launch-params/serializeLaunchParams.ts b/packages/sdk/src/launch-params/serializeLaunchParams.ts index d459ce773..431fe3af4 100644 --- a/packages/sdk/src/launch-params/serializeLaunchParams.ts +++ b/packages/sdk/src/launch-params/serializeLaunchParams.ts @@ -1,5 +1,5 @@ import type { LaunchParams } from './types.js'; -import { serializeThemeParams } from '../theme-params/index.js'; +import { serializeThemeParams } from '../components/theme-params/serializeThemeParams.js'; /** * Converts launch parameters to its initial representation. diff --git a/packages/sdk/src/launch-params/types.ts b/packages/sdk/src/launch-params/types.ts index 8d8086a88..bc9558c01 100644 --- a/packages/sdk/src/launch-params/types.ts +++ b/packages/sdk/src/launch-params/types.ts @@ -1,6 +1,6 @@ -import type { InitDataParsed } from '../init-data/index.js'; -import type { ThemeParamsParsed } from '../theme-params/index.js'; -import type { Platform } from '../types/index.js'; +import type { InitDataParsed } from '../components/init-data/types.js'; +import type { ThemeParamsParsed } from '../components/theme-params/types.js'; +import type { Platform } from '../types/platform.js'; /** * Telegram Mini Apps launch parameters. diff --git a/packages/sdk/src/logger/index.ts b/packages/sdk/src/logger/index.ts deleted file mode 100644 index c2e6ca6eb..000000000 --- a/packages/sdk/src/logger/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './Logger.js'; diff --git a/packages/sdk/src/main-button/index.ts b/packages/sdk/src/main-button/index.ts deleted file mode 100644 index b0c342ffd..000000000 --- a/packages/sdk/src/main-button/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './MainButton.js'; -export * from './types.js'; diff --git a/packages/sdk/src/mini-app/index.ts b/packages/sdk/src/mini-app/index.ts deleted file mode 100644 index 1a5734711..000000000 --- a/packages/sdk/src/mini-app/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './MiniApp.js'; -export * from './types.js'; diff --git a/packages/sdk/src/misc/index.ts b/packages/sdk/src/misc/index.ts deleted file mode 100644 index 2d06b8aa1..000000000 --- a/packages/sdk/src/misc/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export * from './getFirstNavigationEntry.js'; -export * from './isIframe.js'; -export * from './isPageReload.js'; -export * from './isRecord.js'; -export * from './isTMA.js'; diff --git a/packages/sdk/src/misc/isTMA.ts b/packages/sdk/src/misc/isTMA.ts index 9fc6d8c3c..800e562ba 100644 --- a/packages/sdk/src/misc/isTMA.ts +++ b/packages/sdk/src/misc/isTMA.ts @@ -1,4 +1,4 @@ -import { retrieveLaunchParams } from '../launch-params/index.js'; +import { retrieveLaunchParams } from '../launch-params/retrieveLaunchParams.js'; /** * Returns true in case, current environment is Telegram Mini Apps. diff --git a/packages/sdk/src/navigation/HashNavigator/HashNavigator.ts b/packages/sdk/src/navigation/HashNavigator/HashNavigator.ts index f1772edba..880236872 100644 --- a/packages/sdk/src/navigation/HashNavigator/HashNavigator.ts +++ b/packages/sdk/src/navigation/HashNavigator/HashNavigator.ts @@ -4,9 +4,11 @@ import type { HashNavigatorEventsMap, HashNavigatorOptions, } from './types.js'; -import { off, on, postEvent } from '../../bridge/index.js'; -import { EventEmitter } from '../../event-emitter/index.js'; -import { Navigator } from '../Navigator/index.js'; +import { off } from '../../bridge/events/off.js'; +import { on } from '../../bridge/events/on.js'; +import { postEvent } from '../../bridge/methods/postEvent.js'; +import { EventEmitter } from '../../event-emitter/EventEmitter.js'; +import { Navigator } from '../Navigator/Navigator.js'; import type { NavigationEntry, NavigatorConEntry, diff --git a/packages/sdk/src/navigation/HashNavigator/index.ts b/packages/sdk/src/navigation/HashNavigator/index.ts deleted file mode 100644 index 3b9c16bbe..000000000 --- a/packages/sdk/src/navigation/HashNavigator/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './HashNavigator.js'; -export * from './types.js'; diff --git a/packages/sdk/src/navigation/HashNavigator/types.ts b/packages/sdk/src/navigation/HashNavigator/types.ts index 5b2ba34d0..f3c8d2dd5 100644 --- a/packages/sdk/src/navigation/HashNavigator/types.ts +++ b/packages/sdk/src/navigation/HashNavigator/types.ts @@ -1,6 +1,5 @@ import type { HashNavigator } from './HashNavigator.js'; -import type { NavigatorOptions } from '../Navigator/index.js'; -import type { NavigationEntry } from '../Navigator/types.js'; +import type { NavigationEntry, NavigatorOptions } from '../Navigator/types.js'; export type HashNavigatorOptions = Omit; diff --git a/packages/sdk/src/navigation/Navigator/Navigator.ts b/packages/sdk/src/navigation/Navigator/Navigator.ts index 6ad36aa88..cad6a6651 100644 --- a/packages/sdk/src/navigation/Navigator/Navigator.ts +++ b/packages/sdk/src/navigation/Navigator/Navigator.ts @@ -7,7 +7,7 @@ import type { PerformPushOptions, PerformReplaceOptions, } from './types.js'; -import { Logger } from '../../logger/index.js'; +import { Logger } from '../../logger/Logger.js'; import { ensurePrefix } from '../ensurePrefix.js'; /** diff --git a/packages/sdk/src/navigation/Navigator/index.ts b/packages/sdk/src/navigation/Navigator/index.ts deleted file mode 100644 index f9db41882..000000000 --- a/packages/sdk/src/navigation/Navigator/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './Navigator.js'; -export * from './types.js'; diff --git a/packages/sdk/src/navigation/index.ts b/packages/sdk/src/navigation/index.ts deleted file mode 100644 index cf485b071..000000000 --- a/packages/sdk/src/navigation/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './ensurePrefix.js'; -export * from './getHash.js'; -export * from './HashNavigator/index.js'; -export * from './Navigator/index.js'; diff --git a/packages/sdk/src/parsing/ValueParser.ts b/packages/sdk/src/parsing/ValueParser.ts index 61a3b4fce..e2ddd548b 100644 --- a/packages/sdk/src/parsing/ValueParser.ts +++ b/packages/sdk/src/parsing/ValueParser.ts @@ -1,6 +1,6 @@ import { ParseError } from './ParseError.js'; import type { Parser } from './types.js'; -import type { If } from '../types/index.js'; +import type { If } from '../types/logical.js'; /** * Result of "parse" function. diff --git a/packages/sdk/src/parsing/__tests__/ArrayValueParser.ts b/packages/sdk/src/parsing/__tests__/ArrayValueParser.ts index 22ccb1046..b3352a010 100644 --- a/packages/sdk/src/parsing/__tests__/ArrayValueParser.ts +++ b/packages/sdk/src/parsing/__tests__/ArrayValueParser.ts @@ -1,7 +1,7 @@ import { describe, expect, it } from 'vitest'; import { ArrayValueParser } from '../ArrayValueParser'; -import { string } from '../parsers'; +import { string } from '../parsers/string'; describe('constructor', () => { it('should apply parser value directly if it is function', () => { diff --git a/packages/sdk/src/parsing/__tests__/toRecord.ts b/packages/sdk/src/parsing/__tests__/toRecord.ts index ca4c2a525..658b00fc7 100644 --- a/packages/sdk/src/parsing/__tests__/toRecord.ts +++ b/packages/sdk/src/parsing/__tests__/toRecord.ts @@ -1,6 +1,6 @@ import { expect, it } from 'vitest'; -import { toRecord } from '../index'; +import { toRecord } from '../toRecord'; it('should throw an error in case, passed value is not JSON object or not JSON object converted to string', () => { expect(() => toRecord('')).toThrow(); diff --git a/packages/sdk/src/parsing/index.ts b/packages/sdk/src/parsing/index.ts deleted file mode 100644 index 6b4a224b9..000000000 --- a/packages/sdk/src/parsing/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -export * from './ArrayValueParser.js'; -export * from './createValueParserGenerator.js'; -export * from './parseBySchema.js'; -export * from './ParseError.js'; -export * from './parsers/index.js'; -export * from './ParseSchemaFieldError.js'; -export * from './toRecord.js'; -export * from './types.js'; -export * from './unexpectedTypeError.js'; -export * from './ValueParser.js'; diff --git a/packages/sdk/src/parsing/parsers/index.ts b/packages/sdk/src/parsing/parsers/index.ts deleted file mode 100644 index 917522377..000000000 --- a/packages/sdk/src/parsing/parsers/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -export * from './array.js'; -export * from './boolean.js'; -export * from './date.js'; -export * from './json.js'; -export * from './number.js'; -export * from './rgb.js'; -export * from './searchParams.js'; -export * from './string.js'; diff --git a/packages/sdk/src/parsing/parsers/rgb.ts b/packages/sdk/src/parsing/parsers/rgb.ts index 99d5cce13..b082ae6a5 100644 --- a/packages/sdk/src/parsing/parsers/rgb.ts +++ b/packages/sdk/src/parsing/parsers/rgb.ts @@ -1,6 +1,6 @@ import { string } from './string.js'; -import type { RGB } from '../../colors/index.js'; -import { toRGB } from '../../colors/index.js'; +import { toRGB } from '../../colors/toRGB.js'; +import type { RGB } from '../../colors/types.js'; import type { ValueParserGenerator } from '../createValueParserGenerator.js'; import { createValueParserGenerator } from '../createValueParserGenerator.js'; diff --git a/packages/sdk/src/popup/index.ts b/packages/sdk/src/popup/index.ts deleted file mode 100644 index 19b86b864..000000000 --- a/packages/sdk/src/popup/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './Popup.js'; -export * from './types.js'; diff --git a/packages/sdk/src/qr-scanner/index.ts b/packages/sdk/src/qr-scanner/index.ts deleted file mode 100644 index a82fbd8ad..000000000 --- a/packages/sdk/src/qr-scanner/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './QRScanner.js'; -export * from './types.js'; diff --git a/packages/sdk/src/settings-button/index.ts b/packages/sdk/src/settings-button/index.ts deleted file mode 100644 index 1ce6ecfde..000000000 --- a/packages/sdk/src/settings-button/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './SettingsButton.js'; -export * from './types.js'; diff --git a/packages/sdk/src/state/State.ts b/packages/sdk/src/state/State.ts index d373e9fad..81ee58da2 100644 --- a/packages/sdk/src/state/State.ts +++ b/packages/sdk/src/state/State.ts @@ -1,6 +1,6 @@ import type { StateEvents } from './types.js'; -import type { EventEmitter } from '../event-emitter/index.js'; -import type { StringKeys } from '../types/index.js'; +import type { EventEmitter } from '../event-emitter/EventEmitter.js'; +import type { StringKeys } from '../types/utils.js'; /** * Represents state which is observable via passed EventEmitter. diff --git a/packages/sdk/src/state/index.ts b/packages/sdk/src/state/index.ts deleted file mode 100644 index 06d5b3162..000000000 --- a/packages/sdk/src/state/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './State.js'; -export * from './types.js'; diff --git a/packages/sdk/src/state/types.ts b/packages/sdk/src/state/types.ts index 60990f3d2..501bc146a 100644 --- a/packages/sdk/src/state/types.ts +++ b/packages/sdk/src/state/types.ts @@ -1,4 +1,4 @@ -import type { StringKeys } from '../types/index.js'; +import type { StringKeys } from '../types/utils.js'; /** * Computes state property changed event. diff --git a/packages/sdk/src/storage.ts b/packages/sdk/src/storage.ts index 7a3830bc0..77b5ce4d8 100644 --- a/packages/sdk/src/storage.ts +++ b/packages/sdk/src/storage.ts @@ -1,5 +1,5 @@ -import type { HeaderColorKey } from './bridge/index.js'; -import type { RGB } from './colors/index.js'; +import type { HeaderColorKey } from './bridge/methods/methods.js'; +import type { RGB } from './colors/types.js'; // fixme: components-related. Should probably rename diff --git a/packages/sdk/src/supports/__tests__/supports.ts b/packages/sdk/src/supports/__tests__/supports.ts index 1ac0b75d4..897113459 100644 --- a/packages/sdk/src/supports/__tests__/supports.ts +++ b/packages/sdk/src/supports/__tests__/supports.ts @@ -1,12 +1,12 @@ import { expect, it } from 'vitest'; -import type { +import { supports } from '../supports'; +import { MiniAppsMethodName, MiniAppsMethodVersionedParams, MiniAppsMethodWithVersionedParams, -} from '../../bridge'; -import type { Version } from '../../version'; -import { supports } from '../supports'; +} from '../../bridge/methods/methods'; +import { Version } from '../../version/types'; type HaveCheckSupportMethodTuple = { [M in MiniAppsMethodWithVersionedParams]: [M, MiniAppsMethodVersionedParams] diff --git a/packages/sdk/src/supports/createSupportsFunc.ts b/packages/sdk/src/supports/createSupportsFunc.ts index 6c3bb5931..ca61e852b 100644 --- a/packages/sdk/src/supports/createSupportsFunc.ts +++ b/packages/sdk/src/supports/createSupportsFunc.ts @@ -1,7 +1,7 @@ import { supports } from './supports.js'; import type { SupportsFunc } from './types.js'; -import type { MiniAppsMethodName } from '../bridge/index.js'; -import type { Version } from '../version/index.js'; +import type { MiniAppsMethodName } from '../bridge/methods/methods.js'; +import type { Version } from '../version/types.js'; /** * Returns function, which accepts predefined method name and checks if it is supported diff --git a/packages/sdk/src/supports/createSupportsParamFunc.ts b/packages/sdk/src/supports/createSupportsParamFunc.ts index 04774baa3..952d1586d 100644 --- a/packages/sdk/src/supports/createSupportsParamFunc.ts +++ b/packages/sdk/src/supports/createSupportsParamFunc.ts @@ -3,8 +3,8 @@ import type { SupportsFunc } from './types.js'; import type { MiniAppsMethodVersionedParams, MiniAppsMethodWithVersionedParams, -} from '../bridge/index.js'; -import type { Version } from '../version/index.js'; +} from '../bridge/methods/methods.js'; +import type { Version } from '../version/types.js'; type HasCheckSupportMethodTuple = { [M in MiniAppsMethodWithVersionedParams]: [M, MiniAppsMethodVersionedParams] diff --git a/packages/sdk/src/supports/index.ts b/packages/sdk/src/supports/index.ts deleted file mode 100644 index e5ee784c4..000000000 --- a/packages/sdk/src/supports/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './createSupportsFunc.js'; -export * from './createSupportsParamFunc.js'; -export * from './supports.js'; -export * from './types.js'; diff --git a/packages/sdk/src/supports/supports.ts b/packages/sdk/src/supports/supports.ts index 69667be2d..a749adc59 100644 --- a/packages/sdk/src/supports/supports.ts +++ b/packages/sdk/src/supports/supports.ts @@ -2,11 +2,9 @@ import type { MiniAppsMethodName, MiniAppsMethodVersionedParams, MiniAppsMethodWithVersionedParams, -} from '../bridge/methods/index.js'; -import { - compareVersions, - type Version, -} from '../version/index.js'; +} from '../bridge/methods/methods.js'; +import { compareVersions } from '../version/compareVersions.js'; +import type { Version } from '../version/types.js'; /** * Returns true if "a" version is less than or equal to "b" version. diff --git a/packages/sdk/src/supports/types.ts b/packages/sdk/src/supports/types.ts index 1785cdc64..fa691839c 100644 --- a/packages/sdk/src/supports/types.ts +++ b/packages/sdk/src/supports/types.ts @@ -1 +1,4 @@ +/** + * Function which returns true in case, specified method is supported. + */ export type SupportsFunc = (method: M) => boolean; diff --git a/packages/sdk/src/theme-params/index.ts b/packages/sdk/src/theme-params/index.ts deleted file mode 100644 index 966d45879..000000000 --- a/packages/sdk/src/theme-params/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -export * from './parseThemeParams.js'; -export * from './requestThemeParams.js'; -export * from './serializeThemeParams.js'; -export * from './ThemeParams.js'; -export * from './themeParamsParser.js'; -export * from './types.js'; diff --git a/packages/sdk/src/timeout/__tests__/withTimeout.ts b/packages/sdk/src/timeout/__tests__/withTimeout.ts index f3d423d56..aab855231 100644 --- a/packages/sdk/src/timeout/__tests__/withTimeout.ts +++ b/packages/sdk/src/timeout/__tests__/withTimeout.ts @@ -1,6 +1,6 @@ import { afterAll, beforeAll, expect, it, vi } from 'vitest'; - -import { TimeoutError, withTimeout } from '../index'; +import { withTimeout } from '../withTimeout'; +import { TimeoutError } from '../TimeoutError'; beforeAll(() => { vi.useFakeTimers(); diff --git a/packages/sdk/src/timeout/index.ts b/packages/sdk/src/timeout/index.ts deleted file mode 100644 index 217eb372f..000000000 --- a/packages/sdk/src/timeout/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './isTimeoutError.js'; -export * from './sleep.js'; -export * from './TimeoutError.js'; -export * from './withTimeout.js'; diff --git a/packages/sdk/src/types/index.ts b/packages/sdk/src/types/index.ts deleted file mode 100644 index 5da31c5ae..000000000 --- a/packages/sdk/src/types/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -export type * from './logical.js'; -export type * from './methods.js'; -export type * from './platform.js'; -export type * from './request-id.js'; -export type * from './unions.js'; -export type * from './utils.js'; diff --git a/packages/sdk/src/types/methods.ts b/packages/sdk/src/types/methods.ts index 0a216d130..ec6032dd9 100644 --- a/packages/sdk/src/types/methods.ts +++ b/packages/sdk/src/types/methods.ts @@ -1,4 +1,4 @@ -import type { PostEvent } from '../bridge/index.js'; +import type { PostEvent } from '../bridge/methods/postEvent.js'; export interface ExecuteWithTimeout { /** diff --git a/packages/sdk/src/utils/index.ts b/packages/sdk/src/utils/index.ts deleted file mode 100644 index 95341f7a7..000000000 --- a/packages/sdk/src/utils/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './Utils.js'; diff --git a/packages/sdk/src/version/compareVersions.ts b/packages/sdk/src/version/compareVersions.ts index 7aeb2ccb7..82cf7adf5 100644 --- a/packages/sdk/src/version/compareVersions.ts +++ b/packages/sdk/src/version/compareVersions.ts @@ -1,3 +1,5 @@ +import type { Version } from './types.js'; + /** * Returns 1 in case, version "a" is greater than "b". * Returns 0 in case, version "a" equal to "b". @@ -5,7 +7,7 @@ * @param a - first version. * @param b - second version. */ -export function compareVersions(a: string, b: string): number { +export function compareVersions(a: Version, b: Version): number { // Split both of the version by dot. const aParts = a.split('.'); const bParts = b.split('.'); diff --git a/packages/sdk/src/version/index.ts b/packages/sdk/src/version/index.ts deleted file mode 100644 index 5cb43eceb..000000000 --- a/packages/sdk/src/version/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './compareVersions.js'; -export * from './types.js'; diff --git a/packages/sdk/src/version/types.ts b/packages/sdk/src/version/types.ts index bc48920a8..68102d8b1 100644 --- a/packages/sdk/src/version/types.ts +++ b/packages/sdk/src/version/types.ts @@ -1,4 +1,5 @@ /** * Telegram Mini Apps version in format like "\d+.\d+". + * @example "7.0" */ export type Version = string; diff --git a/packages/sdk/src/viewport/index.ts b/packages/sdk/src/viewport/index.ts deleted file mode 100644 index 64057c9d0..000000000 --- a/packages/sdk/src/viewport/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './isStableViewportPlatform.js'; -export * from './requestViewport.js'; -export * from './types.js'; -export * from './Viewport.js'; diff --git a/packages/sdk/vite.config.ts b/packages/sdk/vite.config.ts index 166bfd407..116ea8399 100644 --- a/packages/sdk/vite.config.ts +++ b/packages/sdk/vite.config.ts @@ -17,10 +17,19 @@ export default createViteConfig({ exclude: [ prefix('**/index.ts'), prefix('**/__tests__'), - prefix('back-button/BackButton.ts'), - prefix('bridge/invoke-custom-method.ts'), - prefix('closing-behavior/ClosingBehavior.ts'), - prefix('init-data/InitData.ts'), + prefix('bridge/invokeCustomMethod.ts'), + prefix('bridge/events/onTelegramEvent.ts'), + prefix('components/back-button/BackButton.ts'), + prefix('components/closing-behavior/ClosingBehavior.ts'), + prefix('components/init-data/InitData.ts'), + prefix('components/popup/preparePopupParams.ts'), + prefix('components/main-button/MainButton.ts'), + prefix('components/mini-app/MiniApp.ts'), + prefix('components/theme-params/ThemeParams.ts'), + prefix('components/theme-params/requestThemeParams.ts'), + prefix('components/viewport/Viewport.ts'), + prefix('components/viewport/requestViewport.ts'), + prefix('init/creators/createRequestIdGenerator.ts'), prefix('launch-params/launchParamsParser.ts'), prefix('launch-params/parseLaunchParams.ts'), prefix('launch-params/retrieveFromLocation.ts'), @@ -29,18 +38,11 @@ export default createViteConfig({ prefix('launch-params/retrieveLaunchParams.ts'), prefix('launch-params/serializeLaunchParams.ts'), prefix('launch-params/storage.ts'), - prefix('popup/preparePopupParams.ts'), prefix('state'), prefix('supports/createSupportsParamFunc.ts'), - prefix('main-button/MainButton.ts'), - prefix('mini-app/MiniApp.ts'), prefix('misc/isTMA.ts'), prefix('navigation/**'), - prefix('theme-params/ThemeParams.ts'), - prefix('theme-params/requestThemeParams.ts'), prefix('timeout/sleep.ts'), - prefix('viewport/Viewport.ts'), - prefix('viewport/requestViewport.ts'), ], branches: 100, functions: 100, From 26a1c84e2359bd0eaf5d89dc0e2ebcfde63c2d5b Mon Sep 17 00:00:00 2001 From: Vladislav Kibenko Date: Wed, 13 Mar 2024 15:06:47 +0300 Subject: [PATCH 2/3] docs(changeset): Get rid of barrel files --- .changeset/thin-wolves-sneeze.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/thin-wolves-sneeze.md diff --git a/.changeset/thin-wolves-sneeze.md b/.changeset/thin-wolves-sneeze.md new file mode 100644 index 000000000..526d53c53 --- /dev/null +++ b/.changeset/thin-wolves-sneeze.md @@ -0,0 +1,5 @@ +--- +"@tma.js/sdk": patch +--- + +Get rid of barrel files From c4c3b4543948692a2011a1ff5511a6a7bab3fc4b Mon Sep 17 00:00:00 2001 From: Vladislav Kibenko Date: Wed, 13 Mar 2024 15:10:22 +0300 Subject: [PATCH 3/3] fix(settings-button): fix incorrect imports --- packages/sdk/src/components/settings-button/types.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/sdk/src/components/settings-button/types.ts b/packages/sdk/src/components/settings-button/types.ts index 437d32551..587b3ac0d 100644 --- a/packages/sdk/src/components/settings-button/types.ts +++ b/packages/sdk/src/components/settings-button/types.ts @@ -1,5 +1,5 @@ -import type { MiniAppsEventListener } from '../bridge/index.js'; -import type { StateEvents } from '../state/index.js'; +import type { MiniAppsEventListener } from '../../bridge/events/events.js'; +import type { StateEvents } from '../../state/types.js'; export interface SettingsButtonState { isVisible: boolean;