Skip to content

Docs menu // Reference

[ DOCS ] /docs/sdk

SDK reference

The functions and types a script can import. This reference is generated when the site is built from the declaration files (.eith) in /eitri/sdk/, the same files the console's Docs tab shows, so it always matches what the console offers.

Modules#

ImportWhat it is forFunctions
siteThe page, its content and the actions, events and data scripts plug into.13
site/themeThe look: accent colour, weather, grid, glow and screen effects.11
site/fxOne-shot effects: glitch, shake, flash, sparks, scan, decode and typeout.7
site/uiToasts, the banner, and prompts that use the command palette.5
site/keysKey bindings, sequences and modes, in the style of rex.bind.5
site/timeTimers: after, every and cancel.3
site/soundSmall synthesized sounds.3
cardDraw an SVG card from a GitHub profile with canvas-style calls.24

site and its submodules are for scripts in the console. card is for scripts in the card studio and the card API; the two runtimes do not share modules.

Reading a declaration#

  • pub fn name(a: T) -> R is a function with typed parameters and a return type. Most of the SDK returns void: calling it asks the page to do something.
  • []T is an array of T; ?T is a T or null; fn(A) -> R is a function value, which you pass as a lambda.
  • pub struct is a record you build with module.Name { field: value }; every field is required. pub enum lists the cases you write as .Case.
  • pub let name: T is a value the host provides, such as site.projects.
  • A function marked written in Eitri (a few in card) has a body in the file, not in the host; only its signature is shown here.

How calls reach the page#

A call such as theme.hue(150) does not change the page by itself. The runtime records it, and when the script (or a callback) finishes without a fault, the site applies all the recorded calls together, clamping every value to its range. A script that faults part-way through its top level changes nothing. The numbers each module accepts, and the limits on counts and lengths, are listed on its page.