telegram-transformer 1.2.0 → 1.4.0

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.
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2022 Ivan Odyntsov
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Ivan Odyntsov
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,129 +1,166 @@
1
- <header>
2
-
3
- <h1 align="center">Telegram message transformer</h1>
4
-
5
- </header>
6
-
7
- ## Introduction
8
-
9
- Telegram transformer is a library that makes it simple for you to transform telegram message to any markup.
10
-
11
- ## Getting started
12
-
13
- ### Installation
14
-
15
- ```shellscript
16
- $ npm install telegram-transformer
17
- ```
18
-
19
- or
20
-
21
- ```shellscript
22
- $ yarn add telegram-transformer
23
- ```
24
-
25
- ### Example
26
-
27
- ```js
28
- import formatText, { htmlFormatters } from 'telegram-transformer';
29
- import { MessageEntity } from 'typegram';
30
-
31
- const text =
32
- 'Hello @username #awesome_hashtag $USD /start@jobs_bot https://telegram.org do-not-reply@telegram.org +1-212-555-0123 bold text italic text underlined text strikethrough text spoiler message monowidth string monowidth block text_link';
33
- const entities: MessageEntity[] = [
34
- { offset: 6, length: 9, type: 'mention' },
35
- { offset: 16, length: 16, type: 'hashtag' },
36
- { offset: 25, length: 7, type: 'bold' },
37
- { offset: 33, length: 4, type: 'cashtag' },
38
- { offset: 38, length: 15, type: 'bot_command' },
39
- { offset: 54, length: 20, type: 'url' },
40
- { offset: 75, length: 25, type: 'email' },
41
- { offset: 101, length: 15, type: 'phone_number' },
42
- { offset: 117, length: 9, type: 'bold' },
43
- { offset: 127, length: 11, type: 'italic' },
44
- { offset: 139, length: 5, type: 'underline' },
45
- { offset: 144, length: 10, type: 'underline' },
46
- { offset: 144, length: 5, type: 'bold' },
47
- { offset: 155, length: 18, type: 'strikethrough' },
48
- { offset: 174, length: 15, type: 'spoiler' },
49
- {
50
- offset: 223,
51
- length: 9,
52
- type: 'text_link',
53
- url: 'https://telegram.org/',
54
- },
55
- ];
56
-
57
- const formatted = formatText(text, entities, { formatters: htmlFormatters });
58
-
59
- console.log(formatted);
60
-
61
- /*
62
- {
63
- text: "Hello <a href='https://t.me/username'>@username</a> <a href='#awesome_hashtag'>#awesome_<strong>hashtag</strong></a> $USD /start@jobs_bot <a href='https://telegram.org'>https://telegram.org</a> <a href='mailto:do-not-reply@telegram.org'>do-not-reply@telegram.org</a> <a href='tel:+1-212-555-0123'>+1-212-555-0123</a> <strong>bold text</strong> <i>italic text</i> <u>under</u><u><strong>lined</strong> text</u> <strike>strikethrough text</strike> <span class='spoiler-hover'>spoiler message</span> monowidth string monowidth block <a href='https://telegram.org/'>text_link</a>",
64
- entities: [
65
- { offset: 6, length: 45, type: 'mention' },
66
- { offset: 16, length: 16, type: 'hashtag' },
67
- { offset: 88, length: 24, type: 'bold' },
68
- { offset: 117, length: 4, type: 'cashtag' },
69
- { offset: 122, length: 15, type: 'bot_command' },
70
- { offset: 138, length: 55, type: 'url' },
71
- { offset: 194, length: 72, type: 'email' },
72
- { offset: 267, length: 49, type: 'phone_number' },
73
- { offset: 317, length: 26, type: 'bold' },
74
- { offset: 344, length: 18, type: 'italic' },
75
- { offset: 363, length: 12, type: 'underline' },
76
- { offset: 144, length: 10, type: 'underline' },
77
- { offset: 378, length: 22, type: 'bold' },
78
- { offset: 410, length: 35, type: 'strikethrough' },
79
- { offset: 446, length: 50, type: 'spoiler' },
80
- {
81
- offset: 530,
82
- length: 45,
83
- type: 'text_link',
84
- url: 'https://telegram.org/'
85
- }
86
- ]
87
- }
88
- */
89
- ```
90
-
91
- ### Custom transformer
92
-
93
- ```js
94
- import formatText, { htmlFormatters } from 'telegram-transformer';
95
- import { MessageEntity } from 'typegram';
96
-
97
- const text = 'Hello @username #awesome_hashtag';
98
- const entities: MessageEntity[] = [
99
- { offset: 6, length: 9, type: 'mention' },
100
- { offset: 16, length: 16, type: 'hashtag' },
101
- ];
102
-
103
- const formatters = {
104
- mention: (entityText: string, entity: MessageEntity, text: string) => ({
105
- before: '<awesome-mention>',
106
- after: '</awesome-mention>',
107
- text: entityText,
108
- }),
109
- hashtag: (entityText: string, entity: MessageEntity, text: string) => ({
110
- before: '<span class="hashtag">',
111
- after: '</span>',
112
- text: entityText,
113
- }),
114
- };
115
-
116
- const formatted = formatText(text, entities, { formatters });
117
-
118
- console.log(formatted);
119
-
120
- /*
121
- {
122
- text: 'Hello <awesome-mention>@username</awesome-mention> <span class="hashtag">#awesome_hashtag</span>',
123
- entities: [
124
- { offset: 6, length: 44, type: 'mention' },
125
- { offset: 51, length: 45, type: 'hashtag' }
126
- ]
127
- }
128
- */
129
- ```
1
+ <header>
2
+ <div align="center">
3
+ <h1 align="center">Telegram message transformer</h1>
4
+
5
+ <a href="https://www.npmjs.com/package/telegram-transformer">
6
+ <img src="https://img.shields.io/npm/v/telegram-transformer.svg" alt="Latest Release">
7
+ </a>
8
+
9
+ </div>
10
+ </header>
11
+
12
+ ## Introduction
13
+
14
+ Telegram transformer is a library that makes it simple for you to transform telegram message to any markup.
15
+
16
+ ## Getting started
17
+
18
+ ### Installation
19
+
20
+ ```shellscript
21
+ $ npm install telegram-transformer
22
+ ```
23
+
24
+ or
25
+
26
+ ```shellscript
27
+ $ yarn add telegram-transformer
28
+ ```
29
+
30
+ ### Example
31
+
32
+ ```js
33
+ import formatText, { htmlFormatters } from 'telegram-transformer';
34
+ import { MessageEntity } from 'typegram';
35
+
36
+ const text =
37
+ 'Hello @username #awesome_hashtag $USD /start@jobs_bot https://telegram.org do-not-reply@telegram.org +1-212-555-0123 bold text italic text underlined text strikethrough text spoiler message monowidth string monowidth block text_link custom_emoji text_mention';
38
+ const entities: MessageEntity[] = [
39
+ { offset: 6, length: 9, type: 'mention' },
40
+ { offset: 16, length: 16, type: 'hashtag' },
41
+ { offset: 25, length: 7, type: 'bold' },
42
+ { offset: 33, length: 4, type: 'cashtag' },
43
+ { offset: 38, length: 15, type: 'bot_command' },
44
+ { offset: 54, length: 20, type: 'url' },
45
+ { offset: 75, length: 25, type: 'email' },
46
+ { offset: 101, length: 15, type: 'phone_number' },
47
+ { offset: 117, length: 9, type: 'bold' },
48
+ { offset: 127, length: 11, type: 'italic' },
49
+ { offset: 139, length: 5, type: 'underline' },
50
+ { offset: 144, length: 10, type: 'underline' },
51
+ { offset: 144, length: 5, type: 'bold' },
52
+ { offset: 155, length: 18, type: 'strikethrough' },
53
+ { offset: 174, length: 15, type: 'spoiler' },
54
+ {
55
+ offset: 223,
56
+ length: 9,
57
+ type: 'text_link',
58
+ url: 'https://telegram.org/',
59
+ },
60
+ {
61
+ offset: 233,
62
+ length: 12,
63
+ type: 'custom_emoji',
64
+ custom_emoji_id: '12345',
65
+ },
66
+ {
67
+ offset: 246,
68
+ length: 12,
69
+ type: 'text_mention',
70
+ user: {
71
+ id: 9876543210,
72
+ is_bot: false,
73
+ first_name: 'First Name',
74
+ },
75
+ },
76
+ ];
77
+
78
+ const formatted = formatText(text, entities, { formatters: htmlFormatters });
79
+
80
+ console.log(formatted);
81
+
82
+ /*
83
+ {
84
+ text: "Hello <a href='https://t.me/username'>@username</a> <a href='#awesome_hashtag'>#awesome_<strong>hashtag</strong></a> $USD /start@jobs_bot <a href='https://telegram.org'>https://telegram.org</a> <a href='mailto:do-not-reply@telegram.org'>do-not-reply@telegram.org</a> <a href='tel:+1-212-555-0123'>+1-212-555-0123</a> <strong>bold text</strong> <i>italic text</i> <u>under</u><u><strong>lined</strong> text</u> <strike>strikethrough text</strike> <span class='spoiler-hover'>spoiler message</span> monowidth string monowidth block <a href='https://telegram.org/'>text_link</a> <span>custom_emoji | <b>EMOJI ID:12345</b></span> <span>text_mention: First Name | <b>ID:9876543210</b></span>",
85
+ entities: [
86
+ { offset: 6, length: 45, type: 'mention' },
87
+ { offset: 52, length: 64, type: 'hashtag' },
88
+ { offset: 88, length: 24, type: 'bold' },
89
+ { offset: 117, length: 4, type: 'cashtag' },
90
+ { offset: 122, length: 15, type: 'bot_command' },
91
+ { offset: 138, length: 55, type: 'url' },
92
+ { offset: 194, length: 72, type: 'email' },
93
+ { offset: 267, length: 49, type: 'phone_number' },
94
+ { offset: 317, length: 26, type: 'bold' },
95
+ { offset: 344, length: 18, type: 'italic' },
96
+ { offset: 363, length: 12, type: 'underline' },
97
+ { offset: 375, length: 34, type: 'underline' },
98
+ { offset: 378, length: 22, type: 'bold' },
99
+ { offset: 410, length: 35, type: 'strikethrough' },
100
+ { offset: 446, length: 50, type: 'spoiler' },
101
+ {
102
+ offset: 530,
103
+ length: 45,
104
+ type: 'text_link',
105
+ url: 'https://telegram.org/',
106
+ },
107
+ {
108
+ offset: 576,
109
+ length: 49,
110
+ type: 'custom_emoji',
111
+ custom_emoji_id: '12345',
112
+ },
113
+ {
114
+ offset: 626,
115
+ length: 60,
116
+ type: 'text_mention',
117
+ user: {
118
+ id: 9876543210,
119
+ is_bot: false,
120
+ first_name: 'First Name',
121
+ },
122
+ },
123
+ ]
124
+ }
125
+ */
126
+ ```
127
+
128
+ ### Custom transformer
129
+
130
+ ```js
131
+ import formatText, { htmlFormatters } from 'telegram-transformer';
132
+ import { MessageEntity } from 'typegram';
133
+
134
+ const text = 'Hello @username #awesome_hashtag';
135
+ const entities: MessageEntity[] = [
136
+ { offset: 6, length: 9, type: 'mention' },
137
+ { offset: 16, length: 16, type: 'hashtag' },
138
+ ];
139
+
140
+ const formatters = {
141
+ mention: (entityText: string, entity: MessageEntity, text: string) => ({
142
+ before: '<awesome-mention>',
143
+ after: '</awesome-mention>',
144
+ text: entityText,
145
+ }),
146
+ hashtag: (entityText: string, entity: MessageEntity, text: string) => ({
147
+ before: '<span class="hashtag">',
148
+ after: '</span>',
149
+ text: entityText,
150
+ }),
151
+ };
152
+
153
+ const formatted = formatText(text, entities, { formatters });
154
+
155
+ console.log(formatted);
156
+
157
+ /*
158
+ {
159
+ text: 'Hello <awesome-mention>@username</awesome-mention> <span class="hashtag">#awesome_hashtag</span>',
160
+ entities: [
161
+ { offset: 6, length: 44, type: 'mention' },
162
+ { offset: 51, length: 45, type: 'hashtag' }
163
+ ]
164
+ }
165
+ */
166
+ ```
@@ -1,3 +1,3 @@
1
- import { Options } from './types';
2
- export declare const DEFAULT_OPTIONS: Required<Options>;
1
+ import { Options } from './types';
2
+ export declare const DEFAULT_OPTIONS: Required<Options>;
3
3
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,OAAO,CAG7C,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,OAAO,CAGpC,CAAC"}
package/lib/constants.js CHANGED
@@ -1,8 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DEFAULT_OPTIONS = void 0;
4
- const formatters_1 = require("./formatters");
5
- exports.DEFAULT_OPTIONS = {
6
- formatters: formatters_1.formatters,
7
- startFrom: 0,
8
- };
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_OPTIONS = void 0;
4
+ const formatters_1 = require("./formatters");
5
+ exports.DEFAULT_OPTIONS = {
6
+ formatters: formatters_1.formatters,
7
+ startFrom: 0,
8
+ };
package/lib/format.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { MessageEntity } from 'typegram';
2
- import { Options } from './types';
3
- export declare const format: (text: string, entities?: MessageEntity[], options?: Options) => {
4
- text: string;
5
- entities: MessageEntity[];
6
- };
1
+ import type { MessageEntity } from 'typegram';
2
+ import { Options } from './types';
3
+ export declare const format: (text: string, entities?: MessageEntity[], options?: Options) => {
4
+ text: string;
5
+ entities: MessageEntity[];
6
+ };
7
7
  //# sourceMappingURL=format.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGzC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC,eAAO,MAAM,MAAM,SACX,MAAM,aACF,aAAa,EAAE,YAChB,OAAO;;;CAyEjB,CAAC"}
