Skip to content

Application tools

Build, asset, virtual list, scheduling, and diagnostics helpers. Import virtual lists from wybthon.virtual and scheduling helpers from wybthon.scheduling; neither is re-exported from wybthon. The test renderer has its own page.

build

Deterministic static app bundles, prerendered pages, 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, dev: bool = False) -> 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. A production build (the default) turns dev mode off before the application imports; wyb dev builds with dev=True.

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.

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.

inspect_transitions

Explain pending publication without reading values or mutating the graph.

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.

inspect_transitions

inspect_transitions() -> list[dict[str, Any]]

Explain pending publication without reading values or mutating the graph.

IDs match inspect_graph. A group is ready once its action count and pending computations are empty. Held applies identify consumers whose prepared results haven't reached the DOM or an effect yet.

runtime_stats

runtime_stats() -> dict[str, Any]

Return live scheduler and backend registry counts.