Vectrune documentationAlpha referenceLearning site ↗

Rune-Web commands

Commands registered in the frontend command dispatcher.

--

<path>-- or decrement <path> by <value> or dec <path> by <value>

Decrements a numeric value at the given path.

Runtime: Rune-Web

Aliases: decrement, dec

Returns / effects

Command-specific value or state mutation as described by its signature.

Errors / edge cases

An unmatched command form is not handled. These commands do not return HTTP status codes.

Implementation: runtime/rune-web/src/builtins/decrement.ts

avg

avg <arrayPath> as <var>

Computes average of numeric array values.

Runtime: Rune-Web

Returns / effects

Arithmetic mean after numeric coercion. Requires a nonempty array.

Errors / edge cases

An unmatched command form is not handled. These commands do not return HTTP status codes.

Implementation: runtime/rune-web/src/builtins/avg.ts

clone

clone <srcPath> to <destPath>

Deep‑copies a value from source to destination.

Runtime: Rune-Web

Returns / effects

JSON deep copy; use the to form to write it to a destination.

Errors / edge cases

An unmatched command form is not handled. These commands do not return HTTP status codes.

Implementation: runtime/rune-web/src/builtins/clone.ts

computed:

@Logic/<name> -> computed: <name> = <expr>

Ordered reactive derived properties memoized against state revisions in @Logic.

Runtime: Rune-Web browser runtime and logic test runner

Returns / effects

Computed values available in views, actions, and `derived.<name>` in logic tests.

Errors / edge cases

Evaluation errors yield undefined for the computed key without crashing render.

Example
@Logic/editor
computed:
    frame_count = frames.length
    active_frame = frames[active_frame_index]
    can_undo = history.can_undo

Implementation: src/apps/rune_web/ast.rs · src/apps/rune_web/parser.rs · src/apps/rune_web/jscodegen.rs · runtime/rune-web/src/logic.ts · examples/rune-web/model_studio/parts/logic/state.rune

count

count <path> as <var>

Stores the length of an array or object keys count into a variable.

Runtime: Rune-Web

Returns / effects

Array length or object key count; other values produce zero.

Errors / edge cases

An unmatched command form is not handled. These commands do not return HTTP status codes.

Implementation: runtime/rune-web/src/builtins/count.ts

data-rune-map

data-rune-map=<key> data-latitude=<lat> data-longitude=<lon> data-map-select=<action>

Render an interactive OpenStreetMap tile map in a Rune-Web element.

Runtime: Rune-Web

Returns / effects

Calls the named action with {latitude, longitude} when a point is selected.

Errors / edge cases

Invalid coordinates, duplicate keys or initialization failures are reported in the browser console.

Example
div .map data-rune-map=weather data-latitude="{latitude}" data-longitude="{longitude}" data-map-select=chooseMap

Implementation: runtime/rune-web/src/map.ts

delay

delay <duration>ms

Pauses execution for a given number of milliseconds.

Runtime: Rune-Web

Returns / effects

Blocks synchronously for the duration. Bare numbers and ms use milliseconds; s uses seconds.

Errors / edge cases

Malformed duration is not handled. The implementation busy-waits and blocks the UI; avoid long delays.

Implementation: runtime/rune-web/src/builtins/delay.ts

delete

delete <path>

Deletes a value at the given path from locals.

Runtime: Rune-Web

Aliases: del, rm, remove, rmv, destroy

Returns / effects

Removes a value at the supplied path from frontend state/locals.

Errors / edge cases

An unmatched command form is not handled. These commands do not return HTTP status codes.

Implementation: runtime/rune-web/src/builtins/delete.ts

fetch

fetch <url> [options <binding>] then <action> [catch <action>]

HTTP GET; calls the action with { status, ok, url, content_type, body }.

Runtime: Rune-Web

Returns / effects

Command-specific value or state mutation as described by its signature.

Errors / edge cases

An unmatched command form is not handled. These commands do not return HTTP status codes.

Implementation: runtime/rune-web/src/builtins/fetch.ts

fetch-json

fetch-json <url> [options <binding>] then <action> [catch <action>]

HTTP GET; calls the action with the parsed JSON, or the catch action on failure.

