@effect-tui/react 0.1.3 → 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 +30 -23
- 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 -94
- 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
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Overlay host - SwiftUI-style overlay layout
|
|
3
|
+
*
|
|
4
|
+
* Unlike zstack (which sizes to MAX of all children), overlay:
|
|
5
|
+
* 1. First child is the "base" - determines the container size
|
|
6
|
+
* 2. Subsequent children (overlayItem) are overlaid without affecting measurement
|
|
7
|
+
* 3. Each overlayItem specifies its own alignment
|
|
8
|
+
*
|
|
9
|
+
* Usage with compound component:
|
|
10
|
+
* ```tsx
|
|
11
|
+
* <Overlay>
|
|
12
|
+
* <MainContent />
|
|
13
|
+
* <Overlay.Item alignment={{ v: "top" }}><Toast /></Overlay.Item>
|
|
14
|
+
* <Overlay.Item alignment={{ v: "bottom" }}><Console /></Overlay.Item>
|
|
15
|
+
* </Overlay>
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import type { CellBuffer, Palette, Rect, Size } from "@effect-tui/core"
|
|
20
|
+
import type { HostContext, CommonProps } from "../reconciler/types.js"
|
|
21
|
+
import { BaseHost } from "./base.js"
|
|
22
|
+
import type { OverlayItemHost } from "./overlay-item.js"
|
|
23
|
+
|
|
24
|
+
export interface OverlayProps extends CommonProps {}
|
|
25
|
+
|
|
26
|
+
export class OverlayHost extends BaseHost {
|
|
27
|
+
private cachedSizes: Size[] = []
|
|
28
|
+
|
|
29
|
+
constructor(props: OverlayProps, ctx: HostContext) {
|
|
30
|
+
super("overlay", props, ctx)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
override measure(maxW: number, maxH: number): Size {
|
|
34
|
+
// Apply frame constraints to what we propose to children
|
|
35
|
+
const constrained = this.constrainProposal(maxW, maxH)
|
|
36
|
+
|
|
37
|
+
// Only first child determines our size
|
|
38
|
+
const baseChild = this.children[0]
|
|
39
|
+
if (!baseChild) {
|
|
40
|
+
return this.constrainResult({ w: 0, h: 0 })
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const baseSize = baseChild.measure(constrained.w, constrained.h)
|
|
44
|
+
this.cachedSizes = [baseSize]
|
|
45
|
+
|
|
46
|
+
// Measure overlay children with the base size
|
|
47
|
+
// They don't affect our size, but need to know their constraints
|
|
48
|
+
for (let i = 1; i < this.children.length; i++) {
|
|
49
|
+
const size = this.children[i].measure(baseSize.w, baseSize.h)
|
|
50
|
+
this.cachedSizes.push(size)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Return base size (overlay children don't affect our size)
|
|
54
|
+
return this.constrainResult(baseSize)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
override layout(rect: Rect): void {
|
|
58
|
+
this.rect = rect
|
|
59
|
+
|
|
60
|
+
// Layout base child to fill our rect
|
|
61
|
+
const baseChild = this.children[0]
|
|
62
|
+
if (baseChild) {
|
|
63
|
+
baseChild.layout(rect)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Layout overlay children with their alignment
|
|
67
|
+
for (let i = 1; i < this.children.length; i++) {
|
|
68
|
+
const child = this.children[i]
|
|
69
|
+
const size = this.cachedSizes[i] ?? child.measure(rect.w, rect.h)
|
|
70
|
+
|
|
71
|
+
// Read alignment from OverlayItemHost (use type check, not instanceof, for bundler compatibility)
|
|
72
|
+
const alignment = child.type === "overlayItem" ? (child as OverlayItemHost).alignment : {}
|
|
73
|
+
const hAlign = alignment.h ?? "center"
|
|
74
|
+
const vAlign = alignment.v ?? "center"
|
|
75
|
+
|
|
76
|
+
// Calculate position based on alignment
|
|
77
|
+
let x = rect.x
|
|
78
|
+
let y = rect.y
|
|
79
|
+
|
|
80
|
+
switch (hAlign) {
|
|
81
|
+
case "left":
|
|
82
|
+
x = rect.x
|
|
83
|
+
break
|
|
84
|
+
case "center":
|
|
85
|
+
x = rect.x + Math.floor((rect.w - size.w) / 2)
|
|
86
|
+
break
|
|
87
|
+
case "right":
|
|
88
|
+
x = rect.x + rect.w - size.w
|
|
89
|
+
break
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
switch (vAlign) {
|
|
93
|
+
case "top":
|
|
94
|
+
y = rect.y
|
|
95
|
+
break
|
|
96
|
+
case "center":
|
|
97
|
+
y = rect.y + Math.floor((rect.h - size.h) / 2)
|
|
98
|
+
break
|
|
99
|
+
case "bottom":
|
|
100
|
+
y = rect.y + rect.h - size.h
|
|
101
|
+
break
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
child.layout({
|
|
105
|
+
x,
|
|
106
|
+
y,
|
|
107
|
+
w: Math.min(rect.w, size.w),
|
|
108
|
+
h: Math.min(rect.h, size.h),
|
|
109
|
+
})
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
override render(buffer: CellBuffer, palette: Palette): void {
|
|
114
|
+
// Render all children in order (base first, then overlays)
|
|
115
|
+
for (const child of this.children) {
|
|
116
|
+
if (child.rect) {
|
|
117
|
+
buffer.withClip(child.rect.x, child.rect.y, child.rect.w, child.rect.h, () => {
|
|
118
|
+
child.render(buffer, palette)
|
|
119
|
+
})
|
|
120
|
+
} else {
|
|
121
|
+
child.render(buffer, palette)
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
// scroll.ts — Scrollable container host
|
|
2
|
+
import type { CellBuffer, Palette, Color } from "@effect-tui/core"
|
|
3
|
+
import type { HostContext, Rect, Size, CommonProps } from "../reconciler/types.js"
|
|
4
|
+
import { getInheritedBg } from "./base.js"
|
|
5
|
+
import { SingleChildHost } from "./single-child.js"
|
|
6
|
+
import { resolveBgStyle } from "../utils/index.js"
|
|
7
|
+
|
|
8
|
+
export interface ScrollProps extends CommonProps {
|
|
9
|
+
/** Scroll axis: "vertical" (default), "horizontal", or "both" */
|
|
10
|
+
axis?: "vertical" | "horizontal" | "both"
|
|
11
|
+
/** Current scroll offset in pixels (0 = start) */
|
|
12
|
+
offset?: number
|
|
13
|
+
/** Horizontal offset when axis="both" */
|
|
14
|
+
offsetX?: number
|
|
15
|
+
/** Alignment when content is smaller than viewport */
|
|
16
|
+
align?: "start" | "end"
|
|
17
|
+
/** Background color for the scroll viewport */
|
|
18
|
+
bg?: Color
|
|
19
|
+
/** Whether to show scrollbar indicators */
|
|
20
|
+
showScrollbar?: boolean
|
|
21
|
+
/**
|
|
22
|
+
* Sticky scroll - automatically stay at end when content grows.
|
|
23
|
+
* This is handled in the host itself for instant updates (no React roundtrip).
|
|
24
|
+
*/
|
|
25
|
+
sticky?: boolean
|
|
26
|
+
/** Called when content size is measured (for useScroll) */
|
|
27
|
+
onContentSize?: (width: number, height: number) => void
|
|
28
|
+
/** Called when viewport size changes (for useScroll) */
|
|
29
|
+
onViewportSize?: (width: number, height: number) => void
|
|
30
|
+
/** Called when effective offset changes (for syncing with useScroll when sticky adjusts) */
|
|
31
|
+
onEffectiveOffset?: (offset: number) => void
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export class ScrollHost extends SingleChildHost {
|
|
35
|
+
axis: "vertical" | "horizontal" | "both" = "vertical"
|
|
36
|
+
offset = 0
|
|
37
|
+
offsetX = 0
|
|
38
|
+
align: "start" | "end" = "start"
|
|
39
|
+
bg?: Color
|
|
40
|
+
showScrollbar = true
|
|
41
|
+
sticky = false
|
|
42
|
+
onContentSize?: (width: number, height: number) => void
|
|
43
|
+
onViewportSize?: (width: number, height: number) => void
|
|
44
|
+
onEffectiveOffset?: (offset: number) => void
|
|
45
|
+
|
|
46
|
+
// Measured content dimensions (full size before clipping)
|
|
47
|
+
private contentWidth = 0
|
|
48
|
+
private contentHeight = 0
|
|
49
|
+
// Track last reported sizes to avoid redundant callbacks
|
|
50
|
+
private lastViewportW = 0
|
|
51
|
+
private lastViewportH = 0
|
|
52
|
+
private lastReportedContentW = 0
|
|
53
|
+
private lastReportedContentH = 0
|
|
54
|
+
// Track if we were at end (for sticky behavior)
|
|
55
|
+
private wasAtEnd = true
|
|
56
|
+
// Effective offset after sticky adjustment (used for rendering)
|
|
57
|
+
private effectiveOffset = 0
|
|
58
|
+
private effectiveOffsetX = 0
|
|
59
|
+
|
|
60
|
+
constructor(props: ScrollProps, ctx: HostContext) {
|
|
61
|
+
super("scroll", props, ctx)
|
|
62
|
+
this.updateProps(props)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
measure(maxW: number, maxH: number): Size {
|
|
66
|
+
// Apply frame constraints to determine our size
|
|
67
|
+
const constrained = this.constrainProposal(maxW, maxH)
|
|
68
|
+
|
|
69
|
+
// Measure child with unbounded dimension(s) based on axis
|
|
70
|
+
let childMaxW = constrained.w
|
|
71
|
+
let childMaxH = constrained.h
|
|
72
|
+
|
|
73
|
+
if (this.axis === "vertical" || this.axis === "both") {
|
|
74
|
+
childMaxH = Number.MAX_SAFE_INTEGER
|
|
75
|
+
}
|
|
76
|
+
if (this.axis === "horizontal" || this.axis === "both") {
|
|
77
|
+
childMaxW = Number.MAX_SAFE_INTEGER
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Measure single child (scroll should have at most one child)
|
|
81
|
+
const child = this.child
|
|
82
|
+
if (child) {
|
|
83
|
+
const childSize = child.measure(childMaxW, childMaxH)
|
|
84
|
+
this.contentWidth = childSize.w
|
|
85
|
+
this.contentHeight = childSize.h
|
|
86
|
+
// Note: onContentSize callback is deferred to layout() to keep measure() pure
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Scroll container is greedy - takes all available space (after constraints)
|
|
90
|
+
return this.constrainResult({ w: constrained.w, h: constrained.h })
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
override layout(rect: Rect): void {
|
|
94
|
+
super.layout(rect)
|
|
95
|
+
|
|
96
|
+
// Report content size if changed (deferred from measure() to keep it pure)
|
|
97
|
+
if (this.contentWidth !== this.lastReportedContentW || this.contentHeight !== this.lastReportedContentH) {
|
|
98
|
+
this.lastReportedContentW = this.contentWidth
|
|
99
|
+
this.lastReportedContentH = this.contentHeight
|
|
100
|
+
this.onContentSize?.(this.contentWidth, this.contentHeight)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Report viewport size if changed (for useScroll hook)
|
|
104
|
+
if (rect.w !== this.lastViewportW || rect.h !== this.lastViewportH) {
|
|
105
|
+
this.lastViewportW = rect.w
|
|
106
|
+
this.lastViewportH = rect.h
|
|
107
|
+
this.onViewportSize?.(rect.w, rect.h)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const child = this.child
|
|
111
|
+
if (!child) return
|
|
112
|
+
|
|
113
|
+
// Calculate max scroll offsets
|
|
114
|
+
const maxScrollY = Math.max(0, this.contentHeight - rect.h)
|
|
115
|
+
const maxScrollX = Math.max(0, this.contentWidth - rect.w)
|
|
116
|
+
|
|
117
|
+
// Start with the offset from props (controlled by useScroll)
|
|
118
|
+
let scrollY = this.offset
|
|
119
|
+
let scrollX = this.offsetX
|
|
120
|
+
|
|
121
|
+
// Sticky scroll logic:
|
|
122
|
+
// - If user manually scrolled away from end (offset < effectiveOffset), unstick
|
|
123
|
+
// - If at end (or was at end and content grew), stay stuck
|
|
124
|
+
if (this.sticky) {
|
|
125
|
+
// Detect if user scrolled away (offset prop is less than where we rendered)
|
|
126
|
+
const userScrolledAway = this.offset < this.effectiveOffset - 1
|
|
127
|
+
|
|
128
|
+
if (userScrolledAway) {
|
|
129
|
+
// User scrolled up - unstick
|
|
130
|
+
this.wasAtEnd = false
|
|
131
|
+
} else if (this.wasAtEnd) {
|
|
132
|
+
// Was at end, content may have grown - stay at end
|
|
133
|
+
scrollY = maxScrollY
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// Track if we're at end for next frame
|
|
138
|
+
this.wasAtEnd = scrollY >= maxScrollY - 1
|
|
139
|
+
|
|
140
|
+
// Clamp offsets
|
|
141
|
+
scrollY = Math.max(0, Math.min(maxScrollY, scrollY))
|
|
142
|
+
scrollX = Math.max(0, Math.min(maxScrollX, scrollX))
|
|
143
|
+
|
|
144
|
+
// Store effective offsets for rendering (scrollbar position)
|
|
145
|
+
// Report back if changed (for useScroll to sync its state)
|
|
146
|
+
if (scrollY !== this.effectiveOffset) {
|
|
147
|
+
this.onEffectiveOffset?.(scrollY)
|
|
148
|
+
}
|
|
149
|
+
this.effectiveOffset = scrollY
|
|
150
|
+
this.effectiveOffsetX = scrollX
|
|
151
|
+
|
|
152
|
+
// Handle alignment when content is smaller than viewport
|
|
153
|
+
if (this.align === "end") {
|
|
154
|
+
if (this.contentHeight < rect.h && (this.axis === "vertical" || this.axis === "both")) {
|
|
155
|
+
// Align to bottom
|
|
156
|
+
scrollY = -(rect.h - this.contentHeight)
|
|
157
|
+
}
|
|
158
|
+
if (this.contentWidth < rect.w && (this.axis === "horizontal" || this.axis === "both")) {
|
|
159
|
+
// Align to right
|
|
160
|
+
scrollX = -(rect.w - this.contentWidth)
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// Layout child at offset position
|
|
165
|
+
const childRect: Rect = {
|
|
166
|
+
x: rect.x - scrollX,
|
|
167
|
+
y: rect.y - scrollY,
|
|
168
|
+
w: this.contentWidth,
|
|
169
|
+
h: this.contentHeight,
|
|
170
|
+
}
|
|
171
|
+
child.layout(childRect)
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
render(buffer: CellBuffer, palette: Palette): void {
|
|
175
|
+
if (!this.rect) return
|
|
176
|
+
const { x, y, w, h } = this.rect
|
|
177
|
+
|
|
178
|
+
// Fill background
|
|
179
|
+
const rawBg: Color | undefined = this.bg ?? getInheritedBg(this.parent)
|
|
180
|
+
const { value: bgValue, styleId: bgStyleId } = resolveBgStyle(palette, rawBg)
|
|
181
|
+
if (bgValue !== undefined) {
|
|
182
|
+
buffer.fillRect(x, y, w, h, " ".codePointAt(0)!, bgStyleId)
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// Render children with clipping
|
|
186
|
+
buffer.withClip(x, y, w, h, () => {
|
|
187
|
+
const child = this.child
|
|
188
|
+
if (child) {
|
|
189
|
+
child.render(buffer, palette)
|
|
190
|
+
}
|
|
191
|
+
})
|
|
192
|
+
|
|
193
|
+
// Draw scrollbar indicators
|
|
194
|
+
if (this.showScrollbar) {
|
|
195
|
+
this.renderScrollbars(buffer, palette)
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
private renderScrollbars(buffer: CellBuffer, palette: Palette): void {
|
|
200
|
+
if (!this.rect) return
|
|
201
|
+
const { x, y, w, h } = this.rect
|
|
202
|
+
|
|
203
|
+
// Vertical scrollbar
|
|
204
|
+
if ((this.axis === "vertical" || this.axis === "both") && this.contentHeight > h) {
|
|
205
|
+
const maxScroll = this.contentHeight - h
|
|
206
|
+
const scrollRatio = Math.min(1, this.effectiveOffset / maxScroll)
|
|
207
|
+
const thumbRatio = h / this.contentHeight
|
|
208
|
+
const thumbHeight = Math.max(1, Math.floor(h * thumbRatio))
|
|
209
|
+
const thumbY = Math.floor((h - thumbHeight) * scrollRatio)
|
|
210
|
+
|
|
211
|
+
const trackStyle = palette.id({ fg: 8 }) // dim
|
|
212
|
+
const thumbStyle = palette.id({ fg: 7 }) // brighter
|
|
213
|
+
|
|
214
|
+
// Draw track
|
|
215
|
+
for (let row = 0; row < h; row++) {
|
|
216
|
+
const char = row >= thumbY && row < thumbY + thumbHeight ? "┃" : "│"
|
|
217
|
+
const style = row >= thumbY && row < thumbY + thumbHeight ? thumbStyle : trackStyle
|
|
218
|
+
buffer.drawCP(x + w - 1, y + row, char.codePointAt(0)!, style)
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// Horizontal scrollbar
|
|
223
|
+
if ((this.axis === "horizontal" || this.axis === "both") && this.contentWidth > w) {
|
|
224
|
+
const maxScroll = this.contentWidth - w
|
|
225
|
+
const scrollRatio = Math.min(1, this.effectiveOffsetX / maxScroll)
|
|
226
|
+
const thumbRatio = w / this.contentWidth
|
|
227
|
+
const thumbWidth = Math.max(1, Math.floor(w * thumbRatio))
|
|
228
|
+
const thumbX = Math.floor((w - thumbWidth) * scrollRatio)
|
|
229
|
+
|
|
230
|
+
const trackStyle = palette.id({ fg: 8 })
|
|
231
|
+
const thumbStyle = palette.id({ fg: 7 })
|
|
232
|
+
|
|
233
|
+
// Draw track
|
|
234
|
+
for (let col = 0; col < w; col++) {
|
|
235
|
+
const char = col >= thumbX && col < thumbX + thumbWidth ? "━" : "─"
|
|
236
|
+
const style = col >= thumbX && col < thumbX + thumbWidth ? thumbStyle : trackStyle
|
|
237
|
+
buffer.drawCP(x + col, y + h - 1, char.codePointAt(0)!, style)
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
override updateProps(props: Record<string, unknown>): void {
|
|
243
|
+
super.updateProps(props)
|
|
244
|
+
if (props.axis !== undefined) this.axis = (props.axis as ScrollProps["axis"]) ?? "vertical"
|
|
245
|
+
if (props.offset !== undefined) this.offset = props.offset as number
|
|
246
|
+
if (props.offsetX !== undefined) this.offsetX = props.offsetX as number
|
|
247
|
+
if (props.align !== undefined) this.align = (props.align as ScrollProps["align"]) ?? "start"
|
|
248
|
+
this.bg = props.bg as Color | undefined
|
|
249
|
+
if (props.showScrollbar !== undefined) this.showScrollbar = props.showScrollbar as boolean
|
|
250
|
+
if (props.sticky !== undefined) this.sticky = props.sticky as boolean
|
|
251
|
+
this.onContentSize = props.onContentSize as ScrollProps["onContentSize"]
|
|
252
|
+
this.onViewportSize = props.onViewportSize as ScrollProps["onViewportSize"]
|
|
253
|
+
this.onEffectiveOffset = props.onEffectiveOffset as ScrollProps["onEffectiveOffset"]
|
|
254
|
+
}
|
|
255
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { HostInstance, CommonProps, HostContext } from "../reconciler/types.js"
|
|
2
|
+
import { BaseHost } from "./base.js"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Base host that enforces a single child.
|
|
6
|
+
* Additional children replace the existing child and emit a warning once.
|
|
7
|
+
*/
|
|
8
|
+
export abstract class SingleChildHost extends BaseHost {
|
|
9
|
+
private warned = false
|
|
10
|
+
|
|
11
|
+
constructor(type: string, props: CommonProps, ctx: HostContext) {
|
|
12
|
+
super(type, props, ctx)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
protected get child(): HostInstance | null {
|
|
16
|
+
return this.children[0] ?? null
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
override appendChild(child: HostInstance): void {
|
|
20
|
+
this.setSingleChild(child)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
override insertBefore(child: HostInstance, _before: HostInstance): void {
|
|
24
|
+
this.setSingleChild(child)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
override removeChild(child: HostInstance): void {
|
|
28
|
+
const current = this.children[0]
|
|
29
|
+
if (current === child) {
|
|
30
|
+
this.children.splice(0, 1)
|
|
31
|
+
}
|
|
32
|
+
child.parent = null
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
private setSingleChild(child: HostInstance): void {
|
|
36
|
+
const current = this.children[0]
|
|
37
|
+
if (current === child) return
|
|
38
|
+
|
|
39
|
+
if (current) {
|
|
40
|
+
if (!this.warned) {
|
|
41
|
+
console.warn(`[effect-tui] <${this.type}> only supports a single child; replacing previous child.`)
|
|
42
|
+
this.warned = true
|
|
43
|
+
}
|
|
44
|
+
current.parent = null
|
|
45
|
+
this.children[0] = child
|
|
46
|
+
} else {
|
|
47
|
+
this.children.push(child)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
child.parent = this
|
|
51
|
+
}
|
|
52
|
+
}
|
package/src/hosts/spacer.ts
CHANGED
|
@@ -3,38 +3,42 @@ import type { HostContext, Rect, Size, CommonProps } from "../reconciler/types.j
|
|
|
3
3
|
import { BaseHost } from "./base.js"
|
|
4
4
|
|
|
5
5
|
export interface SpacerProps extends CommonProps {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
/** Minimum width (default 0) */
|
|
7
|
+
minWidth?: number
|
|
8
|
+
/** Minimum height (default 0) */
|
|
9
|
+
minHeight?: number
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export class SpacerHost extends BaseHost {
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
minWidth = 0
|
|
14
|
+
minHeight = 0
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
constructor(props: SpacerProps, ctx: HostContext) {
|
|
17
|
+
// Spacers have flexGrow=1 by default
|
|
18
|
+
const propsWithDefaults = { flexGrow: 1, ...props }
|
|
19
|
+
super("spacer", propsWithDefaults, ctx)
|
|
20
|
+
this.updateProps(propsWithDefaults)
|
|
21
|
+
}
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
measure(_maxW: number, _maxH: number): Size {
|
|
24
|
+
// Spacers have no natural size, they expand via flexGrow
|
|
25
|
+
return { w: this.minWidth, h: this.minHeight }
|
|
26
|
+
}
|
|
26
27
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
override layout(rect: Rect): void {
|
|
29
|
+
super.layout(rect)
|
|
30
|
+
}
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
render(_buffer: CellBuffer, _palette: Palette): void {
|
|
33
|
+
// Spacers render nothing
|
|
34
|
+
}
|
|
34
35
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
override updateProps(props: Record<string, unknown>): void {
|
|
37
|
+
// Keep spacer default flexGrow=1 unless explicitly provided
|
|
38
|
+
const flexGrow = props.flexGrow as number | undefined
|
|
39
|
+
const propsWithDefaults = flexGrow === undefined ? { ...props, flexGrow: 1 } : props
|
|
40
|
+
super.updateProps(propsWithDefaults)
|
|
41
|
+
if (props.minWidth !== undefined) this.minWidth = props.minWidth as number
|
|
42
|
+
if (props.minHeight !== undefined) this.minHeight = props.minHeight as number
|
|
43
|
+
}
|
|
40
44
|
}
|