UNPKG

@unito/integration-debugger

Version:

The Unito Integration Debugger

40 lines (39 loc) 2.01 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const jsx_runtime_1 = require("react/jsx-runtime"); const react_1 = require("react"); const styles_1 = require("../../styles"); const store_1 = require("../../store"); const blessed_1 = require("../../resources/blessed"); const OutputPane = () => { const boxRef = (0, react_1.useRef)(null); const debuggerState = (0, store_1.useDebuggerState)(); const outputTitle = (0, react_1.useCallback)(() => { const step = debuggerState.selectedStack ?? debuggerState.selected; return step ? (0, styles_1.renderCallEntry)(step) : 'output'; }, [debuggerState.selectedStack, debuggerState.selected]); const output = (0, react_1.useCallback)(() => { const step = debuggerState.selectedStack ?? debuggerState.selected; return step ? (0, styles_1.renderInspectCall)(step, debuggerState.inspectMode) : ''; }, [debuggerState.selectedStack, debuggerState.selected, debuggerState.inspectMode]); (0, react_1.useEffect)(() => { if (boxRef.current) { (0, blessed_1.enableBoxScrolling)(boxRef.current); boxRef.current.key(['left', 'right'], () => { debuggerState.selectedPane = store_1.Pane.Calls; }); } return () => { if (boxRef.current) { boxRef.current.free(); } }; }, [boxRef]); (0, react_1.useEffect)(() => { if (boxRef.current && debuggerState.selectedPane === store_1.Pane.Output) { boxRef.current.focus(); } }, [boxRef, debuggerState.selectedPane]); return ((0, jsx_runtime_1.jsx)("box", { ref: boxRef, label: outputTitle(), right: 0, width: "60%", top: 0, height: "100%-3", border: styles_1.paneBorder, style: debuggerState.selectedPane === store_1.Pane.Output ? styles_1.focusedPane : styles_1.pane, scrollbar: styles_1.scrollbar, scrollable: true, focusable: true, children: output() })); }; exports.default = OutputPane;