What the compiler writes
import { state } from '@markless/core';
export default function Chat() @{
let draft = state('Hi');
<>
<p>Typing: {draft}</p>
<input
onInput={(e) => (draft = e.target.value)}
/>
</>
}draft becomes the node state:draft. {draft} becomes symbol:1, a small function that sets that one line's text when draft changes. onInput becomes symbol:0.
Every line becomes named pieces
A symbol is one small function with a stable ID, in a module of its own:
- each
state()becomes a node, likestate:draft - each handler becomes a symbol, like
symbol:0 - each spot that shows a value becomes an update symbol, like
symbol:1
Each colour joins a span of the source to the piece it became. Hover one, then press Edit and change the code. The compiler runs in your browser:
- import { state } from '@markless/core';
- export default function Chat() @{
- let draft = state('Hi');
- <>
- <p>Typing: {draft}</p>
- <input
- onInput={(e) => (draft = e.target.value)}
- />
- </>
- }
… 0 more lines
state:drafta watched valuesymbol:1updates the <p>symbol:0runs on input… and 0 more
Doesn’t compile yet:
The chat box compiles to three pieces: state:draft, symbol:1 for the text update, and symbol:0 for the input handler.
- Each piece points back at the line it came from.
- Change
state('Hi')to a plain'Hi': the node and its update disappear, and the build names the handler that still writes it.
The pieces are planned by a chain of passes
A pass is one small step with named inputs and outputs. The first one runs the analyzer and writes the semantic graph: every value, element, read and write in the file. The 16 passes, in the order they run:
tsrx-semantic-graphReads the file into the semantic graph.state-loweringTurns state reads and writes into graph reads and writes.payload-arenaPlans the state record and the view record.symbol-resolverPlans one symbol per handler and per update.render-dataSplits the elements into fixed HTML and the slots that change.projection-armsFinds the {children} a redrawn @if, @switch or @try arm would freeze.public-render-planCollects scoped styles and decides what the render modules can write.capture-analysisChecks that each symbol reads only what can cross to the browser.protocol-stateWrites the state record.protocol-viewWrites the view record, with symbol IDs on each entry.public-render-moduleWrites the browser and server render modules.server-only-propsStops the compile if browser code reads a prop the server keeps to itself.payload-scriptsWrites the markless/state and markless/view script tags.symbol-modulesWrites one module per symbol.runtime-demand-mapLists the runtime code each symbol and record needs.trigger-groupsGroups each event with the state, records and symbols it touches.symbol-resolver-moduleWrites the module that loads symbols by ID.
For a component this simple, the browser module is a direct module: it keeps state:draft in a plain Map and puts the listener on the input itself. Props, child components, a scoped <style> or a computed() send a component down the general path instead.
The payload shows what a server sends with these pieces.