@effect-tui/react 0.7.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/components/Divider.d.ts.map +1 -1
- package/dist/src/components/Divider.js +1 -1
- package/dist/src/components/Divider.js.map +1 -1
- package/dist/src/components/Markdown.js +13 -13
- package/dist/src/components/Markdown.js.map +1 -1
- package/dist/src/components/MultilineTextInput.d.ts.map +1 -1
- package/dist/src/components/MultilineTextInput.js +1 -1
- package/dist/src/components/MultilineTextInput.js.map +1 -1
- package/dist/src/components/Table.d.ts.map +1 -1
- package/dist/src/components/Table.js +1 -1
- package/dist/src/components/Table.js.map +1 -1
- package/dist/src/components/TextInput.d.ts.map +1 -1
- package/dist/src/components/TextInput.js +1 -1
- package/dist/src/components/TextInput.js.map +1 -1
- package/dist/src/console/ConsoleCapture.d.ts +25 -0
- package/dist/src/console/ConsoleCapture.d.ts.map +1 -1
- package/dist/src/console/ConsoleCapture.js +153 -9
- package/dist/src/console/ConsoleCapture.js.map +1 -1
- package/dist/src/console/ConsolePopover.js +10 -10
- package/dist/src/console/ConsolePopover.js.map +1 -1
- package/dist/src/console/useConsole.d.ts.map +1 -1
- package/dist/src/console/useConsole.js +3 -5
- package/dist/src/console/useConsole.js.map +1 -1
- package/dist/src/debug/DiagnosticsPanel.js +1 -1
- package/dist/src/debug/DiagnosticsPanel.js.map +1 -1
- package/dist/src/dev/Toast.d.ts.map +1 -1
- package/dist/src/dev/Toast.js +4 -8
- package/dist/src/dev/Toast.js.map +1 -1
- package/dist/src/dev.js +1 -1
- package/dist/src/dev.js.map +1 -1
- package/dist/src/hooks/use-scroll.d.ts.map +1 -1
- package/dist/src/hooks/use-scroll.js +14 -9
- package/dist/src/hooks/use-scroll.js.map +1 -1
- package/dist/src/hosts/box.d.ts +6 -0
- package/dist/src/hosts/box.d.ts.map +1 -1
- package/dist/src/hosts/box.js +15 -1
- package/dist/src/hosts/box.js.map +1 -1
- package/dist/src/hosts/canvas.js +1 -1
- package/dist/src/hosts/canvas.js.map +1 -1
- package/dist/src/hosts/codeblock.js +1 -1
- package/dist/src/hosts/codeblock.js.map +1 -1
- package/dist/src/inline/index.js +5 -5
- package/dist/src/inline/index.js.map +1 -1
- package/dist/src/renderer.d.ts.map +1 -1
- package/dist/src/renderer.js +25 -1
- package/dist/src/renderer.js.map +1 -1
- package/dist/src/visualize/index.js +3 -3
- package/dist/src/visualize/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/components/Divider.tsx +1 -1
- package/src/components/Markdown.tsx +13 -13
- package/src/components/MultilineTextInput.tsx +5 -5
- package/src/components/Table.tsx +2 -2
- package/src/components/TextInput.tsx +4 -4
- package/src/console/ConsoleCapture.ts +174 -9
- package/src/console/ConsolePopover.tsx +12 -12
- package/src/console/useConsole.ts +3 -6
- package/src/debug/DiagnosticsPanel.tsx +4 -4
- package/src/dev/Toast.tsx +8 -9
- package/src/dev.tsx +1 -1
- package/src/hooks/use-scroll.ts +18 -9
- package/src/hosts/box.ts +21 -1
- package/src/hosts/canvas.ts +1 -1
- package/src/hosts/codeblock.ts +1 -1
- package/src/inline/index.tsx +5 -5
- package/src/renderer.ts +24 -1
- package/src/visualize/index.tsx +11 -11
package/src/renderer.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { performance } from "node:perf_hooks"
|
|
2
2
|
import { ANSI, bufferToString, type KeyMsg, type MouseMsg } from "@effect-tui/core"
|
|
3
3
|
import React, { type ReactNode } from "react"
|
|
4
|
+
import { createTerminalWriter } from "./console/ConsoleCapture.js"
|
|
4
5
|
import { DEFAULT_FPS } from "./constants.js"
|
|
5
6
|
import { requestExit } from "./exit.js"
|
|
6
7
|
import * as Prof from "./profiler.js"
|
|
@@ -30,7 +31,29 @@ type HandledSignal = "SIGINT" | "SIGTERM"
|
|
|
30
31
|
|
|
31
32
|
export function createRenderer(options?: RendererOptions): TuiRenderer {
|
|
32
33
|
const fps = options?.fps ?? DEFAULT_FPS
|
|
33
|
-
|
|
34
|
+
// Use custom stdout if provided, otherwise use process.stdout with bypassed capture
|
|
35
|
+
let stdout: TuiWriteStream
|
|
36
|
+
if (options?.stdout) {
|
|
37
|
+
// Use custom stdout as-is (e.g., for testing with MockStdout)
|
|
38
|
+
stdout = options.stdout
|
|
39
|
+
} else {
|
|
40
|
+
// Create a proxy that bypasses console capture for writes
|
|
41
|
+
// This ensures Effect.log etc. don't corrupt the TUI
|
|
42
|
+
const terminalWrite = createTerminalWriter()
|
|
43
|
+
stdout = new Proxy(process.stdout as TuiWriteStream, {
|
|
44
|
+
get(target, prop) {
|
|
45
|
+
if (prop === "write") {
|
|
46
|
+
return terminalWrite
|
|
47
|
+
}
|
|
48
|
+
const value = (target as unknown as Record<string | symbol, unknown>)[prop]
|
|
49
|
+
// Bind methods to preserve `this` context (critical for .on(), .removeListener(), etc.)
|
|
50
|
+
if (typeof value === "function") {
|
|
51
|
+
return value.bind(target)
|
|
52
|
+
}
|
|
53
|
+
return value
|
|
54
|
+
},
|
|
55
|
+
})
|
|
56
|
+
}
|
|
34
57
|
const stdin: TuiReadStream = options?.stdin ?? process.stdin
|
|
35
58
|
const mode = options?.mode ?? "fullscreen"
|
|
36
59
|
const exitOnCtrlC = options?.exitOnCtrlC ?? true
|
package/src/visualize/index.tsx
CHANGED
|
@@ -95,12 +95,12 @@ function Visualizer({ state, label }: { state: VisualizerState; label: string })
|
|
|
95
95
|
return (
|
|
96
96
|
<vstack>
|
|
97
97
|
<hstack spacing={1}>
|
|
98
|
-
<text fg={Colors.brightCyan}>{SPINNER_FRAMES[state.spinnerIndex]}</text>
|
|
99
|
-
<text bold fg={Colors.brightWhite}>
|
|
98
|
+
<text fg={Colors.ansi.brightCyan}>{SPINNER_FRAMES[state.spinnerIndex]}</text>
|
|
99
|
+
<text bold fg={Colors.ansi.brightWhite}>
|
|
100
100
|
{label}
|
|
101
101
|
</text>
|
|
102
102
|
</hstack>
|
|
103
|
-
<text fg={Colors.gray(10)}>└ Running… {elapsed}</text>
|
|
103
|
+
<text fg={Colors.ansi.gray(10)}>└ Running… {elapsed}</text>
|
|
104
104
|
</vstack>
|
|
105
105
|
)
|
|
106
106
|
}
|
|
@@ -110,15 +110,15 @@ function Visualizer({ state, label }: { state: VisualizerState; label: string })
|
|
|
110
110
|
return (
|
|
111
111
|
<vstack>
|
|
112
112
|
<hstack spacing={1}>
|
|
113
|
-
<text bold fg={Colors.brightGreen}>
|
|
113
|
+
<text bold fg={Colors.ansi.brightGreen}>
|
|
114
114
|
✓
|
|
115
115
|
</text>
|
|
116
|
-
<text bold fg={Colors.brightGreen}>
|
|
116
|
+
<text bold fg={Colors.ansi.brightGreen}>
|
|
117
117
|
{label}
|
|
118
118
|
</text>
|
|
119
119
|
</hstack>
|
|
120
|
-
{showingResult && <text fg={Colors.gray(20)}>├ {formatResult(state.result)}</text>}
|
|
121
|
-
<text fg={Colors.green}>
|
|
120
|
+
{showingResult && <text fg={Colors.ansi.gray(20)}>├ {formatResult(state.result)}</text>}
|
|
121
|
+
<text fg={Colors.green(500)}>
|
|
122
122
|
{showingResult ? "└" : "└"} Completed in {elapsed}
|
|
123
123
|
</text>
|
|
124
124
|
</vstack>
|
|
@@ -129,15 +129,15 @@ function Visualizer({ state, label }: { state: VisualizerState; label: string })
|
|
|
129
129
|
return (
|
|
130
130
|
<vstack>
|
|
131
131
|
<hstack spacing={1}>
|
|
132
|
-
<text bold fg={Colors.brightRed}>
|
|
132
|
+
<text bold fg={Colors.ansi.brightRed}>
|
|
133
133
|
✗
|
|
134
134
|
</text>
|
|
135
|
-
<text bold fg={Colors.brightRed}>
|
|
135
|
+
<text bold fg={Colors.ansi.brightRed}>
|
|
136
136
|
{label}
|
|
137
137
|
</text>
|
|
138
138
|
</hstack>
|
|
139
|
-
<text fg={Colors.red}>├ {state.errorSummary ?? "Failed"}</text>
|
|
140
|
-
<text fg={Colors.red}>└ Failed after {elapsed}</text>
|
|
139
|
+
<text fg={Colors.red(500)}>├ {state.errorSummary ?? "Failed"}</text>
|
|
140
|
+
<text fg={Colors.red(500)}>└ Failed after {elapsed}</text>
|
|
141
141
|
</vstack>
|
|
142
142
|
)
|
|
143
143
|
}
|