Skip to content

Prepare layout before mounting

Read as Markdown

Warm the shared layout module before creating an asynchronous canvas mount.

Plain source. Run as a browser module after the document body exists. TSX uses jsx: "react-jsx" and jsxImportSource: "@pibbl/core".

import { Rectangle, pibbl, prepareLayoutEngine } from "@pibbl/core";
await prepareLayoutEngine();
const canvas = document.createElement("canvas");
canvas.width = 240;
canvas.height = 100;
document.body.append(canvas);
const controller = await pibbl(
canvas,
<Rectangle
style={{ left: 20, top: 20, width: 200, height: 60, fill: "#087e8b" }}
/>,
);
window.addEventListener("pagehide", () => controller.dispose(), { once: true });
  • Uses the normal awaited mount after preparation.

Documentation built with @pibbl/core 0.0.2, revision a1dcf8e. ALPHA — NOT FOR PRODUCTION USE.