page.mdx 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  1. export const metadata = { title: "Changelog" }
  2. # Changelog
  3. Notable changes and updates to json-render.
  4. ## v0.7.0
  5. February 2026
  6. ### New: `@json-render/shadcn`
  7. Pre-built [shadcn/ui](https://ui.shadcn.com/) component library for json-render. 36 components built on Radix UI + Tailwind CSS, ready to use with `defineCatalog` and `defineRegistry`.
  8. ```bash
  9. npm install @json-render/shadcn
  10. ```
  11. ```typescript
  12. import { defineCatalog } from "@json-render/core";
  13. import { schema } from "@json-render/react/schema";
  14. import { shadcnComponentDefinitions } from "@json-render/shadcn/catalog";
  15. import { defineRegistry } from "@json-render/react";
  16. import { shadcnComponents } from "@json-render/shadcn";
  17. const catalog = defineCatalog(schema, {
  18. components: {
  19. Card: shadcnComponentDefinitions.Card,
  20. Button: shadcnComponentDefinitions.Button,
  21. Input: shadcnComponentDefinitions.Input,
  22. },
  23. actions: {},
  24. });
  25. const { registry } = defineRegistry(catalog, {
  26. components: {
  27. Card: shadcnComponents.Card,
  28. Button: shadcnComponents.Button,
  29. Input: shadcnComponents.Input,
  30. },
  31. });
  32. ```
  33. Components include: layout (Card, Stack, Grid, Separator), navigation (Tabs, Accordion, Collapsible, Pagination), overlay (Dialog, Drawer, Tooltip, Popover, DropdownMenu), content (Heading, Text, Image, Avatar, Badge, Alert, Carousel, Table), feedback (Progress, Skeleton, Spinner), and input (Button, Link, Input, Textarea, Select, Checkbox, Radio, Switch, Slider, Toggle, ToggleGroup, ButtonGroup).
  34. See the [API reference](/docs/api/shadcn) for full details.
  35. ### New: Event Handles (`on()`)
  36. Components now receive an `on(event)` function in addition to `emit(event)`. The `on()` function returns an `EventHandle` with metadata:
  37. - `emit()` -- fire the event
  38. - `shouldPreventDefault` -- whether any action binding requested `preventDefault`
  39. - `bound` -- whether any handler is bound to this event
  40. ```tsx
  41. Link: ({ props, on }) => {
  42. const click = on("click");
  43. return (
  44. <a href={props.href} onClick={(e) => {
  45. if (click.shouldPreventDefault) e.preventDefault();
  46. click.emit();
  47. }}>{props.label}</a>
  48. );
  49. },
  50. ```
  51. ### New: `BaseComponentProps`
  52. Catalog-agnostic base type for component render functions. Use when building reusable component libraries (like `@json-render/shadcn`) that are not tied to a specific catalog.
  53. ```typescript
  54. import type { BaseComponentProps } from "@json-render/react";
  55. const Card = ({ props, children }: BaseComponentProps<{ title?: string }>) => (
  56. <div>{props.title}{children}</div>
  57. );
  58. ```
  59. ### New: Built-in Actions in Schema
  60. Schemas can now declare `builtInActions` -- actions that are always available at runtime and automatically injected into prompts. The React schema declares `setState`, `pushState`, and `removeState` as built-in, so they appear in prompts without needing to be listed in catalog `actions`.
  61. ### New: `preventDefault` on `ActionBinding`
  62. Action bindings now support a `preventDefault` boolean field, allowing the LLM to request that default browser behavior (e.g. navigation on links) be prevented.
  63. ### Improved: Stream Transform Text Block Splitting
  64. `createJsonRenderTransform()` now properly splits text blocks around spec data by emitting `text-end`/`text-start` pairs. This ensures the AI SDK creates separate text parts, preserving correct interleaving of prose and UI in `message.parts`.
  65. ### Improved: `defineRegistry` Actions Requirement
  66. `defineRegistry` now conditionally requires the `actions` field only when the catalog declares actions. Catalogs with no actions (e.g. `actions: {}`) no longer need to pass an empty actions object.
  67. ---
  68. ## v0.6.0
  69. February 2026
  70. ### New: Chat Mode (Inline GenUI)
  71. json-render now supports two generation modes: **Generate** (JSONL-only, the default) and **Chat** (text + JSONL inline). Chat mode lets the AI respond conversationally with embedded UI specs, ideal for chatbots and copilot experiences.
  72. ```typescript
  73. // Generate mode (default) — AI outputs only JSONL
  74. const prompt = catalog.prompt();
  75. // Chat mode — AI outputs text + JSONL inline
  76. const chatPrompt = catalog.prompt({ mode: "chat" });
  77. ```
  78. On the server, `pipeJsonRender()` separates text from JSONL patches in a mixed stream:
  79. ```typescript
  80. import { pipeJsonRender } from "@json-render/core";
  81. import { createUIMessageStream, createUIMessageStreamResponse } from "ai";
  82. const stream = createUIMessageStream({
  83. execute: async ({ writer }) => {
  84. writer.merge(pipeJsonRender(result.toUIMessageStream()));
  85. },
  86. });
  87. return createUIMessageStreamResponse({ stream });
  88. ```
  89. On the client, `useJsonRenderMessage` extracts the spec and text from message parts:
  90. ```tsx
  91. import { useJsonRenderMessage } from "@json-render/react";
  92. function ChatMessage({ message }) {
  93. const { spec, text, hasSpec } = useJsonRenderMessage(message.parts);
  94. return (
  95. <div>
  96. {text && <Markdown>{text}</Markdown>}
  97. {hasSpec && <Renderer spec={spec} registry={registry} />}
  98. </div>
  99. );
  100. }
  101. ```
  102. ### New: AI SDK Integration
  103. First-class Vercel AI SDK support with typed data parts and stream utilities.
  104. - `SpecDataPart` type for `data-spec` stream parts (patch, flat, nested payloads)
  105. - `SPEC_DATA_PART` / `SPEC_DATA_PART_TYPE` constants for type-safe part filtering
  106. - `createJsonRenderTransform()` low-level TransformStream for custom pipelines
  107. - `createMixedStreamParser()` for parsing mixed text + JSONL streams
  108. ### New: Two-Way Binding
  109. Props can now use `$bindState` and `$bindItem` expressions for two-way data binding. The renderer resolves bindings and passes a `bindings` map to components, enabling write-back to state without custom `valuePath` props.
  110. ```json
  111. {
  112. "type": "Input",
  113. "props": { "label": "Email", "value": { "$bindState": "/form/email" } }
  114. }
  115. ```
  116. ```tsx
  117. import { useBoundProp } from "@json-render/react";
  118. Input: ({ props, bindings }) => {
  119. const [value, setValue] = useBoundProp<string>(props.value, bindings?.value);
  120. return <input value={value ?? ""} onChange={(e) => setValue(e.target.value)} />;
  121. }
  122. ```
  123. ### New: Expression-Based Props and Visibility
  124. All dynamic expressions now use structured `$state`, `$item`, and `$index` objects instead of string token rewriting. This is simpler, more explicit, and works for both props and visibility conditions.
  125. **Props:**
  126. ```json
  127. { "title": { "$state": "/user/name" } }
  128. { "label": { "$item": "title" } }
  129. { "position": { "$index": true } }
  130. ```
  131. **Visibility:**
  132. ```json
  133. { "$state": "/isAdmin" }
  134. { "$state": "/role", "eq": "admin" }
  135. [{ "$state": "/isAdmin" }, { "$state": "/feature" }]
  136. { "$or": [{ "$state": "/roleA" }, { "$state": "/roleB" }] }
  137. { "$item": "isActive" }
  138. { "$index": true, "gt": 0 }
  139. ```
  140. Comparison operators: `eq`, `neq`, `gt`, `gte`, `lt`, `lte`, `not`.
  141. ### New: React Chat Hooks
  142. - `useChatUI()` — full chat hook with message history, streaming, and spec extraction
  143. - `useJsonRenderMessage()` — extract spec + text from a message's parts array
  144. - `buildSpecFromParts()` / `getTextFromParts()` — utilities for working with AI SDK message parts
  145. - `useBoundProp()` — two-way binding hook for `$bindState` / `$bindItem`
  146. ### New: Chat Example
  147. Full-featured chat example (`examples/chat`) with AI agent, tool calls (crypto, GitHub, Hacker News, weather, search), theme toggle, and streaming inline UI generation.
  148. ### Improved: Renderer Performance
  149. - `ElementRenderer` is now `React.memo`'d for better performance with repeat lists
  150. - `emit` is always defined (never `undefined`)
  151. - Repeat scope passes the actual item object, eliminating string token rewriting
  152. ### Improved: Utilities
  153. - `applySpecPatch()` — typed wrapper for applying a single patch to a Spec
  154. - `nestedToFlat()` — convert nested tree specs to flat format
  155. - `resolveBindings()` / `resolveActionParam()` — resolve binding paths and action params
  156. ### Breaking Changes
  157. - `{ $path }` and `{ path }` replaced by `{ $state }`, `{ $item }`, `{ $index }` in props
  158. - Visibility: `{ path }` -> `{ $state }`, `{ and/or/not }` -> `{ $and/$or }` with `not` as operator flag
  159. - `DynamicValue`: `{ path: string }` -> `{ $state: string }`
  160. - `repeat.path` -> `repeat.statePath`
  161. - Action params: `path` -> `statePath` in setState action
  162. - `actionHandlers` -> `handlers` on `JSONUIProvider` / `ActionProvider`
  163. - `AuthState` and `{ auth }` visibility conditions removed (model auth as regular state)
  164. - Legacy catalog API removed: `createCatalog`, `generateCatalogPrompt`, `generateSystemPrompt`
  165. - React exports removed: `createRendererFromCatalog`, `rewriteRepeatTokens`
  166. - Codegen: `traverseTree` -> `traverseSpec`
  167. See the [Migration Guide](/docs/migration) for detailed upgrade instructions.
  168. ---
  169. ## v0.5.0
  170. February 2026
  171. ### New: @json-render/react-native
  172. Full React Native renderer with 25+ standard components, data binding, visibility, actions, and dynamic props. Build AI-generated native mobile UIs with the same catalog-driven approach as web.
  173. ```tsx
  174. import { defineCatalog } from "@json-render/core";
  175. import { schema } from "@json-render/react-native/schema";
  176. import {
  177. standardComponentDefinitions,
  178. standardActionDefinitions,
  179. } from "@json-render/react-native/catalog";
  180. import { defineRegistry, Renderer } from "@json-render/react-native";
  181. const catalog = defineCatalog(schema, {
  182. components: { ...standardComponentDefinitions },
  183. actions: standardActionDefinitions,
  184. });
  185. const { registry } = defineRegistry(catalog, { components: {} });
  186. <Renderer spec={spec} registry={registry} />
  187. ```
  188. Includes standard components for layout (Container, Row, Column, ScrollContainer, SafeArea, Pressable, Spacer, Divider), content (Heading, Paragraph, Label, Image, Avatar, Badge, Chip), input (Button, TextInput, Switch, Checkbox, Slider, SearchBar), feedback (Spinner, ProgressBar), and composite (Card, ListItem, Modal).
  189. ### New: Event System
  190. Components now use `emit` to fire named events instead of directly dispatching actions. The element's `on` field maps events to action bindings, decoupling component logic from action handling.
  191. ```tsx
  192. // Component emits a named event
  193. Button: ({ props, emit }) => (
  194. <button onClick={() => emit("press")}>{props.label}</button>
  195. ),
  196. // Element spec maps events to actions
  197. {
  198. "type": "Button",
  199. "props": { "label": "Submit" },
  200. "on": { "press": { "action": "submit", "params": { "formId": "main" } } }
  201. }
  202. ```
  203. ### New: Repeat/List Rendering
  204. Elements can now iterate over state arrays using the `repeat` field. Child elements use `{ "$item": "field" }` to read from the current item and `{ "$index": true }` for the current array index.
  205. ```json
  206. {
  207. "type": "Column",
  208. "repeat": { "statePath": "/posts", "key": "id" },
  209. "children": ["post-card"]
  210. }
  211. ```
  212. ```json
  213. {
  214. "type": "Card",
  215. "props": { "title": { "$item": "title" } }
  216. }
  217. ```
  218. ### New: User Prompt Builder
  219. Build structured user prompts with optional spec refinement and state context:
  220. ```typescript
  221. import { buildUserPrompt } from "@json-render/core";
  222. // Fresh generation
  223. buildUserPrompt({ prompt: "create a todo app" });
  224. // Refinement (patch-only mode)
  225. buildUserPrompt({ prompt: "add a toggle", currentSpec: spec });
  226. // With runtime state
  227. buildUserPrompt({ prompt: "show data", state: { todos: [] } });
  228. ```
  229. ### New: Spec Validation
  230. Validate spec structure and auto-fix common issues:
  231. ```typescript
  232. import { validateSpec, autoFixSpec } from "@json-render/core";
  233. const { valid, issues } = validateSpec(spec);
  234. const fixed = autoFixSpec(spec);
  235. ```
  236. ### Improved: State Management
  237. `DataProvider` has been renamed to `StateProvider` with a clearer API. State is now a first-class part of specs. Elements can bind to state via `$state` expressions, and the built-in `setState` action updates state directly.
  238. ### Improved: AI Prompts
  239. Schema prompts now include streaming best practices, repeat/list examples, and state patching guidance. Schemas can also define `defaultRules` that are always included in generated prompts.
  240. ### Improved: Documentation
  241. - All documentation pages migrated to MDX
  242. - AI-powered documentation chat
  243. - Dynamic Open Graph images for all docs pages
  244. - Improved playground
  245. ### Breaking Changes
  246. - `DataProvider` renamed to `StateProvider`
  247. - `useData` renamed to `useStateStore`, `useDataValue` to `useStateValue`, `useDataBinding` to `useStateBinding`
  248. - `onAction` renamed to `emit` in component context
  249. - `DataModel` type renamed to `StateModel`
  250. - `Action` type renamed to `ActionBinding` (old name still available but deprecated)
  251. ---
  252. ## v0.4.0
  253. February 2026
  254. ### New: Custom Schema System
  255. Create custom output formats with `defineSchema`. Each renderer now defines its own schema, enabling completely different spec formats for different use cases.
  256. ```typescript
  257. import { defineSchema } from "@json-render/core";
  258. const mySchema = defineSchema((s) => ({
  259. spec: s.object({
  260. pages: s.array(s.object({
  261. title: s.string(),
  262. blocks: s.array(s.ref("catalog.blocks")),
  263. })),
  264. }),
  265. catalog: s.object({
  266. blocks: s.map({ props: s.zod(), description: s.string() }),
  267. }),
  268. }), {
  269. promptTemplate: myPromptTemplate,
  270. });
  271. ```
  272. ### New: Component Slots
  273. Components can now define which slots they accept. Use `["default"]` for regular children, or named slots like `["header", "footer"]` for more complex layouts.
  274. ```typescript
  275. const catalog = defineCatalog(schema, {
  276. components: {
  277. Card: {
  278. props: z.object({ title: z.string() }),
  279. slots: ["default"], // accepts children
  280. description: "A card container",
  281. },
  282. Layout: {
  283. props: z.object({}),
  284. slots: ["header", "content", "footer"], // named slots
  285. description: "Page layout with header, content, footer",
  286. },
  287. },
  288. });
  289. ```
  290. ### New: AI Prompt Generation
  291. Catalogs now generate AI system prompts automatically with `catalog.prompt()`. The prompt includes all component definitions, props schemas, and action descriptions - ensuring the AI only generates valid specs.
  292. ```typescript
  293. import { defineCatalog } from "@json-render/core";
  294. import { schema } from "@json-render/react/schema";
  295. const catalog = defineCatalog(schema, {
  296. components: { /* ... */ },
  297. actions: { /* ... */ },
  298. });
  299. // Generate system prompt for AI
  300. const systemPrompt = catalog.prompt();
  301. // Use with any AI SDK
  302. const result = await streamText({
  303. model: "claude-haiku-4.5",
  304. system: systemPrompt,
  305. prompt: userMessage,
  306. });
  307. ```
  308. ### New: @json-render/remotion
  309. Generate AI-powered videos with Remotion. Define video catalogs, stream timeline specs, and render with the Remotion Player.
  310. ```tsx
  311. import { Player } from "@remotion/player";
  312. import { Renderer, schema, standardComponentDefinitions } from "@json-render/remotion";
  313. const catalog = defineCatalog(schema, {
  314. components: standardComponentDefinitions,
  315. transitions: standardTransitionDefinitions,
  316. });
  317. <Player
  318. component={Renderer}
  319. inputProps={{ spec }}
  320. durationInFrames={spec.composition.durationInFrames}
  321. fps={spec.composition.fps}
  322. compositionWidth={spec.composition.width}
  323. compositionHeight={spec.composition.height}
  324. />
  325. ```
  326. Includes 10 standard video components (TitleCard, TypingText, SplitScreen, etc.), 7 transition types, and the ClipWrapper utility for custom components.
  327. ### New: SpecStream
  328. SpecStream is json-render's streaming format for progressively building specs from JSONL patches. The new compiler API makes it easy to process streaming AI responses.
  329. ```typescript
  330. import { createSpecStreamCompiler } from "@json-render/core";
  331. const compiler = createSpecStreamCompiler<MySpec>();
  332. // Process streaming chunks
  333. const { result, newPatches } = compiler.push(chunk);
  334. setSpec(result); // Update UI with partial result
  335. ```
  336. ### Improved: Dashboard Example
  337. The dashboard example is now a full-featured accounting dashboard with:
  338. - Persistent SQLite database with Drizzle ORM
  339. - RESTful API for customers, invoices, expenses, accounts
  340. - Draggable widget reordering
  341. - AI-powered widget generation with streaming
  342. - Real data binding to database records
  343. ### Improved: Documentation
  344. - Interactive playground for testing specs
  345. - New guides: Custom Schema, Streaming, Code Export
  346. - Full API reference for all packages
  347. - Integration guides: A2UI, AG-UI, Adaptive Cards, OpenAPI
  348. ### Breaking Changes
  349. - `UITree` type renamed to `Spec`
  350. - Schema is now imported from renderer packages (`@json-render/react`) not core
  351. - `defineCatalog` now requires a schema as first argument
  352. ---
  353. ## v0.3.0
  354. January 2026
  355. Internal release with codegen foundations.
  356. - Added `@json-render/codegen` package (spec traversal and JSX serialization)
  357. - Configurable AI model via environment variables
  358. - Documentation improvements and bug fixes
  359. *Note: Only @json-render/core was published to npm for this release.*
  360. ---
  361. ## v0.2.0
  362. January 2026
  363. Initial public release.
  364. - Core catalog and spec types
  365. - React renderer with contexts for data, actions, visibility
  366. - AI prompt generation from catalogs
  367. - Basic streaming support
  368. - Dashboard example application