@transferwise/components 0.0.0-experimental-fa3aa98 → 0.0.0-experimental-f4a328f

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 (201) hide show
  1. package/build/Calendar/Calendar.js +16 -94
  2. package/build/Calendar/Calendar.js.map +1 -1
  3. package/build/Calendar/Calendar.messages.js +0 -12
  4. package/build/Calendar/Calendar.messages.js.map +1 -1
  5. package/build/Calendar/Calendar.messages.mjs +0 -12
  6. package/build/Calendar/Calendar.messages.mjs.map +1 -1
  7. package/build/Calendar/Calendar.mjs +17 -95
  8. package/build/Calendar/Calendar.mjs.map +1 -1
  9. package/build/Calendar/DateHeader/DateHeader.js +1 -5
  10. package/build/Calendar/DateHeader/DateHeader.js.map +1 -1
  11. package/build/Calendar/DateHeader/DateHeader.mjs +1 -5
  12. package/build/Calendar/DateHeader/DateHeader.mjs.map +1 -1
  13. package/build/Calendar/DayCalendar/DayCalendar.js +0 -14
  14. package/build/Calendar/DayCalendar/DayCalendar.js.map +1 -1
  15. package/build/Calendar/DayCalendar/DayCalendar.mjs +0 -14
  16. package/build/Calendar/DayCalendar/DayCalendar.mjs.map +1 -1
  17. package/build/Calendar/DayCalendar/Table/DayCalendarTable.js +19 -53
  18. package/build/Calendar/DayCalendar/Table/DayCalendarTable.js.map +1 -1
  19. package/build/Calendar/DayCalendar/Table/DayCalendarTable.mjs +19 -53
  20. package/build/Calendar/DayCalendar/Table/DayCalendarTable.mjs.map +1 -1
  21. package/build/Calendar/MonthCalendar/MonthCalendar.js +0 -6
  22. package/build/Calendar/MonthCalendar/MonthCalendar.js.map +1 -1
  23. package/build/Calendar/MonthCalendar/MonthCalendar.mjs +0 -6
  24. package/build/Calendar/MonthCalendar/MonthCalendar.mjs.map +1 -1
  25. package/build/Calendar/MonthCalendar/Table/MonthCalendarTable.js +3 -8
  26. package/build/Calendar/MonthCalendar/Table/MonthCalendarTable.js.map +1 -1
  27. package/build/Calendar/MonthCalendar/Table/MonthCalendarTable.mjs +3 -8
  28. package/build/Calendar/MonthCalendar/Table/MonthCalendarTable.mjs.map +1 -1
  29. package/build/Calendar/YearCalendar/Table/YearCalendarTable.js +3 -8
  30. package/build/Calendar/YearCalendar/Table/YearCalendarTable.js.map +1 -1
  31. package/build/Calendar/YearCalendar/Table/YearCalendarTable.mjs +3 -8
  32. package/build/Calendar/YearCalendar/Table/YearCalendarTable.mjs.map +1 -1
  33. package/build/Calendar/YearCalendar/YearCalendar.js +0 -7
  34. package/build/Calendar/YearCalendar/YearCalendar.js.map +1 -1
  35. package/build/Calendar/YearCalendar/YearCalendar.mjs +0 -7
  36. package/build/Calendar/YearCalendar/YearCalendar.mjs.map +1 -1
  37. package/build/Calendar/{TableLink → tableLink}/TableLink.js +11 -26
  38. package/build/Calendar/tableLink/TableLink.js.map +1 -0
  39. package/build/Calendar/{TableLink → tableLink}/TableLink.mjs +11 -26
  40. package/build/Calendar/tableLink/TableLink.mjs.map +1 -0
  41. package/build/DateLookup/DateLookup.js +9 -20
  42. package/build/DateLookup/DateLookup.js.map +1 -1
  43. package/build/DateLookup/DateLookup.mjs +9 -20
  44. package/build/DateLookup/DateLookup.mjs.map +1 -1
  45. package/build/Markup/Markup.js +137 -0
  46. package/build/Markup/Markup.js.map +1 -0
  47. package/build/Markup/Markup.mjs +132 -0
  48. package/build/Markup/Markup.mjs.map +1 -0
  49. package/build/Markup/constants.js +36 -0
  50. package/build/Markup/constants.js.map +1 -0
  51. package/build/Markup/constants.mjs +29 -0
  52. package/build/Markup/constants.mjs.map +1 -0
  53. package/build/Markup/utils/parseMarkup.js +236 -0
  54. package/build/Markup/utils/parseMarkup.js.map +1 -0
  55. package/build/Markup/utils/parseMarkup.mjs +231 -0
  56. package/build/Markup/utils/parseMarkup.mjs.map +1 -0
  57. package/build/Markup/utils/sanitise.js +114 -0
  58. package/build/Markup/utils/sanitise.js.map +1 -0
  59. package/build/Markup/utils/sanitise.mjs +111 -0
  60. package/build/Markup/utils/sanitise.mjs.map +1 -0
  61. package/build/i18n/en.json +0 -4
  62. package/build/i18n/en.json.js +0 -4
  63. package/build/i18n/en.json.js.map +1 -1
  64. package/build/i18n/en.json.mjs +0 -4
  65. package/build/i18n/en.json.mjs.map +1 -1
  66. package/build/index.js +4 -2
  67. package/build/index.js.map +1 -1
  68. package/build/index.mjs +2 -1
  69. package/build/index.mjs.map +1 -1
  70. package/build/main.css +78 -123
  71. package/build/styles/Calendar/Calendar.css +37 -112
  72. package/build/styles/Markup/Markup.css +28 -0
  73. package/build/styles/Markup/_stories/Vulnerability/Vulnerability.css +69 -0
  74. package/build/styles/main.css +78 -123
  75. package/build/types/Body/Body.d.ts +2 -2
  76. package/build/types/Calendar/Calendar.d.ts +3 -16
  77. package/build/types/Calendar/Calendar.d.ts.map +1 -1
  78. package/build/types/Calendar/Calendar.messages.d.ts +0 -20
  79. package/build/types/Calendar/Calendar.messages.d.ts.map +1 -1
  80. package/build/types/Calendar/DateHeader/DateHeader.d.ts +0 -2
  81. package/build/types/Calendar/DateHeader/DateHeader.d.ts.map +1 -1
  82. package/build/types/Calendar/DayCalendar/DayCalendar.d.ts +1 -5
  83. package/build/types/Calendar/DayCalendar/DayCalendar.d.ts.map +1 -1
  84. package/build/types/Calendar/DayCalendar/Table/DayCalendarTable.d.ts +0 -4
  85. package/build/types/Calendar/DayCalendar/Table/DayCalendarTable.d.ts.map +1 -1
  86. package/build/types/Calendar/MonthCalendar/MonthCalendar.d.ts +0 -1
  87. package/build/types/Calendar/MonthCalendar/MonthCalendar.d.ts.map +1 -1
  88. package/build/types/Calendar/MonthCalendar/Table/MonthCalendarTable.d.ts +1 -2
  89. package/build/types/Calendar/MonthCalendar/Table/MonthCalendarTable.d.ts.map +1 -1
  90. package/build/types/Calendar/YearCalendar/Table/YearCalendarTable.d.ts +1 -2
  91. package/build/types/Calendar/YearCalendar/Table/YearCalendarTable.d.ts.map +1 -1
  92. package/build/types/Calendar/YearCalendar/YearCalendar.d.ts +0 -1
  93. package/build/types/Calendar/YearCalendar/YearCalendar.d.ts.map +1 -1
  94. package/build/types/Calendar/index.d.ts +0 -1
  95. package/build/types/Calendar/index.d.ts.map +1 -1
  96. package/build/types/Calendar/{TableLink → tableLink}/TableLink.d.ts +1 -3
  97. package/build/types/Calendar/tableLink/TableLink.d.ts.map +1 -0
  98. package/build/types/Calendar/tableLink/index.d.ts.map +1 -0
  99. package/build/types/DateLookup/DateLookup.d.ts +5 -24
  100. package/build/types/DateLookup/DateLookup.d.ts.map +1 -1
  101. package/build/types/DateLookup/index.d.ts +0 -1
  102. package/build/types/DateLookup/index.d.ts.map +1 -1
  103. package/build/types/IconButton/IconButton.d.ts +1 -1
  104. package/build/types/Markup/Markup.d.ts +18 -0
  105. package/build/types/Markup/Markup.d.ts.map +1 -0
  106. package/build/types/Markup/Markup.types.d.ts +77 -0
  107. package/build/types/Markup/Markup.types.d.ts.map +1 -0
  108. package/build/types/Markup/_stories/Vulnerability/Vulnerability.d.ts +12 -0
  109. package/build/types/Markup/_stories/Vulnerability/Vulnerability.d.ts.map +1 -0
  110. package/build/types/Markup/constants.d.ts +20 -0
  111. package/build/types/Markup/constants.d.ts.map +1 -0
  112. package/build/types/Markup/index.d.ts +3 -0
  113. package/build/types/Markup/index.d.ts.map +1 -0
  114. package/build/types/Markup/utils/parseMarkup.d.ts +8 -0
  115. package/build/types/Markup/utils/parseMarkup.d.ts.map +1 -0
  116. package/build/types/Markup/utils/sanitise.d.ts +4 -0
  117. package/build/types/Markup/utils/sanitise.d.ts.map +1 -0
  118. package/build/types/Title/Title.d.ts +2 -2
  119. package/build/types/Upload/Steps/UploadImageStep/UploadImageStep.d.ts +1 -1
  120. package/build/types/UploadInput/UploadItem/UploadItemLink.d.ts +1 -1
  121. package/build/types/common/DateUtils/index.d.ts +0 -2
  122. package/build/types/common/DateUtils/index.d.ts.map +1 -1
  123. package/build/types/index.d.ts +4 -3
  124. package/build/types/index.d.ts.map +1 -1
  125. package/build/types/test-utils/index.d.ts +0 -8
  126. package/build/types/test-utils/index.d.ts.map +1 -1
  127. package/package.json +1 -1
  128. package/src/Calendar/Calendar.css +37 -112
  129. package/src/Calendar/Calendar.less +35 -5
  130. package/src/Calendar/Calendar.messages.ts +0 -21
  131. package/src/Calendar/Calendar.test.tsx +27 -288
  132. package/src/Calendar/Calendar.tsx +19 -136
  133. package/src/Calendar/DateHeader/DateHeader.tsx +0 -6
  134. package/src/Calendar/DayCalendar/DayCalendar.tsx +1 -33
  135. package/src/Calendar/DayCalendar/Table/DayCalendarTable.tsx +28 -62
  136. package/src/Calendar/MonthCalendar/MonthCalendar.tsx +0 -8
  137. package/src/Calendar/MonthCalendar/Table/MonthCalendarTable.tsx +3 -15
  138. package/src/Calendar/YearCalendar/Table/YearCalendarTable.tsx +3 -15
  139. package/src/Calendar/YearCalendar/YearCalendar.tsx +0 -9
  140. package/src/Calendar/_stories/Calendar.story.tsx +4 -138
  141. package/src/Calendar/index.ts +0 -7
  142. package/src/Calendar/{TableLink → tableLink}/TableLink.tsx +14 -29
  143. package/src/DateLookup/DateLookup.test.tsx +37 -34
  144. package/src/DateLookup/DateLookup.tsx +13 -37
  145. package/src/DateLookup/_stories/DateLookup.story.tsx +2 -124
  146. package/src/DateLookup/index.ts +0 -6
  147. package/src/Markup/Markup.css +28 -0
  148. package/src/Markup/Markup.injection.test.tsx +163 -0
  149. package/src/Markup/Markup.less +29 -0
  150. package/src/Markup/Markup.test.tsx +463 -0
  151. package/src/Markup/Markup.tsx +169 -0
  152. package/src/Markup/Markup.types.ts +62 -0
  153. package/src/Markup/_stories/Markup.docs.mdx +75 -0
  154. package/src/Markup/_stories/Markup.security.docs.mdx +343 -0
  155. package/src/Markup/_stories/Markup.story.tsx +266 -0
  156. package/src/Markup/_stories/Vulnerability/Vulnerability.css +69 -0
  157. package/src/Markup/_stories/Vulnerability/Vulnerability.tsx +30 -0
  158. package/src/Markup/constants.ts +41 -0
  159. package/src/Markup/index.ts +2 -0
  160. package/src/Markup/utils/parseMarkup.test.ts +706 -0
  161. package/src/Markup/utils/parseMarkup.ts +234 -0
  162. package/src/Markup/utils/sanitise.test.ts +497 -0
  163. package/src/Markup/utils/sanitise.ts +133 -0
  164. package/src/common/DateUtils/index.ts +0 -2
  165. package/src/i18n/en.json +0 -4
  166. package/src/index.ts +4 -3
  167. package/src/main.css +78 -123
  168. package/src/main.less +1 -0
  169. package/build/Calendar/TableLink/TableLink.js.map +0 -1
  170. package/build/Calendar/TableLink/TableLink.mjs.map +0 -1
  171. package/build/common/DateUtils/hasDisabledDatesInMonth/hasDisabledDatesInMonth.js +0 -33
  172. package/build/common/DateUtils/hasDisabledDatesInMonth/hasDisabledDatesInMonth.js.map +0 -1
  173. package/build/common/DateUtils/hasDisabledDatesInMonth/hasDisabledDatesInMonth.mjs +0 -31
  174. package/build/common/DateUtils/hasDisabledDatesInMonth/hasDisabledDatesInMonth.mjs.map +0 -1
  175. package/build/common/DateUtils/isDateDisabled/isDateDisabled.js +0 -40
  176. package/build/common/DateUtils/isDateDisabled/isDateDisabled.js.map +0 -1
  177. package/build/common/DateUtils/isDateDisabled/isDateDisabled.mjs +0 -38
  178. package/build/common/DateUtils/isDateDisabled/isDateDisabled.mjs.map +0 -1
  179. package/build/styles/Calendar/TableLink/TableLink.css +0 -115
  180. package/build/types/Calendar/Calendar.types.d.ts +0 -32
  181. package/build/types/Calendar/Calendar.types.d.ts.map +0 -1
  182. package/build/types/Calendar/TableLink/TableLink.d.ts.map +0 -1
  183. package/build/types/Calendar/TableLink/index.d.ts.map +0 -1
  184. package/build/types/common/DateUtils/hasDisabledDatesInMonth/hasDisabledDatesInMonth.d.ts +0 -3
  185. package/build/types/common/DateUtils/hasDisabledDatesInMonth/hasDisabledDatesInMonth.d.ts.map +0 -1
  186. package/build/types/common/DateUtils/isDateDisabled/isDateDisabled.d.ts +0 -3
  187. package/build/types/common/DateUtils/isDateDisabled/isDateDisabled.d.ts.map +0 -1
  188. package/src/Calendar/Calendar.disabledDates.test.tsx +0 -518
  189. package/src/Calendar/Calendar.types.ts +0 -35
  190. package/src/Calendar/TableLink/TableLink.css +0 -115
  191. package/src/Calendar/TableLink/TableLink.less +0 -68
  192. package/src/Calendar/_stories/Calendar.accessibility.docs.mdx +0 -118
  193. package/src/Calendar/_stories/Calendar.test.story.tsx +0 -74
  194. package/src/DateLookup/DateLookup.disabledDates.test.tsx +0 -293
  195. package/src/DateLookup/_stories/DateLookup.accessibility.docs.mdx +0 -108
  196. package/src/common/DateUtils/hasDisabledDatesInMonth/hasDisabledDatesInMonth.test.ts +0 -98
  197. package/src/common/DateUtils/hasDisabledDatesInMonth/hasDisabledDatesInMonth.ts +0 -45
  198. package/src/common/DateUtils/isDateDisabled/isDateDisabled.test.ts +0 -169
  199. package/src/common/DateUtils/isDateDisabled/isDateDisabled.ts +0 -59
  200. /package/build/types/Calendar/{TableLink → tableLink}/index.d.ts +0 -0
  201. /package/src/Calendar/{TableLink → tableLink}/index.ts +0 -0
