Skip to content

definePrimitive

Read as Markdown

import { definePrimitive } from "@pibbl/core";

definePrimitive(render, capabilities?) creates a Pibbl primitive component from a PrimitiveRender callback and optional PrimitiveCapabilities, with private style normalization, resolution, and optional measurement capabilities. Use it for component-library primitives, not ordinary application components: invoking its returned component outside the Pibbl renderer throws.

const Dot = definePrimitive(function renderDot(props) {
// paint with the active Pibbl Canvas context
});

The exact generic contracts are in the Elements and components type reference; primitive painting receives Pibbl’s active Canvas context. See Custom components and primitives.

Defines a platform component with private style and measurement behavior.

definePrimitive: <P = Record<string, never>, S extends SystemStyle = SystemStyle, N extends SystemStyle = S, R extends SystemStyle = N>(render: PrimitiveRender<P, R> & PrimitiveStyleGuard<S, N, R> & (PrimitiveInput<P, S> extends never ? never : unknown), ...capabilityArguments: CapabilityArguments<P, S, N, R>) => PibblPrimitiveComponent<PrimitiveProgramProps<P>, PrimitiveInput<P, S>>

Related API: definePrimitive, SystemStyle, PrimitiveRender, PrimitiveInput, PibblPrimitiveComponent, PrimitiveProgramProps.

  • render — Synchronous primitive renderer receiving props, resolved style, and Canvas context. See PrimitiveRender , PrimitiveStyleGuard , PrimitiveInput .

  • capabilityArguments — Style normalization, resolution, and measurement capabilities required by the primitive. See CapabilityArguments .

A primitive component usable with JSX or createElement. See PibblPrimitiveComponent , PrimitiveProgramProps , PrimitiveInput .

PrimitiveRender

PrimitiveInput

PibblPrimitiveComponent

PrimitiveProgramProps

SystemStyle

View source — packages/core/src/lib/define-primitive.ts:83

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 272a94a. ALPHA — NOT FOR PRODUCTION USE.