1
+ {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAQlC,eAAO,MAAM,MAAM,SACX,MAAM,aACF,aAAa,EAAE,YAChB,OAAO;;;CAsGjB,CAAC"}
package/lib/format.js CHANGED
@@ -1,64 +1,90 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.format = void 0;
4
- const constants_1 = require("./constants");
5
- const formatters_1 = require("./formatters");
6
- const format = (text, entities = [], options = constants_1.DEFAULT_OPTIONS) => {
7
- if (!(entities === null || entities === void 0 ? void 0 : entities.length)) {
8
- return {
9
- text,
10
- entities,
11
- };
12
- }
13
- const newEntities = [...entities];
14
- const formatters = {
15
- ...constants_1.DEFAULT_OPTIONS.formatters,
16
- ...options.formatters,
17
- };
18
- const startFrom = options.startFrom || constants_1.DEFAULT_OPTIONS.startFrom;
19
- let newText = text;
20
- let offsetChange = 0;
21
- let afterOffsetChange = 0;
22
- let prevOffsetChange = 0;
23
- let prevLengthChange = 0;
24
- for (let i = 0; i < newEntities.length; i++) {
25
- const entity = { ...newEntities[i] };
26
- const formatter = formatters[entity.type] || formatters_1.defaultFormatter;
27
- const isNotInRange = entity.offset < startFrom;
28
- newEntities[i] = entity;
29
- entity.offset -= startFrom;
30
- if (isNotInRange) {
31
- continue;
32
- }
33
- let newOffset = entity.offset + offsetChange;
34
- let newOffsetWithLength = newOffset + entity.length;
35
- const prevEntity = newEntities[i - 1];
36
- if (prevEntity &&
37
- newOffset >= (prevEntity === null || prevEntity === void 0 ? void 0 : prevEntity.offset) + offsetChange + (prevEntity === null || prevEntity === void 0 ? void 0 : prevEntity.length)) {
38
- prevEntity.offset += prevOffsetChange;
39
- prevEntity.length += prevLengthChange;
40
- offsetChange += afterOffsetChange;
41
- afterOffsetChange = 0;
42
- newOffset = entity.offset + offsetChange;
43
- newOffsetWithLength = newOffset + entity.length;
44
- }
45
- const beforeEntity = newText.substring(0, newOffset);
46
- const entityText = newText.substring(newOffset, newOffsetWithLength);
47
- const afterEntity = newText.substring(newOffsetWithLength, newText.length);
48
- const formatted = formatter(entityText, entity, text);
49
- prevOffsetChange = offsetChange;
50
- prevLengthChange = formatted.before.length + formatted.after.length;
51
- offsetChange += formatted.before.length;
52
- afterOffsetChange += formatted.after.length;
53
- newText = `${beforeEntity}${formatted.before}${formatted.text}${formatted.after}${afterEntity}`;
54
- if (i === entities.length - 1) {
55
- entity.offset += prevOffsetChange;
56
- entity.length += prevLengthChange;
57
- }
58
- }
59
- return {
60
- text: newText,
61
- entities: newEntities,
62
- };
63
- };
64
- exports.format = format;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.format = void 0;
4
+ const constants_1 = require("./constants");
5
+ const renderNode_1 = require("./renderNode");
6
+ const format = (text, entities = [], options = constants_1.DEFAULT_OPTIONS) => {
7
+ var _a, _b;
8
+ if (!(entities === null || entities === void 0 ? void 0 : entities.length)) {
9
+ return { text, entities };
10
+ }
11
+ const formatters = {
12
+ ...constants_1.DEFAULT_OPTIONS.formatters,
13
+ ...options.formatters,
14
+ };
15
+ const startFrom = (_b = (_a = options.startFrom) !== null && _a !== void 0 ? _a : constants_1.DEFAULT_OPTIONS.startFrom) !== null && _b !== void 0 ? _b : 0;
16
+ const prefix = text.substring(0, startFrom);
17
+ const partialText = text.substring(startFrom);
18
+ const unchangedEntities = [];
19
+ const roots = [];
20
+ const stack = [];
21
+ for (const entity of entities) {
22
+ if (entity.offset < startFrom) {
23
+ unchangedEntities.push(entity);
24
+ continue;
25
+ }
26
+ const node = {
27
+ entity: {
28
+ ...entity,
29
+ offset: entity.offset - startFrom,
30
+ },
31
+ children: [],
32
+ };
33
+ while (stack.length > 0) {
34
+ const top = stack[stack.length - 1];
35
+ if (!top) {
36
+ break;
37
+ }
38
+ if (top.entity.offset + top.entity.length > node.entity.offset) {
39
+ break;
40
+ }
41
+ stack.pop();
42
+ }
43
+ if (stack.length > 0) {
44
+ const stackitem = stack[stack.length - 1];
45
+ if (stackitem) {
46
+ stackitem.children.push(node);
47
+ }
48
+ }
49
+ else {
50
+ roots.push(node);
51
+ }
52
+ stack.push(node);
53
+ }
54
+ const parts = [prefix];
55
+ let currentPosition = prefix.length;
56
+ const updatedEntities = [];
57
+ let sourcePosition = 0;
58
+ if (roots.length > 0) {
59
+ roots.sort((a, b) => a.entity.offset - b.entity.offset);
60
+ for (const root of roots) {
61
+ const plain = partialText.substring(sourcePosition, root.entity.offset);
62
+ parts.push(plain);
63
+ currentPosition += plain.length;
64
+ const nodeResult = (0, renderNode_1.renderNode)({
65
+ node: root,
66
+ parts,
67
+ formatters,
68
+ partialText,
69
+ currentPosition,
70
+ text,
71
+ entries: updatedEntities,
72
+ });
73
+ currentPosition = nodeResult.currentPosition;
74
+ sourcePosition = root.entity.offset + root.entity.length;
75
+ }
76
+ const lastPlain = partialText.substring(sourcePosition);
77
+ parts.push(lastPlain);
78
+ currentPosition += lastPlain.length;
79
+ }
80
+ else {
81
+ parts.push(partialText);
82
+ }
83
+ const newEntities = [...unchangedEntities, ...updatedEntities];
84
+ newEntities.sort((a, b) => a.offset - b.offset);
85
+ return {
86
+ text: parts.join(''),
87
+ entities: newEntities,
88
+ };
89
+ };
90
+ exports.format = format;
@@ -1,5 +1,11 @@
1
- import { FormatterFn, FormattersDict } from './types';
2
- export declare const defaultFormatter: FormatterFn;
3
- export declare const formatters: FormattersDict;
4
- export declare const htmlFormatters: FormattersDict;
1
+ import type { MessageEntity } from 'typegram';
2
+ import { FormatterFn, FormattersDict } from './types';
3
+ export declare const abstractDefaultFormatter: FormatterFn<MessageEntity.AbstractMessageEntity>;
4
+ export declare const defaultFormatter: FormatterFn<MessageEntity.CommonMessageEntity>;
5
+ export declare const defaultTextMentaionFormatter: FormatterFn<MessageEntity.TextMentionMessageEntity>;
6
+ export declare const defaultTextLinkFormatter: FormatterFn<MessageEntity.TextLinkMessageEntity>;
7
+ export declare const defaultPreFormatter: FormatterFn<MessageEntity.PreMessageEntity>;
8
+ export declare const defaultCustomEmojiFormatter: FormatterFn<MessageEntity.CustomEmojiMessageEntity>;
9
+ export declare const formatters: FormattersDict;
10
+ export declare const htmlFormatters: FormattersDict;
5
11
  //# sourceMappingURL=formatters.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"formatters.d.ts","sourceRoot":"","sources":["../src/formatters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEtD,eAAO,MAAM,gBAAgB,EAAE,WAS9B,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,cAgBxB,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,cAsH5B,CAAC"}
1
+ {"version":3,"file":"formatters.d.ts","sourceRoot":"","sources":["../src/formatters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEtD,eAAO,MAAM,wBAAwB,EAAE,WAAW,CAChD,aAAa,CAAC,qBAAqB,CAUpC,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,WAAW,CACxC,aAAa,CAAC,mBAAmB,CAGlC,CAAC;AAEF,eAAO,MAAM,4BAA4B,EAAE,WAAW,CACpD,aAAa,CAAC,wBAAwB,CASvC,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,WAAW,CAChD,aAAa,CAAC,qBAAqB,CAGpC,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,WAAW,CAC3C,aAAa,CAAC,gBAAgB,CAG/B,CAAC;AAEF,eAAO,MAAM,2BAA2B,EAAE,WAAW,CACnD,aAAa,CAAC,wBAAwB,CAGvC,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,cAkBxB,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,cAmJ5B,CAAC"}