@promptctl/rich-js 0.10.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +20 -110
- package/THIRD-PARTY-NOTICES +81 -0
- package/dist/core/box.d.ts +0 -1
- package/dist/core/box.js +0 -1
- package/dist/core/cells.d.ts +0 -1
- package/dist/core/cells.js +0 -1
- package/dist/core/color.d.ts +6 -1
- package/dist/core/color.js +6 -1
- package/dist/core/console.d.ts +13 -4
- package/dist/core/console.js +78 -87
- package/dist/core/emoji.d.ts +0 -1
- package/dist/core/emoji.js +0 -1
- package/dist/core/export-html.d.ts +24 -0
- package/dist/core/export-html.js +106 -0
- package/dist/core/export-lines.d.ts +121 -0
- package/dist/core/export-lines.js +141 -0
- package/dist/core/highlighter.d.ts +0 -1
- package/dist/core/highlighter.js +0 -1
- package/dist/core/json.d.ts +0 -1
- package/dist/core/json.js +0 -1
- package/dist/core/markup.d.ts +33 -2
- package/dist/core/markup.js +128 -16
- package/dist/core/measure.d.ts +0 -1
- package/dist/core/measure.js +0 -1
- package/dist/core/oklch.d.ts +34 -1
- package/dist/core/oklch.js +52 -5
- package/dist/core/osc8.d.ts +68 -0
- package/dist/core/osc8.js +90 -0
- package/dist/core/pretty.d.ts +21 -2
- package/dist/core/pretty.js +90 -16
- package/dist/core/protocol.d.ts +18 -2
- package/dist/core/protocol.js +0 -1
- package/dist/core/render.d.ts +0 -1
- package/dist/core/render.js +3 -10
- package/dist/core/segment.d.ts +0 -1
- package/dist/core/segment.js +0 -1
- package/dist/core/spinnerData.d.ts +0 -1
- package/dist/core/spinnerData.js +0 -1
- package/dist/core/strip.d.ts +19 -3
- package/dist/core/strip.js +58 -11
- package/dist/core/style.d.ts +3 -8
- package/dist/core/style.js +85 -68
- package/dist/core/subscription.d.ts +0 -1
- package/dist/core/subscription.js +0 -1
- package/dist/core/text.d.ts +1 -8
- package/dist/core/text.js +28 -31
- package/dist/core/wrap.d.ts +0 -1
- package/dist/core/wrap.js +0 -1
- package/dist/host/host-stream.d.ts +0 -1
- package/dist/host/host-stream.js +0 -1
- package/dist/host/index.d.ts +0 -1
- package/dist/host/index.js +0 -1
- package/dist/host/terminal-host.d.ts +0 -1
- package/dist/host/terminal-host.js +0 -1
- package/dist/index.d.ts +6 -5
- package/dist/index.js +4 -3
- package/dist/node/prompt.d.ts +0 -1
- package/dist/node/prompt.js +0 -1
- package/dist/node/save.d.ts +2 -7
- package/dist/node/save.js +0 -1
- package/dist/node/terminal-host.d.ts +0 -1
- package/dist/node/terminal-host.js +0 -1
- package/dist/node/traceback.d.ts +0 -1
- package/dist/node/traceback.js +0 -1
- package/dist/renderables/align.d.ts +0 -1
- package/dist/renderables/align.js +0 -1
- package/dist/renderables/columns.d.ts +12 -1
- package/dist/renderables/columns.js +29 -5
- package/dist/renderables/constrain.d.ts +0 -1
- package/dist/renderables/constrain.js +0 -1
- package/dist/renderables/flexStrip.d.ts +0 -1
- package/dist/renderables/flexStrip.js +0 -1
- package/dist/renderables/group.d.ts +0 -1
- package/dist/renderables/group.js +0 -1
- package/dist/renderables/layout.d.ts +0 -1
- package/dist/renderables/layout.js +20 -7
- package/dist/renderables/live.d.ts +0 -1
- package/dist/renderables/live.js +0 -1
- package/dist/renderables/markdown.d.ts +0 -1
- package/dist/renderables/markdown.js +0 -1
- package/dist/renderables/padding.d.ts +0 -1
- package/dist/renderables/padding.js +0 -1
- package/dist/renderables/panel.d.ts +0 -1
- package/dist/renderables/panel.js +12 -4
- package/dist/renderables/progress.d.ts +0 -1
- package/dist/renderables/progress.js +7 -2
- package/dist/renderables/progressBar.d.ts +0 -1
- package/dist/renderables/progressBar.js +0 -1
- package/dist/renderables/prompt.d.ts +0 -1
- package/dist/renderables/prompt.js +0 -1
- package/dist/renderables/rule.d.ts +0 -1
- package/dist/renderables/rule.js +0 -1
- package/dist/renderables/spinner.d.ts +0 -1
- package/dist/renderables/spinner.js +0 -1
- package/dist/renderables/status.d.ts +0 -1
- package/dist/renderables/status.js +0 -1
- package/dist/renderables/syntax.d.ts +0 -1
- package/dist/renderables/syntax.js +0 -1
- package/dist/renderables/table.d.ts +0 -1
- package/dist/renderables/table.js +8 -3
- package/dist/renderables/traceback.d.ts +8 -7
- package/dist/renderables/traceback.js +14 -10
- package/dist/renderables/tree.d.ts +0 -1
- package/dist/renderables/tree.js +0 -1
- package/dist/template-bindings/color-funcs.d.ts +0 -1
- package/dist/template-bindings/color-funcs.js +0 -1
- package/dist/template-bindings/helpers.d.ts +0 -1
- package/dist/template-bindings/helpers.js +0 -1
- package/dist/template-bindings/index.d.ts +0 -1
- package/dist/template-bindings/index.js +0 -1
- package/dist/template-bindings/palette-funcs.d.ts +0 -1
- package/dist/template-bindings/palette-funcs.js +0 -1
- package/dist/template-bindings/style-funcs.d.ts +0 -1
- package/dist/template-bindings/style-funcs.js +0 -1
- package/dist/themes/buildPalette.d.ts +0 -1
- package/dist/themes/buildPalette.js +0 -1
- package/dist/themes/colorMath.d.ts +0 -1
- package/dist/themes/colorMath.js +0 -1
- package/dist/themes/colorRef.d.ts +0 -1
- package/dist/themes/colorRef.js +0 -1
- package/dist/themes/data/atom-one-dark.d.ts +0 -1
- package/dist/themes/data/atom-one-dark.js +0 -1
- package/dist/themes/data/atom-one-light.d.ts +0 -1
- package/dist/themes/data/atom-one-light.js +0 -1
- package/dist/themes/data/catppuccin-frappe.d.ts +0 -1
- package/dist/themes/data/catppuccin-frappe.js +0 -1
- package/dist/themes/data/catppuccin-latte.d.ts +0 -1
- package/dist/themes/data/catppuccin-latte.js +0 -1
- package/dist/themes/data/catppuccin-macchiato.d.ts +0 -1
- package/dist/themes/data/catppuccin-macchiato.js +0 -1
- package/dist/themes/data/catppuccin-mocha.d.ts +0 -1
- package/dist/themes/data/catppuccin-mocha.js +0 -1
- package/dist/themes/data/cyberpunk.d.ts +0 -1
- package/dist/themes/data/cyberpunk.js +0 -1
- package/dist/themes/data/default.d.ts +0 -1
- package/dist/themes/data/default.js +0 -1
- package/dist/themes/data/dracula.d.ts +0 -1
- package/dist/themes/data/dracula.js +0 -1
- package/dist/themes/data/flexoki.d.ts +0 -1
- package/dist/themes/data/flexoki.js +0 -1
- package/dist/themes/data/gruvbox.d.ts +0 -1
- package/dist/themes/data/gruvbox.js +0 -1
- package/dist/themes/data/index.d.ts +0 -1
- package/dist/themes/data/index.js +0 -1
- package/dist/themes/data/monokai.d.ts +0 -1
- package/dist/themes/data/monokai.js +0 -1
- package/dist/themes/data/nord.d.ts +0 -1
- package/dist/themes/data/nord.js +0 -1
- package/dist/themes/data/rose-pine-dawn.d.ts +0 -1
- package/dist/themes/data/rose-pine-dawn.js +0 -1
- package/dist/themes/data/rose-pine-moon.d.ts +0 -1
- package/dist/themes/data/rose-pine-moon.js +0 -1
- package/dist/themes/data/rose-pine.d.ts +0 -1
- package/dist/themes/data/rose-pine.js +0 -1
- package/dist/themes/data/solarized-dark.d.ts +0 -1
- package/dist/themes/data/solarized-dark.js +0 -1
- package/dist/themes/data/solarized-light.d.ts +0 -1
- package/dist/themes/data/solarized-light.js +0 -1
- package/dist/themes/data/svg-export.d.ts +0 -1
- package/dist/themes/data/svg-export.js +0 -1
- package/dist/themes/data/textual-ansi.d.ts +0 -1
- package/dist/themes/data/textual-ansi.js +0 -1
- package/dist/themes/data/textual-dark.d.ts +0 -1
- package/dist/themes/data/textual-dark.js +0 -1
- package/dist/themes/data/textual-light.d.ts +0 -1
- package/dist/themes/data/textual-light.js +0 -1
- package/dist/themes/data/tokyo-night.d.ts +0 -1
- package/dist/themes/data/tokyo-night.js +0 -1
- package/dist/themes/data/types.d.ts +0 -1
- package/dist/themes/data/types.js +0 -1
- package/dist/themes/palette.d.ts +0 -1
- package/dist/themes/palette.js +0 -1
- package/dist/themes/ramp.d.ts +0 -1
- package/dist/themes/ramp.js +0 -1
- package/dist/themes/registry.d.ts +0 -1
- package/dist/themes/registry.js +0 -1
- package/dist/themes/terminalThemes.d.ts +0 -1
- package/dist/themes/terminalThemes.js +0 -1
- package/dist/themes/transpose.d.ts +0 -1
- package/dist/themes/transpose.js +0 -1
- package/dist/widgets/button.d.ts +0 -1
- package/dist/widgets/button.js +0 -1
- package/dist/widgets/checkbox.d.ts +0 -1
- package/dist/widgets/checkbox.js +0 -1
- package/dist/widgets/dropdown.d.ts +0 -1
- package/dist/widgets/dropdown.js +0 -1
- package/dist/widgets/event-router.d.ts +0 -1
- package/dist/widgets/event-router.js +0 -1
- package/dist/widgets/focus-manager.d.ts +0 -1
- package/dist/widgets/focus-manager.js +0 -1
- package/dist/widgets/index.d.ts +0 -1
- package/dist/widgets/index.js +0 -1
- package/dist/widgets/screen.d.ts +0 -1
- package/dist/widgets/screen.js +0 -1
- package/dist/widgets/slider.d.ts +0 -1
- package/dist/widgets/slider.js +0 -1
- package/dist/widgets/static-item.d.ts +0 -1
- package/dist/widgets/static-item.js +0 -1
- package/dist/widgets/text-input.d.ts +0 -1
- package/dist/widgets/text-input.js +0 -1
- package/dist/widgets/toggle.d.ts +0 -1
- package/dist/widgets/toggle.js +0 -1
- package/dist/widgets/types.d.ts +0 -1
- package/dist/widgets/types.js +0 -1
- package/dist/widgets/widget-base.d.ts +0 -1
- package/dist/widgets/widget-base.js +0 -1
- package/package.json +4 -3
- package/dist/core/box.d.ts.map +0 -1
- package/dist/core/box.js.map +0 -1
- package/dist/core/cells.d.ts.map +0 -1
- package/dist/core/cells.js.map +0 -1
- package/dist/core/color.d.ts.map +0 -1
- package/dist/core/color.js.map +0 -1
- package/dist/core/console.d.ts.map +0 -1
- package/dist/core/console.js.map +0 -1
- package/dist/core/emoji.d.ts.map +0 -1
- package/dist/core/emoji.js.map +0 -1
- package/dist/core/highlighter.d.ts.map +0 -1
- package/dist/core/highlighter.js.map +0 -1
- package/dist/core/json.d.ts.map +0 -1
- package/dist/core/json.js.map +0 -1
- package/dist/core/markup.d.ts.map +0 -1
- package/dist/core/markup.js.map +0 -1
- package/dist/core/measure.d.ts.map +0 -1
- package/dist/core/measure.js.map +0 -1
- package/dist/core/oklch.d.ts.map +0 -1
- package/dist/core/oklch.js.map +0 -1
- package/dist/core/pretty.d.ts.map +0 -1
- package/dist/core/pretty.js.map +0 -1
- package/dist/core/protocol.d.ts.map +0 -1
- package/dist/core/protocol.js.map +0 -1
- package/dist/core/render.d.ts.map +0 -1
- package/dist/core/render.js.map +0 -1
- package/dist/core/sanitize.d.ts +0 -16
- package/dist/core/sanitize.d.ts.map +0 -1
- package/dist/core/sanitize.js +0 -19
- package/dist/core/sanitize.js.map +0 -1
- package/dist/core/segment.d.ts.map +0 -1
- package/dist/core/segment.js.map +0 -1
- package/dist/core/spinnerData.d.ts.map +0 -1
- package/dist/core/spinnerData.js.map +0 -1
- package/dist/core/strip.d.ts.map +0 -1
- package/dist/core/strip.js.map +0 -1
- package/dist/core/style.d.ts.map +0 -1
- package/dist/core/style.js.map +0 -1
- package/dist/core/subscription.d.ts.map +0 -1
- package/dist/core/subscription.js.map +0 -1
- package/dist/core/text.d.ts.map +0 -1
- package/dist/core/text.js.map +0 -1
- package/dist/core/wrap.d.ts.map +0 -1
- package/dist/core/wrap.js.map +0 -1
- package/dist/host/host-stream.d.ts.map +0 -1
- package/dist/host/host-stream.js.map +0 -1
- package/dist/host/index.d.ts.map +0 -1
- package/dist/host/index.js.map +0 -1
- package/dist/host/terminal-host.d.ts.map +0 -1
- package/dist/host/terminal-host.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/node/prompt.d.ts.map +0 -1
- package/dist/node/prompt.js.map +0 -1
- package/dist/node/save.d.ts.map +0 -1
- package/dist/node/save.js.map +0 -1
- package/dist/node/terminal-host.d.ts.map +0 -1
- package/dist/node/terminal-host.js.map +0 -1
- package/dist/node/traceback.d.ts.map +0 -1
- package/dist/node/traceback.js.map +0 -1
- package/dist/renderables/align.d.ts.map +0 -1
- package/dist/renderables/align.js.map +0 -1
- package/dist/renderables/columns.d.ts.map +0 -1
- package/dist/renderables/columns.js.map +0 -1
- package/dist/renderables/constrain.d.ts.map +0 -1
- package/dist/renderables/constrain.js.map +0 -1
- package/dist/renderables/flexStrip.d.ts.map +0 -1
- package/dist/renderables/flexStrip.js.map +0 -1
- package/dist/renderables/group.d.ts.map +0 -1
- package/dist/renderables/group.js.map +0 -1
- package/dist/renderables/layout.d.ts.map +0 -1
- package/dist/renderables/layout.js.map +0 -1
- package/dist/renderables/live.d.ts.map +0 -1
- package/dist/renderables/live.js.map +0 -1
- package/dist/renderables/markdown.d.ts.map +0 -1
- package/dist/renderables/markdown.js.map +0 -1
- package/dist/renderables/padding.d.ts.map +0 -1
- package/dist/renderables/padding.js.map +0 -1
- package/dist/renderables/panel.d.ts.map +0 -1
- package/dist/renderables/panel.js.map +0 -1
- package/dist/renderables/progress.d.ts.map +0 -1
- package/dist/renderables/progress.js.map +0 -1
- package/dist/renderables/progressBar.d.ts.map +0 -1
- package/dist/renderables/progressBar.js.map +0 -1
- package/dist/renderables/prompt.d.ts.map +0 -1
- package/dist/renderables/prompt.js.map +0 -1
- package/dist/renderables/rule.d.ts.map +0 -1
- package/dist/renderables/rule.js.map +0 -1
- package/dist/renderables/spinner.d.ts.map +0 -1
- package/dist/renderables/spinner.js.map +0 -1
- package/dist/renderables/status.d.ts.map +0 -1
- package/dist/renderables/status.js.map +0 -1
- package/dist/renderables/syntax.d.ts.map +0 -1
- package/dist/renderables/syntax.js.map +0 -1
- package/dist/renderables/table.d.ts.map +0 -1
- package/dist/renderables/table.js.map +0 -1
- package/dist/renderables/traceback.d.ts.map +0 -1
- package/dist/renderables/traceback.js.map +0 -1
- package/dist/renderables/tree.d.ts.map +0 -1
- package/dist/renderables/tree.js.map +0 -1
- package/dist/template-bindings/color-funcs.d.ts.map +0 -1
- package/dist/template-bindings/color-funcs.js.map +0 -1
- package/dist/template-bindings/helpers.d.ts.map +0 -1
- package/dist/template-bindings/helpers.js.map +0 -1
- package/dist/template-bindings/index.d.ts.map +0 -1
- package/dist/template-bindings/index.js.map +0 -1
- package/dist/template-bindings/palette-funcs.d.ts.map +0 -1
- package/dist/template-bindings/palette-funcs.js.map +0 -1
- package/dist/template-bindings/style-funcs.d.ts.map +0 -1
- package/dist/template-bindings/style-funcs.js.map +0 -1
- package/dist/themes/buildPalette.d.ts.map +0 -1
- package/dist/themes/buildPalette.js.map +0 -1
- package/dist/themes/colorMath.d.ts.map +0 -1
- package/dist/themes/colorMath.js.map +0 -1
- package/dist/themes/colorRef.d.ts.map +0 -1
- package/dist/themes/colorRef.js.map +0 -1
- package/dist/themes/data/atom-one-dark.d.ts.map +0 -1
- package/dist/themes/data/atom-one-dark.js.map +0 -1
- package/dist/themes/data/atom-one-light.d.ts.map +0 -1
- package/dist/themes/data/atom-one-light.js.map +0 -1
- package/dist/themes/data/catppuccin-frappe.d.ts.map +0 -1
- package/dist/themes/data/catppuccin-frappe.js.map +0 -1
- package/dist/themes/data/catppuccin-latte.d.ts.map +0 -1
- package/dist/themes/data/catppuccin-latte.js.map +0 -1
- package/dist/themes/data/catppuccin-macchiato.d.ts.map +0 -1
- package/dist/themes/data/catppuccin-macchiato.js.map +0 -1
- package/dist/themes/data/catppuccin-mocha.d.ts.map +0 -1
- package/dist/themes/data/catppuccin-mocha.js.map +0 -1
- package/dist/themes/data/cyberpunk.d.ts.map +0 -1
- package/dist/themes/data/cyberpunk.js.map +0 -1
- package/dist/themes/data/default.d.ts.map +0 -1
- package/dist/themes/data/default.js.map +0 -1
- package/dist/themes/data/dracula.d.ts.map +0 -1
- package/dist/themes/data/dracula.js.map +0 -1
- package/dist/themes/data/flexoki.d.ts.map +0 -1
- package/dist/themes/data/flexoki.js.map +0 -1
- package/dist/themes/data/gruvbox.d.ts.map +0 -1
- package/dist/themes/data/gruvbox.js.map +0 -1
- package/dist/themes/data/index.d.ts.map +0 -1
- package/dist/themes/data/index.js.map +0 -1
- package/dist/themes/data/monokai.d.ts.map +0 -1
- package/dist/themes/data/monokai.js.map +0 -1
- package/dist/themes/data/nord.d.ts.map +0 -1
- package/dist/themes/data/nord.js.map +0 -1
- package/dist/themes/data/rose-pine-dawn.d.ts.map +0 -1
- package/dist/themes/data/rose-pine-dawn.js.map +0 -1
- package/dist/themes/data/rose-pine-moon.d.ts.map +0 -1
- package/dist/themes/data/rose-pine-moon.js.map +0 -1
- package/dist/themes/data/rose-pine.d.ts.map +0 -1
- package/dist/themes/data/rose-pine.js.map +0 -1
- package/dist/themes/data/solarized-dark.d.ts.map +0 -1
- package/dist/themes/data/solarized-dark.js.map +0 -1
- package/dist/themes/data/solarized-light.d.ts.map +0 -1
- package/dist/themes/data/solarized-light.js.map +0 -1
- package/dist/themes/data/svg-export.d.ts.map +0 -1
- package/dist/themes/data/svg-export.js.map +0 -1
- package/dist/themes/data/textual-ansi.d.ts.map +0 -1
- package/dist/themes/data/textual-ansi.js.map +0 -1
- package/dist/themes/data/textual-dark.d.ts.map +0 -1
- package/dist/themes/data/textual-dark.js.map +0 -1
- package/dist/themes/data/textual-light.d.ts.map +0 -1
- package/dist/themes/data/textual-light.js.map +0 -1
- package/dist/themes/data/tokyo-night.d.ts.map +0 -1
- package/dist/themes/data/tokyo-night.js.map +0 -1
- package/dist/themes/data/types.d.ts.map +0 -1
- package/dist/themes/data/types.js.map +0 -1
- package/dist/themes/palette.d.ts.map +0 -1
- package/dist/themes/palette.js.map +0 -1
- package/dist/themes/ramp.d.ts.map +0 -1
- package/dist/themes/ramp.js.map +0 -1
- package/dist/themes/registry.d.ts.map +0 -1
- package/dist/themes/registry.js.map +0 -1
- package/dist/themes/terminalThemes.d.ts.map +0 -1
- package/dist/themes/terminalThemes.js.map +0 -1
- package/dist/themes/transpose.d.ts.map +0 -1
- package/dist/themes/transpose.js.map +0 -1
- package/dist/widgets/button.d.ts.map +0 -1
- package/dist/widgets/button.js.map +0 -1
- package/dist/widgets/checkbox.d.ts.map +0 -1
- package/dist/widgets/checkbox.js.map +0 -1
- package/dist/widgets/dropdown.d.ts.map +0 -1
- package/dist/widgets/dropdown.js.map +0 -1
- package/dist/widgets/event-router.d.ts.map +0 -1
- package/dist/widgets/event-router.js.map +0 -1
- package/dist/widgets/focus-manager.d.ts.map +0 -1
- package/dist/widgets/focus-manager.js.map +0 -1
- package/dist/widgets/index.d.ts.map +0 -1
- package/dist/widgets/index.js.map +0 -1
- package/dist/widgets/screen.d.ts.map +0 -1
- package/dist/widgets/screen.js.map +0 -1
- package/dist/widgets/slider.d.ts.map +0 -1
- package/dist/widgets/slider.js.map +0 -1
- package/dist/widgets/static-item.d.ts.map +0 -1
- package/dist/widgets/static-item.js.map +0 -1
- package/dist/widgets/text-input.d.ts.map +0 -1
- package/dist/widgets/text-input.js.map +0 -1
- package/dist/widgets/toggle.d.ts.map +0 -1
- package/dist/widgets/toggle.js.map +0 -1
- package/dist/widgets/types.d.ts.map +0 -1
- package/dist/widgets/types.js.map +0 -1
- package/dist/widgets/widget-base.d.ts.map +0 -1
- 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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
457
|
-
|
|
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
|
-
|
|
461
|
-
|
|
462
|
-
|
|
|
463
|
-
|
|
464
|
-
| `
|
|
465
|
-
| `
|
|
466
|
-
| `
|
|
467
|
-
| `
|
|
468
|
-
|
|
|
469
|
-
| `
|
|
470
|
-
| `
|
|
471
|
-
|
|
472
|
-
|
|
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
|
+
|
package/dist/core/box.d.ts
CHANGED
package/dist/core/box.js
CHANGED
package/dist/core/cells.d.ts
CHANGED
package/dist/core/cells.js
CHANGED
package/dist/core/color.d.ts
CHANGED
|
@@ -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
|
-
|
|
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[];
|
package/dist/core/color.js
CHANGED
|
@@ -836,4 +836,9 @@ export const ANSI_COLOR_NAMES = withGrayAliases({
|
|
|
836
836
|
grey89: 254,
|
|
837
837
|
grey93: 255,
|
|
838
838
|
});
|
|
839
|
-
|
|
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)];
|
package/dist/core/console.d.ts
CHANGED
|
@@ -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
|
package/dist/core/console.js
CHANGED
|
@@ -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`
|
|
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
|
-
//
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
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
|
-
|
|
282
|
-
|
|
283
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
//
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
//
|
|
338
|
-
|
|
339
|
-
|
|
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(
|
|
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
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
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, "&")
|
|
417
|
-
.replace(/</g, "<")
|
|
418
|
-
.replace(/>/g, ">");
|
|
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
|
|
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
|
package/dist/core/emoji.d.ts
CHANGED
package/dist/core/emoji.js
CHANGED