Wocart

@wocart/theme v4.1.0


@wocart/theme / index / defineComponent

Function: defineComponent()

@wocart/theme — the theme contract.

Code-owned: defineComponent / defineTheme / validateThemeDefinition. Data-owned: parsePageData / validatePageData / resolveInstance / createInstance / checkFieldValue, and the document operations a writer applies (insertInstance, …, checkPageData). Serializable: themeManifest / validateThemeManifest / manifestCatalog / diffThemeManifests.

This entry is framework-neutral. The reference Astro renderer lives in the ./astro subpath.

Call Signature

defineComponent<T, Loaded, Fields>(definition): T & FieldsPart<Fields> & object

Identity helper: returns the definition unchanged so literal types survive. load receives the component's props typed from its own fields, so a definition reads its settings without a cast, and what it returns types the component's props (InferProps).

Type Parameters

T

T extends ComponentBase

Loaded

Loaded extends Record<string, unknown>

Fields

Fields extends readonly FieldDefinition[] = readonly []

Parameters

definition

T & object

Returns

T & FieldsPart<Fields> & object

Call Signature

defineComponent<T, Fields>(definition): T & FieldsPart<Fields>

Identity helper: returns the definition unchanged so literal types survive. load receives the component's props typed from its own fields, so a definition reads its settings without a cast, and what it returns types the component's props (InferProps).

Type Parameters

T

T extends ComponentBase

Fields

Fields extends readonly FieldDefinition[] = readonly []

Parameters

definition

T & object

Returns

T & FieldsPart<Fields>