← all modules

Std.App

Std.App
  Std.App — the unified app builder.

Types
  type NoFallback
  type HasFallback
  type alias BaseConfig = { logFormat : Config.LogFormat , logLevel : Config.LogLevel , database : Maybe Config.Database , telemetry : Maybe Config.Telemetry }
  type Config = WebConfig WebOpts | DesktopConfig DesktopOpts | TabletConfig TabletOpts | MobileConfig MobileOpts | TerminalConfig TerminalOpts
  type alias WebOpts = { port : Int , store : Maybe String , static : Maybe String , staticUrl : Maybe String , ttl : Maybe String , idleEvict : Maybe String , maxBodyBytes : Maybe Int , inputMode : Maybe String , analytics : Maybe { pageViews : Bool } , csrf : Bool , embedded : Bool , sessionTransport : SessionTransport , name : Maybe String }
  type SessionTransport = CookieSession | HeaderToken
  type alias Running = Live.Running
  type alias TabletOpts = WebOpts
  type alias DesktopOpts = { title : String , width : Int , height : Int }
  type alias TerminalOpts = { canvasWidth : Int , canvasHeight : Int }
  type alias MobileOpts = { bundleId : String }
  type Route page
  type ViewImpl model msg
  type App fallback seed page model msg key
  type alias DurableWiring model = { enabled : Bool , setup : Task Error () , restore : String -> Task Error (Maybe model) , persist : String -> model -> Task Error () , discard : String -> Task Error () , applyRestore : Result Error (Maybe model) -> model -> model , runId : String }

