PaperForge.Declarative.Registry (PaperForge v1.3.0)

Copy Markdown View Source

Registry of trusted visual components and resource-access policy.

Templates can invoke registered functions by name, but cannot define or evaluate executable code. Each component receives resolved props and slots and must return a PaperForge.Flow.

Summary

Functions

Registers a trusted renderer accepting (props, slots) or (props, slots, variant).

Resolves a file or URL according to the registry resource policy.

Types

component()

@type component() :: struct()

t()

@type t() :: %PaperForge.Declarative.Registry{
  allowed_schemes: [binary()],
  components: %{optional(binary()) => component()},
  max_resource_bytes: pos_integer(),
  resource_root: Path.t() | nil
}

Functions

component(registry, name, renderer, options \\ [])

@spec component(t(), atom() | binary(), function(), keyword()) :: t()

Registers a trusted renderer accepting (props, slots) or (props, slots, variant).

fetch_component(registry, name)

@spec fetch_component(t(), binary()) :: {:ok, component()} | :error

new(options \\ [])

@spec new(keyword()) :: t()

render(component, props, slots, variant)

@spec render(component(), map(), map(), binary() | nil) ::
  {:ok, PaperForge.Flow.t()} | {:error, term()}

resolve_resource(registry, source)

@spec resolve_resource(t(), binary()) :: {:ok, binary()} | {:error, term()}

Resolves a file or URL according to the registry resource policy.