@promptctl/rich-js 0.10.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (410) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +20 -110
  3. package/THIRD-PARTY-NOTICES +81 -0
  4. package/dist/core/box.d.ts +0 -1
  5. package/dist/core/box.js +0 -1
  6. package/dist/core/cells.d.ts +0 -1
  7. package/dist/core/cells.js +0 -1
  8. package/dist/core/color.d.ts +6 -1
  9. package/dist/core/color.js +6 -1
  10. package/dist/core/console.d.ts +13 -4
  11. package/dist/core/console.js +78 -87
  12. package/dist/core/emoji.d.ts +0 -1
  13. package/dist/core/emoji.js +0 -1
  14. package/dist/core/export-html.d.ts +24 -0
  15. package/dist/core/export-html.js +106 -0
  16. package/dist/core/export-lines.d.ts +121 -0
  17. package/dist/core/export-lines.js +141 -0
  18. package/dist/core/highlighter.d.ts +0 -1
  19. package/dist/core/highlighter.js +0 -1
  20. package/dist/core/json.d.ts +0 -1
  21. package/dist/core/json.js +0 -1
  22. package/dist/core/markup.d.ts +33 -2
  23. package/dist/core/markup.js +128 -16
  24. package/dist/core/measure.d.ts +0 -1
  25. package/dist/core/measure.js +0 -1
  26. package/dist/core/oklch.d.ts +0 -1
  27. package/dist/core/oklch.js +0 -1
  28. package/dist/core/osc8.d.ts +68 -0
  29. package/dist/core/osc8.js +90 -0
  30. package/dist/core/pretty.d.ts +21 -2
  31. package/dist/core/pretty.js +90 -16
  32. package/dist/core/protocol.d.ts +18 -2
  33. package/dist/core/protocol.js +0 -1
  34. package/dist/core/render.d.ts +0 -1
  35. package/dist/core/render.js +3 -10
  36. package/dist/core/segment.d.ts +0 -1
  37. package/dist/core/segment.js +0 -1
  38. package/dist/core/spinnerData.d.ts +0 -1
  39. package/dist/core/spinnerData.js +0 -1
  40. package/dist/core/strip.d.ts +0 -1
  41. package/dist/core/strip.js +12 -1
  42. package/dist/core/style.d.ts +1 -7
  43. package/dist/core/style.js +84 -67
  44. package/dist/core/subscription.d.ts +0 -1
  45. package/dist/core/subscription.js +0 -1
  46. package/dist/core/text.d.ts +1 -8
  47. package/dist/core/text.js +25 -29
  48. package/dist/core/wrap.d.ts +0 -1
  49. package/dist/core/wrap.js +0 -1
  50. package/dist/host/host-stream.d.ts +0 -1
  51. package/dist/host/host-stream.js +0 -1
  52. package/dist/host/index.d.ts +0 -1
  53. package/dist/host/index.js +0 -1
  54. package/dist/host/terminal-host.d.ts +0 -1
  55. package/dist/host/terminal-host.js +0 -1
  56. package/dist/index.d.ts +4 -3
  57. package/dist/index.js +3 -2
  58. package/dist/node/prompt.d.ts +0 -1
  59. package/dist/node/prompt.js +0 -1
  60. package/dist/node/save.d.ts +2 -7
  61. package/dist/node/save.js +0 -1
  62. package/dist/node/terminal-host.d.ts +0 -1
  63. package/dist/node/terminal-host.js +0 -1
  64. package/dist/node/traceback.d.ts +0 -1
  65. package/dist/node/traceback.js +0 -1
  66. package/dist/renderables/align.d.ts +0 -1
  67. package/dist/renderables/align.js +0 -1
  68. package/dist/renderables/columns.d.ts +12 -1
  69. package/dist/renderables/columns.js +29 -5
  70. package/dist/renderables/constrain.d.ts +0 -1
  71. package/dist/renderables/constrain.js +0 -1
  72. package/dist/renderables/flexStrip.d.ts +0 -1
  73. package/dist/renderables/flexStrip.js +0 -1
  74. package/dist/renderables/group.d.ts +0 -1
  75. package/dist/renderables/group.js +0 -1
  76. package/dist/renderables/layout.d.ts +0 -1
  77. package/dist/renderables/layout.js +20 -7
  78. package/dist/renderables/live.d.ts +0 -1
  79. package/dist/renderables/live.js +0 -1
  80. package/dist/renderables/markdown.d.ts +0 -1
  81. package/dist/renderables/markdown.js +0 -1
  82. package/dist/renderables/padding.d.ts +0 -1
  83. package/dist/renderables/padding.js +0 -1
  84. package/dist/renderables/panel.d.ts +0 -1
  85. package/dist/renderables/panel.js +12 -4
  86. package/dist/renderables/progress.d.ts +0 -1
  87. package/dist/renderables/progress.js +7 -2
  88. package/dist/renderables/progressBar.d.ts +0 -1
  89. package/dist/renderables/progressBar.js +0 -1
  90. package/dist/renderables/prompt.d.ts +0 -1
  91. package/dist/renderables/prompt.js +0 -1
  92. package/dist/renderables/rule.d.ts +0 -1
  93. package/dist/renderables/rule.js +0 -1
  94. package/dist/renderables/spinner.d.ts +0 -1
  95. package/dist/renderables/spinner.js +0 -1
  96. package/dist/renderables/status.d.ts +0 -1
  97. package/dist/renderables/status.js +0 -1
  98. package/dist/renderables/syntax.d.ts +0 -1
  99. package/dist/renderables/syntax.js +0 -1
  100. package/dist/renderables/table.d.ts +0 -1
  101. package/dist/renderables/table.js +8 -3
  102. package/dist/renderables/traceback.d.ts +8 -7
  103. package/dist/renderables/traceback.js +14 -10
  104. package/dist/renderables/tree.d.ts +0 -1
  105. package/dist/renderables/tree.js +0 -1
  106. package/dist/template-bindings/color-funcs.d.ts +0 -1
  107. package/dist/template-bindings/color-funcs.js +0 -1
  108. package/dist/template-bindings/helpers.d.ts +0 -1
  109. package/dist/template-bindings/helpers.js +0 -1
  110. package/dist/template-bindings/index.d.ts +0 -1
  111. package/dist/template-bindings/index.js +0 -1
  112. package/dist/template-bindings/palette-funcs.d.ts +0 -1
  113. package/dist/template-bindings/palette-funcs.js +0 -1
  114. package/dist/template-bindings/style-funcs.d.ts +0 -1
  115. package/dist/template-bindings/style-funcs.js +0 -1
  116. package/dist/themes/buildPalette.d.ts +0 -1
  117. package/dist/themes/buildPalette.js +0 -1
  118. package/dist/themes/colorMath.d.ts +0 -1
  119. package/dist/themes/colorMath.js +0 -1
  120. package/dist/themes/colorRef.d.ts +0 -1
  121. package/dist/themes/colorRef.js +0 -1
  122. package/dist/themes/data/atom-one-dark.d.ts +0 -1
  123. package/dist/themes/data/atom-one-dark.js +0 -1
  124. package/dist/themes/data/atom-one-light.d.ts +0 -1
  125. package/dist/themes/data/atom-one-light.js +0 -1
  126. package/dist/themes/data/catppuccin-frappe.d.ts +0 -1
  127. package/dist/themes/data/catppuccin-frappe.js +0 -1
  128. package/dist/themes/data/catppuccin-latte.d.ts +0 -1
  129. package/dist/themes/data/catppuccin-latte.js +0 -1
  130. package/dist/themes/data/catppuccin-macchiato.d.ts +0 -1
  131. package/dist/themes/data/catppuccin-macchiato.js +0 -1
  132. package/dist/themes/data/catppuccin-mocha.d.ts +0 -1
  133. package/dist/themes/data/catppuccin-mocha.js +0 -1
  134. package/dist/themes/data/cyberpunk.d.ts +0 -1
  135. package/dist/themes/data/cyberpunk.js +0 -1
  136. package/dist/themes/data/default.d.ts +0 -1
  137. package/dist/themes/data/default.js +0 -1
  138. package/dist/themes/data/dracula.d.ts +0 -1
  139. package/dist/themes/data/dracula.js +0 -1
  140. package/dist/themes/data/flexoki.d.ts +0 -1
  141. package/dist/themes/data/flexoki.js +0 -1
  142. package/dist/themes/data/gruvbox.d.ts +0 -1
  143. package/dist/themes/data/gruvbox.js +0 -1
  144. package/dist/themes/data/index.d.ts +0 -1
  145. package/dist/themes/data/index.js +0 -1
  146. package/dist/themes/data/monokai.d.ts +0 -1
  147. package/dist/themes/data/monokai.js +0 -1
  148. package/dist/themes/data/nord.d.ts +0 -1
  149. package/dist/themes/data/nord.js +0 -1
  150. package/dist/themes/data/rose-pine-dawn.d.ts +0 -1
  151. package/dist/themes/data/rose-pine-dawn.js +0 -1
  152. package/dist/themes/data/rose-pine-moon.d.ts +0 -1
  153. package/dist/themes/data/rose-pine-moon.js +0 -1
  154. package/dist/themes/data/rose-pine.d.ts +0 -1
  155. package/dist/themes/data/rose-pine.js +0 -1
  156. package/dist/themes/data/solarized-dark.d.ts +0 -1
  157. package/dist/themes/data/solarized-dark.js +0 -1
  158. package/dist/themes/data/solarized-light.d.ts +0 -1
  159. package/dist/themes/data/solarized-light.js +0 -1
  160. package/dist/themes/data/svg-export.d.ts +0 -1
  161. package/dist/themes/data/svg-export.js +0 -1
  162. package/dist/themes/data/textual-ansi.d.ts +0 -1
  163. package/dist/themes/data/textual-ansi.js +0 -1
  164. package/dist/themes/data/textual-dark.d.ts +0 -1
  165. package/dist/themes/data/textual-dark.js +0 -1
  166. package/dist/themes/data/textual-light.d.ts +0 -1
  167. package/dist/themes/data/textual-light.js +0 -1
  168. package/dist/themes/data/tokyo-night.d.ts +0 -1
  169. package/dist/themes/data/tokyo-night.js +0 -1
  170. package/dist/themes/data/types.d.ts +0 -1
  171. package/dist/themes/data/types.js +0 -1
  172. package/dist/themes/palette.d.ts +0 -1
  173. package/dist/themes/palette.js +0 -1
  174. package/dist/themes/ramp.d.ts +0 -1
  175. package/dist/themes/ramp.js +0 -1
  176. package/dist/themes/registry.d.ts +0 -1
  177. package/dist/themes/registry.js +0 -1
  178. package/dist/themes/terminalThemes.d.ts +0 -1
  179. package/dist/themes/terminalThemes.js +0 -1
  180. package/dist/themes/transpose.d.ts +0 -1
  181. package/dist/themes/transpose.js +0 -1
  182. package/dist/widgets/button.d.ts +0 -1
  183. package/dist/widgets/button.js +0 -1
  184. package/dist/widgets/checkbox.d.ts +0 -1
  185. package/dist/widgets/checkbox.js +0 -1
  186. package/dist/widgets/dropdown.d.ts +0 -1
  187. package/dist/widgets/dropdown.js +0 -1
  188. package/dist/widgets/event-router.d.ts +0 -1
  189. package/dist/widgets/event-router.js +0 -1
  190. package/dist/widgets/focus-manager.d.ts +0 -1
  191. package/dist/widgets/focus-manager.js +0 -1
  192. package/dist/widgets/index.d.ts +0 -1
  193. package/dist/widgets/index.js +0 -1
  194. package/dist/widgets/screen.d.ts +0 -1
  195. package/dist/widgets/screen.js +0 -1
  196. package/dist/widgets/slider.d.ts +0 -1
  197. package/dist/widgets/slider.js +0 -1
  198. package/dist/widgets/static-item.d.ts +0 -1
  199. package/dist/widgets/static-item.js +0 -1
  200. package/dist/widgets/text-input.d.ts +0 -1
  201. package/dist/widgets/text-input.js +0 -1
  202. package/dist/widgets/toggle.d.ts +0 -1
  203. package/dist/widgets/toggle.js +0 -1
  204. package/dist/widgets/types.d.ts +0 -1
  205. package/dist/widgets/types.js +0 -1
  206. package/dist/widgets/widget-base.d.ts +0 -1
  207. package/dist/widgets/widget-base.js +0 -1
  208. package/package.json +4 -3
  209. package/dist/core/box.d.ts.map +0 -1
  210. package/dist/core/box.js.map +0 -1
  211. package/dist/core/cells.d.ts.map +0 -1
  212. package/dist/core/cells.js.map +0 -1
  213. package/dist/core/color.d.ts.map +0 -1
  214. package/dist/core/color.js.map +0 -1
  215. package/dist/core/console.d.ts.map +0 -1
  216. package/dist/core/console.js.map +0 -1
  217. package/dist/core/emoji.d.ts.map +0 -1
  218. package/dist/core/emoji.js.map +0 -1
  219. package/dist/core/highlighter.d.ts.map +0 -1
  220. package/dist/core/highlighter.js.map +0 -1
  221. package/dist/core/json.d.ts.map +0 -1
  222. package/dist/core/json.js.map +0 -1
  223. package/dist/core/markup.d.ts.map +0 -1
  224. package/dist/core/markup.js.map +0 -1
  225. package/dist/core/measure.d.ts.map +0 -1
  226. package/dist/core/measure.js.map +0 -1
  227. package/dist/core/oklch.d.ts.map +0 -1
  228. package/dist/core/oklch.js.map +0 -1
  229. package/dist/core/pretty.d.ts.map +0 -1
  230. package/dist/core/pretty.js.map +0 -1
  231. package/dist/core/protocol.d.ts.map +0 -1
  232. package/dist/core/protocol.js.map +0 -1
  233. package/dist/core/render.d.ts.map +0 -1
  234. package/dist/core/render.js.map +0 -1
  235. package/dist/core/sanitize.d.ts +0 -16
  236. package/dist/core/sanitize.d.ts.map +0 -1
  237. package/dist/core/sanitize.js +0 -19
  238. package/dist/core/sanitize.js.map +0 -1
  239. package/dist/core/segment.d.ts.map +0 -1
  240. package/dist/core/segment.js.map +0 -1
  241. package/dist/core/spinnerData.d.ts.map +0 -1
  242. package/dist/core/spinnerData.js.map +0 -1
  243. package/dist/core/strip.d.ts.map +0 -1
  244. package/dist/core/strip.js.map +0 -1
  245. package/dist/core/style.d.ts.map +0 -1
  246. package/dist/core/style.js.map +0 -1
  247. package/dist/core/subscription.d.ts.map +0 -1
  248. package/dist/core/subscription.js.map +0 -1
  249. package/dist/core/text.d.ts.map +0 -1
  250. package/dist/core/text.js.map +0 -1
  251. package/dist/core/wrap.d.ts.map +0 -1
  252. package/dist/core/wrap.js.map +0 -1
  253. package/dist/host/host-stream.d.ts.map +0 -1
  254. package/dist/host/host-stream.js.map +0 -1
  255. package/dist/host/index.d.ts.map +0 -1
  256. package/dist/host/index.js.map +0 -1
  257. package/dist/host/terminal-host.d.ts.map +0 -1
  258. package/dist/host/terminal-host.js.map +0 -1
  259. package/dist/index.d.ts.map +0 -1
  260. package/dist/index.js.map +0 -1
  261. package/dist/node/prompt.d.ts.map +0 -1
  262. package/dist/node/prompt.js.map +0 -1
  263. package/dist/node/save.d.ts.map +0 -1
  264. package/dist/node/save.js.map +0 -1
  265. package/dist/node/terminal-host.d.ts.map +0 -1
  266. package/dist/node/terminal-host.js.map +0 -1
  267. package/dist/node/traceback.d.ts.map +0 -1
  268. package/dist/node/traceback.js.map +0 -1
  269. package/dist/renderables/align.d.ts.map +0 -1
  270. package/dist/renderables/align.js.map +0 -1
  271. package/dist/renderables/columns.d.ts.map +0 -1
  272. package/dist/renderables/columns.js.map +0 -1
  273. package/dist/renderables/constrain.d.ts.map +0 -1
  274. package/dist/renderables/constrain.js.map +0 -1
  275. package/dist/renderables/flexStrip.d.ts.map +0 -1
  276. package/dist/renderables/flexStrip.js.map +0 -1
  277. package/dist/renderables/group.d.ts.map +0 -1
  278. package/dist/renderables/group.js.map +0 -1
  279. package/dist/renderables/layout.d.ts.map +0 -1
  280. package/dist/renderables/layout.js.map +0 -1
  281. package/dist/renderables/live.d.ts.map +0 -1
  282. package/dist/renderables/live.js.map +0 -1
  283. package/dist/renderables/markdown.d.ts.map +0 -1
  284. package/dist/renderables/markdown.js.map +0 -1
  285. package/dist/renderables/padding.d.ts.map +0 -1
  286. package/dist/renderables/padding.js.map +0 -1
  287. package/dist/renderables/panel.d.ts.map +0 -1
  288. package/dist/renderables/panel.js.map +0 -1
  289. package/dist/renderables/progress.d.ts.map +0 -1
  290. package/dist/renderables/progress.js.map +0 -1
  291. package/dist/renderables/progressBar.d.ts.map +0 -1
  292. package/dist/renderables/progressBar.js.map +0 -1
  293. package/dist/renderables/prompt.d.ts.map +0 -1
  294. package/dist/renderables/prompt.js.map +0 -1
  295. package/dist/renderables/rule.d.ts.map +0 -1
  296. package/dist/renderables/rule.js.map +0 -1
  297. package/dist/renderables/spinner.d.ts.map +0 -1
  298. package/dist/renderables/spinner.js.map +0 -1
  299. package/dist/renderables/status.d.ts.map +0 -1
  300. package/dist/renderables/status.js.map +0 -1
  301. package/dist/renderables/syntax.d.ts.map +0 -1
  302. package/dist/renderables/syntax.js.map +0 -1
  303. package/dist/renderables/table.d.ts.map +0 -1
  304. package/dist/renderables/table.js.map +0 -1
  305. package/dist/renderables/traceback.d.ts.map +0 -1
  306. package/dist/renderables/traceback.js.map +0 -1
  307. package/dist/renderables/tree.d.ts.map +0 -1
  308. package/dist/renderables/tree.js.map +0 -1
  309. package/dist/template-bindings/color-funcs.d.ts.map +0 -1
  310. package/dist/template-bindings/color-funcs.js.map +0 -1
  311. package/dist/template-bindings/helpers.d.ts.map +0 -1
  312. package/dist/template-bindings/helpers.js.map +0 -1
  313. package/dist/template-bindings/index.d.ts.map +0 -1
  314. package/dist/template-bindings/index.js.map +0 -1
  315. package/dist/template-bindings/palette-funcs.d.ts.map +0 -1
  316. package/dist/template-bindings/palette-funcs.js.map +0 -1
  317. package/dist/template-bindings/style-funcs.d.ts.map +0 -1
  318. package/dist/template-bindings/style-funcs.js.map +0 -1
  319. package/dist/themes/buildPalette.d.ts.map +0 -1
  320. package/dist/themes/buildPalette.js.map +0 -1
  321. package/dist/themes/colorMath.d.ts.map +0 -1
  322. package/dist/themes/colorMath.js.map +0 -1
  323. package/dist/themes/colorRef.d.ts.map +0 -1
  324. package/dist/themes/colorRef.js.map +0 -1
  325. package/dist/themes/data/atom-one-dark.d.ts.map +0 -1
  326. package/dist/themes/data/atom-one-dark.js.map +0 -1
  327. package/dist/themes/data/atom-one-light.d.ts.map +0 -1
  328. package/dist/themes/data/atom-one-light.js.map +0 -1
  329. package/dist/themes/data/catppuccin-frappe.d.ts.map +0 -1
  330. package/dist/themes/data/catppuccin-frappe.js.map +0 -1
  331. package/dist/themes/data/catppuccin-latte.d.ts.map +0 -1
  332. package/dist/themes/data/catppuccin-latte.js.map +0 -1
  333. package/dist/themes/data/catppuccin-macchiato.d.ts.map +0 -1
  334. package/dist/themes/data/catppuccin-macchiato.js.map +0 -1
  335. package/dist/themes/data/catppuccin-mocha.d.ts.map +0 -1
  336. package/dist/themes/data/catppuccin-mocha.js.map +0 -1
  337. package/dist/themes/data/cyberpunk.d.ts.map +0 -1
  338. package/dist/themes/data/cyberpunk.js.map +0 -1
  339. package/dist/themes/data/default.d.ts.map +0 -1
  340. package/dist/themes/data/default.js.map +0 -1
  341. package/dist/themes/data/dracula.d.ts.map +0 -1
  342. package/dist/themes/data/dracula.js.map +0 -1
  343. package/dist/themes/data/flexoki.d.ts.map +0 -1
  344. package/dist/themes/data/flexoki.js.map +0 -1
  345. package/dist/themes/data/gruvbox.d.ts.map +0 -1
  346. package/dist/themes/data/gruvbox.js.map +0 -1
  347. package/dist/themes/data/index.d.ts.map +0 -1
  348. package/dist/themes/data/index.js.map +0 -1
  349. package/dist/themes/data/monokai.d.ts.map +0 -1
  350. package/dist/themes/data/monokai.js.map +0 -1
  351. package/dist/themes/data/nord.d.ts.map +0 -1
  352. package/dist/themes/data/nord.js.map +0 -1
  353. package/dist/themes/data/rose-pine-dawn.d.ts.map +0 -1
  354. package/dist/themes/data/rose-pine-dawn.js.map +0 -1
  355. package/dist/themes/data/rose-pine-moon.d.ts.map +0 -1
  356. package/dist/themes/data/rose-pine-moon.js.map +0 -1
  357. package/dist/themes/data/rose-pine.d.ts.map +0 -1
  358. package/dist/themes/data/rose-pine.js.map +0 -1
  359. package/dist/themes/data/solarized-dark.d.ts.map +0 -1
  360. package/dist/themes/data/solarized-dark.js.map +0 -1
  361. package/dist/themes/data/solarized-light.d.ts.map +0 -1
  362. package/dist/themes/data/solarized-light.js.map +0 -1
  363. package/dist/themes/data/svg-export.d.ts.map +0 -1
  364. package/dist/themes/data/svg-export.js.map +0 -1
  365. package/dist/themes/data/textual-ansi.d.ts.map +0 -1
  366. package/dist/themes/data/textual-ansi.js.map +0 -1
  367. package/dist/themes/data/textual-dark.d.ts.map +0 -1
  368. package/dist/themes/data/textual-dark.js.map +0 -1
  369. package/dist/themes/data/textual-light.d.ts.map +0 -1
  370. package/dist/themes/data/textual-light.js.map +0 -1
  371. package/dist/themes/data/tokyo-night.d.ts.map +0 -1
  372. package/dist/themes/data/tokyo-night.js.map +0 -1
  373. package/dist/themes/data/types.d.ts.map +0 -1
  374. package/dist/themes/data/types.js.map +0 -1
  375. package/dist/themes/palette.d.ts.map +0 -1
  376. package/dist/themes/palette.js.map +0 -1
  377. package/dist/themes/ramp.d.ts.map +0 -1
  378. package/dist/themes/ramp.js.map +0 -1
  379. package/dist/themes/registry.d.ts.map +0 -1
  380. package/dist/themes/registry.js.map +0 -1
  381. package/dist/themes/terminalThemes.d.ts.map +0 -1
  382. package/dist/themes/terminalThemes.js.map +0 -1
  383. package/dist/themes/transpose.d.ts.map +0 -1
  384. package/dist/themes/transpose.js.map +0 -1
  385. package/dist/widgets/button.d.ts.map +0 -1
  386. package/dist/widgets/button.js.map +0 -1
  387. package/dist/widgets/checkbox.d.ts.map +0 -1
  388. package/dist/widgets/checkbox.js.map +0 -1
  389. package/dist/widgets/dropdown.d.ts.map +0 -1
  390. package/dist/widgets/dropdown.js.map +0 -1
  391. package/dist/widgets/event-router.d.ts.map +0 -1
  392. package/dist/widgets/event-router.js.map +0 -1
  393. package/dist/widgets/focus-manager.d.ts.map +0 -1
  394. package/dist/widgets/focus-manager.js.map +0 -1
  395. package/dist/widgets/index.d.ts.map +0 -1
  396. package/dist/widgets/index.js.map +0 -1
  397. package/dist/widgets/screen.d.ts.map +0 -1
  398. package/dist/widgets/screen.js.map +0 -1
  399. package/dist/widgets/slider.d.ts.map +0 -1
  400. package/dist/widgets/slider.js.map +0 -1
  401. package/dist/widgets/static-item.d.ts.map +0 -1
  402. package/dist/widgets/static-item.js.map +0 -1
  403. package/dist/widgets/text-input.d.ts.map +0 -1
  404. package/dist/widgets/text-input.js.map +0 -1
  405. package/dist/widgets/toggle.d.ts.map +0 -1
  406. package/dist/widgets/toggle.js.map +0 -1
  407. package/dist/widgets/types.d.ts.map +0 -1
  408. package/dist/widgets/types.js.map +0 -1
  409. package/dist/widgets/widget-base.d.ts.map +0 -1
  410. package/dist/widgets/widget-base.js.map +0 -1
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Brandon Fryslie
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -261,7 +261,7 @@ console.print(syntax);
261
261
  <details>
