GizStack
View .mdOpen in ChatGPTOpen in Claude

gizapp/host

A GizApp app run as a program: the app serves its pages on a Unix socket of this run (Application.at), which no other program sees as a port, and one front end shows them until it ends: tui.giz on a terminal's whole screen, window.giz in a window of the desktop. The program ends with the front end's code. The app does not know its front end, and a front end does not know the app: the program's main joins the two (desk/main.giz, browser-app/main.giz).

gizlang
import * as Host from "gizapp/host";

Types

Site

gizlang
type Site = { name: string; socket: string; path: string; }

Where a front end finds the app of this run: giz://NAME on SOCKET, first at PATH ("/" for its first page).

  • name: string
  • socket: string
  • path: string

Functions

run

gizlang
function run<F>(make: () => Pages.Application, name: string, path: string, front: F): i64

Serves the app MAKE makes, named NAME, on a socket of this run, and runs the front end FRONT, (site: Site) => i64, once it listens; the program ends with FRONT's code. FRONT runs on a thread of its own with its own System: generic, so the thread sees what it captures (an erased function may hold the spawner's state, and a thread may not). A program started as a renderer of one of its windows' views runs that, not the app.

close

gizlang
function close(code: i64): void

Ends the run from the app (a chooser's choice, from an action on a server thread): the front end then ends the program with CODE.

Effects: fail, io, alloc.

closing

gizlang
function closing(): i64

The code the app asked to end the run with (close), or -1 while it asked none. A front end reads it each turn.

Effects: fail, io, alloc.

socketOf

gizlang
function socketOf(name: string): string

The socket the app NAME serves on in this run: in the user's runtime folder (XDG_RUNTIME_DIR, which only the user reaches), else in the temporary folder. Two runs have two: apps that share data share their GizDB folder.

Effects: fail, io, alloc.

networkOf

gizlang
function networkOf(site: Site): Network

A network that reaches SITE as giz://NAME, and the web. Its cookies (the page's choices: model, language, theme, and its sign-in) last between runs, in the person's state folder (XDG_STATE_HOME, else ~/.local/state: gizapp/NAME.cookies).

Effects: fail, read, write, console, io, alloc.