plushie/command

Command types returned from update.

Commands describe side effects that the runtime executes after update returns. The lifecycle is: update returns #(model, command), the runtime executes the command, and then calls view with the new model. Batched commands execute in list order. For no side effects, return command.none().

Types

pub type Command(msg) {
  None
  Batch(commands: List(Command(msg)))
  Done(
    value: dynamic.Dynamic,
    mapper: fn(dynamic.Dynamic) -> msg,
  )
  Async(work: fn() -> dynamic.Dynamic, tag: String)
  Stream(
    work: fn(fn(dynamic.Dynamic) -> Nil) -> dynamic.Dynamic,
    tag: String,
  )
  Cancel(tag: String)
  SendAfter(delay_ms: Int, msg: msg)
  Exit
  Renderer(RendererCommand)
}

Constructors

  • None

    No side effect.

  • Batch(commands: List(Command(msg)))

    Execute multiple commands in list order.

  • Done(value: dynamic.Dynamic, mapper: fn(dynamic.Dynamic) -> msg)

    Deliver an already-resolved value through update via the mapper.

    Note: the mapper function runs when the event is processed, which may be after further state changes. Do not capture the current model in the closure; use the model available in your update function instead.

  • Async(work: fn() -> dynamic.Dynamic, tag: String)

    Run a function on a background process. The result is delivered as an AsyncResult event identified by tag. Starting a new task with the same tag cancels the running one (single-instance per tag). Use unique tags for concurrent tasks.

  • Stream(
      work: fn(fn(dynamic.Dynamic) -> Nil) -> dynamic.Dynamic,
      tag: String,
    )

    Run a function that can emit multiple values over time. Each value is delivered as a StreamValue event identified by tag. Starting a new stream with the same tag cancels the running one.

  • Cancel(tag: String)

    Cancel a running Async or Stream task by tag.

  • SendAfter(delay_ms: Int, msg: msg)

    Deliver msg back to update after delay_ms milliseconds. Sending another SendAfter with an identical msg cancels the previous timer (deduplication via stable hashing).

  • Exit

    Shut down the runtime and close all windows.

  • Renderer(RendererCommand)

    A command that targets the renderer (widget ops, window ops, system queries, image management, effects, etc.).

Image registration and management commands.

pub type ImageCommand {
  CreateImage(handle: String, data: BitArray)
  CreateImageRgba(
    handle: String,
    width: Int,
    height: Int,
    pixels: BitArray,
  )
  UpdateImage(handle: String, data: BitArray)
  UpdateImageRgba(
    handle: String,
    width: Int,
    height: Int,
    pixels: BitArray,
  )
  DeleteImage(handle: String)
  ListImages(tag: String)
  ClearImages
}

Constructors

  • CreateImage(handle: String, data: BitArray)

    Register an image from encoded data (PNG, JPEG, etc.) under the given handle for use in image widgets.

  • CreateImageRgba(
      handle: String,
      width: Int,
      height: Int,
      pixels: BitArray,
    )

    Register an image from raw RGBA pixel data (width * height * 4 bytes) under the given handle.

  • UpdateImage(handle: String, data: BitArray)

    Update an existing image handle with new encoded data.

  • UpdateImageRgba(
      handle: String,
      width: Int,
      height: Int,
      pixels: BitArray,
    )

    Update an existing image handle with new raw RGBA pixel data.

  • DeleteImage(handle: String)

    Delete a previously registered image by its handle.

  • ListImages(tag: String)

    List all registered image handles. Result arrives as an ImageList event.

  • ClearImages

    Delete all registered images.

Politeness level for screen reader announcements. Polite is the correct choice for most toast-style feedback (saves, confirmations, counts). Assertive is reserved for urgent context that must interrupt whatever the user is currently hearing.

pub type Politeness {
  Polite
  Assertive
}

Constructors

  • Polite
  • Assertive

Commands sent to the renderer process. Organized into sub-types for window operations, system operations, and image management.

