@dst0/p-tui 0.4.41 → 5.0.2

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 (387) hide show
  1. package/dist/autocomplete.d.ts.map +1 -1
  2. package/dist/autocomplete.js.map +1 -1
  3. package/dist/components/box.d.ts +3 -1
  4. package/dist/components/box.d.ts.map +1 -1
  5. package/dist/components/box.js +19 -10
  6. package/dist/components/box.js.map +1 -1
  7. package/dist/components/cancellable-loader.d.ts.map +1 -1
  8. package/dist/components/cancellable-loader.js.map +1 -1
  9. package/dist/components/editor/constants.d.ts +9 -0
  10. package/dist/components/editor/constants.d.ts.map +1 -0
  11. package/dist/components/editor/constants.js +12 -0
  12. package/dist/components/editor/constants.js.map +1 -0
  13. package/dist/components/editor/editor-methods/autocomplete-matching.d.ts +29 -0
  14. package/dist/components/editor/editor-methods/autocomplete-matching.d.ts.map +1 -0
  15. package/dist/components/editor/editor-methods/autocomplete-matching.js +104 -0
  16. package/dist/components/editor/editor-methods/autocomplete-matching.js.map +1 -0
  17. package/dist/components/editor/editor-methods/autocomplete-request.d.ts +14 -0
  18. package/dist/components/editor/editor-methods/autocomplete-request.d.ts.map +1 -0
  19. package/dist/components/editor/editor-methods/autocomplete-request.js +72 -0
  20. package/dist/components/editor/editor-methods/autocomplete-request.js.map +1 -0
  21. package/dist/components/editor/editor-methods/backspace-cursor.d.ts +9 -0
  22. package/dist/components/editor/editor-methods/backspace-cursor.d.ts.map +1 -0
  23. package/dist/components/editor/editor-methods/backspace-cursor.js +122 -0
  24. package/dist/components/editor/editor-methods/backspace-cursor.js.map +1 -0
  25. package/dist/components/editor/editor-methods/configuration.d.ts +17 -0
  26. package/dist/components/editor/editor-methods/configuration.d.ts.map +1 -0
  27. package/dist/components/editor/editor-methods/configuration.js +107 -0
  28. package/dist/components/editor/editor-methods/configuration.js.map +1 -0
  29. package/dist/components/editor/editor-methods/cursor-movement.d.ts +7 -0
  30. package/dist/components/editor/editor-methods/cursor-movement.d.ts.map +1 -0
  31. package/dist/components/editor/editor-methods/cursor-movement.js +112 -0
  32. package/dist/components/editor/editor-methods/cursor-movement.js.map +1 -0
  33. package/dist/components/editor/editor-methods/input-handling.d.ts +3 -0
  34. package/dist/components/editor/editor-methods/input-handling.d.ts.map +1 -0
  35. package/dist/components/editor/editor-methods/input-handling.js +257 -0
  36. package/dist/components/editor/editor-methods/input-handling.js.map +1 -0
  37. package/dist/components/editor/editor-methods/paste-submit.d.ts +7 -0
  38. package/dist/components/editor/editor-methods/paste-submit.d.ts.map +1 -0
  39. package/dist/components/editor/editor-methods/paste-submit.js +105 -0
  40. package/dist/components/editor/editor-methods/paste-submit.js.map +1 -0
  41. package/dist/components/editor/editor-methods/render.d.ts +3 -0
  42. package/dist/components/editor/editor-methods/render.d.ts.map +1 -0
  43. package/dist/components/editor/editor-methods/render.js +114 -0
  44. package/dist/components/editor/editor-methods/render.js.map +1 -0
  45. package/dist/components/editor/editor-methods/text-insertion.d.ts +4 -0
  46. package/dist/components/editor/editor-methods/text-insertion.d.ts.map +1 -0
  47. package/dist/components/editor/editor-methods/text-insertion.js +91 -0
  48. package/dist/components/editor/editor-methods/text-insertion.js.map +1 -0
  49. package/dist/components/editor/editor-methods/text-layout.d.ts +15 -0
  50. package/dist/components/editor/editor-methods/text-layout.d.ts.map +1 -0
  51. package/dist/components/editor/editor-methods/text-layout.js +129 -0
  52. package/dist/components/editor/editor-methods/text-layout.js.map +1 -0
  53. package/dist/components/editor/editor-methods/vertical-movement.d.ts +8 -0
  54. package/dist/components/editor/editor-methods/vertical-movement.d.ts.map +1 -0
  55. package/dist/components/editor/editor-methods/vertical-movement.js +123 -0
  56. package/dist/components/editor/editor-methods/vertical-movement.js.map +1 -0
  57. package/dist/components/editor/editor-methods/word-operations.d.ts +19 -0
  58. package/dist/components/editor/editor-methods/word-operations.d.ts.map +1 -0
  59. package/dist/components/editor/editor-methods/word-operations.js +122 -0
  60. package/dist/components/editor/editor-methods/word-operations.js.map +1 -0
  61. package/dist/components/editor/editor-methods/yank-undo.d.ts +11 -0
  62. package/dist/components/editor/editor-methods/yank-undo.d.ts.map +1 -0
  63. package/dist/components/editor/editor-methods/yank-undo.js +132 -0
  64. package/dist/components/editor/editor-methods/yank-undo.js.map +1 -0
  65. package/dist/components/editor/editor.d.ts +67 -0
  66. package/dist/components/editor/editor.d.ts.map +1 -0
  67. package/dist/components/editor/editor.js +93 -0
  68. package/dist/components/editor/editor.js.map +1 -0
  69. package/dist/components/editor/helpers.d.ts +3 -0
  70. package/dist/components/editor/helpers.d.ts.map +1 -0
  71. package/dist/components/editor/helpers.js +3 -0
  72. package/dist/components/editor/helpers.js.map +1 -0
  73. package/dist/components/editor/index.d.ts +4 -0
  74. package/dist/components/editor/index.d.ts.map +1 -0
  75. package/dist/components/editor/index.js +3 -0
  76. package/dist/components/editor/index.js.map +1 -0
  77. package/dist/components/editor/paste-marker.d.ts +5 -0
  78. package/dist/components/editor/paste-marker.d.ts.map +1 -0
  79. package/dist/components/editor/paste-marker.js +134 -0
  80. package/dist/components/editor/paste-marker.js.map +1 -0
  81. package/dist/components/editor/trigger-patterns.d.ts +4 -0
  82. package/dist/components/editor/trigger-patterns.d.ts.map +1 -0
  83. package/dist/components/editor/trigger-patterns.js +11 -0
  84. package/dist/components/editor/trigger-patterns.js.map +1 -0
  85. package/dist/components/editor/types.d.ts +25 -0
  86. package/dist/components/editor/types.d.ts.map +1 -0
  87. package/dist/components/editor/types.js +2 -0
  88. package/dist/components/editor/types.js.map +1 -0
  89. package/dist/components/editor.d.ts +1 -253
  90. package/dist/components/editor.d.ts.map +1 -1
  91. package/dist/components/editor.js +1 -1915
  92. package/dist/components/editor.js.map +1 -1
  93. package/dist/components/image.d.ts.map +1 -1
  94. package/dist/components/image.js.map +1 -1
  95. package/dist/components/input/constants.d.ts +2 -0
  96. package/dist/components/input/constants.d.ts.map +1 -0
  97. package/dist/components/input/constants.js +3 -0
  98. package/dist/components/input/constants.js.map +1 -0
  99. package/dist/components/input/index.d.ts +2 -0
  100. package/dist/components/input/index.d.ts.map +1 -0
  101. package/dist/components/input/index.js +2 -0
  102. package/dist/components/input/index.js.map +1 -0
  103. package/dist/components/input/input-methods/input-handling.d.ts +3 -0
  104. package/dist/components/input/input-methods/input-handling.d.ts.map +1 -0
  105. package/dist/components/input/input-methods/input-handling.js +145 -0
  106. package/dist/components/input/input-methods/input-handling.js.map +1 -0
  107. package/dist/components/input/input-methods/render.d.ts +3 -0
  108. package/dist/components/input/input-methods/render.d.ts.map +1 -0
  109. package/dist/components/input/input-methods/render.js +62 -0
  110. package/dist/components/input/input-methods/render.js.map +1 -0
  111. package/dist/components/input/input-methods/text-editing.d.ts +17 -0
  112. package/dist/components/input/input-methods/text-editing.d.ts.map +1 -0
  113. package/dist/components/input/input-methods/text-editing.js +145 -0
  114. package/dist/components/input/input-methods/text-editing.js.map +1 -0
  115. package/dist/components/input/input-methods/value-access.d.ts +4 -0
  116. package/dist/components/input/input-methods/value-access.d.ts.map +1 -0
  117. package/dist/components/input/input-methods/value-access.js +20 -0
  118. package/dist/components/input/input-methods/value-access.js.map +1 -0
  119. package/dist/components/input/input.d.ts +37 -0
  120. package/dist/components/input/input.d.ts.map +1 -0
  121. package/dist/components/input/input.js +77 -0
  122. package/dist/components/input/input.js.map +1 -0
  123. package/dist/components/input/types.d.ts +5 -0
  124. package/dist/components/input/types.d.ts.map +1 -0
  125. package/dist/components/input/types.js +2 -0
  126. package/dist/components/input/types.js.map +1 -0
  127. package/dist/components/input.d.ts +1 -36
  128. package/dist/components/input.d.ts.map +1 -1
  129. package/dist/components/input.js +1 -377
  130. package/dist/components/input.js.map +1 -1
  131. package/dist/components/loader.d.ts.map +1 -1
  132. package/dist/components/loader.js.map +1 -1
  133. package/dist/components/markdown/constants.d.ts +4 -0
  134. package/dist/components/markdown/constants.d.ts.map +1 -0
  135. package/dist/components/markdown/constants.js +8 -0
  136. package/dist/components/markdown/constants.js.map +1 -0
  137. package/dist/components/markdown/index.d.ts +3 -0
  138. package/dist/components/markdown/index.d.ts.map +1 -0
  139. package/dist/components/markdown/index.js +2 -0
  140. package/dist/components/markdown/index.js.map +1 -0
  141. package/dist/components/markdown/markdown-methods/inline-rendering.d.ts +7 -0
  142. package/dist/components/markdown/markdown-methods/inline-rendering.d.ts.map +1 -0
  143. package/dist/components/markdown/markdown-methods/inline-rendering.js +95 -0
  144. package/dist/components/markdown/markdown-methods/inline-rendering.js.map +1 -0
  145. package/dist/components/markdown/markdown-methods/list-table-helpers.d.ts +7 -0
  146. package/dist/components/markdown/markdown-methods/list-table-helpers.d.ts.map +1 -0
  147. package/dist/components/markdown/markdown-methods/list-table-helpers.js +61 -0
  148. package/dist/components/markdown/markdown-methods/list-table-helpers.js.map +1 -0
  149. package/dist/components/markdown/markdown-methods/table-rendering.d.ts +5 -0
  150. package/dist/components/markdown/markdown-methods/table-rendering.d.ts.map +1 -0
  151. package/dist/components/markdown/markdown-methods/table-rendering.js +146 -0
  152. package/dist/components/markdown/markdown-methods/table-rendering.js.map +1 -0
  153. package/dist/components/markdown/markdown-methods/text-rendering.d.ts +6 -0
  154. package/dist/components/markdown/markdown-methods/text-rendering.d.ts.map +1 -0
  155. package/dist/components/markdown/markdown-methods/text-rendering.js +115 -0
  156. package/dist/components/markdown/markdown-methods/text-rendering.js.map +1 -0
  157. package/dist/components/markdown/markdown-methods/theming.d.ts +6 -0
  158. package/dist/components/markdown/markdown-methods/theming.d.ts.map +1 -0
  159. package/dist/components/markdown/markdown-methods/theming.js +41 -0
  160. package/dist/components/markdown/markdown-methods/theming.js.map +1 -0
  161. package/dist/components/markdown/markdown-methods/token-rendering.d.ts +5 -0
  162. package/dist/components/markdown/markdown-methods/token-rendering.d.ts.map +1 -0
  163. package/dist/components/markdown/markdown-methods/token-rendering.js +142 -0
  164. package/dist/components/markdown/markdown-methods/token-rendering.js.map +1 -0
  165. package/dist/components/markdown/markdown.d.ts +32 -0
  166. package/dist/components/markdown/markdown.d.ts.map +1 -0
  167. package/dist/components/markdown/markdown.js +72 -0
  168. package/dist/components/markdown/markdown.js.map +1 -0
  169. package/dist/components/markdown/strictstrikethroughtokenizer.d.ts +6 -0
  170. package/dist/components/markdown/strictstrikethroughtokenizer.d.ts.map +1 -0
  171. package/dist/components/markdown/strictstrikethroughtokenizer.js +18 -0
  172. package/dist/components/markdown/strictstrikethroughtokenizer.js.map +1 -0
  173. package/dist/components/markdown/types.d.ts +42 -0
  174. package/dist/components/markdown/types.d.ts.map +1 -0
  175. package/dist/components/markdown/types.js +2 -0
  176. package/dist/components/markdown/types.js.map +1 -0
  177. package/dist/components/markdown.d.ts +1 -96
  178. package/dist/components/markdown.d.ts.map +1 -1
  179. package/dist/components/markdown.js +1 -653
  180. package/dist/components/markdown.js.map +1 -1
  181. package/dist/components/select-list.d.ts.map +1 -1
  182. package/dist/components/select-list.js +8 -3
  183. package/dist/components/select-list.js.map +1 -1
  184. package/dist/components/settings-list.d.ts.map +1 -1
  185. package/dist/components/settings-list.js +2 -6
  186. package/dist/components/settings-list.js.map +1 -1
  187. package/dist/components/spacer.d.ts.map +1 -1
  188. package/dist/components/spacer.js.map +1 -1
  189. package/dist/components/text.d.ts.map +1 -1
  190. package/dist/components/text.js +2 -2
  191. package/dist/components/text.js.map +1 -1
  192. package/dist/components/truncated-text.d.ts.map +1 -1
  193. package/dist/components/truncated-text.js.map +1 -1
  194. package/dist/editor-component.d.ts.map +1 -1
  195. package/dist/editor-component.js.map +1 -1
  196. package/dist/fuzzy.d.ts.map +1 -1
  197. package/dist/fuzzy.js.map +1 -1
  198. package/dist/index.d.ts +1 -1
  199. package/dist/index.d.ts.map +1 -1
  200. package/dist/index.js +1 -1
  201. package/dist/index.js.map +1 -1
  202. package/dist/keybindings.d.ts.map +1 -1
  203. package/dist/keybindings.js.map +1 -1
  204. package/dist/keys.d.ts.map +1 -1
  205. package/dist/keys.js +145 -14
  206. package/dist/keys.js.map +1 -1
  207. package/dist/kill-ring.d.ts.map +1 -1
  208. package/dist/kill-ring.js.map +1 -1
  209. package/dist/native-modifiers.d.ts +9 -0
  210. package/dist/native-modifiers.d.ts.map +1 -1
  211. package/dist/native-modifiers.js +5 -0
  212. package/dist/native-modifiers.js.map +1 -1
  213. package/dist/stdin-buffer.d.ts +3 -0
  214. package/dist/stdin-buffer.d.ts.map +1 -1
  215. package/dist/stdin-buffer.js +24 -21
  216. package/dist/stdin-buffer.js.map +1 -1
  217. package/dist/terminal/constants.d.ts +9 -0
  218. package/dist/terminal/constants.d.ts.map +1 -0
  219. package/dist/terminal/constants.js +10 -0
  220. package/dist/terminal/constants.js.map +1 -0
  221. package/dist/terminal/helpers.d.ts +6 -0
  222. package/dist/terminal/helpers.d.ts.map +1 -0
  223. package/dist/terminal/helpers.js +23 -0
  224. package/dist/terminal/helpers.js.map +1 -0
  225. package/dist/terminal/index.d.ts +4 -0
  226. package/dist/terminal/index.d.ts.map +1 -0
  227. package/dist/terminal/index.js +3 -0
  228. package/dist/terminal/index.js.map +1 -0
  229. package/dist/terminal/processterminal-methods/cursor-screen.d.ts +11 -0
  230. package/dist/terminal/processterminal-methods/cursor-screen.d.ts.map +1 -0
  231. package/dist/terminal/processterminal-methods/cursor-screen.js +50 -0
  232. package/dist/terminal/processterminal-methods/cursor-screen.js.map +1 -0
  233. package/dist/terminal/processterminal-methods/keyboard-protocol.d.ts +14 -0
  234. package/dist/terminal/processterminal-methods/keyboard-protocol.d.ts.map +1 -0
  235. package/dist/terminal/processterminal-methods/keyboard-protocol.js +147 -0
  236. package/dist/terminal/processterminal-methods/keyboard-protocol.js.map +1 -0
  237. package/dist/terminal/processterminal-methods/terminal-io.d.ts +9 -0
  238. package/dist/terminal/processterminal-methods/terminal-io.d.ts.map +1 -0
  239. package/dist/terminal/processterminal-methods/terminal-io.js +153 -0
  240. package/dist/terminal/processterminal-methods/terminal-io.js.map +1 -0
  241. package/dist/terminal/processterminal.d.ts +49 -0
  242. package/dist/terminal/processterminal.d.ts.map +1 -0
  243. package/dist/terminal/processterminal.js +129 -0
  244. package/dist/terminal/processterminal.js.map +1 -0
  245. package/dist/terminal/types.d.ts +31 -0
  246. package/dist/terminal/types.d.ts.map +1 -0
  247. package/dist/terminal/types.js +2 -0
  248. package/dist/terminal/types.js.map +1 -0
  249. package/dist/terminal-colors.d.ts +2 -0
  250. package/dist/terminal-colors.d.ts.map +1 -1
  251. package/dist/terminal-colors.js +17 -5
  252. package/dist/terminal-colors.js.map +1 -1
  253. package/dist/terminal-image.d.ts.map +1 -1
  254. package/dist/terminal-image.js.map +1 -1
  255. package/dist/terminal.d.ts +1 -109
  256. package/dist/terminal.d.ts.map +1 -1
  257. package/dist/terminal.js +1 -432
  258. package/dist/terminal.js.map +1 -1
  259. package/dist/tui/constants.d.ts +3 -0
  260. package/dist/tui/constants.d.ts.map +1 -0
  261. package/dist/tui/constants.js +3 -0
  262. package/dist/tui/constants.js.map +1 -0
  263. package/dist/tui/container.d.ts +10 -0
  264. package/dist/tui/container.d.ts.map +1 -0
  265. package/dist/tui/container.js +31 -0
  266. package/dist/tui/container.js.map +1 -0
  267. package/dist/tui/helpers.d.ts +8 -0
  268. package/dist/tui/helpers.d.ts.map +1 -0
  269. package/dist/tui/helpers.js +53 -0
  270. package/dist/tui/helpers.js.map +1 -0
  271. package/dist/tui/index.d.ts +6 -0
  272. package/dist/tui/index.d.ts.map +1 -0
  273. package/dist/tui/index.js +5 -0
  274. package/dist/tui/index.js.map +1 -0
  275. package/dist/tui/tui-methods/configuration.d.ts +20 -0
  276. package/dist/tui/tui-methods/configuration.d.ts.map +1 -0
  277. package/dist/tui/tui-methods/configuration.js +131 -0
  278. package/dist/tui/tui-methods/configuration.js.map +1 -0
  279. package/dist/tui/tui-methods/cursor-background.d.ts +10 -0
  280. package/dist/tui/tui-methods/cursor-background.d.ts.map +1 -0
  281. package/dist/tui/tui-methods/cursor-background.js +52 -0
  282. package/dist/tui/tui-methods/cursor-background.js.map +1 -0
  283. package/dist/tui/tui-methods/incremental-render.d.ts +17 -0
  284. package/dist/tui/tui-methods/incremental-render.d.ts.map +1 -0
  285. package/dist/tui/tui-methods/incremental-render.js +259 -0
  286. package/dist/tui/tui-methods/incremental-render.js.map +1 -0
  287. package/dist/tui/tui-methods/input-handling.d.ts +5 -0
  288. package/dist/tui/tui-methods/input-handling.d.ts.map +1 -0
  289. package/dist/tui/tui-methods/input-handling.js +111 -0
  290. package/dist/tui/tui-methods/input-handling.js.map +1 -0
  291. package/dist/tui/tui-methods/line-compositing.d.ts +7 -0
  292. package/dist/tui/tui-methods/line-compositing.d.ts.map +1 -0
  293. package/dist/tui/tui-methods/line-compositing.js +61 -0
  294. package/dist/tui/tui-methods/line-compositing.js.map +1 -0
  295. package/dist/tui/tui-methods/overlay-compositing.d.ts +12 -0
  296. package/dist/tui/tui-methods/overlay-compositing.d.ts.map +1 -0
  297. package/dist/tui/tui-methods/overlay-compositing.js +123 -0
  298. package/dist/tui/tui-methods/overlay-compositing.js.map +1 -0
  299. package/dist/tui/tui-methods/overlay-layout.d.ts +11 -0
  300. package/dist/tui/tui-methods/overlay-layout.d.ts.map +1 -0
  301. package/dist/tui/tui-methods/overlay-layout.js +124 -0
  302. package/dist/tui/tui-methods/overlay-layout.js.map +1 -0
  303. package/dist/tui/tui-methods/overlay-management.d.ts +11 -0
  304. package/dist/tui/tui-methods/overlay-management.d.ts.map +1 -0
  305. package/dist/tui/tui-methods/overlay-management.js +152 -0
  306. package/dist/tui/tui-methods/overlay-management.js.map +1 -0
  307. package/dist/tui/tui-methods/render-pipeline.d.ts +3 -0
  308. package/dist/tui/tui-methods/render-pipeline.d.ts.map +1 -0
  309. package/dist/tui/tui-methods/render-pipeline.js +176 -0
  310. package/dist/tui/tui-methods/render-pipeline.js.map +1 -0
  311. package/dist/tui/tui-methods/render-width-error.d.ts +3 -0
  312. package/dist/tui/tui-methods/render-width-error.d.ts.map +1 -0
  313. package/dist/tui/tui-methods/render-width-error.js +28 -0
  314. package/dist/tui/tui-methods/render-width-error.js.map +1 -0
  315. package/dist/tui/tui-methods/terminal-control.d.ts +8 -0
  316. package/dist/tui/tui-methods/terminal-control.d.ts.map +1 -0
  317. package/dist/tui/tui-methods/terminal-control.js +101 -0
  318. package/dist/tui/tui-methods/terminal-control.js.map +1 -0
  319. package/dist/tui/tui.d.ts +59 -0
  320. package/dist/tui/tui.d.ts.map +1 -0
  321. package/dist/tui/tui.js +78 -0
  322. package/dist/tui/tui.js.map +1 -0
  323. package/dist/tui/types.d.ts +124 -0
  324. package/dist/tui/types.d.ts.map +1 -0
  325. package/dist/tui/types.js +2 -0
  326. package/dist/tui/types.js.map +1 -0
  327. package/dist/tui.d.ts +1 -254
  328. package/dist/tui.d.ts.map +1 -1
  329. package/dist/tui.js +1 -1344
  330. package/dist/tui.js.map +1 -1
  331. package/dist/undo-stack.d.ts.map +1 -1
  332. package/dist/undo-stack.js.map +1 -1
  333. package/dist/utils/ansi-wrapping.d.ts +5 -0
  334. package/dist/utils/ansi-wrapping.d.ts.map +1 -0
  335. package/dist/utils/ansi-wrapping.js +52 -0
  336. package/dist/utils/ansi-wrapping.js.map +1 -0
  337. package/dist/utils/ansicodetracker.d.ts +27 -0
  338. package/dist/utils/ansicodetracker.d.ts.map +1 -0
  339. package/dist/utils/ansicodetracker.js +222 -0
  340. package/dist/utils/ansicodetracker.js.map +1 -0
  341. package/dist/utils/column-slicing.d.ts +12 -0
  342. package/dist/utils/column-slicing.d.ts.map +1 -0
  343. package/dist/utils/column-slicing.js +111 -0
  344. package/dist/utils/column-slicing.js.map +1 -0
  345. package/dist/utils/column-truncation.d.ts +2 -0
  346. package/dist/utils/column-truncation.d.ts.map +1 -0
  347. package/dist/utils/column-truncation.js +129 -0
  348. package/dist/utils/column-truncation.js.map +1 -0
  349. package/dist/utils/constants.d.ts +12 -0
  350. package/dist/utils/constants.d.ts.map +1 -0
  351. package/dist/utils/constants.js +12 -0
  352. package/dist/utils/constants.js.map +1 -0
  353. package/dist/utils/index.d.ts +8 -0
  354. package/dist/utils/index.d.ts.map +1 -0
  355. package/dist/utils/index.js +8 -0
  356. package/dist/utils/index.js.map +1 -0
  357. package/dist/utils/install-delegated-methods.d.ts +5 -0
  358. package/dist/utils/install-delegated-methods.d.ts.map +1 -0
  359. package/dist/utils/install-delegated-methods.js +27 -0
  360. package/dist/utils/install-delegated-methods.js.map +1 -0
  361. package/dist/utils/segmentation.d.ts +10 -0
  362. package/dist/utils/segmentation.d.ts.map +1 -0
  363. package/dist/utils/segmentation.js +111 -0
  364. package/dist/utils/segmentation.js.map +1 -0
  365. package/dist/utils/terminal-output.d.ts +10 -0
  366. package/dist/utils/terminal-output.d.ts.map +1 -0
  367. package/dist/utils/terminal-output.js +122 -0
  368. package/dist/utils/terminal-output.js.map +1 -0
  369. package/dist/utils/types.d.ts +7 -0
  370. package/dist/utils/types.d.ts.map +1 -0
  371. package/dist/utils/types.js +2 -0
  372. package/dist/utils/types.js.map +1 -0
  373. package/dist/utils/width-truncation.d.ts +6 -0
  374. package/dist/utils/width-truncation.d.ts.map +1 -0
  375. package/dist/utils/width-truncation.js +121 -0
  376. package/dist/utils/width-truncation.js.map +1 -0
  377. package/dist/utils/word-wrapping.d.ts +4 -0
  378. package/dist/utils/word-wrapping.d.ts.map +1 -0
  379. package/dist/utils/word-wrapping.js +139 -0
  380. package/dist/utils/word-wrapping.js.map +1 -0
  381. package/dist/utils.d.ts +1 -84
  382. package/dist/utils.d.ts.map +1 -1
  383. package/dist/utils.js +1 -1059
  384. package/dist/utils.js.map +1 -1
  385. package/dist/word-navigation.d.ts.map +1 -1
  386. package/dist/word-navigation.js.map +1 -1
  387. package/package.json +2 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/components/markdown/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC;AAEjF,MAAM,CAAC,MAAM,0BAA0B,GAAG,8DAA8D,CAAC;AAEzG,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,MAAM,EAAE,CAAC;AAC3C,cAAc,CAAC,UAAU,CAAC;IACxB,SAAS,EAAE,IAAI,4BAA4B,EAAE;CAC9C,CAAC,CAAC","sourcesContent":["import { Marked } from \"marked\";\nimport { StrictStrikethroughTokenizer } from \"./strictstrikethroughtokenizer.ts\";\n\nexport const STRICT_STRIKETHROUGH_REGEX = /^(~~)(?=[^\\s~])((?:\\\\.|[^\\\\])*?(?:\\\\.|[^\\s~\\\\]))\\1(?=[^~]|$)/;\n\nexport const markdownParser = new Marked();\nmarkdownParser.setOptions({\n tokenizer: new StrictStrikethroughTokenizer(),\n});\n"]}
