@visulima/tui 1.0.0-alpha.6 → 1.0.0-alpha.7

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 (412) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/core/index.js +1 -5
  3. package/dist/ink/index.d.ts +15 -34
  4. package/dist/ink/index.js +1 -155
  5. package/dist/packem_chunks/devtools.js +3 -26
  6. package/dist/packem_shared/Accordion-BXsqchV-.js +1 -0
  7. package/dist/packem_shared/Alert-BhYVMHtR.js +1 -0
  8. package/dist/packem_shared/AnimatePresence-Eu7Z8KHc.js +1 -0
  9. package/dist/packem_shared/ApprovalPrompt-BSn0FT1g.js +1 -0
  10. package/dist/packem_shared/AreaChart-Chy-frI7.js +1 -0
  11. package/dist/packem_shared/Badge-B8WPyRsK.js +1 -0
  12. package/dist/packem_shared/BarChart-rpZtlMcF.js +1 -0
  13. package/dist/packem_shared/BigText-CRpwUzrt.js +1 -0
  14. package/dist/packem_shared/BlinkDot-BvnRuWP8.js +1 -0
  15. package/dist/packem_shared/Box-BwqSvWuq.js +1 -0
  16. package/dist/packem_shared/Breadcrumb-D0hClbRV.js +1 -0
  17. package/dist/packem_shared/Button-B89Yvbc6.js +1 -0
  18. package/dist/packem_shared/COLOR_BLINDNESS_SIMULATION-DqErf7XX.js +1 -0
  19. package/dist/packem_shared/Calendar-Dmflvm2S.js +1 -0
  20. package/dist/packem_shared/Canvas-CKg6WV47.js +1 -0
  21. package/dist/packem_shared/Card-B_9fXdtU.js +1 -0
  22. package/dist/packem_shared/Cell-BrXn3jxY.js +1 -0
  23. package/dist/packem_shared/Checkbox-BN71eCWU.js +1 -0
  24. package/dist/packem_shared/Code-HhevcyiH.js +2 -0
  25. package/dist/packem_shared/Collapsible-u6uf_FdV.js +1 -0
  26. package/dist/packem_shared/CommandBlock-B-nslpCv.js +4 -0
  27. package/dist/packem_shared/CommandPalette-CEFdaURo.js +1 -0
  28. package/dist/packem_shared/ConfirmDialog-5Jje_Xpu.js +1 -0
  29. package/dist/packem_shared/ConfirmInput-D44Mb9oo.js +1 -0
  30. package/dist/packem_shared/ConsoleOverlay-CM3APfgP.js +1 -0
  31. package/dist/packem_shared/ContentSwitcher-Dm5BkrCt.js +1 -0
  32. package/dist/packem_shared/ControlledScrollView-DI8KZOQB.js +1 -0
  33. package/dist/packem_shared/Cursor-BoLFIMol.js +1 -0
  34. package/dist/packem_shared/DatePicker-CnSrFFAE.js +1 -0
  35. package/dist/packem_shared/DefinitionList-v8RDuF_R.js +1 -0
  36. package/dist/packem_shared/DevTools-O8EbCfHa.js +1 -0
  37. package/dist/packem_shared/Dialog-CTaL8pn0.js +1 -0
  38. package/dist/packem_shared/DiffView-BUIFqUB0.js +1 -0
  39. package/dist/packem_shared/Divider-C47bKmqu.js +1 -0
  40. package/dist/packem_shared/FilePicker-CUo7R5Qb.js +1 -0
  41. package/dist/packem_shared/FocusContext-Xy0cwJpO.js +1 -0
  42. package/dist/packem_shared/FormField-af3aUpRL.js +1 -0
  43. package/dist/packem_shared/Fullscreen-CuJ8y0s0.js +1 -0
  44. package/dist/packem_shared/Gauge-Dz-usH__.js +1 -0
  45. package/dist/packem_shared/Gradient-DYNc0GZA.js +1 -0
  46. package/dist/packem_shared/Heading-mwEYza3Y.js +1 -0
  47. package/dist/packem_shared/Heatmap-ChL97U1-.js +1 -0
  48. package/dist/packem_shared/Help-Zcelyw_U.js +1 -0
  49. package/dist/packem_shared/Histogram-FIf2F83d.js +1 -0
  50. package/dist/packem_shared/IMECompositionBuffer-C89PhiOu.js +1 -0
  51. package/dist/packem_shared/InputParser-rZKjY_7Y.js +2 -0
  52. package/dist/packem_shared/KEY-Bk8B-3h_.js +1 -0
  53. package/dist/packem_shared/Kbd-DpkPp4jB.js +1 -0
  54. package/dist/packem_shared/LayoutNode-rxblE317.js +1 -0
  55. package/dist/packem_shared/LineChart-BXE_girm.js +1 -0
  56. package/dist/packem_shared/Link-i2o2EG4-.js +1 -0
  57. package/dist/packem_shared/LoadingIndicator-TC1Fjwyt.js +1 -0
  58. package/dist/packem_shared/Markdown-R1XqK63D.js +1 -0
  59. package/dist/packem_shared/MaskedInput-J01phOZs.js +1 -0
  60. package/dist/packem_shared/Menu-CfrH4ymk.js +1 -0
  61. package/dist/packem_shared/MessageBubble-BmBBU2Rm.js +1 -0
  62. package/dist/packem_shared/ModelBadge-D3wrXncu.js +1 -0
  63. package/dist/packem_shared/MouseProvider-pjza-lpc.js +1 -0
  64. package/dist/packem_shared/MultiSelect-Dqmn-bVo.js +1 -0
  65. package/dist/packem_shared/NAMED_COLORS-B9fJsYdg.js +1 -0
  66. package/dist/packem_shared/Newline-BSG4iUqp.js +2 -0
  67. package/dist/packem_shared/OperationTree-DksxjMIV.js +1 -0
  68. package/dist/packem_shared/OptionList-CNx7r9yN.js +1 -0
  69. package/dist/packem_shared/OrderedList-BeDy035w.js +1 -0
  70. package/dist/packem_shared/Paginator-B56s6bhS.js +1 -0
  71. package/dist/packem_shared/Paragraph-BqJlH0R-.js +1 -0
  72. package/dist/packem_shared/Placeholder-GMpHRGC8.js +1 -0
  73. package/dist/packem_shared/ProgressBar-Bj3fmORR.js +1 -0
  74. package/dist/packem_shared/RadioGroup-Br8BeEwS.js +1 -0
  75. package/dist/packem_shared/Renderer-DJXooAsp.js +1 -0
  76. package/dist/packem_shared/ResizeObserverEntry-Dq0dk8Kq.js +1 -0
  77. package/dist/packem_shared/ScatterPlot-OhfYco5l.js +1 -0
  78. package/dist/packem_shared/ScrollBar-Da5Y3z7N.js +1 -0
  79. package/dist/packem_shared/ScrollBarBox-Dz6F-Eat.js +1 -0
  80. package/dist/packem_shared/ScrollList-DiVGyEjv.js +1 -0
  81. package/dist/packem_shared/ScrollView-BojONotI.js +1 -0
  82. package/dist/packem_shared/SearchInput-BoPTRbhV.js +1 -0
  83. package/dist/packem_shared/SelectInput-CAJ7SCBq.js +1 -0
  84. package/dist/packem_shared/SelectInputIndicator-N1n8ULHs.js +1 -0
  85. package/dist/packem_shared/SelectInputItem-BEkbmobs.js +1 -0
  86. package/dist/packem_shared/ShimmerText-CuGQ2NDC.js +1 -0
  87. package/dist/packem_shared/Slider-Cg_tJpKa.js +1 -0
  88. package/dist/packem_shared/Spacer-eT3HOrXk.js +1 -0
  89. package/dist/packem_shared/Sparkline-T6_FPVET.js +1 -0
  90. package/dist/packem_shared/Spinner-B0-A50pu.js +1 -0
  91. package/dist/packem_shared/Static-DLynr5pn.js +1 -0
  92. package/dist/packem_shared/Static-jzLPaHJF.js +1 -0
  93. package/dist/packem_shared/StaticRender-BgD61E7x.js +1 -0
  94. package/dist/packem_shared/StatusLine-Ch4jjef1.js +1 -0
  95. package/dist/packem_shared/StatusMessage-B1qfKeMM.js +1 -0
  96. package/dist/packem_shared/Stepper-CNPAqxiU.js +1 -0
  97. package/dist/packem_shared/Stopwatch-CAx2EWwq.js +1 -0
  98. package/dist/packem_shared/StreamingText-BYOKSB2T.js +1 -0
  99. package/dist/packem_shared/Switch-DzSpKYu7.js +1 -0
  100. package/dist/packem_shared/Tab-BcXzSUdj.js +1 -0
  101. package/dist/packem_shared/Table-DJp1TLrR.js +1 -0
  102. package/dist/packem_shared/Tabs-D68z0SOt.js +1 -0
  103. package/dist/packem_shared/Tag-BvLHnYRn.js +1 -0
  104. package/dist/packem_shared/Text-mTAve9R2.js +1 -0
  105. package/dist/packem_shared/TextInput-C_gYQlnF.js +1 -0
  106. package/dist/packem_shared/Textarea-C2ET_oMb.js +2 -0
  107. package/dist/packem_shared/Timer-CI3aQX65.js +1 -0
  108. package/dist/packem_shared/Toast-Drvc8XfG.js +1 -0
  109. package/dist/packem_shared/Tooltip-C5UnQlLd.js +1 -0
  110. package/dist/packem_shared/Transform-fYmcdqRT.js +1 -0
  111. package/dist/packem_shared/Transition-CJDBKYUB.js +1 -0
  112. package/dist/packem_shared/TreeNodeMap-CspqSCpb.js +1 -0
  113. package/dist/packem_shared/TreeView-DjhacGJ5.js +1 -0
  114. package/dist/packem_shared/TuiApp-DrjI_i-R.js +1 -0
  115. package/dist/packem_shared/TuiContext-BoJvG3NN.js +3 -0
  116. package/dist/packem_shared/UnorderedList-BnfqexZs.js +1 -0
  117. package/dist/packem_shared/accessibility-context-DDyHTwmA.js +1 -0
  118. package/dist/packem_shared/animation-context-DW3p-vpk.js +1 -0
  119. package/dist/packem_shared/ansi-parser-B6uXaq65.js +1 -0
  120. package/dist/packem_shared/ansi-tokenizer-DqX9nJuk.js +1 -0
  121. package/dist/packem_shared/app-context-BVpKlG1z.js +1 -0
  122. package/dist/packem_shared/background-context-rjOaWFki.js +1 -0
  123. package/dist/packem_shared/boxes-DyY_LXCi.js +1 -0
  124. package/dist/packem_shared/braille-BBjIoaN0.js +1 -0
  125. package/dist/packem_shared/colorize-DbTZMrJO.js +1 -0
  126. package/dist/packem_shared/comparePoints-C85EsmNz.js +1 -0
  127. package/dist/packem_shared/controlled-scroll-view-CmrAEvJk.js +1 -0
  128. package/dist/packem_shared/createInlineLoop-DRNZ7jqH.js +2 -0
  129. package/dist/packem_shared/createLinkedScrollGroup-BMTJ7rAj.js +1 -0
  130. package/dist/packem_shared/createMemoryStorage-QVZNXbWz.js +2 -0
  131. package/dist/packem_shared/createScreen-CrLrxA6t.js +3 -0
  132. package/dist/packem_shared/cursor-context-CFviBqPX.js +1 -0
  133. package/dist/packem_shared/dom-4y__5fWB.js +1 -0
  134. package/dist/packem_shared/focus-context-CsT69klR.js +1 -0
  135. package/dist/packem_shared/format-time-C7Q-hQZq.js +1 -0
  136. package/dist/packem_shared/getPathToRoot-B2tKmx3i.js +1 -0
  137. package/dist/packem_shared/getScrollHeight-BTEY8ewu.js +1 -0
  138. package/dist/packem_shared/input-utils-fAxzSlNh.js +1 -0
  139. package/dist/packem_shared/isIntersecting-B3KbKTmu.js +1 -0
  140. package/dist/packem_shared/isOsc52Supported-DKK7Uee6.js +1 -0
  141. package/dist/packem_shared/isTerminalPaletteQuerySupported-Dn2hFAZ_.js +1 -0
  142. package/dist/packem_shared/kittyFlags-C3rZLbcK.js +1 -0
  143. package/dist/packem_shared/line-chart-DrM8PwnI.js +1 -0
  144. package/dist/packem_shared/measure-element-DSp7YDus.js +2 -0
  145. package/dist/packem_shared/measure-text-DDjHT1jD.js +3 -0
  146. package/dist/packem_shared/measureElement-DA8WqFP_.js +1 -0
  147. package/dist/packem_shared/mouse-context-DaARgUu1.js +1 -0
  148. package/dist/packem_shared/parseSgrMouse-Ccj70ijb.js +1 -0
  149. package/dist/packem_shared/processLayout-DXDfFb_d.js +1 -0
  150. package/dist/packem_shared/reconciler-BuOP-TZ6.js +1 -0
  151. package/dist/packem_shared/reconciler-DSYCrIZs.js +1 -0
  152. package/dist/packem_shared/render-DDqtMAFN.js +1 -0
  153. package/dist/packem_shared/render-_r0K9K11.js +28 -0
  154. package/dist/packem_shared/renderToString-DeqOWRP8.js +4 -0
  155. package/dist/packem_shared/renderToString-IYYPyASm.js +2 -0
  156. package/dist/packem_shared/renderTreeToBuffer-DPkoCgP2.js +2 -0
  157. package/dist/packem_shared/renderer-D2p6av2X.js +17 -0
  158. package/dist/packem_shared/setEnableStyledLineCache-D2gZbwFM.js +1 -0
  159. package/dist/packem_shared/squashTextNodesWithMap-Cpqmc45i.js +1 -0
  160. package/dist/packem_shared/stderr-context-BzEaUICS.js +1 -0
  161. package/dist/packem_shared/stdin-context-BTaaFagk.js +1 -0
  162. package/dist/packem_shared/stdout-context-BnblEPez.js +1 -0
  163. package/dist/packem_shared/text-width-CZ9vPvM0.js +2 -0
  164. package/dist/packem_shared/token-to-elements-BYxT6J_Q.js +1 -0
  165. package/dist/packem_shared/treeViewTheme-1RIZyB4M.js +1 -0
  166. package/dist/packem_shared/useAnimation-B9we6ZzL.js +1 -0
  167. package/dist/packem_shared/useApp-B6fvM42d.js +1 -0
  168. package/dist/packem_shared/useBoxMetrics-D5pkIr6P.js +1 -0
  169. package/dist/packem_shared/useClipboard-CBxy0hT8.js +1 -0
  170. package/dist/packem_shared/useColorBlindness-BvWcu2Bb.js +1 -0
  171. package/dist/packem_shared/useConsoleCapture-BxiG8iLJ.js +1 -0
  172. package/dist/packem_shared/useCursor-CPu8T5Db.js +1 -0
  173. package/dist/packem_shared/useElementDimensions-qJ_WXFZ9.js +1 -0
  174. package/dist/packem_shared/useFocus-DSmziO_x.js +1 -0
  175. package/dist/packem_shared/useFocusManager-Uapn3LQo.js +1 -0
  176. package/dist/packem_shared/useForm-CzV-Oext.js +1 -0
  177. package/dist/packem_shared/useHotkey-D0dGey14.js +1 -0
  178. package/dist/packem_shared/useInput-D1_jG26Z.js +2 -0
  179. package/dist/packem_shared/useInterval-AobjZT3u.js +1 -0
  180. package/dist/packem_shared/useIsScreenReaderEnabled-DjWHh-II.js +1 -0
  181. package/dist/packem_shared/useKeyBindings-zabkEJQs.js +1 -0
  182. package/dist/packem_shared/useKeyChord-CICQIxXj.js +1 -0
  183. package/dist/packem_shared/useMouseAction-2dRfU1vE.js +1 -0
  184. package/dist/packem_shared/useMouseContext-C746G7kY.js +1 -0
  185. package/dist/packem_shared/useMousePosition-BTWfV4JK.js +1 -0
  186. package/dist/packem_shared/useOnMouseClick-nY8xLZmt.js +1 -0
  187. package/dist/packem_shared/useOnMouseHover-D3DczIol.js +1 -0
  188. package/dist/packem_shared/useOnMouseState-cRK8QvzD.js +1 -0
  189. package/dist/packem_shared/usePaste-CKKB9H-Z.js +1 -0
  190. package/dist/packem_shared/useScrollAcceleration-NrY1oVMs.js +1 -0
  191. package/dist/packem_shared/useScrollInput-Caghtn-Q.js +1 -0
  192. package/dist/packem_shared/useStderr-BDZb6InG.js +1 -0
  193. package/dist/packem_shared/useStdin-DKa4h35k.js +1 -0
  194. package/dist/packem_shared/useStdout-B-2lX4C5.js +1 -0
  195. package/dist/packem_shared/useStopwatch-DffK7iMh.js +1 -0
  196. package/dist/packem_shared/useTerminalPalette-Cv7tSduR.js +1 -0
  197. package/dist/packem_shared/useTextBuffer-DekkGLxI.js +4 -0
  198. package/dist/packem_shared/useTextSelection-CGT0GLDR.js +1 -0
  199. package/dist/packem_shared/useTimeout-7LEFYTnG.js +1 -0
  200. package/dist/packem_shared/useTimer-DyoqSyGi.js +1 -0
  201. package/dist/packem_shared/useTreeView-8UlTK6sW.js +1 -0
  202. package/dist/packem_shared/useTreeViewState-CRPCUWrb.js +1 -0
  203. package/dist/packem_shared/useWindowSize-yDZsXF8z.js +1 -0
  204. package/dist/packem_shared/utils-THUhYKG2.js +1 -0
  205. package/dist/packem_shared/variant-config-BJqpNo7H.js +1 -0
  206. package/dist/packem_shared/waitFor-Dj5zfL5s.js +4 -0
  207. package/dist/packem_shared/wrapOrTruncateStyledLine-BZ00SM8i.js +3 -0
  208. package/dist/react/index.js +1 -9
  209. package/dist/testing/index.js +1 -152
  210. package/package.json +9 -9
  211. package/dist/packem_shared/Accordion-BG-yfIkV.js +0 -80
  212. package/dist/packem_shared/Alert-BLcwIW8V.js +0 -17
  213. package/dist/packem_shared/AnimatePresence-D8nEOr_B.js +0 -98
  214. package/dist/packem_shared/ApprovalPrompt-BXdPros1.js +0 -104
  215. package/dist/packem_shared/AreaChart-CmTcxLum.js +0 -116
  216. package/dist/packem_shared/Badge-CUfbXwAB.js +0 -13
  217. package/dist/packem_shared/BarChart-DWRae67P.js +0 -87
  218. package/dist/packem_shared/BigText-CVq2X7B5.js +0 -24
  219. package/dist/packem_shared/BlinkDot-CrbHMR3L.js +0 -11
  220. package/dist/packem_shared/Box-W1w_NGin.js +0 -71
  221. package/dist/packem_shared/Breadcrumb-CPdNxVYs.js +0 -26
  222. package/dist/packem_shared/Button-CBmTbJ_D.js +0 -57
  223. package/dist/packem_shared/COLOR_BLINDNESS_SIMULATION-BsMy5Ewl.js +0 -81
  224. package/dist/packem_shared/Calendar-C2Qxt-LA.js +0 -139
  225. package/dist/packem_shared/Canvas-COttmLPX.js +0 -246
  226. package/dist/packem_shared/Card-D3tGkNCm.js +0 -24
  227. package/dist/packem_shared/Cell-DCg1kJY-.js +0 -48
  228. package/dist/packem_shared/Checkbox-Dpy_4Lws.js +0 -49
  229. package/dist/packem_shared/Code-CwzzbsLx.js +0 -53
  230. package/dist/packem_shared/Collapsible-BMDrXf5C.js +0 -45
  231. package/dist/packem_shared/CommandBlock-jdOGJPjY.js +0 -80
  232. package/dist/packem_shared/CommandPalette-B5IfUQwi.js +0 -146
  233. package/dist/packem_shared/ConfirmDialog-5XJv3Cc4.js +0 -67
  234. package/dist/packem_shared/ConfirmInput-CxUS0XAA.js +0 -44
  235. package/dist/packem_shared/ConsoleOverlay-BvnCEgjG.js +0 -57
  236. package/dist/packem_shared/ContentSwitcher-BHFpO5Za.js +0 -81
  237. package/dist/packem_shared/ControlledScrollView-C2wOOlJO.js +0 -5
  238. package/dist/packem_shared/Cursor-DiW7YoSK.js +0 -18
  239. package/dist/packem_shared/DatePicker-CPejKoqS.js +0 -73
  240. package/dist/packem_shared/DefinitionList-BAwr0l5J.js +0 -18
  241. package/dist/packem_shared/DevTools-BdxRSkhL.js +0 -63
  242. package/dist/packem_shared/Dialog-S9r7Izff.js +0 -71
  243. package/dist/packem_shared/DiffView-BR4T6-Sj.js +0 -329
  244. package/dist/packem_shared/Divider-DocXIqNn.js +0 -30
  245. package/dist/packem_shared/FilePicker-BZ55oF_n.js +0 -261
  246. package/dist/packem_shared/FocusContext-D5wFxSRz.js +0 -153
  247. package/dist/packem_shared/FormField-BSG16cnA.js +0 -29
  248. package/dist/packem_shared/Fullscreen-DO7voOq5.js +0 -11
  249. package/dist/packem_shared/Gauge-CKXUXxft.js +0 -122
  250. package/dist/packem_shared/Gradient-Dg0NezWc.js +0 -136
  251. package/dist/packem_shared/Heading-BnR7McmP.js +0 -29
  252. package/dist/packem_shared/Heatmap-_jqISOU0.js +0 -79
  253. package/dist/packem_shared/Help-0yZ_IcQg.js +0 -105
  254. package/dist/packem_shared/Histogram-CB6XcmZW.js +0 -92
  255. package/dist/packem_shared/IMECompositionBuffer-Dl3S0KnF.js +0 -55
  256. package/dist/packem_shared/InputParser-BlsfeY9J.js +0 -158
  257. package/dist/packem_shared/KEY-STOdi-nc.js +0 -74
  258. package/dist/packem_shared/Kbd-BNDXQgey.js +0 -19
  259. package/dist/packem_shared/LayoutNode-DAkKg9TE.js +0 -129
  260. package/dist/packem_shared/LineChart-ef3HF816.js +0 -7
  261. package/dist/packem_shared/Link-DZ2Tiq1m.js +0 -66
  262. package/dist/packem_shared/LoadingIndicator-DzbLGfyJ.js +0 -13
  263. package/dist/packem_shared/Markdown-33bpCUoe.js +0 -212
  264. package/dist/packem_shared/MaskedInput-Ctr6v2dO.js +0 -119
  265. package/dist/packem_shared/Menu-CeKxhEix.js +0 -112
  266. package/dist/packem_shared/MessageBubble-BMoU8L2Q.js +0 -26
  267. package/dist/packem_shared/ModelBadge-CNIxPs7v.js +0 -40
  268. package/dist/packem_shared/MouseProvider-CekPbXCh.js +0 -136
  269. package/dist/packem_shared/MultiSelect-yz7-w0Zv.js +0 -129
  270. package/dist/packem_shared/NAMED_COLORS-DcI3erCu.js +0 -300
  271. package/dist/packem_shared/Newline-DBtYEg8x.js +0 -7
  272. package/dist/packem_shared/OperationTree-Dudx5o1o.js +0 -67
  273. package/dist/packem_shared/OptionList-CTyqQaZ1.js +0 -24
  274. package/dist/packem_shared/OrderedList-VsvSmHUC.js +0 -26
  275. package/dist/packem_shared/Paginator-DmGogvEI.js +0 -104
  276. package/dist/packem_shared/Paragraph-CNNhfepo.js +0 -9
  277. package/dist/packem_shared/Placeholder-DkM69Q8Z.js +0 -29
  278. package/dist/packem_shared/ProgressBar-B7cS4uQm.js +0 -22
  279. package/dist/packem_shared/RadioGroup-B4F9PUyL.js +0 -108
  280. package/dist/packem_shared/Renderer-zZ5O3vxc.js +0 -31
  281. package/dist/packem_shared/ResizeObserverEntry-Vr8GZ74x.js +0 -102
  282. package/dist/packem_shared/ScatterPlot-CWOg4G5h.js +0 -63
  283. package/dist/packem_shared/ScrollBar-DFeWH43I.js +0 -106
  284. package/dist/packem_shared/ScrollBarBox-C7VL6Izd.js +0 -72
  285. package/dist/packem_shared/ScrollList-DRcr_RrN.js +0 -227
  286. package/dist/packem_shared/ScrollView-C6rdlGwU.js +0 -196
  287. package/dist/packem_shared/SearchInput-cB8zFhSg.js +0 -32
  288. package/dist/packem_shared/SelectInput-WzZSqp72.js +0 -260
  289. package/dist/packem_shared/SelectInputIndicator-DKeN6v5Z.js +0 -9
  290. package/dist/packem_shared/SelectInputItem-CxFL3spM.js +0 -8
  291. package/dist/packem_shared/ShimmerText-B2VbPUSB.js +0 -34
  292. package/dist/packem_shared/Slider-BOrNTOQe.js +0 -116
  293. package/dist/packem_shared/Spacer-DhmXyTb8.js +0 -8
  294. package/dist/packem_shared/Sparkline-BSbjPrwK.js +0 -44
  295. package/dist/packem_shared/Spinner-BcO5BCAa.js +0 -1942
  296. package/dist/packem_shared/Static-DpTd6Eed.js +0 -22
  297. package/dist/packem_shared/Static-xmD9giJj.js +0 -18
  298. package/dist/packem_shared/StaticRender-C3XWvJdC.js +0 -69
  299. package/dist/packem_shared/StatusLine-DQNUstN9.js +0 -22
  300. package/dist/packem_shared/StatusMessage-BYTL6Pl-.js +0 -14
  301. package/dist/packem_shared/Stepper-CmUPRK3z.js +0 -60
  302. package/dist/packem_shared/Stopwatch-zqLQAxXC.js +0 -21
  303. package/dist/packem_shared/StreamingText-BmuoJtGu.js +0 -38
  304. package/dist/packem_shared/Switch-DcPdy8nm.js +0 -59
  305. package/dist/packem_shared/Tab-C6r5q4hR.js +0 -7
  306. package/dist/packem_shared/Table-Bgxo87Df.js +0 -88
  307. package/dist/packem_shared/Tabs-DubuHdYV.js +0 -164
  308. package/dist/packem_shared/Tag-CCqM7Ee9.js +0 -35
  309. package/dist/packem_shared/Text-CtUwV89_.js +0 -65
  310. package/dist/packem_shared/TextInput-C9r7zT0U.js +0 -137
  311. package/dist/packem_shared/Textarea-CGmgt-Nl.js +0 -272
  312. package/dist/packem_shared/Timer-D7ZZ0_wz.js +0 -20
  313. package/dist/packem_shared/Toast-DXSCXFPY.js +0 -37
  314. package/dist/packem_shared/Tooltip-SvVjj-2k.js +0 -32
  315. package/dist/packem_shared/Transform-Cfyva2wd.js +0 -14
  316. package/dist/packem_shared/Transition-CbNfKhaj.js +0 -108
  317. package/dist/packem_shared/TreeNodeMap-CtJUvBnd.js +0 -155
  318. package/dist/packem_shared/TreeView-DGlZeSsK.js +0 -148
  319. package/dist/packem_shared/TuiApp-DtdgNRWa.js +0 -122
  320. package/dist/packem_shared/TuiContext-lXmJFd-x.js +0 -418
  321. package/dist/packem_shared/UnorderedList-D8RPaEAW.js +0 -33
  322. package/dist/packem_shared/accessibility-context-BLelHhNU.js +0 -7
  323. package/dist/packem_shared/animation-context-BcJg8Jr6.js +0 -15
  324. package/dist/packem_shared/ansi-parser-BOP8fNdT.js +0 -43
  325. package/dist/packem_shared/ansi-tokenizer-LHq2LUWA.js +0 -307
  326. package/dist/packem_shared/app-context-CP0U6H7O.js +0 -11
  327. package/dist/packem_shared/background-context-BAUaxfOb.js +0 -5
  328. package/dist/packem_shared/boxes-oi3WUbyR.js +0 -92
  329. package/dist/packem_shared/braille-BoEWoH2I.js +0 -93
  330. package/dist/packem_shared/colorize-88_Vk8cn.js +0 -48
  331. package/dist/packem_shared/comparePoints-CAAlhiMS.js +0 -287
  332. package/dist/packem_shared/controlled-scroll-view-DJXfdWMm.js +0 -286
  333. package/dist/packem_shared/createInlineLoop-Dnfm1ZSJ.js +0 -99
  334. package/dist/packem_shared/createLinkedScrollGroup-Djw4Ceo0.js +0 -44
  335. package/dist/packem_shared/createMemoryStorage-esFJ61La.js +0 -115
  336. package/dist/packem_shared/createScreen-Dh0sZlQ0.js +0 -38
  337. package/dist/packem_shared/cursor-context-JxRzlqAx.js +0 -9
  338. package/dist/packem_shared/dom-CrbpQgat.js +0 -228
  339. package/dist/packem_shared/focus-context-CWkYtgcm.js +0 -26
  340. package/dist/packem_shared/format-time-BGmnDukX.js +0 -12
  341. package/dist/packem_shared/getPathToRoot-BbvlppLC.js +0 -4
  342. package/dist/packem_shared/getScrollHeight-Cz3CDQN2.js +0 -63
  343. package/dist/packem_shared/input-utils-ViAEXa0Z.js +0 -19
  344. package/dist/packem_shared/isIntersecting-fEXHJN5R.js +0 -10
  345. package/dist/packem_shared/isOsc52Supported-G0k4sXJx.js +0 -36
  346. package/dist/packem_shared/isTerminalPaletteQuerySupported-EeiwMKbr.js +0 -93
  347. package/dist/packem_shared/kittyFlags-bNNf_9kX.js +0 -26
  348. package/dist/packem_shared/line-chart-VGU2l7pu.js +0 -139
  349. package/dist/packem_shared/measure-element-Bc6PEaIe.js +0 -405
  350. package/dist/packem_shared/measure-text-BdOhbOeh.js +0 -1256
  351. package/dist/packem_shared/measureElement-DTELRaij.js +0 -4
  352. package/dist/packem_shared/mouse-context-BUHWKEIe.js +0 -6
  353. package/dist/packem_shared/parseSgrMouse-4hpBJBsW.js +0 -1
  354. package/dist/packem_shared/processLayout-B0Coz0Ua.js +0 -2
  355. package/dist/packem_shared/reconciler-Dd7Z0A97.js +0 -696
  356. package/dist/packem_shared/reconciler-mzMwSOft.js +0 -221
  357. package/dist/packem_shared/render-Bm9Oa1sG.js +0 -2799
  358. package/dist/packem_shared/render-CjlKdg4m.js +0 -199
  359. package/dist/packem_shared/renderToString-CWYS1ZXE.js +0 -86
  360. package/dist/packem_shared/renderToString-DB3ILWFm.js +0 -62
  361. package/dist/packem_shared/renderTreeToBuffer-CDDTGyZn.js +0 -311
  362. package/dist/packem_shared/renderer-GE9OLNNM.js +0 -1437
  363. package/dist/packem_shared/setEnableStyledLineCache-D5f4favX.js +0 -2
  364. package/dist/packem_shared/squashTextNodesWithMap-iqm6OMMT.js +0 -100
  365. package/dist/packem_shared/stderr-context-Bj4Mf7v7.js +0 -17
  366. package/dist/packem_shared/stdin-context-Bq_GNJ3z.js +0 -38
  367. package/dist/packem_shared/stdout-context-CgjWeCdO.js +0 -17
  368. package/dist/packem_shared/text-width-Db-AxMea.js +0 -43
  369. package/dist/packem_shared/token-to-elements-CK4s8MJd.js +0 -249
  370. package/dist/packem_shared/treeViewTheme-BpSw9TMf.js +0 -52
  371. package/dist/packem_shared/useAnimation-DV22qxiJ.js +0 -62
  372. package/dist/packem_shared/useApp-Cbi788rV.js +0 -6
  373. package/dist/packem_shared/useBoxMetrics-_5icypir.js +0 -54
  374. package/dist/packem_shared/useClipboard-MNj6MNR-.js +0 -23
  375. package/dist/packem_shared/useColorBlindness-D_sTIhcb.js +0 -30
  376. package/dist/packem_shared/useConsoleCapture-Dvt7G1W1.js +0 -61
  377. package/dist/packem_shared/useCursor-DS6LjIgv.js +0 -19
  378. package/dist/packem_shared/useElementDimensions-CAoKitVD.js +0 -67
  379. package/dist/packem_shared/useFocus-DLoGQJd9.js +0 -37
  380. package/dist/packem_shared/useFocusManager-UeZWtnNc.js +0 -16
  381. package/dist/packem_shared/useForm-sQENbEuv.js +0 -88
  382. package/dist/packem_shared/useHotkey-D9giUX3q.js +0 -112
  383. package/dist/packem_shared/useInput-DKZbqMRc.js +0 -594
  384. package/dist/packem_shared/useInterval-CSXM8c2I.js +0 -32
  385. package/dist/packem_shared/useIsScreenReaderEnabled-BeoVqo1R.js +0 -9
  386. package/dist/packem_shared/useKeyBindings-S4fSIEAk.js +0 -66
  387. package/dist/packem_shared/useKeyChord-BmXGNuEO.js +0 -114
  388. package/dist/packem_shared/useMouseAction-C5gZ2nj7.js +0 -29
  389. package/dist/packem_shared/useMouseContext-D-rFy60Q.js +0 -12
  390. package/dist/packem_shared/useMousePosition-BHBJ-kBk.js +0 -25
  391. package/dist/packem_shared/useOnMouseClick--ZIyBOBO.js +0 -35
  392. package/dist/packem_shared/useOnMouseHover-26diuXUC.js +0 -32
  393. package/dist/packem_shared/useOnMouseState-NO_Kda_C.js +0 -13
  394. package/dist/packem_shared/usePaste-png73gvT.js +0 -35
  395. package/dist/packem_shared/useScrollAcceleration-R9LfrPVG.js +0 -73
  396. package/dist/packem_shared/useScrollInput-DfzRGQFe.js +0 -72
  397. package/dist/packem_shared/useStderr-BSWerMZ7.js +0 -6
  398. package/dist/packem_shared/useStdin-Rf0zPzVA.js +0 -7
  399. package/dist/packem_shared/useStdout-B5yRcg9N.js +0 -6
  400. package/dist/packem_shared/useStopwatch-C__Zu6hd.js +0 -33
  401. package/dist/packem_shared/useTerminalPalette-CtFG2JTq.js +0 -38
  402. package/dist/packem_shared/useTextBuffer-C8fEe9Ly.js +0 -398
  403. package/dist/packem_shared/useTextSelection-ChrYZXsn.js +0 -50
  404. package/dist/packem_shared/useTimeout-DuCqgWPX.js +0 -34
  405. package/dist/packem_shared/useTimer-DnBtbhB5.js +0 -46
  406. package/dist/packem_shared/useTreeView-mkN5Di7w.js +0 -101
  407. package/dist/packem_shared/useTreeViewState-BpS_KZ-K.js +0 -502
  408. package/dist/packem_shared/useWindowSize-D3UU41mv.js +0 -20
  409. package/dist/packem_shared/utils-BgdlrbOH.js +0 -140
  410. package/dist/packem_shared/variant-config-DSZoX5TM.js +0 -8
  411. package/dist/packem_shared/waitFor-Cv9M2jKA.js +0 -39
  412. package/dist/packem_shared/wrapOrTruncateStyledLine-49Mne3t3.js +0 -147
