@effect-tui/react 0.1.0-alpha.1

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 (277) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +138 -0
  3. package/dist/jsx-dev-runtime.d.ts +3 -0
  4. package/dist/jsx-dev-runtime.d.ts.map +1 -0
  5. package/dist/jsx-dev-runtime.js +3 -0
  6. package/dist/jsx-dev-runtime.js.map +1 -0
  7. package/dist/jsx-runtime.d.ts +47 -0
  8. package/dist/jsx-runtime.d.ts.map +1 -0
  9. package/dist/jsx-runtime.js +6 -0
  10. package/dist/jsx-runtime.js.map +1 -0
  11. package/dist/src/codeblock.d.ts +9 -0
  12. package/dist/src/codeblock.d.ts.map +1 -0
  13. package/dist/src/codeblock.js +24 -0
  14. package/dist/src/codeblock.js.map +1 -0
  15. package/dist/src/constants.d.ts +3 -0
  16. package/dist/src/constants.d.ts.map +1 -0
  17. package/dist/src/constants.js +3 -0
  18. package/dist/src/constants.js.map +1 -0
  19. package/dist/src/debug/DiagnosticsPanel.d.ts +7 -0
  20. package/dist/src/debug/DiagnosticsPanel.d.ts.map +1 -0
  21. package/dist/src/debug/DiagnosticsPanel.js +13 -0
  22. package/dist/src/debug/DiagnosticsPanel.js.map +1 -0
  23. package/dist/src/highlight.d.ts +20 -0
  24. package/dist/src/highlight.d.ts.map +1 -0
  25. package/dist/src/highlight.js +51 -0
  26. package/dist/src/highlight.js.map +1 -0
  27. package/dist/src/hooks/index.d.ts +4 -0
  28. package/dist/src/hooks/index.d.ts.map +1 -0
  29. package/dist/src/hooks/index.js +3 -0
  30. package/dist/src/hooks/index.js.map +1 -0
  31. package/dist/src/hooks/use-keyboard.d.ts +18 -0
  32. package/dist/src/hooks/use-keyboard.d.ts.map +1 -0
  33. package/dist/src/hooks/use-keyboard.js +26 -0
  34. package/dist/src/hooks/use-keyboard.js.map +1 -0
  35. package/dist/src/hooks/use-paste.d.ts +5 -0
  36. package/dist/src/hooks/use-paste.d.ts.map +1 -0
  37. package/dist/src/hooks/use-paste.js +14 -0
  38. package/dist/src/hooks/use-paste.js.map +1 -0
  39. package/dist/src/hooks/useFrameStats.d.ts +7 -0
  40. package/dist/src/hooks/useFrameStats.d.ts.map +1 -0
  41. package/dist/src/hooks/useFrameStats.js +28 -0
  42. package/dist/src/hooks/useFrameStats.js.map +1 -0
  43. package/dist/src/hosts/base.d.ts +22 -0
  44. package/dist/src/hosts/base.d.ts.map +1 -0
  45. package/dist/src/hosts/base.js +53 -0
  46. package/dist/src/hosts/base.js.map +1 -0
  47. package/dist/src/hosts/box.d.ts +26 -0
  48. package/dist/src/hosts/box.d.ts.map +1 -0
  49. package/dist/src/hosts/box.js +84 -0
  50. package/dist/src/hosts/box.js.map +1 -0
  51. package/dist/src/hosts/canvas.d.ts +48 -0
  52. package/dist/src/hosts/canvas.d.ts.map +1 -0
  53. package/dist/src/hosts/canvas.js +109 -0
  54. package/dist/src/hosts/canvas.js.map +1 -0
  55. package/dist/src/hosts/codeblock.d.ts +32 -0
  56. package/dist/src/hosts/codeblock.d.ts.map +1 -0
  57. package/dist/src/hosts/codeblock.js +118 -0
  58. package/dist/src/hosts/codeblock.js.map +1 -0
  59. package/dist/src/hosts/hstack.d.ts +18 -0
  60. package/dist/src/hosts/hstack.d.ts.map +1 -0
  61. package/dist/src/hosts/hstack.js +45 -0
  62. package/dist/src/hosts/hstack.js.map +1 -0
  63. package/dist/src/hosts/index.d.ts +16 -0
  64. package/dist/src/hosts/index.d.ts.map +1 -0
  65. package/dist/src/hosts/index.js +40 -0
  66. package/dist/src/hosts/index.js.map +1 -0
  67. package/dist/src/hosts/spacer.d.ts +19 -0
  68. package/dist/src/hosts/spacer.d.ts.map +1 -0
  69. package/dist/src/hosts/spacer.js +28 -0
  70. package/dist/src/hosts/spacer.js.map +1 -0
  71. package/dist/src/hosts/text.d.ts +43 -0
  72. package/dist/src/hosts/text.d.ts.map +1 -0
  73. package/dist/src/hosts/text.js +148 -0
  74. package/dist/src/hosts/text.js.map +1 -0
  75. package/dist/src/hosts/vstack.d.ts +18 -0
  76. package/dist/src/hosts/vstack.d.ts.map +1 -0
  77. package/dist/src/hosts/vstack.js +45 -0
  78. package/dist/src/hosts/vstack.js.map +1 -0
  79. package/dist/src/hosts/zstack.d.ts +20 -0
  80. package/dist/src/hosts/zstack.d.ts.map +1 -0
  81. package/dist/src/hosts/zstack.js +65 -0
  82. package/dist/src/hosts/zstack.js.map +1 -0
  83. package/dist/src/index.d.ts +20 -0
  84. package/dist/src/index.d.ts.map +1 -0
  85. package/dist/src/index.js +20 -0
  86. package/dist/src/index.js.map +1 -0
  87. package/dist/src/inline/index.d.ts +32 -0
  88. package/dist/src/inline/index.d.ts.map +1 -0
  89. package/dist/src/inline/index.js +111 -0
  90. package/dist/src/inline/index.js.map +1 -0
  91. package/dist/src/jsx.d.ts +2 -0
  92. package/dist/src/jsx.d.ts.map +1 -0
  93. package/dist/src/jsx.js +4 -0
  94. package/dist/src/jsx.js.map +1 -0
  95. package/dist/src/motion/color-motion-value.d.ts +32 -0
  96. package/dist/src/motion/color-motion-value.d.ts.map +1 -0
  97. package/dist/src/motion/color-motion-value.js +80 -0
  98. package/dist/src/motion/color-motion-value.js.map +1 -0
  99. package/dist/src/motion/color.d.ts +30 -0
  100. package/dist/src/motion/color.d.ts.map +1 -0
  101. package/dist/src/motion/color.js +172 -0
  102. package/dist/src/motion/color.js.map +1 -0
  103. package/dist/src/motion/color.test.d.ts +2 -0
  104. package/dist/src/motion/color.test.d.ts.map +1 -0
  105. package/dist/src/motion/color.test.js +97 -0
  106. package/dist/src/motion/color.test.js.map +1 -0
  107. package/dist/src/motion/event-emitter.d.ts +18 -0
  108. package/dist/src/motion/event-emitter.d.ts.map +1 -0
  109. package/dist/src/motion/event-emitter.js +30 -0
  110. package/dist/src/motion/event-emitter.js.map +1 -0
  111. package/dist/src/motion/frame.d.ts +9 -0
  112. package/dist/src/motion/frame.d.ts.map +1 -0
  113. package/dist/src/motion/frame.js +51 -0
  114. package/dist/src/motion/frame.js.map +1 -0
  115. package/dist/src/motion/hooks.d.ts +75 -0
  116. package/dist/src/motion/hooks.d.ts.map +1 -0
  117. package/dist/src/motion/hooks.js +190 -0
  118. package/dist/src/motion/hooks.js.map +1 -0
  119. package/dist/src/motion/index.d.ts +4 -0
  120. package/dist/src/motion/index.d.ts.map +1 -0
  121. package/dist/src/motion/index.js +7 -0
  122. package/dist/src/motion/index.js.map +1 -0
  123. package/dist/src/motion/motion-value.d.ts +40 -0
  124. package/dist/src/motion/motion-value.d.ts.map +1 -0
  125. package/dist/src/motion/motion-value.js +109 -0
  126. package/dist/src/motion/motion-value.js.map +1 -0
  127. package/dist/src/motion/motion-value.test.d.ts +2 -0
  128. package/dist/src/motion/motion-value.test.d.ts.map +1 -0
  129. package/dist/src/motion/motion-value.test.js +177 -0
  130. package/dist/src/motion/motion-value.test.js.map +1 -0
  131. package/dist/src/motion/spring-math.d.ts +28 -0
  132. package/dist/src/motion/spring-math.d.ts.map +1 -0
  133. package/dist/src/motion/spring-math.js +81 -0
  134. package/dist/src/motion/spring-math.js.map +1 -0
  135. package/dist/src/motion/types.d.ts +25 -0
  136. package/dist/src/motion/types.d.ts.map +1 -0
  137. package/dist/src/motion/types.js +13 -0
  138. package/dist/src/motion/types.js.map +1 -0
  139. package/dist/src/output.d.ts +47 -0
  140. package/dist/src/output.d.ts.map +1 -0
  141. package/dist/src/output.js +125 -0
  142. package/dist/src/output.js.map +1 -0
  143. package/dist/src/profiler.d.ts +6 -0
  144. package/dist/src/profiler.d.ts.map +1 -0
  145. package/dist/src/profiler.js +73 -0
  146. package/dist/src/profiler.js.map +1 -0
  147. package/dist/src/reconciler/host-config.d.ts +16 -0
  148. package/dist/src/reconciler/host-config.d.ts.map +1 -0
  149. package/dist/src/reconciler/host-config.js +174 -0
  150. package/dist/src/reconciler/host-config.js.map +1 -0
  151. package/dist/src/reconciler/types.d.ts +52 -0
  152. package/dist/src/reconciler/types.d.ts.map +1 -0
  153. package/dist/src/reconciler/types.js +2 -0
  154. package/dist/src/reconciler/types.js.map +1 -0
  155. package/dist/src/renderer.d.ts +101 -0
  156. package/dist/src/renderer.d.ts.map +1 -0
  157. package/dist/src/renderer.js +509 -0
  158. package/dist/src/renderer.js.map +1 -0
  159. package/dist/src/terminal.d.ts +37 -0
  160. package/dist/src/terminal.d.ts.map +1 -0
  161. package/dist/src/terminal.js +65 -0
  162. package/dist/src/terminal.js.map +1 -0
  163. package/dist/src/test/index.d.ts +3 -0
  164. package/dist/src/test/index.d.ts.map +1 -0
  165. package/dist/src/test/index.js +3 -0
  166. package/dist/src/test/index.js.map +1 -0
  167. package/dist/src/test/mock-streams.d.ts +44 -0
  168. package/dist/src/test/mock-streams.d.ts.map +1 -0
  169. package/dist/src/test/mock-streams.js +136 -0
  170. package/dist/src/test/mock-streams.js.map +1 -0
  171. package/dist/src/test/render-tui.d.ts +47 -0
  172. package/dist/src/test/render-tui.d.ts.map +1 -0
  173. package/dist/src/test/render-tui.js +76 -0
  174. package/dist/src/test/render-tui.js.map +1 -0
  175. package/dist/src/trace/SpanTree.d.ts +10 -0
  176. package/dist/src/trace/SpanTree.d.ts.map +1 -0
  177. package/dist/src/trace/SpanTree.js +104 -0
  178. package/dist/src/trace/SpanTree.js.map +1 -0
  179. package/dist/src/trace/index.d.ts +30 -0
  180. package/dist/src/trace/index.d.ts.map +1 -0
  181. package/dist/src/trace/index.js +142 -0
  182. package/dist/src/trace/index.js.map +1 -0
  183. package/dist/src/trace/location.d.ts +9 -0
  184. package/dist/src/trace/location.d.ts.map +1 -0
  185. package/dist/src/trace/location.js +88 -0
  186. package/dist/src/trace/location.js.map +1 -0
  187. package/dist/src/trace/span-processor.d.ts +16 -0
  188. package/dist/src/trace/span-processor.d.ts.map +1 -0
  189. package/dist/src/trace/span-processor.js +54 -0
  190. package/dist/src/trace/span-processor.js.map +1 -0
  191. package/dist/src/trace/span-state.d.ts +79 -0
  192. package/dist/src/trace/span-state.d.ts.map +1 -0
  193. package/dist/src/trace/span-state.js +229 -0
  194. package/dist/src/trace/span-state.js.map +1 -0
  195. package/dist/src/trace/tui-logger.d.ts +8 -0
  196. package/dist/src/trace/tui-logger.d.ts.map +1 -0
  197. package/dist/src/trace/tui-logger.js +70 -0
  198. package/dist/src/trace/tui-logger.js.map +1 -0
  199. package/dist/src/utils/border.d.ts +31 -0
  200. package/dist/src/utils/border.d.ts.map +1 -0
  201. package/dist/src/utils/border.js +81 -0
  202. package/dist/src/utils/border.js.map +1 -0
  203. package/dist/src/utils/flex-layout.d.ts +20 -0
  204. package/dist/src/utils/flex-layout.d.ts.map +1 -0
  205. package/dist/src/utils/flex-layout.js +85 -0
  206. package/dist/src/utils/flex-layout.js.map +1 -0
  207. package/dist/src/utils/index.d.ts +5 -0
  208. package/dist/src/utils/index.d.ts.map +1 -0
  209. package/dist/src/utils/index.js +5 -0
  210. package/dist/src/utils/index.js.map +1 -0
  211. package/dist/src/utils/padding.d.ts +26 -0
  212. package/dist/src/utils/padding.d.ts.map +1 -0
  213. package/dist/src/utils/padding.js +34 -0
  214. package/dist/src/utils/padding.js.map +1 -0
  215. package/dist/src/utils/styles.d.ts +13 -0
  216. package/dist/src/utils/styles.d.ts.map +1 -0
  217. package/dist/src/utils/styles.js +5 -0
  218. package/dist/src/utils/styles.js.map +1 -0
  219. package/dist/src/visualize/index.d.ts +50 -0
  220. package/dist/src/visualize/index.d.ts.map +1 -0
  221. package/dist/src/visualize/index.js +194 -0
  222. package/dist/src/visualize/index.js.map +1 -0
  223. package/dist/tsconfig.tsbuildinfo +1 -0
  224. package/package.json +94 -0
  225. package/src/codeblock.tsx +47 -0
  226. package/src/constants.ts +2 -0
  227. package/src/debug/DiagnosticsPanel.tsx +38 -0
  228. package/src/highlight.ts +76 -0
  229. package/src/hooks/index.ts +3 -0
  230. package/src/hooks/use-keyboard.ts +37 -0
  231. package/src/hooks/use-paste.ts +14 -0
  232. package/src/hooks/useFrameStats.ts +32 -0
  233. package/src/hosts/base.ts +65 -0
  234. package/src/hosts/box.ts +105 -0
  235. package/src/hosts/canvas.ts +155 -0
  236. package/src/hosts/codeblock.ts +145 -0
  237. package/src/hosts/hstack.ts +64 -0
  238. package/src/hosts/index.ts +45 -0
  239. package/src/hosts/spacer.ts +40 -0
  240. package/src/hosts/text.ts +175 -0
  241. package/src/hosts/vstack.ts +64 -0
  242. package/src/hosts/zstack.ts +77 -0
  243. package/src/index.ts +62 -0
  244. package/src/inline/index.tsx +181 -0
  245. package/src/jsx.ts +3 -0
  246. package/src/motion/color-motion-value.ts +90 -0
  247. package/src/motion/color.test.ts +115 -0
  248. package/src/motion/color.ts +191 -0
  249. package/src/motion/event-emitter.ts +35 -0
  250. package/src/motion/frame.ts +59 -0
  251. package/src/motion/hooks.ts +237 -0
  252. package/src/motion/index.ts +17 -0
  253. package/src/motion/motion-value.test.ts +222 -0
  254. package/src/motion/motion-value.ts +140 -0
  255. package/src/motion/spring-math.ts +114 -0
  256. package/src/motion/types.ts +34 -0
  257. package/src/output.ts +156 -0
  258. package/src/profiler.ts +88 -0
  259. package/src/reconciler/host-config.ts +277 -0
  260. package/src/reconciler/types.ts +66 -0
  261. package/src/renderer.ts +661 -0
  262. package/src/terminal.ts +67 -0
  263. package/src/test/index.ts +8 -0
  264. package/src/test/mock-streams.ts +149 -0
  265. package/src/test/render-tui.ts +118 -0
  266. package/src/trace/SpanTree.tsx +195 -0
  267. package/src/trace/index.tsx +205 -0
  268. package/src/trace/location.ts +90 -0
  269. package/src/trace/span-processor.ts +65 -0
  270. package/src/trace/span-state.ts +286 -0
  271. package/src/trace/tui-logger.ts +72 -0
  272. package/src/utils/border.ts +108 -0
  273. package/src/utils/flex-layout.ts +125 -0
  274. package/src/utils/index.ts +4 -0
  275. package/src/utils/padding.ts +45 -0
  276. package/src/utils/styles.ts +14 -0
  277. package/src/visualize/index.tsx +305 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Kit Langton
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,138 @@
1
+ # @effect-tui/react
2
+
3
+ React renderer for terminal UIs with spring animations.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ bun add @effect-tui/react @effect-tui/core effect react
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```tsx
14
+ // tsconfig.json: { "compilerOptions": { "jsxImportSource": "@effect-tui/react" } }
15
+
16
+ import { render, useKeyboard, Colors } from "@effect-tui/react"
17
+
18
+ function App() {
19
+ const [count, setCount] = useState(0)
20
+
21
+ useKeyboard((key) => {
22
+ if (key === "q") process.exit(0)
23
+ if (key === " ") setCount((c) => c + 1)
24
+ })
25
+
26
+ return (
27
+ <vstack>
28
+ <text>Count: {count}</text>
29
+ <text fg="gray">Press space to increment, q to quit</text>
30
+ </vstack>
31
+ )
32
+ }
33
+
34
+ render(<App />)
35
+ ```
36
+
37
+ ## JSX Elements
38
+
39
+ - `<vstack>` - Vertical flex layout
40
+ - `<hstack>` - Horizontal flex layout
41
+ - `<text>` - Text with optional fg/bg colors
42
+ - `<box>` - Container with optional border
43
+ - `<canvas>` - Imperative drawing API
44
+ - `<spacer>` - Flexible space
45
+
46
+ ## Hooks
47
+
48
+ - `useKeyboard(callback)` - Handle keyboard input
49
+ - `usePaste(callback)` - Handle paste events
50
+ - `useTerminalSize()` - Get terminal dimensions (re-renders on resize)
51
+ - `useSpring(initial, options)` - Spring animation
52
+ - `useSprings(count, fn)` - Multiple springs
53
+ - `useColorSpring(color, options)` - Animate colors
54
+
55
+ ## Spring Animations
56
+
57
+ ```tsx
58
+ import { useSpring, useSpringRenderer, useRenderer } from "@effect-tui/react"
59
+
60
+ function AnimatedBox() {
61
+ const renderer = useRenderer()
62
+ useSpringRenderer(renderer)
63
+
64
+ const [xMv, setX] = useSpring(0, { visualDuration: 0.35 })
65
+
66
+ useKeyboard((key) => {
67
+ if (key === "ArrowRight") setX(20)
68
+ if (key === "ArrowLeft") setX(0)
69
+ })
70
+
71
+ return (
72
+ <canvas draw={(ctx) => {
73
+ ctx.box(xMv.get(), 0, 10, 5, { border: "rounded" })
74
+ }} />
75
+ )
76
+ }
77
+ ```
78
+
79
+ ## Architecture
80
+
81
+ Each frame (60fps default):
82
+ 1. **Measure** - Host tree calculates sizes bottom-up
83
+ 2. **Layout** - Host tree assigns positions top-down
84
+ 3. **Render** - Each host writes to CellBuffer
85
+ 4. **Diff** - Compare with previous buffer, find changed lines
86
+ 5. **Write** - Single `stdout.write()` with ANSI sequences
87
+
88
+ ```
89
+ React JSX → Reconciler → Host Tree → CellBuffer → Terminal
90
+ ```
91
+
92
+ ## Testing
93
+
94
+ Use `renderTUI()` for integration tests:
95
+
96
+ ```tsx
97
+ import { renderTUI } from "@effect-tui/react/test"
98
+
99
+ it("renders and handles input", () => {
100
+ const { lastFrame, sendKey, flush, unmount } = renderTUI(<Counter />)
101
+
102
+ expect(lastFrame()).toContain("Count: 0")
103
+
104
+ sendKey({ name: "up" })
105
+ flush()
106
+
107
+ expect(lastFrame()).toContain("Count: 1")
108
+ unmount()
109
+ })
110
+ ```
111
+
112
+ ## API
113
+
114
+ ### Renderer
115
+
116
+ - `createRenderer(options?)` - Create renderer instance
117
+ - `createRoot(renderer)` - Create React root
118
+ - `render(element, options?)` - One-liner convenience API
119
+
120
+ ### Options
121
+
122
+ ```ts
123
+ interface RendererOptions {
124
+ fps?: number // Default: 60
125
+ mode?: "fullscreen" | "inline"
126
+ exitOnCtrlC?: boolean // Default: true
127
+ manualMode?: boolean // For testing
128
+ }
129
+ ```
130
+
131
+ ## Environment Variables
132
+
133
+ - `PROFILE_TUI=1` - Enable profiling (writes to `tui-profile.txt`)
134
+ - `EFFECT_TUI_EDITOR` / `EDITOR` - Editor for trace visualization
135
+
136
+ ## License
137
+
138
+ MIT
@@ -0,0 +1,3 @@
1
+ export { Fragment, jsxDEV } from "react/jsx-dev-runtime";
2
+ export type { JSX } from "./jsx-runtime.js";
3
+ //# sourceMappingURL=jsx-dev-runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsx-dev-runtime.d.ts","sourceRoot":"","sources":["../jsx-dev-runtime.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAGxD,YAAY,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA"}
@@ -0,0 +1,3 @@
1
+ // Re-export React's jsx dev runtime functions
2
+ export { Fragment, jsxDEV } from "react/jsx-dev-runtime";
3
+ //# sourceMappingURL=jsx-dev-runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsx-dev-runtime.js","sourceRoot":"","sources":["../jsx-dev-runtime.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA"}
@@ -0,0 +1,47 @@
1
+ export { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import type * as React from "react";
3
+ import type { TextProps } from "./src/hosts/text.js";
4
+ import type { SpacerProps } from "./src/hosts/spacer.js";
5
+ import type { VStackProps } from "./src/hosts/vstack.js";
6
+ import type { HStackProps } from "./src/hosts/hstack.js";
7
+ import type { ZStackProps } from "./src/hosts/zstack.js";
8
+ import type { BoxProps } from "./src/hosts/box.js";
9
+ import type { CanvasProps } from "./src/hosts/canvas.js";
10
+ import type { CodeBlockProps } from "./src/hosts/codeblock.js";
11
+ declare const JSX: {};
12
+ export { JSX };
13
+ export declare namespace JSX {
14
+ type Element = React.ReactNode;
15
+ interface ElementClass extends React.ComponentClass<any> {
16
+ render(): React.ReactNode;
17
+ }
18
+ interface ElementAttributesProperty {
19
+ props: {};
20
+ }
21
+ interface ElementChildrenAttribute {
22
+ children: {};
23
+ }
24
+ interface IntrinsicAttributes extends React.Attributes {
25
+ }
26
+ interface IntrinsicElements extends React.JSX.IntrinsicElements {
27
+ text: TextProps & {
28
+ children?: React.ReactNode;
29
+ };
30
+ spacer: SpacerProps;
31
+ vstack: VStackProps & {
32
+ children?: React.ReactNode;
33
+ };
34
+ hstack: HStackProps & {
35
+ children?: React.ReactNode;
36
+ };
37
+ zstack: ZStackProps & {
38
+ children?: React.ReactNode;
39
+ };
40
+ box: BoxProps & {
41
+ children?: React.ReactNode;
42
+ };
43
+ canvas: CanvasProps;
44
+ codeblock: CodeBlockProps;
45
+ }
46
+ }
47
+ //# sourceMappingURL=jsx-runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsx-runtime.d.ts","sourceRoot":"","sources":["../jsx-runtime.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAA;AAGvD,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAA;AACnC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAG9D,QAAA,MAAM,GAAG,IAAK,CAAA;AACd,OAAO,EAAE,GAAG,EAAE,CAAA;AAEd,MAAM,CAAC,OAAO,WAAW,GAAG,CAAC;IAC3B,KAAY,OAAO,GAAG,KAAK,CAAC,SAAS,CAAA;IAErC,UAAiB,YAAa,SAAQ,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC;QAC7D,MAAM,IAAI,KAAK,CAAC,SAAS,CAAA;KAC1B;IAED,UAAiB,yBAAyB;QACxC,KAAK,EAAE,EAAE,CAAA;KACV;IAED,UAAiB,wBAAwB;QACvC,QAAQ,EAAE,EAAE,CAAA;KACb;IAED,UAAiB,mBAAoB,SAAQ,KAAK,CAAC,UAAU;KAAG;IAGhE,UAAiB,iBAAkB,SAAQ,KAAK,CAAC,GAAG,CAAC,iBAAiB;QAEpE,IAAI,EAAE,SAAS,GAAG;YAAE,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;SAAE,CAAA;QAChD,MAAM,EAAE,WAAW,CAAA;QACnB,MAAM,EAAE,WAAW,GAAG;YAAE,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;SAAE,CAAA;QACpD,MAAM,EAAE,WAAW,GAAG;YAAE,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;SAAE,CAAA;QACpD,MAAM,EAAE,WAAW,GAAG;YAAE,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;SAAE,CAAA;QACpD,GAAG,EAAE,QAAQ,GAAG;YAAE,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;SAAE,CAAA;QAC9C,MAAM,EAAE,WAAW,CAAA;QACnB,SAAS,EAAE,cAAc,CAAA;KAC1B;CACF"}
@@ -0,0 +1,6 @@
1
+ // Re-export React's jsx runtime functions
2
+ export { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
+ // Runtime placeholder (the actual JSX namespace below is type-only)
4
+ const JSX = {};
5
+ export { JSX };
6
+ //# sourceMappingURL=jsx-runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsx-runtime.js","sourceRoot":"","sources":["../jsx-runtime.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAA;AAavD,oEAAoE;AACpE,MAAM,GAAG,GAAG,EAAE,CAAA;AACd,OAAO,EAAE,GAAG,EAAE,CAAA"}
@@ -0,0 +1,9 @@
1
+ import type { BundledLanguage, BundledTheme } from "shiki";
2
+ import type { CodeBlockProps as HostCodeBlockProps } from "./hosts/codeblock.js";
3
+ export interface CodeBlockProps extends Omit<HostCodeBlockProps, "lines"> {
4
+ code: string;
5
+ language?: BundledLanguage;
6
+ theme?: BundledTheme;
7
+ }
8
+ export declare function CodeBlock({ code, language, theme, lineNumbers, padding, background, ...rest }: CodeBlockProps): import("react").ReactNode;
9
+ //# sourceMappingURL=codeblock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codeblock.d.ts","sourceRoot":"","sources":["../../src/codeblock.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAE1D,OAAO,KAAK,EAAE,cAAc,IAAI,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAEhF,MAAM,WAAW,cAAe,SAAQ,IAAI,CAAC,kBAAkB,EAAE,OAAO,CAAC;IACvE,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,CAAC,EAAE,eAAe,CAAA;IAC1B,KAAK,CAAC,EAAE,YAAY,CAAA;CACrB;AAED,wBAAgB,SAAS,CAAC,EACxB,IAAI,EACJ,QAAe,EACf,KAAc,EACd,WAAkB,EAClB,OAAW,EACX,UAAU,EACV,GAAG,IAAI,EACR,EAAE,cAAc,6BA2BhB"}
@@ -0,0 +1,24 @@
1
+ import { jsx as _jsx } from "@effect-tui/react/jsx-runtime";
2
+ import { useEffect, useState } from "react";
3
+ import { highlightCode, toPlainLines } from "./highlight.js";
4
+ export function CodeBlock({ code, language = "ts", theme = "nord", lineNumbers = true, padding = 1, background, ...rest }) {
5
+ const [lines, setLines] = useState(() => toPlainLines(code));
6
+ useEffect(() => {
7
+ let cancelled = false;
8
+ highlightCode(code, { lang: language, theme })
9
+ .then((result) => {
10
+ if (!cancelled)
11
+ setLines(result);
12
+ })
13
+ .catch((err) => {
14
+ console.warn("CodeBlock: highlighting failed, falling back to plain text", err);
15
+ if (!cancelled)
16
+ setLines(toPlainLines(code));
17
+ });
18
+ return () => {
19
+ cancelled = true;
20
+ };
21
+ }, [code, language, theme]);
22
+ return (_jsx("codeblock", { ...rest, lines: lines, lineNumbers: lineNumbers, padding: padding, background: background }));
23
+ }
24
+ //# sourceMappingURL=codeblock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codeblock.js","sourceRoot":"","sources":["../../src/codeblock.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAE3C,OAAO,EAAE,aAAa,EAAE,YAAY,EAAsB,MAAM,gBAAgB,CAAA;AAShF,MAAM,UAAU,SAAS,CAAC,EACxB,IAAI,EACJ,QAAQ,GAAG,IAAI,EACf,KAAK,GAAG,MAAM,EACd,WAAW,GAAG,IAAI,EAClB,OAAO,GAAG,CAAC,EACX,UAAU,EACV,GAAG,IAAI,EACQ;IACf,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAkB,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAA;IAE7E,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,SAAS,GAAG,KAAK,CAAA;QACrB,aAAa,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;aAC3C,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;YACf,IAAI,CAAC,SAAS;gBAAE,QAAQ,CAAC,MAAM,CAAC,CAAA;QAClC,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;YACb,OAAO,CAAC,IAAI,CAAC,4DAA4D,EAAE,GAAG,CAAC,CAAA;YAC/E,IAAI,CAAC,SAAS;gBAAE,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAA;QAC9C,CAAC,CAAC,CAAA;QACJ,OAAO,GAAG,EAAE;YACV,SAAS,GAAG,IAAI,CAAA;QAClB,CAAC,CAAA;IACH,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAA;IAE3B,OAAO,CACL,uBACO,IAAgC,EACrC,KAAK,EAAE,KAAK,EACZ,WAAW,EAAE,WAAsB,EACnC,OAAO,EAAE,OAAwC,EACjD,UAAU,EAAE,UAA8C,GAC1D,CACH,CAAA;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ /** Default frames per second for renderer and animation loops */
2
+ export declare const DEFAULT_FPS = 60;
3
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,eAAO,MAAM,WAAW,KAAK,CAAA"}
@@ -0,0 +1,3 @@
1
+ /** Default frames per second for renderer and animation loops */
2
+ export const DEFAULT_FPS = 60;
3
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,MAAM,CAAC,MAAM,WAAW,GAAG,EAAE,CAAA"}
@@ -0,0 +1,7 @@
1
+ import "../jsx.js";
2
+ export interface DiagnosticsPanelProps {
3
+ sampleMs?: number;
4
+ title?: string;
5
+ }
6
+ export declare function DiagnosticsPanel({ sampleMs, title }: DiagnosticsPanelProps): import("react").ReactNode;
7
+ //# sourceMappingURL=DiagnosticsPanel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DiagnosticsPanel.d.ts","sourceRoot":"","sources":["../../../src/debug/DiagnosticsPanel.tsx"],"names":[],"mappings":"AAEA,OAAO,WAAW,CAAA;AAElB,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,wBAAgB,gBAAgB,CAAC,EAAE,QAAc,EAAE,KAAqB,EAAE,EAAE,qBAAqB,6BA4BhG"}
@@ -0,0 +1,13 @@
1
+ import { jsxs as _jsxs, Fragment as _Fragment, jsx as _jsx } from "@effect-tui/react/jsx-runtime";
2
+ import { Colors } from "@effect-tui/core";
3
+ import { useFrameStats } from "../hooks/useFrameStats.js";
4
+ import "../jsx.js";
5
+ export function DiagnosticsPanel({ sampleMs = 200, title = "Diagnostics" }) {
6
+ const stats = useFrameStats(sampleMs);
7
+ const fps = stats ? (stats.frameMs > 0 ? (1000 / stats.frameMs).toFixed(1) : "∞") : "—";
8
+ const bytes = stats ? stats.bytes : 0;
9
+ const h = stats ? stats.contentHeight : 0;
10
+ const phases = stats?.phases;
11
+ return (_jsxs("vstack", { spacing: 1, children: [_jsxs("text", { fg: Colors.cyan, bold: true, children: [title, " (", stats?.mode ?? "?", ")"] }), stats ? (_jsxs(_Fragment, { children: [_jsxs("text", { fg: Colors.gray(12), children: ["size ", stats.width, "\u00D7", stats.height, " content ", h, " rows \u2014 ", bytes, " bytes/frame \u2014 ", fps, " fps"] }), _jsxs("text", { fg: Colors.gray(12), children: ["clear ", phases?.clear.toFixed(2), "ms \u00B7 layout ", phases?.layout.toFixed(2), "ms \u00B7 render", " ", phases?.render.toFixed(2), "ms \u00B7 diff ", phases?.diffAnsi.toFixed(2), "ms \u00B7 write ", phases?.write.toFixed(2), "ms"] })] })) : (_jsx("text", { fg: Colors.gray(10), children: "Waiting for first frame\u2026" }))] }));
12
+ }
13
+ //# sourceMappingURL=DiagnosticsPanel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DiagnosticsPanel.js","sourceRoot":"","sources":["../../../src/debug/DiagnosticsPanel.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AACzD,OAAO,WAAW,CAAA;AAOlB,MAAM,UAAU,gBAAgB,CAAC,EAAE,QAAQ,GAAG,GAAG,EAAE,KAAK,GAAG,aAAa,EAAyB;IAC/F,MAAM,KAAK,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAA;IAErC,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAA;IACvF,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;IACrC,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAA;IACzC,MAAM,MAAM,GAAG,KAAK,EAAE,MAAM,CAAA;IAE5B,OAAO,CACL,kBAAQ,OAAO,EAAE,CAAC,aAChB,gBAAM,EAAE,EAAE,MAAM,CAAC,IAAI,EAAE,IAAI,mBACxB,KAAK,QAAI,KAAK,EAAE,IAAI,IAAI,GAAG,SACvB,EACN,KAAK,CAAC,CAAC,CAAC,CACP,8BACE,gBAAM,EAAE,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,sBACjB,KAAK,CAAC,KAAK,YAAG,KAAK,CAAC,MAAM,eAAW,CAAC,mBAAU,KAAK,0BAAiB,GAAG,YAC1E,EACP,gBAAM,EAAE,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,uBAChB,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,uBAAc,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,sBAAa,GAAG,EACrF,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,qBAAY,MAAM,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,sBAAa,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,UACjG,IACN,CACJ,CAAC,CAAC,CAAC,CACF,eAAM,EAAE,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,8CAAiC,CAC3D,IACM,CACV,CAAA;AACH,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { type BundledLanguage, type BundledTheme } from "shiki";
2
+ import type { ColorLike } from "@effect-tui/core";
3
+ export interface HighlightTokenStyle {
4
+ fg?: ColorLike;
5
+ bg?: ColorLike;
6
+ bold?: boolean;
7
+ italic?: boolean;
8
+ underline?: boolean;
9
+ }
10
+ export interface HighlightToken {
11
+ text: string;
12
+ style?: HighlightTokenStyle;
13
+ }
14
+ export type HighlightLine = HighlightToken[];
15
+ export declare function highlightCode(code: string, opts?: {
16
+ lang?: BundledLanguage;
17
+ theme?: BundledTheme;
18
+ }): Promise<HighlightLine[]>;
19
+ export declare function toPlainLines(code: string): HighlightLine[];
20
+ //# sourceMappingURL=highlight.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"highlight.d.ts","sourceRoot":"","sources":["../../src/highlight.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuC,KAAK,eAAe,EAAE,KAAK,YAAY,EAAE,MAAM,OAAO,CAAA;AACpG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAEjD,MAAM,WAAW,mBAAmB;IAClC,EAAE,CAAC,EAAE,SAAS,CAAA;IACd,EAAE,CAAC,EAAE,SAAS,CAAA;IACd,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,mBAAmB,CAAA;CAC5B;AAED,MAAM,MAAM,aAAa,GAAG,cAAc,EAAE,CAAA;AAoB5C,wBAAsB,aAAa,CACjC,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE;IAAE,IAAI,CAAC,EAAE,eAAe,CAAC;IAAC,KAAK,CAAC,EAAE,YAAY,CAAA;CAAE,GACtD,OAAO,CAAC,aAAa,EAAE,CAAC,CA+B1B;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,EAAE,CAG1D"}
@@ -0,0 +1,51 @@
1
+ import { createHighlighter } from "shiki";
2
+ const DEFAULT_LANGS = ["ts", "tsx", "js", "jsx", "json"];
3
+ const DEFAULT_THEME = "nord";
4
+ const highlighterCache = new Map();
5
+ async function getCachedHighlighter(theme) {
6
+ const key = String(theme);
7
+ let cached = highlighterCache.get(key);
8
+ if (!cached) {
9
+ cached = createHighlighter({
10
+ themes: [theme],
11
+ langs: DEFAULT_LANGS,
12
+ });
13
+ highlighterCache.set(key, cached);
14
+ }
15
+ return cached;
16
+ }
17
+ export async function highlightCode(code, opts) {
18
+ const lang = opts?.lang ?? "ts";
19
+ const theme = opts?.theme ?? DEFAULT_THEME;
20
+ const highlighter = await getCachedHighlighter(theme);
21
+ if (!highlighter.getLoadedLanguages().includes(lang)) {
22
+ await highlighter.loadLanguage(lang);
23
+ }
24
+ const tokensResult = await highlighter.codeToTokens(code, { lang, theme });
25
+ const tokenLines = Array.isArray(tokensResult)
26
+ ? tokensResult
27
+ : // Shiki v3 returns { tokens, theme }
28
+ tokensResult.tokens;
29
+ if (!Array.isArray(tokenLines))
30
+ return toPlainLines(code);
31
+ return tokenLines.map((line) => line.map((token) => {
32
+ const style = {};
33
+ if (token.color)
34
+ style.fg = token.color;
35
+ const fs = token.fontStyle ?? 0;
36
+ // fontStyle bitmask is: 1 = Italic, 2 = Bold, 4 = Underline
37
+ if (fs & 2)
38
+ style.bold = true;
39
+ if (fs & 1)
40
+ style.italic = true;
41
+ if (fs & 4)
42
+ style.underline = true;
43
+ return Object.keys(style).length > 0 ? { text: token.content, style } : { text: token.content };
44
+ }));
45
+ }
46
+ export function toPlainLines(code) {
47
+ if (code.length === 0)
48
+ return [[]];
49
+ return code.split(/\r?\n/).map((line) => [{ text: line }]);
50
+ }
51
+ //# sourceMappingURL=highlight.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"highlight.js","sourceRoot":"","sources":["../../src/highlight.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,4 @@
1
+ export { useKeyboard } from "./use-keyboard.js";
2
+ export type { UseKeyboardOptions } from "./use-keyboard.js";
3
+ export { usePaste } from "./use-paste.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,YAAY,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA"}
@@ -0,0 +1,3 @@
1
+ export { useKeyboard } from "./use-keyboard.js";
2
+ export { usePaste } from "./use-paste.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAE/C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA"}
@@ -0,0 +1,18 @@
1
+ import type { KeyMsg } from "@effect-tui/core";
2
+ export type UseKeyboardOptions = {
3
+ /** Which phase to listen for; defaults to "press" and treats missing phase as "press". */
4
+ phase?: "press" | "repeat" | "release" | "any";
5
+ /** Optional predicate to drop keys before they reach the handler. */
6
+ filter?: (key: KeyMsg) => boolean;
7
+ /**
8
+ * If true, call preventDefault when available before invoking handler.
9
+ * This stops further renderer-level handlers (not a terminal effect).
10
+ */
11
+ stopPropagation?: boolean;
12
+ };
13
+ /**
14
+ * Subscribe to keyboard events.
15
+ * Handler is called for every key press while mounted.
16
+ */
17
+ export declare function useKeyboard(handler: (key: KeyMsg) => void, opts?: UseKeyboardOptions): void;
18
+ //# sourceMappingURL=use-keyboard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-keyboard.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-keyboard.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAG9C,MAAM,MAAM,kBAAkB,GAAG;IAC/B,0FAA0F;IAC1F,KAAK,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,SAAS,GAAG,KAAK,CAAA;IAC9C,qEAAqE;IACrE,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAA;IACjC;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;CAC1B,CAAA;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,EAAE,IAAI,CAAC,EAAE,kBAAkB,GAAG,IAAI,CAgB3F"}
@@ -0,0 +1,26 @@
1
+ import { useEffect } from "react";
2
+ import { useRenderer } from "../renderer.js";
3
+ /**
4
+ * Subscribe to keyboard events.
5
+ * Handler is called for every key press while mounted.
6
+ */
7
+ export function useKeyboard(handler, opts) {
8
+ const renderer = useRenderer();
9
+ const phase = opts?.phase ?? "press";
10
+ const filter = opts?.filter;
11
+ const stopPropagation = opts?.stopPropagation ?? false;
12
+ useEffect(() => {
13
+ const wrapped = (key) => {
14
+ const keyPhase = key.phase ?? "press";
15
+ if (phase !== "any" && phase !== keyPhase)
16
+ return;
17
+ if (filter && !filter(key))
18
+ return;
19
+ if (stopPropagation && key.preventDefault)
20
+ key.preventDefault();
21
+ handler(key);
22
+ };
23
+ return renderer.onKey(wrapped);
24
+ }, [renderer, handler, phase, filter, stopPropagation]);
25
+ }
26
+ //# sourceMappingURL=use-keyboard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-keyboard.js","sourceRoot":"","sources":["../../../src/hooks/use-keyboard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEjC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAc5C;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,OAA8B,EAAE,IAAyB;IACnF,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAA;IAC9B,MAAM,KAAK,GAAG,IAAI,EAAE,KAAK,IAAI,OAAO,CAAA;IACpC,MAAM,MAAM,GAAG,IAAI,EAAE,MAAM,CAAA;IAC3B,MAAM,eAAe,GAAG,IAAI,EAAE,eAAe,IAAI,KAAK,CAAA;IAEtD,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,OAAO,GAAG,CAAC,GAAW,EAAE,EAAE;YAC9B,MAAM,QAAQ,GAAG,GAAG,CAAC,KAAK,IAAI,OAAO,CAAA;YACrC,IAAI,KAAK,KAAK,KAAK,IAAI,KAAK,KAAK,QAAQ;gBAAE,OAAM;YACjD,IAAI,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC;gBAAE,OAAM;YAClC,IAAI,eAAe,IAAI,GAAG,CAAC,cAAc;gBAAE,GAAG,CAAC,cAAc,EAAE,CAAA;YAC/D,OAAO,CAAC,GAAG,CAAC,CAAA;QACd,CAAC,CAAA;QACD,OAAO,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;IAChC,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,eAAe,CAAC,CAAC,CAAA;AACzD,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Subscribe to bracketed paste events (if supported by renderer/terminal).
3
+ */
4
+ export declare function usePaste(handler: (text: string) => void): void;
5
+ //# sourceMappingURL=use-paste.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-paste.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-paste.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAAG,IAAI,CAO9D"}
@@ -0,0 +1,14 @@
1
+ import { useEffect } from "react";
2
+ import { useRenderer } from "../renderer.js";
3
+ /**
4
+ * Subscribe to bracketed paste events (if supported by renderer/terminal).
5
+ */
6
+ export function usePaste(handler) {
7
+ const renderer = useRenderer();
8
+ useEffect(() => {
9
+ if (!renderer.onPaste)
10
+ return;
11
+ return renderer.onPaste(handler);
12
+ }, [renderer, handler]);
13
+ }
14
+ //# sourceMappingURL=use-paste.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-paste.js","sourceRoot":"","sources":["../../../src/hooks/use-paste.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAE5C;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAC,OAA+B;IACtD,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAA;IAE9B,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,QAAQ,CAAC,OAAO;YAAE,OAAM;QAC7B,OAAO,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IAClC,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAA;AACzB,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { FrameStats } from "../renderer.js";
2
+ /**
3
+ * Subscribe to per-frame renderer stats (if enabled).
4
+ * Falls back to null when the renderer does not support onFrameStats.
5
+ */
6
+ export declare function useFrameStats(sampleMs?: number): FrameStats | null;
7
+ //# sourceMappingURL=useFrameStats.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFrameStats.d.ts","sourceRoot":"","sources":["../../../src/hooks/useFrameStats.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAEhD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,QAAQ,SAAM,GAAG,UAAU,GAAG,IAAI,CAuB/D"}
@@ -0,0 +1,28 @@
1
+ import { useEffect, useState } from "react";
2
+ import { useRenderer } from "../renderer.js";
3
+ /**
4
+ * Subscribe to per-frame renderer stats (if enabled).
5
+ * Falls back to null when the renderer does not support onFrameStats.
6
+ */
7
+ export function useFrameStats(sampleMs = 200) {
8
+ const renderer = useRenderer();
9
+ const [stats, setStats] = useState(null);
10
+ useEffect(() => {
11
+ if (!renderer.onFrameStats)
12
+ return;
13
+ let last = null;
14
+ const unsub = renderer.onFrameStats((s) => {
15
+ last = s;
16
+ });
17
+ const id = setInterval(() => {
18
+ if (last)
19
+ setStats(last);
20
+ }, sampleMs);
21
+ return () => {
22
+ clearInterval(id);
23
+ unsub?.();
24
+ };
25
+ }, [renderer, sampleMs]);
26
+ return stats;
27
+ }
28
+ //# sourceMappingURL=useFrameStats.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFrameStats.js","sourceRoot":"","sources":["../../../src/hooks/useFrameStats.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAG5C;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,QAAQ,GAAG,GAAG;IAC1C,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAA;IAC9B,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAoB,IAAI,CAAC,CAAA;IAE3D,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,QAAQ,CAAC,YAAY;YAAE,OAAM;QAElC,IAAI,IAAI,GAAsB,IAAI,CAAA;QAClC,MAAM,KAAK,GAAG,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,EAAE;YACxC,IAAI,GAAG,CAAC,CAAA;QACV,CAAC,CAAC,CAAA;QAEF,MAAM,EAAE,GAAG,WAAW,CAAC,GAAG,EAAE;YAC1B,IAAI,IAAI;gBAAE,QAAQ,CAAC,IAAI,CAAC,CAAA;QAC1B,CAAC,EAAE,QAAQ,CAAC,CAAA;QAEZ,OAAO,GAAG,EAAE;YACV,aAAa,CAAC,EAAE,CAAC,CAAA;YACjB,KAAK,EAAE,EAAE,CAAA;QACX,CAAC,CAAA;IACH,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAA;IAExB,OAAO,KAAK,CAAA;AACd,CAAC"}
@@ -0,0 +1,22 @@
1
+ import type { CellBuffer, Palette } from "@effect-tui/core";
2
+ import type { HostInstance, Rect, Size, HostContext, CommonProps } from "../reconciler/types.js";
3
+ export declare abstract class BaseHost implements HostInstance {
4
+ id: string;
5
+ type: string;
6
+ parent: HostInstance | null;
7
+ children: HostInstance[];
8
+ rect: Rect | null;
9
+ flexGrow: number;
10
+ flexShrink: number;
11
+ protected ctx: HostContext;
12
+ constructor(type: string, props: CommonProps, ctx: HostContext);
13
+ abstract measure(maxW: number, maxH: number): Size;
14
+ abstract render(buffer: CellBuffer, palette: Palette): void;
15
+ layout(rect: Rect): void;
16
+ updateProps(props: Record<string, unknown>): void;
17
+ destroy(): void;
18
+ appendChild(child: HostInstance): void;
19
+ removeChild(child: HostInstance): void;
20
+ insertBefore(child: HostInstance, before: HostInstance): void;
21
+ }
22
+ //# sourceMappingURL=base.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/hosts/base.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAIhG,8BAAsB,QAAS,YAAW,YAAY;IACpD,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,YAAY,GAAG,IAAI,CAAO;IAClC,QAAQ,EAAE,YAAY,EAAE,CAAK;IAC7B,IAAI,EAAE,IAAI,GAAG,IAAI,CAAO;IAGxB,QAAQ,SAAI;IACZ,UAAU,SAAI;IAEd,SAAS,CAAC,GAAG,EAAE,WAAW,CAAA;gBAEd,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,WAAW;IAO9D,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;IAClD,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI;IAE3D,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;IAIxB,WAAW,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAKjD,OAAO,IAAI,IAAI;IAKf,WAAW,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI;IAKtC,WAAW,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI;IAQtC,YAAY,CAAC,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI;CAS9D"}