@@ -0,0 +1,3 @@
1
+ export { Markdown } from "./markdown.ts";
2
+ export type { DefaultTextStyle, MarkdownOptions, MarkdownTheme } from "./types.ts";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/markdown/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC","sourcesContent":["export { Markdown } from \"./markdown.ts\";\nexport type { DefaultTextStyle, MarkdownOptions, MarkdownTheme } from \"./types.ts\";\n"]}
@@ -0,0 +1,2 @@
1
+ export { Markdown } from "./markdown.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/markdown/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC","sourcesContent":["export { Markdown } from \"./markdown.ts\";\nexport type { DefaultTextStyle, MarkdownOptions, MarkdownTheme } from \"./types.ts\";\n"]}
@@ -0,0 +1,7 @@
1
+ import type { Token, Tokens } from "marked";
2
+ import type { Markdown } from "../markdown.ts";
3
+ import type { InlineStyleContext } from "../types.ts";
4
+ export declare function do_renderInlineTokens(self: Markdown, tokens: Token[], styleContext?: InlineStyleContext): string;
5
+ export declare function do_getOrderedListMarker(_self: Markdown, item: Tokens.ListItem): string | undefined;
6
+ export declare function do_getUnorderedListMarker(_self: Markdown, item: Tokens.ListItem): string | undefined;
7
+ //# sourceMappingURL=inline-rendering.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inline-rendering.d.ts","sourceRoot":"","sources":["../../../../src/components/markdown/markdown-methods/inline-rendering.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,YAAY,CAAC,EAAE,kBAAkB,GAAG,MAAM,CA6FhH;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,CAAC,QAAQ,GAAG,MAAM,GAAG,SAAS,CAGlG;AAED,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,CAAC,QAAQ,GAAG,MAAM,GAAG,SAAS,CAGpG","sourcesContent":["import type { Token, Tokens } from \"marked\";\nimport { getCapabilities, hyperlink } from \"../../../terminal-image.ts\";\nimport type { Markdown } from \"../markdown.ts\";\nimport type { InlineStyleContext } from \"../types.ts\";\n\nexport function do_renderInlineTokens(self: Markdown, tokens: Token[], styleContext?: InlineStyleContext): string {\n let result = \"\";\n const resolvedStyleContext = styleContext ?? self.getDefaultInlineStyleContext();\n const { applyText, stylePrefix } = resolvedStyleContext;\n const applyTextWithNewlines = (text: string): string => {\n const segments: string[] = text.split(\"\\n\");\n return segments.map((segment: string) => applyText(segment)).join(\"\\n\");\n };\n\n for (const token of tokens) {\n switch (token.type) {\n case \"text\":\n // Text tokens in list items can have nested tokens for inline formatting\n if (token.tokens && token.tokens.length > 0) {\n result += self.renderInlineTokens(token.tokens, resolvedStyleContext);\n } else {\n result += applyTextWithNewlines(token.text);\n }\n break;\n\n case \"paragraph\":\n // Paragraph tokens contain nested inline tokens\n result += self.renderInlineTokens(token.tokens || [], resolvedStyleContext);\n break;\n\n case \"strong\": {\n const boldContent = self.renderInlineTokens(token.tokens || [], resolvedStyleContext);\n result += self.theme.bold(boldContent) + stylePrefix;\n break;\n }\n\n case \"em\": {\n const italicContent = self.renderInlineTokens(token.tokens || [], resolvedStyleContext);\n result += self.theme.italic(italicContent) + stylePrefix;\n break;\n }\n\n case \"codespan\":\n result += self.theme.code(token.text) + stylePrefix;\n break;\n\n case \"link\": {\n const linkText = self.renderInlineTokens(token.tokens || [], resolvedStyleContext);\n const styledLink = self.theme.link(self.theme.underline(linkText));\n if (getCapabilities().hyperlinks) {\n // OSC 8: render as a clickable hyperlink. The URL is not printed inline,\n // so we always show only the link text regardless of whether it matches href.\n result += hyperlink(styledLink, token.href) + stylePrefix;\n } else {\n // Fallback: print URL in parentheses when text differs from href.\n // Compare raw token.text (not styled) against href for the equality check.\n // For mailto: links strip the prefix (autolinked emails use text=\"foo@bar.com\"\n // but href=\"mailto:foo@bar.com\").\n const hrefForComparison = token.href.startsWith(\"mailto:\") ? token.href.slice(7) : token.href;\n if (token.text === token.href || token.text === hrefForComparison) {\n result += styledLink + stylePrefix;\n } else {\n result += styledLink + self.theme.linkUrl(` (${token.href})`) + stylePrefix;\n }\n }\n break;\n }\n\n case \"br\":\n result += \"\\n\";\n break;\n\n case \"del\": {\n const delContent = self.renderInlineTokens(token.tokens || [], resolvedStyleContext);\n result += self.theme.strikethrough(delContent) + stylePrefix;\n break;\n }\n\n case \"html\":\n // Render inline HTML as plain text\n if (\"raw\" in token && typeof token.raw === \"string\") {\n result += applyTextWithNewlines(token.raw);\n }\n break;\n\n default:\n // Handle any other inline token types as plain text\n if (\"text\" in token && typeof token.text === \"string\") {\n result += applyTextWithNewlines(token.text);\n }\n }\n }\n\n while (stylePrefix && result.endsWith(stylePrefix)) {\n result = result.slice(0, -stylePrefix.length);\n }\n\n return result;\n}\n\nexport function do_getOrderedListMarker(_self: Markdown, item: Tokens.ListItem): string | undefined {\n const match = /^(?: {0,3})(\\d{1,9}[.)])[ \\t]+/.exec(item.raw);\n return match ? `${match[1]} ` : undefined;\n}\n\nexport function do_getUnorderedListMarker(_self: Markdown, item: Tokens.ListItem): string | undefined {\n const match = /^(?: {0,3})([-+*])(?:[ \\t]+|(?=\\r?\\n|$))/.exec(item.raw);\n return match ? `${match[1]} ` : undefined;\n}\n"]}
@@ -0,0 +1,95 @@
1
+ import { getCapabilities, hyperlink } from "../../../terminal-image.js";
2
+ export function do_renderInlineTokens(self, tokens, styleContext) {
3
+ let result = "";
4
+ const resolvedStyleContext = styleContext ?? self.getDefaultInlineStyleContext();
5
+ const { applyText, stylePrefix } = resolvedStyleContext;
6
+ const applyTextWithNewlines = (text) => {
7
+ const segments = text.split("\n");
8
+ return segments.map((segment) => applyText(segment)).join("\n");
9
+ };
10
+ for (const token of tokens) {
11
+ switch (token.type) {
12
+ case "text":
13
+ // Text tokens in list items can have nested tokens for inline formatting
14
+ if (token.tokens && token.tokens.length > 0) {
15
+ result += self.renderInlineTokens(token.tokens, resolvedStyleContext);
16
+ }
17
+ else {
18
+ result += applyTextWithNewlines(token.text);
19
+ }
20
+ break;
21
+ case "paragraph":
22
+ // Paragraph tokens contain nested inline tokens
23
+ result += self.renderInlineTokens(token.tokens || [], resolvedStyleContext);
24
+ break;
25
+ case "strong": {
26
+ const boldContent = self.renderInlineTokens(token.tokens || [], resolvedStyleContext);
27
+ result += self.theme.bold(boldContent) + stylePrefix;
28
+ break;
29
+ }
30
+ case "em": {
31
+ const italicContent = self.renderInlineTokens(token.tokens || [], resolvedStyleContext);
32
+ result += self.theme.italic(italicContent) + stylePrefix;
33
+ break;
34
+ }
35
+ case "codespan":
36
+ result += self.theme.code(token.text) + stylePrefix;
37
+ break;
38
+ case "link": {
39
+ const linkText = self.renderInlineTokens(token.tokens || [], resolvedStyleContext);
40
+ const styledLink = self.theme.link(self.theme.underline(linkText));
41
+ if (getCapabilities().hyperlinks) {
42
+ // OSC 8: render as a clickable hyperlink. The URL is not printed inline,
43
+ // so we always show only the link text regardless of whether it matches href.
44
+ result += hyperlink(styledLink, token.href) + stylePrefix;
45
+ }
46
+ else {
47
+ // Fallback: print URL in parentheses when text differs from href.
48
+ // Compare raw token.text (not styled) against href for the equality check.
49
+ // For mailto: links strip the prefix (autolinked emails use text="foo@bar.com"
50
+ // but href="mailto:foo@bar.com").
51
+ const hrefForComparison = token.href.startsWith("mailto:") ? token.href.slice(7) : token.href;
52
+ if (token.text === token.href || token.text === hrefForComparison) {
53
+ result += styledLink + stylePrefix;
54
+ }
55
+ else {
56
+ result += styledLink + self.theme.linkUrl(` (${token.href})`) + stylePrefix;
57
+ }
58
+ }
59
+ break;
60
+ }
61
+ case "br":
62
+ result += "\n";
63
+ break;
64
+ case "del": {
65
+ const delContent = self.renderInlineTokens(token.tokens || [], resolvedStyleContext);
66
+ result += self.theme.strikethrough(delContent) + stylePrefix;
67
+ break;
68
+ }
69
+ case "html":
70
+ // Render inline HTML as plain text
71
+ if ("raw" in token && typeof token.raw === "string") {
72
+ result += applyTextWithNewlines(token.raw);
73
+ }
74
+ break;
75
+ default:
76
+ // Handle any other inline token types as plain text
77
+ if ("text" in token && typeof token.text === "string") {
78
+ result += applyTextWithNewlines(token.text);
79
+ }
80
+ }
81
+ }
82
+ while (stylePrefix && result.endsWith(stylePrefix)) {
83
+ result = result.slice(0, -stylePrefix.length);
84
+ }
85
+ return result;
86
+ }
87
+ export function do_getOrderedListMarker(_self, item) {
88
+ const match = /^(?: {0,3})(\d{1,9}[.)])[ \t]+/.exec(item.raw);
89
+ return match ? `${match[1]} ` : undefined;
90
+ }
91
+ export function do_getUnorderedListMarker(_self, item) {
92
+ const match = /^(?: {0,3})([-+*])(?:[ \t]+|(?=\r?\n|$))/.exec(item.raw);
93
+ return match ? `${match[1]} ` : undefined;
94
+ }
95
+ //# sourceMappingURL=inline-rendering.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inline-rendering.js","sourceRoot":"","sources":["../../../../src/components/markdown/markdown-methods/inline-rendering.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAIxE,MAAM,UAAU,qBAAqB,CAAC,IAAc,EAAE,MAAe,EAAE,YAAiC,EAAU;IAChH,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,MAAM,oBAAoB,GAAG,YAAY,IAAI,IAAI,CAAC,4BAA4B,EAAE,CAAC;IACjF,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,GAAG,oBAAoB,CAAC;IACxD,MAAM,qBAAqB,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC;QACtD,MAAM,QAAQ,GAAa,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC5C,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAe,EAAE,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAAA,CACzE,CAAC;IAEF,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;YACnB,KAAK,MAAM;gBACT,yEAAyE;gBACzE,IAAI,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBAC5C,MAAM,IAAI,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;gBACxE,CAAC;qBAAM,CAAC;oBACN,MAAM,IAAI,qBAAqB,CAAC,KAAK,CAAC,I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Q,EAAE,CAAC;oBACtD,MAAM,IAAI,qBAAqB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBAC9C,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO,WAAW,IAAI,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;QACnD,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAChD,CAAC;IAED,OAAO,MAAM,CAAC;AAAA,CACf;AAED,MAAM,UAAU,uBAAuB,CAAC,KAAe,EAAE,IAAqB,EAAsB;IAClG,MAAM,KAAK,GAAG,gCAAgC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC9D,OAAO,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC;AAAA,CAC3C;AAED,MAAM,UAAU,yBAAyB,CAAC,KAAe,EAAE,IAAqB,EAAsB;IACpG,MAAM,KAAK,GAAG,0CAA0C,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACxE,OAAO,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC;AAAA,CAC3C","sourcesContent":["import type { Token, Tokens } from \"marked\";\nimport { getCapabilities, hyperlink } from \"../../../terminal-image.ts\";\nimport type { Markdown } from \"../markdown.ts\";\nimport type { InlineStyleContext } from \"../types.ts\";\n\nexport function do_renderInlineTokens(self: Markdown, tokens: Token[], styleContext?: InlineStyleContext): string {\n let result = \"\";\n const resolvedStyleContext = styleContext ?? self.getDefaultInlineStyleContext();\n const { applyText, stylePrefix } = resolvedStyleContext;\n const applyTextWithNewlines = (text: string): string => {\n const segments: string[] = text.split(\"\\n\");\n return segments.map((segment: string) => applyText(segment)).join(\"\\n\");\n };\n\n for (const token of tokens) {\n switch (token.type) {\n case \"text\":\n // Text tokens in list items can have nested tokens for inline formatting\n if (token.tokens && token.tokens.length > 0) {\n result += self.renderInlineTokens(token.tokens, resolvedStyleContext);\n } else {\n result += applyTextWithNewlines(token.text);\n }\n break;\n\n case \"paragraph\":\n // Paragraph tokens contain nested inline tokens\n result += self.renderInlineTokens(token.tokens || [], resolvedStyleContext);\n break;\n\n case \"strong\": {\n const boldContent = self.renderInlineTokens(token.tokens || [], resolvedStyleContext);\n result += self.theme.bold(boldContent) + stylePrefix;\n break;\n }\n\n case \"em\": {\n const italicContent = self.renderInlineTokens(token.tokens || [], resolvedStyleContext);\n result += self.theme.italic(italicContent) + stylePrefix;\n break;\n }\n\n case \"codespan\":\n result += self.theme.code(token.text) + stylePrefix;\n break;\n\n case \"link\": {\n const linkText = self.renderInlineTokens(token.tokens || [], resolvedStyleContext);\n const styledLink = self.theme.link(self.theme.underline(linkText));\n if (getCapabilities().hyperlinks) {\n // OSC 8: render as a clickable hyperlink. The URL is not printed inline,\n // so we always show only the link text regardless of whether it matches href.\n result += hyperlink(styledLink, token.href) + stylePrefix;\n } else {\n // Fallback: print URL in parentheses when text differs from href.\n // Compare raw token.text (not styled) against href for the equality check.\n // For mailto: links strip the prefix (autolinked emails use text=\"foo@bar.com\"\n // but href=\"mailto:foo@bar.com\").\n const hrefForComparison = token.href.startsWith(\"mailto:\") ? token.href.slice(7) : token.href;\n if (token.text === token.href || token.text === hrefForComparison) {\n result += styledLink + stylePrefix;\n } else {\n result += styledLink + self.theme.linkUrl(` (${token.href})`) + stylePrefix;\n }\n }\n break;\n }\n\n case \"br\":\n result += \"\\n\";\n break;\n\n case \"del\": {\n const delContent = self.renderInlineTokens(token.tokens || [], resolvedStyleContext);\n result += self.theme.strikethrough(delContent) + stylePrefix;\n break;\n }\n\n case \"html\":\n // Render inline HTML as plain text\n if (\"raw\" in token && typeof token.raw === \"string\") {\n result += applyTextWithNewlines(token.raw);\n }\n break;\n\n default:\n // Handle any other inline token types as plain text\n if (\"text\" in token && typeof token.text === \"string\") {\n result += applyTextWithNewlines(token.text);\n }\n }\n }\n\n while (stylePrefix && result.endsWith(stylePrefix)) {\n result = result.slice(0, -stylePrefix.length);\n }\n\n return result;\n}\n\nexport function do_getOrderedListMarker(_self: Markdown, item: Tokens.ListItem): string | undefined {\n const match = /^(?: {0,3})(\\d{1,9}[.)])[ \\t]+/.exec(item.raw);\n return match ? `${match[1]} ` : undefined;\n}\n\nexport function do_getUnorderedListMarker(_self: Markdown, item: Tokens.ListItem): string | undefined {\n const match = /^(?: {0,3})([-+*])(?:[ \\t]+|(?=\\r?\\n|$))/.exec(item.raw);\n return match ? `${match[1]} ` : undefined;\n}\n"]}
@@ -0,0 +1,7 @@
1
+ import type { Tokens } from "marked";
2
+ import type { Markdown } from "../markdown.ts";
3
+ import type { InlineStyleContext } from "../types.ts";
4
+ export declare function do_renderList(self: Markdown, token: Tokens.List, depth: number, width: number, styleContext?: InlineStyleContext): string[];
5
+ export declare function do_getLongestWordWidth(_self: Markdown, text: string, maxWidth?: number): number;
6
+ export declare function do_wrapCellText(_self: Markdown, text: string, maxWidth: number): string[];
7
+ //# sourceMappingURL=list-table-helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-table-helpers.d.ts","sourceRoot":"","sources":["../../../../src/components/markdown/markdown-methods/list-table-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD,wBAAgB,aAAa,CAC3B,IAAI,EAAE,QAAQ,EACd,KAAK,EAAE,MAAM,CAAC,IAAI,EAClB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,YAAY,CAAC,EAAE,kBAAkB,GAChC,MAAM,EAAE,CAkDV;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAU/F;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAEzF","sourcesContent":["import type { Tokens } from \"marked\";\nimport { visibleWidth, wrapTextWithAnsi } from \"../../../utils.ts\";\nimport type { Markdown } from \"../markdown.ts\";\nimport type { InlineStyleContext } from \"../types.ts\";\n\nexport function do_renderList(\n self: Markdown,\n token: Tokens.List,\n depth: number,\n width: number,\n styleContext?: InlineStyleContext,\n): string[] {\n const lines: string[] = [];\n const indent = \" \".repeat(depth);\n // Use the list's start property (defaults to 1 for ordered lists)\n const startNumber = typeof token.start === \"number\" ? token.start : 1;\n\n for (let i = 0; i < token.items.length; i++) {\n const item = token.items[i];\n const isLastItem = i === token.items.length - 1;\n const bullet = token.ordered\n ? self.options.preserveOrderedListMarkers\n ? (self.getOrderedListMarker(item) ?? `${startNumber + i}. `)\n : `${startNumber + i}. `\n : self.options.preserveOrderedListMarkers\n ? (self.getUnorderedListMarker(item) ?? \"- \")\n : \"- \";\n const taskMarker = item.task ? `[${item.checked ? \"x\" : \" \"}] ` : \"\";\n const marker = bullet + taskMarker;\n const firstPrefix = indent + self.theme.listBullet(marker);\n const continuationPrefix = indent + \" \".repeat(visibleWidth(marker));\n const itemWidth = Math.max(1, width - visibleWidth(firstPrefix));\n let renderedAnyLine = false;\n\n for (const itemToken of item.tokens) {\n if (itemToken.type === \"list\") {\n lines.push(...self.renderList(itemToken as Tokens.List, depth + 1, width, styleContext));\n renderedAnyLine = true;\n continue;\n }\n\n const itemLines = self.renderToken(itemToken, itemWidth, undefined, styleContext);\n for (const line of itemLines) {\n for (const wrappedLine of wrapTextWithAnsi(line, itemWidth)) {\n const linePrefix = renderedAnyLine ? continuationPrefix : firstPrefix;\n lines.push(linePrefix + wrappedLine);\n renderedAnyLine = true;\n }\n }\n }\n\n if (!renderedAnyLine) {\n lines.push(firstPrefix);\n }\n\n if (token.loose && !isLastItem) {\n lines.push(\"\");\n }\n }\n\n return lines;\n}\n\nexport function do_getLongestWordWidth(_self: Markdown, text: string, maxWidth?: number): number {\n const words = text.split(/\\s+/).filter((word) => word.length > 0);\n let longest = 0;\n for (const word of words) {\n longest = Math.max(longest, visibleWidth(word));\n }\n if (maxWidth === undefined) {\n return longest;\n }\n return Math.min(longest, maxWidth);\n}\n\nexport function do_wrapCellText(_self: Markdown, text: string, maxWidth: number): string[] {\n return wrapTextWithAnsi(text, Math.max(1, maxWidth));\n}\n"]}
@@ -0,0 +1,61 @@
1
+ import { visibleWidth, wrapTextWithAnsi } from "../../../utils.js";
2
+ export function do_renderList(self, token, depth, width, styleContext) {
3
+ const lines = [];
4
+ const indent = " ".repeat(depth);
5
+ // Use the list's start property (defaults to 1 for ordered lists)
6
+ const startNumber = typeof token.start === "number" ? token.start : 1;
7
+ for (let i = 0; i < token.items.length; i++) {
8
+ const item = token.items[i];
9
+ const isLastItem = i === token.items.length - 1;
10
+ const bullet = token.ordered
11
+ ? self.options.preserveOrderedListMarkers
12
+ ? (self.getOrderedListMarker(item) ?? `${startNumber + i}. `)
13
+ : `${startNumber + i}. `
14
+ : self.options.preserveOrderedListMarkers
15
+ ? (self.getUnorderedListMarker(item) ?? "- ")
16
+ : "- ";
17
+ const taskMarker = item.task ? `[${item.checked ? "x" : " "}] ` : "";
18
+ const marker = bullet + taskMarker;
19
+ const firstPrefix = indent + self.theme.listBullet(marker);
20
+ const continuationPrefix = indent + " ".repeat(visibleWidth(marker));
21
+ const itemWidth = Math.max(1, width - visibleWidth(firstPrefix));
22
+ let renderedAnyLine = false;
23
+ for (const itemToken of item.tokens) {
24
+ if (itemToken.type === "list") {
25
+ lines.push(...self.renderList(itemToken, depth + 1, width, styleContext));
26
+ renderedAnyLine = true;
27
+ continue;
28
+ }
29
+ const itemLines = self.renderToken(itemToken, itemWidth, undefined, styleContext);
30
+ for (const line of itemLines) {
31
+ for (const wrappedLine of wrapTextWithAnsi(line, itemWidth)) {
32
+ const linePrefix = renderedAnyLine ? continuationPrefix : firstPrefix;
33
+ lines.push(linePrefix + wrappedLine);
34
+ renderedAnyLine = true;
35
+ }
36
+ }
37
+ }
38
+ if (!renderedAnyLine) {
39
+ lines.push(firstPrefix);
40
+ }
41
+ if (token.loose && !isLastItem) {
42
+ lines.push("");
43
+ }
44
+ }
45
+ return lines;
46
+ }
47
+ export function do_getLongestWordWidth(_self, text, maxWidth) {
48
+ const words = text.split(/\s+/).filter((word) => word.length > 0);
49
+ let longest = 0;
50
+ for (const word of words) {
51
+ longest = Math.max(longest, visibleWidth(word));
52
+ }
53
+ if (maxWidth === undefined) {
54
+ return longest;
55
+ }
56
+ return Math.min(longest, maxWidth);
57
+ }
58
+ export function do_wrapCellText(_self, text, maxWidth) {
59
+ return wrapTextWithAnsi(text, Math.max(1, maxWidth));
60
+ }
61
+ //# sourceMappingURL=list-table-helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-table-helpers.js","sourceRoot":"","sources":["../../../../src/components/markdown/markdown-methods/list-table-helpers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAInE,MAAM,UAAU,aAAa,CAC3B,IAAc,EACd,KAAkB,EAClB,KAAa,EACb,KAAa,EACb,YAAiC,EACvB;IACV,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACpC,kEAAkE;IAClE,MAAM,WAAW,GAAG,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAEtE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE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;QACzB,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC;IAClD,CAAC;IACD,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;AAAA,CACpC;AAED,MAAM,UAAU,eAAe,CAAC,KAAe,EAAE,IAAY,EAAE,QAAgB,EAAY;IACzF,OAAO,gBAAgB,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC;AAAA,CACtD","sourcesContent":["import type { Tokens } from \"marked\";\nimport { visibleWidth, wrapTextWithAnsi } from \"../../../utils.ts\";\nimport type { Markdown } from \"../markdown.ts\";\nimport type { InlineStyleContext } from \"../types.ts\";\n\nexport function do_renderList(\n self: Markdown,\n token: Tokens.List,\n depth: number,\n width: number,\n styleContext?: InlineStyleContext,\n): string[] {\n const lines: string[] = [];\n const indent = \" \".repeat(depth);\n // Use the list's start property (defaults to 1 for ordered lists)\n const startNumber = typeof token.start === \"number\" ? token.start : 1;\n\n for (let i = 0; i < token.items.length; i++) {\n const item = token.items[i];\n const isLastItem = i === token.items.length - 1;\n const bullet = token.ordered\n ? self.options.preserveOrderedListMarkers\n ? (self.getOrderedListMarker(item) ?? `${startNumber + i}. `)\n : `${startNumber + i}. `\n : self.options.preserveOrderedListMarkers\n ? (self.getUnorderedListMarker(item) ?? \"- \")\n : \"- \";\n const taskMarker = item.task ? `[${item.checked ? \"x\" : \" \"}] ` : \"\";\n const marker = bullet + taskMarker;\n const firstPrefix = indent + self.theme.listBullet(marker);\n const continuationPrefix = indent + \" \".repeat(visibleWidth(marker));\n const itemWidth = Math.max(1, width - visibleWidth(firstPrefix));\n let renderedAnyLine = false;\n\n for (const itemToken of item.tokens) {\n if (itemToken.type === \"list\") {\n lines.push(...self.renderList(itemToken as Tokens.List, depth + 1, width, styleContext));\n renderedAnyLine = true;\n continue;\n }\n\n const itemLines = self.renderToken(itemToken, itemWidth, undefined, styleContext);\n for (const line of itemLines) {\n for (const wrappedLine of wrapTextWithAnsi(line, itemWidth)) {\n const linePrefix = renderedAnyLine ? continuationPrefix : firstPrefix;\n lines.push(linePrefix + wrappedLine);\n renderedAnyLine = true;\n }\n }\n }\n\n if (!renderedAnyLine) {\n lines.push(firstPrefix);\n }\n\n if (token.loose && !isLastItem) {\n lines.push(\"\");\n }\n }\n\n return lines;\n}\n\nexport function do_getLongestWordWidth(_self: Markdown, text: string, maxWidth?: number): number {\n const words = text.split(/\\s+/).filter((word) => word.length > 0);\n let longest = 0;\n for (const word of words) {\n longest = Math.max(longest, visibleWidth(word));\n }\n if (maxWidth === undefined) {\n return longest;\n }\n return Math.min(longest, maxWidth);\n}\n\nexport function do_wrapCellText(_self: Markdown, text: string, maxWidth: number): string[] {\n return wrapTextWithAnsi(text, Math.max(1, maxWidth));\n}\n"]}
@@ -0,0 +1,5 @@
1
+ import type { Tokens } from "marked";
2
+ import type { Markdown } from "../markdown.ts";
3
+ import type { InlineStyleContext } from "../types.ts";
4
+ export declare function do_renderTable(self: Markdown, token: Tokens.Table, availableWidth: number, nextTokenType?: string, styleContext?: InlineStyleContext): string[];
5
+ //# sourceMappingURL=table-rendering.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table-rendering.d.ts","sourceRoot":"","sources":["../../../../src/components/markdown/markdown-methods/table-rendering.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD,wBAAgB,cAAc,CAC5B,IAAI,EAAE,QAAQ,EACd,KAAK,EAAE,MAAM,CAAC,KAAK,EACnB,cAAc,EAAE,MAAM,EACtB,aAAa,CAAC,EAAE,MAAM,EACtB,YAAY,CAAC,EAAE,kBAAkB,GAChC,MAAM,EAAE,CAoKV","sourcesContent":["import type { Tokens } from \"marked\";\nimport { visibleWidth, wrapTextWithAnsi } from \"../../../utils.ts\";\nimport type { Markdown } from \"../markdown.ts\";\nimport type { InlineStyleContext } from \"../types.ts\";\n\nexport function do_renderTable(\n self: Markdown,\n token: Tokens.Table,\n availableWidth: number,\n nextTokenType?: string,\n styleContext?: InlineStyleContext,\n): string[] {\n const lines: string[] = [];\n const numCols = token.header.length;\n\n if (numCols === 0) {\n return lines;\n }\n\n // Calculate border overhead: \"│ \" + (n-1) * \" │ \" + \" │\"\n // = 2 + (n-1) * 3 + 2 = 3n + 1\n const borderOverhead = 3 * numCols + 1;\n const availableForCells = availableWidth - borderOverhead;\n if (availableForCells < numCols) {\n // Too narrow to render a stable table. Fall back to raw markdown.\n const fallbackLines = token.raw ? wrapTextWithAnsi(token.raw, availableWidth) : [];\n if (nextTokenType && nextTokenType !== \"space\") {\n fallbackLines.push(\"\");\n }\n return fallbackLines;\n }\n\n const maxUnbrokenWordWidth = 30;\n\n // Calculate natural column widths (what each column needs without constraints)\n const naturalWidths: number[] = [];\n const minWordWidths: number[] = [];\n for (let i = 0; i < numCols; i++) {\n const headerText = self.renderInlineTokens(token.header[i].tokens || [], styleContext);\n naturalWidths[i] = visibleWidth(headerText);\n minWordWidths[i] = Math.max(1, self.getLongestWordWidth(headerText, maxUnbrokenWordWidth));\n }\n for (const row of token.rows) {\n for (let i = 0; i < row.length; i++) {\n const cellText = self.renderInlineTokens(row[i].tokens || [], styleContext);\n naturalWidths[i] = Math.max(naturalWidths[i] || 0, visibleWidth(cellText));\n minWordWidths[i] = Math.max(minWordWidths[i] || 1, self.getLongestWordWidth(cellText, maxUnbrokenWordWidth));\n }\n }\n\n let minColumnWidths = minWordWidths;\n let minCellsWidth = minColumnWidths.reduce((a, b) => a + b, 0);\n\n if (minCellsWidth > availableForCells) {\n minColumnWidths = new Array(numCols).fill(1);\n const remaining = availableForCells - numCols;\n\n if (remaining > 0) {\n const totalWeight = minWordWidths.reduce((total, width) => total + Math.max(0, width - 1), 0);\n const growth = minWordWidths.map((width) => {\n const weight = Math.max(0, width - 1);\n return totalWeight > 0 ? Math.floor((weight / totalWeight) * remaining) : 0;\n });\n\n for (let i = 0; i < numCols; i++) {\n minColumnWidths[i] += growth[i] ?? 0;\n }\n\n const allocated = growth.reduce((total, width) => total + width, 0);\n let leftover = remaining - allocated;\n for (let i = 0; leftover > 0 && i < numCols; i++) {\n minColumnWidths[i]++;\n leftover--;\n }\n }\n\n minCellsWidth = minColumnWidths.reduce((a, b) => a + b, 0);\n }\n\n // Calculate column widths that fit within available width\n const totalNaturalWidth = naturalWidths.reduce((a, b) => a + b, 0) + borderOverhead;\n let columnWidths: number[];\n\n if (totalNaturalWidth <= availableWidth) {\n // Everything fits naturally\n columnWidths = naturalWidths.map((width, index) => Math.max(width, minColumnWidths[index]));\n } else {\n // Need to shrink columns to fit\n const totalGrowPotential = naturalWidths.reduce((total, width, index) => {\n return total + Math.max(0, width - minColumnWidths[index]);\n }, 0);\n const extraWidth = Math.max(0, availableForCells - minCellsWidth);\n columnWidths = minColumnWidths.map((minWidth, index) => {\n const naturalWidth = naturalWidths[index];\n const minWidthDelta = Math.max(0, naturalWidth - minWidth);\n let grow = 0;\n if (totalGrowPotential > 0) {\n grow = Math.floor((minWidthDelta / totalGrowPotential) * extraWidth);\n }\n return minWidth + grow;\n });\n\n // Adjust for rounding errors - distribute remaining space\n const allocated = columnWidths.reduce((a, b) => a + b, 0);\n let remaining = availableForCells - allocated;\n while (remaining > 0) {\n let grew = false;\n for (let i = 0; i < numCols && remaining > 0; i++) {\n if (columnWidths[i] < naturalWidths[i]) {\n columnWidths[i]++;\n remaining--;\n grew = true;\n }\n }\n if (!grew) {\n break;\n }\n }\n }\n\n // Render top border\n const topBorderCells = columnWidths.map((w) => \"─\".repeat(w));\n lines.push(`┌─${topBorderCells.join(\"─┬─\")}─┐`);\n\n // Render header with wrapping\n const headerCellLines: string[][] = token.header.map((cell, i) => {\n const text = self.renderInlineTokens(cell.tokens || [], styleContext);\n return self.wrapCellText(text, columnWidths[i]);\n });\n const headerLineCount = Math.max(...headerCellLines.map((c) => c.length));\n\n for (let lineIdx = 0; lineIdx < headerLineCount; lineIdx++) {\n const rowParts = headerCellLines.map((cellLines, colIdx) => {\n const text = cellLines[lineIdx] || \"\";\n const padded = text + \" \".repeat(Math.max(0, columnWidths[colIdx] - visibleWidth(text)));\n return self.theme.bold(padded);\n });\n lines.push(`│ ${rowParts.join(\" │ \")} │`);\n }\n\n // Render separator\n const separatorCells = columnWidths.map((w) => \"─\".repeat(w));\n const separatorLine = `├─${separatorCells.join(\"─┼─\")}─┤`;\n lines.push(separatorLine);\n\n // Render rows with wrapping\n for (let rowIndex = 0; rowIndex < token.rows.length; rowIndex++) {\n const row = token.rows[rowIndex];\n const rowCellLines: string[][] = row.map((cell, i) => {\n const text = self.renderInlineTokens(cell.tokens || [], styleContext);\n return self.wrapCellText(text, columnWidths[i]);\n });\n const rowLineCount = Math.max(...rowCellLines.map((c) => c.length));\n\n for (let lineIdx = 0; lineIdx < rowLineCount; lineIdx++) {\n const rowParts = rowCellLines.map((cellLines, colIdx) => {\n const text = cellLines[lineIdx] || \"\";\n return text + \" \".repeat(Math.max(0, columnWidths[colIdx] - visibleWidth(text)));\n });\n lines.push(`│ ${rowParts.join(\" │ \")} │`);\n }\n\n if (rowIndex < token.rows.length - 1) {\n lines.push(separatorLine);\n }\n }\n\n // Render bottom border\n const bottomBorderCells = columnWidths.map((w) => \"─\".repeat(w));\n lines.push(`└─${bottomBorderCells.join(\"─┴─\")}─┘`);\n\n if (nextTokenType && nextTokenType !== \"space\") {\n lines.push(\"\"); // Add spacing after table\n }\n return lines;\n}\n"]}
@@ -0,0 +1,146 @@
1
+ import { visibleWidth, wrapTextWithAnsi } from "../../../utils.js";
2
+ export function do_renderTable(self, token, availableWidth, nextTokenType, styleContext) {
3
+ const lines = [];
4
+ const numCols = token.header.length;
5
+ if (numCols === 0) {
6
+ return lines;
7
+ }
8
+ // Calculate border overhead: "│ " + (n-1) * " │ " + " │"
9
+ // = 2 + (n-1) * 3 + 2 = 3n + 1
10
+ const borderOverhead = 3 * numCols + 1;
11
+ const availableForCells = availableWidth - borderOverhead;
12
+ if (availableForCells < numCols) {
13
+ // Too narrow to render a stable table. Fall back to raw markdown.
14
+ const fallbackLines = token.raw ? wrapTextWithAnsi(token.raw, availableWidth) : [];
15
+ if (nextTokenType && nextTokenType !== "space") {
16
+ fallbackLines.push("");
17
+ }
18
+ return fallbackLines;
19
+ }
20
+ const maxUnbrokenWordWidth = 30;
21
+ // Calculate natural column widths (what each column needs without constraints)
22
+ const naturalWidths = [];
23
+ const minWordWidths = [];
24
+ for (let i = 0; i < numCols; i++) {
25
+ const headerText = self.renderInlineTokens(token.header[i].tokens || [], styleContext);
26
+ naturalWidths[i] = visibleWidth(headerText);
27
+ minWordWidths[i] = Math.max(1, self.getLongestWordWidth(headerText, maxUnbrokenWordWidth));
28
+ }
29
+ for (const row of token.rows) {
30
+ for (let i = 0; i < row.length; i++) {
31
+ const cellText = self.renderInlineTokens(row[i].tokens || [], styleContext);
32
+ naturalWidths[i] = Math.max(naturalWidths[i] || 0, visibleWidth(cellText));
33
+ minWordWidths[i] = Math.max(minWordWidths[i] || 1, self.getLongestWordWidth(cellText, maxUnbrokenWordWidth));
34
+ }
35
+ }
36
+ let minColumnWidths = minWordWidths;
37
+ let minCellsWidth = minColumnWidths.reduce((a, b) => a + b, 0);
38
+ if (minCellsWidth > availableForCells) {
39
+ minColumnWidths = new Array(numCols).fill(1);
40
+ const remaining = availableForCells - numCols;
41
+ if (remaining > 0) {
42
+ const totalWeight = minWordWidths.reduce((total, width) => total + Math.max(0, width - 1), 0);
43
+ const growth = minWordWidths.map((width) => {
44
+ const weight = Math.max(0, width - 1);
45
+ return totalWeight > 0 ? Math.floor((weight / totalWeight) * remaining) : 0;
46
+ });
47
+ for (let i = 0; i < numCols; i++) {
48
+ minColumnWidths[i] += growth[i] ?? 0;
49
+ }
50
+ const allocated = growth.reduce((total, width) => total + width, 0);
51
+ let leftover = remaining - allocated;
52
+ for (let i = 0; leftover > 0 && i < numCols; i++) {
53
+ minColumnWidths[i]++;
54
+ leftover--;
55
+ }
56
+ }
57
+ minCellsWidth = minColumnWidths.reduce((a, b) => a + b, 0);
58
+ }
59
+ // Calculate column widths that fit within available width
60
+ const totalNaturalWidth = naturalWidths.reduce((a, b) => a + b, 0) + borderOverhead;
61
+ let columnWidths;
62
+ if (totalNaturalWidth <= availableWidth) {
63
+ // Everything fits naturally
64
+ columnWidths = naturalWidths.map((width, index) => Math.max(width, minColumnWidths[index]));
65
+ }
66
+ else {
67
+ // Need to shrink columns to fit
68
+ const totalGrowPotential = naturalWidths.reduce((total, width, index) => {
69
+ return total + Math.max(0, width - minColumnWidths[index]);
70
+ }, 0);
71
+ const extraWidth = Math.max(0, availableForCells - minCellsWidth);
72
+ columnWidths = minColumnWidths.map((minWidth, index) => {
73
+ const naturalWidth = naturalWidths[index];
74
+ const minWidthDelta = Math.max(0, naturalWidth - minWidth);
75
+ let grow = 0;
76
+ if (totalGrowPotential > 0) {
77
+ grow = Math.floor((minWidthDelta / totalGrowPotential) * extraWidth);
78
+ }
79
+ return minWidth + grow;
80
+ });
81
+ // Adjust for rounding errors - distribute remaining space
82
+ const allocated = columnWidths.reduce((a, b) => a + b, 0);
83
+ let remaining = availableForCells - allocated;
84
+ while (remaining > 0) {
85
+ let grew = false;
86
+ for (let i = 0; i < numCols && remaining > 0; i++) {
87
+ if (columnWidths[i] < naturalWidths[i]) {
88
+ columnWidths[i]++;
89
+ remaining--;
90
+ grew = true;
91
+ }
92
+ }
93
+ if (!grew) {
94
+ break;
95
+ }
96
+ }
97
+ }
98
+ // Render top border
99
+ const topBorderCells = columnWidths.map((w) => "─".repeat(w));
100
+ lines.push(`┌─${topBorderCells.join("─┬─")}─┐`);
101
+ // Render header with wrapping
102
+ const headerCellLines = token.header.map((cell, i) => {
103
+ const text = self.renderInlineTokens(cell.tokens || [], styleContext);
104
+ return self.wrapCellText(text, columnWidths[i]);
105
+ });
106
+ const headerLineCount = Math.max(...headerCellLines.map((c) => c.length));
107
+ for (let lineIdx = 0; lineIdx < headerLineCount; lineIdx++) {
108
+ const rowParts = headerCellLines.map((cellLines, colIdx) => {
109
+ const text = cellLines[lineIdx] || "";
110
+ const padded = text + " ".repeat(Math.max(0, columnWidths[colIdx] - visibleWidth(text)));
111
+ return self.theme.bold(padded);
112
+ });
113
+ lines.push(`│ ${rowParts.join(" │ ")} │`);
114
+ }
115
+ // Render separator
116
+ const separatorCells = columnWidths.map((w) => "─".repeat(w));
117
+ const separatorLine = `├─${separatorCells.join("─┼─")}─┤`;
118
+ lines.push(separatorLine);
119
+ // Render rows with wrapping
120
+ for (let rowIndex = 0; rowIndex < token.rows.length; rowIndex++) {
121
+ const row = token.rows[rowIndex];
122
+ const rowCellLines = row.map((cell, i) => {
123
+ const text = self.renderInlineTokens(cell.tokens || [], styleContext);
124
+ return self.wrapCellText(text, columnWidths[i]);
125
+ });
126
+ const rowLineCount = Math.max(...rowCellLines.map((c) => c.length));
127
+ for (let lineIdx = 0; lineIdx < rowLineCount; lineIdx++) {
128
+ const rowParts = rowCellLines.map((cellLines, colIdx) => {
129
+ const text = cellLines[lineIdx] || "";
130
+ return text + " ".repeat(Math.max(0, columnWidths[colIdx] - visibleWidth(text)));
131
+ });
132
+ lines.push(`│ ${rowParts.join(" │ ")} │`);
133
+ }
134
+ if (rowIndex < token.rows.length - 1) {
135
+ lines.push(separatorLine);
136
+ }
137
+ }
138
+ // Render bottom border
139
+ const bottomBorderCells = columnWidths.map((w) => "─".repeat(w));
140
+ lines.push(`└─${bottomBorderCells.join("─┴─")}─┘`);
141
+ if (nextTokenType && nextTokenType !== "space") {
142
+ lines.push(""); // Add spacing after table
143
+ }
144
+ return lines;
145
+ }
146
+ //# sourceMappingURL=table-rendering.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table-rendering.js","sourceRoot":"","sources":["../../../../src/components/markdown/markdown-methods/table-rendering.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAInE,MAAM,UAAU,cAAc,CAC5B,IAAc,EACd,KAAmB,EACnB,cAAsB,EACtB,aAAsB,EACtB,YAAiC,EACvB;IACV,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC;IAEpC,IAAI,OAAO,KAAK,CAAC,EAAE,CAAC;QAClB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,+DAAyD;IACzD,+BAA+B;IAC/B,MAAM,cAAc,GAAG,CAAC,GAAG,OAAO,GAAG,CAAC,CAAC;IACvC,MAAM,iBAAiB,GAAG,cAAc,GAAG,cAAc,CAAC;IAC1D,IAAI,iBAAiB,GAAG,OAAO,EAAE,CAAC;QAChC,kEAAkE;QAClE,MAAM,aAAa,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,gBAAgB,CAAC,KAAK,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACnF,IAAI,aAAa,IAAI,aAAa,KAAK,OAAO,EAAE,CAAC;YAC/C,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACzB,CAAC;QACD,OAAO,aAAa,CAAC;IACvB,CAAC;IAED,MAAM,oBAAoB,GAAG,EAAE,CAAC;IAEhC,+EAA+E;IAC/E,MAAM,aAAa,GAAa,EAAE,CAAC;IACnC,MAAM,aAAa,GAAa,EAAE,CAAC;IACnC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,EAAE,CAAC,EAAE,EAAE,CAAC;QACjC,MAAM,UAAU,GAAG,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,MAAM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AC5B,CAAC;IACH,CAAC;IAED,uBAAuB;IACvB,MAAM,iBAAiB,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IACjE,KAAK,CAAC,IAAI,CAAC,SAAK,iBAAiB,CAAC,IAAI,CAAC,WAAK,CAAC,QAAI,CAAC,CAAC;IAEnD,IAAI,aAAa,IAAI,aAAa,KAAK,OAAO,EAAE,CAAC;QAC/C,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,0BAA0B;IAC5C,CAAC;IACD,OAAO,KAAK,CAAC;AAAA,CACd","sourcesContent":["import type { Tokens } from \"marked\";\nimport { visibleWidth, wrapTextWithAnsi } from \"../../../utils.ts\";\nimport type { Markdown } from \"../markdown.ts\";\nimport type { InlineStyleContext } from \"../types.ts\";\n\nexport function do_renderTable(\n self: Markdown,\n token: Tokens.Table,\n availableWidth: number,\n nextTokenType?: string,\n styleContext?: InlineStyleContext,\n): string[] {\n const lines: string[] = [];\n const numCols = token.header.length;\n\n if (numCols === 0) {\n return lines;\n }\n\n // Calculate border overhead: \"│ \" + (n-1) * \" │ \" + \" │\"\n // = 2 + (n-1) * 3 + 2 = 3n + 1\n const borderOverhead = 3 * numCols + 1;\n const availableForCells = availableWidth - borderOverhead;\n if (availableForCells < numCols) {\n // Too narrow to render a stable table. Fall back to raw markdown.\n const fallbackLines = token.raw ? wrapTextWithAnsi(token.raw, availableWidth) : [];\n if (nextTokenType && nextTokenType !== \"space\") {\n fallbackLines.push(\"\");\n }\n return fallbackLines;\n }\n\n const maxUnbrokenWordWidth = 30;\n\n // Calculate natural column widths (what each column needs without constraints)\n const naturalWidths: number[] = [];\n const minWordWidths: number[] = [];\n for (let i = 0; i < numCols; i++) {\n const headerText = self.renderInlineTokens(token.header[i].tokens || [], styleContext);\n naturalWidths[i] = visibleWidth(headerText);\n minWordWidths[i] = Math.max(1, self.getLongestWordWidth(headerText, maxUnbrokenWordWidth));\n }\n for (const row of token.rows) {\n for (let i = 0; i < row.length; i++) {\n const cellText = self.renderInlineTokens(row[i].tokens || [], styleContext);\n naturalWidths[i] = Math.max(naturalWidths[i] || 0, visibleWidth(cellText));\n minWordWidths[i] = Math.max(minWordWidths[i] || 1, self.getLongestWordWidth(cellText, maxUnbrokenWordWidth));\n }\n }\n\n let minColumnWidths = minWordWidths;\n let minCellsWidth = minColumnWidths.reduce((a, b) => a + b, 0);\n\n if (minCellsWidth > availableForCells) {\n minColumnWidths = new Array(numCols).fill(1);\n const remaining = availableForCells - numCols;\n\n if (remaining > 0) {\n const totalWeight = minWordWidths.reduce((total, width) => total + Math.max(0, width - 1), 0);\n const growth = minWordWidths.map((width) => {\n const weight = Math.max(0, width - 1);\n return totalWeight > 0 ? Math.floor((weight / totalWeight) * remaining) : 0;\n });\n\n for (let i = 0; i < numCols; i++) {\n minColumnWidths[i] += growth[i] ?? 0;\n }\n\n const allocated = growth.reduce((total, width) => total + width, 0);\n let leftover = remaining - allocated;\n for (let i = 0; leftover > 0 && i < numCols; i++) {\n minColumnWidths[i]++;\n leftover--;\n }\n }\n\n minCellsWidth = minColumnWidths.reduce((a, b) => a + b, 0);\n }\n\n // Calculate column widths that fit within available width\n const totalNaturalWidth = naturalWidths.reduce((a, b) => a + b, 0) + borderOverhead;\n let columnWidths: number[];\n\n if (totalNaturalWidth <= availableWidth) {\n // Everything fits naturally\n columnWidths = naturalWidths.map((width, index) => Math.max(width, minColumnWidths[index]));\n } else {\n // Need to shrink columns to fit\n const totalGrowPotential = naturalWidths.reduce((total, width, index) => {\n return total + Math.max(0, width - minColumnWidths[index]);\n }, 0);\n const extraWidth = Math.max(0, availableForCells - minCellsWidth);\n columnWidths = minColumnWidths.map((minWidth, index) => {\n const naturalWidth = naturalWidths[index];\n const minWidthDelta = Math.max(0, naturalWidth - minWidth);\n let grow = 0;\n if (totalGrowPotential > 0) {\n grow = Math.floor((minWidthDelta / totalGrowPotential) * extraWidth);\n }\n return minWidth + grow;\n });\n\n // Adjust for rounding errors - distribute remaining space\n const allocated = columnWidths.reduce((a, b) => a + b, 0);\n let remaining = availableForCells - allocated;\n while (remaining > 0) {\n let grew = false;\n for (let i = 0; i < numCols && remaining > 0; i++) {\n if (columnWidths[i] < naturalWidths[i]) {\n columnWidths[i]++;\n remaining--;\n grew = true;\n }\n }\n if (!grew) {\n break;\n }\n }\n }\n\n // Render top border\n const topBorderCells = columnWidths.map((w) => \"─\".repeat(w));\n lines.push(`┌─${topBorderCells.join(\"─┬─\")}─┐`);\n\n // Render header with wrapping\n const headerCellLines: string[][] = token.header.map((cell, i) => {\n const text = self.renderInlineTokens(cell.tokens || [], styleContext);\n return self.wrapCellText(text, columnWidths[i]);\n });\n const headerLineCount = Math.max(...headerCellLines.map((c) => c.length));\n\n for (let lineIdx = 0; lineIdx < headerLineCount; lineIdx++) {\n const rowParts = headerCellLines.map((cellLines, colIdx) => {\n const text = cellLines[lineIdx] || \"\";\n const padded = text + \" \".repeat(Math.max(0, columnWidths[colIdx] - visibleWidth(text)));\n return self.theme.bold(padded);\n });\n lines.push(`│ ${rowParts.join(\" │ \")} │`);\n }\n\n // Render separator\n const separatorCells = columnWidths.map((w) => \"─\".repeat(w));\n const separatorLine = `├─${separatorCells.join(\"─┼─\")}─┤`;\n lines.push(separatorLine);\n\n // Render rows with wrapping\n for (let rowIndex = 0; rowIndex < token.rows.length; rowIndex++) {\n const row = token.rows[rowIndex];\n const rowCellLines: string[][] = row.map((cell, i) => {\n const text = self.renderInlineTokens(cell.tokens || [], styleContext);\n return self.wrapCellText(text, columnWidths[i]);\n });\n const rowLineCount = Math.max(...rowCellLines.map((c) => c.length));\n\n for (let lineIdx = 0; lineIdx < rowLineCount; lineIdx++) {\n const rowParts = rowCellLines.map((cellLines, colIdx) => {\n const text = cellLines[lineIdx] || \"\";\n return text + \" \".repeat(Math.max(0, columnWidths[colIdx] - visibleWidth(text)));\n });\n lines.push(`│ ${rowParts.join(\" │ \")} │`);\n }\n\n if (rowIndex < token.rows.length - 1) {\n lines.push(separatorLine);\n }\n }\n\n // Render bottom border\n const bottomBorderCells = columnWidths.map((w) => \"─\".repeat(w));\n lines.push(`└─${bottomBorderCells.join(\"─┴─\")}─┘`);\n\n if (nextTokenType && nextTokenType !== \"space\") {\n lines.push(\"\"); // Add spacing after table\n }\n return lines;\n}\n"]}
@@ -0,0 +1,6 @@
1
+ import type { Markdown } from "../markdown.ts";
2
+ export declare function do_setText(self: Markdown, text: string): void;
3
+ export declare function do_invalidate(self: Markdown): void;
4
+ export declare function do_render(self: Markdown, width: number): string[];
5
+ export declare function do_applyDefaultStyle(self: Markdown, text: string): string;
6
+ //# sourceMappingURL=text-rendering.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text-rendering.d.ts","sourceRoot":"","sources":["../../../../src/components/markdown/markdown-methods/text-rendering.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C,wBAAgB,UAAU,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAG7D;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI,CAIlD;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CA0FjE;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CA2BzE","sourcesContent":["import { isImageLine } from \"../../../terminal-image.ts\";\nimport { applyBackgroundToLine, visibleWidth, wrapTextWithAnsi } from \"../../../utils.ts\";\nimport { markdownParser } from \"../constants.ts\";\nimport type { Markdown } from \"../markdown.ts\";\n\nexport function do_setText(self: Markdown, text: string): void {\n self.text = text;\n self.invalidate();\n}\n\nexport function do_invalidate(self: Markdown): void {\n self.cachedText = undefined;\n self.cachedWidth = undefined;\n self.cachedLines = undefined;\n}\n\nexport function do_render(self: Markdown, width: number): string[] {\n // Check cache\n if (self.cachedLines && self.cachedText === self.text && self.cachedWidth === width) {\n return self.cachedLines;\n }\n\n // Calculate available width for content (subtract horizontal padding)\n const contentWidth = Math.max(1, width - self.paddingX * 2);\n\n // Don't render anything if there's no actual text\n if (!self.text || self.text.trim() === \"\") {\n const result: string[] = [];\n // Update cache\n self.cachedText = self.text;\n self.cachedWidth = width;\n self.cachedLines = result;\n return result;\n }\n\n // Replace tabs with 4 spaces for consistent rendering\n const normalizedText = self.text.replace(/\\t/g, \" \");\n\n // Parse markdown to HTML-like tokens\n const tokens = markdownParser.lexer(normalizedText);\n\n // Convert tokens to styled terminal output\n const renderedLines: string[] = [];\n\n for (let i = 0; i < tokens.length; i++) {\n const token = tokens[i];\n const nextToken = tokens[i + 1];\n const tokenLines = self.renderToken(token, contentWidth, nextToken?.type);\n for (const tokenLine of tokenLines) {\n renderedLines.push(tokenLine);\n }\n }\n\n // Wrap lines (NO padding, NO background yet)\n const wrappedLines: string[] = [];\n for (const line of renderedLines) {\n if (isImageLine(line)) {\n wrappedLines.push(line);\n } else {\n for (const wrappedLine of wrapTextWithAnsi(line, contentWidth)) {\n wrappedLines.push(wrappedLine);\n }\n }\n }\n\n // Add margins and background to each wrapped line\n const leftMargin = \" \".repeat(self.paddingX);\n const rightMargin = \" \".repeat(self.paddingX);\n const bgFn = self.defaultTextStyle?.bgColor;\n const contentLines: string[] = [];\n\n for (const line of wrappedLines) {\n if (isImageLine(line)) {\n contentLines.push(line);\n continue;\n }\n\n const lineWithMargins = leftMargin + line + rightMargin;\n\n if (bgFn) {\n contentLines.push(applyBackgroundToLine(lineWithMargins, width, bgFn));\n } else {\n // No background - just pad to width\n const visibleLen = visibleWidth(lineWithMargins);\n const paddingNeeded = Math.max(0, width - visibleLen);\n contentLines.push(lineWithMargins + \" \".repeat(paddingNeeded));\n }\n }\n\n // Add top/bottom padding (empty lines)\n const emptyLine = \" \".repeat(width);\n const emptyLines: string[] = [];\n for (let i = 0; i < self.paddingY; i++) {\n const line = bgFn ? applyBackgroundToLine(emptyLine, width, bgFn) : emptyLine;\n emptyLines.push(line);\n }\n\n // Combine top padding, content, and bottom padding\n const result = emptyLines.concat(contentLines, emptyLines);\n\n // Update cache\n self.cachedText = self.text;\n self.cachedWidth = width;\n self.cachedLines = result;\n\n return result.length > 0 ? result : [\"\"];\n}\n\nexport function do_applyDefaultStyle(self: Markdown, text: string): string {\n if (!self.defaultTextStyle) {\n return text;\n }\n\n let styled = text;\n\n // Apply foreground color (NOT background - that's applied at padding stage)\n if (self.defaultTextStyle.color) {\n styled = self.defaultTextStyle.color(styled);\n }\n\n // Apply text decorations using self.theme\n if (self.defaultTextStyle.bold) {\n styled = self.theme.bold(styled);\n }\n if (self.defaultTextStyle.italic) {\n styled = self.theme.italic(styled);\n }\n if (self.defaultTextStyle.strikethrough) {\n styled = self.theme.strikethrough(styled);\n }\n if (self.defaultTextStyle.underline) {\n styled = self.theme.underline(styled);\n }\n\n return styled;\n}\n"]}
@@ -0,0 +1,115 @@
1
+ import { isImageLine } from "../../../terminal-image.js";
2
+ import { applyBackgroundToLine, visibleWidth, wrapTextWithAnsi } from "../../../utils.js";
3
+ import { markdownParser } from "../constants.js";
4
+ export function do_setText(self, text) {
5
+ self.text = text;
6
+ self.invalidate();
7
+ }
8
+ export function do_invalidate(self) {
9
+ self.cachedText = undefined;
10
+ self.cachedWidth = undefined;
11
+ self.cachedLines = undefined;
12
+ }
13
+ export function do_render(self, width) {
14
+ // Check cache
15
+ if (self.cachedLines && self.cachedText === self.text && self.cachedWidth === width) {
16
+ return self.cachedLines;
17
+ }
18
+ // Calculate available width for content (subtract horizontal padding)
19
+ const contentWidth = Math.max(1, width - self.paddingX * 2);
20
+ // Don't render anything if there's no actual text
21
+ if (!self.text || self.text.trim() === "") {
22
+ const result = [];
23
+ // Update cache
24
+ self.cachedText = self.text;
25
+ self.cachedWidth = width;
26
+ self.cachedLines = result;
27
+ return result;
28
+ }
29
+ // Replace tabs with 4 spaces for consistent rendering
30
+ const normalizedText = self.text.replace(/\t/g, " ");
31
+ // Parse markdown to HTML-like tokens
32
+ const tokens = markdownParser.lexer(normalizedText);
33
+ // Convert tokens to styled terminal output
34
+ const renderedLines = [];
35
+ for (let i = 0; i < tokens.length; i++) {
36
+ const token = tokens[i];
37
+ const nextToken = tokens[i + 1];
38
+ const tokenLines = self.renderToken(token, contentWidth, nextToken?.type);
39
+ for (const tokenLine of tokenLines) {
40
+ renderedLines.push(tokenLine);
41
+ }
42
+ }
43
+ // Wrap lines (NO padding, NO background yet)
44
+ const wrappedLines = [];
45
+ for (const line of renderedLines) {
46
+ if (isImageLine(line)) {
47
+ wrappedLines.push(line);
48
+ }
49
+ else {
50
+ for (const wrappedLine of wrapTextWithAnsi(line, contentWidth)) {
51
+ wrappedLines.push(wrappedLine);
52
+ }
53
+ }
54
+ }
55
+ // Add margins and background to each wrapped line
56
+ const leftMargin = " ".repeat(self.paddingX);
57
+ const rightMargin = " ".repeat(self.paddingX);
58
+ const bgFn = self.defaultTextStyle?.bgColor;
59
+ const contentLines = [];
60
+ for (const line of wrappedLines) {
61
+ if (isImageLine(line)) {
62
+ contentLines.push(line);
63
+ continue;
64
+ }
65
+ const lineWithMargins = leftMargin + line + rightMargin;
66
+ if (bgFn) {
67
+ contentLines.push(applyBackgroundToLine(lineWithMargins, width, bgFn));
68
+ }
69
+ else {
70
+ // No background - just pad to width
71
+ const visibleLen = visibleWidth(lineWithMargins);
72
+ const paddingNeeded = Math.max(0, width - visibleLen);
73
+ contentLines.push(lineWithMargins + " ".repeat(paddingNeeded));
74
+ }
75
+ }
76
+ // Add top/bottom padding (empty lines)
77
+ const emptyLine = " ".repeat(width);
78
+ const emptyLines = [];
79
+ for (let i = 0; i < self.paddingY; i++) {
80
+ const line = bgFn ? applyBackgroundToLine(emptyLine, width, bgFn) : emptyLine;
81
+ emptyLines.push(line);
82
+ }
83
+ // Combine top padding, content, and bottom padding
84
+ const result = emptyLines.concat(contentLines, emptyLines);
85
+ // Update cache
86
+ self.cachedText = self.text;
87
+ self.cachedWidth = width;
88
+ self.cachedLines = result;
89
+ return result.length > 0 ? result : [""];
90
+ }
91
+ export function do_applyDefaultStyle(self, text) {
92
+ if (!self.defaultTextStyle) {
93
+ return text;
94
+ }
95
+ let styled = text;
96
+ // Apply foreground color (NOT background - that's applied at padding stage)
97
+ if (self.defaultTextStyle.color) {
98
+ styled = self.defaultTextStyle.color(styled);
99
+ }
100
+ // Apply text decorations using self.theme
101
+ if (self.defaultTextStyle.bold) {
102
+ styled = self.theme.bold(styled);
103
+ }
104
+ if (self.defaultTextStyle.italic) {
105
+ styled = self.theme.italic(styled);
106
+ }
107
+ if (self.defaultTextStyle.strikethrough) {
108
+ styled = self.theme.strikethrough(styled);
109
+ }
110
+ if (self.defaultTextStyle.underline) {
111
+ styled = self.theme.underline(styled);
112
+ }
113
+ return styled;
114
+ }
115
+ //# sourceMappingURL=text-rendering.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text-rendering.js","sourceRoot":"","sources":["../../../../src/components/markdown/markdown-methods/text-rendering.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1F,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGjD,MAAM,UAAU,UAAU,CAAC,IAAc,EAAE,IAAY,EAAQ;IAC7D,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACjB,IAAI,CAAC,UAAU,EAAE,CAAC;AAAA,CACnB;AAED,MAAM,UAAU,aAAa,CAAC,IAAc,EAAQ;IAClD,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;IAC5B,IAAI,CAAC,WAAW,GAAG,SAAS,CAAC;IAC7B,IAAI,CAAC,WAAW,GAAG,SAAS,CAAC;AAAA,CAC9B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,CAAC,KAAK,EAAE,CAAC;QAChC,MAAM,GAAG,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC/C,CAAC;IAED,0CAA0C;IAC1C,IAAI,IAAI,CAAC,gBAAgB,CAAC,IAAI,EAAE,CAAC;QAC/B,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACnC,CAAC;IACD,IAAI,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,CAAC;QACjC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACrC,CAAC;IACD,IAAI,IAAI,CAAC,gBAAgB,CAAC,aAAa,EAAE,CAAC;QACxC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IAC5C,CAAC;IACD,IAAI,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE,CAAC;QACpC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACxC,CAAC;IAED,OAAO,MAAM,CAAC;AAAA,CACf","sourcesContent":["import { isImageLine } from \"../../../terminal-image.ts\";\nimport { applyBackgroundToLine, visibleWidth, wrapTextWithAnsi } from \"../../../utils.ts\";\nimport { markdownParser } from \"../constants.ts\";\nimport type { Markdown } from \"../markdown.ts\";\n\nexport function do_setText(self: Markdown, text: string): void {\n self.text = text;\n self.invalidate();\n}\n\nexport function do_invalidate(self: Markdown): void {\n self.cachedText = undefined;\n self.cachedWidth = undefined;\n self.cachedLines = undefined;\n}\n\nexport function do_render(self: Markdown, width: number): string[] {\n // Check cache\n if (self.cachedLines && self.cachedText === self.text && self.cachedWidth === width) {\n return self.cachedLines;\n }\n\n // Calculate available width for content (subtract horizontal padding)\n const contentWidth = Math.max(1, width - self.paddingX * 2);\n\n // Don't render anything if there's no actual text\n if (!self.text || self.text.trim() === \"\") {\n const result: string[] = [];\n // Update cache\n self.cachedText = self.text;\n self.cachedWidth = width;\n self.cachedLines = result;\n return result;\n }\n\n // Replace tabs with 4 spaces for consistent rendering\n const normalizedText = self.text.replace(/\\t/g, \" \");\n\n // Parse markdown to HTML-like tokens\n const tokens = markdownParser.lexer(normalizedText);\n\n // Convert tokens to styled terminal output\n const renderedLines: string[] = [];\n\n for (let i = 0; i < tokens.length; i++) {\n const token = tokens[i];\n const nextToken = tokens[i + 1];\n const tokenLines = self.renderToken(token, contentWidth, nextToken?.type);\n for (const tokenLine of tokenLines) {\n renderedLines.push(tokenLine);\n }\n }\n\n // Wrap lines (NO padding, NO background yet)\n const wrappedLines: string[] = [];\n for (const line of renderedLines) {\n if (isImageLine(line)) {\n wrappedLines.push(line);\n } else {\n for (const wrappedLine of wrapTextWithAnsi(line, contentWidth)) {\n wrappedLines.push(wrappedLine);\n }\n }\n }\n\n // Add margins and background to each wrapped line\n const leftMargin = \" \".repeat(self.paddingX);\n const rightMargin = \" \".repeat(self.paddingX);\n const bgFn = self.defaultTextStyle?.bgColor;\n const contentLines: string[] = [];\n\n for (const line of wrappedLines) {\n if (isImageLine(line)) {\n contentLines.push(line);\n continue;\n }\n\n const lineWithMargins = leftMargin + line + rightMargin;\n\n if (bgFn) {\n contentLines.push(applyBackgroundToLine(lineWithMargins, width, bgFn));\n } else {\n // No background - just pad to width\n const visibleLen = visibleWidth(lineWithMargins);\n const paddingNeeded = Math.max(0, width - visibleLen);\n contentLines.push(lineWithMargins + \" \".repeat(paddingNeeded));\n }\n }\n\n // Add top/bottom padding (empty lines)\n const emptyLine = \" \".repeat(width);\n const emptyLines: string[] = [];\n for (let i = 0; i < self.paddingY; i++) {\n const line = bgFn ? applyBackgroundToLine(emptyLine, width, bgFn) : emptyLine;\n emptyLines.push(line);\n }\n\n // Combine top padding, content, and bottom padding\n const result = emptyLines.concat(contentLines, emptyLines);\n\n // Update cache\n self.cachedText = self.text;\n self.cachedWidth = width;\n self.cachedLines = result;\n\n return result.length > 0 ? result : [\"\"];\n}\n\nexport function do_applyDefaultStyle(self: Markdown, text: string): string {\n if (!self.defaultTextStyle) {\n return text;\n }\n\n let styled = text;\n\n // Apply foreground color (NOT background - that's applied at padding stage)\n if (self.defaultTextStyle.color) {\n styled = self.defaultTextStyle.color(styled);\n }\n\n // Apply text decorations using self.theme\n if (self.defaultTextStyle.bold) {\n styled = self.theme.bold(styled);\n }\n if (self.defaultTextStyle.italic) {\n styled = self.theme.italic(styled);\n }\n if (self.defaultTextStyle.strikethrough) {\n styled = self.theme.strikethrough(styled);\n }\n if (self.defaultTextStyle.underline) {\n styled = self.theme.underline(styled);\n }\n\n return styled;\n}\n"]}