@mdxui/terminal 2.0.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 (191) hide show
  1. package/README.md +571 -0
  2. package/dist/ansi-css-Sk5mWtdK.d.ts +119 -0
  3. package/dist/ansi-css-V6JIHGsM.d.ts +119 -0
  4. package/dist/ansi-css-_3eSEU9d.d.ts +119 -0
  5. package/dist/chunk-3EFDH7PK.js +5235 -0
  6. package/dist/chunk-3RG5ZIWI.js +10 -0
  7. package/dist/chunk-3X5IR6WE.js +884 -0
  8. package/dist/chunk-4FV5ZDCE.js +5236 -0
  9. package/dist/chunk-4OVMSF2J.js +243 -0
  10. package/dist/chunk-63FEETIS.js +4048 -0
  11. package/dist/chunk-B43KP7XJ.js +884 -0
  12. package/dist/chunk-BMTJXWUV.js +655 -0
  13. package/dist/chunk-C3SVH4N7.js +882 -0
  14. package/dist/chunk-EVWR7Y47.js +874 -0
  15. package/dist/chunk-F6A5VWUC.js +1285 -0
  16. package/dist/chunk-FD7KW7GE.js +882 -0
  17. package/dist/chunk-GBQ6UD6I.js +655 -0
  18. package/dist/chunk-GMDD3M6U.js +5227 -0
  19. package/dist/chunk-JBHRXOXM.js +1058 -0
  20. package/dist/chunk-JFOO3EYO.js +1182 -0
  21. package/dist/chunk-JQ5H3WXL.js +1291 -0
  22. package/dist/chunk-JQD5NASE.js +234 -0
  23. package/dist/chunk-KRHJP5R7.js +592 -0
  24. package/dist/chunk-KWF6WVJE.js +962 -0
  25. package/dist/chunk-LHYQVN3H.js +1038 -0
  26. package/dist/chunk-M3TLQLGC.js +1032 -0
  27. package/dist/chunk-MVW4Q5OP.js +240 -0
  28. package/dist/chunk-NXCZSWLU.js +1294 -0
  29. package/dist/chunk-O25TNRO6.js +607 -0
  30. package/dist/chunk-PNECDA2I.js +884 -0
  31. package/dist/chunk-QIHWRLJR.js +962 -0
  32. package/dist/chunk-QW5YMQ7K.js +882 -0
  33. package/dist/chunk-R5U7XKVJ.js +16 -0
  34. package/dist/chunk-RP2MVQLR.js +962 -0
  35. package/dist/chunk-TP6RXGXA.js +1087 -0
  36. package/dist/chunk-TQQSTITZ.js +655 -0
  37. package/dist/chunk-X24GWXQV.js +1281 -0
  38. package/dist/components/index.d.ts +802 -0
  39. package/dist/components/index.js +149 -0
  40. package/dist/data/index.d.ts +2554 -0
  41. package/dist/data/index.js +51 -0
  42. package/dist/forms/index.d.ts +1596 -0
  43. package/dist/forms/index.js +464 -0
  44. package/dist/index-CQRFZntR.d.ts +867 -0
  45. package/dist/index.d.ts +579 -0
  46. package/dist/index.js +786 -0
  47. package/dist/interactive-D0JkWosD.d.ts +217 -0
  48. package/dist/keyboard/index.d.ts +2 -0
  49. package/dist/keyboard/index.js +43 -0
  50. package/dist/renderers/index.d.ts +546 -0
  51. package/dist/renderers/index.js +2157 -0
  52. package/dist/storybook/index.d.ts +396 -0
  53. package/dist/storybook/index.js +641 -0
  54. package/dist/theme/index.d.ts +1339 -0
  55. package/dist/theme/index.js +123 -0
  56. package/dist/types-Bxu5PAgA.d.ts +710 -0
  57. package/dist/types-CIlop5Ji.d.ts +701 -0
  58. package/dist/types-Ca8p_p5X.d.ts +710 -0
  59. package/package.json +90 -0
  60. package/src/__tests__/components/data/card.test.ts +458 -0
  61. package/src/__tests__/components/data/list.test.ts +473 -0
  62. package/src/__tests__/components/data/metrics.test.ts +541 -0
  63. package/src/__tests__/components/data/table.test.ts +448 -0
  64. package/src/__tests__/components/input/field.test.ts +555 -0
  65. package/src/__tests__/components/input/form.test.ts +870 -0
  66. package/src/__tests__/components/input/search.test.ts +1238 -0
  67. package/src/__tests__/components/input/select.test.ts +658 -0
  68. package/src/__tests__/components/navigation/breadcrumb.test.ts +923 -0
  69. package/src/__tests__/components/navigation/command-palette.test.ts +1095 -0
  70. package/src/__tests__/components/navigation/sidebar.test.ts +1018 -0
  71. package/src/__tests__/components/navigation/tabs.test.ts +995 -0
  72. package/src/__tests__/components.test.tsx +1197 -0
  73. package/src/__tests__/core/compiler.test.ts +986 -0
  74. package/src/__tests__/core/parser.test.ts +785 -0
  75. package/src/__tests__/core/tier-switcher.test.ts +1103 -0
  76. package/src/__tests__/core/types.test.ts +1398 -0
  77. package/src/__tests__/data/collections.test.ts +1337 -0
  78. package/src/__tests__/data/db.test.ts +1265 -0
  79. package/src/__tests__/data/reactive.test.ts +1010 -0
  80. package/src/__tests__/data/sync.test.ts +1614 -0
  81. package/src/__tests__/errors.test.ts +660 -0
  82. package/src/__tests__/forms/integration.test.ts +444 -0
  83. package/src/__tests__/integration.test.ts +905 -0
  84. package/src/__tests__/keyboard.test.ts +1791 -0
  85. package/src/__tests__/renderer.test.ts +489 -0
  86. package/src/__tests__/renderers/ansi-css.test.ts +948 -0
  87. package/src/__tests__/renderers/ansi.test.ts +1366 -0
  88. package/src/__tests__/renderers/ascii.test.ts +1360 -0
  89. package/src/__tests__/renderers/interactive.test.ts +2353 -0
  90. package/src/__tests__/renderers/markdown.test.ts +1483 -0
  91. package/src/__tests__/renderers/text.test.ts +1369 -0
  92. package/src/__tests__/renderers/unicode.test.ts +1307 -0
  93. package/src/__tests__/theme.test.ts +639 -0
  94. package/src/__tests__/utils/assertions.ts +685 -0
  95. package/src/__tests__/utils/index.ts +115 -0
  96. package/src/__tests__/utils/test-renderer.ts +381 -0
  97. package/src/__tests__/utils/utils.test.ts +560 -0
  98. package/src/components/containers/card.ts +56 -0
  99. package/src/components/containers/dialog.ts +53 -0
  100. package/src/components/containers/index.ts +9 -0
  101. package/src/components/containers/panel.ts +59 -0
  102. package/src/components/feedback/badge.ts +40 -0
  103. package/src/components/feedback/index.ts +8 -0
  104. package/src/components/feedback/spinner.ts +23 -0
  105. package/src/components/helpers.ts +81 -0
  106. package/src/components/index.ts +153 -0
  107. package/src/components/layout/breadcrumb.ts +31 -0
  108. package/src/components/layout/index.ts +10 -0
  109. package/src/components/layout/list.ts +29 -0
  110. package/src/components/layout/sidebar.ts +79 -0
  111. package/src/components/layout/table.ts +62 -0
  112. package/src/components/primitives/box.ts +95 -0
  113. package/src/components/primitives/button.ts +54 -0
  114. package/src/components/primitives/index.ts +11 -0
  115. package/src/components/primitives/input.ts +88 -0
  116. package/src/components/primitives/select.ts +97 -0
  117. package/src/components/primitives/text.ts +60 -0
  118. package/src/components/render.ts +155 -0
  119. package/src/components/templates/app.ts +43 -0
  120. package/src/components/templates/index.ts +8 -0
  121. package/src/components/templates/site.ts +54 -0
  122. package/src/components/types.ts +777 -0
  123. package/src/core/compiler.ts +718 -0
  124. package/src/core/parser.ts +127 -0
  125. package/src/core/tier-switcher.ts +607 -0
  126. package/src/core/types.ts +672 -0
  127. package/src/data/collection.ts +316 -0
  128. package/src/data/collections.ts +50 -0
  129. package/src/data/context.tsx +174 -0
  130. package/src/data/db.ts +127 -0
  131. package/src/data/hooks.ts +532 -0
  132. package/src/data/index.ts +138 -0
  133. package/src/data/reactive.ts +1225 -0
  134. package/src/data/saas-collections.ts +375 -0
  135. package/src/data/sync.ts +1213 -0
  136. package/src/data/types.ts +660 -0
  137. package/src/forms/converters.ts +512 -0
  138. package/src/forms/index.ts +133 -0
  139. package/src/forms/schemas.ts +403 -0
  140. package/src/forms/types.ts +476 -0
  141. package/src/index.ts +542 -0
  142. package/src/keyboard/focus.ts +748 -0
  143. package/src/keyboard/index.ts +96 -0
  144. package/src/keyboard/integration.ts +371 -0
  145. package/src/keyboard/manager.ts +377 -0
  146. package/src/keyboard/presets.ts +90 -0
  147. package/src/renderers/ansi-css.ts +576 -0
  148. package/src/renderers/ansi.ts +802 -0
  149. package/src/renderers/ascii.ts +680 -0
  150. package/src/renderers/breadcrumb.ts +480 -0
  151. package/src/renderers/command-palette.ts +802 -0
  152. package/src/renderers/components/field.ts +210 -0
  153. package/src/renderers/components/form.ts +327 -0
  154. package/src/renderers/components/index.ts +21 -0
  155. package/src/renderers/components/search.ts +449 -0
  156. package/src/renderers/components/select.ts +222 -0
  157. package/src/renderers/index.ts +101 -0
  158. package/src/renderers/interactive/component-handlers.ts +622 -0
  159. package/src/renderers/interactive/cursor-manager.ts +147 -0
  160. package/src/renderers/interactive/focus-manager.ts +279 -0
  161. package/src/renderers/interactive/index.ts +661 -0
  162. package/src/renderers/interactive/input-handler.ts +164 -0
  163. package/src/renderers/interactive/keyboard-handler.ts +212 -0
  164. package/src/renderers/interactive/mouse-handler.ts +167 -0
  165. package/src/renderers/interactive/state-manager.ts +109 -0
  166. package/src/renderers/interactive/types.ts +338 -0
  167. package/src/renderers/interactive-string.ts +299 -0
  168. package/src/renderers/interactive.ts +59 -0
  169. package/src/renderers/markdown.ts +950 -0
  170. package/src/renderers/sidebar.ts +549 -0
  171. package/src/renderers/tabs.ts +682 -0
  172. package/src/renderers/text.ts +791 -0
  173. package/src/renderers/unicode.ts +917 -0
  174. package/src/renderers/utils.ts +942 -0
  175. package/src/router/adapters.ts +383 -0
  176. package/src/router/types.ts +140 -0
  177. package/src/router/utils.ts +452 -0
  178. package/src/schemas.ts +205 -0
  179. package/src/storybook/index.ts +91 -0
  180. package/src/storybook/interactive-decorator.tsx +659 -0
  181. package/src/storybook/keyboard-simulator.ts +501 -0
  182. package/src/theme/ansi-codes.ts +80 -0
  183. package/src/theme/box-drawing.ts +132 -0
  184. package/src/theme/color-convert.ts +254 -0
  185. package/src/theme/color-support.ts +321 -0
  186. package/src/theme/index.ts +134 -0
  187. package/src/theme/strip-ansi.ts +50 -0
  188. package/src/theme/tailwind-map.ts +469 -0
  189. package/src/theme/text-styles.ts +206 -0
  190. package/src/theme/theme-system.ts +568 -0
  191. package/src/types.ts +103 -0
