@teactjs/telegram 0.1.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/README.md +111 -0
  2. package/dist/index.js +8263 -0
  3. package/dist/react/src/callback-registry.d.ts +11 -0
  4. package/dist/react/src/callback-registry.d.ts.map +1 -0
  5. package/dist/react/src/components.d.ts +396 -0
  6. package/dist/react/src/components.d.ts.map +1 -0
  7. package/dist/react/src/error-boundary.d.ts +19 -0
  8. package/dist/react/src/error-boundary.d.ts.map +1 -0
  9. package/dist/react/src/hooks.d.ts +37 -0
  10. package/dist/react/src/hooks.d.ts.map +1 -0
  11. package/dist/react/src/index.d.ts +11 -0
  12. package/dist/react/src/index.d.ts.map +1 -0
  13. package/dist/renderer/src/index.d.ts +5 -0
  14. package/dist/renderer/src/index.d.ts.map +1 -0
  15. package/dist/renderer/src/nodes.d.ts +23 -0
  16. package/dist/renderer/src/nodes.d.ts.map +1 -0
  17. package/dist/renderer/src/renderer.d.ts +9 -0
  18. package/dist/renderer/src/renderer.d.ts.map +1 -0
  19. package/dist/renderer/src/types.d.ts +36 -0
  20. package/dist/renderer/src/types.d.ts.map +1 -0
  21. package/dist/runtime/src/auth-session.d.ts +51 -0
  22. package/dist/runtime/src/auth-session.d.ts.map +1 -0
  23. package/dist/runtime/src/auth.d.ts +37 -0
  24. package/dist/runtime/src/auth.d.ts.map +1 -0
  25. package/dist/runtime/src/bot.d.ts +143 -0
  26. package/dist/runtime/src/bot.d.ts.map +1 -0
  27. package/dist/runtime/src/config.d.ts +38 -0
  28. package/dist/runtime/src/config.d.ts.map +1 -0
  29. package/dist/runtime/src/context.d.ts +74 -0
  30. package/dist/runtime/src/context.d.ts.map +1 -0
  31. package/dist/runtime/src/conversation.d.ts +310 -0
  32. package/dist/runtime/src/conversation.d.ts.map +1 -0
  33. package/dist/runtime/src/event-hooks.d.ts +49 -0
  34. package/dist/runtime/src/event-hooks.d.ts.map +1 -0
  35. package/dist/runtime/src/i18n.d.ts +55 -0
  36. package/dist/runtime/src/i18n.d.ts.map +1 -0
  37. package/dist/runtime/src/index.d.ts +28 -0
  38. package/dist/runtime/src/index.d.ts.map +1 -0
  39. package/dist/runtime/src/invoice.d.ts +120 -0
  40. package/dist/runtime/src/invoice.d.ts.map +1 -0
  41. package/dist/runtime/src/media-hooks.d.ts +178 -0
  42. package/dist/runtime/src/media-hooks.d.ts.map +1 -0
  43. package/dist/runtime/src/middleware.d.ts +26 -0
  44. package/dist/runtime/src/middleware.d.ts.map +1 -0
  45. package/dist/runtime/src/plugin.d.ts +32 -0
  46. package/dist/runtime/src/plugin.d.ts.map +1 -0
  47. package/dist/runtime/src/router.d.ts +168 -0
  48. package/dist/runtime/src/router.d.ts.map +1 -0
  49. package/dist/runtime/src/session.d.ts +20 -0
  50. package/dist/runtime/src/session.d.ts.map +1 -0
  51. package/dist/runtime/src/stream.d.ts +34 -0
  52. package/dist/runtime/src/stream.d.ts.map +1 -0
  53. package/dist/telegram/src/adapter.d.ts +83 -0
  54. package/dist/telegram/src/adapter.d.ts.map +1 -0
  55. package/dist/telegram/src/conversations.d.ts +175 -0
  56. package/dist/telegram/src/conversations.d.ts.map +1 -0
  57. package/dist/telegram/src/index.d.ts +8 -0
  58. package/dist/telegram/src/index.d.ts.map +1 -0
  59. package/dist/telegram/src/serialize.d.ts +80 -0
  60. package/dist/telegram/src/serialize.d.ts.map +1 -0
  61. package/dist/telegram/src/stream.d.ts +12 -0
  62. package/dist/telegram/src/stream.d.ts.map +1 -0
  63. package/package.json +38 -0
  64. package/src/index.ts +7 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../../runtime/src/conversation.ts"],"names":[],"mappings":"AAAA,OAAO,KAA4D,MAAM,OAAO,CAAC;AAMjF;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,GAAG,MAAM,CAAC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,EAAE,UAAU,CAAC;CACpB,GAAG,KAAK,CAAC,YAAY,CAiCrB;AAED,eAAO,MAAM,IAAI;;;CAGf,CAAC"}
