Skip to content

Application tools

build

Deterministic static app bundles and a production preview server.

Functions:

Name Description
init_app

Create a reviewable starter project without overwriting existing files.

build_app

Build source archives, explicit lazy chunks, and a pinned browser bootstrap.

preview

Serve a built app with its base path, client-route fallback, and cache policy.

init_app

init_app(directory: Path) -> None

Create a reviewable starter project without overwriting existing files.

build_app

build_app(directory: Path, *, output: Path | None = None, base: str | None = None) -> dict[str, Any]

Build source archives, explicit lazy chunks, and a pinned browser bootstrap.

The output is replaced only after all inputs validate and a complete build succeeds. Existing output must contain Wybthon's build marker.

preview

preview(directory: Path, *, host: str = '127.0.0.1', port: int = 8000) -> None

Serve a built app with its base path, client-route fallback, and cache policy.

assets

Explicit lazy application chunks produced by wyb build.

Functions:

Name Description
load_chunk

Fetch and mount a named production chunk, sharing concurrent requests.

load_chunk async

load_chunk(name: str) -> None

Fetch and mount a named production chunk, sharing concurrent requests.

virtual

Fixed-height list virtualization built on owned virtual DOM list regions.

Classes:

Name Description
Virtualizer

Reactive visible bounds and layout dimensions, all in CSS pixels.

Functions:

Name Description
create_virtualizer

Calculate a fixed-size visible range without visiting collection items.

VirtualFor

Render only visible fixed-height rows inside a scrolling container.

Virtualizer dataclass

Virtualizer(start: Accessor[int], stop: Accessor[int], offset: Accessor[float], total: Accessor[float])

Reactive visible bounds and layout dimensions, all in CSS pixels.

create_virtualizer

create_virtualizer(count: Any, *, item_size: float, viewport_size: Any, scroll_offset: Any, overscan: int = 3) -> Virtualizer

Calculate a fixed-size visible range without visiting collection items.

VirtualFor

VirtualFor(each: Any, children: Any, *, height: float, row_height: float, overscan: int = 3, keyed: Any = True, **props: Any) -> VNode

Render only visible fixed-height rows inside a scrolling container.

Offscreen rows are disposed. Keep durable item state in the source store. Callback index accessors refer to the full collection, not the window.

scheduling

Cooperative CPU work that gives the browser opportunities to paint.

Functions:

Name Description
yield_to_browser

Yield through a timer task, allowing input and rendering between chunks.

map_cooperative

Map CPU work in bounded time slices; cancellation interrupts between slices.

yield_to_browser async

yield_to_browser() -> None

Yield through a timer task, allowing input and rendering between chunks.

map_cooperative async

map_cooperative(values: Iterable[T], fn: Callable[[T], U], *, budget_ms: float = 8) -> list[U]

Map CPU work in bounded time slices; cancellation interrupts between slices.

A single callback must itself be short. The budget limits time between callbacks, and can't preempt a long Python function.

testing

Small testing helpers that exercise the real scheduler and renderer.

Use an installed Python backend for native tests or the browser backend for Pyodide tests. The helpers never replace reactive primitives with mocks.

Functions:

Name Description
reactive_scope

Own test computations and dispose them deterministically at scope exit.

render_test

Render a fixture and release its tree, listeners, and temporary container.

tick

Drain ready asyncio continuations and flush reactive work.

wait_for

Wait for an observable condition, raising TimeoutError on failure.

reactive_scope

reactive_scope() -> Iterator[Owner]

Own test computations and dispose them deterministically at scope exit.

render_test

render_test(view: Any, container: Element | str | None = None) -> Iterator[Root]

Render a fixture and release its tree, listeners, and temporary container.

tick async

tick(rounds: int = 2) -> None

Drain ready asyncio continuations and flush reactive work.

wait_for async

wait_for(predicate: Callable[[], bool], *, timeout: float = 1, interval: float = 0.001) -> None

Wait for an observable condition, raising TimeoutError on failure.

diagnostics

Opt-in runtime counters and JSON-ready ownership graph inspection.

Profiling is disabled by default. Capture counters around a specific operation and compare work counts as well as elapsed time; these are application metrics, not cross-framework benchmark rankings.

Classes:

Name Description
Profile

Counters and elapsed seconds for a measured operation.

Functions:

Name Description
profile

Capture work performed in this scope, including explicit flush calls.

inspect_graph

Inspect ownership and dependencies without evaluating or retaining values.

runtime_stats

Return live scheduler and backend registry counts.

Profile dataclass

Profile(counts: Counter[str] = Counter(), elapsed: float = 0.0)

Counters and elapsed seconds for a measured operation.

Methods:

Name Description
as_dict

Return a serializable report.

as_dict

as_dict() -> dict[str, Any]

Return a serializable report.

profile

profile() -> Iterator[Profile]

Capture work performed in this scope, including explicit flush calls.

inspect_graph

inspect_graph(owner: Any) -> dict[str, Any]

Inspect ownership and dependencies without evaluating or retaining values.

runtime_stats

runtime_stats() -> dict[str, Any]

Return live scheduler and backend registry counts.