Ship · Runtimes
Docs / Ship

Runtimes

The .egg file

Export bakes a project into a compact binary: artboards, animations, state machines, view models, and the pictures, sounds and fonts it needs (or, with --referenced, a folder of assets your app hands over at run time). A bundle (.eggs) holds several artboards.

Web

The web runtime is WebAssembly plus a small helper, egg-player.js, that sizes the canvas, runs the frame loop and forwards pointer, wheel, keyboard and text input.

index.htmlweb runtime
import init, * as egg from "./egg_web.js";
import { mount } from "./egg-player.js";

await init();
const bytes = new Uint8Array(await (await fetch("hatch.egg")).arrayBuffer());
const view = mount(egg, document.querySelector("canvas"), bytes, {
  machine: "hatch",     // "" = the first; null = play the first animation
  fit: "contain",       // or "layout": the artboard takes the canvas size
});
OptionDoes
artboardWhich artboard of a bundle ("" = the first).
renderer"canvas" (default, Canvas2D) or "pixels" (software, exact).
openUrlsFollow "open URL" events (default true).
soundPlay audio events (default true).
onEventA function called with every event the file reports.
semanticsMirror tappable shapes as accessible elements (default true).

Native and engines

One runtime written in Rust, with a C API and bindings on top of it:

PlatformBinding
iOS, macOSSwift package
AndroidKotlin (AAR)
FlutterDart packages (runtime and a player widget)
UnityC# package
UnrealPlugin
C, C++ and anything with an FFIegg.h and egg.hpp

Driving it from code

Every runtime exposes the same calls: start a state machine, set its inputs (set_bool, set_number, fire), read and write view model properties (vm_set_number, vm_fire, …), read the current state and take the events the file reported.