Runtime: Rune-Web

Returns / effects

Command-specific value or state mutation as described by its signature.

Errors / edge cases

An unmatched command form is not handled. These commands do not return HTTP status codes.

Implementation: runtime/rune-web/src/builtins/fetch.ts

flatten

flatten <arrayPath> as <var>

Flattens a nested array into a one‑dimensional array.

Runtime: Rune-Web

Returns / effects

New recursively flattened array; nested arrays of any depth are expanded.

Errors / edge cases

An unmatched command form is not handled. These commands do not return HTTP status codes.

Implementation: runtime/rune-web/src/builtins/flatten.ts

history

history.checkpoint(keys, max?) | history.capture(keys) | history.push(entry, max?) | history.undo() | history.redo() | history.clear()

Built-in undo/redo state snapshot manager for Rune-Web applications and editors.

Runtime: Rune-Web browser runtime and logic test runner

Returns / effects

Exposes reactive readouts `history.can_undo`, `history.can_redo`, `history.undo_count`, and `history.redo_count`.

Errors / edge cases

Undo/redo on an empty stack is a safe no-op returning false.

Example
history.checkpoint(["frames", "palette"], 40)
history.undo()
history.redo()

Implementation: runtime/rune-web/src/history.ts · runtime/rune-web/src/statement.ts · runtime/rune-web/src/scope.ts · examples/rune-web/model_studio/parts/logic/editor.rune

increment

<path>++ | increment <path> by <number> | inc <path> by <number>

Increments a numeric value at the given path.

Runtime: Rune-Web

Aliases: inc, ++

Returns / effects

Updates the path and returns its new numeric value. Postfix ++ adds one.

Errors / edge cases

An unmatched command form is not handled. These commands do not return HTTP status codes.

Implementation: runtime/rune-web/src/builtins/increment.ts

invert

invert <path>

Inverts a boolean value at the given path.

Runtime: Rune-Web

Returns / effects

Negates the current truth value and stores the new boolean at the path.

Errors / edge cases

An unmatched command form is not handled. These commands do not return HTTP status codes.

Implementation: runtime/rune-web/src/builtins/invert.ts

list.slice

list.slice <array> <start> [end] [as <var>]

Return a shallow subarray slice from start to optional end index.

Runtime: Rune-Web

Returns / effects

Command-specific value or state mutation as described by its signature.

Errors / edge cases

An unmatched command form is not handled. These commands do not return HTTP status codes.

Implementation: runtime/rune-web/src/builtins/str_list.ts

list.sort-by

list.sort-by <array> <field> [asc|desc] [as <var>]

Return a new array sorted by a numeric or string object field.

Runtime: Rune-Web

Returns / effects

Command-specific value or state mutation as described by its signature.

Errors / edge cases

An unmatched command form is not handled. These commands do not return HTTP status codes.

Implementation: runtime/rune-web/src/builtins/str_list.ts

location.current

location.current then <action> [catch <action>]

Request the browser's current device position.

Runtime: Rune-Web

Returns / effects

Calls the success action with {latitude, longitude, accuracy, timestamp}.

Errors / edge cases

The optional catch action receives {code, message} for denied, unavailable or timed-out location; otherwise a warning is logged.

Example
location.current then showLocation catch locationFailed

Implementation: runtime/rune-web/src/builtins/location.ts

location.current

location.current then <action> [catch <action>]

Request the browser location, prompting for permission if necessary.

Runtime: Rune-Web

Returns / effects

Calls the success action with latitude, longitude, accuracy and timestamp.

Errors / edge cases

Calls the optional catch action on failure; otherwise logs a warning.

Implementation: runtime/rune-web/src/builtins/location.ts

location.if-granted

location.if-granted then <action> [catch <action>]

Request browser location only when permission is already granted.

Runtime: Rune-Web

Returns / effects

Calls the success action with {latitude, longitude, accuracy, timestamp}.

Errors / edge cases

The catch action receives {code, message}, including prompt, denied, unavailable or timeout; otherwise a warning is logged.

Example
location.if-granted then showLocation catch locationFailed

Implementation: runtime/rune-web/src/builtins/location.ts