262
262
  <summary>Tracebacks</summary>
263
263
 
264
- Rich can render beautiful tracebacks that are easier to read and show more context than standard Node.js errors:
264
+ Rich can print an error as its name and message followed by one line per stack frame, with library frames suppressed on request:
265
265
 
266
266
  ```typescript
267
267
  import { Console, Traceback } from "@promptctl/rich-js";
@@ -379,120 +379,30 @@ saveHtml(console, "output.html");
379
379
 
380
380
  ## Demos
381
381
 
382
- Every demo below also runs in your browser on the [live demo gallery](https://brandon-fryslie.github.io/rich-js/master/demos/) — the same code mounted against an xterm.js terminal, nothing to install. To drive one against your own terminal instead, run its npm script:
382
+ The [live demo gallery](https://brandon-fryslie.github.io/rich-js/master/demos/) runs every demo in your browser, against an xterm.js terminal — the same code that runs under Node, with nothing to install. Each gallery page links to the demo's source in [`examples/`](https://github.com/brandon-fryslie/rich-js/tree/master/examples), which is the place to look for working code to copy.
383
383
 
384
- ```sh
385
- # Interactive
386
- npm run demo # rich-explore — TUI file browser + markdown/code reader
387
- npm run sessions # claude-sessions — Claude Code session browser
388
- npm run demo-inputs # rich-config — TextInput / palette search
389
- npm run demo:dropdown # dropdown-demo — Dropdown widget showcase
390
- npm run dash # rich-dash — Live dashboard
391
- npm run template-bindings # rich-template-bindings — go-template / reactive bindings playground
392
-
393
- # Non-interactive transcripts
394
- npm run themes-and-color-studio # color / palette / theme / contrast tour (eight sections)
395
- npm run strip # rich-strip — side-by-side joiner showcase
396
- npm run markup-plugins # rich-markup-plugins — plugin-tag examples
397
- ```
398
-
399
- `rich-explore`, `claude-sessions`, and `themes-and-color-studio` are covered in detail below. `package.json` holds the authoritative script list — `jq .scripts package.json` to see it.
400
-
401
- ### rich-explore — TUI file browser + markdown/code reader
402
-
403
- A two-pane file browser with a directory tree on the left and a file preview on the right. Navigate with vim-style keys, Tab to switch focus, Enter/arrow keys to expand/collapse directories.
404
-
405
- ```sh
406
- npm run demo # browse current directory
407
- npm run demo -- /some/path # browse a specific path
408
- ```
409
-
410
- **Features exercised:**
411
-
412
- | Module | How it's used |
413
- |---|---|
414
- | `Console` | Render orchestrator, style application, color-system detection |
415
- | `Layout` | Row split (tree / preview), column split (header / body / footer), `ratio` and `size` allocation |
416
- | `Panel` | Bordered panes with dynamic titles (`▸ Tree (20)`), `borderStyle`, `padding`, focus-aware styling |
417
- | `Tree` | Recursive directory tree with guide lines, `guide_style`, mixed RichText labels |
418
- | `Table` + `Column` | Directory listing (name, kind, size, mtime), styled headers, right-justified columns |
419
- | `Markdown` | Renders `.md` files in the preview pane |
420
- | `Syntax` | Syntax-highlighted source code with `lineNumbers` and per-extension language detection |
421
- | `JSONRenderable` | Pretty-printed + highlighted JSON file preview |
422
- | `RichText` + `Span` | Labels, headers, status bar; `.stylize()`, `.append()`, `end` control |
423
- | `Style` | Parsed inline everywhere (`"bold cyan"`, `"reverse bold"`, `"bold white on blue"`) |
424
- | `Segment` | Used directly in the `Window` renderable for line splitting, padding, and clipping |
425
- | `Renderable` protocol | Custom `Window` class implements `Renderable` for viewport clipping |
426
- | `Box` | `ROUNDED` (Panel default), `HEAVY_HEAD` (Table default) |
427
-
428
- ### claude-sessions — Claude Code session browser
429
-
430
- Browses `~/.claude/projects/` JSONL session files. Two-level sidebar (projects → sessions) on top, conversation viewer below. Pretty-prints every block type (human turns, assistant responses, tool calls, subagents, system events, errors) with per-block raw-JSON toggle. Includes local search, global cross-file search, subagent drill-down with session stack, and hidden-block reveal.
431
-
432
- ```sh
433
- npm run sessions
434
- ```
435
-
436
- **Key bindings:** `↑↓/jk` navigate, `→/Enter` open/drill, `←` back, `Tab` focus, `\` toggle browser, `v` raw view, `e` expand, `H` hidden blocks, `/` local search, `S` global search, `n/N` next/prev match, `p` parent, `u` pop subagent, `q` quit.
437
-
438
- **Features exercised (incremental to rich-explore):**
439
-
440
- | Module | How it's used |
441
- |---|---|
442
- | `Rule` | Turn-duration system blocks rendered as horizontal dividers; input/output separators in tool-call blocks |
443
- | `Group` | Composes multi-section tool-call blocks (input + Rule + result) into a single renderable |
444
- | `Pretty` | Per-block raw view (toggled with `v`) — exercises `ReprHighlighter`, indent guides, `maxString`, `expandAll` |
445
- | `Traceback` | Error blocks with stack traces render via `Traceback` for styled frame display |
446
- | `Markdown` | Assistant text rendering (Claude output is often markdown) |
447
- | `Syntax` | Bash command highlighting in tool-call input summaries |
448
- | `Panel` | Six distinct border-color schemes by block kind (cyan/blue/yellow/red/magenta/green) |
449
- | `Layout` | Column split (browser-on-top / viewer-on-bottom), dynamic height budgeting |
450
-
451
- ### themes-and-color-studio — color, palette, theme, and contrast tour
452
-
453
- A one-shot non-interactive demo that walks every public surface of the color subsystem in eight sections: ColorRgba values and parsing, ColorSpec and downgrade tables, color-system detection, the theme registry, colour references through `resolveColorRef`, every bundled `TerminalTheme` constant, OKLCH transposition (hue circle / chroma sweep / lightness invert / themeKeyForRoot), and the WCAG contrast toolkit.
384
+ To run a demo in your own terminal instead, clone the repository, install, and use the demo's npm script:
454
385
 
455
386
  ```sh
