Authoring Surface
Public v0.1 TSX primitives and list syntax.
v0.1 keeps the public authoring API intentionally small. The compiler accepts a narrow TSX subset and reports structured diagnostics for patterns outside that subset.
Public Primitives
| Primitive | Purpose |
|---|---|
state() | Writable local state with accessor, setter, and updater methods. |
computed() | Read-only derived value tracked by the compiler/runtime helpers. |
effect() | Lifecycle-aware side effect with cleanup support. |
event() | Typed CustomEvent dispatch helper. |
on() | Typed DOM listener helper with listener options. |
host() | Current custom element and abort signal inside lifecycle work. |
Show | Static-analysis-friendly conditional rendering. |
Use state() for writable local state. Function props, component options, and
host lifecycle access use normal TypeScript exports and the primitives above.
Events And Listeners
Events dispatch native CustomEvent instances. In the current MVP, generated
events use bubbles: true, composed: true, and cancelable: false.
Listener options belong on on().
const changed = event<boolean>("toggle-change")
return (
<button
onClick={on(
"click",
() => changed.emit(true),
{ passive: true }
)}
/>
)event(name) creates the typed emitter. on(type, handler, listenerOptions)
configures DOM listeners. The handler's second argument is an AbortSignal
that aborts on listener re-entry or host disconnect. Event option code
generation is a later milestone.
Keyed Lists
Dynamic lists use a narrow typed .map() form:
return (
<ul>
{items().map((item) => (
<li key={item.id}>{item.label}</li>
))}
</ul>
)key is required. The compiler lowers accepted map expressions into keyed list
IR and rejects unsupported block bodies, arbitrary list expressions, unkeyed
maps, and non-JSX map returns.
Component Composition
Imported PascalCase component references compile to native kebab-case Custom Element tags. The public output remains platform DOM; Naos does not install a component runtime or virtual DOM reconciler.