Skip to content

pibblSync

Read as Markdown

import { Rectangle } from "@pibbl/core";
import { pibblSync } from "@pibbl/core/sync";
const controller = pibblSync(
document.querySelector("canvas")!,
<Rectangle style={{ width: 160, height: 80, fill: "#2563eb" }} />,
);
// Later: controller.dispose();

The root is a PibblNode, configuration uses PibblConfig, and the return value is PibblController.

pibblSync(canvas, root, config?): PibblController synchronously prepares the embedded version of the same generated layout binary and mounts or updates the canvas. It does not fetch or wait for a Promise. Use this separate entry for intentionally synchronous or offline hosts. The root package does not re-export this operation or include its embedded bytes in asynchronous-only bundles.

If prepareLayoutEngine or an earlier pibbl call has prepared the compatible module, synchronous mounting reuses it without decoding or compiling again. Compiled code is shared; mutable layout instances and memory remain owned by their respective mounts.

Initialization and mount failures throw synchronously. An already aborted caller throws AbortError. New same-canvas requests supersede older pending requests; existing live mounts retain their stable controller and originally captured surface/lifetime configuration. Disposing the live mount invalidates a pending update so it cannot resurrect the released mount. Importing the sync entry alone performs no decoding, compilation, instantiation or scheduling.

Mounts or updates synchronously using the embedded layout WASM binary. Import from

pibblSync: (canvas: HTMLCanvasElement, element: PibblNode, config?: PibblConfig) => PibblController

Related API: pibblSync, PibblNode, PibblConfig, PibblController.

  • canvas — The HTML Canvas owned by the mount.

  • element — The branded recursive root descriptor. See PibblNode.

  • config — Surface and lifetime options. See PibblConfig.

The stable PibblController, synchronously.

Throws on compilation/mount failure, or AbortError for a pre-aborted signal. Supersedes pending asynchronous requests for this Canvas.

PibblController

PibblConfig

View source — packages/core/src/sync.ts:20

Read the Authoring, signals, and lifecycle companion for ownership, adaptation, failure modes, and verification. Agent start provides the version-selection workflow.

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