tuiuiu.js 0.1.1
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 +324 -0
- package/dist/app/index.d.ts +9 -0
- package/dist/app/index.d.ts.map +1 -0
- package/dist/app/index.js +12 -0
- package/dist/app/index.js.map +1 -0
- package/dist/app/render-loop.d.ts +51 -0
- package/dist/app/render-loop.d.ts.map +1 -0
- package/dist/app/render-loop.js +263 -0
- package/dist/app/render-loop.js.map +1 -0
- package/dist/atoms/button.d.ts +109 -0
- package/dist/atoms/button.d.ts.map +1 -0
- package/dist/atoms/button.js +173 -0
- package/dist/atoms/button.js.map +1 -0
- package/dist/atoms/index.d.ts +29 -0
- package/dist/atoms/index.d.ts.map +1 -0
- package/dist/atoms/index.js +53 -0
- package/dist/atoms/index.js.map +1 -0
- package/dist/atoms/progress-bar.d.ts +96 -0
- package/dist/atoms/progress-bar.d.ts.map +1 -0
- package/dist/atoms/progress-bar.js +443 -0
- package/dist/atoms/progress-bar.js.map +1 -0
- package/dist/atoms/slider.d.ts +137 -0
- package/dist/atoms/slider.d.ts.map +1 -0
- package/dist/atoms/slider.js +317 -0
- package/dist/atoms/slider.js.map +1 -0
- package/dist/atoms/spinner.d.ts +91 -0
- package/dist/atoms/spinner.d.ts.map +1 -0
- package/dist/atoms/spinner.js +650 -0
- package/dist/atoms/spinner.js.map +1 -0
- package/dist/atoms/switch.d.ts +102 -0
- package/dist/atoms/switch.d.ts.map +1 -0
- package/dist/atoms/switch.js +176 -0
- package/dist/atoms/switch.js.map +1 -0
- package/dist/atoms/text-input.d.ts +82 -0
- package/dist/atoms/text-input.d.ts.map +1 -0
- package/dist/atoms/text-input.js +347 -0
- package/dist/atoms/text-input.js.map +1 -0
- package/dist/atoms/timer.d.ts +178 -0
- package/dist/atoms/timer.d.ts.map +1 -0
- package/dist/atoms/timer.js +355 -0
- package/dist/atoms/timer.js.map +1 -0
- package/dist/atoms/tooltip.d.ts +191 -0
- package/dist/atoms/tooltip.d.ts.map +1 -0
- package/dist/atoms/tooltip.js +279 -0
- package/dist/atoms/tooltip.js.map +1 -0
- package/dist/components/canvas.d.ts +322 -0
- package/dist/components/canvas.d.ts.map +1 -0
- package/dist/components/canvas.js +833 -0
- package/dist/components/canvas.js.map +1 -0
- package/dist/components/code-block.d.ts +75 -0
- package/dist/components/code-block.d.ts.map +1 -0
- package/dist/components/code-block.js +322 -0
- package/dist/components/code-block.js.map +1 -0
- package/dist/components/components.d.ts +122 -0
- package/dist/components/components.d.ts.map +1 -0
- package/dist/components/components.js +151 -0
- package/dist/components/components.js.map +1 -0
- package/dist/components/data-viz/bar-chart.d.ts +167 -0
- package/dist/components/data-viz/bar-chart.d.ts.map +1 -0
- package/dist/components/data-viz/bar-chart.js +375 -0
- package/dist/components/data-viz/bar-chart.js.map +1 -0
- package/dist/components/data-viz/gauge.d.ts +163 -0
- package/dist/components/data-viz/gauge.d.ts.map +1 -0
- package/dist/components/data-viz/gauge.js +451 -0
- package/dist/components/data-viz/gauge.js.map +1 -0
- package/dist/components/data-viz/heatmap.d.ts +154 -0
- package/dist/components/data-viz/heatmap.d.ts.map +1 -0
- package/dist/components/data-viz/heatmap.js +458 -0
- package/dist/components/data-viz/heatmap.js.map +1 -0
- package/dist/components/data-viz/index.d.ts +16 -0
- package/dist/components/data-viz/index.d.ts.map +1 -0
- package/dist/components/data-viz/index.js +16 -0
- package/dist/components/data-viz/index.js.map +1 -0
- package/dist/components/data-viz/line-chart.d.ts +157 -0
- package/dist/components/data-viz/line-chart.d.ts.map +1 -0
- package/dist/components/data-viz/line-chart.js +578 -0
- package/dist/components/data-viz/line-chart.js.map +1 -0
- package/dist/components/data-viz/sparkline.d.ts +156 -0
- package/dist/components/data-viz/sparkline.d.ts.map +1 -0
- package/dist/components/data-viz/sparkline.js +325 -0
- package/dist/components/data-viz/sparkline.js.map +1 -0
- package/dist/components/grid.d.ts +234 -0
- package/dist/components/grid.d.ts.map +1 -0
- package/dist/components/grid.js +719 -0
- package/dist/components/grid.js.map +1 -0
- package/dist/components/index.d.ts +33 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +69 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/markdown.d.ts +52 -0
- package/dist/components/markdown.d.ts.map +1 -0
- package/dist/components/markdown.js +341 -0
- package/dist/components/markdown.js.map +1 -0
- package/dist/components/modal.d.ts +237 -0
- package/dist/components/modal.d.ts.map +1 -0
- package/dist/components/modal.js +396 -0
- package/dist/components/modal.js.map +1 -0
- package/dist/components/progress-bar.d.ts +89 -0
- package/dist/components/progress-bar.d.ts.map +1 -0
- package/dist/components/progress-bar.js +288 -0
- package/dist/components/progress-bar.js.map +1 -0
- package/dist/components/select.d.ts +114 -0
- package/dist/components/select.d.ts.map +1 -0
- package/dist/components/select.js +415 -0
- package/dist/components/select.js.map +1 -0
- package/dist/components/spinner.d.ts +71 -0
- package/dist/components/spinner.d.ts.map +1 -0
- package/dist/components/spinner.js +300 -0
- package/dist/components/spinner.js.map +1 -0
- package/dist/components/split-panel.d.ts +175 -0
- package/dist/components/split-panel.d.ts.map +1 -0
- package/dist/components/split-panel.js +322 -0
- package/dist/components/split-panel.js.map +1 -0
- package/dist/components/table.d.ts +103 -0
- package/dist/components/table.d.ts.map +1 -0
- package/dist/components/table.js +359 -0
- package/dist/components/table.js.map +1 -0
- package/dist/components/text-input.d.ts +79 -0
- package/dist/components/text-input.d.ts.map +1 -0
- package/dist/components/text-input.js +332 -0
- package/dist/components/text-input.js.map +1 -0
- package/dist/core/animation.d.ts +262 -0
- package/dist/core/animation.d.ts.map +1 -0
- package/dist/core/animation.js +626 -0
- package/dist/core/animation.js.map +1 -0
- package/dist/core/buffer.d.ts +179 -0
- package/dist/core/buffer.d.ts.map +1 -0
- package/dist/core/buffer.js +549 -0
- package/dist/core/buffer.js.map +1 -0
- package/dist/core/capabilities.d.ts +184 -0
- package/dist/core/capabilities.d.ts.map +1 -0
- package/dist/core/capabilities.js +393 -0
- package/dist/core/capabilities.js.map +1 -0
- package/dist/core/colors.d.ts +111 -0
- package/dist/core/colors.d.ts.map +1 -0
- package/dist/core/colors.js +417 -0
- package/dist/core/colors.js.map +1 -0
- package/dist/core/command-palette.d.ts +220 -0
- package/dist/core/command-palette.d.ts.map +1 -0
- package/dist/core/command-palette.js +564 -0
- package/dist/core/command-palette.js.map +1 -0
- package/dist/core/constraint.d.ts +315 -0
- package/dist/core/constraint.d.ts.map +1 -0
- package/dist/core/constraint.js +651 -0
- package/dist/core/constraint.js.map +1 -0
- package/dist/core/delta-render.d.ts +64 -0
- package/dist/core/delta-render.d.ts.map +1 -0
- package/dist/core/delta-render.js +367 -0
- package/dist/core/delta-render.js.map +1 -0
- package/dist/core/dirty.d.ts +181 -0
- package/dist/core/dirty.d.ts.map +1 -0
- package/dist/core/dirty.js +335 -0
- package/dist/core/dirty.js.map +1 -0
- package/dist/core/error-boundary.d.ts +79 -0
- package/dist/core/error-boundary.d.ts.map +1 -0
- package/dist/core/error-boundary.js +258 -0
- package/dist/core/error-boundary.js.map +1 -0
- package/dist/core/events.d.ts +206 -0
- package/dist/core/events.d.ts.map +1 -0
- package/dist/core/events.js +411 -0
- package/dist/core/events.js.map +1 -0
- package/dist/core/focus.d.ts +294 -0
- package/dist/core/focus.d.ts.map +1 -0
- package/dist/core/focus.js +589 -0
- package/dist/core/focus.js.map +1 -0
- package/dist/core/graphics.d.ts +146 -0
- package/dist/core/graphics.d.ts.map +1 -0
- package/dist/core/graphics.js +561 -0
- package/dist/core/graphics.js.map +1 -0
- package/dist/core/highlighter.d.ts +148 -0
- package/dist/core/highlighter.d.ts.map +1 -0
- package/dist/core/highlighter.js +2726 -0
- package/dist/core/highlighter.js.map +1 -0
- package/dist/core/hit-test.d.ts +126 -0
- package/dist/core/hit-test.d.ts.map +1 -0
- package/dist/core/hit-test.js +336 -0
- package/dist/core/hit-test.js.map +1 -0
- package/dist/core/index.d.ts +58 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +254 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/input.d.ts +241 -0
- package/dist/core/input.d.ts.map +1 -0
- package/dist/core/input.js +768 -0
- package/dist/core/input.js.map +1 -0
- package/dist/core/keybindings.d.ts +256 -0
- package/dist/core/keybindings.d.ts.map +1 -0
- package/dist/core/keybindings.js +532 -0
- package/dist/core/keybindings.js.map +1 -0
- package/dist/core/layout.d.ts +30 -0
- package/dist/core/layout.d.ts.map +1 -0
- package/dist/core/layout.js +347 -0
- package/dist/core/layout.js.map +1 -0
- package/dist/core/overlay.d.ts +318 -0
- package/dist/core/overlay.d.ts.map +1 -0
- package/dist/core/overlay.js +794 -0
- package/dist/core/overlay.js.map +1 -0
- package/dist/core/query.d.ts +155 -0
- package/dist/core/query.d.ts.map +1 -0
- package/dist/core/query.js +616 -0
- package/dist/core/query.js.map +1 -0
- package/dist/core/renderer.d.ts +28 -0
- package/dist/core/renderer.d.ts.map +1 -0
- package/dist/core/renderer.js +403 -0
- package/dist/core/renderer.js.map +1 -0
- package/dist/core/router.d.ts +401 -0
- package/dist/core/router.d.ts.map +1 -0
- package/dist/core/router.js +766 -0
- package/dist/core/router.js.map +1 -0
- package/dist/core/screen.d.ts +302 -0
- package/dist/core/screen.d.ts.map +1 -0
- package/dist/core/screen.js +537 -0
- package/dist/core/screen.js.map +1 -0
- package/dist/core/signal.d.ts +136 -0
- package/dist/core/signal.d.ts.map +1 -0
- package/dist/core/signal.js +336 -0
- package/dist/core/signal.js.map +1 -0
- package/dist/core/theme.d.ts +220 -0
- package/dist/core/theme.d.ts.map +1 -0
- package/dist/core/theme.js +499 -0
- package/dist/core/theme.js.map +1 -0
- package/dist/core/tick.d.ts +107 -0
- package/dist/core/tick.d.ts.map +1 -0
- package/dist/core/tick.js +174 -0
- package/dist/core/tick.js.map +1 -0
- package/dist/core/transitions.d.ts +335 -0
- package/dist/core/transitions.d.ts.map +1 -0
- package/dist/core/transitions.js +650 -0
- package/dist/core/transitions.js.map +1 -0
- package/dist/core/virtual-scroll.d.ts +241 -0
- package/dist/core/virtual-scroll.d.ts.map +1 -0
- package/dist/core/virtual-scroll.js +476 -0
- package/dist/core/virtual-scroll.js.map +1 -0
- package/dist/core/visualization.d.ts +248 -0
- package/dist/core/visualization.d.ts.map +1 -0
- package/dist/core/visualization.js +709 -0
- package/dist/core/visualization.js.map +1 -0
- package/dist/design-system/core/index.d.ts +6 -0
- package/dist/design-system/core/index.d.ts.map +1 -0
- package/dist/design-system/core/index.js +6 -0
- package/dist/design-system/core/index.js.map +1 -0
- package/dist/design-system/core/layout.d.ts +30 -0
- package/dist/design-system/core/layout.d.ts.map +1 -0
- package/dist/design-system/core/layout.js +344 -0
- package/dist/design-system/core/layout.js.map +1 -0
- package/dist/design-system/core/renderer.d.ts +28 -0
- package/dist/design-system/core/renderer.d.ts.map +1 -0
- package/dist/design-system/core/renderer.js +418 -0
- package/dist/design-system/core/renderer.js.map +1 -0
- package/dist/design-system/data-display/calendar.d.ts +141 -0
- package/dist/design-system/data-display/calendar.d.ts.map +1 -0
- package/dist/design-system/data-display/calendar.js +524 -0
- package/dist/design-system/data-display/calendar.js.map +1 -0
- package/dist/design-system/data-display/code-block.d.ts +75 -0
- package/dist/design-system/data-display/code-block.d.ts.map +1 -0
- package/dist/design-system/data-display/code-block.js +311 -0
- package/dist/design-system/data-display/code-block.js.map +1 -0
- package/dist/design-system/data-display/data-table.d.ts +173 -0
- package/dist/design-system/data-display/data-table.d.ts.map +1 -0
- package/dist/design-system/data-display/data-table.js +428 -0
- package/dist/design-system/data-display/data-table.js.map +1 -0
- package/dist/design-system/data-display/index.d.ts +10 -0
- package/dist/design-system/data-display/index.d.ts.map +1 -0
- package/dist/design-system/data-display/index.js +16 -0
- package/dist/design-system/data-display/index.js.map +1 -0
- package/dist/design-system/data-display/markdown.d.ts +52 -0
- package/dist/design-system/data-display/markdown.d.ts.map +1 -0
- package/dist/design-system/data-display/markdown.js +341 -0
- package/dist/design-system/data-display/markdown.js.map +1 -0
- package/dist/design-system/data-display/table.d.ts +103 -0
- package/dist/design-system/data-display/table.d.ts.map +1 -0
- package/dist/design-system/data-display/table.js +342 -0
- package/dist/design-system/data-display/table.js.map +1 -0
- package/dist/design-system/data-display/tree.d.ts +166 -0
- package/dist/design-system/data-display/tree.d.ts.map +1 -0
- package/dist/design-system/data-display/tree.js +428 -0
- package/dist/design-system/data-display/tree.js.map +1 -0
- package/dist/design-system/feedback/badge.d.ts +21 -0
- package/dist/design-system/feedback/badge.d.ts.map +1 -0
- package/dist/design-system/feedback/badge.js +9 -0
- package/dist/design-system/feedback/badge.js.map +1 -0
- package/dist/design-system/feedback/index.d.ts +8 -0
- package/dist/design-system/feedback/index.d.ts.map +1 -0
- package/dist/design-system/feedback/index.js +12 -0
- package/dist/design-system/feedback/index.js.map +1 -0
- package/dist/design-system/feedback/progress-bar.d.ts +93 -0
- package/dist/design-system/feedback/progress-bar.d.ts.map +1 -0
- package/dist/design-system/feedback/progress-bar.js +440 -0
- package/dist/design-system/feedback/progress-bar.js.map +1 -0
- package/dist/design-system/feedback/spinner.d.ts +88 -0
- package/dist/design-system/feedback/spinner.d.ts.map +1 -0
- package/dist/design-system/feedback/spinner.js +679 -0
- package/dist/design-system/feedback/spinner.js.map +1 -0
- package/dist/design-system/feedback/timer.d.ts +175 -0
- package/dist/design-system/feedback/timer.d.ts.map +1 -0
- package/dist/design-system/feedback/timer.js +352 -0
- package/dist/design-system/feedback/timer.js.map +1 -0
- package/dist/design-system/forms/autocomplete.d.ts +163 -0
- package/dist/design-system/forms/autocomplete.d.ts.map +1 -0
- package/dist/design-system/forms/autocomplete.js +455 -0
- package/dist/design-system/forms/autocomplete.js.map +1 -0
- package/dist/design-system/forms/button.d.ts +106 -0
- package/dist/design-system/forms/button.d.ts.map +1 -0
- package/dist/design-system/forms/button.js +170 -0
- package/dist/design-system/forms/button.js.map +1 -0
- package/dist/design-system/forms/index.d.ts +12 -0
- package/dist/design-system/forms/index.d.ts.map +1 -0
- package/dist/design-system/forms/index.js +20 -0
- package/dist/design-system/forms/index.js.map +1 -0
- package/dist/design-system/forms/multi-select.d.ts +102 -0
- package/dist/design-system/forms/multi-select.d.ts.map +1 -0
- package/dist/design-system/forms/multi-select.js +309 -0
- package/dist/design-system/forms/multi-select.js.map +1 -0
- package/dist/design-system/forms/radio-group.d.ts +88 -0
- package/dist/design-system/forms/radio-group.d.ts.map +1 -0
- package/dist/design-system/forms/radio-group.js +145 -0
- package/dist/design-system/forms/radio-group.js.map +1 -0
- package/dist/design-system/forms/select.d.ts +116 -0
- package/dist/design-system/forms/select.d.ts.map +1 -0
- package/dist/design-system/forms/select.js +441 -0
- package/dist/design-system/forms/select.js.map +1 -0
- package/dist/design-system/forms/slider.d.ts +134 -0
- package/dist/design-system/forms/slider.d.ts.map +1 -0
- package/dist/design-system/forms/slider.js +314 -0
- package/dist/design-system/forms/slider.js.map +1 -0
- package/dist/design-system/forms/switch.d.ts +99 -0
- package/dist/design-system/forms/switch.d.ts.map +1 -0
- package/dist/design-system/forms/switch.js +173 -0
- package/dist/design-system/forms/switch.js.map +1 -0
- package/dist/design-system/forms/text-input.d.ts +79 -0
- package/dist/design-system/forms/text-input.d.ts.map +1 -0
- package/dist/design-system/forms/text-input.js +344 -0
- package/dist/design-system/forms/text-input.js.map +1 -0
- package/dist/design-system/index.d.ts +23 -0
- package/dist/design-system/index.d.ts.map +1 -0
- package/dist/design-system/index.js +74 -0
- package/dist/design-system/index.js.map +1 -0
- package/dist/design-system/layout/app.d.ts +205 -0
- package/dist/design-system/layout/app.d.ts.map +1 -0
- package/dist/design-system/layout/app.js +286 -0
- package/dist/design-system/layout/app.js.map +1 -0
- package/dist/design-system/layout/collapsible.d.ts +166 -0
- package/dist/design-system/layout/collapsible.d.ts.map +1 -0
- package/dist/design-system/layout/collapsible.js +286 -0
- package/dist/design-system/layout/collapsible.js.map +1 -0
- package/dist/design-system/layout/grid.d.ts +232 -0
- package/dist/design-system/layout/grid.d.ts.map +1 -0
- package/dist/design-system/layout/grid.js +333 -0
- package/dist/design-system/layout/grid.js.map +1 -0
- package/dist/design-system/layout/index.d.ts +27 -0
- package/dist/design-system/layout/index.d.ts.map +1 -0
- package/dist/design-system/layout/index.js +34 -0
- package/dist/design-system/layout/index.js.map +1 -0
- package/dist/design-system/layout/scroll-area.d.ts +188 -0
- package/dist/design-system/layout/scroll-area.d.ts.map +1 -0
- package/dist/design-system/layout/scroll-area.js +348 -0
- package/dist/design-system/layout/scroll-area.js.map +1 -0
- package/dist/design-system/layout/split-panel.d.ts +183 -0
- package/dist/design-system/layout/split-panel.d.ts.map +1 -0
- package/dist/design-system/layout/split-panel.js +323 -0
- package/dist/design-system/layout/split-panel.js.map +1 -0
- package/dist/design-system/layout/stack.d.ts +189 -0
- package/dist/design-system/layout/stack.d.ts.map +1 -0
- package/dist/design-system/layout/stack.js +170 -0
- package/dist/design-system/layout/stack.js.map +1 -0
- package/dist/design-system/layout/tabs.d.ts +129 -0
- package/dist/design-system/layout/tabs.d.ts.map +1 -0
- package/dist/design-system/layout/tabs.js +373 -0
- package/dist/design-system/layout/tabs.js.map +1 -0
- package/dist/design-system/media/index.d.ts +13 -0
- package/dist/design-system/media/index.d.ts.map +1 -0
- package/dist/design-system/media/index.js +23 -0
- package/dist/design-system/media/index.js.map +1 -0
- package/dist/design-system/media/picture.d.ts +304 -0
- package/dist/design-system/media/picture.d.ts.map +1 -0
- package/dist/design-system/media/picture.js +681 -0
- package/dist/design-system/media/picture.js.map +1 -0
- package/dist/design-system/navigation/file-manager.d.ts +492 -0
- package/dist/design-system/navigation/file-manager.d.ts.map +1 -0
- package/dist/design-system/navigation/file-manager.js +807 -0
- package/dist/design-system/navigation/file-manager.js.map +1 -0
- package/dist/design-system/navigation/index.d.ts +13 -0
- package/dist/design-system/navigation/index.d.ts.map +1 -0
- package/dist/design-system/navigation/index.js +19 -0
- package/dist/design-system/navigation/index.js.map +1 -0
- package/dist/design-system/overlays/command-palette.d.ts +217 -0
- package/dist/design-system/overlays/command-palette.d.ts.map +1 -0
- package/dist/design-system/overlays/command-palette.js +443 -0
- package/dist/design-system/overlays/command-palette.js.map +1 -0
- package/dist/design-system/overlays/index.d.ts +7 -0
- package/dist/design-system/overlays/index.d.ts.map +1 -0
- package/dist/design-system/overlays/index.js +10 -0
- package/dist/design-system/overlays/index.js.map +1 -0
- package/dist/design-system/overlays/modal.d.ts +251 -0
- package/dist/design-system/overlays/modal.d.ts.map +1 -0
- package/dist/design-system/overlays/modal.js +461 -0
- package/dist/design-system/overlays/modal.js.map +1 -0
- package/dist/design-system/overlays/overlay-stack.d.ts +200 -0
- package/dist/design-system/overlays/overlay-stack.d.ts.map +1 -0
- package/dist/design-system/overlays/overlay-stack.js +341 -0
- package/dist/design-system/overlays/overlay-stack.js.map +1 -0
- package/dist/design-system/primitives/box.d.ts +16 -0
- package/dist/design-system/primitives/box.d.ts.map +1 -0
- package/dist/design-system/primitives/box.js +23 -0
- package/dist/design-system/primitives/box.js.map +1 -0
- package/dist/design-system/primitives/divider.d.ts +52 -0
- package/dist/design-system/primitives/divider.d.ts.map +1 -0
- package/dist/design-system/primitives/divider.js +72 -0
- package/dist/design-system/primitives/divider.js.map +1 -0
- package/dist/design-system/primitives/helpers.d.ts +10 -0
- package/dist/design-system/primitives/helpers.d.ts.map +1 -0
- package/dist/design-system/primitives/helpers.js +27 -0
- package/dist/design-system/primitives/helpers.js.map +1 -0
- package/dist/design-system/primitives/index.d.ts +11 -0
- package/dist/design-system/primitives/index.d.ts.map +1 -0
- package/dist/design-system/primitives/index.js +14 -0
- package/dist/design-system/primitives/index.js.map +1 -0
- package/dist/design-system/primitives/slot.d.ts +35 -0
- package/dist/design-system/primitives/slot.d.ts.map +1 -0
- package/dist/design-system/primitives/slot.js +17 -0
- package/dist/design-system/primitives/slot.js.map +1 -0
- package/dist/design-system/primitives/spacer.d.ts +34 -0
- package/dist/design-system/primitives/spacer.d.ts.map +1 -0
- package/dist/design-system/primitives/spacer.js +53 -0
- package/dist/design-system/primitives/spacer.js.map +1 -0
- package/dist/design-system/primitives/text.d.ts +12 -0
- package/dist/design-system/primitives/text.d.ts.map +1 -0
- package/dist/design-system/primitives/text.js +25 -0
- package/dist/design-system/primitives/text.js.map +1 -0
- package/dist/design-system/primitives/utilities.d.ts +70 -0
- package/dist/design-system/primitives/utilities.d.ts.map +1 -0
- package/dist/design-system/primitives/utilities.js +56 -0
- package/dist/design-system/primitives/utilities.js.map +1 -0
- package/dist/design-system/visual/big-text.d.ts +151 -0
- package/dist/design-system/visual/big-text.d.ts.map +1 -0
- package/dist/design-system/visual/big-text.js +578 -0
- package/dist/design-system/visual/big-text.js.map +1 -0
- package/dist/design-system/visual/digits.d.ts +159 -0
- package/dist/design-system/visual/digits.d.ts.map +1 -0
- package/dist/design-system/visual/digits.js +287 -0
- package/dist/design-system/visual/digits.js.map +1 -0
- package/dist/design-system/visual/index.d.ts +20 -0
- package/dist/design-system/visual/index.d.ts.map +1 -0
- package/dist/design-system/visual/index.js +23 -0
- package/dist/design-system/visual/index.js.map +1 -0
- package/dist/design-system/visual/splash-screen.d.ts +93 -0
- package/dist/design-system/visual/splash-screen.d.ts.map +1 -0
- package/dist/design-system/visual/splash-screen.js +219 -0
- package/dist/design-system/visual/splash-screen.js.map +1 -0
- package/dist/design-system/visual/tooltip.d.ts +188 -0
- package/dist/design-system/visual/tooltip.d.ts.map +1 -0
- package/dist/design-system/visual/tooltip.js +276 -0
- package/dist/design-system/visual/tooltip.js.map +1 -0
- package/dist/dev-tools/debugger.d.ts +223 -0
- package/dist/dev-tools/debugger.d.ts.map +1 -0
- package/dist/dev-tools/debugger.js +489 -0
- package/dist/dev-tools/debugger.js.map +1 -0
- package/dist/dev-tools/index.d.ts +22 -0
- package/dist/dev-tools/index.d.ts.map +1 -0
- package/dist/dev-tools/index.js +63 -0
- package/dist/dev-tools/index.js.map +1 -0
- package/dist/dev-tools/mouse-simulator.d.ts +155 -0
- package/dist/dev-tools/mouse-simulator.d.ts.map +1 -0
- package/dist/dev-tools/mouse-simulator.js +314 -0
- package/dist/dev-tools/mouse-simulator.js.map +1 -0
- package/dist/dev-tools/testing.d.ts +262 -0
- package/dist/dev-tools/testing.d.ts.map +1 -0
- package/dist/dev-tools/testing.js +858 -0
- package/dist/dev-tools/testing.js.map +1 -0
- package/dist/hooks/context.d.ts +47 -0
- package/dist/hooks/context.d.ts.map +1 -0
- package/dist/hooks/context.js +108 -0
- package/dist/hooks/context.js.map +1 -0
- package/dist/hooks/focus-context.d.ts +65 -0
- package/dist/hooks/focus-context.d.ts.map +1 -0
- package/dist/hooks/focus-context.js +79 -0
- package/dist/hooks/focus-context.js.map +1 -0
- package/dist/hooks/index.d.ts +16 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +22 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/types.d.ts +76 -0
- package/dist/hooks/types.d.ts.map +1 -0
- package/dist/hooks/types.js +5 -0
- package/dist/hooks/types.js.map +1 -0
- package/dist/hooks/use-app.d.ts +27 -0
- package/dist/hooks/use-app.d.ts.map +1 -0
- package/dist/hooks/use-app.js +179 -0
- package/dist/hooks/use-app.js.map +1 -0
- package/dist/hooks/use-effect.d.ts +20 -0
- package/dist/hooks/use-effect.d.ts.map +1 -0
- package/dist/hooks/use-effect.js +55 -0
- package/dist/hooks/use-effect.js.map +1 -0
- package/dist/hooks/use-focus.d.ts +48 -0
- package/dist/hooks/use-focus.d.ts.map +1 -0
- package/dist/hooks/use-focus.js +152 -0
- package/dist/hooks/use-focus.js.map +1 -0
- package/dist/hooks/use-input.d.ts +35 -0
- package/dist/hooks/use-input.d.ts.map +1 -0
- package/dist/hooks/use-input.js +352 -0
- package/dist/hooks/use-input.js.map +1 -0
- package/dist/hooks/use-mouse.d.ts +82 -0
- package/dist/hooks/use-mouse.d.ts.map +1 -0
- package/dist/hooks/use-mouse.js +328 -0
- package/dist/hooks/use-mouse.js.map +1 -0
- package/dist/hooks/use-navigation.d.ts +206 -0
- package/dist/hooks/use-navigation.d.ts.map +1 -0
- package/dist/hooks/use-navigation.js +319 -0
- package/dist/hooks/use-navigation.js.map +1 -0
- package/dist/hooks/use-state.d.ts +15 -0
- package/dist/hooks/use-state.d.ts.map +1 -0
- package/dist/hooks/use-state.js +29 -0
- package/dist/hooks/use-state.js.map +1 -0
- package/dist/hooks/use-terminal-size.d.ts +12 -0
- package/dist/hooks/use-terminal-size.d.ts.map +1 -0
- package/dist/hooks/use-terminal-size.js +20 -0
- package/dist/hooks/use-terminal-size.js.map +1 -0
- package/dist/index.d.ts +85 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +334 -0
- package/dist/index.js.map +1 -0
- package/dist/molecules/autocomplete.d.ts +166 -0
- package/dist/molecules/autocomplete.d.ts.map +1 -0
- package/dist/molecules/autocomplete.js +458 -0
- package/dist/molecules/autocomplete.js.map +1 -0
- package/dist/molecules/calendar.d.ts +144 -0
- package/dist/molecules/calendar.d.ts.map +1 -0
- package/dist/molecules/calendar.js +527 -0
- package/dist/molecules/calendar.js.map +1 -0
- package/dist/molecules/code-block.d.ts +88 -0
- package/dist/molecules/code-block.d.ts.map +1 -0
- package/dist/molecules/code-block.js +324 -0
- package/dist/molecules/code-block.js.map +1 -0
- package/dist/molecules/collapsible.d.ts +169 -0
- package/dist/molecules/collapsible.d.ts.map +1 -0
- package/dist/molecules/collapsible.js +289 -0
- package/dist/molecules/collapsible.js.map +1 -0
- package/dist/molecules/data-viz/bar-chart.d.ts +167 -0
- package/dist/molecules/data-viz/bar-chart.d.ts.map +1 -0
- package/dist/molecules/data-viz/bar-chart.js +375 -0
- package/dist/molecules/data-viz/bar-chart.js.map +1 -0
- package/dist/molecules/data-viz/gauge.d.ts +163 -0
- package/dist/molecules/data-viz/gauge.d.ts.map +1 -0
- package/dist/molecules/data-viz/gauge.js +451 -0
- package/dist/molecules/data-viz/gauge.js.map +1 -0
- package/dist/molecules/data-viz/heatmap.d.ts +154 -0
- package/dist/molecules/data-viz/heatmap.d.ts.map +1 -0
- package/dist/molecules/data-viz/heatmap.js +458 -0
- package/dist/molecules/data-viz/heatmap.js.map +1 -0
- package/dist/molecules/data-viz/index.d.ts +16 -0
- package/dist/molecules/data-viz/index.d.ts.map +1 -0
- package/dist/molecules/data-viz/index.js +16 -0
- package/dist/molecules/data-viz/index.js.map +1 -0
- package/dist/molecules/data-viz/line-chart.d.ts +157 -0
- package/dist/molecules/data-viz/line-chart.d.ts.map +1 -0
- package/dist/molecules/data-viz/line-chart.js +578 -0
- package/dist/molecules/data-viz/line-chart.js.map +1 -0
- package/dist/molecules/data-viz/sparkline.d.ts +156 -0
- package/dist/molecules/data-viz/sparkline.d.ts.map +1 -0
- package/dist/molecules/data-viz/sparkline.js +325 -0
- package/dist/molecules/data-viz/sparkline.js.map +1 -0
- package/dist/molecules/index.d.ts +22 -0
- package/dist/molecules/index.d.ts.map +1 -0
- package/dist/molecules/index.js +26 -0
- package/dist/molecules/index.js.map +1 -0
- package/dist/molecules/markdown.d.ts +61 -0
- package/dist/molecules/markdown.d.ts.map +1 -0
- package/dist/molecules/markdown.js +350 -0
- package/dist/molecules/markdown.js.map +1 -0
- package/dist/molecules/multi-select.d.ts +105 -0
- package/dist/molecules/multi-select.d.ts.map +1 -0
- package/dist/molecules/multi-select.js +312 -0
- package/dist/molecules/multi-select.js.map +1 -0
- package/dist/molecules/radio-group.d.ts +91 -0
- package/dist/molecules/radio-group.d.ts.map +1 -0
- package/dist/molecules/radio-group.js +148 -0
- package/dist/molecules/radio-group.js.map +1 -0
- package/dist/molecules/select.d.ts +119 -0
- package/dist/molecules/select.d.ts.map +1 -0
- package/dist/molecules/select.js +444 -0
- package/dist/molecules/select.js.map +1 -0
- package/dist/molecules/table.d.ts +106 -0
- package/dist/molecules/table.d.ts.map +1 -0
- package/dist/molecules/table.js +345 -0
- package/dist/molecules/table.js.map +1 -0
- package/dist/molecules/tabs.d.ts +132 -0
- package/dist/molecules/tabs.d.ts.map +1 -0
- package/dist/molecules/tabs.js +376 -0
- package/dist/molecules/tabs.js.map +1 -0
- package/dist/molecules/tree.d.ts +169 -0
- package/dist/molecules/tree.d.ts.map +1 -0
- package/dist/molecules/tree.js +431 -0
- package/dist/molecules/tree.js.map +1 -0
- package/dist/organisms/command-palette.d.ts +217 -0
- package/dist/organisms/command-palette.d.ts.map +1 -0
- package/dist/organisms/command-palette.js +443 -0
- package/dist/organisms/command-palette.js.map +1 -0
- package/dist/organisms/data-table.d.ts +173 -0
- package/dist/organisms/data-table.d.ts.map +1 -0
- package/dist/organisms/data-table.js +428 -0
- package/dist/organisms/data-table.js.map +1 -0
- package/dist/organisms/file-browser.d.ts +492 -0
- package/dist/organisms/file-browser.d.ts.map +1 -0
- package/dist/organisms/file-browser.js +807 -0
- package/dist/organisms/file-browser.js.map +1 -0
- package/dist/organisms/grid.d.ts +234 -0
- package/dist/organisms/grid.d.ts.map +1 -0
- package/dist/organisms/grid.js +719 -0
- package/dist/organisms/grid.js.map +1 -0
- package/dist/organisms/index.d.ts +30 -0
- package/dist/organisms/index.d.ts.map +1 -0
- package/dist/organisms/index.js +92 -0
- package/dist/organisms/index.js.map +1 -0
- package/dist/organisms/modal.d.ts +251 -0
- package/dist/organisms/modal.d.ts.map +1 -0
- package/dist/organisms/modal.js +461 -0
- package/dist/organisms/modal.js.map +1 -0
- package/dist/organisms/overlay-stack.d.ts +200 -0
- package/dist/organisms/overlay-stack.d.ts.map +1 -0
- package/dist/organisms/overlay-stack.js +341 -0
- package/dist/organisms/overlay-stack.js.map +1 -0
- package/dist/organisms/scroll-area.d.ts +188 -0
- package/dist/organisms/scroll-area.d.ts.map +1 -0
- package/dist/organisms/scroll-area.js +348 -0
- package/dist/organisms/scroll-area.js.map +1 -0
- package/dist/organisms/split-panel.d.ts +183 -0
- package/dist/organisms/split-panel.d.ts.map +1 -0
- package/dist/organisms/split-panel.js +323 -0
- package/dist/organisms/split-panel.js.map +1 -0
- package/dist/primitives/canvas.d.ts +322 -0
- package/dist/primitives/canvas.d.ts.map +1 -0
- package/dist/primitives/canvas.js +833 -0
- package/dist/primitives/canvas.js.map +1 -0
- package/dist/primitives/context.d.ts +83 -0
- package/dist/primitives/context.d.ts.map +1 -0
- package/dist/primitives/context.js +101 -0
- package/dist/primitives/context.js.map +1 -0
- package/dist/primitives/divider.d.ts +52 -0
- package/dist/primitives/divider.d.ts.map +1 -0
- package/dist/primitives/divider.js +71 -0
- package/dist/primitives/divider.js.map +1 -0
- package/dist/primitives/index.d.ts +10 -0
- package/dist/primitives/index.d.ts.map +1 -0
- package/dist/primitives/index.js +10 -0
- package/dist/primitives/index.js.map +1 -0
- package/dist/primitives/nodes.d.ts +152 -0
- package/dist/primitives/nodes.d.ts.map +1 -0
- package/dist/primitives/nodes.js +164 -0
- package/dist/primitives/nodes.js.map +1 -0
- package/dist/primitives/signal.d.ts +136 -0
- package/dist/primitives/signal.d.ts.map +1 -0
- package/dist/primitives/signal.js +338 -0
- package/dist/primitives/signal.js.map +1 -0
- package/dist/primitives/store.d.ts +86 -0
- package/dist/primitives/store.d.ts.map +1 -0
- package/dist/primitives/store.js +147 -0
- package/dist/primitives/store.js.map +1 -0
- package/dist/storybook/app.d.ts +16 -0
- package/dist/storybook/app.d.ts.map +1 -0
- package/dist/storybook/app.js +697 -0
- package/dist/storybook/app.js.map +1 -0
- package/dist/storybook/cli.d.ts +10 -0
- package/dist/storybook/cli.d.ts.map +1 -0
- package/dist/storybook/cli.js +14 -0
- package/dist/storybook/cli.js.map +1 -0
- package/dist/storybook/components/compare-view.d.ts +46 -0
- package/dist/storybook/components/compare-view.d.ts.map +1 -0
- package/dist/storybook/components/compare-view.js +235 -0
- package/dist/storybook/components/compare-view.js.map +1 -0
- package/dist/storybook/components/index.d.ts +7 -0
- package/dist/storybook/components/index.d.ts.map +1 -0
- package/dist/storybook/components/index.js +7 -0
- package/dist/storybook/components/index.js.map +1 -0
- package/dist/storybook/components/log-viewer.d.ts +9 -0
- package/dist/storybook/components/log-viewer.d.ts.map +1 -0
- package/dist/storybook/components/log-viewer.js +46 -0
- package/dist/storybook/components/log-viewer.js.map +1 -0
- package/dist/storybook/components/preview.d.ts +28 -0
- package/dist/storybook/components/preview.d.ts.map +1 -0
- package/dist/storybook/components/preview.js +248 -0
- package/dist/storybook/components/preview.js.map +1 -0
- package/dist/storybook/components/sidebar.d.ts +29 -0
- package/dist/storybook/components/sidebar.d.ts.map +1 -0
- package/dist/storybook/components/sidebar.js +176 -0
- package/dist/storybook/components/sidebar.js.map +1 -0
- package/dist/storybook/core/comparatives.d.ts +94 -0
- package/dist/storybook/core/comparatives.d.ts.map +1 -0
- package/dist/storybook/core/comparatives.js +301 -0
- package/dist/storybook/core/comparatives.js.map +1 -0
- package/dist/storybook/core/index.d.ts +8 -0
- package/dist/storybook/core/index.d.ts.map +1 -0
- package/dist/storybook/core/index.js +8 -0
- package/dist/storybook/core/index.js.map +1 -0
- package/dist/storybook/core/navigator.d.ts +64 -0
- package/dist/storybook/core/navigator.d.ts.map +1 -0
- package/dist/storybook/core/navigator.js +279 -0
- package/dist/storybook/core/navigator.js.map +1 -0
- package/dist/storybook/core/playground.d.ts +73 -0
- package/dist/storybook/core/playground.d.ts.map +1 -0
- package/dist/storybook/core/playground.js +338 -0
- package/dist/storybook/core/playground.js.map +1 -0
- package/dist/storybook/core/registry.d.ts +87 -0
- package/dist/storybook/core/registry.d.ts.map +1 -0
- package/dist/storybook/core/registry.js +222 -0
- package/dist/storybook/core/registry.js.map +1 -0
- package/dist/storybook/data/ascii-art.d.ts +18 -0
- package/dist/storybook/data/ascii-art.d.ts.map +1 -0
- package/dist/storybook/data/ascii-art.js +62 -0
- package/dist/storybook/data/ascii-art.js.map +1 -0
- package/dist/storybook/data/tuiuiu-bird-colored.d.ts +13 -0
- package/dist/storybook/data/tuiuiu-bird-colored.d.ts.map +1 -0
- package/dist/storybook/data/tuiuiu-bird-colored.js +12 -0
- package/dist/storybook/data/tuiuiu-bird-colored.js.map +1 -0
- package/dist/storybook/index.d.ts +33 -0
- package/dist/storybook/index.d.ts.map +1 -0
- package/dist/storybook/index.js +44 -0
- package/dist/storybook/index.js.map +1 -0
- package/dist/storybook/store.d.ts +39 -0
- package/dist/storybook/store.d.ts.map +1 -0
- package/dist/storybook/store.js +91 -0
- package/dist/storybook/store.js.map +1 -0
- package/dist/storybook/stories/apps/index.d.ts +24 -0
- package/dist/storybook/stories/apps/index.d.ts.map +1 -0
- package/dist/storybook/stories/apps/index.js +434 -0
- package/dist/storybook/stories/apps/index.js.map +1 -0
- package/dist/storybook/stories/atoms/index.d.ts +40 -0
- package/dist/storybook/stories/atoms/index.d.ts.map +1 -0
- package/dist/storybook/stories/atoms/index.js +462 -0
- package/dist/storybook/stories/atoms/index.js.map +1 -0
- package/dist/storybook/stories/index.d.ts +37 -0
- package/dist/storybook/stories/index.d.ts.map +1 -0
- package/dist/storybook/stories/index.js +56 -0
- package/dist/storybook/stories/index.js.map +1 -0
- package/dist/storybook/stories/molecules/index.d.ts +68 -0
- package/dist/storybook/stories/molecules/index.d.ts.map +1 -0
- package/dist/storybook/stories/molecules/index.js +587 -0
- package/dist/storybook/stories/molecules/index.js.map +1 -0
- package/dist/storybook/stories/organisms/index.d.ts +29 -0
- package/dist/storybook/stories/organisms/index.d.ts.map +1 -0
- package/dist/storybook/stories/organisms/index.js +677 -0
- package/dist/storybook/stories/organisms/index.js.map +1 -0
- package/dist/storybook/types.d.ts +40 -0
- package/dist/storybook/types.d.ts.map +1 -0
- package/dist/storybook/types.js +5 -0
- package/dist/storybook/types.js.map +1 -0
- package/dist/styling/index.d.ts +12 -0
- package/dist/styling/index.d.ts.map +1 -0
- package/dist/styling/index.js +24 -0
- package/dist/styling/index.js.map +1 -0
- package/dist/styling/parser.d.ts +217 -0
- package/dist/styling/parser.d.ts.map +1 -0
- package/dist/styling/parser.js +901 -0
- package/dist/styling/parser.js.map +1 -0
- package/dist/styling/resolver.d.ts +217 -0
- package/dist/styling/resolver.d.ts.map +1 -0
- package/dist/styling/resolver.js +628 -0
- package/dist/styling/resolver.js.map +1 -0
- package/dist/styling/tokenizer.d.ts +121 -0
- package/dist/styling/tokenizer.d.ts.map +1 -0
- package/dist/styling/tokenizer.js +553 -0
- package/dist/styling/tokenizer.js.map +1 -0
- package/dist/templates/app.d.ts +205 -0
- package/dist/templates/app.d.ts.map +1 -0
- package/dist/templates/app.js +286 -0
- package/dist/templates/app.js.map +1 -0
- package/dist/templates/index.d.ts +30 -0
- package/dist/templates/index.d.ts.map +1 -0
- package/dist/templates/index.js +40 -0
- package/dist/templates/index.js.map +1 -0
- package/dist/templates/stack.d.ts +189 -0
- package/dist/templates/stack.d.ts.map +1 -0
- package/dist/templates/stack.js +170 -0
- package/dist/templates/stack.js.map +1 -0
- package/dist/utils/batcher.d.ts +88 -0
- package/dist/utils/batcher.d.ts.map +1 -0
- package/dist/utils/batcher.js +172 -0
- package/dist/utils/batcher.js.map +1 -0
- package/dist/utils/cursor.d.ts +28 -0
- package/dist/utils/cursor.d.ts.map +1 -0
- package/dist/utils/cursor.js +86 -0
- package/dist/utils/cursor.js.map +1 -0
- package/dist/utils/fs-storage.d.ts +23 -0
- package/dist/utils/fs-storage.d.ts.map +1 -0
- package/dist/utils/fs-storage.js +34 -0
- package/dist/utils/fs-storage.js.map +1 -0
- package/dist/utils/index.d.ts +14 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +15 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/log-update.d.ts +31 -0
- package/dist/utils/log-update.d.ts.map +1 -0
- package/dist/utils/log-update.js +147 -0
- package/dist/utils/log-update.js.map +1 -0
- package/dist/utils/text-utils.d.ts +151 -0
- package/dist/utils/text-utils.d.ts.map +1 -0
- package/dist/utils/text-utils.js +699 -0
- package/dist/utils/text-utils.js.map +1 -0
- package/dist/utils/types.d.ts +205 -0
- package/dist/utils/types.d.ts.map +1 -0
- package/dist/utils/types.js +430 -0
- package/dist/utils/types.js.map +1 -0
- package/package.json +142 -0
|
@@ -0,0 +1,699 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reck Text Utilities - ANSI-aware text manipulation
|
|
3
|
+
*
|
|
4
|
+
* Features:
|
|
5
|
+
* - Text wrapping with ANSI preservation
|
|
6
|
+
* - Text truncation (start, middle, end)
|
|
7
|
+
* - Advanced color support (named, hex, RGB, ANSI256)
|
|
8
|
+
*/
|
|
9
|
+
// ANSI escape sequence constants
|
|
10
|
+
const ESC = '\u001B';
|
|
11
|
+
const CSI = '[';
|
|
12
|
+
const OSC = ']';
|
|
13
|
+
const SGR_END = 'm';
|
|
14
|
+
const BELL = '\u0007';
|
|
15
|
+
const HYPERLINK_START = `${OSC}8;;`;
|
|
16
|
+
// Regex patterns
|
|
17
|
+
const ANSI_REGEX = /\u001B\[[0-9;]*m/g;
|
|
18
|
+
const SGR_REGEX = /^\u001B\[(\d+)m/;
|
|
19
|
+
/**
|
|
20
|
+
* Strip ANSI escape codes from text
|
|
21
|
+
*/
|
|
22
|
+
export function stripAnsi(text) {
|
|
23
|
+
return text.replace(ANSI_REGEX, '');
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Get visible width of text (excluding ANSI codes)
|
|
27
|
+
* Handles wide characters (CJK, emoji) as width 2
|
|
28
|
+
*/
|
|
29
|
+
export function stringWidth(text) {
|
|
30
|
+
const stripped = stripAnsi(text);
|
|
31
|
+
let width = 0;
|
|
32
|
+
for (const char of stripped) {
|
|
33
|
+
const code = char.codePointAt(0) ?? 0;
|
|
34
|
+
// Control characters
|
|
35
|
+
if (code <= 0x1f || (code >= 0x7f && code <= 0x9f)) {
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
// Zero-width characters (should not contribute to width)
|
|
39
|
+
if (isZeroWidthCharacter(code)) {
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
// Wide characters (CJK, emoji, etc.)
|
|
43
|
+
if (isWideCharacter(code)) {
|
|
44
|
+
width += 2;
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
width += 1;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return width;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Check if a character is zero-width (variation selectors, joiners, etc.)
|
|
54
|
+
*/
|
|
55
|
+
function isZeroWidthCharacter(code) {
|
|
56
|
+
return (
|
|
57
|
+
// Variation Selectors (VS1-VS16)
|
|
58
|
+
(code >= 0xfe00 && code <= 0xfe0f) ||
|
|
59
|
+
// Variation Selectors Supplement (VS17-VS256)
|
|
60
|
+
(code >= 0xe0100 && code <= 0xe01ef) ||
|
|
61
|
+
// Zero Width Space
|
|
62
|
+
code === 0x200b ||
|
|
63
|
+
// Zero Width Non-Joiner
|
|
64
|
+
code === 0x200c ||
|
|
65
|
+
// Zero Width Joiner (used in emoji sequences)
|
|
66
|
+
code === 0x200d ||
|
|
67
|
+
// Word Joiner
|
|
68
|
+
code === 0x2060 ||
|
|
69
|
+
// Zero Width No-Break Space (BOM)
|
|
70
|
+
code === 0xfeff ||
|
|
71
|
+
// Combining marks (general range)
|
|
72
|
+
(code >= 0x0300 && code <= 0x036f) ||
|
|
73
|
+
// Combining Diacritical Marks Extended
|
|
74
|
+
(code >= 0x1ab0 && code <= 0x1aff) ||
|
|
75
|
+
// Combining Diacritical Marks Supplement
|
|
76
|
+
(code >= 0x1dc0 && code <= 0x1dff) ||
|
|
77
|
+
// Combining Half Marks
|
|
78
|
+
(code >= 0xfe20 && code <= 0xfe2f) ||
|
|
79
|
+
// Soft hyphen
|
|
80
|
+
code === 0x00ad);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Check if a character is a wide character (CJK, emoji, fullwidth)
|
|
84
|
+
* Note: Many terminals render these symbols as width 2, even if Unicode
|
|
85
|
+
* standard says width 1. We prioritize visual consistency in terminals.
|
|
86
|
+
*/
|
|
87
|
+
function isWideCharacter(code) {
|
|
88
|
+
return (
|
|
89
|
+
// CJK Unified Ideographs
|
|
90
|
+
(code >= 0x4e00 && code <= 0x9fff) ||
|
|
91
|
+
// CJK Extension A-F
|
|
92
|
+
(code >= 0x3400 && code <= 0x4dbf) ||
|
|
93
|
+
(code >= 0x20000 && code <= 0x2a6df) ||
|
|
94
|
+
(code >= 0x2a700 && code <= 0x2ceaf) ||
|
|
95
|
+
// Fullwidth Forms
|
|
96
|
+
(code >= 0xff00 && code <= 0xff60) ||
|
|
97
|
+
(code >= 0xffe0 && code <= 0xffe6) ||
|
|
98
|
+
// Hiragana, Katakana
|
|
99
|
+
(code >= 0x3040 && code <= 0x30ff) ||
|
|
100
|
+
// Hangul
|
|
101
|
+
(code >= 0xac00 && code <= 0xd7a3) ||
|
|
102
|
+
// Emoji (basic range) - actual pictographic emoji are width 2
|
|
103
|
+
(code >= 0x1f300 && code <= 0x1f9ff) ||
|
|
104
|
+
(code >= 0x1fa00 && code <= 0x1faff) ||
|
|
105
|
+
// Specific emoji-presentation characters from Dingbats/Misc Symbols
|
|
106
|
+
// These render as emoji (width 2) in most terminals
|
|
107
|
+
isEmojiPresentationChar(code)
|
|
108
|
+
// Note: Simple symbols like ✓ ✗ ⚠ ℹ (U+2713, U+2717, U+26A0, U+2139)
|
|
109
|
+
// are "Ambiguous Width" and render as width 1 in most Western terminals
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Check if character has default emoji presentation (renders as width 2)
|
|
114
|
+
* These are specific characters from Dingbats/Misc Symbols ranges that
|
|
115
|
+
* typically render as colored emoji rather than simple text symbols
|
|
116
|
+
*/
|
|
117
|
+
function isEmojiPresentationChar(code) {
|
|
118
|
+
// Common emoji from Dingbats range (0x2700-0x27BF)
|
|
119
|
+
const dingbatEmoji = [
|
|
120
|
+
0x2702, // ✂ scissors
|
|
121
|
+
0x2705, // ✅ check mark
|
|
122
|
+
0x2708, // ✈ airplane
|
|
123
|
+
0x2709, // ✉ envelope
|
|
124
|
+
0x270a, // ✊ fist
|
|
125
|
+
0x270b, // ✋ hand
|
|
126
|
+
0x270c, // ✌ victory
|
|
127
|
+
0x270d, // ✍ writing hand
|
|
128
|
+
0x270f, // ✏ pencil
|
|
129
|
+
0x2712, // ✒ nib
|
|
130
|
+
0x2714, // ✔ heavy check
|
|
131
|
+
0x2716, // ✖ heavy x
|
|
132
|
+
0x2728, // ✨ sparkles
|
|
133
|
+
0x2733, // ✳ asterisk
|
|
134
|
+
0x2734, // ✴ star
|
|
135
|
+
0x2744, // ❄ snowflake
|
|
136
|
+
0x2747, // ❇ sparkle
|
|
137
|
+
0x274c, // ❌ cross mark
|
|
138
|
+
0x274e, // ❎ negative cross
|
|
139
|
+
0x2753, // ❓ question
|
|
140
|
+
0x2754, // ❔ question
|
|
141
|
+
0x2755, // ❕ exclamation
|
|
142
|
+
0x2757, // ❗ exclamation
|
|
143
|
+
0x2763, // ❣ heart exclamation
|
|
144
|
+
0x2764, // ❤ heart
|
|
145
|
+
0x2795, // ➕ plus
|
|
146
|
+
0x2796, // ➖ minus
|
|
147
|
+
0x2797, // ➗ division
|
|
148
|
+
0x27a1, // ➡ arrow
|
|
149
|
+
0x27b0, // ➰ loop
|
|
150
|
+
];
|
|
151
|
+
// Common emoji from Misc Symbols range (0x2600-0x26FF)
|
|
152
|
+
const miscEmoji = [
|
|
153
|
+
0x2600, // ☀ sun
|
|
154
|
+
0x2601, // ☁ cloud
|
|
155
|
+
0x2602, // ☂ umbrella
|
|
156
|
+
0x2603, // ☃ snowman
|
|
157
|
+
0x2604, // ☄ comet
|
|
158
|
+
0x260e, // ☎ telephone
|
|
159
|
+
0x2611, // ☑ ballot check
|
|
160
|
+
0x2614, // ☔ umbrella rain
|
|
161
|
+
0x2615, // ☕ coffee
|
|
162
|
+
0x2618, // ☘ shamrock
|
|
163
|
+
0x261d, // ☝ index finger
|
|
164
|
+
0x2620, // ☠ skull
|
|
165
|
+
0x2622, // ☢ radioactive
|
|
166
|
+
0x2623, // ☣ biohazard
|
|
167
|
+
0x2626, // ☦ cross
|
|
168
|
+
0x262a, // ☪ star crescent
|
|
169
|
+
0x262e, // ☮ peace
|
|
170
|
+
0x262f, // ☯ yin yang
|
|
171
|
+
0x2638, // ☸ wheel
|
|
172
|
+
0x2639, // ☹ frown
|
|
173
|
+
0x263a, // ☺ smile
|
|
174
|
+
0x2640, // ♀ female
|
|
175
|
+
0x2642, // ♂ male
|
|
176
|
+
0x2648, 0x2649, 0x264a, 0x264b, 0x264c, 0x264d, // zodiac
|
|
177
|
+
0x264e, 0x264f, 0x2650, 0x2651, 0x2652, 0x2653,
|
|
178
|
+
0x265f, // ♟ chess pawn
|
|
179
|
+
0x2660, // ♠ spade
|
|
180
|
+
0x2663, // ♣ club
|
|
181
|
+
0x2665, // ♥ heart
|
|
182
|
+
0x2666, // ♦ diamond
|
|
183
|
+
0x2668, // ♨ hot springs
|
|
184
|
+
0x267b, // ♻ recycle
|
|
185
|
+
0x267e, // ♾ infinity
|
|
186
|
+
0x267f, // ♿ wheelchair
|
|
187
|
+
0x2692, // ⚒ hammers
|
|
188
|
+
0x2693, // ⚓ anchor
|
|
189
|
+
0x2694, // ⚔ swords
|
|
190
|
+
0x2695, // ⚕ medical
|
|
191
|
+
0x2696, // ⚖ scales
|
|
192
|
+
0x2697, // ⚗ alembic
|
|
193
|
+
0x2699, // ⚙ gear
|
|
194
|
+
0x269b, // ⚛ atom
|
|
195
|
+
0x269c, // ⚜ fleur-de-lis
|
|
196
|
+
0x26a1, // ⚡ lightning
|
|
197
|
+
0x26aa, // ⚪ white circle
|
|
198
|
+
0x26ab, // ⚫ black circle
|
|
199
|
+
0x26b0, // ⚰ coffin
|
|
200
|
+
0x26b1, // ⚱ urn
|
|
201
|
+
0x26bd, // ⚽ soccer
|
|
202
|
+
0x26be, // ⚾ baseball
|
|
203
|
+
0x26c4, // ⛄ snowman
|
|
204
|
+
0x26c5, // ⛅ sun cloud
|
|
205
|
+
0x26ce, // ⛎ ophiuchus
|
|
206
|
+
0x26d4, // ⛔ no entry
|
|
207
|
+
0x26ea, // ⛪ church
|
|
208
|
+
0x26f2, // ⛲ fountain
|
|
209
|
+
0x26f3, // ⛳ golf
|
|
210
|
+
0x26f5, // ⛵ sailboat
|
|
211
|
+
0x26fa, // ⛺ tent
|
|
212
|
+
0x26fd, // ⛽ fuel pump
|
|
213
|
+
];
|
|
214
|
+
return dingbatEmoji.includes(code) || miscEmoji.includes(code);
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Wrap text to fit within a given width
|
|
218
|
+
* Preserves ANSI escape codes across line breaks
|
|
219
|
+
*/
|
|
220
|
+
export function wrapText(text, columns, options = {}) {
|
|
221
|
+
const { hard = true, trim = true, wordWrap = true } = options;
|
|
222
|
+
if (columns < 1)
|
|
223
|
+
return '';
|
|
224
|
+
if (trim && text.trim() === '')
|
|
225
|
+
return '';
|
|
226
|
+
return text
|
|
227
|
+
.split('\n')
|
|
228
|
+
.map(line => wrapLine(line, columns, { hard, trim, wordWrap }))
|
|
229
|
+
.join('\n');
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Wrap a single line of text
|
|
233
|
+
*/
|
|
234
|
+
function wrapLine(text, columns, options) {
|
|
235
|
+
const { hard, trim, wordWrap } = options;
|
|
236
|
+
const words = text.split(' ');
|
|
237
|
+
const rows = [''];
|
|
238
|
+
let currentStyle = '';
|
|
239
|
+
for (let i = 0; i < words.length; i++) {
|
|
240
|
+
const word = words[i];
|
|
241
|
+
let row = rows[rows.length - 1];
|
|
242
|
+
if (trim) {
|
|
243
|
+
row = row.trimStart();
|
|
244
|
+
}
|
|
245
|
+
const rowWidth = stringWidth(row);
|
|
246
|
+
const wordWidth = stringWidth(word);
|
|
247
|
+
// Add space between words (except at start of line)
|
|
248
|
+
const needsSpace = i !== 0 && rowWidth > 0;
|
|
249
|
+
const spaceWidth = needsSpace ? 1 : 0;
|
|
250
|
+
if (rowWidth + spaceWidth + wordWidth <= columns) {
|
|
251
|
+
// Word fits on current line
|
|
252
|
+
rows[rows.length - 1] = row + (needsSpace ? ' ' : '') + word;
|
|
253
|
+
}
|
|
254
|
+
else if (hard && wordWidth > columns) {
|
|
255
|
+
// Word is longer than line width - break it
|
|
256
|
+
wrapWord(rows, word, columns, currentStyle);
|
|
257
|
+
}
|
|
258
|
+
else if (wordWrap && rowWidth > 0) {
|
|
259
|
+
// Start new line
|
|
260
|
+
if (currentStyle) {
|
|
261
|
+
rows[rows.length - 1] += '\u001B[0m'; // Reset at end of line
|
|
262
|
+
}
|
|
263
|
+
rows.push(currentStyle + word); // Apply style at start of new line
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
rows[rows.length - 1] = row + (needsSpace ? ' ' : '') + word;
|
|
267
|
+
}
|
|
268
|
+
// Track current style
|
|
269
|
+
const styleMatches = word.match(/\u001B\[\d+m/g);
|
|
270
|
+
if (styleMatches) {
|
|
271
|
+
for (const match of styleMatches) {
|
|
272
|
+
if (match === '\u001B[0m') {
|
|
273
|
+
currentStyle = '';
|
|
274
|
+
}
|
|
275
|
+
else {
|
|
276
|
+
currentStyle = match;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
// Trim trailing spaces if needed
|
|
282
|
+
if (trim) {
|
|
283
|
+
return rows.map(row => row.trimEnd()).join('\n');
|
|
284
|
+
}
|
|
285
|
+
return rows.join('\n');
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Break a long word across multiple lines
|
|
289
|
+
*/
|
|
290
|
+
function wrapWord(rows, word, columns, currentStyle) {
|
|
291
|
+
let visible = stringWidth(rows[rows.length - 1]);
|
|
292
|
+
let charIndex = 0;
|
|
293
|
+
const chars = [];
|
|
294
|
+
for (const char of word) {
|
|
295
|
+
chars.push(char);
|
|
296
|
+
}
|
|
297
|
+
while (charIndex < chars.length) {
|
|
298
|
+
const char = chars[charIndex];
|
|
299
|
+
const charWidth = stringWidth(char);
|
|
300
|
+
// Skip ANSI escape sequences
|
|
301
|
+
if (char === ESC) {
|
|
302
|
+
let escape = char;
|
|
303
|
+
charIndex++;
|
|
304
|
+
while (charIndex < chars.length && !chars[charIndex].match(/[a-zA-Z]/)) {
|
|
305
|
+
escape += chars[charIndex];
|
|
306
|
+
charIndex++;
|
|
307
|
+
}
|
|
308
|
+
if (charIndex < chars.length) {
|
|
309
|
+
escape += chars[charIndex];
|
|
310
|
+
charIndex++;
|
|
311
|
+
}
|
|
312
|
+
rows[rows.length - 1] += escape;
|
|
313
|
+
continue;
|
|
314
|
+
}
|
|
315
|
+
if (visible + charWidth <= columns) {
|
|
316
|
+
rows[rows.length - 1] += char;
|
|
317
|
+
visible += charWidth;
|
|
318
|
+
}
|
|
319
|
+
else {
|
|
320
|
+
// Start new line
|
|
321
|
+
if (currentStyle) {
|
|
322
|
+
rows[rows.length - 1] += '\u001B[0m';
|
|
323
|
+
}
|
|
324
|
+
rows.push(currentStyle + char);
|
|
325
|
+
visible = charWidth;
|
|
326
|
+
}
|
|
327
|
+
charIndex++;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Truncate text to fit within a given width
|
|
332
|
+
* Preserves ANSI escape codes
|
|
333
|
+
*/
|
|
334
|
+
export function truncateText(text, columns, options = {}) {
|
|
335
|
+
const { position = 'end', truncationCharacter = '...', space = false, preferTruncationOnSpace = false, } = options;
|
|
336
|
+
const length = stringWidth(text);
|
|
337
|
+
if (length <= columns) {
|
|
338
|
+
return text;
|
|
339
|
+
}
|
|
340
|
+
if (columns < stringWidth(truncationCharacter)) {
|
|
341
|
+
return truncationCharacter.slice(0, columns);
|
|
342
|
+
}
|
|
343
|
+
const ellipsis = space
|
|
344
|
+
? position === 'middle'
|
|
345
|
+
? ` ${truncationCharacter} `
|
|
346
|
+
: position === 'start'
|
|
347
|
+
? `${truncationCharacter} `
|
|
348
|
+
: ` ${truncationCharacter}`
|
|
349
|
+
: truncationCharacter;
|
|
350
|
+
const ellipsisWidth = stringWidth(ellipsis);
|
|
351
|
+
if (position === 'start') {
|
|
352
|
+
return truncateStart(text, columns, ellipsis, ellipsisWidth, preferTruncationOnSpace);
|
|
353
|
+
}
|
|
354
|
+
if (position === 'middle') {
|
|
355
|
+
return truncateMiddle(text, columns, ellipsis, ellipsisWidth, preferTruncationOnSpace);
|
|
356
|
+
}
|
|
357
|
+
return truncateEnd(text, columns, ellipsis, ellipsisWidth, preferTruncationOnSpace);
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* Truncate from the start
|
|
361
|
+
*/
|
|
362
|
+
function truncateStart(text, columns, ellipsis, ellipsisWidth, preferSpace) {
|
|
363
|
+
const visibleChars = columns - ellipsisWidth;
|
|
364
|
+
const result = sliceAnsi(text, stringWidth(text) - visibleChars);
|
|
365
|
+
if (preferSpace) {
|
|
366
|
+
const spaceIndex = result.indexOf(' ');
|
|
367
|
+
if (spaceIndex !== -1 && spaceIndex < 4) {
|
|
368
|
+
return ellipsis + result.slice(spaceIndex + 1);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
return ellipsis + result;
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Truncate from the end
|
|
375
|
+
*/
|
|
376
|
+
function truncateEnd(text, columns, ellipsis, ellipsisWidth, preferSpace) {
|
|
377
|
+
const visibleChars = columns - ellipsisWidth;
|
|
378
|
+
const result = sliceAnsi(text, 0, visibleChars);
|
|
379
|
+
if (preferSpace) {
|
|
380
|
+
const lastSpace = result.lastIndexOf(' ');
|
|
381
|
+
if (lastSpace !== -1 && result.length - lastSpace < 4) {
|
|
382
|
+
return result.slice(0, lastSpace) + ellipsis;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
return result + ellipsis;
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Truncate from the middle
|
|
389
|
+
*/
|
|
390
|
+
function truncateMiddle(text, columns, ellipsis, ellipsisWidth, preferSpace) {
|
|
391
|
+
const half = Math.floor((columns - ellipsisWidth) / 2);
|
|
392
|
+
const start = sliceAnsi(text, 0, half);
|
|
393
|
+
const end = sliceAnsi(text, stringWidth(text) - half);
|
|
394
|
+
return start + ellipsis + end;
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* Slice ANSI string by visible character positions
|
|
398
|
+
* Preserves ANSI escape codes
|
|
399
|
+
*/
|
|
400
|
+
export function sliceAnsi(text, start, end) {
|
|
401
|
+
const chars = [];
|
|
402
|
+
for (const char of text) {
|
|
403
|
+
chars.push(char);
|
|
404
|
+
}
|
|
405
|
+
let result = '';
|
|
406
|
+
let visible = 0;
|
|
407
|
+
let currentStyle = '';
|
|
408
|
+
let i = 0;
|
|
409
|
+
while (i < chars.length && (end === undefined || visible < end)) {
|
|
410
|
+
const char = chars[i];
|
|
411
|
+
// Handle ANSI escape sequences
|
|
412
|
+
if (char === ESC && i + 1 < chars.length && chars[i + 1] === '[') {
|
|
413
|
+
let escape = char;
|
|
414
|
+
i++;
|
|
415
|
+
while (i < chars.length) {
|
|
416
|
+
escape += chars[i];
|
|
417
|
+
if (chars[i].match(/[a-zA-Z]/)) {
|
|
418
|
+
i++;
|
|
419
|
+
break;
|
|
420
|
+
}
|
|
421
|
+
i++;
|
|
422
|
+
}
|
|
423
|
+
// Track style for preservation
|
|
424
|
+
if (escape === '\u001B[0m') {
|
|
425
|
+
currentStyle = '';
|
|
426
|
+
}
|
|
427
|
+
else if (escape.match(/\u001B\[\d+m/)) {
|
|
428
|
+
currentStyle = escape;
|
|
429
|
+
}
|
|
430
|
+
// Include escape if we're in the visible range
|
|
431
|
+
if (visible >= start) {
|
|
432
|
+
result += escape;
|
|
433
|
+
}
|
|
434
|
+
continue;
|
|
435
|
+
}
|
|
436
|
+
const charWidth = stringWidth(char);
|
|
437
|
+
if (visible >= start && (end === undefined || visible < end)) {
|
|
438
|
+
// Add style if starting fresh
|
|
439
|
+
if (result === '' && currentStyle) {
|
|
440
|
+
result += currentStyle;
|
|
441
|
+
}
|
|
442
|
+
result += char;
|
|
443
|
+
}
|
|
444
|
+
visible += charWidth;
|
|
445
|
+
i++;
|
|
446
|
+
}
|
|
447
|
+
// Reset style at end if we have active styling
|
|
448
|
+
if (currentStyle && result) {
|
|
449
|
+
result += '\u001B[0m';
|
|
450
|
+
}
|
|
451
|
+
return result;
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* Skip (remove) N visible characters from the start of ANSI string
|
|
455
|
+
* Preserves ANSI escape codes and reapplies active styles
|
|
456
|
+
*
|
|
457
|
+
*
|
|
458
|
+
*
|
|
459
|
+
* @example
|
|
460
|
+
* ```typescript
|
|
461
|
+
* skipAnsi('\u001B[31mHello\u001B[0m World', 3)
|
|
462
|
+
* // Returns: '\u001B[31mlo\u001B[0m World'
|
|
463
|
+
* ```
|
|
464
|
+
*/
|
|
465
|
+
export function skipAnsi(text, count) {
|
|
466
|
+
if (count <= 0)
|
|
467
|
+
return text;
|
|
468
|
+
return sliceAnsi(text, count);
|
|
469
|
+
}
|
|
470
|
+
/**
|
|
471
|
+
* Take only N visible characters from the start of ANSI string
|
|
472
|
+
* Alias for sliceAnsi(text, 0, count) - useful for transition APIs
|
|
473
|
+
*
|
|
474
|
+
* @example
|
|
475
|
+
* ```typescript
|
|
476
|
+
* takeAnsi('\u001B[31mHello\u001B[0m World', 3)
|
|
477
|
+
* // Returns: '\u001B[31mHel\u001B[0m'
|
|
478
|
+
* ```
|
|
479
|
+
*/
|
|
480
|
+
export function takeAnsi(text, count) {
|
|
481
|
+
if (count <= 0)
|
|
482
|
+
return '';
|
|
483
|
+
return sliceAnsi(text, 0, count);
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
* Pad string to width, preserving ANSI codes
|
|
487
|
+
* Useful for aligning columns in tables and transitions
|
|
488
|
+
*/
|
|
489
|
+
export function padAnsi(text, width, align = 'left', char = ' ') {
|
|
490
|
+
const visibleWidth = stringWidth(text);
|
|
491
|
+
if (visibleWidth >= width)
|
|
492
|
+
return text;
|
|
493
|
+
const padding = width - visibleWidth;
|
|
494
|
+
switch (align) {
|
|
495
|
+
case 'right':
|
|
496
|
+
return char.repeat(padding) + text;
|
|
497
|
+
case 'center': {
|
|
498
|
+
const left = Math.floor(padding / 2);
|
|
499
|
+
const right = padding - left;
|
|
500
|
+
return char.repeat(left) + text + char.repeat(right);
|
|
501
|
+
}
|
|
502
|
+
case 'left':
|
|
503
|
+
default:
|
|
504
|
+
return text + char.repeat(padding);
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
/**
|
|
508
|
+
* Split text into lines, handling both \n and \r\n
|
|
509
|
+
*/
|
|
510
|
+
export function splitLines(text) {
|
|
511
|
+
return text.split(/\r?\n/);
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
* Join lines with newline character
|
|
515
|
+
*/
|
|
516
|
+
export function joinLines(lines) {
|
|
517
|
+
return lines.join('\n');
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* Ensure text has exactly N lines (pad with empty or truncate)
|
|
521
|
+
*/
|
|
522
|
+
export function normalizeLines(text, lineCount) {
|
|
523
|
+
const lines = splitLines(text);
|
|
524
|
+
if (lines.length >= lineCount) {
|
|
525
|
+
return lines.slice(0, lineCount);
|
|
526
|
+
}
|
|
527
|
+
return [...lines, ...Array(lineCount - lines.length).fill('')];
|
|
528
|
+
}
|
|
529
|
+
/**
|
|
530
|
+
* Composite two texts horizontally for transition effects
|
|
531
|
+
* Each text is split into lines and combined side by side
|
|
532
|
+
*
|
|
533
|
+
* Used for swipe/slide transitions where both prev and next content
|
|
534
|
+
* are visible during the animation
|
|
535
|
+
*
|
|
536
|
+
* @example
|
|
537
|
+
* ```typescript
|
|
538
|
+
* // During swipe left animation at 50%
|
|
539
|
+
* const prev = 'Hello\nWorld';
|
|
540
|
+
* const next = 'Goodbye\nEarth';
|
|
541
|
+
* compositeHorizontal(prev, next, 40, 20) // 20 chars from each
|
|
542
|
+
* ```
|
|
543
|
+
*/
|
|
544
|
+
export function compositeHorizontal(left, right, totalWidth, splitPoint, gap = 0) {
|
|
545
|
+
const leftLines = splitLines(left);
|
|
546
|
+
const rightLines = splitLines(right);
|
|
547
|
+
const maxLines = Math.max(leftLines.length, rightLines.length);
|
|
548
|
+
const leftWidth = splitPoint;
|
|
549
|
+
const rightWidth = totalWidth - splitPoint - gap;
|
|
550
|
+
const result = [];
|
|
551
|
+
for (let i = 0; i < maxLines; i++) {
|
|
552
|
+
const leftLine = leftLines[i] || '';
|
|
553
|
+
const rightLine = rightLines[i] || '';
|
|
554
|
+
// Take rightmost part of left content (sliding out)
|
|
555
|
+
const leftVisible = skipAnsi(leftLine, Math.max(0, stringWidth(leftLine) - leftWidth));
|
|
556
|
+
const leftPadded = padAnsi(leftVisible, leftWidth, 'right');
|
|
557
|
+
// Take leftmost part of right content (sliding in)
|
|
558
|
+
const rightVisible = takeAnsi(rightLine, rightWidth);
|
|
559
|
+
const rightPadded = padAnsi(rightVisible, rightWidth, 'left');
|
|
560
|
+
result.push(leftPadded + ' '.repeat(gap) + rightPadded);
|
|
561
|
+
}
|
|
562
|
+
return joinLines(result);
|
|
563
|
+
}
|
|
564
|
+
/**
|
|
565
|
+
* Composite two texts vertically for slide up/down transitions
|
|
566
|
+
*/
|
|
567
|
+
export function compositeVertical(top, bottom, totalHeight, splitPoint, gap = 0) {
|
|
568
|
+
const topLines = splitLines(top);
|
|
569
|
+
const bottomLines = splitLines(bottom);
|
|
570
|
+
const topHeight = splitPoint;
|
|
571
|
+
const bottomHeight = totalHeight - splitPoint - gap;
|
|
572
|
+
// Take bottom part of top content (sliding out)
|
|
573
|
+
const topVisible = topLines.slice(-topHeight);
|
|
574
|
+
// Take top part of bottom content (sliding in)
|
|
575
|
+
const bottomVisible = bottomLines.slice(0, bottomHeight);
|
|
576
|
+
return joinLines([
|
|
577
|
+
...topVisible,
|
|
578
|
+
...Array(gap).fill(''),
|
|
579
|
+
...bottomVisible
|
|
580
|
+
]);
|
|
581
|
+
}
|
|
582
|
+
/**
|
|
583
|
+
* Parse a color value and return ANSI codes
|
|
584
|
+
* Supports:
|
|
585
|
+
* - Named colors (red, green, blue, etc.)
|
|
586
|
+
* - Hex colors (#fff, #ffffff)
|
|
587
|
+
* - RGB colors (rgb(255, 0, 0))
|
|
588
|
+
* - ANSI 256 colors (ansi256(196))
|
|
589
|
+
*/
|
|
590
|
+
export function colorToAnsi(color, type = 'foreground') {
|
|
591
|
+
if (!color)
|
|
592
|
+
return '';
|
|
593
|
+
// Named colors
|
|
594
|
+
const namedColors = {
|
|
595
|
+
black: [30, 40],
|
|
596
|
+
red: [31, 41],
|
|
597
|
+
green: [32, 42],
|
|
598
|
+
yellow: [33, 43],
|
|
599
|
+
blue: [34, 44],
|
|
600
|
+
magenta: [35, 45],
|
|
601
|
+
cyan: [36, 46],
|
|
602
|
+
white: [37, 47],
|
|
603
|
+
gray: [90, 100],
|
|
604
|
+
grey: [90, 100],
|
|
605
|
+
blackBright: [90, 100],
|
|
606
|
+
redBright: [91, 101],
|
|
607
|
+
greenBright: [92, 102],
|
|
608
|
+
yellowBright: [93, 103],
|
|
609
|
+
blueBright: [94, 104],
|
|
610
|
+
magentaBright: [95, 105],
|
|
611
|
+
cyanBright: [96, 106],
|
|
612
|
+
whiteBright: [97, 107],
|
|
613
|
+
};
|
|
614
|
+
const named = namedColors[color];
|
|
615
|
+
if (named) {
|
|
616
|
+
return `\u001B[${type === 'foreground' ? named[0] : named[1]}m`;
|
|
617
|
+
}
|
|
618
|
+
// Hex colors
|
|
619
|
+
if (color.startsWith('#')) {
|
|
620
|
+
const hex = color.slice(1);
|
|
621
|
+
let r, g, b;
|
|
622
|
+
if (hex.length === 3) {
|
|
623
|
+
r = parseInt(hex[0] + hex[0], 16);
|
|
624
|
+
g = parseInt(hex[1] + hex[1], 16);
|
|
625
|
+
b = parseInt(hex[2] + hex[2], 16);
|
|
626
|
+
}
|
|
627
|
+
else if (hex.length === 6) {
|
|
628
|
+
r = parseInt(hex.slice(0, 2), 16);
|
|
629
|
+
g = parseInt(hex.slice(2, 4), 16);
|
|
630
|
+
b = parseInt(hex.slice(4, 6), 16);
|
|
631
|
+
}
|
|
632
|
+
else {
|
|
633
|
+
return '';
|
|
634
|
+
}
|
|
635
|
+
return type === 'foreground'
|
|
636
|
+
? `\u001B[38;2;${r};${g};${b}m`
|
|
637
|
+
: `\u001B[48;2;${r};${g};${b}m`;
|
|
638
|
+
}
|
|
639
|
+
// RGB colors
|
|
640
|
+
const rgbMatch = color.match(/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/);
|
|
641
|
+
if (rgbMatch) {
|
|
642
|
+
const [, r, g, b] = rgbMatch;
|
|
643
|
+
return type === 'foreground'
|
|
644
|
+
? `\u001B[38;2;${r};${g};${b}m`
|
|
645
|
+
: `\u001B[48;2;${r};${g};${b}m`;
|
|
646
|
+
}
|
|
647
|
+
// ANSI 256 colors
|
|
648
|
+
const ansi256Match = color.match(/^ansi256\(\s*(\d+)\s*\)$/);
|
|
649
|
+
if (ansi256Match) {
|
|
650
|
+
const code = ansi256Match[1];
|
|
651
|
+
return type === 'foreground'
|
|
652
|
+
? `\u001B[38;5;${code}m`
|
|
653
|
+
: `\u001B[48;5;${code}m`;
|
|
654
|
+
}
|
|
655
|
+
return '';
|
|
656
|
+
}
|
|
657
|
+
/**
|
|
658
|
+
* Apply color to text
|
|
659
|
+
*/
|
|
660
|
+
export function colorize(text, color, type = 'foreground') {
|
|
661
|
+
const code = colorToAnsi(color, type);
|
|
662
|
+
if (!code)
|
|
663
|
+
return text;
|
|
664
|
+
return `${code}${text}\u001B[0m`;
|
|
665
|
+
}
|
|
666
|
+
// ============================================
|
|
667
|
+
// Text Style Helpers
|
|
668
|
+
// ============================================
|
|
669
|
+
const styles = {
|
|
670
|
+
reset: '\u001B[0m',
|
|
671
|
+
bold: '\u001B[1m',
|
|
672
|
+
dim: '\u001B[2m',
|
|
673
|
+
italic: '\u001B[3m',
|
|
674
|
+
underline: '\u001B[4m',
|
|
675
|
+
inverse: '\u001B[7m',
|
|
676
|
+
strikethrough: '\u001B[9m',
|
|
677
|
+
boldOff: '\u001B[22m',
|
|
678
|
+
dimOff: '\u001B[22m',
|
|
679
|
+
italicOff: '\u001B[23m',
|
|
680
|
+
underlineOff: '\u001B[24m',
|
|
681
|
+
inverseOff: '\u001B[27m',
|
|
682
|
+
strikethroughOff: '\u001B[29m',
|
|
683
|
+
};
|
|
684
|
+
/**
|
|
685
|
+
* Apply text style
|
|
686
|
+
*/
|
|
687
|
+
export function style(text, ...styleNames) {
|
|
688
|
+
const codes = styleNames.map(name => styles[name]).join('');
|
|
689
|
+
return `${codes}${text}${styles.reset}`;
|
|
690
|
+
}
|
|
691
|
+
/**
|
|
692
|
+
* Create a hyperlink (OSC 8)
|
|
693
|
+
*/
|
|
694
|
+
export function hyperlink(text, url) {
|
|
695
|
+
return `\u001B]8;;${url}\u0007${text}\u001B]8;;\u0007`;
|
|
696
|
+
}
|
|
697
|
+
// Export style codes for direct use
|
|
698
|
+
export { styles };
|
|
699
|
+
//# sourceMappingURL=text-utils.js.map
|