pub type RendererCommand {
  Focus(widget_id: String)
  FocusNext
  FocusPrevious
  FocusNextWithin(scope: String)
  FocusPreviousWithin(scope: String)
  SelectAll(widget_id: String)
  MoveCursorToFront(widget_id: String)
  MoveCursorToEnd(widget_id: String)
  MoveCursorTo(widget_id: String, position: Int)
  SelectRange(widget_id: String, start_pos: Int, end_pos: Int)
  ScrollTo(widget_id: String, x: Float, y: Float)
  SnapTo(widget_id: String, x: Float, y: Float)
  SnapToEnd(widget_id: String)
  ScrollBy(widget_id: String, x: Float, y: Float)
  PaneSplit(
    pane_grid_id: String,
    pane_id: String,
    axis: String,
    new_pane_id: String,
  )
  PaneClose(pane_grid_id: String, pane_id: String)
  PaneSwap(pane_grid_id: String, pane_a: String, pane_b: String)
  PaneMaximize(pane_grid_id: String, pane_id: String)
  PaneRestore(pane_grid_id: String)
  Window(WindowCommand)
  System(SystemCommand)
  Image(ImageCommand)
  NativeCommand(
    node_id: String,
    op: String,
    payload: dict.Dict(String, node.PropValue),
  )
  NativeCommands(
    commands: List(
      #(String, String, dict.Dict(String, node.PropValue)),
    ),
  )
  Effect(
    id: String,
    tag: String,
    kind: String,
    payload: dict.Dict(String, node.PropValue),
  )
  Announce(text: String, politeness: Politeness)
  LoadFont(family: String, data: BitArray)
  TreeHashQuery(tag: String)
  FindFocused(tag: String)
  AdvanceFrame(timestamp: Int)
}

Constructors

  • Focus(widget_id: String)

    Move keyboard focus to the given widget. For canvas elements, use the scoped path (e.g. “canvas/element”).

  • FocusNext

    Move focus to the next focusable widget in tab order.

  • FocusPrevious

    Move focus to the previous focusable widget in tab order.

  • FocusNextWithin(scope: String)

    Move focus to the next focusable widget within the subtree rooted at scope. Focus wraps at the subtree boundary.

  • FocusPreviousWithin(scope: String)

    Move focus to the previous focusable widget within the subtree rooted at scope. Focus wraps at the subtree boundary.

  • SelectAll(widget_id: String)

    Select all text in a text input or text editor widget.

  • MoveCursorToFront(widget_id: String)

    Move the text cursor to the beginning of the input.

  • MoveCursorToEnd(widget_id: String)

    Move the text cursor to the end of the input.

  • MoveCursorTo(widget_id: String, position: Int)

    Move the text cursor to a specific character position.

  • SelectRange(widget_id: String, start_pos: Int, end_pos: Int)

    Select a range of text between start_pos and end_pos character positions.

  • ScrollTo(widget_id: String, x: Float, y: Float)

    Scroll a scrollable widget to an absolute offset.

  • SnapTo(widget_id: String, x: Float, y: Float)

    Snap a scrollable widget to an absolute x/y offset instantly (no smooth scrolling).

  • SnapToEnd(widget_id: String)

    Snap a scrollable widget to the end of its content.

  • ScrollBy(widget_id: String, x: Float, y: Float)

    Scroll a scrollable widget by a relative x/y delta.

  • PaneSplit(
      pane_grid_id: String,
      pane_id: String,
      axis: String,
      new_pane_id: String,
    )

    Split a pane in a pane_grid widget along the given axis (“horizontal” or “vertical”), creating a new pane.

  • PaneClose(pane_grid_id: String, pane_id: String)

    Close a pane in a pane_grid widget.

  • PaneSwap(pane_grid_id: String, pane_a: String, pane_b: String)

    Swap two panes in a pane_grid widget.

  • PaneMaximize(pane_grid_id: String, pane_id: String)

    Maximize a single pane to fill the entire pane_grid.

  • PaneRestore(pane_grid_id: String)

    Restore all panes from maximized state in a pane_grid.

  • Window(WindowCommand)

    Window operation.

  • System(SystemCommand)

    System operation.

  • Image(ImageCommand)

    Image operation.

  • NativeCommand(
      node_id: String,
      op: String,
      payload: dict.Dict(String, node.PropValue),
    )

    Send a command directly to a native widget, bypassing the normal tree diff/patch cycle.

  • NativeCommands(
      commands: List(
        #(String, String, dict.Dict(String, node.PropValue)),
      ),
    )

    Send a batch of widget commands processed in one cycle.

  • Effect(
      id: String,
      tag: String,
      kind: String,
      payload: dict.Dict(String, node.PropValue),
    )

    Request a platform effect (file dialog, clipboard, notification). The tag identifies this effect in the EffectResponse event. The id is an opaque wire correlation ID, never exposed to app code.

  • Announce(text: String, politeness: Politeness)

    Announce text to screen readers via the accessibility system.

  • LoadFont(family: String, data: BitArray)

    Load a font at runtime from raw TrueType or OpenType binary data. family is the name the app uses to reference the font in default_font and widget font props.

  • TreeHashQuery(tag: String)

    Compute a SHA-256 hash of the renderer’s current tree state. Result arrives as a TreeHash event.

  • FindFocused(tag: String)

    Query which widget currently has keyboard focus. Result arrives as a FocusedWidget event.

  • AdvanceFrame(timestamp: Int)

    Advance the renderer by one frame in test/headless mode. The timestamp is monotonic milliseconds. In normal mode the renderer drives frames from display vsync.

