Dala.Plugin.Component (dala v0.3.2)

Copy Markdown View Source

Represents a single component schema within a plugin.

Contains all metadata needed for code generation, validation, and runtime dispatch. This is the core of the schema-first architecture.

Summary

Functions

Adds a required capability to the component schema.

Adds an event to the component schema.

Adds a native platform mapping to the component schema.

Adds an optional capability to the component schema.

Adds a property to the component schema.

Types

event()

@type event() :: %{
  name: Dala.Plugin.event_name(),
  payload: map(),
  doc: String.t() | nil
}

lifecycle_event()

@type lifecycle_event() :: :create | :update | :layout | :event | :dispose

prop()

@type prop() :: %{
  name: Dala.Plugin.prop_name(),
  type: Dala.Plugin.prop_type(),
  required: boolean(),
  default: term(),
  doc: String.t() | nil
}

t()

@type t() :: %Dala.Plugin.Component{
  capabilities: [Dala.Plugin.capability()],
  doc: String.t() | nil,
  event_structs: %{required(atom()) => module()},
  events: [event()],
  lifecycle: [lifecycle_event()],
  metadata: map(),
  name: Dala.Plugin.component_name(),
  natives: %{required(String.t()) => String.t()},
  optional_capabilities: [atom()],
  plugin: Dala.Plugin.plugin_name(),
  props: [prop()]
}

Functions

add_capability(component, capability)

@spec add_capability(t(), Dala.Plugin.capability()) :: t()

Adds a required capability to the component schema.

add_event(component, name, opts \\ [])

@spec add_event(t(), Dala.Plugin.event_name(), keyword()) :: t()

Adds an event to the component schema.

Options:

  • :payload — map of field names to types (default: %{})
  • :doc — documentation string (default: nil)

add_native(component, platform, class_name)

@spec add_native(t(), String.t(), String.t()) :: t()

Adds a native platform mapping to the component schema.

platform is the platform string (e.g. "ios", "android"). class_name is the native class name to instantiate.

add_optional_capability(component, capability)

@spec add_optional_capability(t(), atom()) :: t()

Adds an optional capability to the component schema.

Optional capabilities enhance the component but are not required for basic functionality.

add_prop(component, name, type, opts \\ [])

@spec add_prop(t(), Dala.Plugin.prop_name(), Dala.Plugin.prop_type(), keyword()) ::
  t()

Adds a property to the component schema.

Options:

  • :required — boolean, whether the prop is required (default: false)
  • :default — default value (default: nil)
  • :doc — documentation string (default: nil)