Native targets, an early proof

2 min·Assumes: state, events

Markless is built to compile one web-like
to any device. Today the web ships; iOS and macOS are early proofs.
import { state } from '@markless/core';

export function Counter() @{
	let count = state(0);

	<button onClick={() => count++}>Count {count}</button>
}

This is the proof's real source. <button> becomes a native UIButton on iOS and an NSButton on macOS, and onClick runs in JavaScriptCore when you tap it.

The views are native, not a web page

Press Debug View Hierarchy, then search the layers for WebView:

A pen-and-ink drawing of an iPhone running the early Markless proof, showing a native label, Markless iOS Proof, and a native button. Beside it is Xcode's Debug View Hierarchy button. Press it, or D, and the screen comes apart into its real layers from the proof's code: UIWindow, UIView, UIStackView, UILabel and UIButton, each named beside it. Type in the search box to find a layer; WebView finds 0 results, because there is no web view. Tap the phone's button, or press T, and the native button sets its own title. Three greyed outlines, Android, Windows and Linux, are marked not started. Escape starts again.

An iPhone running the early Markless proof: a native label and a native button. Press Debug View Hierarchy to look inside.

  • The layers are the proof's own views: UIWindow, UIView, UIStackView, UILabel, UIButton.
  • There is no WKWebView anywhere, and a check script in the proof makes sure of it.
  • Tapping the button runs the handler, and the native button sets its own title.

How the proof works today

The plan the proof runs, its artifact.json, is written by hand. It lists the state, the views, the event and the text binding:

{
	"node": "host:button",
	"authoredEvent": "onClick",
	"semanticEvent": "activate",
	"nativeEvent": "touchUpInside",
	"symbolId": "symbol:counter.increment"
}

Not yet:

  • The compiler doesn't write artifact.json. Both proofs live in poc/fixtures/proofs/.
  • They don't use @markless/runtime, and don't cover styling, lists, navigation or packaging.
  • Android, Windows and Linux are not started.

Want a device sooner? Contributing shows where to start.