@core-ease/telegram-kit 3.0.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 (86) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +299 -0
  3. package/dist/animation/index.d.mts +4 -0
  4. package/dist/animation/index.d.ts +4 -0
  5. package/dist/animation/index.js +2413 -0
  6. package/dist/animation/index.mjs +5 -0
  7. package/dist/animation/lottie/index.d.mts +10 -0
  8. package/dist/animation/lottie/index.d.ts +10 -0
  9. package/dist/animation/lottie/index.js +2313 -0
  10. package/dist/animation/lottie/index.mjs +4 -0
  11. package/dist/animation/tgs/index.d.mts +18 -0
  12. package/dist/animation/tgs/index.d.ts +18 -0
  13. package/dist/animation/tgs/index.js +2402 -0
  14. package/dist/animation/tgs/index.mjs +4 -0
  15. package/dist/bot/index.d.mts +477 -0
  16. package/dist/bot/index.d.ts +477 -0
  17. package/dist/bot/index.js +870 -0
  18. package/dist/bot/index.mjs +847 -0
  19. package/dist/bot-D8BnLWIi.d.mts +2041 -0
  20. package/dist/bot-D8BnLWIi.d.ts +2041 -0
  21. package/dist/browser.global.js +23 -0
  22. package/dist/chunk-7AARTHNW.mjs +40 -0
  23. package/dist/chunk-7CVYPKAL.mjs +15 -0
  24. package/dist/chunk-B3PWALX5.mjs +4418 -0
  25. package/dist/chunk-BQEUEAVK.mjs +2262 -0
  26. package/dist/chunk-FPWYSKK2.mjs +3089 -0
  27. package/dist/chunk-JXK5HCDV.mjs +254 -0
  28. package/dist/chunk-OMH2JGOH.mjs +88 -0
  29. package/dist/chunk-PXO36YTU.mjs +38 -0
  30. package/dist/core/index.d.mts +151 -0
  31. package/dist/core/index.d.ts +151 -0
  32. package/dist/core/index.js +3837 -0
  33. package/dist/core/index.mjs +495 -0
  34. package/dist/dev/index.d.mts +77 -0
  35. package/dist/dev/index.d.ts +77 -0
  36. package/dist/dev/index.js +3214 -0
  37. package/dist/dev/index.mjs +151 -0
  38. package/dist/engine-BDm1_hzn.d.mts +382 -0
  39. package/dist/engine-BDm1_hzn.d.ts +382 -0
  40. package/dist/format/index.d.mts +61 -0
  41. package/dist/format/index.d.ts +61 -0
  42. package/dist/format/index.js +121 -0
  43. package/dist/format/index.mjs +112 -0
  44. package/dist/hooks/index.d.mts +1 -0
  45. package/dist/hooks/index.d.ts +1 -0
  46. package/dist/hooks/index.js +4234 -0
  47. package/dist/hooks/index.mjs +3 -0
  48. package/dist/hooks-C5Per70R.d.mts +1066 -0
  49. package/dist/hooks-C5Per70R.d.ts +1066 -0
  50. package/dist/index.d.mts +849 -0
  51. package/dist/index.d.ts +849 -0
  52. package/dist/index.js +5026 -0
  53. package/dist/index.mjs +478 -0
  54. package/dist/keyboards/index.d.mts +50 -0
  55. package/dist/keyboards/index.d.ts +50 -0
  56. package/dist/keyboards/index.js +127 -0
  57. package/dist/keyboards/index.mjs +124 -0
  58. package/dist/links/index.d.mts +53 -0
  59. package/dist/links/index.d.ts +53 -0
  60. package/dist/links/index.js +139 -0
  61. package/dist/links/index.mjs +133 -0
  62. package/dist/lottie/index.d.mts +3 -0
  63. package/dist/lottie/index.d.ts +3 -0
  64. package/dist/lottie/index.js +2313 -0
  65. package/dist/lottie/index.mjs +4 -0
  66. package/dist/qr/index.d.mts +75 -0
  67. package/dist/qr/index.d.ts +75 -0
  68. package/dist/qr/index.js +983 -0
  69. package/dist/qr/index.mjs +946 -0
  70. package/dist/sdk/index.d.mts +322 -0
  71. package/dist/sdk/index.d.ts +322 -0
  72. package/dist/sdk/index.js +3138 -0
  73. package/dist/sdk/index.mjs +2 -0
  74. package/dist/server/index.d.mts +28 -0
  75. package/dist/server/index.d.ts +28 -0
  76. package/dist/server/index.js +254 -0
  77. package/dist/server/index.mjs +246 -0
  78. package/dist/tgs/index.d.mts +3 -0
  79. package/dist/tgs/index.d.ts +3 -0
  80. package/dist/tgs/index.js +2402 -0
  81. package/dist/tgs/index.mjs +4 -0
  82. package/dist/webapp-B-3_74nK.d.mts +842 -0
  83. package/dist/webapp-B-3_74nK.d.ts +842 -0
  84. package/dist/webapp-BDi9q3-a.d.mts +42 -0
  85. package/dist/webapp-YvmwFYUQ.d.ts +42 -0
  86. package/package.json +165 -0