@@ -0,0 +1,234 @@
1
+ import { ALLOWED_TARGETS, MAX_NESTING_DEPTH, TAG_ALIASES, TAG_REGEX } from '../constants';
2
+ import { MarkupNode } from '../Markup.types';
3
+
4
+ export { MAX_NESTING_DEPTH };
5
+ export const MAX_INPUT_LENGTH = 10_000;
6
+ export const MAX_ACCESSIBILITY_LABEL_LENGTH = 250;
7
+
8
+ const OBJECT_PROTOTYPE_KEYS = new Set(Object.getOwnPropertyNames(Object.prototype));
9
+
10
+ // eslint-disable-next-line regexp/no-control-character
11
+ const CONTROL_CHARS = /[\x00-\x1f\x7f-\x9f]/g;
12
+ const HTML_METACHAR = /[<>"']/g;
13
+
14
+ type Token =
15
+ | { type: 'text'; content: string }
16
+ | { type: 'newline' }
17
+ | { type: 'open'; tag: string; attrs: string }
18
+ | { type: 'close'; tag: string };
19
+
20
+ /**
21
+ * Splits the input string into a flat list of tokens by scanning for known tags.
22
+ * Text between tags is emitted as text/newline tokens. Unrecognised tags are never
23
+ * tokenised — they remain part of the surrounding text content.
24
+ */
25
+ function tokenise(input: string): Token[] {
26
+ const tokens: Token[] = [];
27
+ let lastIndex = 0;
28
+
29
+ TAG_REGEX.lastIndex = 0;
30
+ let match = TAG_REGEX.exec(input);
31
+
32
+ while (match !== null) {
33
+ if (match.index > lastIndex) {
34
+ pushTextWithNewlines(tokens, input.slice(lastIndex, match.index));
35
+ }
36
+
37
+ const isClose = match[1] === '/';
38
+ const tag = match[2];
39
+ const attrs = match[3] || '';
40
+
41
+ if (isClose) {
42
+ tokens.push({ type: 'close', tag });
43
+ } else {
44
+ tokens.push({ type: 'open', tag, attrs });
45
+ }
46
+
47
+ lastIndex = TAG_REGEX.lastIndex;
48
+ match = TAG_REGEX.exec(input);
49
+ }
50
+
51
+ if (lastIndex < input.length) {
52
+ pushTextWithNewlines(tokens, input.slice(lastIndex));
53
+ }
54
+
55
+ return tokens;
56
+ }
57
+
58
+ /** Splits a text fragment on newline characters, interleaving newline tokens between parts. */
59
+ function pushTextWithNewlines(tokens: Token[], text: string): void {
60
+ const parts = text.split('\n');
61
+ for (let index = 0; index < parts.length; index += 1) {
62
+ if (index > 0) {
63
+ tokens.push({ type: 'newline' });
64
+ }
65
+ if (parts[index]) {
66
+ tokens.push({ type: 'text', content: parts[index] });
67
+ }
68
+ }
69
+ }
70
+
71
+ type ParseResult = { closed: true; nodes: MarkupNode[] } | { closed: false; nodes: MarkupNode[] };
72
+
73
+ /**
74
+ * Recursive descent parser that consumes tokens and builds a MarkupNode tree.
75
+ *
76
+ * When `untilTag` is provided, the function collects nodes until it finds a matching
77
+ * close token — returning `{ closed: true }`. If it exhausts all tokens without finding
78
+ * the close, it returns `{ closed: false }` so the caller can fall back to plain text
79
+ * (graceful degradation for malformed input).
80
+ *
81
+ * The shared `position` object acts as a cursor across recursive calls, avoiding the
82
+ * need to slice or copy the token array.
83
+ */
84
+ function parse(
85
+ tokens: Token[],
86
+ position: { index: number },
87
+ untilTag?: string,
88
+ depth = 0,
89
+ ): ParseResult {
90
+ const nodes: MarkupNode[] = [];
91
+
92
+ while (position.index < tokens.length) {
93
+ const token = tokens[position.index];
94
+
95
+ if (token.type === 'text') {
96
+ nodes.push({ type: 'text', content: token.content });
97
+ position.index += 1;
98
+ } else if (token.type === 'newline') {
99
+ nodes.push({ type: 'newline' });
100
+ position.index += 1;
101
+ } else if (token.type === 'close') {
102
+ if (token.tag === untilTag) {
103
+ position.index += 1;
104
+ return { closed: true, nodes };
105
+ }
106
+ // Mismatched close tag — render as literal text
107
+ nodes.push({ type: 'text', content: `</${token.tag}>` });
108
+ position.index += 1;
109
+ } else if (token.type === 'open') {
110
+ if (depth >= MAX_NESTING_DEPTH) {
111
+ nodes.push({ type: 'text', content: `<${token.tag}${token.attrs}>` });
112
+ position.index += 1;
113
+ } else {
114
+ position.index += 1;
115
+ const result = parse(tokens, position, token.tag, depth + 1);
116
+
117
+ if (result.closed) {
118
+ const node = buildNode(token.tag, token.attrs, result.nodes);
119
+ nodes.push(node);
120
+ } else {
121
+ nodes.push({ type: 'text', content: `<${token.tag}${token.attrs}>` });
122
+ nodes.push(...result.nodes);
123
+ }
124
+ }
125
+ }
126
+ }
127
+
128
+ if (untilTag) {
129
+ return { closed: false, nodes };
130
+ }
131
+
132
+ return { closed: true, nodes };
133
+ }
134
+
135
+ /**
136
+ * Maps a raw tag name to a typed MarkupNode. Resolves aliases first (p→paragraph, a→link),
137
+ * then builds the appropriate node shape. Link nodes carry full attributes; other element
138
+ * nodes extract only accessibilityLabel.
139
+ */
140
+ function buildNode(rawTag: string, attrs: string, children: MarkupNode[]): MarkupNode {
141
+ const tag = TAG_ALIASES[rawTag] || rawTag;
142
+
143
+ if (tag === 'link') {
144
+ return { type: 'link', children, ...parseAttributes(attrs) };
145
+ }
146
+
147
+ if (tag === 'paragraph') {
148
+ return { type: 'paragraph', children };
149
+ }
150
+
151
+ const { accessibilityLabel } = parseAttributes(attrs);
152
+
153
+ return {
154
+ type: tag as MarkupNode['type'],
155
+ children,
156
+ ...(accessibilityLabel && { accessibilityLabel }),
157
+ } as MarkupNode;
158
+ }
159
+
160
+ const ATTR_REGEX = /(?<=\s)(href|action|target|accessibilityLabel)=(?:"([^"]*)"|'([^']*)')/g;
161
+
162
+ type ParsedAttributes = {
163
+ href?: string;
164
+ action?: string;
165
+ target?: string;
166
+ accessibilityLabel?: string;
167
+ };
168
+
169
+ /**
170
+ * Extracts allowed attributes from a raw attribute string.
171
+ * Supports both double- and single-quoted values. Any attribute not in the
172
+ * allow-list (href, action, target, accessibilityLabel) is silently discarded.
173
+ * First occurrence wins — duplicates are ignored.
174
+ */
175
+ function parseAttributes(attrs: string): ParsedAttributes {
176
+ const result: ParsedAttributes = {};
177
+ ATTR_REGEX.lastIndex = 0;
178
+ let match = ATTR_REGEX.exec(attrs);
179
+
180
+ while (match !== null) {
181
+ const key = match[1] as 'href' | 'action' | 'target' | 'accessibilityLabel';
182
+ const value = match[2] ?? match[3];
183
+
184
+ if (!(key in result)) {
185
+ const sanitized = sanitizeAttributeValue(key, value);
186
+ if (sanitized !== undefined) {
187
+ result[key] = sanitized;
188
+ }
189
+ }
190
+
191
+ match = ATTR_REGEX.exec(attrs);
192
+ }
193
+
194
+ return result;
195
+ }
196
+
197
+ function sanitizeAttributeValue(
198
+ key: 'href' | 'action' | 'target' | 'accessibilityLabel',
199
+ value: string,
200
+ ): string | undefined {
201
+ switch (key) {
202
+ case 'href':
203
+ return value.replace(CONTROL_CHARS, '');
204
+ case 'action':
205
+ if (OBJECT_PROTOTYPE_KEYS.has(value)) {
206
+ return undefined;
207
+ }
208
+ return value;
209
+ case 'target':
210
+ if (!ALLOWED_TARGETS.includes(value)) {
211
+ return undefined;
212
+ }
213
+ return value;
214
+ case 'accessibilityLabel':
215
+ return value.replace(HTML_METACHAR, '').slice(0, MAX_ACCESSIBILITY_LABEL_LENGTH);
216
+ default:
217
+ return value;
218
+ }
219
+ }
220
+
221
+ /** Entry point: tokenises the input string, then parses the token stream into a MarkupNode tree. */
222
+ export function parseMarkup(input: string): MarkupNode[] {
223
+ if (!input) {
224
+ return [];
225
+ }
226
+
227
+ if (input.length > MAX_INPUT_LENGTH) {
228
+ return [{ type: 'text', content: input }];
229
+ }
230
+
231
+ const tokens = tokenise(input);
232
+ const position = { index: 0 };
233
+ return parse(tokens, position).nodes;
234
+ }