@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,701 @@
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 for nested components
80
+ * @remarks
81
+ * Children are rendered as the component's content. Nested to arbitrary depth.
82
+ * Undefined if the component has no children.
83
+ */
84
+ children?: UINode[];
85
+ /**
86
+ * Optional bound query data for data-driven components
87
+ * @remarks
88
+ * Used for components that render arrays of items (tables, lists, grids).
89
+ * The data can be any shape; the component implementation defines how to use it.
90
+ * Examples: array of records, nested objects, primitive values.
91
+ */
92
+ data?: unknown;
93
+ /**
94
+ * Optional key for React-style reconciliation
95
+ * @remarks
96
+ * Used in lists to maintain identity across renders. If a node's key changes,
97
+ * the component is recreated. Useful for preserving component state.
98
+ * Should be stable across renders for the same logical item.
99
+ */
100
+ key?: string;
101
+ }
102
+ /**
103
+ * RenderTier - Defines the capability level for rendering output.
104
+ *
105
+ * Tiers are ordered by increasing capability:
106
+ * `text` < `markdown` < `ascii` < `unicode` < `ansi` < `interactive`
107
+ *
108
+ * Each tier builds on the previous one, enabling progressively richer
109
+ * terminal output while maintaining backward compatibility.
110
+ *
111
+ * @remarks
112
+ * **Tier Definitions:**
113
+ *
114
+ * - **text** - Plain text output without any formatting or special characters.
115
+ * No colors, no box drawing, no markdown. Useful for piping output or
116
+ * basic terminal environments with no formatting support.
117
+ * Example: `Hello World`
118
+ *
119
+ * - **markdown** - Text with Markdown syntax for basic formatting:
120
+ * **bold**, *italic*, `code`, links. No color support. Good for converting
121
+ * terminal output to documentation or emails.
122
+ * Example: `**Hello** _World_`
123
+ *
124
+ * - **ascii** - ASCII art characters (/, \, |, -, +, =) for drawing
125
+ * boxes, borders, and diagrams. No unicode box drawing characters.
126
+ * Broader terminal compatibility than unicode.
127
+ * Example: `+---+\n| A |\n+---+`
128
+ *
129
+ * - **unicode** - Unicode box drawing characters (┌, ─, │, └, etc.)
130
+ * for elegant borders and tables. Better appearance than ASCII but
131
+ * requires UTF-8 terminal support.
132
+ * Example: `┌───┐\n│ A │\n└───┘`
133
+ *
134
+ * - **ansi** - ANSI escape sequences for 256-color or truecolor output.
135
+ * Supports foreground/background colors, bold, underline, etc.
136
+ * Requires modern terminal supporting ANSI codes.
137
+ * Example: `\x1b[31mRed Text\x1b[0m`
138
+ *
139
+ * - **interactive** - Full interactive terminal UI with keyboard input,
140
+ * mouse events, and real-time updates. Requires a terminal library like
141
+ * Ink or Blessed. Most capable tier but requires active user interaction.
142
+ * Example: Menu navigation, live dashboards, text input.
143
+ *
144
+ * @example
145
+ * Checking tier capability:
146
+ * ```tsx
147
+ * const canUseColors = tier === 'ansi' || tier === 'interactive'
148
+ * const canUseUnicode = tier === 'unicode' || tier === 'ansi' || tier === 'interactive'
149
+ * const isPlainText = tier === 'text'
150
+ * ```
151
+ */
152
+ type RenderTier = 'text' | 'markdown' | 'ascii' | 'unicode' | 'ansi' | 'interactive';
153
+ /**
154
+ * ThemeTokens - Color tokens for theming terminal output.
155
+ *
156
+ * All tokens are strings containing ANSI escape sequences (or empty for text tier).
157
+ * This interface defines a complete semantic color palette for terminal applications.
158
+ *
159
+ * @remarks
160
+ * **Format and Values:**
161
+ * - For `text` tier: Empty string `''` (no color support)
162
+ * - For `markdown` tier: Empty string `''` (colors not supported in markdown)
163
+ * - For `ascii`/`unicode`/`ansi`/`interactive` tiers:
164
+ * ANSI escape sequences like `'\x1b[31m'` (red) or `'\x1b[1;32m'` (bold green)
165
+ *
166
+ * **Semantic Categories:**
167
+ * - **Primary/Secondary**: Brand colors for emphasis and hierarchy
168
+ * - **Foreground/Background**: Text and surface colors
169
+ * - **Status Colors**: Semantic meaning (green=success, red=error, yellow=warning, blue=info)
170
+ * - **Muted**: De-emphasized text (help text, secondary content)
171
+ * - **Border**: For drawing boxes and separators
172
+ *
173
+ * @example
174
+ * Light ANSI theme:
175
+ * ```tsx
176
+ * const lightTheme: ThemeTokens = {
177
+ * primary: '\x1b[34m', // Blue
178
+ * secondary: '\x1b[36m', // Cyan
179
+ * muted: '\x1b[90m', // Bright black
180
+ * foreground: '\x1b[37m', // White
181
+ * background: '\x1b[40m', // Black background
182
+ * border: '\x1b[90m', // Gray
183
+ * success: '\x1b[32m', // Green
184
+ * warning: '\x1b[33m', // Yellow
185
+ * error: '\x1b[31m', // Red
186
+ * info: '\x1b[34m', // Blue
187
+ * }
188
+ * ```
189
+ *
190
+ * @example
191
+ * Text tier (no colors):
192
+ * ```tsx
193
+ * const textTheme: ThemeTokens = {
194
+ * primary: '',
195
+ * secondary: '',
196
+ * muted: '',
197
+ * foreground: '',
198
+ * background: '',
199
+ * border: '',
200
+ * success: '',
201
+ * warning: '',
202
+ * error: '',
203
+ * info: '',
204
+ * }
205
+ * ```
206
+ */
207
+ interface ThemeTokens {
208
+ /**
209
+ * Primary brand color
210
+ * @remarks
211
+ * Used for primary CTAs, headings, and key UI elements.
212
+ * ANSI code string, empty for text/markdown tiers.
213
+ */
214
+ primary: string;
215
+ /**
216
+ * Secondary accent color
217
+ * @remarks
218
+ * Used for secondary actions and accents.
219
+ * ANSI code string, empty for text/markdown tiers.
220
+ */
221
+ secondary: string;
222
+ /**
223
+ * Muted/dimmed text color
224
+ * @remarks
225
+ * Used for helper text, secondary content, disabled states.
226
+ * Lower contrast than foreground color.
227
+ * ANSI code string, empty for text/markdown tiers.
228
+ */
229
+ muted: string;
230
+ /**
231
+ * Default foreground text color
232
+ * @remarks
233
+ * Primary text color for body content and labels.
234
+ * Should have high contrast with background.
235
+ * ANSI code string, empty for text/markdown tiers.
236
+ */
237
+ foreground: string;
238
+ /**
239
+ * Background color
240
+ * @remarks
241
+ * Used for panels, boxes, and background surfaces.
242
+ * Should contrast well with foreground for readability.
243
+ * ANSI code string, empty for text/markdown tiers.
244
+ */
245
+ background: string;
246
+ /**
247
+ * Border/separator color
248
+ * @remarks
249
+ * Used for drawing borders, dividers, and separators.
250
+ * Often same as muted for subtle appearance.
251
+ * ANSI code string, empty for text/markdown tiers.
252
+ */
253
+ border: string;
254
+ /**
255
+ * Success state color (typically green)
256
+ * @remarks
257
+ * Used for success messages, checkmarks, confirmations.
258
+ * Semantic meaning: positive outcome, success state.
259
+ * ANSI code string, empty for text/markdown tiers.
260
+ */
261
+ success: string;
262
+ /**
263
+ * Warning state color (typically yellow/orange)
264
+ * @remarks
265
+ * Used for warnings, alerts, caution messages.
266
+ * Semantic meaning: attention needed, non-critical issue.
267
+ * ANSI code string, empty for text/markdown tiers.
268
+ */
269
+ warning: string;
270
+ /**
271
+ * Error state color (typically red)
272
+ * @remarks
273
+ * Used for errors, failures, destructive actions.
274
+ * Semantic meaning: critical issue, failure state.
275
+ * ANSI code string, empty for text/markdown tiers.
276
+ */
277
+ error: string;
278
+ /**
279
+ * Info state color (typically blue)
280
+ * @remarks
281
+ * Used for information, hints, explanatory messages.
282
+ * Semantic meaning: additional context, non-critical info.
283
+ * ANSI code string, empty for text/markdown tiers.
284
+ */
285
+ info: string;
286
+ }
287
+ /**
288
+ * RenderContext - Context passed to renderers during tree traversal.
289
+ *
290
+ * Contains information about the rendering environment and is passed down
291
+ * through the UINode tree as components render. This allows renderers to
292
+ * make decisions about layout, styling, and interactivity based on the
293
+ * current environment.
294
+ *
295
+ * @remarks
296
+ * **Context Propagation:**
297
+ * - Passed to each component's renderer function
298
+ * - Updated for nested components (depth increments)
299
+ * - Allows renderers to adapt output to terminal capabilities
300
+ * - Enables responsive layouts based on terminal dimensions
301
+ *
302
+ * **Tier-Dependent Behavior:**
303
+ * - Lower tiers (text, markdown) ignore complex styling
304
+ * - Higher tiers (ansi, interactive) use full theme and interactivity
305
+ * - Renderers should gracefully degrade for lower tiers
306
+ *
307
+ * @example
308
+ * Using context in a renderer:
309
+ * ```tsx
310
+ * function renderBox(node: UINode, ctx: RenderContext): string {
311
+ * if (ctx.tier === 'text') {
312
+ * // No styling, return plain text
313
+ * return node.props.content as string
314
+ * }
315
+ *
316
+ * if (ctx.tier === 'ansi' || ctx.tier === 'interactive') {
317
+ * // Can use colors and styling
318
+ * return `${ctx.theme.primary}[Box]${RESET}${node.props.content}`
319
+ * }
320
+ *
321
+ * // Other tiers: use unicode or ascii
322
+ * return drawBox(node, ctx)
323
+ * }
324
+ * ```
325
+ *
326
+ * @example
327
+ * Responsive layout based on terminal width:
328
+ * ```tsx
329
+ * function renderGrid(node: UINode, ctx: RenderContext): string {
330
+ * const columns = ctx.width < 80 ? 1 : ctx.width < 120 ? 2 : 3
331
+ * // ... render grid with calculated columns
332
+ * }
333
+ * ```
334
+ */
335
+ interface RenderContext {
336
+ /**
337
+ * Current rendering tier
338
+ * @remarks
339
+ * Determines what output capabilities are available (colors, unicode, etc).
340
+ * Renderers should adapt their output based on this tier.
341
+ */
342
+ tier: RenderTier;
343
+ /**
344
+ * Terminal width in columns
345
+ * @remarks
346
+ * Used for responsive layouts and line wrapping decisions.
347
+ * Standard values: 80 (legacy), 120 (modern), 160+ (wide monitors).
348
+ * Must be positive integer.
349
+ */
350
+ width: number;
351
+ /**
352
+ * Terminal height in rows
353
+ * @remarks
354
+ * Used for pagination and viewport-aware rendering.
355
+ * Standard values: 24 (legacy), 40 (modern).
356
+ * Must be positive integer.
357
+ */
358
+ height: number;
359
+ /**
360
+ * Current nesting depth
361
+ * @remarks
362
+ * Starts at 0 for root components, increments for each nested level.
363
+ * Used for indentation, padding, and determining when to truncate output.
364
+ * Must be non-negative integer.
365
+ */
366
+ depth: number;
367
+ /**
368
+ * Theme tokens for styling
369
+ * @remarks
370
+ * Contains ANSI color codes for the current tier.
371
+ * For text/markdown tiers, all values are empty strings.
372
+ * Renderers should use these tokens instead of hardcoding colors.
373
+ */
374
+ theme: ThemeTokens;
375
+ /**
376
+ * Whether interactive input is enabled
377
+ * @remarks
378
+ * True only for the 'interactive' tier. Indicates that the renderer
379
+ * should support keyboard input, mouse events, and real-time updates.
380
+ * Always false for non-interactive tiers.
381
+ */
382
+ interactive: boolean;
383
+ }
384
+ /**
385
+ * Zod schema for RenderTier validation.
386
+ *
387
+ * @remarks
388
+ * Validates that a value is one of the six defined render tiers.
389
+ * Rejects any other string or non-string values.
390
+ *
391
+ * **Validation Rules:**
392
+ * - Must be exactly one of: 'text', 'markdown', 'ascii', 'unicode', 'ansi', 'interactive'
393
+ * - Case-sensitive (e.g., 'TEXT' is rejected)
394
+ * - Rejects null, undefined, numbers, objects
395
+ *
396
+ * @example
397
+ * ```tsx
398
+ * // Valid
399
+ * RenderTierSchema.parse('ansi')
400
+ * RenderTierSchema.parse('text')
401
+ *
402
+ * // Invalid - throws ZodError
403
+ * RenderTierSchema.parse('html')
404
+ * RenderTierSchema.parse('TEXT')
405
+ * RenderTierSchema.parse(123)
406
+ * ```
407
+ */
408
+ declare const RenderTierSchema: z.ZodEnum<["text", "markdown", "ascii", "unicode", "ansi", "interactive"]>;
409
+ /**
410
+ * Zod schema for ThemeTokens validation.
411
+ *
412
+ * @remarks
413
+ * Validates that all 10 color tokens are present and are strings.
414
+ * No validation of ANSI code format - any string is accepted
415
+ * (including empty strings for text tier).
416
+ *
417
+ * **Validation Rules:**
418
+ * - All 10 fields are required: primary, secondary, muted, foreground,
419
+ * background, border, success, warning, error, info
420
+ * - Each field must be a string (empty string is valid)
421
+ * - Rejects objects with missing fields or non-string values
422
+ * - No validation of ANSI code validity
423
+ *
424
+ * **Required Fields:**
425
+ * ```
426
+ * primary, secondary, muted, foreground, background,
427
+ * border, success, warning, error, info
428
+ * ```
429
+ *
430
+ * @example
431
+ * ```tsx
432
+ * // Valid theme
433
+ * const validTheme = {
434
+ * primary: '\x1b[34m',
435
+ * secondary: '\x1b[36m',
436
+ * muted: '\x1b[90m',
437
+ * foreground: '\x1b[37m',
438
+ * background: '\x1b[40m',
439
+ * border: '\x1b[90m',
440
+ * success: '\x1b[32m',
441
+ * warning: '\x1b[33m',
442
+ * error: '\x1b[31m',
443
+ * info: '\x1b[34m',
444
+ * }
445
+ * ThemeTokensSchema.parse(validTheme) // OK
446
+ *
447
+ * // Invalid - missing field
448
+ * ThemeTokensSchema.parse({ primary: '\x1b[34m' }) // Throws
449
+ *
450
+ * // Invalid - non-string value
451
+ * ThemeTokensSchema.parse({ ...validTheme, primary: 123 }) // Throws
452
+ * ```
453
+ */
454
+ declare const ThemeTokensSchema: z.ZodObject<{
455
+ primary: z.ZodString;
456
+ secondary: z.ZodString;
457
+ muted: z.ZodString;
458
+ foreground: z.ZodString;
459
+ background: z.ZodString;
460
+ border: z.ZodString;
461
+ success: z.ZodString;
462
+ warning: z.ZodString;
463
+ error: z.ZodString;
464
+ info: z.ZodString;
465
+ }, "strip", z.ZodTypeAny, {
466
+ primary: string;
467
+ secondary: string;
468
+ muted: string;
469
+ success: string;
470
+ warning: string;
471
+ error: string;
472
+ info: string;
473
+ border: string;
474
+ background: string;
475
+ foreground: string;
476
+ }, {
477
+ primary: string;
478
+ secondary: string;
479
+ muted: string;
480
+ success: string;
481
+ warning: string;
482
+ error: string;
483
+ info: string;
484
+ border: string;
485
+ background: string;
486
+ foreground: string;
487
+ }>;
488
+ /**
489
+ * Zod schema for UINode validation.
490
+ *
491
+ * @remarks
492
+ * Validates the complete UINode structure including recursive children.
493
+ * Uses `z.lazy()` to support arbitrary nesting depth.
494
+ *
495
+ * **Validation Rules:**
496
+ * - `type`: Required, must be string
497
+ * - `props`: Required, must be object with string keys and any values
498
+ * - `children`: Optional, must be array of UINode objects
499
+ * - `data`: Optional, can be any value (unknown)
500
+ * - `key`: Optional, must be string if provided
501
+ * - Extra fields are not allowed (strict validation)
502
+ *
503
+ * **Recursion:**
504
+ * Uses `z.lazy()` to support infinitely nested children without
505
+ * causing infinite type computation. Each child must also be valid UINode.
506
+ *
507
+ * @example
508
+ * ```tsx
509
+ * // Valid - simple node
510
+ * UINodeSchema.parse({
511
+ * type: 'text',
512
+ * props: { content: 'Hello' }
513
+ * }) // OK
514
+ *
515
+ * // Valid - nested children
516
+ * UINodeSchema.parse({
517
+ * type: 'box',
518
+ * props: {},
519
+ * children: [
520
+ * { type: 'text', props: { content: 'Child' } }
521
+ * ]
522
+ * }) // OK
523
+ *
524
+ * // Valid - all optional fields
525
+ * UINodeSchema.parse({
526
+ * type: 'table',
527
+ * props: { columns: ['A', 'B'] },
528
+ * children: [],
529
+ * data: [{ a: 1, b: 2 }],
530
+ * key: 'table-1'
531
+ * }) // OK
532
+ *
533
+ * // Invalid - missing type
534
+ * UINodeSchema.parse({ props: {} }) // Throws ZodError
535
+ *
536
+ * // Invalid - non-string type
537
+ * UINodeSchema.parse({ type: 123, props: {} }) // Throws ZodError
538
+ *
539
+ * // Invalid - invalid child
540
+ * UINodeSchema.parse({
541
+ * type: 'box',
542
+ * props: {},
543
+ * children: [{ props: {} }] // Missing type
544
+ * }) // Throws ZodError
545
+ * ```
546
+ */
547
+ declare const UINodeSchema: z.ZodType<UINode>;
548
+ /**
549
+ * Zod schema for RenderContext validation.
550
+ *
551
+ * @remarks
552
+ * Validates the complete RenderContext structure with all required fields.
553
+ * Ensures numeric constraints are met and nested types are valid.
554
+ *
555
+ * **Validation Rules:**
556
+ * - `tier`: Required, must be valid RenderTier
557
+ * - `width`: Required, must be non-negative number (positive in practice)
558
+ * - `height`: Required, must be non-negative number (positive in practice)
559
+ * - `depth`: Required, must be non-negative number
560
+ * - `theme`: Required, must be valid ThemeTokens with all fields
561
+ * - `interactive`: Required, must be boolean
562
+ * - All fields are required (no optional fields)
563
+ * - Extra fields are not allowed
564
+ *
565
+ * **Numeric Constraints:**
566
+ * - width, height, depth must all satisfy `.nonnegative()`
567
+ * - No upper bounds enforced (size validation handled elsewhere)
568
+ *
569
+ * @example
570
+ * ```tsx
571
+ * // Valid context
572
+ * RenderContextSchema.parse({
573
+ * tier: 'ansi',
574
+ * width: 80,
575
+ * height: 24,
576
+ * depth: 0,
577
+ * theme: {
578
+ * primary: '\x1b[34m',
579
+ * secondary: '\x1b[36m',
580
+ * muted: '\x1b[90m',
581
+ * foreground: '\x1b[37m',
582
+ * background: '\x1b[40m',
583
+ * border: '\x1b[90m',
584
+ * success: '\x1b[32m',
585
+ * warning: '\x1b[33m',
586
+ * error: '\x1b[31m',
587
+ * info: '\x1b[34m',
588
+ * },
589
+ * interactive: false
590
+ * }) // OK
591
+ *
592
+ * // Invalid - negative width
593
+ * RenderContextSchema.parse({
594
+ * tier: 'text',
595
+ * width: -10, // ERROR
596
+ * height: 24,
597
+ * depth: 0,
598
+ * theme: { primary: '', secondary: '' }, // truncated
599
+ * interactive: false
600
+ * }) // Throws ZodError
601
+ *
602
+ * // Invalid - invalid tier
603
+ * RenderContextSchema.parse({
604
+ * tier: 'html', // ERROR - not a valid tier
605
+ * width: 80,
606
+ * height: 24,
607
+ * depth: 0,
608
+ * theme: { primary: '', secondary: '' }, // truncated
609
+ * interactive: false
610
+ * }) // Throws ZodError
611
+ *
612
+ * // Invalid - missing theme field
613
+ * RenderContextSchema.parse({
614
+ * tier: 'text',
615
+ * width: 80,
616
+ * height: 24,
617
+ * depth: 0,
618
+ * interactive: false
619
+ * // Missing: theme field
620
+ * }) // Throws ZodError
621
+ * ```
622
+ */
623
+ declare const RenderContextSchema: z.ZodObject<{
624
+ tier: z.ZodEnum<["text", "markdown", "ascii", "unicode", "ansi", "interactive"]>;
625
+ width: z.ZodNumber;
626
+ height: z.ZodNumber;
627
+ depth: z.ZodNumber;
628
+ theme: z.ZodObject<{
629
+ primary: z.ZodString;
630
+ secondary: z.ZodString;
631
+ muted: z.ZodString;
632
+ foreground: z.ZodString;
633
+ background: z.ZodString;
634
+ border: z.ZodString;
635
+ success: z.ZodString;
636
+ warning: z.ZodString;
637
+ error: z.ZodString;
638
+ info: z.ZodString;
639
+ }, "strip", z.ZodTypeAny, {
640
+ primary: string;
641
+ secondary: string;
642
+ muted: string;
643
+ success: string;
644
+ warning: string;
645
+ error: string;
646
+ info: string;
647
+ border: string;
648
+ background: string;
649
+ foreground: string;
650
+ }, {
651
+ primary: string;
652
+ secondary: string;
653
+ muted: string;
654
+ success: string;
655
+ warning: string;
656
+ error: string;
657
+ info: string;
658
+ border: string;
659
+ background: string;
660
+ foreground: string;
661
+ }>;
662
+ interactive: z.ZodBoolean;
663
+ }, "strip", z.ZodTypeAny, {
664
+ width: number;
665
+ height: number;
666
+ theme: {
667
+ primary: string;
668
+ secondary: string;
669
+ muted: string;
670
+ success: string;
671
+ warning: string;
672
+ error: string;
673
+ info: string;
674
+ border: string;
675
+ background: string;
676
+ foreground: string;
677
+ };
678
+ interactive: boolean;
679
+ tier: "text" | "ascii" | "markdown" | "unicode" | "ansi" | "interactive";
680
+ depth: number;
681
+ }, {
682
+ width: number;
683
+ height: number;
684
+ theme: {
685
+ primary: string;
686
+ secondary: string;
687
+ muted: string;
688
+ success: string;
689
+ warning: string;
690
+ error: string;
691
+ info: string;
692
+ border: string;
693
+ background: string;
694
+ foreground: string;
695
+ };
696
+ interactive: boolean;
697
+ tier: "text" | "ascii" | "markdown" | "unicode" | "ansi" | "interactive";
698
+ depth: number;
699
+ }>;
700
+
701
+ 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 };