@promptctl/rich-js 0.9.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.
- 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 +0 -1
- package/dist/core/oklch.js +0 -1
- 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 +0 -1
- package/dist/core/strip.js +12 -1
- package/dist/core/style.d.ts +1 -7
- package/dist/core/style.js +84 -67
- 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 +25 -29
- 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 +4 -3
- package/dist/index.js +3 -2
- 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 +4 -6
- package/dist/widgets/checkbox.d.ts +0 -1
- package/dist/widgets/checkbox.js +3 -5
- package/dist/widgets/dropdown.d.ts +0 -1
- package/dist/widgets/dropdown.js +4 -6
- 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 -2
- package/dist/widgets/focus-manager.js +3 -8
- 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 +2 -5
- package/dist/widgets/slider.d.ts +0 -1
- package/dist/widgets/slider.js +7 -9
- 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 +5 -7
- package/dist/widgets/toggle.d.ts +0 -1
- package/dist/widgets/toggle.js +4 -6
- package/dist/widgets/types.d.ts +0 -1
- package/dist/widgets/types.js +0 -1
- package/dist/widgets/widget-base.d.ts +3 -4
- package/dist/widgets/widget-base.js +4 -7
- package/package.json +14 -13
- 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/dist/core/protocol.js
CHANGED
package/dist/core/render.d.ts
CHANGED
|
@@ -67,4 +67,3 @@ export declare function segmentToString(segment: Segment, colorSystem: ColorDept
|
|
|
67
67
|
*/
|
|
68
68
|
export declare function segmentsToString(segments: Iterable<Segment>, colorSystem: ColorDepth | null): string;
|
|
69
69
|
export declare function renderToString(renderable: Renderable, options?: RenderToStringOptions): string;
|
|
70
|
-
//# sourceMappingURL=render.d.ts.map
|
package/dist/core/render.js
CHANGED
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
* mechanical fold over it.
|
|
30
30
|
*/
|
|
31
31
|
import { ColorDepth, resolveColorSystem } from "./color.js";
|
|
32
|
-
import {
|
|
32
|
+
import { OSC8_CLOSE, osc8Open } from "./osc8.js";
|
|
33
33
|
const DEFAULT_WIDTH = 80;
|
|
34
34
|
function segmentToPiece(segment, colorSystem) {
|
|
35
35
|
if (segment.isControl)
|
|
@@ -86,16 +86,10 @@ export function segmentsToString(segments, colorSystem) {
|
|
|
86
86
|
while (l < j && pieces[l].link === link)
|
|
87
87
|
l++;
|
|
88
88
|
if (link) {
|
|
89
|
-
|
|
90
|
-
// at the one place it becomes an OSC 8 sequence, regardless of which
|
|
91
|
-
// upstream API attached it to the Style. Defense-in-depth for the
|
|
92
|
-
// RichText data-model boundary in text.ts; also covers Style paths
|
|
93
|
-
// that don't go through RichText (Console.print({style: ...}), any
|
|
94
|
-
// direct `Segment.applyStyle(... new Style({ link })) ...`).
|
|
95
|
-
parts.push(`\x1b]8;;${stripOscTerminators(link)}\x1b\\`);
|
|
89
|
+
parts.push(osc8Open(link));
|
|
96
90
|
for (let m = k; m < l; m++)
|
|
97
91
|
parts.push(pieces[m].text);
|
|
98
|
-
parts.push(
|
|
92
|
+
parts.push(OSC8_CLOSE);
|
|
99
93
|
}
|
|
100
94
|
else {
|
|
101
95
|
for (let m = k; m < l; m++)
|
|
@@ -141,4 +135,3 @@ export function renderToString(renderable, options) {
|
|
|
141
135
|
};
|
|
142
136
|
return segmentsToString(renderable.render(renderOptions), colorSystem);
|
|
143
137
|
}
|
|
144
|
-
//# sourceMappingURL=render.js.map
|
package/dist/core/segment.d.ts
CHANGED
package/dist/core/segment.js
CHANGED
package/dist/core/spinnerData.js
CHANGED
package/dist/core/strip.d.ts
CHANGED
package/dist/core/strip.js
CHANGED
|
@@ -51,6 +51,18 @@ export class Strip {
|
|
|
51
51
|
const next = i + 1 < items.length ? items[i + 1] : null;
|
|
52
52
|
yield* this.joiner.join(item, next).render(options);
|
|
53
53
|
}
|
|
54
|
+
// [LAW:one-source-of-truth] `Strip`'s sibling `FlexStrip` ends every line
|
|
55
|
+
// it emits, including the last, and the other block-level renderables
|
|
56
|
+
// (`Panel`/`Rule`/`Table` structurally, `RichText` via `end`) do too — so
|
|
57
|
+
// `Group` can emit children back to back with nothing in between
|
|
58
|
+
// (docs/group.md). A `Strip` that left its last line open broke only
|
|
59
|
+
// under composition: printed alone, Console's own "close whatever the
|
|
60
|
+
// renderable left open" step (console.ts) papered over it, and a `Group`
|
|
61
|
+
// of a Strip and a RichText ran the RichText onto the Strip's line
|
|
62
|
+
// instead of below it. (Not every renderable follows this — a `Spinner`
|
|
63
|
+
// or `ProgressBar` is a line *fragment*, not a block; see
|
|
64
|
+
// rich-flexstrip-5kf.4cq for the open question of formalizing that split.)
|
|
65
|
+
yield Segment.line();
|
|
54
66
|
}
|
|
55
67
|
}
|
|
56
68
|
// --- Helpers ---
|
|
@@ -206,4 +218,3 @@ export class GradientJoiner {
|
|
|
206
218
|
});
|
|
207
219
|
}
|
|
208
220
|
}
|
|
209
|
-
//# sourceMappingURL=strip.js.map
|
package/dist/core/style.d.ts
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* Immutable style descriptors — colors, text attributes, links, metadata.
|
|
3
3
|
*/
|
|
4
4
|
import { ColorSpec, ColorDepth } from "./color.js";
|
|
5
|
-
import type { TerminalTheme } from "./color.js";
|
|
6
5
|
/**
|
|
7
6
|
* Canonical text-attribute inventory. Single source of truth consumed by
|
|
8
7
|
* `Style.parse` / `Style.toString` and the template bindings — adding an
|
|
@@ -38,7 +37,7 @@ export interface StyleOptions {
|
|
|
38
37
|
meta?: Record<string, unknown>;
|
|
39
38
|
}
|
|
40
39
|
export declare class StyleSyntaxError extends Error {
|
|
41
|
-
constructor(message: string);
|
|
40
|
+
constructor(message: string, options?: ErrorOptions);
|
|
42
41
|
}
|
|
43
42
|
export declare class Style {
|
|
44
43
|
readonly color: ColorSpec | undefined;
|
|
@@ -85,10 +84,6 @@ export declare class Style {
|
|
|
85
84
|
* Render text with this style's ANSI escape codes.
|
|
86
85
|
*/
|
|
87
86
|
render(text: string, colorSystem?: ColorDepth): string;
|
|
88
|
-
/**
|
|
89
|
-
* Returns a CSS style string for HTML rendering.
|
|
90
|
-
*/
|
|
91
|
-
getHtmlStyle(theme?: TerminalTheme): string;
|
|
92
87
|
/**
|
|
93
88
|
* Serializes to a canonical string that round-trips through `Style.parse()`.
|
|
94
89
|
*/
|
|
@@ -141,4 +136,3 @@ export declare const DEFAULT_STYLES: Record<string, Style>;
|
|
|
141
136
|
* a renderable sees outside a `Console`, as in `renderToString`.
|
|
142
137
|
*/
|
|
143
138
|
export declare const DEFAULT_THEME: Theme;
|
|
144
|
-
//# sourceMappingURL=style.d.ts.map
|
package/dist/core/style.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Immutable style descriptors — colors, text attributes, links, metadata.
|
|
3
3
|
*/
|
|
4
|
-
import { ColorRgba, ColorSpec, } from "./color.js";
|
|
5
|
-
import {
|
|
4
|
+
import { COLOR_NAMES, ColorRgba, ColorSpec, } from "./color.js";
|
|
5
|
+
import { OSC8_CLOSE, osc8Open } from "./osc8.js";
|
|
6
6
|
// [LAW:one-way-deps] `core/style` depends only on `core/color` and the leaf
|
|
7
|
-
// `core/
|
|
7
|
+
// `core/osc8` (the link wire grammar). The substrate fallback is the
|
|
8
8
|
// canonical canvas color (black), inlined to avoid pulling in any preset
|
|
9
9
|
// theme constants. Preset themes live in `src/themes/` and depend on core,
|
|
10
10
|
// never the reverse.
|
|
@@ -64,8 +64,8 @@ export const ATTRIBUTE_SHORT_ALIASES = {
|
|
|
64
64
|
uu: "underline2",
|
|
65
65
|
};
|
|
66
66
|
export class StyleSyntaxError extends Error {
|
|
67
|
-
constructor(message) {
|
|
68
|
-
super(message);
|
|
67
|
+
constructor(message, options) {
|
|
68
|
+
super(message, options);
|
|
69
69
|
this.name = "StyleSyntaxError";
|
|
70
70
|
}
|
|
71
71
|
}
|
|
@@ -315,57 +315,11 @@ export class Style {
|
|
|
315
315
|
const codes = this.toSgrCodes(colorSystem);
|
|
316
316
|
let result = codes.length > 0 ? `\x1b[${codes}m${text}\x1b[0m` : text;
|
|
317
317
|
if (this.link) {
|
|
318
|
-
// [LAW:
|
|
319
|
-
|
|
320
|
-
// global counter, no construction-order dependence. Tradeoff: terminals
|
|
321
|
-
// can no longer hover-group non-adjacent same-URL spans (when linked
|
|
322
|
-
// segments are separated by other content, each becomes its own OSC 8
|
|
323
|
-
// pair instead of sharing an id). The coalescer in render.ts already
|
|
324
|
-
// merges adjacent same-link runs into one wrap, so the common case is
|
|
325
|
-
// unaffected; non-adjacent hover-grouping is the intentional sacrifice.
|
|
326
|
-
//
|
|
327
|
-
// [LAW:single-enforcer] Wire-byte sanitization at the OSC 8 emit site
|
|
328
|
-
// — paired with the same call in render.ts:segmentsToString so every
|
|
329
|
-
// path that turns `Style.link` into bytes goes through one rule. Style
|
|
330
|
-
// itself stays a faithful container (this.link is unchanged); only the
|
|
331
|
-
// bytes going out the door are stripped.
|
|
332
|
-
result = `\x1b]8;;${stripOscTerminators(this.link)}\x1b\\${result}\x1b]8;;\x1b\\`;
|
|
318
|
+
// [LAW:single-enforcer] One OSC 8 spelling, shared with segmentsToString.
|
|
319
|
+
result = `${osc8Open(this.link)}${result}${OSC8_CLOSE}`;
|
|
333
320
|
}
|
|
334
321
|
return result;
|
|
335
322
|
}
|
|
336
|
-
/**
|
|
337
|
-
* Returns a CSS style string for HTML rendering.
|
|
338
|
-
*/
|
|
339
|
-
getHtmlStyle(theme) {
|
|
340
|
-
if (this.isNull)
|
|
341
|
-
return "";
|
|
342
|
-
const parts = [];
|
|
343
|
-
if (this.color) {
|
|
344
|
-
const triplet = this.color.getTruecolor(theme, true);
|
|
345
|
-
parts.push(`color: ${triplet.hex}`);
|
|
346
|
-
}
|
|
347
|
-
if (this.bgcolor) {
|
|
348
|
-
const triplet = this.bgcolor.getTruecolor(theme, false);
|
|
349
|
-
parts.push(`background-color: ${triplet.hex}`);
|
|
350
|
-
}
|
|
351
|
-
if (this.bold)
|
|
352
|
-
parts.push("font-weight: bold");
|
|
353
|
-
if (this.italic)
|
|
354
|
-
parts.push("font-style: italic");
|
|
355
|
-
const decorations = [];
|
|
356
|
-
if (this.underline)
|
|
357
|
-
decorations.push("underline");
|
|
358
|
-
if (this.strike)
|
|
359
|
-
decorations.push("line-through");
|
|
360
|
-
if (this.overline)
|
|
361
|
-
decorations.push("overline");
|
|
362
|
-
if (decorations.length > 0) {
|
|
363
|
-
parts.push(`text-decoration: ${decorations.join(" ")}`);
|
|
364
|
-
}
|
|
365
|
-
if (this.dim)
|
|
366
|
-
parts.push("opacity: 0.5");
|
|
367
|
-
return parts.join("; ");
|
|
368
|
-
}
|
|
369
323
|
/**
|
|
370
324
|
* Serializes to a canonical string that round-trips through `Style.parse()`.
|
|
371
325
|
*/
|
|
@@ -503,6 +457,80 @@ export class Theme {
|
|
|
503
457
|
}
|
|
504
458
|
// --- Parse helpers ---
|
|
505
459
|
const ATTRIBUTE_SET = new Set(ATTRIBUTE_NAMES);
|
|
460
|
+
// The words each position of a definition can hold: a bare token is a keyword,
|
|
461
|
+
// an attribute or a colour name; `on` takes a colour name; `not` an attribute.
|
|
462
|
+
// The short aliases are left out, since `b` is no help to someone who typed
|
|
463
|
+
// `bolt` and a one-letter name sits one edit from every other short word.
|
|
464
|
+
// [LAW:one-source-of-truth] Derived from the lists the parser accepts from; the
|
|
465
|
+
// keywords are the three `parseStyleDefinition` reads before anything else.
|
|
466
|
+
const FOREGROUND_WORDS = ["not", "on", "link", ...ATTRIBUTE_NAMES, ...COLOR_NAMES];
|
|
467
|
+
/**
|
|
468
|
+
* Optimal string alignment distance: insertions, deletions, substitutions, and
|
|
469
|
+
* swaps of two neighbouring letters each cost one edit, so `cyna` is as near
|
|
470
|
+
* `cyan` as `rd` is to `red`. Kept to three rows, since only the two before the
|
|
471
|
+
* current one are ever read.
|
|
472
|
+
*/
|
|
473
|
+
function editDistance(a, b) {
|
|
474
|
+
let before = [];
|
|
475
|
+
let previous = Array.from({ length: b.length + 1 }, (_, j) => j);
|
|
476
|
+
for (let i = 1; i <= a.length; i++) {
|
|
477
|
+
const current = [i];
|
|
478
|
+
for (let j = 1; j <= b.length; j++) {
|
|
479
|
+
const swap = i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1];
|
|
480
|
+
current[j] = Math.min(previous[j] + 1, current[j - 1] + 1, previous[j - 1] + Number(a[i - 1] !== b[j - 1]), swap ? before[j - 2] + 1 : Infinity);
|
|
481
|
+
}
|
|
482
|
+
[before, previous] = [previous, current];
|
|
483
|
+
}
|
|
484
|
+
return previous[b.length];
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* The ` (did you mean …?)` clause for a word no position accepted, or `""`
|
|
488
|
+
* when nothing in `words` is a plausible typo of it.
|
|
489
|
+
*
|
|
490
|
+
* Plausible means within one edit per three letters, at least one, which lets
|
|
491
|
+
* `rd` reach `red` and keeps `hello` from reaching `yellow`. Every name tied
|
|
492
|
+
* for nearest is offered: `gold` is one edit from `bold` and from three
|
|
493
|
+
* `goldN` colours, and choosing among them would be a guess the reader cannot
|
|
494
|
+
* tell from a finding. Case is not an edit, because the colour parser ignores
|
|
495
|
+
* it: `Cyna` is as near `cyan` as `cyna` is.
|
|
496
|
+
*
|
|
497
|
+
* This runs on every render that meets the bad style, since only successful
|
|
498
|
+
* parses are cached. Two words differ by at least their difference in length,
|
|
499
|
+
* so a name outside the budget on length alone is never measured — which is
|
|
500
|
+
* also what keeps a long garbage token from costing length × length per name.
|
|
501
|
+
*/
|
|
502
|
+
function nearMiss(word, words) {
|
|
503
|
+
const typed = word.toLowerCase();
|
|
504
|
+
const budget = Math.max(1, Math.floor(typed.length / 3));
|
|
505
|
+
const scored = words
|
|
506
|
+
.filter((name) => Math.abs(name.length - typed.length) <= budget)
|
|
507
|
+
.map((name) => ({ name, distance: editDistance(typed, name) }));
|
|
508
|
+
const nearest = Math.min(budget, ...scored.map((s) => s.distance));
|
|
509
|
+
const names = scored
|
|
510
|
+
.filter((s) => s.distance === nearest)
|
|
511
|
+
.map((s) => `"${s.name}"`)
|
|
512
|
+
.sort();
|
|
513
|
+
return names.length === 0 ? "" : ` (did you mean ${names.join(" or ")}?)`;
|
|
514
|
+
}
|
|
515
|
+
/**
|
|
516
|
+
* A style token read as a colour. The colour parser's own error is the reason
|
|
517
|
+
* the token failed, so it rides along twice: in the message, for a reader with
|
|
518
|
+
* only the text, and as `cause`, for code that wants the original error.
|
|
519
|
+
*
|
|
520
|
+
* [LAW:single-enforcer] Both colour positions in a definition rewrap here, and
|
|
521
|
+
* the near miss is named here rather than by the colour parser: only a
|
|
522
|
+
* definition knows whether the token could also have been an attribute.
|
|
523
|
+
*/
|
|
524
|
+
function parseStyleColor(token, failure, words) {
|
|
525
|
+
try {
|
|
526
|
+
return ColorSpec.parse(token);
|
|
527
|
+
}
|
|
528
|
+
catch (cause) {
|
|
529
|
+
throw new StyleSyntaxError(`${failure} "${token}"${nearMiss(token, words)}: ${String(cause)}`, {
|
|
530
|
+
cause,
|
|
531
|
+
});
|
|
532
|
+
}
|
|
533
|
+
}
|
|
506
534
|
function parseStyleDefinition(definition) {
|
|
507
535
|
const tokens = definition.split(/\s+/);
|
|
508
536
|
const opts = {};
|
|
@@ -518,7 +546,7 @@ function parseStyleDefinition(definition) {
|
|
|
518
546
|
}
|
|
519
547
|
const attrName = ATTRIBUTE_SHORT_ALIASES[next] ?? next;
|
|
520
548
|
if (!ATTRIBUTE_SET.has(attrName)) {
|
|
521
|
-
throw new StyleSyntaxError(`Invalid attribute: "${next}"`);
|
|
549
|
+
throw new StyleSyntaxError(`Invalid attribute: "${next}"${nearMiss(next, ATTRIBUTE_NAMES)}`);
|
|
522
550
|
}
|
|
523
551
|
opts[attrName] = false;
|
|
524
552
|
i++;
|
|
@@ -531,12 +559,7 @@ function parseStyleDefinition(definition) {
|
|
|
531
559
|
if (!next) {
|
|
532
560
|
throw new StyleSyntaxError(`Expected color after "on" in style definition`);
|
|
533
561
|
}
|
|
534
|
-
|
|
535
|
-
opts.bgcolor = ColorSpec.parse(next);
|
|
536
|
-
}
|
|
537
|
-
catch {
|
|
538
|
-
throw new StyleSyntaxError(`Invalid background color: "${next}"`);
|
|
539
|
-
}
|
|
562
|
+
opts.bgcolor = parseStyleColor(next, "Invalid background color", COLOR_NAMES);
|
|
540
563
|
i++;
|
|
541
564
|
continue;
|
|
542
565
|
}
|
|
@@ -558,12 +581,7 @@ function parseStyleDefinition(definition) {
|
|
|
558
581
|
continue;
|
|
559
582
|
}
|
|
560
583
|
// Must be a color
|
|
561
|
-
|
|
562
|
-
opts.color = ColorSpec.parse(token);
|
|
563
|
-
}
|
|
564
|
-
catch {
|
|
565
|
-
throw new StyleSyntaxError(`Invalid style definition: "${token}"`);
|
|
566
|
-
}
|
|
584
|
+
opts.color = parseStyleColor(token, "Invalid style definition", FOREGROUND_WORDS);
|
|
567
585
|
i++;
|
|
568
586
|
}
|
|
569
587
|
return new Style(opts);
|
|
@@ -713,4 +731,3 @@ export const DEFAULT_STYLES = {
|
|
|
713
731
|
* a renderable sees outside a `Console`, as in `renderToString`.
|
|
714
732
|
*/
|
|
715
733
|
export const DEFAULT_THEME = new Theme();
|
|
716
|
-
//# sourceMappingURL=style.js.map
|
package/dist/core/text.d.ts
CHANGED
|
@@ -104,8 +104,7 @@ export declare class RichText implements Renderable, Measurable {
|
|
|
104
104
|
setLength(length: number): this;
|
|
105
105
|
extendStyle(count: number): this;
|
|
106
106
|
/**
|
|
107
|
-
* Truncate to a fixed cell-column width
|
|
108
|
-
* `overflow` form.
|
|
107
|
+
* Truncate to a fixed cell-column width, in one of three modes.
|
|
109
108
|
*
|
|
110
109
|
* - `mode: "right"` (default) \u2014 drop characters from the right; append
|
|
111
110
|
* `marker` (if any) at the cut.
|
|
@@ -117,10 +116,6 @@ export declare class RichText implements Renderable, Measurable {
|
|
|
117
116
|
* Marker default is `"\u2026"`. Pass `marker: ""` for raw cropping without an
|
|
118
117
|
* indicator glyph.
|
|
119
118
|
*
|
|
120
|
-
* Legacy form: `{ overflow: "ellipsis" }` is equivalent to
|
|
121
|
-
* `{ mode: "right", marker: "\u2026" }`; `{ overflow: "crop" | "fold" }` is
|
|
122
|
-
* equivalent to `{ marker: "" }`.
|
|
123
|
-
*
|
|
124
119
|
* Spans are preserved through the cut: characters that survive keep their
|
|
125
120
|
* styling; the marker (if any) is inserted as plain text with no span.
|
|
126
121
|
* Use `stylize(...)` on the result to color the marker if needed.
|
|
@@ -130,7 +125,6 @@ export declare class RichText implements Renderable, Measurable {
|
|
|
130
125
|
* branch \u2014 the unchanged path just early-returns when content fits.
|
|
131
126
|
*/
|
|
132
127
|
truncate(width: number, options?: {
|
|
133
|
-
overflow?: "fold" | "crop" | "ellipsis";
|
|
134
128
|
mode?: "right" | "left" | "middle";
|
|
135
129
|
marker?: string;
|
|
136
130
|
}): this;
|
|
@@ -259,4 +253,3 @@ export declare class RichText implements Renderable, Measurable {
|
|
|
259
253
|
*/
|
|
260
254
|
private _fitLine;
|
|
261
255
|
}
|
|
262
|
-
//# sourceMappingURL=text.d.ts.map
|
package/dist/core/text.js
CHANGED
|
@@ -5,7 +5,7 @@ import { cellLen, cellCount } from "./cells.js";
|
|
|
5
5
|
import { divideLine } from "./wrap.js";
|
|
6
6
|
import { Segment } from "./segment.js";
|
|
7
7
|
import { Style, NULL_STYLE, StyleSyntaxError } from "./style.js";
|
|
8
|
-
import { stripOscTerminators } from "./
|
|
8
|
+
import { stripOscTerminators } from "./osc8.js";
|
|
9
9
|
import { getStyle, withBoundedWidth } from "./protocol.js";
|
|
10
10
|
// Strip control characters except \t and \n
|
|
11
11
|
// [LAW:single-enforcer] Single place where control chars are sanitized
|
|
@@ -76,21 +76,29 @@ function isEmptyStyle(style) {
|
|
|
76
76
|
/**
|
|
77
77
|
* The style a stored `string | Style` stands for in this render.
|
|
78
78
|
*
|
|
79
|
+
* A parsed string can carry a link, so the result is sanitized on the way out
|
|
80
|
+
* as well.
|
|
81
|
+
*/
|
|
82
|
+
function resolveStyle(options, style) {
|
|
83
|
+
return sanitizeStyleLink(style instanceof Style ? style : resolveDefinition(options, style));
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
79
86
|
* [LAW:single-enforcer] Styling is non-critical — an unrecognized style name
|
|
80
87
|
* (typo, missing theme key, bad concatenation) degrades to unstyled rather
|
|
81
88
|
* than crashing, as the reference's `Text.render` resolves with a null
|
|
82
89
|
* default. Absorb only StyleSyntaxError here; other errors are genuine bugs
|
|
83
|
-
* and must surface.
|
|
84
|
-
*
|
|
90
|
+
* and must surface. The render's `onStyleError` hears about each one first,
|
|
91
|
+
* and a handler that throws turns the degrade into a failure.
|
|
85
92
|
*/
|
|
86
|
-
function
|
|
93
|
+
function resolveDefinition(options, style) {
|
|
87
94
|
try {
|
|
88
|
-
return
|
|
95
|
+
return getStyle(options, style);
|
|
89
96
|
}
|
|
90
97
|
catch (err) {
|
|
91
|
-
if (err instanceof StyleSyntaxError)
|
|
92
|
-
|
|
93
|
-
|
|
98
|
+
if (!(err instanceof StyleSyntaxError))
|
|
99
|
+
throw err;
|
|
100
|
+
options.onStyleError?.(err, style);
|
|
101
|
+
return NULL_STYLE;
|
|
94
102
|
}
|
|
95
103
|
}
|
|
96
104
|
// --- Span ---
|
|
@@ -467,8 +475,7 @@ export class RichText {
|
|
|
467
475
|
}
|
|
468
476
|
// --- Truncation ---
|
|
469
477
|
/**
|
|
470
|
-
* Truncate to a fixed cell-column width
|
|
471
|
-
* `overflow` form.
|
|
478
|
+
* Truncate to a fixed cell-column width, in one of three modes.
|
|
472
479
|
*
|
|
473
480
|
* - `mode: "right"` (default) \u2014 drop characters from the right; append
|
|
474
481
|
* `marker` (if any) at the cut.
|
|
@@ -480,10 +487,6 @@ export class RichText {
|
|
|
480
487
|
* Marker default is `"\u2026"`. Pass `marker: ""` for raw cropping without an
|
|
481
488
|
* indicator glyph.
|
|
482
489
|
*
|
|
483
|
-
* Legacy form: `{ overflow: "ellipsis" }` is equivalent to
|
|
484
|
-
* `{ mode: "right", marker: "\u2026" }`; `{ overflow: "crop" | "fold" }` is
|
|
485
|
-
* equivalent to `{ marker: "" }`.
|
|
486
|
-
*
|
|
487
490
|
* Spans are preserved through the cut: characters that survive keep their
|
|
488
491
|
* styling; the marker (if any) is inserted as plain text with no span.
|
|
489
492
|
* Use `stylize(...)` on the result to color the marker if needed.
|
|
@@ -495,15 +498,8 @@ export class RichText {
|
|
|
495
498
|
truncate(width, options) {
|
|
496
499
|
if (this.cellLength <= width)
|
|
497
500
|
return this;
|
|
498
|
-
const overflow = options?.overflow;
|
|
499
501
|
const mode = options?.mode ?? "right";
|
|
500
|
-
const marker = options?.marker
|
|
501
|
-
? options.marker
|
|
502
|
-
: overflow === "ellipsis"
|
|
503
|
-
? "\u2026"
|
|
504
|
-
: overflow === undefined && options?.mode !== undefined
|
|
505
|
-
? "\u2026"
|
|
506
|
-
: "";
|
|
502
|
+
const marker = options?.marker ?? "\u2026";
|
|
507
503
|
const markerWidth = cellLen(marker);
|
|
508
504
|
if (width <= 0) {
|
|
509
505
|
this.plain = "";
|
|
@@ -697,11 +693,6 @@ export class RichText {
|
|
|
697
693
|
// --- Renderable ---
|
|
698
694
|
*render(options) {
|
|
699
695
|
const text = this._expandTabs(this._text);
|
|
700
|
-
if (text.length === 0) {
|
|
701
|
-
if (this._end)
|
|
702
|
-
yield new Segment(this._end);
|
|
703
|
-
return;
|
|
704
|
-
}
|
|
705
696
|
const base = this.resolvedStyle(options);
|
|
706
697
|
const allSegments = this._buildSegments(text, base, options);
|
|
707
698
|
const logicalLines = Segment.splitLines(allSegments);
|
|
@@ -744,7 +735,13 @@ export class RichText {
|
|
|
744
735
|
}
|
|
745
736
|
}
|
|
746
737
|
}
|
|
747
|
-
|
|
738
|
+
// [LAW:single-enforcer] The one place `end` is emitted, for empty and
|
|
739
|
+
// non-empty text alike — the pre-fix code checked it once for empty text
|
|
740
|
+
// (truthy) and again for non-empty text (truthy and not the default
|
|
741
|
+
// "\n"), which gave `end` two meanings depending on whether the text was
|
|
742
|
+
// empty (rich-text-5ai). Empty text takes zero iterations of the loop
|
|
743
|
+
// above, so this is reached either way with nothing yielded but this.
|
|
744
|
+
if (this._end) {
|
|
748
745
|
yield new Segment(this._end);
|
|
749
746
|
}
|
|
750
747
|
}
|
|
@@ -990,4 +987,3 @@ export class RichText {
|
|
|
990
987
|
yield* Segment.adjustLineLength(line, maxWidth, undefined, false);
|
|
991
988
|
}
|
|
992
989
|
}
|
|
993
|
-
//# sourceMappingURL=text.js.map
|
package/dist/core/wrap.d.ts
CHANGED
package/dist/core/wrap.js
CHANGED
package/dist/host/host-stream.js
CHANGED
package/dist/host/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
export { BrowserTerminalHost } from "./terminal-host.js";
|
|
2
2
|
export type { TerminalHost, TerminalSize, DataHandler, ResizeHandler, BrowserTerminalHostOptions, XtermTerminal, XtermDisposable, XtermResizeEvent, } from "./terminal-host.js";
|
|
3
3
|
export { hostStream } from "./host-stream.js";
|
|
4
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/host/index.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ export { Box } from "./core/box.js";
|
|
|
23
23
|
export type { EdgeChars, ContentChars, RowLevel, SubstituteOptions } from "./core/box.js";
|
|
24
24
|
export { ASCII, ASCII2, ASCII_DOUBLE_HEAD, SQUARE, SQUARE_DOUBLE_HEAD, MINIMAL, MINIMAL_HEAVY_HEAD, MINIMAL_DOUBLE_HEAD, SIMPLE, SIMPLE_HEAD, SIMPLE_HEAVY, HORIZONTALS, ROUNDED, HEAVY, HEAVY_EDGE, HEAVY_HEAD, DOUBLE, DOUBLE_EDGE, MARKDOWN, } from "./core/box.js";
|
|
25
25
|
export { isRenderable, isMeasurable, withCellWidth, withBoundedWidth, } from "./core/protocol.js";
|
|
26
|
-
export type { RenderOptions, Renderable, Measurable, } from "./core/protocol.js";
|
|
26
|
+
export type { RenderOptions, Renderable, Measurable, StyleErrorHandler, } from "./core/protocol.js";
|
|
27
27
|
export type { Unsubscribe } from "./core/subscription.js";
|
|
28
28
|
export { Measurement, measureRenderables } from "./core/measure.js";
|
|
29
29
|
export { Span, RichText } from "./core/text.js";
|
|
@@ -32,10 +32,12 @@ export { Strip, PowerlineJoiner, CapsuleJoiner, PlainJoiner, GradientJoiner, } f
|
|
|
32
32
|
export type { StyledRenderable, Joiner, PowerlineJoinerOptions, CapsuleJoinerOptions, PlainJoinerOptions, GradientJoinerOptions, } from "./core/strip.js";
|
|
33
33
|
export { renderToString, segmentToString, segmentsToString, } from "./core/render.js";
|
|
34
34
|
export type { RenderToStringOptions } from "./core/render.js";
|
|
35
|
+
export { OSC8, osc8Sequences } from "./core/osc8.js";
|
|
36
|
+
export type { Osc8Sequence } from "./core/osc8.js";
|
|
35
37
|
export { MarkupRegistry, globalMarkupRegistry, renderMarkup, } from "./core/markup.js";
|
|
36
38
|
export type { MarkupTagContext, MarkupTagHandler, RenderMarkupOptions, } from "./core/markup.js";
|
|
37
39
|
export { EMOJI, emojiReplace, Emoji, NoEmoji } from "./core/emoji.js";
|
|
38
|
-
export { MarkupError, escape as escapeMarkup } from "./core/markup.js";
|
|
40
|
+
export { MarkupError, MarkupSyntaxError, escape as escapeMarkup } from "./core/markup.js";
|
|
39
41
|
export { Highlighter, NullHighlighter, RegexHighlighter, ReprHighlighter, JSONHighlighter, ISO8601Highlighter, } from "./core/highlighter.js";
|
|
40
42
|
export { Pretty } from "./core/pretty.js";
|
|
41
43
|
export type { PrettyOptions } from "./core/pretty.js";
|
|
@@ -83,4 +85,3 @@ export { Markdown } from "./renderables/markdown.js";
|
|
|
83
85
|
export type { MarkdownOptions } from "./renderables/markdown.js";
|
|
84
86
|
export { Layout } from "./renderables/layout.js";
|
|
85
87
|
export type { LayoutOptions } from "./renderables/layout.js";
|
|
86
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -41,12 +41,14 @@ export { Span, RichText } from "./core/text.js";
|
|
|
41
41
|
export { Strip, PowerlineJoiner, CapsuleJoiner, PlainJoiner, GradientJoiner, } from "./core/strip.js";
|
|
42
42
|
// renderToString — stateless one-shot emission
|
|
43
43
|
export { renderToString, segmentToString, segmentsToString, } from "./core/render.js";
|
|
44
|
+
// OSC 8 hyperlink wire grammar — for consumers that read rendered bytes back
|
|
45
|
+
export { OSC8, osc8Sequences } from "./core/osc8.js";
|
|
44
46
|
// Markup plugin tags
|
|
45
47
|
export { MarkupRegistry, globalMarkupRegistry, renderMarkup, } from "./core/markup.js";
|
|
46
48
|
// Emoji
|
|
47
49
|
export { EMOJI, emojiReplace, Emoji, NoEmoji } from "./core/emoji.js";
|
|
48
50
|
// Markup
|
|
49
|
-
export { MarkupError, escape as escapeMarkup } from "./core/markup.js";
|
|
51
|
+
export { MarkupError, MarkupSyntaxError, escape as escapeMarkup } from "./core/markup.js";
|
|
50
52
|
// Highlighter
|
|
51
53
|
export { Highlighter, NullHighlighter, RegexHighlighter, ReprHighlighter, JSONHighlighter, ISO8601Highlighter, } from "./core/highlighter.js";
|
|
52
54
|
// Pretty
|
|
@@ -100,4 +102,3 @@ export { Layout } from "./renderables/layout.js";
|
|
|
100
102
|
//
|
|
101
103
|
// This is also why there is no widget list here to keep in sync: `src/widgets/index.ts`
|
|
102
104
|
// is that list, and a copy of it in this file would be a second one to drift from.
|
|
103
|
-
//# sourceMappingURL=index.js.map
|
package/dist/node/prompt.d.ts
CHANGED
package/dist/node/prompt.js
CHANGED
package/dist/node/save.d.ts
CHANGED
|
@@ -13,10 +13,5 @@
|
|
|
13
13
|
* the IO sink.
|
|
14
14
|
*/
|
|
15
15
|
import type { Console } from "../core/console.js";
|
|
16
|
-
export declare function saveText(out: Console, path: string, options?:
|
|
17
|
-
|
|
18
|
-
}): void;
|
|
19
|
-
export declare function saveHtml(out: Console, path: string, options?: {
|
|
20
|
-
clear?: boolean;
|
|
21
|
-
}): void;
|
|
22
|
-
//# sourceMappingURL=save.d.ts.map
|
|
16
|
+
export declare function saveText(out: Console, path: string, options?: Parameters<Console["exportText"]>[0]): void;
|
|
17
|
+
export declare function saveHtml(out: Console, path: string, options?: Parameters<Console["exportHtml"]>[0]): void;
|
package/dist/node/save.js
CHANGED
package/dist/node/traceback.d.ts
CHANGED