location.if-granted

location.if-granted then <action> [catch <action>]

Request the browser location only when permission is already granted.

Runtime: Rune-Web

Returns / effects

Calls the success action with latitude, longitude, accuracy and timestamp.

Errors / edge cases

Calls the optional catch action if permission is not granted or location fails; otherwise logs a warning.

Implementation: runtime/rune-web/src/builtins/location.ts

log

log <expression>

Logs the interpolated expression to the console.

Runtime: Rune-Web

Returns / effects

Writes the evaluated message to the host console.

Errors / edge cases

An unmatched command form is not handled. These commands do not return HTTP status codes.

Implementation: runtime/rune-web/src/builtins/log.ts

max

max <arrayPath> as <var>

Finds maximum numeric value in an array.

Runtime: Rune-Web

Returns / effects

Maximum after numeric coercion. Requires a nonempty array.

Errors / edge cases

An unmatched command form is not handled. These commands do not return HTTP status codes.

Implementation: runtime/rune-web/src/builtins/max.ts

min

min <arrayPath> as <var>

Finds minimum numeric value in an array.

Runtime: Rune-Web

Returns / effects

Minimum after numeric coercion. Requires a nonempty array.

Errors / edge cases

An unmatched command form is not handled. These commands do not return HTTP status codes.

Implementation: runtime/rune-web/src/builtins/min.ts

parse-json

x = parse-json <expr>

Parses a JSON string and returns the value.

Runtime: Rune-Web

Returns / effects

Command-specific value or state mutation as described by its signature.

Errors / edge cases

An unmatched command form is not handled. These commands do not return HTTP status codes.

Implementation: runtime/rune-web/src/builtins/parse_json.ts

pixel3d.draw

pixel3d.draw(view_id, scene)

Generic Pixel-3D preview canvas widget with orbit/zoom, analytic face/floor raycasting, 3D move/resize gizmos, and hover placement wireframes.

Runtime: Rune-Web browser runtime

Parameters

view_id
Matches `data-pixel3d-view` on the target canvas.
scene
Scene specification with width, height, camera, grid, axes, glow, gizmo, place_preview, hud, and models.

Returns / effects

Draws the scene onto `<canvas data-pixel3d-view="<view_id>">` and updates `[data-pixel3d-hud]` text without replacing DOM nodes.

Errors / edge cases

Resolution is clamped to 80..1920 x 60..1200.

Example
canvas data-pixel3d-view=main data-pixel3d-orbit=onOrbit data-pixel3d-hit=onHit data-pixel3d-gizmo=onGizmo
pixel3d.draw("main", scene)

Implementation: runtime/rune-web/src/pixel3d_view.ts · runtime/rune-web/src/morph.ts · runtime/rune-web/tests/pixel3d_view.test.ts · examples/rune-web/model_studio/parts/logic/viewport.rune

push

push <path> <valueExpression>

Pushes a value onto the array at the given path.

Runtime: Rune-Web

Returns / effects

Appends a value and writes the array back to its state path.

Errors / edge cases

An unmatched command form is not handled. These commands do not return HTTP status codes.

Implementation: runtime/rune-web/src/builtins/push.ts

randomize

randomize <min> <max> as <var> | randomize <arrayPath> as <var>

Generates a random number in a range or shuffles an array.

Runtime: Rune-Web

Returns / effects

An inclusive random integer for numeric bounds, or a shuffled copy of an array.

Errors / edge cases

An unmatched command form is not handled. These commands do not return HTTP status codes.

Implementation: runtime/rune-web/src/builtins/randomize.ts

start-timer

start-timer <action> <duration>ms

Starts a periodic timer calling the named action.

Runtime: Rune-Web

Aliases: interval

Returns / effects

Starts the app periodic timer calling the named action; not a returned timer ID.

Errors / edge cases

An unmatched command form is not handled. These commands do not return HTTP status codes.

Implementation: runtime/rune-web/src/builtins/timer.ts

stop

stop

Stops execution of the current script.

Runtime: Rune-Web

Returns / effects

Stops the current action statement sequence.

Errors / edge cases

An unmatched command form is not handled. These commands do not return HTTP status codes.