System-wide commands not tied to a specific window.

pub type SystemCommand {
  AllowAutomaticTabbing(enabled: Bool)
  GetSystemTheme(tag: String)
  GetSystemInfo(tag: String)
}

Constructors

  • AllowAutomaticTabbing(enabled: Bool)

    Set whether the system can automatically organize windows into tabs. macOS-specific; no-op on other platforms.

  • GetSystemTheme(tag: String)

    Query the OS light/dark theme preference. Result arrives as a SystemTheme event with “light”, “dark”, or “none”. Use theme.system_theme_from_string to convert concrete preferences.

  • GetSystemInfo(tag: String)

    Query system information (OS, CPU, memory, graphics). Result arrives as a SystemInfo event with a map of system fields.

Window lifecycle and query commands.

pub type WindowCommand {
  CloseWindow(window_id: String)
  ResizeWindow(window_id: String, width: Float, height: Float)
  MoveWindow(window_id: String, x: Float, y: Float)
  MaximizeWindow(window_id: String, maximized: Bool)
  MinimizeWindow(window_id: String, minimized: Bool)
  SetWindowMode(window_id: String, mode: String)
  ToggleMaximize(window_id: String)
  ToggleDecorations(window_id: String)
  FocusWindow(window_id: String)
  SetWindowLevel(window_id: String, level: String)
  DragWindow(window_id: String)
  DragResizeWindow(window_id: String, direction: String)
  RequestUserAttention(
    window_id: String,
    urgency: option.Option(String),
  )
  Screenshot(window_id: String, tag: String)
  SetResizable(window_id: String, resizable: Bool)
  SetMinSize(window_id: String, width: Float, height: Float)
  SetMaxSize(window_id: String, width: Float, height: Float)
  EnableMousePassthrough(window_id: String)
  DisableMousePassthrough(window_id: String)
  ShowSystemMenu(window_id: String)
  SetResizeIncrements(
    window_id: String,
    width: option.Option(Float),
    height: option.Option(Float),
  )
  SetIcon(
    window_id: String,
    rgba_data: BitArray,
    width: Int,
    height: Int,
  )
  GetWindowSize(window_id: String, tag: String)
  GetWindowPosition(window_id: String, tag: String)
  IsMaximized(window_id: String, tag: String)
  IsMinimized(window_id: String, tag: String)
  GetMode(window_id: String, tag: String)
  GetScaleFactor(window_id: String, tag: String)
  RawWindowId(window_id: String, tag: String)
  MonitorSize(window_id: String, tag: String)
}