456
- npm run themes-and-color-studio # terminal output
457
- EXPORT_HTML=out.html npm run themes-and-color-studio # also write a styled HTML transcript
387
+ git clone https://github.com/brandon-fryslie/rich-js.git
388
+ cd rich-js
389
+ npm install
390
+ npm run demo
458
391
  ```
459
392
 
460
- **Features exercised (incremental to above):**
461
-
462
- | Module | How it's used |
463
- |---|---|
464
- | `ColorRgba` / `parseRgbHex` / `parseRgbaHex` / `blendRgb` | Pixel-level values, two hex parsers, linear blend, alpha compositing |
465
- | `ColorSpec` / `ColorDepth` | Every factory; downgrade across `STANDARD_TABLE` / `EIGHT_BIT_TABLE` / `WINDOWS_TABLE`; `ANSI_COLOR_NAMES` lookups; `ColorParseError` |
466
- | `detectColorSystem` / `resolveColorSystem` | Env-driven color-system detection with `DetectColorOptions` fixtures; spec-string resolution |
467
- | `Palette` / `resolveColorRef` / `parseHexColor` / `buildPalette` | Palette names and `#RRGGBB` literals through one checkpoint against gruvbox, including the hex round-trip that shows it is idempotent and the `ColorRefError` miss; `BaseColors` → derived `text-*` / `on-*` / `*-muted` vars |
468
- | Theme registry | `getThemePalette` / `listThemePalettes` / `getThemeBaseColors` walking every bundled theme; raw `THEMES` / `ThemePaletteData` via subpath |
469
- | `TerminalTheme` constants | All bundled constants (`DEFAULT`, `SVG_EXPORT`, `MONOKAI`, `NORD`, `GRUVBOX`, `DRACULA`, `TOKYO_NIGHT`, `FLEXOKI`, `CYBERPUNK`, `CATPPUCCIN_*`, `SOLARIZED_*`, `ROSE_PINE*`, `ATOM_ONE_*`, `TEXTUAL_*`) |
470
- | `Oklch` / `transposePalette` / `themeKeyForRoot` | Round-trip + `IDENTITY` / `INVERT_LIGHTNESS`; hue circle; chroma sweep; light↔dark invert; `ANCHORED_ROOTS` / `isAnchored` |
471
- | `relativeLuminance` / `contrastRatio` / `contrastFor` / `ensureContrast` | WCAG contrast matrix, hue-preserving lightness adjustment to clear the AA threshold |
472
- | `Console` record / `saveHtml` | Optional HTML export via `EXPORT_HTML=path`; same render pipeline drives both terminal and file output |
473
-
474
- ---
475
-
476
- ### Demo coverage is checked, not claimed
477
-
478
- `test/coverage/coverage.test.ts` asserts that every public export is referenced by at least one file under `examples/`. Add a public export without demoing it and CI fails.
479
-
480
- The check builds its universe from `package.json#exports` when the test loads, so there is no hand-written list of covered symbols to maintain — and none to drift out of date. Coverage is counted per *symbol origin*, meaning the declaring file plus the declared name, so one declaration re-exported under two names is still one thing to demonstrate. Renaming a symbol on import inside a demo still counts; `import * as rich` does not, because a namespace import never names what it pulls in.
481
-
482
- An export that genuinely cannot be demonstrated at runtime belongs in `test/coverage/coverage-allowlist.ts` with a written reason. The allowlist is validated in both directions: an entry pointing at no real export fails the suite, and so does an entry for something a demo now covers. You can neither widen the exemption quietly nor leave a stale one lying around.
483
-
484
- Two things to know before adding a demo. `examples/shared/` is a helper module rather than a demo, and references from it count — the verifier walks every file under `examples/`, not just the entry points. And a demo reaches the browser gallery only if it has an `examples/<name>/wire.ts`; `npm run demos:build` fails loudly when a `wire.ts` has no compiled output rather than dropping the demo from the site.
485
-
486
- That check is a floor, not a goal. A script that imports thirty exports and prints them in sequence passes it; a small interactive TUI that lets you drive eight of them in a real composition is the better demo, and no test can tell you which one you wrote.
487
-
488
- **Bugs found and fixed via demo integration** — the argument for exercising the library this way rather than only in unit tests:
489
-
490
- | Bug | Location | Impact | Fix |
491
- |---|---|---|---|
492
- | `Live.refresh()` strips all ANSI styles | `Live.refresh` in `src/renderables/live.ts` | Every renderable flowing through `Live` (including `Status`, `Progress`, `Spinner`) appeared unstyled | Apply `style.render(text, colorSystem)` instead of bare `s.text` |
493
- | `Progress.render()` drops column styles | `Progress.render` in `src/renderables/progress.ts` | Progress percentage, timing, and spinner styles were stripped when building table cells | Use `RichText.append(text, style)` to preserve segment styles |
494
- | `Tree` emits double blank lines | `Tree.render` in `src/renderables/tree.ts` | Label rendering and the explicit `Segment.line()` both contributed a newline, producing blank lines between tree entries | Make `RichText` stop emitting a trailing newline so `Tree`'s explicit `yield Segment.line()` remains the only line break |
495
- | `Spinner` constructor rejects `undefined` name | `Spinner` constructor in `src/renderables/spinner.ts` | `SpinnerColumn` (used by `Progress`) passed optional `string \| undefined` to required `string` parameter | Make `name` optional, default to `DEFAULT_SPINNER` |
393
+ | Script | Demo | What it shows |
394
+ |---|---|---|
395
+ | `npm run demo` | rich-explore | A file browser: a directory tree beside a Markdown, source-code, or JSON preview. `npm run demo -- <path>` browses somewhere other than the current directory. |
396
+ | `npm run sessions` | claude-sessions | A reader for the Claude Code session logs under `~/.claude/projects/`, with search across files. |
397
+ | `npm run dash` | rich-dash | A live dashboard: system stats, a running job, and this README rendered as Markdown. |
398
+ | `npm run demo-inputs` | rich-config | The widgets — checkbox, toggle, slider, dropdown, text input, button — driving a theme and palette viewer. |
399
+ | `npm run demo:dropdown` | dropdown-demo | Three `Dropdown` widgets: a plain one, one filtered as you type, and one whose options change every few seconds. |
400
+ | `npm run template-bindings` | rich-template-bindings | Type a template on the left and watch it render on the right. |
401
+ | `npm run themes-and-color-studio` | themes-and-color-studio | A printed tour of colours, palettes, bundled themes, and contrast. Prints once and exits; set `EXPORT_HTML=out.html` to save it as HTML too. |
402
+ | `npm run strip` | rich-strip | Every built-in `Joiner`, printed side by side. Prints once and exits. |
403
+ | `npm run markup-plugins` | rich-markup-plugins | Custom markup tags registered through `MarkupRegistry`. Prints once and exits. |
404
+
405
+ `Ctrl-C` quits any demo that stays running.
496
406
 
