Files
bedolaga-cabinet/src/vite-env.d.ts
2026-01-28 21:01:12 +03:00

97 lines
2.5 KiB
TypeScript

/// <reference types="vite/client" />
interface ImportMetaEnv {
readonly VITE_API_URL: string;
readonly VITE_TELEGRAM_BOT_USERNAME?: string;
readonly VITE_APP_NAME?: string;
readonly VITE_APP_LOGO?: string;
}
interface ImportMeta {
readonly env: ImportMetaEnv;
}
// Telegram WebApp types
interface TelegramWebApp {
initData: string;
initDataUnsafe: {
user?: {
id: number;
first_name: string;
last_name?: string;
username?: string;
language_code?: string;
};
auth_date: number;
hash: string;
};
version: string;
platform: string;
isExpanded: boolean;
isClosingConfirmationEnabled: boolean;
isVerticalSwipesEnabled: boolean;
isFullscreen: boolean;
isOrientationLocked: boolean;
safeAreaInset: { top: number; bottom: number; left: number; right: number };
contentSafeAreaInset: { top: number; bottom: number; left: number; right: number };
ready: () => void;
expand: () => void;
close: () => void;
openLink: (url: string, options?: { try_instant_view?: boolean; try_browser?: boolean }) => void;
openTelegramLink: (url: string) => void;
openInvoice: (
url: string,
callback?: (status: 'paid' | 'cancelled' | 'failed' | 'pending') => void,
) => void;
// Fullscreen API (Bot API 8.0+)
requestFullscreen: () => void;
exitFullscreen: () => void;
lockOrientation: () => void;
unlockOrientation: () => void;
// Vertical swipes control
disableVerticalSwipes: () => void;
enableVerticalSwipes: () => void;
// Closing confirmation
enableClosingConfirmation: () => void;
disableClosingConfirmation: () => void;
// Event handlers
onEvent: (eventType: string, callback: () => void) => void;
offEvent: (eventType: string, callback: () => void) => void;
MainButton: {
text: string;
color: string;
textColor: string;
isVisible: boolean;
isActive: boolean;
show: () => void;
hide: () => void;
enable: () => void;
disable: () => void;
onClick: (callback: () => void) => void;
offClick: (callback: () => void) => void;
};
BackButton: {
isVisible: boolean;
show: () => void;
hide: () => void;
onClick: (callback: () => void) => void;
offClick: (callback: () => void) => void;
};
themeParams: {
bg_color?: string;
text_color?: string;
hint_color?: string;
link_color?: string;
button_color?: string;
button_text_color?: string;
};
// Version check helper
isVersionAtLeast: (version: string) => boolean;
}
interface Window {
Telegram?: {
WebApp: TelegramWebApp;
};
}