pibbl
import { pibbl, Rectangle } from "@pibbl/core";pibbl(canvas, root, config?) mounts a PibblNode on a Canvas host and
returns a Promise for the stable PibblController. A later call for the same canvas queues the
latest root after preparation and resolves to the same controller. The first mount owns the surface
configuration; call dispose() when the mount is no longer needed.
const canvas = document.querySelector("canvas")!;const controller = await pibbl( canvas, <Rectangle style={{ width: 160, height: 80, fill: "#2563eb" }} />,);// Later: controller.dispose();The optional PibblConfig selects the surface policy. Fixed surfaces capture the initial canvas viewport; { viewport: "responsive" }
uses the CSS content box. See the Getting started guide.
The external layout WASM asset is fetched and compiled before a new mount admits components, events or frames, including drawing-only roots. Layout and frame execution remain synchronous afterward. Use prepareLayoutEngine to warm the shared module before mounting, or the separate pibblSync entry for an intentionally synchronous host.
Loading failures reject with their cause and asset/phase context, without leaving
a partial mount. A later call retries a failed preparation attempt.
config.signal cancels only that caller’s pending wait with AbortError; it does
not cancel shared preparation or other canvases. A newer same-canvas request
supersedes older pending requests. Cancelling a pending update does not dispose
the existing mount; its original lifetime signal remains authoritative.
API details from source
Section titled “API details from source”
Prepares the external layout engine, then mounts or updates one Canvas. The first live mount owns surface configuration and its lifetime signal. Layout, component evaluation and scheduled frames remain synchronous.
pibbl: (canvas: HTMLCanvasElement, element: PibblNode, config?: PibblConfig) => Promise<PibblController>Related API: pibbl, PibblNode, PibblConfig, PibblController.
Parameters
Section titled “Parameters”-
canvas— The HTML Canvas owned by the mount. -
element— The branded recursive root descriptor. See PibblNode. -
config— Surface and lifetime options. See PibblConfig.
Returns
Section titled “Returns”A Promise for the stable PibblController; dispose releases the mount.
Throws
Section titled “Throws”Rejects on loading/mount failure, or with AbortError on cancellation, supersession or disposal while pending. A later call retries failed loading.
See also
Section titled “See also”View source — packages/core/src/lib/pibbl.ts:30
Implementation guidance for agents
Section titled “Implementation guidance for agents”Read the Authoring, signals, and lifecycle companion for ownership, adaptation, failure modes, and verification. Agent start provides the version-selection workflow.
Complete minimal examples
Section titled “Complete minimal examples”- Mount, update, and dispose: Own one Pibbl root for a canvas and replace its content without creating another controller. Plain source
Documentation version
Section titled “Documentation version”Documentation built with @pibbl/core 0.0.2, revision a1dcf8e. ALPHA — NOT FOR PRODUCTION USE.