@@ -0,0 +1,49 @@
1
+ import { type NavigateOptions } from './router';
2
+ /**
3
+ * Telegram update event types supported by `useOn` and `useEventData`.
4
+ * Use `'*'` to match all events.
5
+ */
6
+ export type TelegramEvent = '*' | 'message' | 'text' | 'photo' | 'video' | 'audio' | 'voice' | 'document' | 'sticker' | 'contact' | 'location' | 'venue' | 'animation' | 'video_note' | 'poll' | 'poll_answer' | 'callback_query' | 'inline_query' | 'new_chat_members' | 'left_chat_member' | 'dice' | 'game' | 'web_app_data' | 'successful_payment' | 'pre_checkout_query';
7
+ /** Context object passed to `useOn` handlers with navigation and reply helpers. */
8
+ export interface EventContext {
9
+ navigate: (path: string, opts?: NavigateOptions) => void;
10
+ chatId: string;
11
+ userId: string;
12
+ user: {
13
+ id: string;
14
+ username?: string;
15
+ firstName?: string;
16
+ };
17
+ reply: (text: string) => Promise<void>;
18
+ raw: any;
19
+ }
20
+ type EventHandler = (data: any, ctx: EventContext) => void;
21
+ /**
22
+ * Listen for a specific Telegram event type within a React component.
23
+ * The handler fires once per matching update and receives an `EventContext`
24
+ * with `navigate`, `reply`, and user info.
25
+ *
26
+ * @example
27
+ * useOn('callback_query', (data, ctx) => {
28
+ * console.log('Callback from', ctx.user.firstName);
29
+ * ctx.navigate('/details');
30
+ * });
31
+ *
32
+ * useOn('contact', (contact, ctx) => {
33
+ * ctx.reply(`Got your number: ${contact.phone_number}`);
34
+ * });
35
+ */
36
+ export declare function useOn(event: TelegramEvent, handler: EventHandler): void;
37
+ /**
38
+ * Returns data from the current update if it matches the event, otherwise null.
39
+ * A declarative alternative to `useOn` — read the value instead of registering a callback.
40
+ *
41
+ * @example
42
+ * const contact = useEventData('contact');
43
+ * if (contact) {
44
+ * return <Message text={`Got your number: ${contact.phone_number}`} />;
45
+ * }
46
+ */
47
+ export declare function useEventData<T = any>(event: TelegramEvent): T | null;
48
+ export {};
49
+ //# sourceMappingURL=event-hooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-hooks.d.ts","sourceRoot":"","sources":["../../../../runtime/src/event-hooks.ts"],"names":[],"mappings":"AAEA,OAAO,EAAa,KAAK,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3D;;;GAGG;AACH,MAAM,MAAM,aAAa,GACrB,GAAG,GACH,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAC1D,UAAU,GAAG,SAAS,GAAG,SAAS,GAAG,UAAU,GAAG,OAAO,GACzD,WAAW,GAAG,YAAY,GAAG,MAAM,GAAG,aAAa,GACnD,gBAAgB,GAAG,cAAc,GACjC,kBAAkB,GAAG,kBAAkB,GACvC,MAAM,GAAG,MAAM,GAAG,cAAc,GAChC,oBAAoB,GAAG,oBAAoB,CAAC;AAEhD,mFAAmF;AACnF,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,eAAe,KAAK,IAAI,CAAC;IACzD,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5D,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,GAAG,EAAE,GAAG,CAAC;CACV;AAED,KAAK,YAAY,GAAG,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,YAAY,KAAK,IAAI,CAAC;AAiC3D;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,YAAY,GAAG,IAAI,CAsCvE;AAED;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,aAAa,GAAG,CAAC,GAAG,IAAI,CAKpE"}
@@ -0,0 +1,55 @@
1
+ import React from 'react';
2
+ /** Configuration for {@link createI18n}. */
3
+ export interface I18nConfig {
4
+ /** Language code used on first load (e.g. `'en'`). */
5
+ defaultLocale: string;
6
+ /** i18next-style resources keyed by locale, each containing a `translation` object. */
7
+ resources: Record<string, {
8
+ translation: Record<string, any>;
9
+ }>;
10
+ /** Locale to fall back to when a key is missing. Defaults to `defaultLocale`. */
11
+ fallbackLocale?: string;
12
+ }
13
+ /**
14
+ * Create an i18n instance powered by i18next + react-i18next.
15
+ *
16
+ * Each locale must have a `translation` key following the i18next convention.
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * import en from './locales/en.json';
21
+ * import am from './locales/am.json';
22
+ *
23
+ * const i18n = createI18n({
24
+ * defaultLocale: 'en',
25
+ * resources: {
26
+ * en: { translation: en },
27
+ * am: { translation: am },
28
+ * },
29
+ * });
30
+ * ```
31
+ */
32
+ export declare function createI18n(config: I18nConfig): {
33
+ Provider: ({ children }: {
34
+ children: React.ReactNode;
35
+ }) => React.ReactElement;
36
+ instance: import("node_modules/i18next").i18n;
37
+ };
38
+ /**
39
+ * Access translations from any component.
40
+ *
41
+ * Returns `t` (bound to the current locale), `locale`, `setLocale`, and `availableLocales`.
42
+ *
43
+ * @example
44
+ * ```tsx
45
+ * const { t, locale, setLocale } = useLocale();
46
+ * return <Message text={t('home.title')} />;
47
+ * ```
48
+ */
49
+ export declare function useLocale(): {
50
+ t: import("i18next").TFunction<"translation", undefined>;
51
+ locale: string;
52
+ setLocale: (lng: string) => void;
53
+ availableLocales: string[];
54
+ };
55
+ //# sourceMappingURL=i18n.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../../../runtime/src/i18n.ts"],"names":[],"mappings":"AAAA,OAAO,KAAoE,MAAM,OAAO,CAAC;AAIzF,4CAA4C;AAC5C,MAAM,WAAW,UAAU;IACzB,sDAAsD;IACtD,aAAa,EAAE,MAAM,CAAC;IACtB,uFAAuF;IACvF,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;KAAE,CAAC,CAAC;IAChE,iFAAiF;IACjF,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AASD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,UAAU;6BASX;QAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;KAAE,KAAG,KAAK,CAAC,YAAY;;EAoBnF;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,SAAS;;;qBAlEN,MAAM,KAAK,IAAI;;EA8EjC"}
@@ -0,0 +1,28 @@
1
+ export { createBot } from './bot';
2
+ export type { CreateBotOptions, CommandContext, CommandDef, ReplyOptions, ReplyButton, ReplyKeyboardButton, WebhookConfig } from './bot';
3
+ export { MemorySessionStore } from './session';
4
+ export { compose, commandMiddleware } from './middleware';
5
+ export { createRouter, useNavigate, useParams, useRoute, redirect } from './router';
6
+ export type { RouterConfig, NavigateOptions, NavigateMode, BeforeLoadContext, RouteGuard, GuardRedirect, GuardComponent, GuardReply, GuardReplyOptions, GuardButton, RouteValue, CreateRouterOptions } from './router';
7
+ export { useConversation, useForm, useConversationContext, useFormContext, Conversation, Form } from './conversation';
8
+ export type { ConversationState, FormFieldDef, FormResult, Validator, ValidateFn, SchemaLike, StepDef, StepsConfig, StepActions, ConversationActions, FormActions } from './conversation';
9
+ export type { TeactPlugin } from './plugin';
10
+ export { useStream } from './stream';
11
+ export type { UseStreamResult } from './stream';
12
+ export { authPlugin, useAuth } from './auth';
13
+ export type { AuthConfig, AuthState } from './auth';
14
+ export { useAuthSession } from './auth-session';
15
+ export type { AuthTokens, AuthSessionState } from './auth-session';
16
+ export { defineConfig } from './config';
17
+ export type { TeactConfig } from './config';
18
+ export { RuntimeContext, useBot, useSession, usePlatform, useChatId, useText, useCallbackData, useCommand, } from './context';
19
+ export type { RuntimeContextValue } from './context';
20
+ export { useChat, useTelegram, usePhoto, useVideo, useAnimation, useAudio, useVoice, useDocument, useSticker, useLocation, useContact, useVenue, usePoll, } from './media-hooks';
21
+ export type { ChatInfo, TelegramAccess } from './media-hooks';
22
+ export { useOn, useEventData } from './event-hooks';
23
+ export type { TelegramEvent, EventContext } from './event-hooks';
24
+ export { createI18n, useLocale } from './i18n';
25
+ export type { I18nConfig } from './i18n';
26
+ export { useInvoice } from './invoice';
27
+ export type { InvoiceConfig, InvoiceResult, LabeledPrice, SuccessfulPayment } from './invoice';
28
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../runtime/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,YAAY,EAAE,gBAAgB,EAAE,cAAc,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEzI,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAE/C,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAE1D,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpF,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,YAAY,EAAE,iBAAiB,EAAE,UAAU,EAAE,aAAa,EAAE,cAAc,EAAE,UAAU,EAAE,iBAAiB,EAAE,WAAW,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAEvN,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,sBAAsB,EAAE,cAAc,EAAE,YAAY,EAAE,IAAI,EAAE,MAA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AAE,UAAU,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAC/C,YAAY,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEzC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC"}
@@ -0,0 +1,120 @@
1
+ /** A price entry for a Telegram payment invoice. */
2
+ export interface LabeledPrice {
3
+ label: string;
4
+ /** Price in the smallest currency unit (e.g. cents for USD: 499 = $4.99). */
5
+ amount: number;
6
+ }
7
+ /**
8
+ * Configuration for {@link useInvoice}.
9
+ *
10
+ * Maps 1-to-1 with Telegram's `sendInvoice` parameters.
11
+ * The `providerToken` is the secret token you get from BotFather
12
+ * after linking a payment provider.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * useInvoice({
17
+ * title: 'Premium Plan',
18
+ * description: 'Monthly subscription',
19
+ * payload: 'premium-v1',
20
+ * providerToken: process.env.CHAPA_PROVIDER_TOKEN!,
21
+ * currency: 'ETB',
22
+ * prices: [{ label: 'Premium', amount: 10000 }],
23
+ * photoUrl: 'https://example.com/product.png',
24
+ * photoWidth: 512,
25
+ * photoHeight: 512,
26
+ * needName: true,
27
+ * needEmail: true,
28
+ * });
29
+ * ```
30
+ */
31
+ export interface InvoiceConfig {
32
+ title: string;
33
+ description: string;
34
+ /** Bot-defined payload for tracking (1-128 bytes, not shown to users). */
35
+ payload: string;
36
+ /** Payment provider token from BotFather. */
37
+ providerToken: string;
38
+ /** Three-letter ISO 4217 currency code (e.g. "USD", "ETB"). */
39
+ currency: string;
40
+ prices: LabeledPrice[];
41
+ /** URL of the product photo for the invoice. */
42
+ photoUrl?: string;
43
+ /** Photo width in pixels. */
44
+ photoWidth?: number;
45
+ /** Photo height in pixels. */
46
+ photoHeight?: number;
47
+ /** Photo size in bytes. */
48
+ photoSize?: number;
49
+ /** Request the user's full name. */
50
+ needName?: boolean;
51
+ /** Request the user's phone number. */
52
+ needPhoneNumber?: boolean;
53
+ /** Request the user's email address. */
54
+ needEmail?: boolean;
55
+ /** Request the user's shipping address. */
56
+ needShippingAddress?: boolean;
57
+ /** Pass the user's phone number to the payment provider. */
58
+ sendPhoneNumberToProvider?: boolean;
59
+ /** Pass the user's email to the payment provider. */
60
+ sendEmailToProvider?: boolean;
61
+ /** True if the final price depends on the shipping method. */
62
+ isFlexible?: boolean;
63
+ /** Maximum accepted tip amount in the smallest currency unit. */
64
+ maxTipAmount?: number;
65
+ /** Suggested tip amounts (max 4 values). */
66
+ suggestedTipAmounts?: number[];
67
+ /** Deep-linking parameter for the invoice link. */
68
+ startParameter?: string;
69
+ /** JSON-serialized data about the invoice for the payment provider. */
70
+ providerData?: string;
71
+ /** Protect the content of the invoice message from forwarding/saving. */
72
+ protectContent?: boolean;
73
+ }
74
+ /** Data received after a successful Telegram payment. */
75
+ export interface SuccessfulPayment {
76
+ currency: string;
77
+ totalAmount: number;
78
+ invoicePayload: string;
79
+ telegramPaymentChargeId: string;
80
+ providerPaymentChargeId: string;
81
+ orderInfo?: any;
82
+ }
83
+ /** Return value of {@link useInvoice} with send action and payment state. */
84
+ export interface InvoiceResult {
85
+ /** Send the invoice to the current chat. */
86
+ send: () => Promise<void>;
87
+ /** Current payment status. */
88
+ status: 'idle' | 'pending' | 'success' | 'failed';
89
+ /** Populated after successful payment. */
90
+ receipt: SuccessfulPayment | null;
91
+ /** Error message when status is 'failed'. */
92
+ error: string | null;
93
+ }
94
+ /**
95
+ * Hook for sending Telegram payment invoices.
96
+ *
97
+ * @example
98
+ * ```tsx
99
+ * const invoice = useInvoice({
100
+ * title: 'Premium',
101
+ * description: 'Unlock all features',
102
+ * payload: 'premium-v1',
103
+ * providerToken: process.env.PAYMENT_PROVIDER_TOKEN!,
104
+ * currency: 'USD',
105
+ * prices: [{ label: 'Premium', amount: 499 }],
106
+ * });
107
+ *
108
+ * return (
109
+ * <Message text={invoice.status === 'success' ? '✅ Paid!' : '💎 Buy Premium'}>
110
+ * <InlineKeyboard>
111
+ * <ButtonRow>
112
+ * <Button text="💳 Pay $4.99" onClick={invoice.send} />
113
+ * </ButtonRow>
114
+ * </InlineKeyboard>
115
+ * </Message>
116
+ * );
117
+ * ```
118
+ */
119
+ export declare function useInvoice(config: InvoiceConfig): InvoiceResult;
120
+ //# sourceMappingURL=invoice.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invoice.d.ts","sourceRoot":"","sources":["../../../../runtime/src/invoice.ts"],"names":[],"mappings":"AAIA,oDAAoD;AACpD,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,6EAA6E;IAC7E,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,0EAA0E;IAC1E,OAAO,EAAE,MAAM,CAAC;IAChB,6CAA6C;IAC7C,aAAa,EAAE,MAAM,CAAC;IACtB,+DAA+D;IAC/D,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,gDAAgD;IAChD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,6BAA6B;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,8BAA8B;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,2BAA2B;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oCAAoC;IACpC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,uCAAuC;IACvC,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,wCAAwC;IACxC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,2CAA2C;IAC3C,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,4DAA4D;IAC5D,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,qDAAqD;IACrD,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,8DAA8D;IAC9D,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,iEAAiE;IACjE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,4CAA4C;IAC5C,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC/B,mDAAmD;IACnD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,uEAAuE;IACvE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,yEAAyE;IACzE,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,yDAAyD;AACzD,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,uBAAuB,EAAE,MAAM,CAAC;IAChC,uBAAuB,EAAE,MAAM,CAAC;IAChC,SAAS,CAAC,EAAE,GAAG,CAAC;CACjB;AAED,6EAA6E;AAC7E,MAAM,WAAW,aAAa;IAC5B,4CAA4C;IAC5C,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,8BAA8B;IAC9B,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;IAClD,0CAA0C;IAC1C,OAAO,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAClC,6CAA6C;IAC7C,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,aAAa,GAAG,aAAa,CAkE/D"}
@@ -0,0 +1,178 @@
1
+ /** Aggregated chat information for the current update. */
2
+ export interface ChatInfo {
3
+ chatId: string;
4
+ userId: string;
5
+ user: {
6
+ id: string;
7
+ username?: string;
8
+ firstName?: string;
9
+ lastName?: string;
10
+ isBot?: boolean;
11
+ };
12
+ messageId?: string;
13
+ text?: string;
14
+ callbackData?: string;
15
+ platform: string;
16
+ }
17
+ /**
18
+ * Returns aggregated chat info (user, chatId, text, callbackData, etc.) for the current update.
19
+ *
20
+ * @example
21
+ * const { chatId, user, text } = useChat();
22
+ */
23
+ export declare function useChat(): ChatInfo;
24
+ /** Low-level access to the grammY API, context, chat, and sender objects. */
25
+ export interface TelegramAccess {
26
+ api: any;
27
+ ctx: any;
28
+ chat: any;
29
+ from: any;
30
+ chatId: number;
31
+ }
32
+ /**
33
+ * Returns low-level Telegram API access for advanced use cases.
34
+ *
35
+ * @example
36
+ * const { api, chatId } = useTelegram();
37
+ * await api.sendMessage(chatId, 'Hello from raw API!');
38
+ */
39
+ export declare function useTelegram(): TelegramAccess;
40
+ /**
41
+ * Returns a callback to send a photo to the current chat.
42
+ *
43
+ * @example
44
+ * const sendPhoto = usePhoto();
45
+ * await sendPhoto('https://example.com/cat.jpg', { caption: 'A cute cat' });
46
+ */
47
+ export declare function usePhoto(): (src: string, opts?: {
48
+ caption?: string;
49
+ parse_mode?: string;
50
+ has_spoiler?: boolean;
51
+ }) => Promise<any>;
52
+ /**
53
+ * Returns a callback to send a video to the current chat.
54
+ *
55
+ * @example
56
+ * const sendVideo = useVideo();
57
+ * await sendVideo('https://example.com/clip.mp4', { caption: 'Watch this' });
58
+ */
59
+ export declare function useVideo(): (src: string, opts?: {
60
+ caption?: string;
61
+ parse_mode?: string;
62
+ duration?: number;
63
+ width?: number;
64
+ height?: number;
65
+ supports_streaming?: boolean;
66
+ }) => Promise<any>;
67
+ /**
68
+ * Returns a callback to send a GIF/animation to the current chat.
69
+ *
70
+ * @example
71
+ * const sendGif = useAnimation();
72
+ * await sendGif('https://example.com/funny.gif');
73
+ */
74
+ export declare function useAnimation(): (src: string, opts?: {
75
+ caption?: string;
76
+ parse_mode?: string;
77
+ duration?: number;
78
+ width?: number;
79
+ height?: number;
80
+ }) => Promise<any>;
81
+ /**
82
+ * Returns a callback to send an audio file to the current chat.
83
+ *
84
+ * @example
85
+ * const sendAudio = useAudio();
86
+ * await sendAudio('https://example.com/song.mp3', { title: 'My Song' });
87
+ */
88
+ export declare function useAudio(): (src: string, opts?: {
89
+ caption?: string;
90
+ parse_mode?: string;
91
+ performer?: string;
92
+ title?: string;
93
+ duration?: number;
94
+ }) => Promise<any>;
95
+ /**
96
+ * Returns a callback to send a voice message to the current chat.
97
+ *
98
+ * @example
99
+ * const sendVoice = useVoice();
100
+ * await sendVoice('https://example.com/voice.ogg');
101
+ */
102
+ export declare function useVoice(): (src: string, opts?: {
103
+ caption?: string;
104
+ parse_mode?: string;
105
+ duration?: number;
106
+ }) => Promise<any>;
107
+ /**
108
+ * Returns a callback to send a document/file to the current chat.
109
+ *
110
+ * @example
111
+ * const sendDoc = useDocument();
112
+ * await sendDoc('https://example.com/report.pdf', { filename: 'report.pdf' });
113
+ */
114
+ export declare function useDocument(): (src: string, opts?: {
115
+ caption?: string;
116
+ filename?: string;
117
+ }) => Promise<any>;
118
+ /**
119
+ * Returns a callback to send a sticker to the current chat.
120
+ *
121
+ * @example
122
+ * const sendSticker = useSticker();
123
+ * await sendSticker('CAACAgIAAxkB...');
124
+ */
125
+ export declare function useSticker(): (src: string, opts?: {
126
+ emoji?: string;
127
+ }) => Promise<any>;
128
+ /**
129
+ * Returns a callback to send a location to the current chat.
130
+ *
131
+ * @example
132
+ * const sendLocation = useLocation();
133
+ * await sendLocation(9.0192, 38.7525);
134
+ */
135
+ export declare function useLocation(): (latitude: number, longitude: number, opts?: {
136
+ live_period?: number;
137
+ horizontal_accuracy?: number;
138
+ heading?: number;
139
+ proximity_alert_radius?: number;
140
+ }) => Promise<any>;
141
+ /**
142
+ * Returns a callback to send a contact card to the current chat.
143
+ *
144
+ * @example
145
+ * const sendContact = useContact();
146
+ * await sendContact('+1234567890', 'Jane');
147
+ */
148
+ export declare function useContact(): (phoneNumber: string, firstName: string, opts?: {
149
+ last_name?: string;
150
+ vcard?: string;
151
+ }) => Promise<any>;
152
+ /**
153
+ * Returns a callback to send a venue to the current chat.
154
+ *
155
+ * @example
156
+ * const sendVenue = useVenue();
157
+ * await sendVenue(9.0192, 38.7525, 'Meskel Square', 'Addis Ababa');
158
+ */
159
+ export declare function useVenue(): (latitude: number, longitude: number, title: string, address: string, opts?: {
160
+ foursquare_id?: string;
161
+ google_place_id?: string;
162
+ }) => Promise<any>;
163
+ /**
164
+ * Returns a callback to send a poll to the current chat.
165
+ *
166
+ * @example
167
+ * const sendPoll = usePoll();
168
+ * await sendPoll('Favorite color?', ['Red', 'Blue', 'Green']);
169
+ */
170
+ export declare function usePoll(): (question: string, options: string[], opts?: {
171
+ is_anonymous?: boolean;
172
+ type?: "regular" | "quiz";
173
+ allows_multiple_answers?: boolean;
174
+ correct_option_id?: number;
175
+ explanation?: string;
176
+ open_period?: number;
177
+ }) => Promise<any>;
178
+ //# sourceMappingURL=media-hooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"media-hooks.d.ts","sourceRoot":"","sources":["../../../../runtime/src/media-hooks.ts"],"names":[],"mappings":"AAKA,0DAA0D;AAC1D,MAAM,WAAW,QAAQ;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;IAChG,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,IAAI,QAAQ,CAWlC;AAID,6EAA6E;AAC7E,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,GAAG,CAAC;IACT,GAAG,EAAE,GAAG,C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MAAM,EAAE,SAAS;IAAE,YAAY,CAAC,EAAE,OAAO,CAAC;IAAC,IAAI,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IAAC,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,KAE9I,OAAO,CAAC,GAAG,CAAC,CAI9E"}
@@ -0,0 +1,26 @@
1
+ import type { BotContext, Middleware } from '@teactjs/renderer';
2
+ /**
3
+ * Compose an array of middleware functions into a single middleware.
4
+ *
5
+ * Unlike Koa-style middleware, `next()` is called automatically if
6
+ * the middleware function completes without calling it. This means
7
+ * simple middleware (loggers, analytics) don't need to remember to
8
+ * call `next()` — the framework handles it.
9
+ *
10
+ * @param middlewares - Ordered list of middleware to chain.
11
+ * @returns A single middleware that runs the chain in order.
12
+ *
13
+ * @example
14
+ * const logger: Middleware = async (ctx) => {
15
+ * console.log(ctx.text); // no need to call next() — it's automatic
16
+ * };
17
+ */
18
+ export declare function compose(middlewares: Middleware[]): Middleware;
19
+ /**
20
+ * Middleware that intercepts `/command` messages and dispatches them to registered handlers.
21
+ *
22
+ * @param commands - Map of command names (without `/`) to their handler functions.
23
+ * @returns Middleware that calls the matching handler or passes through via `next()`.
24
+ */
25
+ export declare function commandMiddleware(commands: Map<string, (ctx: BotContext, args: string[]) => Promise<void> | void>): Middleware;
26
+ //# sourceMappingURL=middleware.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../../../runtime/src/middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEhE;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,OAAO,CAAC,WAAW,EAAE,UAAU,EAAE,GAAG,UAAU,CAiB7D;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,GAC/E,UAAU,CAUZ"}
@@ -0,0 +1,32 @@
1
+ import type { FunctionComponent, ReactNode } from 'react';
2
+ import type { Middleware } from '@teactjs/renderer';
3
+ import type { TelegramAdapter } from '@teactjs/telegram';
4
+ /**
5
+ * Teact plugin interface.
6
+ * Plugins can hook into the bot lifecycle, provide middleware,
7
+ * and wrap the component tree with React providers.
8
+ *
9
+ * @example
10
+ * export function myPlugin(opts: MyOpts): TeactPlugin {
11
+ * return {
12
+ * name: 'my-plugin',
13
+ * Provider: ({ children }) => <MyContext.Provider value={...}>{children}</MyContext.Provider>,
14
+ * middleware: async (ctx, next) => { ... ; await next(); },
15
+ * onStart: (adapter) => console.log('bot started!'),
16
+ * };
17
+ * }
18
+ */
19
+ export interface TeactPlugin {
20
+ name: string;
21
+ /** Called when the bot starts. Receives the adapter for advanced setup. */
22
+ onStart?: (adapter: TelegramAdapter) => Promise<void> | void;
23
+ /** Middleware that runs on every update before the component renders. */
24
+ middleware?: Middleware;
25
+ /** React provider component that wraps the app tree. Receives children. */
26
+ Provider?: FunctionComponent<{
27
+ children: ReactNode;
28
+ }>;
29
+ /** Cleanup when the bot stops. */
30
+ onStop?: () => Promise<void> | void;
31
+ }
32
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../runtime/src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC1D,OAAO,KAAK,EAAc,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,2EAA2E;IAC3E,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAC7D,yEAAyE;IACzE,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,2EAA2E;IAC3E,QAAQ,CAAC,EAAE,iBAAiB,CAAC;QAAE,QAAQ,EAAE,SAAS,CAAA;KAAE,CAAC,CAAC;IACtD,kCAAkC;IAClC,MAAM,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CACrC"}