@effect-tui/react 0.1.1 → 0.1.4
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/dist/jsx-runtime.d.ts +13 -0
- package/dist/jsx-runtime.d.ts.map +1 -1
- package/dist/jsx-runtime.js.map +1 -1
- package/dist/src/codeblock.d.ts.map +1 -1
- package/dist/src/codeblock.js.map +1 -1
- package/dist/src/components/Divider.d.ts +18 -0
- package/dist/src/components/Divider.d.ts.map +1 -0
- package/dist/src/components/Divider.js +17 -0
- package/dist/src/components/Divider.js.map +1 -0
- package/dist/src/components/Markdown.d.ts +66 -0
- package/dist/src/components/Markdown.d.ts.map +1 -0
- package/dist/src/components/Markdown.js +226 -0
- package/dist/src/components/Markdown.js.map +1 -0
- package/dist/src/components/MultilineTextInput.d.ts +65 -0
- package/dist/src/components/MultilineTextInput.d.ts.map +1 -0
- package/dist/src/components/MultilineTextInput.js +607 -0
- package/dist/src/components/MultilineTextInput.js.map +1 -0
- package/dist/src/components/Overlay.d.ts +46 -0
- package/dist/src/components/Overlay.d.ts.map +1 -0
- package/dist/src/components/Overlay.js +11 -0
- package/dist/src/components/Overlay.js.map +1 -0
- package/dist/src/components/Static.d.ts +44 -0
- package/dist/src/components/Static.d.ts.map +1 -0
- package/dist/src/components/Static.js +53 -0
- package/dist/src/components/Static.js.map +1 -0
- package/dist/src/components/TextInput.d.ts +53 -0
- package/dist/src/components/TextInput.d.ts.map +1 -0
- package/dist/src/components/TextInput.js +210 -0
- package/dist/src/components/TextInput.js.map +1 -0
- package/dist/src/components/index.d.ts +7 -0
- package/dist/src/components/index.d.ts.map +1 -0
- package/dist/src/components/index.js +7 -0
- package/dist/src/components/index.js.map +1 -0
- package/dist/src/components/text-editing.d.ts +62 -0
- package/dist/src/components/text-editing.d.ts.map +1 -0
- package/dist/src/components/text-editing.js +385 -0
- package/dist/src/components/text-editing.js.map +1 -0
- package/dist/src/console/ConsoleCapture.d.ts +36 -0
- package/dist/src/console/ConsoleCapture.d.ts.map +1 -0
- package/dist/src/console/ConsoleCapture.js +210 -0
- package/dist/src/console/ConsoleCapture.js.map +1 -0
- package/dist/src/console/ConsolePopover.d.ts +18 -0
- package/dist/src/console/ConsolePopover.d.ts.map +1 -0
- package/dist/src/console/ConsolePopover.js +324 -0
- package/dist/src/console/ConsolePopover.js.map +1 -0
- package/dist/src/console/clipboard.d.ts +10 -0
- package/dist/src/console/clipboard.d.ts.map +1 -0
- package/dist/src/console/clipboard.js +74 -0
- package/dist/src/console/clipboard.js.map +1 -0
- package/dist/src/console/index.d.ts +5 -0
- package/dist/src/console/index.d.ts.map +1 -0
- package/dist/src/console/index.js +33 -0
- package/dist/src/console/index.js.map +1 -0
- package/dist/src/console/useConsole.d.ts +44 -0
- package/dist/src/console/useConsole.d.ts.map +1 -0
- package/dist/src/console/useConsole.js +91 -0
- package/dist/src/console/useConsole.js.map +1 -0
- package/dist/src/debug/DebugOverlay.d.ts +49 -0
- package/dist/src/debug/DebugOverlay.d.ts.map +1 -0
- package/dist/src/debug/DebugOverlay.js +438 -0
- package/dist/src/debug/DebugOverlay.js.map +1 -0
- package/dist/src/debug/DiagnosticsPanel.d.ts.map +1 -1
- package/dist/src/debug/DiagnosticsPanel.js.map +1 -1
- package/dist/src/dev/Toast.d.ts +19 -0
- package/dist/src/dev/Toast.d.ts.map +1 -0
- package/dist/src/dev/Toast.js +72 -0
- package/dist/src/dev/Toast.js.map +1 -0
- package/dist/src/dev/index.d.ts +2 -0
- package/dist/src/dev/index.d.ts.map +1 -0
- package/dist/src/dev/index.js +3 -0
- package/dist/src/dev/index.js.map +1 -0
- package/dist/src/dev.d.ts +114 -0
- package/dist/src/dev.d.ts.map +1 -0
- package/dist/src/dev.js +373 -0
- package/dist/src/dev.js.map +1 -0
- package/dist/src/highlight.d.ts +3 -3
- package/dist/src/highlight.d.ts.map +1 -1
- package/dist/src/highlight.js.map +1 -1
- package/dist/src/hmr-plugin.d.ts +2 -0
- package/dist/src/hmr-plugin.d.ts.map +1 -0
- package/dist/src/hmr-plugin.js +53 -0
- package/dist/src/hmr-plugin.js.map +1 -0
- package/dist/src/hooks/index.d.ts +4 -0
- package/dist/src/hooks/index.d.ts.map +1 -1
- package/dist/src/hooks/index.js +2 -0
- package/dist/src/hooks/index.js.map +1 -1
- package/dist/src/hooks/use-keyboard.d.ts +11 -0
- package/dist/src/hooks/use-keyboard.d.ts.map +1 -1
- package/dist/src/hooks/use-keyboard.js +22 -4
- package/dist/src/hooks/use-keyboard.js.map +1 -1
- package/dist/src/hooks/use-mouse.d.ts +24 -0
- package/dist/src/hooks/use-mouse.d.ts.map +1 -0
- package/dist/src/hooks/use-mouse.js +41 -0
- package/dist/src/hooks/use-mouse.js.map +1 -0
- package/dist/src/hooks/use-paste.d.ts +11 -0
- package/dist/src/hooks/use-paste.d.ts.map +1 -1
- package/dist/src/hooks/use-paste.js +17 -3
- package/dist/src/hooks/use-paste.js.map +1 -1
- package/dist/src/hooks/use-scroll.d.ts +79 -0
- package/dist/src/hooks/use-scroll.d.ts.map +1 -0
- package/dist/src/hooks/use-scroll.js +239 -0
- package/dist/src/hooks/use-scroll.js.map +1 -0
- package/dist/src/hooks/useFrameStats.js.map +1 -1
- package/dist/src/hosts/base.d.ts +62 -1
- package/dist/src/hosts/base.d.ts.map +1 -1
- package/dist/src/hosts/base.js +118 -5
- package/dist/src/hosts/base.js.map +1 -1
- package/dist/src/hosts/box.d.ts +7 -7
- package/dist/src/hosts/box.d.ts.map +1 -1
- package/dist/src/hosts/box.js +31 -26
- package/dist/src/hosts/box.js.map +1 -1
- package/dist/src/hosts/canvas.d.ts +8 -8
- package/dist/src/hosts/canvas.d.ts.map +1 -1
- package/dist/src/hosts/canvas.js +13 -22
- package/dist/src/hosts/canvas.js.map +1 -1
- package/dist/src/hosts/codeblock.d.ts +7 -7
- package/dist/src/hosts/codeblock.d.ts.map +1 -1
- package/dist/src/hosts/codeblock.js +11 -20
- package/dist/src/hosts/codeblock.js.map +1 -1
- package/dist/src/hosts/flex-container.d.ts +45 -0
- package/dist/src/hosts/flex-container.d.ts.map +1 -0
- package/dist/src/hosts/flex-container.js +90 -0
- package/dist/src/hosts/flex-container.js.map +1 -0
- package/dist/src/hosts/hstack.d.ts +6 -11
- package/dist/src/hosts/hstack.d.ts.map +1 -1
- package/dist/src/hosts/hstack.js +6 -41
- package/dist/src/hosts/hstack.js.map +1 -1
- package/dist/src/hosts/index.d.ts +4 -0
- package/dist/src/hosts/index.d.ts.map +1 -1
- package/dist/src/hosts/index.js +10 -0
- package/dist/src/hosts/index.js.map +1 -1
- package/dist/src/hosts/overlay-item.d.ts +32 -0
- package/dist/src/hosts/overlay-item.d.ts.map +1 -0
- package/dist/src/hosts/overlay-item.js +54 -0
- package/dist/src/hosts/overlay-item.js.map +1 -0
- package/dist/src/hosts/overlay.d.ts +30 -0
- package/dist/src/hosts/overlay.d.ts.map +1 -0
- package/dist/src/hosts/overlay.js +105 -0
- package/dist/src/hosts/overlay.js.map +1 -0
- package/dist/src/hosts/scroll.d.ts +56 -0
- package/dist/src/hosts/scroll.d.ts.map +1 -0
- package/dist/src/hosts/scroll.js +204 -0
- package/dist/src/hosts/scroll.js.map +1 -0
- package/dist/src/hosts/single-child.d.ts +16 -0
- package/dist/src/hosts/single-child.d.ts.map +1 -0
- package/dist/src/hosts/single-child.js +45 -0
- package/dist/src/hosts/single-child.js.map +1 -0
- package/dist/src/hosts/spacer.d.ts.map +1 -1
- package/dist/src/hosts/spacer.js +7 -3
- package/dist/src/hosts/spacer.js.map +1 -1
- package/dist/src/hosts/text.d.ts +9 -6
- package/dist/src/hosts/text.d.ts.map +1 -1
- package/dist/src/hosts/text.js +49 -22
- package/dist/src/hosts/text.js.map +1 -1
- package/dist/src/hosts/vstack.d.ts +6 -11
- package/dist/src/hosts/vstack.d.ts.map +1 -1
- package/dist/src/hosts/vstack.js +6 -41
- package/dist/src/hosts/vstack.js.map +1 -1
- package/dist/src/hosts/zstack.d.ts.map +1 -1
- package/dist/src/hosts/zstack.js +16 -5
- package/dist/src/hosts/zstack.js.map +1 -1
- package/dist/src/index.d.ts +9 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +10 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/inline/index.d.ts.map +1 -1
- package/dist/src/inline/index.js.map +1 -1
- package/dist/src/motion/color-motion-value.d.ts.map +1 -1
- package/dist/src/motion/color-motion-value.js.map +1 -1
- package/dist/src/motion/color.d.ts +1 -29
- package/dist/src/motion/color.d.ts.map +1 -1
- package/dist/src/motion/color.js +2 -170
- package/dist/src/motion/color.js.map +1 -1
- package/dist/src/motion/color.test.js.map +1 -1
- package/dist/src/motion/event-emitter.d.ts.map +1 -1
- package/dist/src/motion/event-emitter.js.map +1 -1
- package/dist/src/motion/frame.js.map +1 -1
- package/dist/src/motion/hooks.d.ts.map +1 -1
- package/dist/src/motion/hooks.js +8 -3
- package/dist/src/motion/hooks.js.map +1 -1
- package/dist/src/motion/index.d.ts.map +1 -1
- package/dist/src/motion/index.js.map +1 -1
- package/dist/src/motion/motion-value.d.ts.map +1 -1
- package/dist/src/motion/motion-value.js.map +1 -1
- package/dist/src/motion/motion-value.test.js.map +1 -1
- package/dist/src/motion/spring-math.d.ts +6 -1
- package/dist/src/motion/spring-math.d.ts.map +1 -1
- package/dist/src/motion/spring-math.js +6 -1
- package/dist/src/motion/spring-math.js.map +1 -1
- package/dist/src/motion/types.d.ts.map +1 -1
- package/dist/src/motion/types.js.map +1 -1
- package/dist/src/profiler.js.map +1 -1
- package/dist/src/reconciler/host-config.d.ts +5 -5
- package/dist/src/reconciler/host-config.d.ts.map +1 -1
- package/dist/src/reconciler/host-config.js +43 -51
- package/dist/src/reconciler/host-config.js.map +1 -1
- package/dist/src/reconciler/noop-methods.d.ts +29 -0
- package/dist/src/reconciler/noop-methods.d.ts.map +1 -0
- package/dist/src/reconciler/noop-methods.js +43 -0
- package/dist/src/reconciler/noop-methods.js.map +1 -0
- package/dist/src/reconciler/types.d.ts +68 -14
- package/dist/src/reconciler/types.d.ts.map +1 -1
- package/dist/src/remote/Procedures.d.ts +22 -0
- package/dist/src/remote/Procedures.d.ts.map +1 -0
- package/dist/src/remote/Procedures.js +42 -0
- package/dist/src/remote/Procedures.js.map +1 -0
- package/dist/src/remote/Router.d.ts +20 -0
- package/dist/src/remote/Router.d.ts.map +1 -0
- package/dist/src/remote/Router.js +26 -0
- package/dist/src/remote/Router.js.map +1 -0
- package/dist/src/remote/Server.d.ts +6 -0
- package/dist/src/remote/Server.d.ts.map +1 -0
- package/dist/src/remote/Server.js +53 -0
- package/dist/src/remote/Server.js.map +1 -0
- package/dist/src/remote/index.d.ts +18 -0
- package/dist/src/remote/index.d.ts.map +1 -0
- package/dist/src/remote/index.js +74 -0
- package/dist/src/remote/index.js.map +1 -0
- package/dist/src/renderer/core/FrameBuilder.d.ts +18 -0
- package/dist/src/renderer/core/FrameBuilder.d.ts.map +1 -0
- package/dist/src/renderer/core/FrameBuilder.js +38 -0
- package/dist/src/renderer/core/FrameBuilder.js.map +1 -0
- package/dist/src/renderer/core/RendererState.d.ts +41 -0
- package/dist/src/renderer/core/RendererState.d.ts.map +1 -0
- package/dist/src/renderer/core/RendererState.js +70 -0
- package/dist/src/renderer/core/RendererState.js.map +1 -0
- package/dist/src/renderer/core/index.d.ts +3 -0
- package/dist/src/renderer/core/index.d.ts.map +1 -0
- package/dist/src/renderer/core/index.js +3 -0
- package/dist/src/renderer/core/index.js.map +1 -0
- package/dist/src/renderer/input/InputProcessor.d.ts +25 -0
- package/dist/src/renderer/input/InputProcessor.d.ts.map +1 -0
- package/dist/src/renderer/input/InputProcessor.js +81 -0
- package/dist/src/renderer/input/InputProcessor.js.map +1 -0
- package/dist/src/renderer/input/index.d.ts +2 -0
- package/dist/src/renderer/input/index.d.ts.map +1 -0
- package/dist/src/renderer/input/index.js +2 -0
- package/dist/src/renderer/input/index.js.map +1 -0
- package/dist/src/renderer/lifecycle/EventBus.d.ts +41 -0
- package/dist/src/renderer/lifecycle/EventBus.d.ts.map +1 -0
- package/dist/src/renderer/lifecycle/EventBus.js +78 -0
- package/dist/src/renderer/lifecycle/EventBus.js.map +1 -0
- package/dist/src/renderer/lifecycle/ResizeManager.d.ts +34 -0
- package/dist/src/renderer/lifecycle/ResizeManager.d.ts.map +1 -0
- package/dist/src/renderer/lifecycle/ResizeManager.js +47 -0
- package/dist/src/renderer/lifecycle/ResizeManager.js.map +1 -0
- package/dist/src/renderer/lifecycle/TerminalSetup.d.ts +36 -0
- package/dist/src/renderer/lifecycle/TerminalSetup.d.ts.map +1 -0
- package/dist/src/renderer/lifecycle/TerminalSetup.js +82 -0
- package/dist/src/renderer/lifecycle/TerminalSetup.js.map +1 -0
- package/dist/src/renderer/lifecycle/index.d.ts +4 -0
- package/dist/src/renderer/lifecycle/index.d.ts.map +1 -0
- package/dist/src/renderer/lifecycle/index.js +4 -0
- package/dist/src/renderer/lifecycle/index.js.map +1 -0
- package/dist/src/renderer/modes/FullscreenRenderer.d.ts +12 -0
- package/dist/src/renderer/modes/FullscreenRenderer.d.ts.map +1 -0
- package/dist/src/renderer/modes/FullscreenRenderer.js +52 -0
- package/dist/src/renderer/modes/FullscreenRenderer.js.map +1 -0
- package/dist/src/renderer/modes/InlineRenderer.d.ts +22 -0
- package/dist/src/renderer/modes/InlineRenderer.d.ts.map +1 -0
- package/dist/src/renderer/modes/InlineRenderer.js +154 -0
- package/dist/src/renderer/modes/InlineRenderer.js.map +1 -0
- package/dist/src/renderer/modes/RendererMode.d.ts +42 -0
- package/dist/src/renderer/modes/RendererMode.d.ts.map +1 -0
- package/dist/src/renderer/modes/RendererMode.js +2 -0
- package/dist/src/renderer/modes/RendererMode.js.map +1 -0
- package/dist/src/renderer/modes/StaticContentRenderer.d.ts +25 -0
- package/dist/src/renderer/modes/StaticContentRenderer.d.ts.map +1 -0
- package/dist/src/renderer/modes/StaticContentRenderer.js +47 -0
- package/dist/src/renderer/modes/StaticContentRenderer.js.map +1 -0
- package/dist/src/renderer/modes/index.d.ts +5 -0
- package/dist/src/renderer/modes/index.d.ts.map +1 -0
- package/dist/src/renderer/modes/index.js +4 -0
- package/dist/src/renderer/modes/index.js.map +1 -0
- package/dist/src/renderer-context.d.ts +9 -0
- package/dist/src/renderer-context.d.ts.map +1 -0
- package/dist/src/renderer-context.js +22 -0
- package/dist/src/renderer-context.js.map +1 -0
- package/dist/src/renderer-types.d.ts +103 -0
- package/dist/src/renderer-types.d.ts.map +1 -0
- package/dist/src/renderer-types.js +2 -0
- package/dist/src/renderer-types.js.map +1 -0
- package/dist/src/renderer.d.ts +4 -86
- package/dist/src/renderer.d.ts.map +1 -1
- package/dist/src/renderer.js +213 -384
- package/dist/src/renderer.js.map +1 -1
- package/dist/src/test/index.d.ts.map +1 -1
- package/dist/src/test/index.js.map +1 -1
- package/dist/src/test/mock-streams.d.ts.map +1 -1
- package/dist/src/test/mock-streams.js.map +1 -1
- package/dist/src/test/render-tui.d.ts.map +1 -1
- package/dist/src/test/render-tui.js +2 -5
- package/dist/src/test/render-tui.js.map +1 -1
- package/dist/src/trace/SpanTree.d.ts.map +1 -1
- package/dist/src/trace/SpanTree.js +21 -11
- package/dist/src/trace/SpanTree.js.map +1 -1
- package/dist/src/trace/format-value.d.ts +15 -0
- package/dist/src/trace/format-value.d.ts.map +1 -0
- package/dist/src/trace/format-value.js +77 -0
- package/dist/src/trace/format-value.js.map +1 -0
- package/dist/src/trace/index.d.ts.map +1 -1
- package/dist/src/trace/index.js.map +1 -1
- package/dist/src/trace/location.js +1 -1
- package/dist/src/trace/location.js.map +1 -1
- package/dist/src/trace/span-processor.d.ts.map +1 -1
- package/dist/src/trace/span-processor.js.map +1 -1
- package/dist/src/trace/span-state.d.ts +19 -2
- package/dist/src/trace/span-state.d.ts.map +1 -1
- package/dist/src/trace/span-state.js +62 -31
- package/dist/src/trace/span-state.js.map +1 -1
- package/dist/src/trace/tui-logger.js.map +1 -1
- package/dist/src/utils/border.d.ts +1 -1
- package/dist/src/utils/border.d.ts.map +1 -1
- package/dist/src/utils/border.js +6 -0
- package/dist/src/utils/border.js.map +1 -1
- package/dist/src/utils/flex-layout.d.ts +2 -1
- package/dist/src/utils/flex-layout.d.ts.map +1 -1
- package/dist/src/utils/flex-layout.js +22 -33
- package/dist/src/utils/flex-layout.js.map +1 -1
- package/dist/src/utils/index.d.ts +1 -1
- package/dist/src/utils/index.d.ts.map +1 -1
- package/dist/src/utils/index.js +1 -1
- package/dist/src/utils/index.js.map +1 -1
- package/dist/src/utils/padding.d.ts.map +1 -1
- package/dist/src/utils/padding.js.map +1 -1
- package/dist/src/utils/styles.d.ts +20 -1
- package/dist/src/utils/styles.d.ts.map +1 -1
- package/dist/src/utils/styles.js +36 -1
- package/dist/src/utils/styles.js.map +1 -1
- package/dist/src/visualize/index.d.ts +8 -19
- package/dist/src/visualize/index.d.ts.map +1 -1
- package/dist/src/visualize/index.js +11 -25
- package/dist/src/visualize/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/jsx-dev-runtime.ts +5 -0
- package/jsx-runtime.ts +54 -0
- package/package.json +124 -92
- package/src/codeblock.tsx +34 -34
- package/src/components/Divider.tsx +23 -0
- package/src/components/Markdown.tsx +380 -0
- package/src/components/MultilineTextInput.tsx +749 -0
- package/src/components/Overlay.tsx +56 -0
- package/src/components/Static.tsx +68 -0
- package/src/components/TextInput.tsx +285 -0
- package/src/components/index.ts +6 -0
- package/src/components/text-editing.ts +464 -0
- package/src/console/ConsoleCapture.ts +272 -0
- package/src/console/ConsolePopover.tsx +487 -0
- package/src/console/clipboard.ts +81 -0
- package/src/console/index.ts +42 -0
- package/src/console/useConsole.ts +129 -0
- package/src/debug/DebugOverlay.ts +557 -0
- package/src/debug/DiagnosticsPanel.tsx +27 -27
- package/src/dev/Toast.tsx +117 -0
- package/src/dev/index.ts +2 -0
- package/src/dev.tsx +489 -0
- package/src/highlight.ts +46 -46
- package/src/hmr-plugin.ts +61 -0
- package/src/hooks/index.ts +4 -0
- package/src/hooks/use-keyboard.ts +44 -24
- package/src/hooks/use-mouse.ts +51 -0
- package/src/hooks/use-paste.ts +21 -6
- package/src/hooks/use-scroll.ts +386 -0
- package/src/hooks/useFrameStats.ts +17 -17
- package/src/hosts/base.ts +180 -59
- package/src/hosts/box.ts +117 -96
- package/src/hosts/canvas.ts +137 -141
- package/src/hosts/codeblock.ts +117 -133
- package/src/hosts/flex-container.ts +124 -0
- package/src/hosts/hstack.ts +11 -59
- package/src/hosts/index.ts +24 -14
- package/src/hosts/overlay-item.ts +72 -0
- package/src/hosts/overlay.ts +125 -0
- package/src/hosts/scroll.ts +255 -0
- package/src/hosts/single-child.ts +52 -0
- package/src/hosts/spacer.ts +30 -26
- package/src/hosts/text.ts +198 -164
- package/src/hosts/vstack.ts +11 -59
- package/src/hosts/zstack.ts +79 -67
- package/src/index.ts +44 -19
- package/src/inline/index.tsx +123 -123
- package/src/motion/color-motion-value.ts +67 -67
- package/src/motion/color.test.ts +107 -107
- package/src/motion/color.ts +9 -190
- package/src/motion/event-emitter.ts +20 -20
- package/src/motion/frame.ts +35 -35
- package/src/motion/hooks.ts +144 -139
- package/src/motion/index.ts +10 -10
- package/src/motion/motion-value.test.ts +207 -207
- package/src/motion/motion-value.ts +112 -112
- package/src/motion/spring-math.ts +88 -83
- package/src/motion/types.ts +25 -25
- package/src/profiler.ts +50 -50
- package/src/reconciler/host-config.ts +152 -174
- package/src/reconciler/noop-methods.ts +55 -0
- package/src/reconciler/types.ts +112 -46
- package/src/remote/Procedures.ts +52 -0
- package/src/remote/Router.ts +58 -0
- package/src/remote/Server.ts +76 -0
- package/src/remote/index.ts +90 -0
- package/src/renderer/core/FrameBuilder.ts +49 -0
- package/src/renderer/core/RendererState.ts +80 -0
- package/src/renderer/core/index.ts +2 -0
- package/src/renderer/input/InputProcessor.ts +94 -0
- package/src/renderer/input/index.ts +1 -0
- package/src/renderer/lifecycle/EventBus.ts +90 -0
- package/src/renderer/lifecycle/ResizeManager.ts +65 -0
- package/src/renderer/lifecycle/TerminalSetup.ts +105 -0
- package/src/renderer/lifecycle/index.ts +3 -0
- package/src/renderer/modes/FullscreenRenderer.ts +53 -0
- package/src/renderer/modes/InlineRenderer.ts +178 -0
- package/src/renderer/modes/RendererMode.ts +46 -0
- package/src/renderer/modes/StaticContentRenderer.ts +56 -0
- package/src/renderer/modes/index.ts +4 -0
- package/src/renderer-context.ts +27 -0
- package/src/renderer-types.ts +109 -0
- package/src/renderer.ts +391 -642
- package/src/test/index.ts +5 -5
- package/src/test/mock-streams.ts +115 -115
- package/src/test/render-tui.ts +84 -87
- package/src/utils/border.ts +79 -73
- package/src/utils/flex-layout.ts +80 -93
- package/src/utils/index.ts +1 -1
- package/src/utils/padding.ts +27 -27
- package/src/utils/styles.ts +50 -7
- package/src/visualize/index.tsx +225 -240
- package/dist/src/output.d.ts +0 -47
- package/dist/src/output.d.ts.map +0 -1
- package/dist/src/output.js +0 -125
- package/dist/src/output.js.map +0 -1
- package/dist/src/terminal.d.ts +0 -37
- package/dist/src/terminal.d.ts.map +0 -1
- package/dist/src/terminal.js +0 -65
- package/dist/src/terminal.js.map +0 -1
- package/src/output.ts +0 -156
- package/src/terminal.ts +0 -67
- package/src/trace/SpanTree.tsx +0 -195
- package/src/trace/index.tsx +0 -205
- package/src/trace/location.ts +0 -90
- package/src/trace/span-processor.ts +0 -65
- package/src/trace/span-state.ts +0 -286
- package/src/trace/tui-logger.ts +0 -72
package/src/hosts/codeblock.ts
CHANGED
|
@@ -1,145 +1,129 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Colors,
|
|
3
|
-
displayWidth,
|
|
4
|
-
parseColor,
|
|
5
|
-
type CellBuffer,
|
|
6
|
-
type ColorLike,
|
|
7
|
-
type Palette,
|
|
8
|
-
type ColorValue,
|
|
9
|
-
} from "@effect-tui/core"
|
|
1
|
+
import { Colors, displayWidth, type CellBuffer, type Color, type Palette } from "@effect-tui/core"
|
|
10
2
|
import type { HighlightLine } from "../highlight.js"
|
|
11
3
|
import type { HostContext, Rect, Size, CommonProps } from "../reconciler/types.js"
|
|
12
4
|
import { BaseHost } from "./base.js"
|
|
13
|
-
import { type Padding, type PaddingInput, resolvePadding } from "../utils/index.js"
|
|
5
|
+
import { type Padding, type PaddingInput, resolvePadding, resolveBgStyle, styleIdFromProps } from "../utils/index.js"
|
|
14
6
|
|
|
15
7
|
export interface CodeBlockProps extends CommonProps {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function normalizeColor(c: unknown): ColorValue | undefined {
|
|
25
|
-
if (c === undefined || c === null) return undefined
|
|
26
|
-
if (typeof c === "number" || typeof c === "object") return c as ColorValue
|
|
27
|
-
return parseColor(c as string)
|
|
8
|
+
lines: HighlightLine[]
|
|
9
|
+
lineNumbers?: boolean
|
|
10
|
+
padding?: PaddingInput
|
|
11
|
+
background?: Color
|
|
12
|
+
lineNumberColor?: Color
|
|
13
|
+
lineNumberBackground?: Color
|
|
28
14
|
}
|
|
29
15
|
|
|
30
16
|
function lineDisplayWidth(line: HighlightLine): number {
|
|
31
|
-
|
|
17
|
+
return line.reduce((w, token) => w + displayWidth(token.text), 0)
|
|
32
18
|
}
|
|
33
19
|
|
|
34
20
|
export class CodeBlockHost extends BaseHost {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
if (props.lineNumberBackground !== undefined) this.lineNumberBackground = props.lineNumberBackground as ColorLike
|
|
144
|
-
}
|
|
21
|
+
lines: HighlightLine[] = [[]]
|
|
22
|
+
lineNumbers = false
|
|
23
|
+
padding: Padding = { top: 0, right: 0, bottom: 0, left: 0 }
|
|
24
|
+
background?: Color
|
|
25
|
+
lineNumberColor?: Color
|
|
26
|
+
lineNumberBackground?: Color
|
|
27
|
+
|
|
28
|
+
private cachedLineWidths: number[] = []
|
|
29
|
+
private gutterWidth = 0
|
|
30
|
+
|
|
31
|
+
constructor(props: CodeBlockProps, ctx: HostContext) {
|
|
32
|
+
super("codeblock", props, ctx)
|
|
33
|
+
this.updateProps(props)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
private computeGutterWidth(): number {
|
|
37
|
+
if (!this.lineNumbers) return 0
|
|
38
|
+
// Fix width so layout doesn't shift when moving from 1→2 digits.
|
|
39
|
+
const digits = Math.max(2, String(Math.max(1, this.lines.length)).length)
|
|
40
|
+
// digits plus a trailing space
|
|
41
|
+
return digits + 1
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
private get insetX(): number {
|
|
45
|
+
return this.padding.left + this.padding.right + this.gutterWidth
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
private get insetY(): number {
|
|
49
|
+
return this.padding.top + this.padding.bottom
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
measure(maxW: number, maxH: number): Size {
|
|
53
|
+
this.cachedLineWidths = this.lines.map((l) => lineDisplayWidth(l))
|
|
54
|
+
this.gutterWidth = this.computeGutterWidth()
|
|
55
|
+
|
|
56
|
+
const maxLineW = this.cachedLineWidths.reduce((max, w) => (w > max ? w : max), 0)
|
|
57
|
+
const contentW = maxLineW + this.insetX
|
|
58
|
+
|
|
59
|
+
const innerHeight = Math.max(1, this.lines.length) + this.insetY
|
|
60
|
+
|
|
61
|
+
return {
|
|
62
|
+
w: Math.min(maxW, contentW),
|
|
63
|
+
h: Math.min(maxH, innerHeight),
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
override layout(rect: Rect): void {
|
|
68
|
+
super.layout(rect)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
render(buffer: CellBuffer, palette: Palette): void {
|
|
72
|
+
if (!this.rect) return
|
|
73
|
+
|
|
74
|
+
const { x, y, w, h } = this.rect
|
|
75
|
+
const contentWidth = Math.max(0, w - this.insetX)
|
|
76
|
+
const maxLines = Math.max(0, Math.min(this.lines.length, h - this.insetY))
|
|
77
|
+
const startX = x + this.padding.left + this.gutterWidth
|
|
78
|
+
const startY = y + this.padding.top
|
|
79
|
+
|
|
80
|
+
const { value: bgValue, styleId: bgStyleId } = resolveBgStyle(palette, this.background)
|
|
81
|
+
if (bgValue !== undefined && w > 0 && h > 0) {
|
|
82
|
+
buffer.fillRect(x, y, w, h, " ".codePointAt(0)!, bgStyleId)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
for (let i = 0; i < maxLines; i++) {
|
|
86
|
+
const lineY = startY + i
|
|
87
|
+
let drawX = startX
|
|
88
|
+
|
|
89
|
+
if (this.lineNumbers) {
|
|
90
|
+
const gutterStyle = styleIdFromProps(palette, {
|
|
91
|
+
fg: this.lineNumberColor ?? Colors.gray(11),
|
|
92
|
+
bg: this.lineNumberBackground ?? this.background,
|
|
93
|
+
})
|
|
94
|
+
const digits = String(i + 1).padStart(this.gutterWidth - 1, " ")
|
|
95
|
+
buffer.drawText(x + this.padding.left, lineY, `${digits} `, gutterStyle, this.gutterWidth)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const line = this.lines[i] ?? []
|
|
99
|
+
for (const token of line) {
|
|
100
|
+
if (contentWidth <= 0) break
|
|
101
|
+
const remaining = x + w - drawX
|
|
102
|
+
if (remaining <= 0) break
|
|
103
|
+
|
|
104
|
+
const style = token.style ?? {}
|
|
105
|
+
const styleId = styleIdFromProps(palette, {
|
|
106
|
+
fg: style.fg,
|
|
107
|
+
bg: style.bg ?? this.background,
|
|
108
|
+
bold: style.bold,
|
|
109
|
+
italic: style.italic,
|
|
110
|
+
underline: style.underline,
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
buffer.drawText(drawX, lineY, token.text, styleId, remaining)
|
|
114
|
+
drawX += displayWidth(token.text)
|
|
115
|
+
if (drawX >= x + w) break
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
override updateProps(props: Record<string, unknown>): void {
|
|
121
|
+
super.updateProps(props)
|
|
122
|
+
if (props.lines !== undefined) this.lines = props.lines as HighlightLine[]
|
|
123
|
+
if (props.lineNumbers !== undefined) this.lineNumbers = !!props.lineNumbers
|
|
124
|
+
if (props.padding !== undefined) this.padding = resolvePadding(props.padding as CodeBlockProps["padding"])
|
|
125
|
+
if (props.background !== undefined) this.background = props.background as Color
|
|
126
|
+
if (props.lineNumberColor !== undefined) this.lineNumberColor = props.lineNumberColor as Color
|
|
127
|
+
if (props.lineNumberBackground !== undefined) this.lineNumberBackground = props.lineNumberBackground as Color
|
|
128
|
+
}
|
|
145
129
|
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
// flex-container.ts — Unified base class for VStackHost and HStackHost
|
|
2
|
+
import type { CellBuffer, Palette, Color } from "@effect-tui/core"
|
|
3
|
+
import { splitConstraints } from "@effect-tui/core"
|
|
4
|
+
import type { HostContext, Rect, Size, CommonProps } from "../reconciler/types.js"
|
|
5
|
+
import { BaseHost } from "./base.js"
|
|
6
|
+
import { measureFlex, layoutFlex, type FlexAxis, type FlexAlignment, resolveBgStyle } from "../utils/index.js"
|
|
7
|
+
|
|
8
|
+
export type CrossAlignment<A extends FlexAxis> = A extends "vertical"
|
|
9
|
+
? "leading" | "center" | "trailing"
|
|
10
|
+
: "top" | "center" | "bottom"
|
|
11
|
+
|
|
12
|
+
export interface FlexContainerProps<A extends FlexAxis> extends CommonProps {
|
|
13
|
+
spacing?: number
|
|
14
|
+
alignment?: CrossAlignment<A>
|
|
15
|
+
/** Background color to fill the entire container rect */
|
|
16
|
+
bg?: Color
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Map alignment names to generic flex alignment
|
|
20
|
+
function toFlexAlignment<A extends FlexAxis>(axis: A, alignment: CrossAlignment<A>): FlexAlignment {
|
|
21
|
+
if (alignment === "center") return "center"
|
|
22
|
+
if (axis === "vertical") {
|
|
23
|
+
return alignment === "leading" ? "start" : "end"
|
|
24
|
+
} else {
|
|
25
|
+
return alignment === "top" ? "start" : "end"
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* FlexContainerHost is a generic linear layout container.
|
|
31
|
+
* VStackHost and HStackHost extend this with their axis-specific defaults.
|
|
32
|
+
*/
|
|
33
|
+
export class FlexContainerHost<A extends FlexAxis> extends BaseHost {
|
|
34
|
+
spacing = 0
|
|
35
|
+
alignment!: CrossAlignment<A> // Set in constructor before updateProps
|
|
36
|
+
bg?: Color
|
|
37
|
+
private cachedSizes: Size[] = []
|
|
38
|
+
private layoutChildren: typeof this.children = []
|
|
39
|
+
|
|
40
|
+
constructor(
|
|
41
|
+
protected readonly axis: A,
|
|
42
|
+
elementType: string,
|
|
43
|
+
props: FlexContainerProps<A>,
|
|
44
|
+
ctx: HostContext,
|
|
45
|
+
defaultAlignment: CrossAlignment<A>,
|
|
46
|
+
) {
|
|
47
|
+
super(elementType, props, ctx)
|
|
48
|
+
this.alignment = defaultAlignment
|
|
49
|
+
this.updateProps(props)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Get children excluding __static nodes (which are rendered separately) */
|
|
53
|
+
private getNonStaticChildren() {
|
|
54
|
+
return this.children.filter((c) => !c.__static)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Measure this container's size given parent's proposed constraints.
|
|
59
|
+
*
|
|
60
|
+
* Frame constraints are applied in two places:
|
|
61
|
+
* 1. constrainProposal() - limits what we tell children is available
|
|
62
|
+
* 2. constrainResult() - limits what we report back to parent
|
|
63
|
+
*
|
|
64
|
+
* This enables patterns like:
|
|
65
|
+
* ```tsx
|
|
66
|
+
* <vstack height={10}> // Reports 10, proposes 10 to children
|
|
67
|
+
* <scroll>...</scroll> // Greedy, but only gets 10
|
|
68
|
+
* </vstack>
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
measure(maxW: number, maxH: number): Size {
|
|
72
|
+
// Apply frame constraints to what we propose to children
|
|
73
|
+
const constrained = this.constrainProposal(maxW, maxH)
|
|
74
|
+
|
|
75
|
+
// Exclude __static children from normal layout - they're rendered to scrollback separately
|
|
76
|
+
this.layoutChildren = this.getNonStaticChildren()
|
|
77
|
+
const [maxMain, maxCross] = splitConstraints(this.axis, constrained.w, constrained.h)
|
|
78
|
+
const result = measureFlex(this.axis, this.layoutChildren, this.spacing, maxMain, maxCross)
|
|
79
|
+
this.cachedSizes = result.sizes
|
|
80
|
+
|
|
81
|
+
// Apply frame constraints to what we report to parent
|
|
82
|
+
return this.constrainResult(result.totalSize)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
override layout(rect: Rect): void {
|
|
86
|
+
super.layout(rect)
|
|
87
|
+
const stretchCross = this.axis === "vertical" ? this.alignment === "leading" : this.alignment === "top"
|
|
88
|
+
layoutFlex(
|
|
89
|
+
this.axis,
|
|
90
|
+
this.layoutChildren,
|
|
91
|
+
this.cachedSizes,
|
|
92
|
+
rect,
|
|
93
|
+
this.spacing,
|
|
94
|
+
toFlexAlignment(this.axis, this.alignment),
|
|
95
|
+
stretchCross,
|
|
96
|
+
)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
render(buffer: CellBuffer, palette: Palette): void {
|
|
100
|
+
// Fill background color if set
|
|
101
|
+
if (this.bg && this.rect) {
|
|
102
|
+
const { styleId } = resolveBgStyle(palette, this.bg)
|
|
103
|
+
buffer.fillRect(this.rect.x, this.rect.y, this.rect.w, this.rect.h, 32, styleId)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Only render non-static children to buffer (static content goes to scrollback)
|
|
107
|
+
// Check __static at render time (not just measure time) to avoid race with React commit
|
|
108
|
+
for (const child of this.layoutChildren) {
|
|
109
|
+
if (!child.__static) {
|
|
110
|
+
child.render(buffer, palette)
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
override updateProps(props: Record<string, unknown>): void {
|
|
116
|
+
super.updateProps(props)
|
|
117
|
+
this.spacing = (props.spacing as number | undefined) ?? 0
|
|
118
|
+
// Reset to axis-specific default when undefined
|
|
119
|
+
this.alignment =
|
|
120
|
+
(props.alignment as CrossAlignment<A> | undefined) ??
|
|
121
|
+
((this.axis === "vertical" ? "leading" : "top") as CrossAlignment<A>)
|
|
122
|
+
this.bg = props.bg as Color | undefined
|
|
123
|
+
}
|
|
124
|
+
}
|
package/src/hosts/hstack.ts
CHANGED
|
@@ -1,64 +1,16 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import
|
|
3
|
-
import { BaseHost } from "./base.js"
|
|
4
|
-
import { measureFlex, layoutFlex, type FlexAlignment } from "../utils/index.js"
|
|
1
|
+
import type { HostContext, CommonProps } from "../reconciler/types.js"
|
|
2
|
+
import { FlexContainerHost, type FlexContainerProps } from "./flex-container.js"
|
|
5
3
|
|
|
6
4
|
export interface HStackProps extends CommonProps {
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
spacing?: number
|
|
6
|
+
alignment?: "top" | "center" | "bottom"
|
|
9
7
|
}
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
case "bottom":
|
|
19
|
-
return "end"
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export class HStackHost extends BaseHost {
|
|
24
|
-
spacing = 0
|
|
25
|
-
alignment: "top" | "center" | "bottom" = "top"
|
|
26
|
-
private cachedSizes: Size[] = []
|
|
27
|
-
|
|
28
|
-
constructor(props: HStackProps, ctx: HostContext) {
|
|
29
|
-
super("hstack", props, ctx)
|
|
30
|
-
this.updateProps(props)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
measure(maxW: number, maxH: number): Size {
|
|
34
|
-
const result = measureFlex("horizontal", this.children, this.spacing, maxW, maxH)
|
|
35
|
-
this.cachedSizes = result.sizes
|
|
36
|
-
return result.totalSize
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
override layout(rect: Rect): void {
|
|
40
|
-
super.layout(rect)
|
|
41
|
-
const stretchCross = this.alignment === "top"
|
|
42
|
-
layoutFlex(
|
|
43
|
-
"horizontal",
|
|
44
|
-
this.children,
|
|
45
|
-
this.cachedSizes,
|
|
46
|
-
rect,
|
|
47
|
-
this.spacing,
|
|
48
|
-
toFlexAlignment(this.alignment),
|
|
49
|
-
stretchCross,
|
|
50
|
-
)
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
render(buffer: CellBuffer, palette: Palette): void {
|
|
54
|
-
for (const child of this.children) {
|
|
55
|
-
child.render(buffer, palette)
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
override updateProps(props: Record<string, unknown>): void {
|
|
60
|
-
super.updateProps(props)
|
|
61
|
-
if (props.spacing !== undefined) this.spacing = props.spacing as number
|
|
62
|
-
if (props.alignment !== undefined) this.alignment = props.alignment as "top" | "center" | "bottom"
|
|
63
|
-
}
|
|
9
|
+
/**
|
|
10
|
+
* HStackHost lays out children horizontally with optional spacing and cross-axis alignment.
|
|
11
|
+
*/
|
|
12
|
+
export class HStackHost extends FlexContainerHost<"horizontal"> {
|
|
13
|
+
constructor(props: HStackProps, ctx: HostContext) {
|
|
14
|
+
super("horizontal", "hstack", props as FlexContainerProps<"horizontal">, ctx, "top")
|
|
15
|
+
}
|
|
64
16
|
}
|
package/src/hosts/index.ts
CHANGED
|
@@ -8,6 +8,10 @@ import { ZStackHost } from "./zstack.js"
|
|
|
8
8
|
import { BoxHost } from "./box.js"
|
|
9
9
|
import { CanvasHost } from "./canvas.js"
|
|
10
10
|
import { CodeBlockHost } from "./codeblock.js"
|
|
11
|
+
import { ScrollHost } from "./scroll.js"
|
|
12
|
+
import { OverlayHost } from "./overlay.js"
|
|
13
|
+
import { OverlayItemHost } from "./overlay-item.js"
|
|
14
|
+
export { SingleChildHost } from "./single-child.js"
|
|
11
15
|
|
|
12
16
|
export { BaseHost } from "./base.js"
|
|
13
17
|
export { TextHost, RawTextHost, type TextProps } from "./text.js"
|
|
@@ -18,28 +22,34 @@ export { ZStackHost, type ZStackProps } from "./zstack.js"
|
|
|
18
22
|
export { BoxHost, type BoxProps } from "./box.js"
|
|
19
23
|
export { CanvasHost, type CanvasProps, type DrawContext } from "./canvas.js"
|
|
20
24
|
export { CodeBlockHost, type CodeBlockProps } from "./codeblock.js"
|
|
25
|
+
export { ScrollHost, type ScrollProps } from "./scroll.js"
|
|
26
|
+
export { OverlayHost, type OverlayProps } from "./overlay.js"
|
|
27
|
+
export { OverlayItemHost, type OverlayItemProps } from "./overlay-item.js"
|
|
21
28
|
|
|
22
29
|
// Use any to allow specialized props on each host type
|
|
23
30
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
24
31
|
export const hostRegistry: Record<string, new (props: any, ctx: HostContext) => BaseHost> = {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
text: TextHost,
|
|
33
|
+
spacer: SpacerHost,
|
|
34
|
+
vstack: VStackHost,
|
|
35
|
+
hstack: HStackHost,
|
|
36
|
+
zstack: ZStackHost,
|
|
37
|
+
box: BoxHost,
|
|
38
|
+
canvas: CanvasHost,
|
|
39
|
+
codeblock: CodeBlockHost,
|
|
40
|
+
scroll: ScrollHost,
|
|
41
|
+
overlay: OverlayHost,
|
|
42
|
+
overlayItem: OverlayItemHost,
|
|
33
43
|
}
|
|
34
44
|
|
|
35
45
|
export function createHostInstance(type: string, props: CommonProps, ctx: HostContext): BaseHost {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
46
|
+
const Host = hostRegistry[type]
|
|
47
|
+
if (!Host) {
|
|
48
|
+
throw new Error(`Unknown host component type: ${type}`)
|
|
49
|
+
}
|
|
50
|
+
return new Host(props, ctx)
|
|
41
51
|
}
|
|
42
52
|
|
|
43
53
|
export function createTextInstance(text: string, ctx: HostContext): RawTextHost {
|
|
44
|
-
|
|
54
|
+
return new RawTextHost(text, ctx)
|
|
45
55
|
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OverlayItem host - wrapper for overlay children with alignment
|
|
3
|
+
*
|
|
4
|
+
* This is a pass-through container that holds alignment props.
|
|
5
|
+
* Used by Overlay to position non-base children.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { CellBuffer, Palette, Rect, Size } from "@effect-tui/core"
|
|
9
|
+
import type { HostContext, CommonProps } from "../reconciler/types.js"
|
|
10
|
+
import { BaseHost } from "./base.js"
|
|
11
|
+
|
|
12
|
+
type HAlign = "left" | "center" | "right"
|
|
13
|
+
type VAlign = "top" | "center" | "bottom"
|
|
14
|
+
|
|
15
|
+
export interface OverlayItemProps extends CommonProps {
|
|
16
|
+
/** Alignment within the overlay container */
|
|
17
|
+
alignment?: { h?: HAlign; v?: VAlign }
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export class OverlayItemHost extends BaseHost {
|
|
21
|
+
/** Stored alignment for parent Overlay to read */
|
|
22
|
+
alignment: { h?: HAlign; v?: VAlign } = {}
|
|
23
|
+
|
|
24
|
+
constructor(props: OverlayItemProps, ctx: HostContext) {
|
|
25
|
+
super("overlayItem", props, ctx)
|
|
26
|
+
this.updateProps(props)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
override measure(maxW: number, maxH: number): Size {
|
|
30
|
+
const constrained = this.constrainProposal(maxW, maxH)
|
|
31
|
+
|
|
32
|
+
// Size is determined by single child
|
|
33
|
+
const child = this.children[0]
|
|
34
|
+
if (!child) {
|
|
35
|
+
return this.constrainResult({ w: 0, h: 0 })
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const childSize = child.measure(constrained.w, constrained.h)
|
|
39
|
+
return this.constrainResult(childSize)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
override layout(rect: Rect): void {
|
|
43
|
+
this.rect = rect
|
|
44
|
+
|
|
45
|
+
// Pass rect to child
|
|
46
|
+
const child = this.children[0]
|
|
47
|
+
if (child) {
|
|
48
|
+
child.layout(rect)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
override render(buffer: CellBuffer, palette: Palette): void {
|
|
53
|
+
// Render child
|
|
54
|
+
const child = this.children[0]
|
|
55
|
+
if (child) {
|
|
56
|
+
if (child.rect) {
|
|
57
|
+
buffer.withClip(child.rect.x, child.rect.y, child.rect.w, child.rect.h, () => {
|
|
58
|
+
child.render(buffer, palette)
|
|
59
|
+
})
|
|
60
|
+
} else {
|
|
61
|
+
child.render(buffer, palette)
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
override updateProps(props: Record<string, unknown>): void {
|
|
67
|
+
super.updateProps(props)
|
|
68
|
+
if (props.alignment !== undefined) {
|
|
69
|
+
this.alignment = props.alignment as { h?: HAlign; v?: VAlign }
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|