497
407
  ## Environment Variables
498
408
 
@@ -0,0 +1,81 @@
1
+ Third-party notices for @promptctl/rich-js
2
+
3
+ This package contains material from the three projects below. All are
4
+ distributed under the MIT License, which requires their copyright and
5
+ permission notices to travel with every copy; they are reproduced here
6
+ unchanged. The license for rich-js itself is in LICENSE.
7
+
8
+ -------------------------------------------------------------------------------
9
+ Rich
10
+ https://github.com/Textualize/rich
11
+
12
+ rich-js is a TypeScript port of Rich. Its API, its rendering behaviour, and
13
+ much of its implementation follow Rich's Python source.
14
+
15
+ Copyright (c) 2020 Will McGugan
16
+
17
+ Permission is hereby granted, free of charge, to any person obtaining a copy
18
+ of this software and associated documentation files (the "Software"), to deal
19
+ in the Software without restriction, including without limitation the rights
20
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
21
+ copies of the Software, and to permit persons to whom the Software is
22
+ furnished to do so, subject to the following conditions:
23
+
24
+ The above copyright notice and this permission notice shall be included in all
25
+ copies or substantial portions of the Software.
26
+
27
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
28
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
29
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
30
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
31
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
32
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33
+ SOFTWARE.
34
+
35
+ -------------------------------------------------------------------------------
36
+ Textual
37
+ https://github.com/Textualize/textual
38
+
39
+ Most of the bundled themes come from Textual, along with the formulas
40
+ buildPalette uses to derive a full palette from a theme's base colours.
41
+
42
+ MIT License
43
+
44
+ Copyright (c) 2021 Will McGugan
45
+
46
+ Permission is hereby granted, free of charge, to any person obtaining a copy
47
+ of this software and associated documentation files (the "Software"), to deal
48
+ in the Software without restriction, including without limitation the rights
49
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
50
+ copies of the Software, and to permit persons to whom the Software is
51
+ furnished to do so, subject to the following conditions:
52
+
53
+ The above copyright notice and this permission notice shall be included in all
54
+ copies or substantial portions of the Software.
55
+
56
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
57
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
58
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
59
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
60
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
61
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
62
+ SOFTWARE.
63
+
64
+ -------------------------------------------------------------------------------
65
+ cli-spinners
66
+ https://github.com/sindresorhus/cli-spinners
67
+
68
+ The built-in spinners - their names, frames, and intervals - come from
69
+ cli-spinners. They arrived by way of Rich, which carries this same notice for
70
+ them.
71
+
72
+ MIT License
73
+
74
+ Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
75
+
76
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
77
+
78
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
79
+
80
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
81
+
@@ -142,4 +142,3 @@ export declare const HEAVY_HEAD: Box;
142
142
  export declare const DOUBLE: Box;