@@ -0,0 +1,710 @@
1
+ import { z } from 'zod';
2
+
3
+ /**
4
+ * @mdxui/terminal UINode Type System
5
+ *
6
+ * Core type definitions and Zod schemas for the Universal Terminal UI's
7
+ * multi-tier rendering architecture.
8
+ */
9
+
10
+ /**
11
+ * UINode - The fundamental building block of the terminal UI tree.
12
+ *
13
+ * Represents a component with type, props, optional children, data, and key.
14
+ * This is the core abstraction that allows universal rendering across different
15
+ * output tiers (text, markdown, ascii, unicode, ansi, interactive).
16
+ *
17
+ * @remarks
18
+ * UINode follows a tree-based component model similar to React:
19
+ * - Each node has a `type` that identifies the component (e.g., 'box', 'text', 'panel')
20
+ * - Props are passed as a generic key-value record
21
+ * - Children can be nested to arbitrary depth
22
+ * - Optional `data` field can hold query results for data-driven components
23
+ * - Optional `key` field helps with list reconciliation
24
+ *
25
+ * @example
26
+ * Simple text node:
27
+ * ```tsx
28
+ * const node: UINode = {
29
+ * type: 'text',
30
+ * props: { content: 'Hello, World!' }
31
+ * }
32
+ * ```
33
+ *
34
+ * @example
35
+ * Nested structure with children:
36
+ * ```tsx
37
+ * const node: UINode = {
38
+ * type: 'box',
39
+ * props: { padding: 2, border: 'rounded' },
40
+ * children: [
41
+ * { type: 'text', props: { content: 'Title' } },
42
+ * { type: 'text', props: { content: 'Subtitle' } }
43
+ * ]
44
+ * }
45
+ * ```
46
+ *
47
+ * @example
48
+ * Data-driven component:
49
+ * ```tsx
50
+ * const node: UINode = {
51
+ * type: 'table',
52
+ * props: { headers: ['Name', 'Age'] },
53
+ * data: [
54
+ * { name: 'Alice', age: 30 },
55
+ * { name: 'Bob', age: 28 }
56
+ * ]
57
+ * }
58
+ * ```
59
+ */
60
+ interface UINode {
61
+ /**
62
+ * Component type identifier
63
+ * @remarks
64
+ * String that identifies the component type. Common examples: 'text', 'box', 'panel',
65
+ * 'table', 'list', 'button'. Custom component types are supported.
66
+ */
67
+ type: string;
68
+ /**
69
+ * Component props as a generic record
70
+ * @remarks
71
+ * Props are component-specific configuration. All values must be serializable
72
+ * for cross-tier rendering. Examples:
73
+ * - { content: 'text content' }
74
+ * - { padding: 2, border: 'single' }
75
+ * - { columns: ['Name', 'Email'] }
76
+ */
77
+ props?: Record<string, unknown>;
78
+ /**
79
+ * Optional child UINodes or string content for nested components
80
+ * @remarks
81
+ * Children are rendered as the component's content. Nested to arbitrary depth.
82
+ * Can be an array of UINode objects or a direct string for simple text content.
83
+ * Undefined if the component has no children.
84
+ */
85
+ children?: UINode[] | string;
86
+ /**
87
+ * Optional shorthand for text content
88
+ * @remarks
89
+ * Convenience property for setting text content directly on a node without
90
+ * using props.content. Commonly used for simple text nodes.
91
+ * Example: { type: 'text', text: 'Hello World' }
92
+ */
93
+ text?: string;
94
+ /**
95
+ * Optional bound query data for data-driven components
96
+ * @remarks
97
+ * Used for components that render arrays of items (tables, lists, grids).
98
+ * The data can be any shape; the component implementation defines how to use it.
99
+ * Examples: array of records, nested objects, primitive values.
100
+ */
101
+ data?: unknown;
102
+ /**
103
+ * Optional key for React-style reconciliation
104
+ * @remarks
105
+ * Used in lists to maintain identity across renders. If a node's key changes,
106
+ * the component is recreated. Useful for preserving component state.
107
+ * Should be stable across renders for the same logical item.
108
+ */
109
+ key?: string;
110
+ }
111
+ /**
112
+ * RenderTier - Defines the capability level for rendering output.
113
+ *
114
+ * Tiers are ordered by increasing capability:
115
+ * `text` < `markdown` < `ascii` < `unicode` < `ansi` < `interactive`
116
+ *
117
+ * Each tier builds on the previous one, enabling progressively richer
118
+ * terminal output while maintaining backward compatibility.
119
+ *
120
+ * @remarks
121
+ * **Tier Definitions:**
122
+ *
123
+ * - **text** - Plain text output without any formatting or special characters.
124
+ * No colors, no box drawing, no markdown. Useful for piping output or
125
+ * basic terminal environments with no formatting support.
126
+ * Example: `Hello World`
127
+ *
128
+ * - **markdown** - Text with Markdown syntax for basic formatting:
129
+ * **bold**, *italic*, `code`, links. No color support. Good for converting
130
+ * terminal output to documentation or emails.
131
+ * Example: `**Hello** _World_`
132
+ *
133
+ * - **ascii** - ASCII art characters (/, \, |, -, +, =) for drawing
134
+ * boxes, borders, and diagrams. No unicode box drawing characters.
135
+ * Broader terminal compatibility than unicode.
136
+ * Example: `+---+\n| A |\n+---+`
137
+ *
138
+ * - **unicode** - Unicode box drawing characters (┌, ─, │, └, etc.)
139
+ * for elegant borders and tables. Better appearance than ASCII but
140
+ * requires UTF-8 terminal support.
141
+ * Example: `┌───┐\n│ A │\n└───┘`
142
+ *
143
+ * - **ansi** - ANSI escape sequences for 256-color or truecolor output.
144
+ * Supports foreground/background colors, bold, underline, etc.
145
+ * Requires modern terminal supporting ANSI codes.
146
+ * Example: `\x1b[31mRed Text\x1b[0m`
147
+ *
148
+ * - **interactive** - Full interactive terminal UI with keyboard input,
149
+ * mouse events, and real-time updates. Requires a terminal library like
150
+ * Ink or Blessed. Most capable tier but requires active user interaction.
151
+ * Example: Menu navigation, live dashboards, text input.
152
+ *
153
+ * @example
154
+ * Checking tier capability:
155
+ * ```tsx
156
+ * const canUseColors = tier === 'ansi' || tier === 'interactive'
157
+ * const canUseUnicode = tier === 'unicode' || tier === 'ansi' || tier === 'interactive'
158
+ * const isPlainText = tier === 'text'
159
+ * ```
160
+ */
161
+ type RenderTier = 'text' | 'markdown' | 'ascii' | 'unicode' | 'ansi' | 'interactive';
162
+ /**
163
+ * ThemeTokens - Color tokens for theming terminal output.
164
+ *
165
+ * All tokens are strings containing ANSI escape sequences (or empty for text tier).
166
+ * This interface defines a complete semantic color palette for terminal applications.
167
+ *
168
+ * @remarks
169
+ * **Format and Values:**
170
+ * - For `text` tier: Empty string `''` (no color support)
171
+ * - For `markdown` tier: Empty string `''` (colors not supported in markdown)
172
+ * - For `ascii`/`unicode`/`ansi`/`interactive` tiers:
173
+ * ANSI escape sequences like `'\x1b[31m'` (red) or `'\x1b[1;32m'` (bold green)
174
+ *
175
+ * **Semantic Categories:**
176
+ * - **Primary/Secondary**: Brand colors for emphasis and hierarchy
177
+ * - **Foreground/Background**: Text and surface colors
178
+ * - **Status Colors**: Semantic meaning (green=success, red=error, yellow=warning, blue=info)
179
+ * - **Muted**: De-emphasized text (help text, secondary content)
180
+ * - **Border**: For drawing boxes and separators
181
+ *
182
+ * @example
183
+ * Light ANSI theme:
184
+ * ```tsx
185
+ * const lightTheme: ThemeTokens = {
186
+ * primary: '\x1b[34m', // Blue
187
+ * secondary: '\x1b[36m', // Cyan
188
+ * muted: '\x1b[90m', // Bright black
189
+ * foreground: '\x1b[37m', // White
190
+ * background: '\x1b[40m', // Black background
191
+ * border: '\x1b[90m', // Gray
192
+ * success: '\x1b[32m', // Green
193
+ * warning: '\x1b[33m', // Yellow
194
+ * error: '\x1b[31m', // Red
195
+ * info: '\x1b[34m', // Blue
196
+ * }
197
+ * ```
198
+ *
199
+ * @example
200
+ * Text tier (no colors):
201
+ * ```tsx
202
+ * const textTheme: ThemeTokens = {
203
+ * primary: '',
204
+ * secondary: '',
205
+ * muted: '',
206
+ * foreground: '',
207
+ * background: '',
208
+ * border: '',
209
+ * success: '',
210
+ * warning: '',
211
+ * error: '',
212
+ * info: '',
213
+ * }
214
+ * ```
215
+ */
216
+ interface ThemeTokens {
217
+ /**
218
+ * Primary brand color
219
+ * @remarks
220
+ * Used for primary CTAs, headings, and key UI elements.
221
+ * ANSI code string, empty for text/markdown tiers.
222
+ */
223
+ primary: string;
224
+ /**
225
+ * Secondary accent color
226
+ * @remarks
227
+ * Used for secondary actions and accents.
228
+ * ANSI code string, empty for text/markdown tiers.
229
+ */
230
+ secondary: string;
231
+ /**
232
+ * Muted/dimmed text color
233
+ * @remarks
234
+ * Used for helper text, secondary content, disabled states.
235
+ * Lower contrast than foreground color.
236
+ * ANSI code string, empty for text/markdown tiers.
237
+ */
238
+ muted: string;
239
+ /**
240
+ * Default foreground text color
241
+ * @remarks
242
+ * Primary text color for body content and labels.
243
+ * Should have high contrast with background.
244
+ * ANSI code string, empty for text/markdown tiers.
245
+ */
246
+ foreground: string;
247
+ /**
248
+ * Background color
249
+ * @remarks
250
+ * Used for panels, boxes, and background surfaces.
251
+ * Should contrast well with foreground for readability.
252
+ * ANSI code string, empty for text/markdown tiers.
253
+ */
254
+ background: string;
255
+ /**
256
+ * Border/separator color
257
+ * @remarks
258
+ * Used for drawing borders, dividers, and separators.
259
+ * Often same as muted for subtle appearance.
260
+ * ANSI code string, empty for text/markdown tiers.
261
+ */
262
+ border: string;
263
+ /**
264
+ * Success state color (typically green)
265
+ * @remarks
266
+ * Used for success messages, checkmarks, confirmations.
267
+ * Semantic meaning: positive outcome, success state.
268
+ * ANSI code string, empty for text/markdown tiers.
269
+ */
270
+ success: string;
271
+ /**
272
+ * Warning state color (typically yellow/orange)
273
+ * @remarks
274
+ * Used for warnings, alerts, caution messages.
275
+ * Semantic meaning: attention needed, non-critical issue.
276
+ * ANSI code string, empty for text/markdown tiers.
277
+ */
278
+ warning: string;
279
+ /**
280
+ * Error state color (typically red)
281
+ * @remarks
282
+ * Used for errors, failures, destructive actions.
283
+ * Semantic meaning: critical issue, failure state.
284
+ * ANSI code string, empty for text/markdown tiers.
285
+ */
286
+ error: string;
287
+ /**
288
+ * Info state color (typically blue)
289
+ * @remarks
290
+ * Used for information, hints, explanatory messages.
291
+ * Semantic meaning: additional context, non-critical info.
292
+ * ANSI code string, empty for text/markdown tiers.
293
+ */
294
+ info: string;
295
+ }
296
+ /**
297
+ * RenderContext - Context passed to renderers during tree traversal.
298
+ *
299
+ * Contains information about the rendering environment and is passed down
300
+ * through the UINode tree as components render. This allows renderers to
301
+ * make decisions about layout, styling, and interactivity based on the
302
+ * current environment.
303
+ *
304
+ * @remarks
305
+ * **Context Propagation:**
306
+ * - Passed to each component's renderer function
307
+ * - Updated for nested components (depth increments)
308
+ * - Allows renderers to adapt output to terminal capabilities
309
+ * - Enables responsive layouts based on terminal dimensions
310
+ *
311
+ * **Tier-Dependent Behavior:**
312
+ * - Lower tiers (text, markdown) ignore complex styling
313
+ * - Higher tiers (ansi, interactive) use full theme and interactivity
314
+ * - Renderers should gracefully degrade for lower tiers
315
+ *
316
+ * @example
317
+ * Using context in a renderer:
318
+ * ```tsx
319
+ * function renderBox(node: UINode, ctx: RenderContext): string {
320
+ * if (ctx.tier === 'text') {
321
+ * // No styling, return plain text
322
+ * return node.props.content as string
323
+ * }
324
+ *
325
+ * if (ctx.tier === 'ansi' || ctx.tier === 'interactive') {
326
+ * // Can use colors and styling
327
+ * return `${ctx.theme.primary}[Box]${RESET}${node.props.content}`
328
+ * }
329
+ *
330
+ * // Other tiers: use unicode or ascii
331
+ * return drawBox(node, ctx)
332
+ * }
333
+ * ```
334
+ *
335
+ * @example
336
+ * Responsive layout based on terminal width:
337
+ * ```tsx
338
+ * function renderGrid(node: UINode, ctx: RenderContext): string {
339
+ * const columns = ctx.width < 80 ? 1 : ctx.width < 120 ? 2 : 3
340
+ * // ... render grid with calculated columns
341
+ * }
342
+ * ```
343
+ */
344
+ interface RenderContext {
345
+ /**
346
+ * Current rendering tier
347
+ * @remarks
348
+ * Determines what output capabilities are available (colors, unicode, etc).
349
+ * Renderers should adapt their output based on this tier.
350
+ */
351
+ tier: RenderTier;
352
+ /**
353
+ * Terminal width in columns
354
+ * @remarks
355
+ * Used for responsive layouts and line wrapping decisions.
356
+ * Standard values: 80 (legacy), 120 (modern), 160+ (wide monitors).
357
+ * Must be positive integer.
358
+ */
359
+ width: number;
360
+ /**
361
+ * Terminal height in rows
362
+ * @remarks
363
+ * Used for pagination and viewport-aware rendering.
364
+ * Standard values: 24 (legacy), 40 (modern).
365
+ * Must be positive integer.
366
+ */
367
+ height: number;
368
+ /**
369
+ * Current nesting depth
370
+ * @remarks
371
+ * Starts at 0 for root components, increments for each nested level.
372
+ * Used for indentation, padding, and determining when to truncate output.
373
+ * Must be non-negative integer.
374
+ */
375
+ depth: number;
376
+ /**
377
+ * Theme tokens for styling
378
+ * @remarks
379
+ * Contains ANSI color codes for the current tier.
380
+ * For text/markdown tiers, all values are empty strings.
381
+ * Renderers should use these tokens instead of hardcoding colors.
382
+ */
383
+ theme: ThemeTokens;
384
+ /**
385
+ * Whether interactive input is enabled
386
+ * @remarks
387
+ * True only for the 'interactive' tier. Indicates that the renderer
388
+ * should support keyboard input, mouse events, and real-time updates.
389
+ * Always false for non-interactive tiers.
390
+ */
391
+ interactive: boolean;
392
+ }
393
+ /**
394
+ * Zod schema for RenderTier validation.
395
+ *
396
+ * @remarks
397
+ * Validates that a value is one of the six defined render tiers.
398
+ * Rejects any other string or non-string values.
399
+ *
400
+ * **Validation Rules:**
401
+ * - Must be exactly one of: 'text', 'markdown', 'ascii', 'unicode', 'ansi', 'interactive'
402
+ * - Case-sensitive (e.g., 'TEXT' is rejected)
403
+ * - Rejects null, undefined, numbers, objects
404
+ *
405
+ * @example
406
+ * ```tsx
407
+ * // Valid
408
+ * RenderTierSchema.parse('ansi')
409
+ * RenderTierSchema.parse('text')
410
+ *
411
+ * // Invalid - throws ZodError
412
+ * RenderTierSchema.parse('html')
413
+ * RenderTierSchema.parse('TEXT')
414
+ * RenderTierSchema.parse(123)
415
+ * ```
416
+ */
417
+ declare const RenderTierSchema: z.ZodEnum<["text", "markdown", "ascii", "unicode", "ansi", "interactive"]>;
418
+ /**
419
+ * Zod schema for ThemeTokens validation.
420
+ *
421
+ * @remarks
422
+ * Validates that all 10 color tokens are present and are strings.
423
+ * No validation of ANSI code format - any string is accepted
424
+ * (including empty strings for text tier).
425
+ *
426
+ * **Validation Rules:**
427
+ * - All 10 fields are required: primary, secondary, muted, foreground,
428
+ * background, border, success, warning, error, info
429
+ * - Each field must be a string (empty string is valid)
430
+ * - Rejects objects with missing fields or non-string values
431
+ * - No validation of ANSI code validity
432
+ *
433
+ * **Required Fields:**
434
+ * ```
435
+ * primary, secondary, muted, foreground, background,
436
+ * border, success, warning, error, info
437
+ * ```
438
+ *
439
+ * @example
440
+ * ```tsx
441
+ * // Valid theme
442
+ * const validTheme = {
443
+ * primary: '\x1b[34m',
444
+ * secondary: '\x1b[36m',
445
+ * muted: '\x1b[90m',
446
+ * foreground: '\x1b[37m',
447
+ * background: '\x1b[40m',
448
+ * border: '\x1b[90m',
449
+ * success: '\x1b[32m',
450
+ * warning: '\x1b[33m',
451
+ * error: '\x1b[31m',
452
+ * info: '\x1b[34m',
453
+ * }
454
+ * ThemeTokensSchema.parse(validTheme) // OK
455
+ *
456
+ * // Invalid - missing field
457
+ * ThemeTokensSchema.parse({ primary: '\x1b[34m' }) // Throws
458
+ *
459
+ * // Invalid - non-string value
460
+ * ThemeTokensSchema.parse({ ...validTheme, primary: 123 }) // Throws
461
+ * ```
462
+ */
463
+ declare const ThemeTokensSchema: z.ZodObject<{
464
+ primary: z.ZodString;
465
+ secondary: z.ZodString;
466
+ muted: z.ZodString;
467
+ foreground: z.ZodString;
468
+ background: z.ZodString;
469
+ border: z.ZodString;
470
+ success: z.ZodString;
471
+ warning: z.ZodString;
472
+ error: z.ZodString;
473
+ info: z.ZodString;
474
+ }, "strip", z.ZodTypeAny, {
475
+ primary: string;
476
+ secondary: string;
477
+ muted: string;
478
+ success: string;
479
+ warning: string;
480
+ error: string;
481
+ info: string;
482
+ border: string;
483
+ background: string;
484
+ foreground: string;
485
+ }, {
486
+ primary: string;
487
+ secondary: string;
488
+ muted: string;
489
+ success: string;
490
+ warning: string;
491
+ error: string;
492
+ info: string;
493
+ border: string;
494
+ background: string;
495
+ foreground: string;
496
+ }>;
497
+ /**
498
+ * Zod schema for UINode validation.
499
+ *
500
+ * @remarks
501
+ * Validates the complete UINode structure including recursive children.
502
+ * Uses `z.lazy()` to support arbitrary nesting depth.
503
+ *
504
+ * **Validation Rules:**
505
+ * - `type`: Required, must be string
506
+ * - `props`: Required, must be object with string keys and any values
507
+ * - `children`: Optional, must be array of UINode objects
508
+ * - `data`: Optional, can be any value (unknown)
509
+ * - `key`: Optional, must be string if provided
510
+ * - Extra fields are not allowed (strict validation)
511
+ *
512
+ * **Recursion:**
513
+ * Uses `z.lazy()` to support infinitely nested children without
514
+ * causing infinite type computation. Each child must also be valid UINode.
515
+ *
516
+ * @example
517
+ * ```tsx
518
+ * // Valid - simple node
519
+ * UINodeSchema.parse({
520
+ * type: 'text',
521
+ * props: { content: 'Hello' }
522
+ * }) // OK
523
+ *
524
+ * // Valid - nested children
525
+ * UINodeSchema.parse({
526
+ * type: 'box',
527
+ * props: {},
528
+ * children: [
529
+ * { type: 'text', props: { content: 'Child' } }
530
+ * ]
531
+ * }) // OK
532
+ *
533
+ * // Valid - all optional fields
534
+ * UINodeSchema.parse({
535
+ * type: 'table',
536
+ * props: { columns: ['A', 'B'] },
537
+ * children: [],
538
+ * data: [{ a: 1, b: 2 }],
539
+ * key: 'table-1'
540
+ * }) // OK
541
+ *
542
+ * // Invalid - missing type
543
+ * UINodeSchema.parse({ props: {} }) // Throws ZodError
544
+ *
545
+ * // Invalid - non-string type
546
+ * UINodeSchema.parse({ type: 123, props: {} }) // Throws ZodError
547
+ *
548
+ * // Invalid - invalid child
549
+ * UINodeSchema.parse({
550
+ * type: 'box',
551
+ * props: {},
552
+ * children: [{ props: {} }] // Missing type
553
+ * }) // Throws ZodError
554
+ * ```
555
+ */
556
+ declare const UINodeSchema: z.ZodType<UINode>;
557
+ /**
558
+ * Zod schema for RenderContext validation.
559
+ *
560
+ * @remarks
561
+ * Validates the complete RenderContext structure with all required fields.
562
+ * Ensures numeric constraints are met and nested types are valid.
563
+ *
564
+ * **Validation Rules:**
565
+ * - `tier`: Required, must be valid RenderTier
566
+ * - `width`: Required, must be non-negative number (positive in practice)
567
+ * - `height`: Required, must be non-negative number (positive in practice)
568
+ * - `depth`: Required, must be non-negative number
569
+ * - `theme`: Required, must be valid ThemeTokens with all fields
570
+ * - `interactive`: Required, must be boolean
571
+ * - All fields are required (no optional fields)
572
+ * - Extra fields are not allowed
573
+ *
574
+ * **Numeric Constraints:**
575
+ * - width, height, depth must all satisfy `.nonnegative()`
576
+ * - No upper bounds enforced (size validation handled elsewhere)
577
+ *
578
+ * @example
579
+ * ```tsx
580
+ * // Valid context
581
+ * RenderContextSchema.parse({
582
+ * tier: 'ansi',
583
+ * width: 80,
584
+ * height: 24,
585
+ * depth: 0,
586
+ * theme: {
587
+ * primary: '\x1b[34m',
588
+ * secondary: '\x1b[36m',
589
+ * muted: '\x1b[90m',
590
+ * foreground: '\x1b[37m',
591
+ * background: '\x1b[40m',
592
+ * border: '\x1b[90m',
593
+ * success: '\x1b[32m',
594
+ * warning: '\x1b[33m',
595
+ * error: '\x1b[31m',
596
+ * info: '\x1b[34m',
597
+ * },
598
+ * interactive: false
599
+ * }) // OK
600
+ *
601
+ * // Invalid - negative width
602
+ * RenderContextSchema.parse({
603
+ * tier: 'text',
604
+ * width: -10, // ERROR
605
+ * height: 24,
606
+ * depth: 0,
607
+ * theme: { primary: '', secondary: '' }, // truncated
608
+ * interactive: false
609
+ * }) // Throws ZodError
610
+ *
611
+ * // Invalid - invalid tier
612
+ * RenderContextSchema.parse({
613
+ * tier: 'html', // ERROR - not a valid tier
614
+ * width: 80,
615
+ * height: 24,
616
+ * depth: 0,
617
+ * theme: { primary: '', secondary: '' }, // truncated
618
+ * interactive: false
619
+ * }) // Throws ZodError
620
+ *
621
+ * // Invalid - missing theme field
622
+ * RenderContextSchema.parse({
623
+ * tier: 'text',
624
+ * width: 80,
625
+ * height: 24,
626
+ * depth: 0,
627
+ * interactive: false
628
+ * // Missing: theme field
629
+ * }) // Throws ZodError
630
+ * ```
631
+ */
632
+ declare const RenderContextSchema: z.ZodObject<{
633
+ tier: z.ZodEnum<["text", "markdown", "ascii", "unicode", "ansi", "interactive"]>;
634
+ width: z.ZodNumber;
635
+ height: z.ZodNumber;
636
+ depth: z.ZodNumber;
637
+ theme: z.ZodObject<{
638
+ primary: z.ZodString;
639
+ secondary: z.ZodString;
640
+ muted: z.ZodString;
641
+ foreground: z.ZodString;
642
+ background: z.ZodString;
643
+ border: z.ZodString;
644
+ success: z.ZodString;
645
+ warning: z.ZodString;
646
+ error: z.ZodString;
647
+ info: z.ZodString;
648
+ }, "strip", z.ZodTypeAny, {
649
+ primary: string;
650
+ secondary: string;
651
+ muted: string;
652
+ success: string;
653
+ warning: string;
654
+ error: string;
655
+ info: string;
656
+ border: string;
657
+ background: string;
658
+ foreground: string;
659
+ }, {
660
+ primary: string;
661
+ secondary: string;
662
+ muted: string;
663
+ success: string;
664
+ warning: string;
665
+ error: string;
666
+ info: string;
667
+ border: string;
668
+ background: string;
669
+ foreground: string;
670
+ }>;
671
+ interactive: z.ZodBoolean;
672
+ }, "strip", z.ZodTypeAny, {
673
+ width: number;
674
+ height: number;
675
+ theme: {
676
+ primary: string;
677
+ secondary: string;
678
+ muted: string;
679
+ success: string;
680
+ warning: string;
681
+ error: string;
682
+ info: string;
683
+ border: string;
684
+ background: string;
685
+ foreground: string;
686
+ };
687
+ interactive: boolean;
688
+ tier: "text" | "ascii" | "markdown" | "unicode" | "ansi" | "interactive";
689
+ depth: number;
690
+ }, {
691
+ width: number;
692
+ height: number;
693
+ theme: {
694
+ primary: string;
695
+ secondary: string;
696
+ muted: string;
697
+ success: string;
698
+ warning: string;
699
+ error: string;
700
+ info: string;
701
+ border: string;
702
+ background: string;
703
+ foreground: string;
704
+ };
705
+ interactive: boolean;
706
+ tier: "text" | "ascii" | "markdown" | "unicode" | "ansi" | "interactive";
707
+ depth: number;
708
+ }>;
709
+
710
+ export { type RenderTier as R, type ThemeTokens as T, type UINode as U, type RenderContext as a, UINodeSchema as b, RenderTierSchema as c, ThemeTokensSchema as d, RenderContextSchema as e };