Constructors

  • CloseWindow(window_id: String)

    Close the window with the given ID.

  • ResizeWindow(window_id: String, width: Float, height: Float)

    Resize a window to the given dimensions in logical pixels.

  • MoveWindow(window_id: String, x: Float, y: Float)

    Move a window to the given screen position in logical pixels.

  • MaximizeWindow(window_id: String, maximized: Bool)

    Set whether a window is maximized or restored.

  • MinimizeWindow(window_id: String, minimized: Bool)

    Set whether a window is minimized or restored.

  • SetWindowMode(window_id: String, mode: String)

    Set window mode (e.g. “windowed”, “fullscreen”).

  • ToggleMaximize(window_id: String)

    Toggle a window between maximized and restored state.

  • ToggleDecorations(window_id: String)

    Toggle window decorations (title bar, borders).

  • FocusWindow(window_id: String)

    Give keyboard/input focus to a window, bringing it to the front.

  • SetWindowLevel(window_id: String, level: String)

    Set window stacking level (“normal”, “always_on_top”, “always_on_bottom”). May be ignored on Wayland.

  • DragWindow(window_id: String)

    Initiate a window drag operation (user moves the window).

  • DragResizeWindow(window_id: String, direction: String)

    Initiate a drag-resize from the given edge/corner direction.

  • RequestUserAttention(
      window_id: String,
      urgency: option.Option(String),
    )

    Flash the taskbar/dock icon to request user attention. Urgency is “informational” or “critical”; None clears the request.

  • Screenshot(window_id: String, tag: String)

    Capture a screenshot of a window. The result arrives as a tagged system event.

  • SetResizable(window_id: String, resizable: Bool)

    Set whether a window can be resized by the user.

  • SetMinSize(window_id: String, width: Float, height: Float)

    Set the minimum allowed size for a window in logical pixels.

  • SetMaxSize(window_id: String, width: Float, height: Float)

    Set the maximum allowed size for a window in logical pixels.

  • EnableMousePassthrough(window_id: String)

    Enable mouse passthrough so clicks pass through to windows below.

  • DisableMousePassthrough(window_id: String)

    Disable mouse passthrough, restoring normal click handling.

  • ShowSystemMenu(window_id: String)

    Show the native system menu (window controls) for a window.

  • SetResizeIncrements(
      window_id: String,
      width: option.Option(Float),
      height: option.Option(Float),
    )

    Set the resize increment size. The window will only resize in multiples of the given width/height. Pass None to clear.

  • SetIcon(
      window_id: String,
      rgba_data: BitArray,
      width: Int,
      height: Int,
    )

    Set the window icon from raw RGBA pixel data. The BitArray must be width * height * 4 bytes (R, G, B, A per pixel, row-major).

  • GetWindowSize(window_id: String, tag: String)

    Query the size of a window. Result arrives as a SystemInfo event.

  • GetWindowPosition(window_id: String, tag: String)

    Query the position of a window. Result arrives as a SystemInfo event.

  • IsMaximized(window_id: String, tag: String)

    Query whether a window is maximized. Result arrives as a SystemInfo event.

  • IsMinimized(window_id: String, tag: String)

    Query whether a window is minimized. Result arrives as a SystemInfo event.

  • GetMode(window_id: String, tag: String)

    Query the current window mode (windowed, fullscreen, hidden). Result arrives as a SystemInfo event.

  • GetScaleFactor(window_id: String, tag: String)

    Query the window’s DPI scale factor. Result arrives as a SystemInfo event.

  • RawWindowId(window_id: String, tag: String)

    Query the raw platform window ID (e.g. X11 window ID, HWND). Result arrives as a SystemInfo event.

  • MonitorSize(window_id: String, tag: String)

    Query the monitor size for the display containing a window. Result arrives as a SystemInfo event. Data is None if the monitor cannot be determined.

Values

pub fn advance_frame(timestamp: Int) -> Command(msg)

Advance the renderer by one frame in test/headless mode.

pub fn allow_automatic_tabbing(enabled: Bool) -> Command(msg)

Set whether the system can automatically organize windows into tabs. macOS-specific; no-op on other platforms.

pub fn announce(text: String) -> Command(msg)