Implementation: runtime/rune-web/src/builtins/stop.ts

stop-timer

stop-timer

Stops the active periodic timer.

Runtime: Rune-Web

Aliases: clear-timer, clear-interval

Returns / effects

Stops the app active periodic timer.

Errors / edge cases

An unmatched command form is not handled. These commands do not return HTTP status codes.

Implementation: runtime/rune-web/src/builtins/timer.ts

str.contains

str.contains <haystack> <needle> [as <var>]

Check whether a string contains a substring.

Runtime: Rune-Web

Returns / effects

Command-specific value or state mutation as described by its signature.

Errors / edge cases

An unmatched command form is not handled. These commands do not return HTTP status codes.

Implementation: runtime/rune-web/src/builtins/str_list.ts

str.join

str.join <array> [separator] [as <var>]

Join array elements into a single string with an optional separator.

Runtime: Rune-Web

Returns / effects

Command-specific value or state mutation as described by its signature.

Errors / edge cases

An unmatched command form is not handled. These commands do not return HTTP status codes.

Implementation: runtime/rune-web/src/builtins/str_list.ts

str.lower

str.lower <expr> [as <var>]

Convert a value to a lowercase string.

Runtime: Rune-Web

Returns / effects

Command-specific value or state mutation as described by its signature.

Errors / edge cases

An unmatched command form is not handled. These commands do not return HTTP status codes.

Implementation: runtime/rune-web/src/builtins/str_list.ts

str.split

str.split <text> [separator] [as <var>]

Split a string on whitespace or an explicit separator into an array.

Runtime: Rune-Web

Returns / effects

Command-specific value or state mutation as described by its signature.

Errors / edge cases

An unmatched command form is not handled. These commands do not return HTTP status codes.

Implementation: runtime/rune-web/src/builtins/str_list.ts

str.trim

str.trim <expr> [as <var>]

Remove leading and trailing whitespace from a string.

Runtime: Rune-Web

Returns / effects

Command-specific value or state mutation as described by its signature.

Errors / edge cases

An unmatched command form is not handled. These commands do not return HTTP status codes.

Implementation: runtime/rune-web/src/builtins/str_list.ts

sum

sum <arrayPath> as <var>

Sums numeric values in an array and stores the result.

Runtime: Rune-Web

Returns / effects

Sum after numeric coercion; the empty array produces zero.

Errors / edge cases

An unmatched command form is not handled. These commands do not return HTTP status codes.

Implementation: runtime/rune-web/src/builtins/sum.ts

swap

swap <path> <A> <B>

Swaps the values of A and B at path.

Runtime: Rune-Web

Returns / effects

With A and B: switches the target between those values. With one value: assigns it.

Errors / edge cases

An unmatched command form is not handled. These commands do not return HTTP status codes.

Implementation: runtime/rune-web/src/builtins/swap.ts

to-json

to-json <expr> [as <var>]

Serialize a value to a JSON string.

Runtime: Rune-Web

Returns / effects

Command-specific value or state mutation as described by its signature.

Errors / edge cases

An unmatched command form is not handled. These commands do not return HTTP status codes.

Implementation: runtime/rune-web/src/builtins/str_list.ts

unique

unique <arrayPath> as <var>

Removes duplicate entries from an array.

Runtime: Rune-Web

Returns / effects

New array with JavaScript Set uniqueness semantics; objects compare by identity.

Errors / edge cases

An unmatched command form is not handled. These commands do not return HTTP status codes.

Implementation: runtime/rune-web/src/builtins/unique.ts

watch

watch key1, key2: <steps>

Declarative reactive side-effect hook that runs when any watched state or computed key changes.

Runtime: Rune-Web browser runtime and logic test runner

Returns / effects

Executes watcher steps once after a top-level action changes watched keys.

Errors / edge cases

Re-entrancy guarded to prevent recursive watcher loops.

Example
watch frames, palette, tool_mode:
    call renderViewport

Implementation: src/apps/rune_web/ast.rs · src/apps/rune_web/parser.rs · runtime/rune-web/src/logic.ts · examples/rune-web/model_studio/parts/logic/state.rune