Values
  address : Running -> String
      The address a [`serve`]d app is bound to, as `host:port`
  api : String -> (Request -> Task Error Response) -> Route page
      A raw HTTP endpoint alongside the TEA routes: `api "/webhook" handler`,
  apiServerRoute : Route page -> List Server.Route
      Lower an [`App`] [`Route`] to the BACKEND server routes it mounts: a raw
  app : { init : () -> ( model, Cmd msg ) , update : msg -> model -> ( model, Cmd msg ) , view : model -> Element msg , subscriptions : model -> Sub msg } -> App NoFallback () page model msg key
      Describe an app from the shared TEA core. Routing, config, and function
  baseDefaults : BaseConfig
      The built-in [`BaseConfig`] default. Record-update it (with `Sky.Config`
  cli : { init : () -> ( model, Cmd msg ) , update : msg -> model -> ( model, Cmd msg ) , view : model -> String , subscriptions : model -> Sub msg } -> App NoFallback () page model msg key
      Describe an app whose `view` returns a plain `String` — the line-oriented
  desktopDefaults : DesktopOpts
      The built-in [`DesktopOpts`] default.
  mobileDefaults : MobileOpts
      The built-in [`MobileOpts`] default.
  route : String -> page -> Route page
      A static route: `route "/about" AboutPage`.
  routeParam : String -> (String -> page) -> Route page
      A parametric route: `routeParam "/products/:slug" ProductPage`, where
  run : App fallback seed page model msg key -> Task Error ()
      The unified entry: `main = App.run app`. The build resolves `--target` and
  runCli : App fallback seed page model msg key -> Task Error ()
      Run as a line-based CLI (`--target terminal:cli`, = Sky.Cli). An [`app`]
  runLive : App HasFallback () page model msg key -> Task Error ()
      Run as server-driven HTML + SSE (`--target web`, = Sky.Live). Requires a
  runLiveWindow : App HasFallback () page model msg key -> Task Error ()
      Run as **Sky.Live in a native window** (`--target desktop`): serve the Live
  runSpa : App fallback seed page model msg key -> Task Error ()
      Run as a client wasm SPA (`--target web:app` / `mobile:*` / `tablet:*`,
  runTui : App fallback seed page model msg key -> Task Error ()
      Run as a full-screen terminal UI (`--target terminal:tui`, = Sky.Tui).
  runWebview : App fallback () page model msg key -> Task Error ()
      Run as a native desktop window (`--target desktop:<os>` is native wasm; this
  serve : App HasFallback () page model msg key -> Task Error Running
      Start a `web` app and return once it is listening, with a handle to stop
  spaRoute : Route page -> List Spa.Route
      Lower an [`App`] [`Route`] to a `Sky.Spa` route (same erasure as Live).
  stop : Running -> Task Error ()
      Stop a [`serve`]d app. The listener stops accepting, the app's open live
  tabletDefaults : TabletOpts
      The built-in [`TabletOpts`] default (= [`webDefaults`]).
  terminalDefaults : TerminalOpts
      The built-in [`TerminalOpts`] default.
  tui : { init : () -> ( model, Cmd msg ) , update : msg -> model -> ( model, Cmd msg ) , view : model -> String , subscriptions : model -> Sub msg } -> App NoFallback () page model msg key
      Describe an app whose `view` returns a plain `String`, rendered full-screen
  web : { init : () -> ( model, Cmd msg ) , update : msg -> model -> ( model, Cmd msg ) , view : model -> Html msg , subscriptions : model -> Sub msg } -> App NoFallback () page model msg key
      Describe an app whose `view` returns `Std.Html.Html` (not a `Std.Ui`
  webDefaults : WebOpts
      The built-in [`WebOpts`] default.
  withAppUrl : String -> App fallback seed page model msg key -> App fallback seed page model msg key
      Set the backend address the NATIVE shells load: `mobile:ios`,
  withBase : BaseConfig -> App fallback seed page model msg key -> App fallback seed page model msg key
      Attach the cross-target [`BaseConfig`] (log, database, telemetry).
  withClientCrypto : App fallback seed page model msg key -> App fallback seed page model msg key
      Keep end-to-end key material on the device, on the client targets
  withConfig : Config -> App fallback seed page model msg key -> App fallback seed page model msg key
      Attach a per-target [`Config`] variant. Call once per customised target;
  withConsoleAuth : (Request -> model -> Task Error (Maybe Console.Identity)) -> App fallback seed page model msg key -> App fallback seed page model msg key
      Let the app's own signed-in users open the Sky Console (`/_sky/console`)
  withDurable : Db -> Codec model -> App fallback seed page model msg key -> App fallback seed page model msg key
      Make the app DURABLE with zero changes to `model` / `msg` / `update`: the
  withDurableId : String -> Db -> Codec model -> App fallback seed page model msg key -> App fallback seed page model msg key
      `withDurable` with an explicit run id (for the terminal backends, which have
  withEmbedded : App fallback seed page model msg key -> App fallback seed page model msg key
      Run a `web` (Sky.Live) app as ONE task inside a larger Task program:
  withGuard : (msg -> model -> Result Error ()) -> App fallback seed page model msg key -> App fallback seed page model msg key
      Attach a per-Msg guard — `guard msg model` returns `Err` to reject the
  withHead : (model -> List (Html msg)) -> App fallback seed page model msg key -> App fallback seed page model msg key
      Set the document `<head>` builder (web/desktop targets → `Live.withHead`).
  withInput : (String -> msg) -> App fallback seed page model msg key -> App fallback seed page model msg key
      Wire a line/text input handler (terminal targets). The payload is the
  withName : String -> App fallback seed page model msg key -> App fallback seed page model msg key
      Name the session namespace of an app started with [`serve`]. Two apps
  withNotFound : page -> App fallback seed page model msg key -> App HasFallback seed page model msg key
      Set the fallback page for an unmatched route (web targets).
  withOnKey : (key -> msg) -> App fallback seed page model msg key -> App fallback seed page model msg key
      Attach a raw key-event handler (terminal target → `Tui.withOnKey`). The
  withOnNavigate : (page -> msg) -> App fallback seed page model msg key -> App fallback seed page model msg key
      Wire a navigation handler — `onNavigate page` yields a `msg` when the app
  withRequest : (Request -> model -> ( model, Cmd msg )) -> App fallback () page model msg key -> App fallback () page model msg key
      Give a WEB app the incoming HTTP request at session start —
  withRoutes : List (Route page) -> App fallback seed page model msg key -> App fallback seed page model msg key
      Attach URL routes (web targets), built with [`route`] / [`routeParam`].
  withRpcError : (Error -> msg) -> App fallback seed page model msg key -> App fallback seed page model msg key
      Route a FAILED RPC into your own `update`. On the `web:app` (Sky.Spa)
  withSessionTransport : SessionTransport -> App fallback seed page model msg key -> App fallback seed page model msg key
      Carry the Sky.Live session id in a header instead of a cookie:
  withWindow : String -> Int -> Int -> App fallback seed page model msg key -> App fallback seed page model msg key
      Set the desktop window title + initial size (desktop targets). Shorthand