a post-component library for building user-interfaces on the web.
1export { html, keyed, type Displayable, type HTML, type Renderable } from './shared.ts'
2
3import { is_html } from './shared.ts'
4
5if (__DEV__) {
6 type JsonML = string | readonly [tag: string, attrs?: Record<string, any>, ...children: JsonML[]]
7 interface Formatter {
8 header(value: unknown): JsonML | null
9 hasBody(value: unknown): boolean
10 body?(value: unknown): JsonML | null
11 }
12
13 ;((globalThis as { devtoolsFormatters?: Formatter[] }).devtoolsFormatters ??= []).push({
14 header(value) {
15 if (!is_html(value)) return null
16
17 const children: JsonML[] = []
18 for (let i = 0; i < value._dynamics.length; i++)
19 children.push(value._statics[i], ['object', { object: value._dynamics[i] }])
20 children.push(value._statics[value._statics.length - 1])
21
22 return ['span', {}, 'html`', ...children, '`']
23 },
24 hasBody() {
25 return false
26 },
27 })
28}