Announce text to screen readers at polite politeness.

Polite is the correct choice for most toast-style feedback (saves, confirmations, counts). Use announce_assertive for urgent context that must interrupt whatever the user is currently hearing.

pub fn announce_assertive(text: String) -> Command(msg)

Announce text to screen readers at assertive politeness, interrupting the current announcement. Reserve for urgent context.

pub fn announce_with(
  text: String,
  politeness: Politeness,
) -> Command(msg)

Announce text to screen readers at the given politeness level.

pub fn batch(commands: List(Command(msg))) -> Command(msg)

Execute multiple commands in list order.

pub fn cancel(tag: String) -> Command(msg)

Cancel a running async or stream task by its tag.

pub fn clear_images() -> Command(msg)

Delete all registered images.

pub fn close_window(window_id: String) -> Command(msg)

Close the window with the given ID.

pub fn create_image(
  handle: String,
  data: BitArray,
) -> Command(msg)

Register an image from encoded data (PNG, JPEG, etc.) under the given handle for use in image widgets.

pub fn create_image_rgba(
  handle: String,
  width: Int,
  height: Int,
  pixels: BitArray,
) -> Command(msg)

Register an image from raw RGBA pixel data under the given handle. The pixel buffer must be exactly width * height * 4 bytes (R, G, B, A per pixel, row-major).

pub fn delete_image(handle: String) -> Command(msg)

Delete a previously registered image by its handle.

pub fn disable_mouse_passthrough(
  window_id: String,
) -> Command(msg)

Disable mouse passthrough, restoring normal click handling.

pub fn dispatch(
  value: dynamic.Dynamic,
  mapper: fn(dynamic.Dynamic) -> msg,
) -> Command(msg)

Wrap an already-resolved value and deliver it through update via the mapper function. Useful for lifting pure values into the command pipeline.

Note: the mapper function runs when the event is processed, which may be after further state changes. Do not capture the current model in the closure; use the model available in your update function instead.

pub fn drag_resize_window(
  window_id: String,
  direction: String,
) -> Command(msg)

Initiate a drag-resize from the given edge/corner direction.

pub fn drag_window(window_id: String) -> Command(msg)

Initiate a window drag operation (user moves the window).

pub fn enable_mouse_passthrough(
  window_id: String,
) -> Command(msg)

Enable mouse passthrough so clicks pass through to windows below.

pub fn exit() -> Command(msg)

Shut down the runtime and close all windows.

pub fn find_focused(tag: String) -> Command(msg)

Query which widget currently has focus. The result arrives as a tagged event.

pub fn focus(widget_id: String) -> Command(msg)

Move keyboard focus to the given widget.

pub fn focus_next() -> Command(msg)

Move focus to the next focusable widget.

pub fn focus_next_within(scope: String) -> Command(msg)

Move focus to the next focusable widget within the subtree rooted at scope. Useful for menus, pane grids, and other keyboard containers that want a bounded Tab cycle.

pub fn focus_previous() -> Command(msg)

Move focus to the previous focusable widget.

pub fn focus_previous_within(scope: String) -> Command(msg)

Move focus to the previous focusable widget within the subtree rooted at scope. See focus_next_within for semantics.

pub fn focus_window(window_id: String) -> Command(msg)

Give focus to a window, bringing it to the front.

pub fn is_maximized(
  window_id: String,
  tag: String,
) -> Command(msg)

Query whether a window is maximized. Result arrives as a SystemInfo event.

pub fn is_minimized(
  window_id: String,
  tag: String,
) -> Command(msg)

Query whether a window is minimized. Result arrives as a SystemInfo event.

pub fn is_valid_native_op(op: String) -> Bool

Returns whether a native widget operation name is safe for the wire protocol. Widget-specific allowlists live in native_widget.NativeDef.

pub fn list_images(tag: String) -> Command(msg)

List all registered image handles. Result arrives as an ImageList event.

pub fn load_font(family: String, data: BitArray) -> Command(msg)

Load a font at runtime from raw TrueType or OpenType binary data. family is the name the app uses to reference the font in default_font and widget font props.

