Runtime API
window.WF — the runtime every compiled page calls, usable from a script of your own, the console or a library's callback.
app.js opens with the runtime, and the page can reach it as window.WF. Compiled code calls it; so may a hand-written script in public/, a library's callback, or you in the browser's console:
js
WF.navigate("/about");
WF.toast("Saved", "success");
WF.storeSnapshot("Cart");
A build keeps only the modules its own code reaches, so a script calling a module nothing else uses needs "build": { "runtime": "full" } (chapter 32). Most names here are what the compiler emits for the language's features; the ones worth calling yourself are marked ●.
State — core
| Function | Does |
|---|---|
|
|
A reactive value: call it to read, |
|
|
A value computed from signals, recomputed when they change |
|
|
Runs |
|
|
Ownership: what |
|
|
A timer or listener tied to the current scope |
|
|
An element handle, filled when the element is made |
Elements and bodies — core, when, each, show, match, slot
| Function | Does |
|---|---|
|
|
Makes an element; a function attribute or child follows the signals it reads |
|
|
A text node, a component's props, live classes, animation marks |
|
|
A handler on a component's root element |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
A component's slot fill |
|
|
Fires a component's declared event |
|
|
|
Motion — motion
| Function | Does |
|---|---|
|
|
Plays an animation now; returns a handle with |
|
|
Plays an element's own animation again |
|
|
Enter and exit |
|
|
Opens or closes to the measured height |
|
|
A number that counts |
|
|
Plays when scrolled to |
|
|
An element carried across a route change |
Routing — core, router, pages
| Function | Does |
|---|---|
|
|
Moves to a route (a page load in a static build) |
|
|
The current route's parameters |
|
|
The router |
|
|
Keeps a link's |
|
|
Page chunks and their stylesheets |
|
|
Set at boot from the config |
Browser values — browser, core
viewport(), query(), hash(), now(every), network() and theme() read what the language's browser values hold; setTheme(choice) ● switches the theme.
Data — net, http, api
| Function | Does |
|---|---|
|
|
|
|
|
A request through the engine: retries, timeouts, cache, typed errors; resolves to the parsed body |
|
|
The engine's request itself |
|
|
Drops a cached answer |
|
|
A change shown now and rolled back if |
|
|
A post that survives unloading |
|
|
A service |
|
|
A socket, a stream, a channel |
|
|
A peer — module |
Stores — store, keep
| Function | Does |
|---|---|
|
|
A store, built on first read |
|
|
Drops the |
|
|
Calls |
|
|
What every store — or one — holds |
|
|
Puts a store back to what it held |
|
|
A |
Nothing is recorded while nothing is watching.
Widgets — toast, overlay, announce, field, tooltip, carousel, drawer, form
| Function | Does |
|---|---|
|
|
Shows a toast: |
|
|
Says |
|
|
What the matching built-ins compile to |
|
|
A |
Safety — core, sanitize
| Function | Does |
|---|---|
|
|
The URL where a browser may follow it, |
|
|
Markup through the allow-list |
|
|
An attribute holding JSON, as the prop it stands for |
Both safeUrl and sanitize have a build-time twin, held to one table of cases.
Text — text, format
markdown(text) ● renders the language's Markdown to HTML; highlight(code, lang) ● colours wf, json, bash or css; format(value, style, option) ● and ago(date) ● format in the locale.
Values — helpers, scalars
The list and string helpers (sortBy, groupBy, unique, take, first, last, capitalize, truncate, dedent, lines, words, range, removeAt) and the built-in types' methods (plus, minus, until, year … inZone, money, times, convert, host, path, domain, mix, lighten, darken, alpha, contrast, preview, uuid, dateOf, timeOf, urlWith, urlQuery), and caseOf(v) and payload(v) for an enum case — each a function of the value it works on.
Everything else
| Module | Functions |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
On this page
State — core Elements and bodies — core, when, each, show, match, slot Motion — motion Routing — core, router, pages Browser values — browser, core Data — net, http, api Stores — store, keep Widgets — toast, overlay, announce, field, tooltip, carousel, drawer, form Safety — core, sanitize Text — text, format Values — helpers, scalars Everything elseChecked by the test suite
Every code block in the guide is parsed, checked and type-checked on each release.