Playground
JSON has no dates and no symbols. The page reads {"$date": "2026-11-03"} as a Date, and a key "$type" as the TYPE_SYMBOL of its object.
The layout helpers, live
A viewer gets a size, and gives sizes to its children. Three helpers calculate the boxes. Drag the corner of the container, or move the sliders.
How dispatch works
The core is about 200 lines of TypeScript with no dependencies. Each call of dispatch does these four steps.
-
1
Find the type
inferType(data)gives"null","undefined","function"or thetypeofof a primitive. For an object, the value of itsTYPE_SYMBOLcomes first, then"array","date"and"object". -
2
Find the viewer
registry.get(type)gives the viewer of that type. A registry is a map from a type to a viewer. -
3
No viewer? Use the fallback
With no viewer,
dispatchgivesfallback(type, data), orundefinedwhen the config has no fallback. Turn off a viewer above to see it. -
4
Call the viewer
The viewer gets
ctx:data,size,path,depthandrender.ctx.render(child, size, path)starts step 1 again for each nested value.
API
The page runs each example with the package, and shows the result. size and box are { width: 300, height: 100 }.
Install
Add the package
pnpm add @mark1russell7/splay
Use it
Splay is part of client: its procedure results render with splay.
text-viewers.ts: the plain string viewers of this page