pub fn maximize_window(window_id: String) -> Command(msg)

Maximize a window.

pub fn minimize_window(window_id: String) -> Command(msg)

Minimize a window.

pub fn monitor_size(
  window_id: String,
  tag: String,
) -> Command(msg)

Query the monitor size for the display containing a window. Result arrives as a SystemInfo event.

pub fn move_cursor_to(
  widget_id: String,
  position: Int,
) -> Command(msg)

Move the text cursor to a specific character position.

pub fn move_cursor_to_end(widget_id: String) -> Command(msg)

Move the text cursor to the end of the input.

pub fn move_cursor_to_front(widget_id: String) -> Command(msg)

Move the text cursor to the beginning of the input.

pub fn move_window(
  window_id: String,
  x: Float,
  y: Float,
) -> Command(msg)

Move a window to the given screen position.

pub fn native_command(
  node_id: String,
  op: String,
  payload: dict.Dict(String, node.PropValue),
) -> Command(msg)

Send a command directly to a native widget, bypassing the normal tree diff/patch cycle. Operation names must start with lowercase ASCII and may contain lowercase ASCII, digits, _, or :. Prefer native_widget.command when you have a NativeDef; it also checks the operation against the widget’s declared commands.

pub fn none() -> Command(msg)

No side effect. Return this from update when no command is needed.

pub fn pane_close(
  pane_grid_id: String,
  pane_id: String,
) -> Command(msg)

Close a pane in a pane_grid widget.

pub fn pane_maximize(
  pane_grid_id: String,
  pane_id: String,
) -> Command(msg)

Maximize a single pane to fill the entire pane_grid.

pub fn pane_restore(pane_grid_id: String) -> Command(msg)

Restore all panes from maximized state in a pane_grid.

pub fn pane_split(
  pane_grid_id: String,
  pane_id: String,
  axis: String,
  new_pane_id: String,
) -> Command(msg)

Split a pane in a pane_grid widget along the given axis (“horizontal” or “vertical”), creating a new pane.

pub fn pane_swap(
  pane_grid_id: String,
  pane_a: String,
  pane_b: String,
) -> Command(msg)

Swap two panes in a pane_grid widget.

pub fn raw_window_id(
  window_id: String,
  tag: String,
) -> Command(msg)

Query the raw platform window ID (e.g. X11 window ID, HWND). Result arrives as a SystemInfo event.

pub fn request_attention(
  window_id: String,
  urgency: option.Option(String),
) -> Command(msg)

Flash the taskbar/dock icon to request user attention. Urgency is “informational” or “critical”; None clears the request.

pub fn resize_window(
  window_id: String,
  width: Float,
  height: Float,
) -> Command(msg)

Resize a window to the given dimensions in logical pixels.

pub fn scale_factor(
  window_id: String,
  tag: String,
) -> Command(msg)

Query the window’s DPI scale factor. Result arrives as a SystemInfo event.

pub fn screenshot(window_id: String, tag: String) -> Command(msg)

Take a screenshot of a window. The result arrives as a tagged event.

pub fn scroll_by(
  widget_id: String,
  x: Float,
  y: Float,
) -> Command(msg)

Scroll a scrollable widget by a relative x/y delta.

pub fn scroll_to(
  widget_id: String,
  x: Float,
  y: Float,
) -> Command(msg)

Scroll a scrollable widget to an absolute x/y offset.

pub fn select_all(widget_id: String) -> Command(msg)

Select all text in the given text input widget.

pub fn select_range(
  widget_id: String,
  start_pos: Int,
  end_pos: Int,
) -> Command(msg)

Select a range of text between start_pos and end_pos character positions.

pub fn send_after(delay_ms: Int, msg: msg) -> Command(msg)

Deliver a message back to update after a delay in milliseconds. Sending another SendAfter with an identical msg replaces the previous timer.

pub fn set_icon(
  window_id: String,
  rgba_data: BitArray,
  width: Int,
  height: Int,
) -> Command(msg)

