# `Macaw.Frame.Document.Composite`
[🔗](https://github.com/dcoai/macaw_frame/blob/v0.1.0/lib/macaw/frame/document/composite.ex#L1)

The frame document's part of composition (spec/02 §8.4, §16.4): where a composite's
site lands, how its `defaults` reach what it places, how a whole saved design is placed
under a key, how ids left at reference sites resolve, and how a whole design cuts into
inline sites. The machinery (use sites, the stack, flattening) is
`Macaw.Layers.Composite`'s; `Macaw.Frame.Document` answers its hooks from here.

    iex> design = %{frames: %{"main" => %{kind: "polar"}}, layers: [%{kind: "arc", id: "needle"}]}
    iex> Macaw.Frame.Document.Composite.place_whole(design, "gauge")
    {:ok, %{frames: %{"gauge" => %{kind: "polar"}}, layers: [%{kind: "arc", id: "gauge_needle", frame: "gauge"}]}}

# `decompose`

```elixir
@spec decompose(term()) :: [Macaw.Layers.Use.t()]
```

A whole design as inline sites, one kind each, keyed where the design keys them, in a
stable order: flattening them is the design again (spec/14 §4). One frame is its own
site with a site per scale and per axis; several are a site per whole frame.

# `inline`

```elixir
@spec inline(map(), (term() -&gt; {:ok, map()} | :error)) :: {map(), [{term(), list()}]}
```

The ids left at reference sites of a flattened design resolved through `fetch`: a style
id inlined where it stands, a scale id declared under its frame's `scales` and a slot or
paint id under `slots` or `defs`, each under a synthesized key (`"scale:4"`); an id the
fetch does not hold masks its site and is reported as `{id, path}`.

# `merge_defaults`

```elixir
@spec merge_defaults(map(), map()) :: map()
```

Two defaults nodes laid by the style merge rule (§3.5, §3.8): `over` nearer, each kind
entry merged as its own node.

# `place_whole`

```elixir
@spec place_whole(term(), term()) :: {:ok, map()}
```

A keyed whole-design contribution placed under its key: a design of one frame lands as
`frames[key]`, of several as `frames["<key>_<name>"]`; its layers and labels retargeted
to the renamed frames, its adoptions following the rename, and its layers' and labels'
ids prefixed by the key, so two copies of one saved design never merge.

# `scope`

```elixir
@spec scope(term(), term(), term()) :: term()
```

A site's contribution with its composite's `defaults` written under what it places: each
layer, label and axis, and each whole frame, takes the composite's defaults farther and
its own nearer. A composite with no defaults leaves the contribution as it is.

---

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