143
143
  export declare const DOUBLE_EDGE: Box;
144
144
  export declare const MARKDOWN: Box;
145
- //# sourceMappingURL=box.d.ts.map
package/dist/core/box.js CHANGED
@@ -389,4 +389,3 @@ const PLAIN_HEADED_SUBSTITUTIONS = [
389
389
  [MINIMAL_DOUBLE_HEAD, MINIMAL],
390
390
  [ASCII_DOUBLE_HEAD, ASCII2],
391
391
  ];
392
- //# sourceMappingURL=box.js.map
@@ -146,4 +146,3 @@ export declare function nextCodePoint(s: string, cu: CodeUnit): CodePoint;
146
146
  */
147
147
  export declare function prevCodePoint(s: string, cu: CodeUnit): CodePoint;
148
148
  export {};
149
- //# sourceMappingURL=cells.d.ts.map
@@ -264,4 +264,3 @@ function cropToWidth(text, targetWidth) {
264
264
  const diff = targetWidth - width;
265
265
  return diff > 0 ? cropped + " ".repeat(diff) : cropped;
266
266
  }
267
- //# sourceMappingURL=cells.js.map
@@ -155,4 +155,9 @@ export declare const STANDARD_TABLE: ColorTable;
155
155
  export declare const EIGHT_BIT_TABLE: ColorTable;
