15 lines · 654 B
import yoga from "satori/yoga.wasm?module";
import resvg from "@resvg/resvg-wasm/index_bg.wasm?module";
import regular from "./fonts/plex-sans-400.bin";
import semibold from "./fonts/plex-sans-600.bin";
import type { OgRuntime } from "./render";

/**
 * Workers can't compile wasm from bytes at runtime, so both modules are bundled as compiled wasm modules. The fonts
 * are IBM Plex Sans latin as uncompressed TrueType: a byte-identical copy of the CSS's .woff would be deduplicated
 * into that asset by the bundler and lose its Data module type.
 */
export function loadRuntime(): OgRuntime {
  return { yoga, resvg, fonts: { regular, semibold } };
}