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: "file",               // "file", "layout", "expand", "contain", "cover", or "fill"
  layoutScaleFactor: "auto", // number or "auto" for Fit.Layout logical scaling
});
OptionDoes
artboardWhich artboard of a bundle ("" = the first).
fitHow the artboard meets the canvas: "file" (use the file's setting), "layout", "expand", "contain", "cover", or "fill".
layoutScaleFactorPositive number or "auto" to scale logical artboard units in "layout" fit (see Responsive layouts).
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
Web (full & lite)@egg/player and @egg/player/lite (793 KB gzip, Canvas2D)
React Native@egg/react-native (iOS Metal + Android ViewManager)
iOS, macOSSwift package & XCFramework
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.

Generate strongly-typed wrappers for your state machines and view models straight from a baked file:

Terminaltypegen
egg typegen dashboard.egg --lang ts -o src/dashboard.gen.ts
egg typegen dashboard.egg --lang swift -o DashboardEgg.swift