156
156
  export declare const WINDOWS_TABLE: ColorTable;
157
157
  export declare const ANSI_COLOR_NAMES: Record<string, number>;
158
- //# sourceMappingURL=color.d.ts.map
158
+ /**
159
+ * Every word `ColorSpec.parse` accepts as a name rather than a `#hex`,
160
+ * `rgb()` or `color(N)` form: `default` and the named palette entries, which
161
+ * are exactly the two name checks `parseSingle` makes.
162
+ */
163
+ export declare const COLOR_NAMES: readonly string[];
@@ -836,4 +836,9 @@ export const ANSI_COLOR_NAMES = withGrayAliases({
836
836
  grey89: 254,
837
837
  grey93: 255,
838
838
  });
839
- //# sourceMappingURL=color.js.map
839
+ /**
840
+ * Every word `ColorSpec.parse` accepts as a name rather than a `#hex`,
841
+ * `rgb()` or `color(N)` form: `default` and the named palette entries, which
842
+ * are exactly the two name checks `parseSingle` makes.
843
+ */
844
+ export const COLOR_NAMES = ["default", ...Object.keys(ANSI_COLOR_NAMES)];
@@ -3,10 +3,11 @@
3
3
  */
4
4
  import { Style, Theme } from "./style.js";
5
5
  import { ColorDepth } from "./color.js";
6
+ import type { TerminalTheme } from "./color.js";
6
7
  import { type JSONOptions } from "./json.js";
7
8
  import type { Highlighter } from "./highlighter.js";
8
9
  import { type RuleOptions } from "../renderables/rule.js";
9
- import type { RenderOptions } from "./protocol.js";
10
+ import type { RenderOptions, StyleErrorHandler } from "./protocol.js";
10
11
  export interface ConsoleSink {
11
12
  write(chunk: string | Uint8Array): unknown;
12
13
  }
