# `PhiaUiDesign.Codegen.LiveviewEmitter`
[🔗](https://github.com/charlenopires/PhiaUI/blob/v0.1.17/lib/phiaui_design/codegen/liveview_emitter.ex#L1)

Generates a complete Phoenix LiveView module source string from a scene graph.

The output is a ready-to-paste `.ex` file containing:

- `use MyAppWeb, :live_view`
- `import` statements for every PhiaUI module referenced by components in the scene
- A `mount/3` callback that assigns any specified initial state
- A `render/1` callback containing the emitted HEEx template
- Optional `handle_event/3` callbacks

Also provides helpers to list required JS hooks and `mix phia.add` commands
so the consumer app can install everything the design needs.

# `emit`

```elixir
@spec emit(reference(), String.t(), keyword()) :: String.t()
```

Generate a complete LiveView module source string.

## Parameters

- `scene` - the ETS scene reference
- `module_name` - fully-qualified module name string, e.g. `"MyAppWeb.DashboardLive"`

## Options

- `:web_module` - the Phoenix web module (default: `"MyAppWeb"`)
- `:assigns` - map of assigns to set in `mount/3` (default: `%{}`)
- `:events` - list of `{event_name, body_string}` tuples for `handle_event/3` callbacks (default: `[]`)

# `generate_imports`

```elixir
@spec generate_imports([atom()]) :: String.t()
```

Generate import statements for the modules that provide the used components.

Looks up each component key in `PhiaUi.ComponentRegistry`, collects the
unique modules, and returns a list of `import Module` lines.

# `required_add_commands`

```elixir
@spec required_add_commands([atom()]) :: [String.t()]
```

Return the `mix phia.add` commands needed to install all used components.

# `required_hooks`

```elixir
@spec required_hooks([atom()]) :: [String.t()]
```

Return the list of JS hook names required by the given component keys.

The hooks must be registered in the LiveSocket on the client side.

---

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