@effect-tui/react 0.6.3 → 0.7.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.
Files changed (50) hide show
  1. package/dist/jsx-runtime.d.ts +4 -1
  2. package/dist/jsx-runtime.d.ts.map +1 -1
  3. package/dist/src/components/ListView.d.ts +3 -1
  4. package/dist/src/components/ListView.d.ts.map +1 -1
  5. package/dist/src/components/ListView.js +38 -11
  6. package/dist/src/components/ListView.js.map +1 -1
  7. package/dist/src/hooks/use-scroll.d.ts +5 -3
  8. package/dist/src/hooks/use-scroll.d.ts.map +1 -1
  9. package/dist/src/hooks/use-scroll.js +4 -2
  10. package/dist/src/hooks/use-scroll.js.map +1 -1
  11. package/dist/src/hosts/index.d.ts +1 -1
  12. package/dist/src/hosts/index.d.ts.map +1 -1
  13. package/dist/src/hosts/index.js +3 -2
  14. package/dist/src/hosts/index.js.map +1 -1
  15. package/dist/src/hosts/scroll.d.ts +5 -0
  16. package/dist/src/hosts/scroll.d.ts.map +1 -1
  17. package/dist/src/hosts/scroll.js +10 -0
  18. package/dist/src/hosts/scroll.js.map +1 -1
  19. package/dist/src/hosts/text.d.ts +48 -1
  20. package/dist/src/hosts/text.d.ts.map +1 -1
  21. package/dist/src/hosts/text.js +200 -5
  22. package/dist/src/hosts/text.js.map +1 -1
  23. package/dist/src/index.d.ts +1 -1
  24. package/dist/src/index.d.ts.map +1 -1
  25. package/dist/src/remote/Procedures.d.ts +11 -0
  26. package/dist/src/remote/Procedures.d.ts.map +1 -1
  27. package/dist/src/remote/Procedures.js +17 -1
  28. package/dist/src/remote/Procedures.js.map +1 -1
  29. package/dist/src/remote/Router.d.ts +12 -1
  30. package/dist/src/remote/Router.d.ts.map +1 -1
  31. package/dist/src/remote/Router.js +1 -0
  32. package/dist/src/remote/Router.js.map +1 -1
  33. package/dist/src/remote/index.d.ts.map +1 -1
  34. package/dist/src/remote/index.js +14 -0
  35. package/dist/src/remote/index.js.map +1 -1
  36. package/dist/src/test/render-tui.js +2 -2
  37. package/dist/src/test/render-tui.js.map +1 -1
  38. package/dist/tsconfig.tsbuildinfo +1 -1
  39. package/jsx-runtime.ts +2 -1
  40. package/package.json +2 -2
  41. package/src/components/ListView.tsx +50 -13
  42. package/src/hooks/use-scroll.ts +9 -5
  43. package/src/hosts/index.ts +13 -2
  44. package/src/hosts/scroll.ts +13 -0
  45. package/src/hosts/text.ts +242 -5
  46. package/src/index.ts +1 -1
  47. package/src/remote/Procedures.ts +19 -1
  48. package/src/remote/Router.ts +14 -1
  49. package/src/remote/index.ts +15 -1
  50. package/src/test/render-tui.ts +2 -2
@@ -13,8 +13,9 @@ export { getSocketPath, makeServerLayer } from "./Server.js"
13
13
 
14
14
  import * as fs from "node:fs"
15
15
  import { Effect, Exit, Layer, Scope } from "effect"
16
+ import { getConsoleCapture } from "../console/ConsoleCapture.js"
16
17
  import type { TuiRenderer } from "../renderer-types.js"
17
- import type { TuiSessionImpl } from "./Router.js"
18
+ import type { LogEntryResult, TuiSessionImpl } from "./Router.js"
18
19
  import { getSocketPath, makeServerLayer } from "./Server.js"
19
20
 
20
21
  export interface EnableRemoteOptions {
@@ -76,6 +77,19 @@ export function enableRemote(renderer: TuiRenderer, options?: EnableRemoteOption
76
77
  entryPath: opts.entryPath,
77
78
  name,
78
79
  }),
80
+ getLogEntries: (limit?: number): { entries: LogEntryResult[]; total: number } => {
81
+ const all = getConsoleCapture().getEntries()
82
+ const total = all.length
83
+ const sliced = limit ? all.slice(-limit) : all
84
+ const entries: LogEntryResult[] = sliced.map((e) => ({
85
+ timestamp: e.timestamp.toISOString(),
86
+ level: e.level,
87
+ message: e.message,
88
+ file: e.location?.file,
89
+ line: e.location?.line,
90
+ }))
91
+ return { entries, total }
92
+ },
79
93
  }
80
94
 
81
95
  // Build and run the server layer
@@ -71,9 +71,9 @@ export function renderTUI(element: ReactElement, options?: RenderTUIOptions): Re
71
71
  const root = createRoot(renderer)
72
72
  let bump: (() => void) | null = null
73
73
  const Harness = ({ children }: { children: ReactElement }) => {
74
- const [, setTick] = useState(0)
74
+ const [tick, setTick] = useState(0)
75
75
  bump = () => setTick((value) => value + 1)
76
- return children
76
+ return React.cloneElement(children, { __renderTick: tick } as Record<string, unknown>)
77
77
  }
78
78
 
79
79
  const harnessed = React.createElement(Harness, null, element)