@@ -73,6 +74,14 @@ export interface ConsoleOptions {
73
74
  highlight?: boolean;
74
75
  theme?: Theme;
75
76
  highlighter?: Highlighter;
77
+ /**
78
+ * Called each time a render resolves a style string it cannot parse — a
79
+ * misspelled name, a key the theme lacks — and degrades it to unstyled.
80
+ * Calls are per resolution, not per distinct string: a style read twice, or
81
+ * redrawn by a refresh, is reported again. Throw from it to make rendering
82
+ * strict.
83
+ */
84
+ onStyleError?: StyleErrorHandler;
76
85
  }
77
86
  export interface PrintOptions {
78
87
  style?: string | Style;
@@ -97,6 +106,7 @@ export declare class Console {
97
106
  private _markup;
98
107
  private _highlight;
99
108
  private _theme;
109
+ private _onStyleError;
100
110
  private _highlighter;
101
111
  private _recorded;
102
112
  private _capture;
@@ -123,11 +133,10 @@ export declare class Console {
123
133
  exportText({ clear }?: {
124
134
  clear?: boolean;
125
135
  }): string;
126
- exportHtml({ clear }?: {
136
+ exportHtml({ theme, clear }?: {
137
+ theme?: TerminalTheme;
127
138
  clear?: boolean;
128
139
  }): string;
129
- private _styleToCss;
130
140
  private _writeSegments;
131
141
  private _write;
132
142
  }
133
- //# sourceMappingURL=console.d.ts.map
@@ -4,6 +4,7 @@
4
4
  import { Segment } from "./segment.js";
5
5
  import { NULL_STYLE, DEFAULT_THEME } from "./style.js";
6
6
  import { resolveColorSystem } from "./color.js";
7
+ import { encodeHtml } from "./export-html.js";
7
8
  import { RichText } from "./text.js";
8
9
  import { renderMarkup } from "./markup.js";
9
10
  import { Pretty } from "./pretty.js";
@@ -135,8 +136,8 @@ const NO_HIGHLIGHT = new NullHighlighter();
135
136
  * `print(deeplyNested)` descends until the stack gives out, and a single
136
137
  * response body assigned to a field arrives in full — each of them a debug line
137
138
  * that costs megabytes or hangs the terminal. All three bounds announce
138
- * themselves in the output (`... +N`, `{...}`, `+N` inside the quotes), so this
139
- * truncates visibly and never silently. [LAW:no-silent-failure]
139
+ * themselves in the output (`... +N`, `{...}`, `+N` after the closing quote),
140
+ * so this truncates visibly and never silently. [LAW:no-silent-failure]
140
141
  *
141
142
  * `maxString` reaches only strings nested inside data; a string argument is
142
143
  * printed by the arm above, where the caller asked for that string by name.
@@ -164,6 +165,7 @@ export class Console {
164
165
  _markup;
165
166
  _highlight;
166
167
  _theme;
168
+ _onStyleError;
167
169
  _highlighter;
168
170
  _recorded;
169
171
  // [LAW:types-are-the-program] The capture state is carried in the *type*
@@ -192,6 +194,7 @@ export class Console {
192
194
  this._markup = options?.markup !== false;
193
195
  this._highlight = options?.highlight !== false;
194
196
  this._highlighter = options?.highlighter ?? new ReprHighlighter();
197
+ this._onStyleError = options?.onStyleError;
195
198
  this._recorded = [];
196
199
  this._capture = null;
197
200
  }
@@ -239,6 +242,7 @@ export class Console {
239
242
  encoding: this.encoding,
240
243
  asciiOnly: false,
241
244
  theme: this._theme,
245
+ onStyleError: this._onStyleError,
242
246
  };
243
247
  }
244
248
  // --- Print ---
@@ -272,22 +276,39 @@ export class Console {
272
276
  const end = opts.end ?? "\n";
273
277
  const softWrap = opts.softWrap ?? false;
274
278
  const printStyle = this._theme.resolve(opts.style ?? NULL_STYLE);
275
- // Convert items to renderables
276
- const renderables = [];
277
- for (let i = 0; i < items.length; i++) {
278
- if (i > 0 && sep) {
279
- renderables.push(new RichText(sep, { end: "" }));
279
+ // A print is a column of blocks, and every argument joins one of two kinds.
280
+ // Text — a string, a `RichText`, or data — runs together: adjacent text
281
+ // items are one block, joined by `sep` and ended by `end`. Any other
282
+ // renderable is a block of its own that occupies whole lines, so neither
283
+ // `sep` nor `end` ever touches it. That is the reference's split — `end`
284
+ // belongs to text, not to the print — and it is what lets two printed panels
285
+ // stack with no blank line between them. The one place the reference cuts
286
+ // differently is data: it gives a container lines of its own, and here all
287
+ // data is text. The line is not closed by asking where the cursor sits:
288
+ // `print("a\n")` is a line and an empty one, here as in the reference and
289
+ // in every other `print`, and only the kind of the item can tell that
290
+ // trailing break from a `Panel`'s. A call with nothing to print is one
291
+ // empty text run, so it still ends the line.
292
+ const blocks = items.length === 0 ? [{ kind: "text", items: [] }] : [];
293
+ for (const item of items) {
294
+ // Four arms, and they are the whole domain. A `RichText` is already text;
295
+ // it runs as a copy with its own `end` cleared, as a string's is, because
296
+ // the line end of a run is the print's. Any other renderable draws itself,
297
+ // as a block. A string is the only kind of argument that can *contain*
298
+ // markup, so it is the only kind the markup dialect is applied to.
299
+ // Everything else is data, and `Pretty` is the single authority on how a
300
+ // JavaScript value displays — `String(value)` was a second, weaker one
301
+ // that answered `[object Object]` for every object and let the markup
302
+ // parser eat it. [LAW:one-source-of-truth]
303
+ let text;
304
+ if (item instanceof RichText) {
305
+ const richText = item.copy();
306
+ richText.end = "";
307
+ text = richText;
280
308
  }
281
- // Three arms, and they are the whole domain. A renderable draws itself.
282
- // A string is the only kind of argument that can *contain* markup, so it
283
- // is the only kind the markup dialect is applied to. Everything else is
284
- // data, and `Pretty` is the single authority on how a JavaScript value
285
- // displays — `String(value)` was a second, weaker one that answered
286
- // `[object Object]` for every object and let the markup parser eat it.
287
- // [LAW:one-source-of-truth]
288
- const item = items[i];
289
- if (isRenderable(item)) {
290
- renderables.push(item);
309
+ else if (isRenderable(item)) {
310
+ blocks.push({ kind: "lines", renderable: item });
311
+ continue;
291
312
  }
292
313
  else if (typeof item === "string") {
293
314
  const richText = doMarkup ? renderMarkup(item) : new RichText(item);
@@ -295,7 +316,7 @@ export class Console {
295
316
  if (doHighlight) {
296
317
  this._highlighter.highlight(richText);
297
318
  }
298
- renderables.push(richText);
319
+ text = richText;
299
320
  }
300
321
  else {
301
322
  // The highlighter travels with the value. `highlight` and a custom
@@ -306,15 +327,18 @@ export class Console {
306
327
  // Indent guides are styling too, and travel with the same decision —
307
328
  // the console owns what `highlight` means for everything it emits,
308
329
  // rather than `Pretty` inferring it back out of the highlighter.
309
- renderables.push(new Pretty(item, {
330
+ text = new Pretty(item, {
310
331
  ...PRINT_DATA_BOUNDS,
311
332
  highlighter: doHighlight ? this._highlighter : NO_HIGHLIGHT,
312
333
  indentGuides: doHighlight,
313
- }));
334
+ });
314
335
  }
336
+ const run = blocks.at(-1);
337
+ if (run?.kind === "text")
338
+ run.items.push(new RichText(sep, { end: "" }), text);
339
+ else
340
+ blocks.push({ kind: "text", items: [text] });
315
341
  }
316
- // Render all items
317
- const allSegments = [];
318
342
  // [LAW:parse-dont-validate] `"ignore"` is not a way of cutting a line but
319
343
  // the absence of an edge to cut at: no break, and nothing cut at the width.
320
344
  // That is what `noWrap` already means to `RichText`, so it crosses into the
@@ -327,24 +351,35 @@ export class Console {
327
351
  overflow: opts.overflow === "ignore" ? undefined : opts.overflow,
328
352
  noWrap: softWrap || opts.overflow === "ignore",
329
353
  };
330
- for (const renderable of renderables) {
331
- allSegments.push(...renderable.render(renderOpts));
332
- }
333
- // Apply print style
334
- const styled = printStyle.isNull
335
- ? allSegments
336
- : [...Segment.applyStyle(allSegments, printStyle)];
337
- // Apply base console style
338
- const final = this._style.isNull
339
- ? styled
340
- : [...Segment.applyStyle(styled, this._style)];
341
- // Output. The line-end goes through the same writeSegments funnel as
342
- // every other emitted text so it survives recording — otherwise
343
- // `exportText` and `exportHtml` would join consecutive prints onto a
344
- // single line. [LAW:single-enforcer]
354
+ // The print style, then the console's base style, over what each block drew
355
+ // and not over the line ends added below: a styled break carries SGR codes
356
+ // across the newline.
357
+ // [LAW:dataflow-not-control-flow] no style to apply is an empty list, not
358
+ // a skipped step.
359
+ const styles = [printStyle, this._style].filter((style) => !style.isNull);
360
+ const styleContent = (segments) => styles.reduce((styled, style) => Segment.applyStyle(styled, style), segments);
361
+ // Every line end goes through the same writeSegments funnel as the text it
362
+ // ends, so it survives recording — otherwise `exportText` and `exportHtml`
363
+ // would join consecutive prints onto a single line. [LAW:single-enforcer]
345
364
  // The common default end is "\n" — reuse Segment's cached newline rather
346
365
  // than allocating one per print; only a non-default end needs a fresh one.
347
366
  const terminator = end === "\n" ? Segment.line() : new Segment(end);
367
+ const output = [];
368
+ for (const block of blocks) {
369
+ if (block.kind === "text") {
370
+ output.push(...styleContent(block.items.flatMap((item) => [...item.render(renderOpts)])), terminator);
371
+ }
372
+ else {
373
+ // A block's lines are closed whether or not it closed them itself: a
374
+ // `Panel` ends in a line break and a bare `Spinner` or `ProgressBar`
375
+ // does not (they're line fragments, meant to be composed within a
376
+ // line — rich-flexstrip-5kf.4cq), and both leave the next print at
377
+ // the start of a line.
378
+ for (const line of Segment.splitLines(block.renderable.render(renderOpts))) {
379
+ output.push(...styleContent(line), Segment.line());
380
+ }
381
+ }
382
+ }
348
383
  // Crop last, and crop the line-end with the rest: in the reference `end` is
349
384
  // the tail of the printed line, so a line cut at the edge loses it too.
350
385
  // Soft wrap turns cropping off whatever `crop` says, because a line it left
@@ -352,7 +387,7 @@ export class Console {
352
387
  // Not cropping is an unbounded width rather than a skipped step — the same
353
388
  // spelling `RichText` uses for `noWrap`.
354
389
  const cropWidth = !softWrap && (opts.crop ?? true) ? this.width : Infinity;
355
- this._writeSegments([...Segment.cropLines([...final, terminator], cropWidth)]);
390
+ this._writeSegments([...Segment.cropLines(output, cropWidth)]);
356
391
  }
357
392
  log(...args) {
358
393
  // Simple log implementation — adds timestamp
@@ -401,56 +436,13 @@ export class Console {
401
436
  this._recorded = [];
402
437
  return text;
403
438
  }
404
- exportHtml({ clear = true } = {}) {
405
- const parts = [];
406
- parts.push('<!DOCTYPE html>');
407
- parts.push('<html><head><meta charset="utf-8"><style>');
408
- parts.push('body{background:#000;color:#fff;font-family:monospace;padding:1em}');
409
- parts.push('pre{margin:0;white-space:pre-wrap;word-wrap:break-word}');
410
- parts.push('</style></head><body><pre>');
411
- for (const segment of this._recorded) {
412
- if (segment.isControl)
413
- continue;
414
- const css = this._styleToCss(segment.style);
415
- const escaped = segment.text
416
- .replace(/&/g, "&amp;")
417
- .replace(/</g, "&lt;")
418
- .replace(/>/g, "&gt;");
419
- parts.push(css ? `<span style="${css}">${escaped}</span>` : escaped);
420
- }
421
- parts.push('</pre></body></html>');
439
+ // [LAW:single-enforcer] `encodeHtml` draws the picture `exportLines`
440
+ // resolves; nothing here interprets a `Style`.
441
+ exportHtml({ theme, clear = true } = {}) {
442
+ const html = encodeHtml(this._recorded, theme);
422
443
  if (clear)
423
444
  this._recorded = [];
424
- return parts.join("");
425
- }
426
- _styleToCss(style) {
427
- if (!style || style.isNull)
428
- return "";
429
- const parts = [];
430
- if (style.bold)
431
- parts.push("font-weight:bold");
432
- if (style.italic)
433
- parts.push("font-style:italic");
434
- if (style.dim)
435
- parts.push("opacity:0.5");
436
- const underlineParts = [];
437
- if (style.underline || style.underline2)
438
- underlineParts.push("underline");
439
- if (style.strike)
440
- underlineParts.push("line-through");
441
- if (style.overline)
442
- underlineParts.push("overline");
443
- if (underlineParts.length)
444
- parts.push(`text-decoration:${underlineParts.join(" ")}`);
445
- if (style.color && !style.color.isDefault) {
446
- const t = style.color.getTruecolor();
447
- parts.push(`color:${t.hex}`);
448
- }
449
- if (style.bgcolor && !style.bgcolor.isDefault) {
450
- const t = style.bgcolor.getTruecolor();
451
- parts.push(`background-color:${t.hex}`);
452
- }
453
- return parts.join(";");
445
+ return html;
454
446
  }
455
447
  // --- Internal ---
456
448
  // [LAW:single-enforcer] One encode call per write batch routes through the
@@ -482,4 +474,3 @@ export class Console {
482
474
  target.write(text);
483
475
  }
484
476
  }
485
- //# sourceMappingURL=console.js.map
@@ -22,4 +22,3 @@ export declare class Emoji implements Renderable {
22
22
  render(_options: RenderOptions): Iterable<Segment>;
23
23
  static replace(text: string): string;
24
24
  }
25
- //# sourceMappingURL=emoji.d.ts.map
@@ -389,4 +389,3 @@ export class Emoji {
389
389
  return emojiReplace(text);
390
390
  }
391
391
  }
392
- //# sourceMappingURL=emoji.js.map