# `Noizu.Tessera.Component.LitCodegen`
[🔗](https://github.com/the-robot-lives/tessera/blob/v0.2.0/lib/noizu/tessera/component/lit_codegen.ex#L1)

SPIKE (`spike/elixir-to-lit`): emits the Lit element module for a spec that
declared `state` / `template ~TSR` / `action` (docs/notes/spike-elixir-to-lit.md
§codegen).

Output (colocated with the component's `.ex`):

  * `<tag>.element.generated.mjs` — a `LitElement` subclass mixed with
    `TesseraElement` (CONTRACT.md §4): reactive properties from state +
    attrs + props (with Lit property options — `attribute` rename/disable,
    `reflect`, typed converters incl. `Array` for `:list`), a `render()`
    built from the template, one method per action (running the JS
    translated at compile time), one method per declared lifecycle hook
    (`shouldUpdate`/`willUpdate`/`firstUpdated`/`updated`), `emit` routed
    through `@noizu/tessera-core`'s `emit` (so the `data-tsr-on` Hologram
    bridge keeps working), and an exported `register()`.
  * `<snake>.mjs` — the `:js` entry wrapper (`register();` top-level —
    load-bearing for Hologram page bundles, CONTRACT.md §5). Written only
    when it does not exist, so a hand-written element `.mjs` is never
    clobbered.

Deterministic: same spec in, same bytes out (golden fixtures pin it).

# `element_module`

```elixir
@spec element_module(Noizu.Tessera.Spec.t()) :: String.t()
```

The `<tag>.element.generated.mjs` text for a template-bearing spec.

# `element_path`

```elixir
@spec element_path(Noizu.Tessera.Spec.t(), String.t()) :: String.t()
```

Path of the generated element module under `dir`. Takeover layers are keyed
by the BASE tag like their merged specs — the stem carries the declaring
module so sibling layers don't clobber each other's artifacts (§5.8/§5.9).

# `wrapper_module`

```elixir
@spec wrapper_module(Noizu.Tessera.Spec.t()) :: String.t()
```

The generated `:js` entry wrapper for Hologram hosts (top-level
`register()`, CONTRACT.md §5).

# `write_element_module`

```elixir
@spec write_element_module(Noizu.Tessera.Spec.t(), String.t()) ::
  :written | :unchanged | {:error, term()}
```

Write-if-changed `element_module/1` (returns `:written | :unchanged | {:error, reason}`).

# `write_wrapper_module`

```elixir
@spec write_wrapper_module(Noizu.Tessera.Spec.t(), String.t()) ::
  :written | :exists | {:error, term()}
```

Write the wrapper only when it does not exist (a hand-written element
`.mjs` is never clobbered). Returns `:written | :exists | {:error, reason}`.

---

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