definePrimitive
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.
API details from source
Section titled “API details from source”
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.
Parameters
Section titled “Parameters”-
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. SeeCapabilityArguments.
Returns
Section titled “Returns”A primitive component usable with JSX or createElement. See PibblPrimitiveComponent , PrimitiveProgramProps , PrimitiveInput .
See also
Section titled “See also”View source — packages/core/src/lib/define-primitive.ts:83
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”- Define a Canvas primitive: Supply synchronous drawing, style normalization, resolution, and opt-in measurement. Plain source
Interactive examples
Section titled “Interactive examples”Documentation version
Section titled “Documentation version”Documentation built with @pibbl/core 0.0.2, revision 2dccb19. ALPHA — NOT FOR PRODUCTION USE.