Set the window icon from raw RGBA pixel data. The BitArray must be width * height * 4 bytes (R, G, B, A per pixel, row-major).

pub fn set_max_size(
  window_id: String,
  width: Float,
  height: Float,
) -> Command(msg)

Set the maximum allowed size for a window in logical pixels.

pub fn set_min_size(
  window_id: String,
  width: Float,
  height: Float,
) -> Command(msg)

Set the minimum allowed size for a window in logical pixels.

pub fn set_resizable(
  window_id: String,
  resizable: Bool,
) -> Command(msg)

Set whether a window can be resized by the user.

pub fn set_resize_increments(
  window_id: String,
  width: option.Option(Float),
  height: option.Option(Float),
) -> Command(msg)

Set the resize increment size. The window will only resize in multiples of the given width/height. Pass None to clear.

pub fn set_window_level(
  window_id: String,
  level: String,
) -> Command(msg)

Set window stacking level (“normal”, “always_on_top”, “always_on_bottom”). May be ignored on Wayland.

pub fn set_window_mode(
  window_id: String,
  mode: String,
) -> Command(msg)

Set the window mode (e.g. “windowed”, “fullscreen”).

pub fn show_system_menu(window_id: String) -> Command(msg)

Show the native system menu (window controls) for a window.

pub fn snap_to(
  widget_id: String,
  x: Float,
  y: Float,
) -> Command(msg)

Snap a scrollable widget to an absolute x/y offset instantly (no smooth scrolling).

pub fn snap_to_end(widget_id: String) -> Command(msg)

Snap a scrollable widget to the end of its content.

pub fn stream(
  work: fn(fn(dynamic.Dynamic) -> Nil) -> dynamic.Dynamic,
  tag: String,
) -> Command(msg)

Run a function that can emit multiple values over time. Each value is delivered as a StreamValue event identified by the tag. Starting a new stream with the same tag cancels the running one.

pub fn system_info(tag: String) -> Command(msg)

Query system information (OS, CPU, memory, graphics). Result arrives as a SystemInfo event with a map of system fields.

pub fn system_theme(tag: String) -> Command(msg)

Query the OS light/dark theme preference. Result arrives as a SystemTheme event with “light”, “dark”, or “none”. Use theme.system_theme_from_string to convert concrete preferences.

pub fn task(
  work: fn() -> dynamic.Dynamic,
  tag: String,
) -> Command(msg)

Run a function asynchronously on a background process. The result is delivered as an AsyncResult event identified by the tag. Starting a new task with the same tag cancels the running one.

pub fn toggle_decorations(window_id: String) -> Command(msg)

Toggle window decorations (title bar, borders).

pub fn toggle_maximize(window_id: String) -> Command(msg)

Toggle a window between maximized and restored state.

pub fn tree_hash(tag: String) -> Command(msg)

Query the current tree hash from the renderer. The result arrives as a tagged event.

pub fn update_image(
  handle: String,
  data: BitArray,
) -> Command(msg)

Update an existing image handle with new encoded data.

pub fn update_image_rgba(
  handle: String,
  width: Int,
  height: Int,
  pixels: BitArray,
) -> Command(msg)

Update an existing image handle with new raw RGBA pixel data. The pixel buffer must be exactly width * height * 4 bytes (R, G, B, A per pixel, row-major).

pub fn widget_batch(
  commands: List(
    #(String, String, dict.Dict(String, node.PropValue)),
  ),
) -> Command(msg)

Send a batch of native widget commands processed in one cycle. Each tuple is #(node_id, op, payload). The same operation-name rule as native_command applies. A batch with any invalid operation is dropped by the encoder.

pub fn window_mode(
  window_id: String,
  tag: String,
) -> Command(msg)

Query the current window mode (windowed, fullscreen, hidden). Result arrives as a SystemInfo event.

pub fn window_position(
  window_id: String,
  tag: String,
) -> Command(msg)

Query the position of a window. Result arrives as a SystemInfo event.

pub fn window_size(
  window_id: String,
  tag: String,
) -> Command(msg)

Query the size of a window. Result arrives as a SystemInfo event.

Search Document