@@ -1,1256 +0,0 @@
1
- import { isFullwidthCodePoint, getStringWidth } from '@visulima/string';
2
- import { t as tokenizeAnsi } from './ansi-tokenizer-LHq2LUWA.js';
3
-
4
- class DataLimitedLruMap {
5
- map;
6
- maxDataSize;
7
- maxKeys;
8
- currentDataSize = 0;
9
- constructor(maxKeys, maxDataSize) {
10
- this.map = /* @__PURE__ */ new Map();
11
- this.maxKeys = maxKeys;
12
- this.maxDataSize = maxDataSize;
13
- }
14
- get size() {
15
- return this.map.size;
16
- }
17
- clear() {
18
- this.map.clear();
19
- this.currentDataSize = 0;
20
- }
21
- get(key) {
22
- if (!this.map.has(key)) {
23
- return void 0;
24
- }
25
- const value = this.map.get(key);
26
- this.map.delete(key);
27
- this.map.set(key, value);
28
- return value;
29
- }
30
- set(key, value) {
31
- const size = key.length;
32
- if (size > this.maxDataSize) {
33
- return;
34
- }
35
- const hasKey = this.map.has(key);
36
- if (hasKey) {
37
- this.map.delete(key);
38
- this.currentDataSize -= size;
39
- }
40
- while (this.currentDataSize + size > this.maxDataSize && this.map.size > 0) {
41
- const lruKey = this.map.keys().next().value;
42
- if (lruKey === void 0) {
43
- break;
44
- }
45
- this.map.delete(lruKey);
46
- this.currentDataSize -= lruKey.length;
47
- }
48
- while (this.map.size >= this.maxKeys) {
49
- const lruKey = this.map.keys().next().value;
50
- if (lruKey === void 0) {
51
- break;
52
- }
53
- this.map.delete(lruKey);
54
- this.currentDataSize -= lruKey.length;
55
- }
56
- this.map.set(key, value);
57
- this.currentDataSize += size;
58
- }
59
- }
60
-
61
- const BOLD_MASK = 1;
62
- const DIM_MASK = 1 << 1;
63
- const ITALIC_MASK = 1 << 2;
64
- const UNDERLINE_MASK = 1 << 3;
65
- const STRIKETHROUGH_MASK = 1 << 4;
66
- const INVERSE_MASK = 1 << 5;
67
- const HIDDEN_MASK = 1 << 6;
68
- const FULL_WIDTH_MASK = 1 << 7;
69
-
70
- const OFFSET_MASK = 1073741823;
71
- const FULL_WIDTH_FLAG = 1073741824;
72
- class StyledLine {
73
- length = 0;
74
- static emptyCache = /* @__PURE__ */ new Map();
75
- text;
76
- charData;
77
- spans;
78
- _cachedTrimmedLength;
79
- static empty(length) {
80
- if (length <= 0) {
81
- return new StyledLine();
82
- }
83
- const cached = StyledLine.emptyCache.get(length);
84
- if (cached) {
85
- return cached.clone();
86
- }
87
- const line = new StyledLine();
88
- line.length = length;
89
- line.text = " ".repeat(length);
90
- line.charData = Array.from({ length });
91
- for (let i = 0; i < length; i++) {
92
- line.charData[i] = i;
93
- }
94
- line.spans = [{ formatFlags: 0, length }];
95
- line._cachedTrimmedLength = 0;
96
- Object.freeze(line.spans[0]);
97
- Object.freeze(line.spans);
98
- Object.freeze(line);
99
- StyledLine.emptyCache.set(length, line);
100
- return line.clone();
101
- }
102
- getValue(index) {
103
- if (this.text === void 0 || index < 0 || index >= this.length) {
104
- return "";
105
- }
106
- const start = this.charData[index] & OFFSET_MASK;
107
- const end = index + 1 < this.length ? this.charData[index + 1] & OFFSET_MASK : this.text.length;
108
- return this.text.slice(start, end);
109
- }
110
- /**
111
- * Get the raw text for a range of characters as a single string slice.
112
- * Much faster than calling getValue() per character.
113
- */
114
- getTextRange(start, end) {
115
- if (this.text === void 0 || start < 0 || end > this.length || start >= end) {
116
- return "";
117
- }
118
- const textStart = this.charData[start] & OFFSET_MASK;
119
- const textEnd = end < this.length ? this.charData[end] & OFFSET_MASK : this.text.length;
120
- return this.text.slice(textStart, textEnd);
121
- }
122
- getSpan(index) {
123
- if (this.spans === void 0 || index < 0 || index >= this.length) {
124
- return void 0;
125
- }
126
- let current = 0;
127
- for (const span of this.spans) {
128
- if (index < current + span.length) {
129
- return span;
130
- }
131
- current += span.length;
132
- }
133
- return void 0;
134
- }
135
- getFullWidth(index) {
136
- if (this.charData === void 0 || index < 0 || index >= this.length) {
137
- return false;
138
- }
139
- return (this.charData[index] & FULL_WIDTH_FLAG) !== 0;
140
- }
141
- hasStyles(index) {
142
- const span = this.getSpan(index);
143
- if (!span) {
144
- return false;
145
- }
146
- return (span.formatFlags & ~FULL_WIDTH_MASK) !== 0 || span.fgColor !== void 0 || span.bgColor !== void 0 || span.link !== void 0;
147
- }
148
- getFormatFlags(index) {
149
- let flags = this.getSpan(index)?.formatFlags ?? 0;
150
- if (this.getFullWidth(index)) {
151
- flags |= FULL_WIDTH_MASK;
152
- }
153
- return flags;
154
- }
155
- getFgColor(index) {
156
- return this.getSpan(index)?.fgColor;
157
- }
158
- getBgColor(index) {
159
- return this.getSpan(index)?.bgColor;
160
- }
161
- getLink(index) {
162
- return this.getSpan(index)?.link;
163
- }
164
- setInverted(index, inverted) {
165
- this._cachedTrimmedLength = void 0;
166
- this.updateSpanAt(index, (span) => {
167
- if (inverted) {
168
- span.formatFlags |= INVERSE_MASK;
169
- } else {
170
- span.formatFlags &= ~INVERSE_MASK;
171
- }
172
- });
173
- }
174
- setBackgroundColor(index, color) {
175
- this._cachedTrimmedLength = void 0;
176
- this.updateSpanAt(index, (span) => {
177
- span.bgColor = color;
178
- });
179
- }
180
- setForegroundColor(index, color) {
181
- this._cachedTrimmedLength = void 0;
182
- this.updateSpanAt(index, (span) => {
183
- span.fgColor = color;
184
- });
185
- }
186
- setChar(index, value, formatFlags, fgColor, bgColor, link) {
187
- if (index < 0 || index >= this.length) {
188
- return;
189
- }
190
- this._cachedTrimmedLength = void 0;
191
- this.ensureInitialized();
192
- const isFullWidth = (formatFlags & FULL_WIDTH_MASK) !== 0;
193
- const cleanFormatFlags = formatFlags & ~FULL_WIDTH_MASK;
194
- const start = this.charData[index] & OFFSET_MASK;
195
- const end = index + 1 < this.length ? this.charData[index + 1] & OFFSET_MASK : this.text.length;
196
- const oldLength = end - start;
197
- const newLength = value.length;
198
- this.text = this.text.slice(0, start) + value + this.text.slice(end);
199
- if (oldLength !== newLength) {
200
- const diff = newLength - oldLength;
201
- for (let i = index + 1; i < this.length; i++) {
202
- const data = this.charData[i];
203
- const oldOffset = data & OFFSET_MASK;
204
- const fw = data & FULL_WIDTH_FLAG;
205
- this.charData[i] = oldOffset + diff | fw;
206
- }
207
- }
208
- this.charData[index] = start | (isFullWidth ? FULL_WIDTH_FLAG : 0);
209
- if (this.trySetStyleAtIndex(index, cleanFormatFlags, fgColor, bgColor, link)) {
210
- return;
211
- }
212
- this.splitSpansAt(index);
213
- this.splitSpansAt(index + 1);
214
- let current = 0;
215
- for (let i = 0; i < this.spans.length; i++) {
216
- const span = this.spans[i];
217
- if (current === index && span.length === 1) {
218
- this.spans[i] = {
219
- bgColor,
220
- fgColor,
221
- formatFlags: cleanFormatFlags,
222
- length: 1,
223
- link
224
- };
225
- break;
226
- }
227
- current += span.length;
228
- }
229
- this.mergeSpans();
230
- }
231
- /**
232
- * Optimized setChar for same-length single-byte replacement.
233
- * Skips string rebuild and offset adjustment when old and new values
234
- * have the same byte length (the common case for ASCII overwrites on empty lines).
235
- */
236
- setCharFast(index, value, formatFlags, fgColor, bgColor, link) {
237
- if (index < 0 || index >= this.length) {
238
- return;
239
- }
240
- this._cachedTrimmedLength = void 0;
241
- this.ensureInitialized();
242
- const isFullWidth = (formatFlags & FULL_WIDTH_MASK) !== 0;
243
- const cleanFormatFlags = formatFlags & ~FULL_WIDTH_MASK;
244
- const start = this.charData[index] & OFFSET_MASK;
245
- const end = index + 1 < this.length ? this.charData[index + 1] & OFFSET_MASK : this.text.length;
246
- const oldLength = end - start;
247
- if (value.length === oldLength) {
248
- if (value !== this.text.slice(start, end)) {
249
- this.text = this.text.slice(0, start) + value + this.text.slice(end);
250
- }
251
- this.charData[index] = start | (isFullWidth ? FULL_WIDTH_FLAG : 0);
252
- } else {
253
- this.text = this.text.slice(0, start) + value + this.text.slice(end);
254
- if (oldLength !== value.length) {
255
- const diff = value.length - oldLength;
256
- for (let i = index + 1; i < this.length; i++) {
257
- const data = this.charData[i];
258
- this.charData[i] = (data & OFFSET_MASK) + diff | data & FULL_WIDTH_FLAG;
259
- }
260
- }
261
- this.charData[index] = start | (isFullWidth ? FULL_WIDTH_FLAG : 0);
262
- }
263
- if (this.trySetStyleAtIndex(index, cleanFormatFlags, fgColor, bgColor, link)) {
264
- return;
265
- }
266
- this.splitSpansAt(index);
267
- this.splitSpansAt(index + 1);
268
- let current = 0;
269
- for (let i = 0; i < this.spans.length; i++) {
270
- const span = this.spans[i];
271
- if (current === index && span.length === 1) {
272
- this.spans[i] = {
273
- bgColor,
274
- fgColor,
275
- formatFlags: cleanFormatFlags,
276
- length: 1,
277
- link
278
- };
279
- break;
280
- }
281
- current += span.length;
282
- }
283
- this.mergeSpans();
284
- }
285
- /**
286
- * Overwrite a range of this line with content from a source StyledLine.
287
- * More efficient than calling setChar() per character because it does
288
- * a single span split + rebuild instead of per-character span manipulation.
289
- * @param destinationStart — start index in this line
290
- * @param source — the StyledLine to copy from
291
- * @param srcStart — start index in source (default 0)
292
- * @param count — number of characters to copy (default: source.length)
293
- */
294
- writeFrom(destinationStart, source, srcStart = 0, count) {
295
- const n = count ?? source.length - srcStart;
296
- if (n <= 0 || destinationStart >= this.length) {
297
- return;
298
- }
299
- this._cachedTrimmedLength = void 0;
300
- this.ensureInitialized();
301
- const actualCount = Math.min(n, this.length - destinationStart, source.length - srcStart);
302
- const destinationTextStart = this.charData[destinationStart] & OFFSET_MASK;
303
- const destinationTextEnd = destinationStart + actualCount < this.length ? this.charData[destinationStart + actualCount] & OFFSET_MASK : this.text.length;
304
- let newSegment = "";
305
- for (let i = 0; i < actualCount; i++) {
306
- newSegment += source.getValue(srcStart + i);
307
- }
308
- const oldSegLength = destinationTextEnd - destinationTextStart;
309
- const diff = newSegment.length - oldSegLength;
310
- this.text = this.text.slice(0, destinationTextStart) + newSegment + this.text.slice(destinationTextEnd);
311
- let offset = destinationTextStart;
312
- for (let i = 0; i < actualCount; i++) {
313
- const srcFullWidth = source.getFullWidth(srcStart + i);
314
- this.charData[destinationStart + i] = offset | (srcFullWidth ? FULL_WIDTH_FLAG : 0);
315
- offset += source.getValue(srcStart + i).length;
316
- }
317
- if (diff !== 0) {
318
- for (let i = destinationStart + actualCount; i < this.length; i++) {
319
- const data = this.charData[i];
320
- this.charData[i] = (data & OFFSET_MASK) + diff | data & FULL_WIDTH_FLAG;
321
- }
322
- }
323
- this.splitSpansAt(destinationStart);
324
- this.splitSpansAt(destinationStart + actualCount);
325
- const newSpans = [];
326
- let srcSpanStart = 0;
327
- for (const span of source.getSpans()) {
328
- const spanEnd = srcSpanStart + span.length;
329
- const overlapStart = Math.max(srcStart, srcSpanStart);
330
- const overlapEnd = Math.min(srcStart + actualCount, spanEnd);
331
- if (overlapStart < overlapEnd) {
332
- newSpans.push({ ...span, length: overlapEnd - overlapStart });
333
- }
334
- srcSpanStart = spanEnd;
335
- if (srcSpanStart >= srcStart + actualCount) {
336
- break;
337
- }
338
- }
339
- let destinationSpanIndex = 0;
340
- let destinationSpanOffset = 0;
341
- for (let i = 0; i < this.spans.length; i++) {
342
- if (destinationSpanOffset === destinationStart) {
343
- destinationSpanIndex = i;
344
- break;
345
- }
346
- destinationSpanOffset += this.spans[i].length;
347
- }
348
- let removeCount = 0;
349
- let covered = 0;
350
- for (let i = destinationSpanIndex; i < this.spans.length && covered < actualCount; i++) {
351
- covered += this.spans[i].length;
352
- removeCount++;
353
- }
354
- this.spans.splice(destinationSpanIndex, removeCount, ...newSpans);
355
- this.mergeSpans();
356
- }
357
- pushChar(value, formatFlags, fgColor, bgColor, link) {
358
- this._cachedTrimmedLength = void 0;
359
- this.ensureInitialized();
360
- const isFullWidth = (formatFlags & FULL_WIDTH_MASK) !== 0;
361
- const cleanFormatFlags = formatFlags & ~FULL_WIDTH_MASK;
362
- const offset = this.text.length;
363
- this.text = (this.text ?? "") + value;
364
- this.charData.push(offset | (isFullWidth ? FULL_WIDTH_FLAG : 0));
365
- const lastSpan = this.spans.at(-1);
366
- if (lastSpan?.formatFlags === cleanFormatFlags && lastSpan.fgColor === fgColor && lastSpan.bgColor === bgColor && lastSpan.link === link) {
367
- lastSpan.length++;
368
- } else {
369
- this.spans.push({
370
- bgColor,
371
- fgColor,
372
- formatFlags: cleanFormatFlags,
373
- length: 1,
374
- link
375
- });
376
- }
377
- this.length++;
378
- }
379
- clone() {
380
- if (this.charData === void 0) {
381
- return new StyledLine();
382
- }
383
- const result = new StyledLine();
384
- result.length = this.length;
385
- result.text = this.text;
386
- result.charData = [...this.charData];
387
- result.spans = this.spans.map((span) => {
388
- return {
389
- ...span
390
- };
391
- });
392
- result._cachedTrimmedLength = this._cachedTrimmedLength;
393
- return result;
394
- }
395
- slice(start, end) {
396
- if (this.charData === void 0) {
397
- return new StyledLine();
398
- }
399
- const actualStart = Math.max(0, start);
400
- const actualEnd = end === void 0 ? this.length : Math.min(this.length, end);
401
- if (actualStart >= actualEnd) {
402
- return new StyledLine();
403
- }
404
- if (actualStart === 0 && actualEnd === this.length) {
405
- return this.clone();
406
- }
407
- const result = new StyledLine();
408
- result.length = actualEnd - actualStart;
409
- result.charData = Array.from({ length: result.length });
410
- const textStart = this.charData[actualStart] & OFFSET_MASK;
411
- const textEnd = actualEnd < this.length ? this.charData[actualEnd] & OFFSET_MASK : this.text.length;
412
- result.text = this.text.slice(textStart, textEnd);
413
- for (let i = 0; i < result.length; i++) {
414
- const oldData = this.charData[actualStart + i];
415
- const oldOffset = oldData & OFFSET_MASK;
416
- const fw = oldData & FULL_WIDTH_FLAG;
417
- result.charData[i] = oldOffset - textStart | fw;
418
- }
419
- const newSpans = [];
420
- let current = 0;
421
- for (const span of this.spans) {
422
- const spanStart = current;
423
- const spanEnd = current + span.length;
424
- const intersectStart = Math.max(actualStart, spanStart);
425
- const intersectEnd = Math.min(actualEnd, spanEnd);
426
- if (intersectStart < intersectEnd) {
427
- newSpans.push({
428
- ...span,
429
- length: intersectEnd - intersectStart
430
- });
431
- }
432
- current += span.length;
433
- if (current >= actualEnd) {
434
- break;
435
- }
436
- }
437
- result.spans = newSpans;
438
- result.mergeSpans();
439
- return result;
440
- }
441
- combine(...others) {
442
- if (others.length === 0) {
443
- return this.clone();
444
- }
445
- const allLines = [this, ...others].filter((l) => l.length > 0);
446
- if (allLines.length === 0) {
447
- return new StyledLine();
448
- }
449
- if (allLines.length === 1) {
450
- return allLines[0].clone();
451
- }
452
- let totalChars = 0;
453
- for (const line of allLines) {
454
- totalChars += line.length;
455
- }
456
- const result = new StyledLine();
457
- result.length = totalChars;
458
- result.text = allLines.map((l) => l.getText()).join("");
459
- result.charData = Array.from({ length: totalChars });
460
- let currentChar = 0;
461
- let currentOffset = 0;
462
- for (const line of allLines) {
463
- const lineCharData = line.charData;
464
- const lineText = line.getText();
465
- if (lineCharData) {
466
- for (let i = 0; i < line.length; i++) {
467
- const data = lineCharData[i];
468
- const lineOffset = data & OFFSET_MASK;
469
- const fw = data & FULL_WIDTH_FLAG;
470
- result.charData[currentChar + i] = currentOffset + lineOffset | fw;
471
- }
472
- } else {
473
- for (let i = 0; i < line.length; i++) {
474
- result.charData[currentChar + i] = currentOffset + i;
475
- }
476
- }
477
- currentChar += line.length;
478
- currentOffset += lineText.length;
479
- }
480
- result.spans = allLines.flatMap(
481
- (l) => l.getSpans().map((s) => {
482
- return {
483
- ...s
484
- };
485
- })
486
- );
487
- result.mergeSpans();
488
- return result;
489
- }
490
- getTrimmedLength() {
491
- if (this._cachedTrimmedLength !== void 0) {
492
- return this._cachedTrimmedLength;
493
- }
494
- if (this.length === 0) {
495
- this._cachedTrimmedLength = 0;
496
- return 0;
497
- }
498
- if (this.text === void 0 || this.charData === void 0) {
499
- this._cachedTrimmedLength = 0;
500
- return 0;
501
- }
502
- let currentIndex = this.length - 1;
503
- if (this.spans) {
504
- for (let s = this.spans.length - 1; s >= 0; s--) {
505
- const span = this.spans[s];
506
- const hasStylesOnSpan = (span.formatFlags & ~FULL_WIDTH_MASK) !== 0 || span.fgColor !== void 0 || span.bgColor !== void 0 || span.link !== void 0;
507
- if (hasStylesOnSpan) {
508
- this._cachedTrimmedLength = currentIndex + 1;
509
- return this._cachedTrimmedLength;
510
- }
511
- for (let i = 0; i < span.length; i++) {
512
- const charStart = this.charData[currentIndex] & OFFSET_MASK;
513
- const charEnd = currentIndex + 1 < this.length ? this.charData[currentIndex + 1] & OFFSET_MASK : this.text.length;
514
- if (charEnd - charStart !== 1 || this.text[charStart] !== " ") {
515
- this._cachedTrimmedLength = currentIndex + 1;
516
- return this._cachedTrimmedLength;
517
- }
518
- currentIndex--;
519
- }
520
- }
521
- }
522
- this._cachedTrimmedLength = 0;
523
- return 0;
524
- }
525
- trimEnd() {
526
- const trimmedLength = this.getTrimmedLength();
527
- if (trimmedLength === this.length) {
528
- return this;
529
- }
530
- if (trimmedLength === 0) {
531
- return new StyledLine();
532
- }
533
- return this.slice(0, trimmedLength);
534
- }
535
- equals(other) {
536
- if (this.length !== other.length) {
537
- return false;
538
- }
539
- if (this.length === 0) {
540
- return true;
541
- }
542
- if (this.getText() !== other.getText()) {
543
- return false;
544
- }
545
- const s1 = this.getSpans();
546
- const s2 = other.getSpans();
547
- if (s1.length !== s2.length) {
548
- return false;
549
- }
550
- for (const [i, element] of s1.entries()) {
551
- const sp1 = element;
552
- const sp2 = s2[i];
553
- if (sp1.length !== sp2.length || sp1.formatFlags !== sp2.formatFlags || sp1.fgColor !== sp2.fgColor || sp1.bgColor !== sp2.bgColor || sp1.link !== sp2.link) {
554
- return false;
555
- }
556
- }
557
- const thisCharData = this.charData;
558
- const otherCharData = other.charData;
559
- if (thisCharData && otherCharData) {
560
- for (let i = 0; i < this.length; i++) {
561
- if (thisCharData[i] !== otherCharData[i]) {
562
- return false;
563
- }
564
- }
565
- }
566
- return true;
567
- }
568
- getText() {
569
- return this.text ?? "";
570
- }
571
- getSpans() {
572
- return this.spans ?? [];
573
- }
574
- getValues() {
575
- return Array.from({ length: this.length }, (_, i) => this.getValue(i));
576
- }
577
- *[Symbol.iterator]() {
578
- if (this.length === 0) {
579
- return;
580
- }
581
- let currentSpanIndex = 0;
582
- let currentSpanPos = 0;
583
- const spans = this.getSpans();
584
- for (let i = 0; i < this.length; i++) {
585
- const span = spans[currentSpanIndex];
586
- const flags = span ? span.formatFlags : 0;
587
- const isFullWidth = this.getFullWidth(i);
588
- yield {
589
- bgColor: span?.bgColor,
590
- fgColor: span?.fgColor,
591
- formatFlags: flags | (isFullWidth ? FULL_WIDTH_MASK : 0),
592
- fullWidth: isFullWidth,
593
- hasStyles: (flags & ~FULL_WIDTH_MASK) !== 0 || span?.fgColor !== void 0 || span?.bgColor !== void 0 || span?.link !== void 0,
594
- link: span?.link,
595
- value: this.getValue(i)
596
- };
597
- if (span) {
598
- currentSpanPos++;
599
- if (currentSpanPos >= span.length) {
600
- currentSpanIndex++;
601
- currentSpanPos = 0;
602
- }
603
- }
604
- }
605
- }
606
- /**
607
- * Split the span at `index` into a single-char span, apply the updater,
608
- * then merge adjacent spans. Shared by setInverted/setBackgroundColor/setForegroundColor.
609
- */
610
- updateSpanAt(index, updater) {
611
- if (index < 0 || index >= this.length) {
612
- return;
613
- }
614
- this.ensureInitialized();
615
- this.splitSpansAt(index);
616
- this.splitSpansAt(index + 1);
617
- let current = 0;
618
- for (const span of this.spans) {
619
- if (current === index && span.length === 1) {
620
- updater(span);
621
- break;
622
- }
623
- current += span.length;
624
- }
625
- this.mergeSpans();
626
- }
627
- /**
628
- * Grow the line to at least `minWidth` columns, filling new cells with
629
- * empty strings (zero-width placeholders). This matches the behavior of
630
- * sparse JS arrays in the original ink Output where out-of-bounds writes
631
- * created gaps that produced no visible output.
632
- */
633
- ensureWidth(minWidth) {
634
- if (minWidth <= this.length) {
635
- return;
636
- }
637
- this.ensureInitialized();
638
- const oldLength = this.length;
639
- const extraCount = minWidth - oldLength;
640
- const oldTextLength = this.text.length;
641
- for (let i = 0; i < extraCount; i++) {
642
- this.charData.push(oldTextLength);
643
- }
644
- this.length = minWidth;
645
- const lastSpan = this.spans.at(-1);
646
- if (lastSpan?.formatFlags === 0 && lastSpan.fgColor === void 0 && lastSpan.bgColor === void 0 && lastSpan.link === void 0) {
647
- lastSpan.length += extraCount;
648
- } else {
649
- this.spans.push({ formatFlags: 0, length: extraCount });
650
- }
651
- }
652
- ensureInitialized() {
653
- if (this.charData === void 0) {
654
- this.text = "";
655
- this.charData = Array.from({ length: this.length });
656
- this.spans = this.length > 0 ? [{ formatFlags: 0, length: this.length }] : [];
657
- if (this.length > 0 && this.text.length === 0) {
658
- this.text = " ".repeat(this.length);
659
- for (let i = 0; i < this.length; i++) {
660
- this.charData[i] = i;
661
- }
662
- }
663
- }
664
- }
665
- splitSpansAt(index) {
666
- if (this.spans === void 0 || index <= 0 || index >= this.length) {
667
- return;
668
- }
669
- let current = 0;
670
- for (let i = 0; i < this.spans.length; i++) {
671
- const span = this.spans[i];
672
- if (index > current && index < current + span.length) {
673
- const leftLength = index - current;
674
- const rightLength = span.length - leftLength;
675
- this.spans.splice(i, 1, { ...span, length: leftLength }, { ...span, length: rightLength });
676
- return;
677
- }
678
- current += span.length;
679
- }
680
- }
681
- /**
682
- * Try to apply a single-char style at `index` by matching or merging
683
- * with an adjacent span, avoiding splitSpansAt + mergeSpans.
684
- *
685
- * Returns true if the style was applied (or was already correct),
686
- * false if the caller must fall through to the split/update/merge path.
687
- *
688
- * Ported from jacob314/ink PR #123 (Google LLC, Apache-2.0).
689
- */
690
- trySetStyleAtIndex(index, formatFlags, fgColor, bgColor, link) {
691
- if (!this.spans) {
692
- return false;
693
- }
694
- let currentOffset = 0;
695
- let spanIndex = -1;
696
- let span;
697
- for (let i = 0; i < this.spans.length; i++) {
698
- const s = this.spans[i];
699
- if (currentOffset <= index && currentOffset + s.length > index) {
700
- spanIndex = i;
701
- span = s;
702
- break;
703
- }
704
- currentOffset += s.length;
705
- }
706
- if (!span) {
707
- return false;
708
- }
709
- if (span.formatFlags === formatFlags && span.fgColor === fgColor && span.bgColor === bgColor && span.link === link) {
710
- return true;
711
- }
712
- if (index === currentOffset && spanIndex > 0) {
713
- const previousSpan = this.spans[spanIndex - 1];
714
- if (previousSpan.formatFlags === formatFlags && previousSpan.fgColor === fgColor && previousSpan.bgColor === bgColor && previousSpan.link === link) {
715
- previousSpan.length += 1;
716
- if (span.length === 1) {
717
- this.spans.splice(spanIndex, 1);
718
- } else {
719
- span.length -= 1;
720
- }
721
- return true;
722
- }
723
- }
724
- if (index === currentOffset + span.length - 1 && spanIndex < this.spans.length - 1) {
725
- const nextSpan = this.spans[spanIndex + 1];
726
- if (nextSpan.formatFlags === formatFlags && nextSpan.fgColor === fgColor && nextSpan.bgColor === bgColor && nextSpan.link === link) {
727
- nextSpan.length += 1;
728
- if (span.length === 1) {
729
- this.spans.splice(spanIndex, 1);
730
- } else {
731
- span.length -= 1;
732
- }
733
- return true;
734
- }
735
- }
736
- return false;
737
- }
738
- mergeSpans() {
739
- if (this.spans === void 0) {
740
- return;
741
- }
742
- const newSpans = [];
743
- for (const span of this.spans) {
744
- if (span.length === 0) {
745
- continue;
746
- }
747
- const last = newSpans.at(-1);
748
- if (last?.formatFlags === span.formatFlags && last.fgColor === span.fgColor && last.bgColor === span.bgColor && last.link === span.link) {
749
- last.length += span.length;
750
- } else {
751
- newSpans.push({ ...span });
752
- }
753
- }
754
- this.spans = newSpans;
755
- }
756
- }
757
-
758
- const NAMED_COLORS = {
759
- black: 0,
760
- blue: 4,
761
- cyan: 6,
762
- gray: 8,
763
- green: 2,
764
- grey: 8,
765
- magenta: 5,
766
- red: 1,
767
- white: 7,
768
- yellow: 3
769
- };
770
- const BRIGHT_COLORS = {
771
- blackBright: 8,
772
- blueBright: 12,
773
- cyanBright: 14,
774
- greenBright: 10,
775
- magentaBright: 13,
776
- redBright: 9,
777
- whiteBright: 15,
778
- yellowBright: 11
779
- };
780
- const ansi256Regex = /^ansi256\(\s?(\d+)\s?\)$/;
781
- const rgbRegex = /^rgb\(\s?(\d+),\s?(\d+),\s?(\d+)\s?\)$/;
782
- const colorToAnsi256 = (color) => {
783
- const named = NAMED_COLORS[color];
784
- if (named !== void 0) {
785
- return named;
786
- }
787
- const bright = BRIGHT_COLORS[color];
788
- if (bright !== void 0) {
789
- return bright;
790
- }
791
- const ansi256Match = ansi256Regex.exec(color);
792
- if (ansi256Match) {
793
- return Number(ansi256Match[1]) & 255;
794
- }
795
- if (color.startsWith("#") && color.length === 7) {
796
- const r = Number.parseInt(color.slice(1, 3), 16);
797
- const g = Number.parseInt(color.slice(3, 5), 16);
798
- const b = Number.parseInt(color.slice(5, 7), 16);
799
- return 16 + 36 * Math.round(r / 51) + 6 * Math.round(g / 51) + Math.round(b / 51);
800
- }
801
- const rgbMatch = rgbRegex.exec(color);
802
- if (rgbMatch) {
803
- return 16 + 36 * Math.round(Number(rgbMatch[1]) / 51) + 6 * Math.round(Number(rgbMatch[2]) / 51) + Math.round(Number(rgbMatch[3]) / 51);
804
- }
805
- return 255;
806
- };
807
- const colorToSgrParams = (color, isFg) => {
808
- const base = isFg ? 30 : 40;
809
- const named = NAMED_COLORS[color];
810
- if (named !== void 0) {
811
- return [base + named];
812
- }
813
- const bright = BRIGHT_COLORS[color];
814
- if (bright !== void 0) {
815
- return [base + 60 + (bright - 8)];
816
- }
817
- if (color.startsWith("#") && color.length === 7) {
818
- const r = Number.parseInt(color.slice(1, 3), 16);
819
- const g = Number.parseInt(color.slice(3, 5), 16);
820
- const b = Number.parseInt(color.slice(5, 7), 16);
821
- return [isFg ? 38 : 48, 2, r, g, b];
822
- }
823
- const ansi256Match = ansi256Regex.exec(color);
824
- if (ansi256Match) {
825
- return [isFg ? 38 : 48, 5, Number(ansi256Match[1])];
826
- }
827
- const rgbMatch = rgbRegex.exec(color);
828
- if (rgbMatch) {
829
- return [isFg ? 38 : 48, 2, Number(rgbMatch[1]), Number(rgbMatch[2]), Number(rgbMatch[3])];
830
- }
831
- return [];
832
- };
833
- const ansi256ToColorName = (index) => {
834
- const standardNames = ["black", "red", "green", "yellow", "blue", "magenta", "cyan", "white"];
835
- if (index >= 0 && index <= 7) {
836
- return standardNames[index];
837
- }
838
- return `ansi256(${index})`;
839
- };
840
-
841
- const createSgrState = () => {
842
- return {
843
- bgColor: void 0,
844
- fgColor: void 0,
845
- formatFlags: 0,
846
- link: void 0
847
- };
848
- };
849
- const applySgrParams = (state, parameterString) => {
850
- if (parameterString.length === 0) {
851
- return createSgrState();
852
- }
853
- const normalizedParams = parameterString.includes(":") ? parameterString.replaceAll(":", ";") : parameterString;
854
- const params = normalizedParams.split(";").filter((s) => s.length > 0).map(Number);
855
- let { bgColor, fgColor, formatFlags, link } = state;
856
- let index = 0;
857
- while (index < params.length) {
858
- const code = params[index];
859
- switch (code) {
860
- case 0: {
861
- formatFlags = 0;
862
- fgColor = void 0;
863
- bgColor = void 0;
864
- link = void 0;
865
- break;
866
- }
867
- case 1: {
868
- formatFlags |= BOLD_MASK;
869
- break;
870
- }
871
- case 2: {
872
- formatFlags |= DIM_MASK;
873
- break;
874
- }
875
- case 3: {
876
- formatFlags |= ITALIC_MASK;
877
- break;
878
- }
879
- case 4: {
880
- formatFlags |= UNDERLINE_MASK;
881
- break;
882
- }
883
- case 7: {
884
- formatFlags |= INVERSE_MASK;
885
- break;
886
- }
887
- case 8: {
888
- formatFlags |= HIDDEN_MASK;
889
- break;
890
- }
891
- case 9: {
892
- formatFlags |= STRIKETHROUGH_MASK;
893
- break;
894
- }
895
- // Reset individual attributes
896
- case 22: {
897
- formatFlags &= -4;
898
- break;
899
- }
900
- case 23: {
901
- formatFlags &= ~ITALIC_MASK;
902
- break;
903
- }
904
- case 24: {
905
- formatFlags &= ~UNDERLINE_MASK;
906
- break;
907
- }
908
- case 27: {
909
- formatFlags &= ~INVERSE_MASK;
910
- break;
911
- }
912
- case 28: {
913
- formatFlags &= ~HIDDEN_MASK;
914
- break;
915
- }
916
- case 29: {
917
- formatFlags &= ~STRIKETHROUGH_MASK;
918
- break;
919
- }
920
- // Standard foreground colors (30-37)
921
- case 30:
922
- case 31:
923
- case 32:
924
- case 33:
925
- case 34:
926
- case 35:
927
- case 36:
928
- case 37: {
929
- fgColor = ansi256ToColorName(code - 30);
930
- break;
931
- }
932
- // Extended foreground: 256-color or RGB
933
- case 38: {
934
- if (params[index + 1] === 5 && params[index + 2] !== void 0) {
935
- fgColor = ansi256ToColorName(params[index + 2]);
936
- index += 2;
937
- } else if (params[index + 1] === 2 && index + 4 < params.length) {
938
- fgColor = `rgb(${params[index + 2]}, ${params[index + 3]}, ${params[index + 4]})`;
939
- index += 4;
940
- }
941
- break;
942
- }
943
- // Default foreground
944
- case 39: {
945
- fgColor = void 0;
946
- break;
947
- }
948
- // Standard background colors (40-47)
949
- case 40:
950
- case 41:
951
- case 42:
952
- case 43:
953
- case 44:
954
- case 45:
955
- case 46:
956
- case 47: {
957
- bgColor = ansi256ToColorName(code - 40);
958
- break;
959
- }
960
- // Extended background: 256-color or RGB
961
- case 48: {
962
- if (params[index + 1] === 5 && params[index + 2] !== void 0) {
963
- bgColor = ansi256ToColorName(params[index + 2]);
964
- index += 2;
965
- } else if (params[index + 1] === 2 && index + 4 < params.length) {
966
- bgColor = `rgb(${params[index + 2]}, ${params[index + 3]}, ${params[index + 4]})`;
967
- index += 4;
968
- }
969
- break;
970
- }
971
- // Default background
972
- case 49: {
973
- bgColor = void 0;
974
- break;
975
- }
976
- // Bright foreground (90-97)
977
- case 90:
978
- case 91:
979
- case 92:
980
- case 93:
981
- case 94:
982
- case 95:
983
- case 96:
984
- case 97: {
985
- fgColor = `ansi256(${code - 90 + 8})`;
986
- break;
987
- }
988
- // Bright background (100-107)
989
- case 100:
990
- case 101:
991
- case 102:
992
- case 103:
993
- case 104:
994
- case 105:
995
- case 106:
996
- case 107: {
997
- bgColor = `ansi256(${code - 100 + 8})`;
998
- break;
999
- }
1000
- }
1001
- index++;
1002
- }
1003
- return { bgColor, fgColor, formatFlags, link };
1004
- };
1005
- const REGIONAL_INDICATOR_START = 127462;
1006
- const REGIONAL_INDICATOR_END = 127487;
1007
- const SKIN_TONE_START = 127995;
1008
- const SKIN_TONE_END = 127999;
1009
- const ZWJ = 8205;
1010
- const TAGS_BLOCK_START = 917504;
1011
- const TAGS_BLOCK_END = 917631;
1012
- const unicodeMarkRegex = new RegExp("\\p{Mark}", "u");
1013
- const graphemeSegmenter = new Intl.Segmenter(void 0, { granularity: "grapheme" });
1014
- const isFullwidthGrapheme = (grapheme, codePoint) => {
1015
- if (isFullwidthCodePoint(codePoint)) {
1016
- return true;
1017
- }
1018
- if (grapheme.includes("️")) {
1019
- return true;
1020
- }
1021
- if (codePoint >= REGIONAL_INDICATOR_START && codePoint <= REGIONAL_INDICATOR_END) {
1022
- return true;
1023
- }
1024
- return false;
1025
- };
1026
- const oscHyperlinkRegex = /(?:\u001B\]|\u009D)8;([^;]*);(.*?)(?:\u001B\\|\u0007|\u009C)/;
1027
- const parseOscHyperlink = (oscValue) => {
1028
- const match = oscHyperlinkRegex.exec(oscValue);
1029
- if (!match?.[2]) {
1030
- return void 0;
1031
- }
1032
- if (match[2].length === 0) {
1033
- return void 0;
1034
- }
1035
- const usesST = oscValue.endsWith("\x1B\\");
1036
- return usesST ? `ST:${match[2]}` : match[2];
1037
- };
1038
- const processTextToken = (text, line, state) => {
1039
- const segments = graphemeSegmenter.segment(text);
1040
- const graphemes = [];
1041
- for (const { segment } of segments) {
1042
- graphemes.push(segment);
1043
- }
1044
- for (let i = 0; i < graphemes.length; i++) {
1045
- let value = graphemes[i];
1046
- if (value === " ") {
1047
- for (let s = 0; s < 4; s++) {
1048
- line.pushChar(" ", state.formatFlags, state.fgColor, state.bgColor, state.link);
1049
- }
1050
- continue;
1051
- }
1052
- if (value === "\b") {
1053
- continue;
1054
- }
1055
- const firstCodePoint = value.codePointAt(0);
1056
- if (!firstCodePoint) {
1057
- continue;
1058
- }
1059
- if (firstCodePoint >= REGIONAL_INDICATOR_START && firstCodePoint <= REGIONAL_INDICATOR_END && i + 1 < graphemes.length) {
1060
- const nextGrapheme = graphemes[i + 1];
1061
- const nextCodePoint = nextGrapheme.codePointAt(0);
1062
- if (nextCodePoint && nextCodePoint >= REGIONAL_INDICATOR_START && nextCodePoint <= REGIONAL_INDICATOR_END) {
1063
- value += nextGrapheme;
1064
- i++;
1065
- }
1066
- } else {
1067
- while (i + 1 < graphemes.length) {
1068
- const nextGrapheme = graphemes[i + 1];
1069
- const nextCodePoint = nextGrapheme.codePointAt(0);
1070
- if (!nextCodePoint) {
1071
- break;
1072
- }
1073
- const firstCharIsUnicodeMark = unicodeMarkRegex.test(String.fromCodePoint(nextCodePoint));
1074
- const isSkinToneModifier = nextCodePoint >= SKIN_TONE_START && nextCodePoint <= SKIN_TONE_END;
1075
- const isZeroWidthJoiner = nextCodePoint === ZWJ;
1076
- const isTagsBlock = nextCodePoint >= TAGS_BLOCK_START && nextCodePoint <= TAGS_BLOCK_END;
1077
- if (!firstCharIsUnicodeMark && !isSkinToneModifier && !isZeroWidthJoiner && !isTagsBlock) {
1078
- break;
1079
- }
1080
- value += nextGrapheme;
1081
- i++;
1082
- if (isZeroWidthJoiner && i + 1 < graphemes.length) {
1083
- value += graphemes[i + 1];
1084
- i++;
1085
- }
1086
- }
1087
- }
1088
- const fw = isFullwidthGrapheme(value, firstCodePoint);
1089
- const flags = fw ? state.formatFlags | FULL_WIDTH_MASK : state.formatFlags;
1090
- line.pushChar(value, flags, state.fgColor, state.bgColor, state.link);
1091
- }
1092
- };
1093
- const textToStyledLine = (text) => {
1094
- if (text.length === 0) {
1095
- return new StyledLine();
1096
- }
1097
- const tokens = tokenizeAnsi(text);
1098
- const line = new StyledLine();
1099
- let sgrState = createSgrState();
1100
- for (const token of tokens) {
1101
- switch (token.type) {
1102
- case "csi": {
1103
- if (token.finalCharacter === "m") {
1104
- sgrState = applySgrParams(sgrState, token.parameterString);
1105
- }
1106
- break;
1107
- }
1108
- case "osc": {
1109
- const link = parseOscHyperlink(token.value);
1110
- if (link !== void 0) {
1111
- sgrState = { ...sgrState, link };
1112
- } else if (token.value.includes("8;")) {
1113
- sgrState = { ...sgrState, link: void 0 };
1114
- }
1115
- break;
1116
- }
1117
- case "text": {
1118
- processTextToken(token.value, line, sgrState);
1119
- break;
1120
- }
1121
- }
1122
- }
1123
- return line;
1124
- };
1125
- const asciiPrintableRegex = /^[\u0020-\u007E]*$/;
1126
- const plainTextToStyledLine = (text) => {
1127
- if (text.length === 0) {
1128
- return new StyledLine();
1129
- }
1130
- const line = new StyledLine();
1131
- if (asciiPrintableRegex.test(text)) {
1132
- for (const element of text) {
1133
- line.pushChar(element, 0);
1134
- }
1135
- return line;
1136
- }
1137
- processTextToken(text, line, createSgrState());
1138
- return line;
1139
- };
1140
-
1141
- const cache = new DataLimitedLruMap(1e4, 1e6);
1142
- const widthCache = /* @__PURE__ */ new Map();
1143
- const styledLineCache = new DataLimitedLruMap(1e4, 1e6);
1144
- let styledLineCacheEnabled = true;
1145
- let currentStringWidth = getStringWidth;
1146
- const setEnableStyledLineCache = (enabled) => {
1147
- styledLineCacheEnabled = enabled;
1148
- if (!enabled) {
1149
- styledLineCache.clear();
1150
- }
1151
- };
1152
- const clearStyledLineCache = () => {
1153
- styledLineCache.clear();
1154
- };
1155
- const setStringWidthFunction = (function_) => {
1156
- currentStringWidth = function_;
1157
- clearStringWidthCache();
1158
- };
1159
- const clearStringWidthCache = () => {
1160
- cache.clear();
1161
- widthCache.clear();
1162
- styledLineCache.clear();
1163
- };
1164
- const inkCharacterWidth = (text) => {
1165
- if (text.length === 1) {
1166
- const code = text.codePointAt(0);
1167
- if (code !== void 0 && code >= 32 && code < 127) {
1168
- return 1;
1169
- }
1170
- }
1171
- const cached = widthCache.get(text);
1172
- if (cached !== void 0) {
1173
- return cached;
1174
- }
1175
- let calculatedWidth;
1176
- try {
1177
- calculatedWidth = currentStringWidth(text);
1178
- } catch {
1179
- calculatedWidth = 1;
1180
- }
1181
- widthCache.set(text, calculatedWidth);
1182
- return calculatedWidth;
1183
- };
1184
- const safeGetStringWidth = (text) => {
1185
- try {
1186
- return currentStringWidth(text);
1187
- } catch {
1188
- return 1;
1189
- }
1190
- };
1191
- const measureText = (text) => {
1192
- if (text.length === 0) {
1193
- return {
1194
- height: 0,
1195
- width: 0
1196
- };
1197
- }
1198
- const cachedDimensions = cache.get(text);
1199
- if (cachedDimensions) {
1200
- return cachedDimensions;
1201
- }
1202
- const lines = text.split("\n");
1203
- const width = Math.max(...lines.map((line) => safeGetStringWidth(line)));
1204
- const height = lines.length;
1205
- const dimensions = { height, width };
1206
- cache.set(text, dimensions);
1207
- return dimensions;
1208
- };
1209
- const toStyledLine = (text) => {
1210
- if (styledLineCacheEnabled) {
1211
- const cached = styledLineCache.get(text);
1212
- if (cached !== void 0) {
1213
- return cached;
1214
- }
1215
- }
1216
- const line = textToStyledLine(text);
1217
- if (styledLineCacheEnabled) {
1218
- styledLineCache.set(text, line);
1219
- }
1220
- return line;
1221
- };
1222
- const styledLineWidth = (line) => {
1223
- let length = 0;
1224
- for (let i = 0; i < line.length; i++) {
1225
- length += inkCharacterWidth(line.getValue(i));
1226
- }
1227
- return length;
1228
- };
1229
- const splitStyledLineByNewline = (line) => {
1230
- if (line.length === 0) {
1231
- return [new StyledLine()];
1232
- }
1233
- const lines = [];
1234
- let start = 0;
1235
- for (let i = 0; i < line.length; i++) {
1236
- if (line.getValue(i) === "\n") {
1237
- lines.push(i > start ? line.slice(start, i) : new StyledLine());
1238
- start = i + 1;
1239
- }
1240
- }
1241
- lines.push(start < line.length ? line.slice(start) : new StyledLine());
1242
- return lines;
1243
- };
1244
- const measureStyledLine = (line) => {
1245
- if (line.length === 0) {
1246
- return { height: 0, width: 0 };
1247
- }
1248
- const lines = splitStyledLineByNewline(line);
1249
- let maxWidth = 0;
1250
- for (const l of lines) {
1251
- maxWidth = Math.max(maxWidth, styledLineWidth(l));
1252
- }
1253
- return { height: lines.length, width: maxWidth };
1254
- };
1255
-
1256
- export { BOLD_MASK as B, DIM_MASK as D, FULL_WIDTH_MASK as F, HIDDEN_MASK as H, ITALIC_MASK as I, StyledLine as S, UNDERLINE_MASK as U, clearStyledLineCache as a, setStringWidthFunction as b, clearStringWidthCache as c, styledLineWidth as d, INVERSE_MASK as e, STRIKETHROUGH_MASK as f, colorToSgrParams as g, colorToAnsi256 as h, inkCharacterWidth as i, textToStyledLine as j, measureStyledLine as k, splitStyledLineByNewline as l, measureText as m, plainTextToStyledLine as p, setEnableStyledLineCache as s, toStyledLine as t };