Skip to content

packages/core/src/sync.ts

Read as Markdown

This is the source snapshot used to build these API details. View this revision on GitHub.

Back to reference

1 import { prepareLayoutEngineSync } from './lib/layout/wasm/embedded.js';
2 import { cancelPendingMount } from './lib/mount-request.js';
3 import { assertMountRequest, mountPreparedPibbl } from './lib/mount-prepared-pibbl.js';
4 import type { PibblController, PibblNode } from './lib/types.js';
5 import type { PibblConfig } from './lib/surface/types.js';
6 
7 /**
8  * Mounts or updates synchronously using the embedded layout WASM binary.
9  * Import from @pibbl/core/sync to opt into its Base64 payload. Reuses a compatible
10  * module prepared by prepareLayoutEngine() or a prior mount. Imports are inert.
11  * @param canvas The HTML Canvas owned by the mount.
12  * @param element The branded recursive root descriptor. See {@link PibblNode}.
13  * @param config Surface and lifetime options. See {@link PibblConfig}.
14  * @returns The stable {@link PibblController}, synchronously.
15  * @throws Throws on compilation/mount failure, or AbortError for a pre-aborted signal.
16  * Supersedes pending asynchronous requests for this Canvas.
17  * @see {@link PibblController}
18  * @see {@link PibblConfig}
19  */
20 export function pibblSync(canvas: HTMLCanvasElement, element: PibblNode, config?: PibblConfig): PibblController {
21   assertMountRequest(canvas, element, config);
22   cancelPendingMount(canvas);
23   prepareLayoutEngineSync();
24   return mountPreparedPibbl(canvas, element, config);
25 }
26 

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