@@ -0,0 +1,112 @@
1
+ import '../chunk-7AARTHNW.mjs';
2
+
3
+ // src/utils/format.ts
4
+ var TelegramFormattedText = class {
5
+ constructor(raw) {
6
+ this.raw = raw;
7
+ }
8
+ toString() {
9
+ return this.raw;
10
+ }
11
+ };
12
+ function isFragment(part) {
13
+ return part instanceof TelegramFormattedText;
14
+ }
15
+ function joinParts(parts, escape) {
16
+ return parts.map((part) => isFragment(part) ? part.raw : escape(part)).join("");
17
+ }
18
+ var MARKDOWN_V2_RESERVED = /[_*[\]()~`>#+\-=|{}.!\\]/g;
19
+ var MARKDOWN_V2_CODE_RESERVED = /[`\\]/g;
20
+ var MARKDOWN_V2_LINK_URL_RESERVED = /[)\\]/g;
21
+ function escapeMarkdownV2(text) {
22
+ return text.replace(MARKDOWN_V2_RESERVED, (ch) => `\\${ch}`);
23
+ }
24
+ function escapeMarkdownV2Code(text) {
25
+ return text.replace(MARKDOWN_V2_CODE_RESERVED, (ch) => `\\${ch}`);
26
+ }
27
+ function escapeMarkdownV2LinkUrl(url) {
28
+ return url.replace(MARKDOWN_V2_LINK_URL_RESERVED, (ch) => `\\${ch}`);
29
+ }
30
+ function createMarkdownV2Formatter() {
31
+ const wrap = (raw) => new TelegramFormattedText(raw);
32
+ const t = (parts) => joinParts(parts, escapeMarkdownV2);
33
+ return {
34
+ escape: escapeMarkdownV2,
35
+ escapeCode: escapeMarkdownV2Code,
36
+ escapeLinkUrl: escapeMarkdownV2LinkUrl,
37
+ text: (...parts) => wrap(t(parts)),
38
+ bold: (...parts) => wrap(`*${t(parts)}*`),
39
+ italic: (...parts) => wrap(`_${t(parts)}_`),
40
+ underline: (...parts) => wrap(`__${t(parts)}__`),
41
+ strikethrough: (...parts) => wrap(`~${t(parts)}~`),
42
+ spoiler: (...parts) => wrap(`||${t(parts)}||`),
43
+ code: (text) => wrap(`\`${escapeMarkdownV2Code(text)}\``),
44
+ pre: (text, language) => wrap(`\`\`\`${language != null ? language : ""}
45
+ ${escapeMarkdownV2Code(text)}
46
+ \`\`\``),
47
+ link: (url, ...parts) => wrap(`[${t(parts)}](${escapeMarkdownV2LinkUrl(url)})`),
48
+ mentionUser: (userId, ...parts) => wrap(`[${t(parts)}](tg://user?id=${userId})`),
49
+ customEmoji: (emojiId, fallbackEmoji) => wrap(`![${escapeMarkdownV2(fallbackEmoji)}](tg://emoji?id=${emojiId})`),
50
+ raw: (raw) => wrap(raw)
51
+ };
52
+ }
53
+ function escapeHTML(text) {
54
+ return text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
55
+ }
56
+ function escapeHTMLAttribute(text) {
57
+ return escapeHTML(text).replace(/"/g, "&quot;");
58
+ }
59
+ function createHtmlFormatter() {
60
+ const wrap = (raw) => new TelegramFormattedText(raw);
61
+ const t = (parts) => joinParts(parts, escapeHTML);
62
+ return {
63
+ escape: escapeHTML,
64
+ escapeAttribute: escapeHTMLAttribute,
65
+ text: (...parts) => wrap(t(parts)),
66
+ bold: (...parts) => wrap(`<b>${t(parts)}</b>`),
67
+ italic: (...parts) => wrap(`<i>${t(parts)}</i>`),
68
+ underline: (...parts) => wrap(`<u>${t(parts)}</u>`),
69
+ strikethrough: (...parts) => wrap(`<s>${t(parts)}</s>`),
70
+ spoiler: (...parts) => wrap(`<tg-spoiler>${t(parts)}</tg-spoiler>`),
71
+ code: (text) => wrap(`<code>${escapeHTML(text)}</code>`),
72
+ pre: (text, language) => wrap(
73
+ language ? `<pre><code class="language-${escapeHTMLAttribute(language)}">${escapeHTML(text)}</code></pre>` : `<pre>${escapeHTML(text)}</pre>`
74
+ ),
75
+ link: (url, ...parts) => wrap(`<a href="${escapeHTMLAttribute(url)}">${t(parts)}</a>`),
76
+ mentionUser: (userId, ...parts) => wrap(`<a href="tg://user?id=${userId}">${t(parts)}</a>`),
77
+ blockquote: (...parts) => wrap(`<blockquote>${t(parts)}</blockquote>`),
78
+ expandableBlockquote: (...parts) => wrap(`<blockquote expandable>${t(parts)}</blockquote>`),
79
+ customEmoji: (emojiId, fallbackEmoji) => wrap(`<tg-emoji emoji-id="${escapeHTMLAttribute(emojiId)}">${escapeHTML(fallbackEmoji)}</tg-emoji>`),
80
+ raw: (rawHtml) => wrap(rawHtml)
81
+ };
82
+ }
83
+ var md = createMarkdownV2Formatter();
84
+ var html = createHtmlFormatter();
85
+ var TELEGRAM_TEXT_LIMITS = {
86
+ MESSAGE: 4096,
87
+ CAPTION: 1024,
88
+ BUTTON_TEXT: 64,
89
+ CALLBACK_DATA: 64,
90
+ START_PARAMETER: 64,
91
+ BOT_DESCRIPTION: 512,
92
+ BOT_SHORT_DESCRIPTION: 120,
93
+ CHAT_TITLE: 128,
94
+ POLL_QUESTION: 300,
95
+ POLL_OPTION: 100
96
+ };
97
+ function isHighSurrogate(code) {
98
+ return code >= 55296 && code <= 56319;
99
+ }
100
+ function isLowSurrogate(code) {
101
+ return code >= 56320 && code <= 57343;
102
+ }
103
+ function truncateText(text, maxLength, ellipsis = "\u2026") {
104
+ if (text.length <= maxLength) return text;
105
+ let cut = Math.max(0, maxLength - ellipsis.length);
106
+ if (cut > 0 && isHighSurrogate(text.charCodeAt(cut - 1)) && isLowSurrogate(text.charCodeAt(cut))) {
107
+ cut -= 1;
108
+ }
109
+ return text.slice(0, cut) + ellipsis;
110
+ }
111
+
112
+ export { TELEGRAM_TEXT_LIMITS, TelegramFormattedText, escapeHTML, escapeHTMLAttribute, escapeMarkdownV2, escapeMarkdownV2Code, escapeMarkdownV2LinkUrl, html, md, truncateText };
@@ -0,0 +1 @@
1
+ export { a3 as useAccelerometer, a4 as useBiometric, a5 as useCloudStorage, a6 as useDeviceOrientation, a7 as useDeviceStorage, a8 as useDownloadFile, a9 as useGyroscope, aa as useHapticFeedback, ab as useHideKeyboard, ac as useHomeScreen, ad as useInitData, ae as useInvokeCustomMethod, af as useIsActive, ag as useLocation, ah as useOrientationLock, ai as useReadTextFromClipboard, aj as useReady, ak as useRequestChat, al as useRequestContact, am as useRequestEmojiStatusAccess, an as useRequestWriteAccess, ao as useSafeArea, ap as useScanQrPopup, aq as useSecureStorage, ar as useSetEmojiStatus, as as useShareMessage, at as useShareToStory, au as useShowAlert, av as useShowConfirm, aw as useShowPopup, ax as useSwitchInlineQuery, ay as useTelegramBackButton, az as useTelegramEvent, aA as useTelegramFullscreen, aB as useTelegramMainButton, aC as useTelegramSecondaryButton, aD as useTelegramSettingsButton, aE as useTelegramStartParam, aF as useTelegramTheme, aG as useTelegramUser, aH as useTelegramViewport, aI as useTelegramWebApp } from '../hooks-C5Per70R.mjs';
@@ -0,0 +1 @@
1
+ export { a3 as useAccelerometer, a4 as useBiometric, a5 as useCloudStorage, a6 as useDeviceOrientation, a7 as useDeviceStorage, a8 as useDownloadFile, a9 as useGyroscope, aa as useHapticFeedback, ab as useHideKeyboard, ac as useHomeScreen, ad as useInitData, ae as useInvokeCustomMethod, af as useIsActive, ag as useLocation, ah as useOrientationLock, ai as useReadTextFromClipboard, aj as useReady, ak as useRequestChat, al as useRequestContact, am as useRequestEmojiStatusAccess, an as useRequestWriteAccess, ao as useSafeArea, ap as useScanQrPopup, aq as useSecureStorage, ar as useSetEmojiStatus, as as useShareMessage, at as useShareToStory, au as useShowAlert, av as useShowConfirm, aw as useShowPopup, ax as useSwitchInlineQuery, ay as useTelegramBackButton, az as useTelegramEvent, aA as useTelegramFullscreen, aB as useTelegramMainButton, aC as useTelegramSecondaryButton, aD as useTelegramSettingsButton, aE as useTelegramStartParam, aF as useTelegramTheme, aG as useTelegramUser, aH as useTelegramViewport, aI as useTelegramWebApp } from '../hooks-C5Per70R.js';