# `Figler`
[🔗](https://github.com/open-pencil/figler/blob/v0.1.0-beta.3/lib/figler.ex#L1)

Fast analysis, transformation, and rendering for Figma `.fig` files.

Use `Figler.Scene` to inspect large files, `decode/1` and `encode/1` to change
complete documents with ordinary Elixir data operations, and `Figler.Render`
to render pages or selected layers.

Lower-level schema and message codecs are available for tools that already
manage their own Figma archive or container boundary.

# `decode`

```elixir
@spec decode(binary()) :: {:ok, Figler.Document.t()} | {:error, Figler.Error.t()}
```

Decodes a complete `.fig` archive, `fig-kiwi` container, or raw message.

The returned `Figler.Document` contains the decoded message alongside every
preserved archive entry. It can be changed with ordinary Elixir struct,
`Enum`, and `Access` operations before being passed to `encode/1`.

# `decode!`

```elixir
@spec decode!(binary()) :: Figler.Document.t()
```

Like `decode/1`, but raises `Figler.Error` for malformed input.

# `decode_message`

```elixir
@spec decode_message(binary() | Figler.Scene.source()) :: Figler.Schema.Message.t()
```

Decodes a Figma `Message` into generated schema structs.

Accepts a `.fig` archive, a `fig-kiwi` container, a raw `Message` payload, or
a `t:Figler.Scene.source/0`. Fields that newer Figma versions add are
skipped using the schema embedded in the file.

# `decode_message_runtime`

```elixir
@spec decode_message_runtime(binary()) :: map()
```

Decodes a Figma `Message` payload with the runtime schema interpreter.

# `decode_sparse_message`

```elixir
@spec decode_sparse_message(binary()) :: map()
```

Decodes a Figma `Message` payload into sparse schema-backed maps.

Sparse maps include `:__kiwi_module__` and only fields present on the wire.
This avoids materializing hundreds of nil fields per large `NodeChange`.

# `encode`

```elixir
@spec encode(Figler.Document.t()) :: {:ok, binary()} | {:error, Figler.Error.t()}
```

Encodes a `Figler.Document` back to its original representation.

Archives retain all entries and replace only their `canvas.fig` container.
Containers retain their schema, version, compression family, and trailing
chunks. Documents decoded from raw messages encode back to raw messages.

# `encode!`

```elixir
@spec encode!(Figler.Document.t()) :: binary()
```

Like `encode/1`, but raises `Figler.Error` for invalid document data.

# `encode_message`

```elixir
@spec encode_message(Figler.Schema.Message.t()) :: binary()
```

Encodes a generated Figma `Message` struct.

# `encode_message_runtime`

```elixir
@spec encode_message_runtime(map()) :: binary()
```

Encodes a Figma `Message` map with the runtime schema interpreter.

# `schema`

```elixir
@spec schema() :: KiwiCodec.Schema.t()
```

Parses the vendored Figma Kiwi schema.

# `schema_text`

```elixir
@spec schema_text() :: String.t()
```

Returns the vendored Figma Kiwi schema text.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
