Macaw.Component.Package (macaw_component v0.1.2)

Copy Markdown View Source

The package side of the registry (spec/03): what a package provides, read the same way by every host. A package is a module with __members__/0; its components are the members that use Macaw.Component, each registering through its static declarations.

Enabling packages, the boot-time duplicate check across them and resolving names in documents are the host's.

Summary

Functions

:ok when components/1 answers {:ok, _}, else its faults.

A package's components, in member order, each with its static declarations; members of other behaviors are skipped. Every fault at once: :not_a_package, {:not_loaded, member}, and {:duplicate, name, [module, module]} for two components of one name.

Every hook of the components of the listed packages, %{hook_name => {package, path}}, from which a host generates the one module that registers them in its LiveSocket. Two hooks of one name are {:duplicate_hook, name, [component, component]}; a package's own faults are reported at [package].

Types

component()

@type component() :: %{
  name: String.t(),
  module: module(),
  kinds: [Macaw.Component.kind(), ...],
  hooks: %{required(String.t()) => String.t()},
  assets: [String.t()]
}

Functions

check(package)

@spec check(module()) :: :ok | {:error, [Macaw.Component.fault(), ...]}

:ok when components/1 answers {:ok, _}, else its faults.

components(package)

@spec components(module()) ::
  {:ok, [component()]} | {:error, [Macaw.Component.fault(), ...]}

A package's components, in member order, each with its static declarations; members of other behaviors are skipped. Every fault at once: :not_a_package, {:not_loaded, member}, and {:duplicate, name, [module, module]} for two components of one name.

hooks(packages)

@spec hooks([module()]) ::
  {:ok, %{required(String.t()) => {module(), String.t()}}}
  | {:error, [Macaw.Component.fault(), ...]}

Every hook of the components of the listed packages, %{hook_name => {package, path}}, from which a host generates the one module that registers them in its LiveSocket. Two hooks of one name are {:duplicate_hook, name, [component, component]}; a package's own faults are reported at [package].