# Changelog

## Unreleased

## 0.6.1 - 2026-10-09

Checked against PhoenixReplay 0.6.2, recording real sessions of the demo and replaying them in its player.

### Changed

- Require vize 0.17.2, whose template split leaves Vue's reserved `ref` and `key` out and gives each `<option>` of a `<select v-model>` a slot, so the selected one renders `selected`.
- While a session is recorded, a hybrid component reports a changed value once it has been still for the replayer's debounce, as PhoenixReplay records a form control, and at least once per flush interval while it keeps changing. A typed word is one step on the timeline, and an input PhoenixReplay records itself agrees with the component's report. Before, a report went out once per flush interval and could catch a word halfway typed.
- `replay_render/1` no longer translates `__changed__` for tracked replay renders: PhoenixReplay renders a replay in full at every step.

### Fixed

- A replay of a hybrid component in PhoenixReplay's player showed the first moment of the session at every step. The player renders each moment with `__changed__: nil` and diffs it with change tracking, which crashed the template renderer, and the frame restarted. `__changed__: nil` now renders every slot, as in LiveView.
- A replay on a server that didn't compile the component itself, such as a release, failed for recorded client state whose name appears nowhere in Elixir code, such as `useClipboard`'s `copied`: the name's atom, made while compiling, didn't exist there. The render spec now carries every declared name's atom.
- A `<select v-model>` rendered no option selected, so its first paint showed the first option until the browser mounted. The option whose value, bound `:value` or text is the select's is now `selected`, or each one among them for `<select multiple>`, as Vue's server renderer does.
- A static `ref` or `key` rendered as an attribute, such as `ref="search"` on an input. Vue reserves both and never renders them, nor now does PhoenixVapor.
- A hybrid LiveView's client module, which compiling writes, wasn't written again once missing while the build was up to date, such as on a fresh checkout beside a build restored from a CI cache, so building the assets failed. The LiveView now recompiles while its client module is missing.
- A server action reached the recording before the client state it was sent from, when that state was still waiting for the next report: a project name typed just before Save was recorded after the save. The state now goes out first.

## 0.6.0 - 2026-10-06

### Upgrading from 0.5

A hybrid server action no longer writes props. Declare the data it changes as a model, and write the model's `.value`:

```diff
-const props = defineProps(["contacts"])
+const contacts = defineModel("contacts")

 function deleteContact(id) {
   "use server"
-  props.contacts = props.contacts.filter((c) => c.id !== id)
+  contacts.value = contacts.value.filter((c) => c.id !== id)
 }
```

Read the model as `contacts.value` in the script and as `contacts` in the template; the LiveView assigns it as `contacts`, as before. The compiler reports each remaining `props.x = ...` with its line. The body of a server action now runs in the browser, so a guard (`if (!id) return`) keeps it from reaching the server, and a prop it reads is sent to the browser. See Breaking changes below and the Hybrid guide's Server actions section.

### Breaking changes

- Require Volt 0.21. Its `mix volt.js.check` type-checks a `.vue` file's scripts with the project's `tsconfig.json`, path aliases and declaration files included, and leaves `<script lang="elixir">` out, so hybrid components type-check as written.
- Hybrid components declare data the browser changes, and the server owns, with Vue's `defineModel("name")` instead of writing to props. A server action writes the model's `.value`: `contacts.value = contacts.value.filter(...)` in place of `props.contacts = ...`. Writing `props.x`, or a bare `x` for a prop the script doesn't declare, is a compile error that points at `defineModel`, since props are read-only in Vue, in its types and at runtime; the old convention only worked because the compiler rewrote the assignment. A model must be named after its variable (`const open = defineModel("open")`), the assign the LiveView sets. A function that writes a model is a server action, as one that wrote a prop was.
- A server action's body now runs in the browser as written, and the action is sent afterwards, unless the body returns or throws first, so a guard such as `if (!dirty.value) return` validates in the browser. Before, only its prop assignments ran and the event always went. So a prop a server action reads is now sent to the browser; one the browser must never see, such as a token, isn't a prop, and `handle_event/3` reads it instead.
- Reactive mode and the full runtime keep their QuickBEAM runtime in `socket.private` instead of the `:__vapor_runtime__` and `:__vue_runtime__` assigns, so a session recorder doesn't record a pid and `render/1` reads only state.
- `PhoenixVapor.Component` and its `vue/1` macro, which returned its argument unchanged, are removed; `use PhoenixVapor` imports only the `~VUE` sigil. Use `~VUE` directly.
- Template expressions follow JavaScript's semantics, as Vue renders them in the browser: truthiness (`0`, `""` and `NaN` are falsy in `v-if`, `? :`, `!`, `&&` and `||`), `===` (`1 === 1.0`), `==`, relational comparison (`undefined > 0` is false), `+` concatenation and arithmetic with `NaN` and `Infinity`, and `typeof null`. A missing assign is `undefined` and `nil` is `null`. Before, Elixir's semantics leaked through, so `v-if="items.length > 0"` rendered with no `items`.
- Modules are grouped by role: `PhoenixVapor.Compiler.*` compiles templates, `PhoenixVapor.Renderer.*` renders them, and each mode's modules sit under it. `PhoenixVapor.Runtime` is now `PhoenixVapor.Reactive.Runtime`, `PhoenixVapor.LiveVue` is `PhoenixVapor.Full`, `PhoenixVapor.VueRuntime` is `PhoenixVapor.Full.Runtime`, and `PhoenixVapor.ScriptSetup` is `PhoenixVapor.Compiler.ScriptSetup`; the runtimes and `ScriptSetup` are internal. `use PhoenixVapor`, `~VUE`, `PhoenixVapor.Vue`, `PhoenixVapor.Template` and `PhoenixVapor.ExpressionError` are unchanged.

### Added

- Elixir counterparts for hybrid computeds: a `def filtered(assigns)` in `<script lang="elixir">` computes `filtered` on the server, from the props, the refs and earlier computeds, so a computed built on a composable or a library such as es-toolkit still renders in the first paint and in a replay. A key in the counterpart's pattern, or read as `assigns.key`, is required, and one read as `assigns[:key]` is optional, `nil` when the render doesn't have it; a counterpart that requires state only the browser has is never called on the live render, with a compile-time warning. A counterpart named after a LiveView callback, such as `render`, is a compile error.
- A hybrid component's constants (`const PAGE_SIZE = 20`) are evaluated once while compiling and known to its server render, and a computed calling a script function with an Elixir counterpart calls the counterpart. State only the browser has, such as a composable's value, is absent from the live render: an expression reading it isn't rendered, a `v-if` chain whose condition reads it renders no branch, and a counterpart reading it isn't called, until a replay that recorded it.
- A `.vue` file is hybrid when `<script setup>` declares state the browser owns: a `ref()`, or now any top-level name bound by a call the compiler can't run, such as a composable's (`useLocalStorage`, `const { copy, copied } = useClipboard()`) or `reactive()`. A file whose only state came from composables used to compile as server-only.
- Session replay for hybrid components: while a session replayer such as PhoenixReplay records client state (`phx_replay:start` on `window`), each hybrid component reports the client state its server render reads, refs and composables' results alike, as `phx_replay:state` events: all of it on start, or on mount during a recording (`<html data-phx-replay>`), then the latest value of what changed, at most once per flush interval, under `phoenix_vapor:<wrapper id>`, with non-plain values as `null`; nothing is dispatched otherwise. Each hybrid LiveView defines `replay_render/1`, which renders without the client hook and with the state recorded in `@phoenix_replay_state`. PhoenixVapor needs no dependency on PhoenixReplay. See the Hybrid guide's Session replay section.
- An expression only JavaScript can evaluate, such as `items.filter(i => i.on)` or `Math.max(a, b)`, is reported at compile time as a warning: it runs in QuickBEAM on every render, while the rest of rendering is Elixir. A method a value doesn't have, such as `trim()` on a number, raises `PhoenixVapor.ExpressionError`, as it throws in the browser.
- In hybrid mode, components from packages, such as Reka UI, render on the server when everything they receive is known at compile time. Vue's server renderer runs them once in QuickBEAM while the template compiles, so rendering runs no JavaScript. Nested package components render together, providers such as `TooltipProvider` render only their content, and in hybrid mode the initial values of refs count as known. One that can't render is reported with the reason, such as a prop known only when rendering or an error from the component. Outside hybrid mode, where nothing takes over in the browser, only package components that render just their content, such as providers, render; others remain a compile error.
- A macro call that reads props known only when rendering runs at compile time once per combination of the values their TypeScript types allow, up to 64, and rendering looks the result up. Types come from TypeScript's own checker, from the project's `node_modules`, so variant types derived from a tailwind-variants config work. A value outside the type raises `PhoenixVapor.ExpressionError`.
- A package component's props may be expressions of known values, such as `:open="selected !== null"` over a ref's initial value, and package parts inside the template's own `v-for` or `v-if`, such as a tooltip per row, render in their ancestors' context.
- A template's call to a `<script setup>` function renders on the server through the function of the same name in snake_case that `<script lang="elixir">` defines, such as `role_tone/1` for `roleTone(role)`. The full runtime now leaves a `<script lang="elixir">` block out of its browser bundle.
- `PhoenixVapor.Volt`, a Volt plugin that resolves `phoenix_vapor` imports from a path or umbrella dependency, which `resolve_dirs: ["deps"]` doesn't find.
- The `file:` option and `PhoenixVapor.Vue.component/2` take any expression known at compile time, such as `Path.join(@templates, "Card.vue")`, besides a path relative to the module's file.

### Fixed

- A server action sent the refs it read as they were after its body ran, so `selectedIds.value = []` at the end of the body sent an empty selection. It sends them as they were when it was called.
- While several server actions were in flight, the first answer reapplied the server's props, undoing the optimistic changes of the others until their own answers came. The props now apply once every action in flight has been answered, or has failed.
- An optimistic change the server declined stayed on screen: when `handle_event/3` left the assign unchanged, no new props came. Once the server has handled a server action, the component's props and models are the server's again.
- A server action whose body returned early, such as `if (!id) return`, wasn't recognized: its body was parsed as a script, where `return` is a syntax error, so it was a client handler and never reached the server.
- A hybrid component's prop that only the template read, as `props.saved`, stayed on the server: the browser never received it, and the server's own first paint rendered it empty. A prop the template reads now goes to the browser.
- Reactive mode's direct DOM patching assumed the template was the LiveView's whole render, so inside a layout it matched the layout's slots instead of the template's, and updates didn't reach the page. It now finds the template in the rendered tree, and patches directly only when a diff changes nothing outside it.
- A hybrid computed that read something only the browser has, such as a composable's result (`refDebounced`) or an import (`sortBy` from es-toolkit), failed every server render with `ExpressionError`. The server now decides this when compiling: it leaves such a computed, and what reads it, out of the first paint, with a warning naming what it lacks. An expression reading it isn't rendered, and a `v-if` chain whose condition reads it renders no branch, rather than its `v-else`.
- The QuickBEAM runtime that ran macro calls while compiling was never stopped, and the one for package components leaked when compiling raised. One runtime per compile now serves both and stops in an `after`.
- A hybrid component started a QuickBEAM runtime on every render to evaluate its computed values, and a computed that failed rendered as missing without a report. Computeds now evaluate as template expressions do: one that reads only refs is evaluated once while compiling, and package components can render with it; one that reads props is evaluated when rendering, on the LiveView process's runtime, with its last value reused while its inputs are unchanged. A computed's other computeds are evaluated first, so lists such as a filtered view of props render on the server. A failure is a compile-time warning, or an `ExpressionError` when rendering.
- A template literal's text between expressions rendered empty: `` `a${x}b` `` gave `1`.

## 0.5.0 - 2026-10-03

### Breaking changes

- Require vize 0.17 and Volt 0.20. Vize's `Vize.split_template/2` replaces `vapor_split`. It works from Vize's L2 semantic IR instead of scanning Vapor's template HTML, so PhoenixVapor no longer depends on locating elements in generated HTML. `PhoenixVapor.render/2` takes a template string or a `PhoenixVapor.Template`.
- Compiled templates are `%PhoenixVapor.Template{}` structs, which inspect as their file and slot count, instead of maps.
- An expression that fails when rendering, such as a call to something that isn't a function, raises `PhoenixVapor.ExpressionError` with its file, line, and column, where it rendered nothing.
- A component, function call, or macro call the server can't render is a compile error outside hybrid mode, and a warning in it; it used to render nothing.
- Reactive templates carry `data-vapor-keys` beside `data-vapor-statics`; the browser code in this release reads it.

### Added

- Components imported from `.vue` files render on the server, in every mode: props, slots and scoped slots, `<slot>` fallbacks, and fallthrough attributes merged into the root element.
- Helpers imported with `with { type: "macro" }` run at compile time when their arguments are known then, so variant helpers such as tailwind-variants cost nothing when rendering.
- Compile errors and warnings point to the line in the `.vue` file, and editors show them there.
- Function components from the `__components__` assign receive default slot content as `inner_block`.

### Fixed

- Attributes render as Vue's server renderer does: `null` and a false boolean attribute are left out, where `disabled="false"` made an element disabled, and `class` and `style` take objects and arrays. An object literal such as `:class="{ on: active }"` used to evaluate to nothing.
- `v-show` merges with the element's `style`, and `v-model` renders a checkbox's or radio's `checked` state and a textarea's content.
- `v-for` binds the index, or a map's key and index, to its other aliases.
- Interpolated objects and lists display as JSON, as in Vue.
- A root `v-if` rendered its first branch twice.
- A `v-if`, `v-for` or component re-renders when an assign its content reads changes, not only its condition or source.
- Reactive templates patch text that mixes static text and several values, such as `Doubled: {{ n }} · {{ label }}`, directly, and decode HTML entities in patched text. A diff that also changed a value the patcher couldn't write was half applied.
- A component prop bound to a list or map keeps its value instead of raising.
- Relative imports in a hybrid component's client module resolve from where the module is written.
- Full-runtime components resolve imports through the project's Volt aliases, and a resolution failure raises a readable error.
- Reactive LiveViews recompile when their `.vue` file changes.

## 0.4.0 - 2026-10-03

### Breaking changes

- Require Elixir 1.19, vize 0.16.1, OXC 0.18, QuickBEAM 0.11.2, and Volt 0.19.4, dropping the older versions 0.3.4 also accepted. Volt is now a required dependency, used at compile time only. Building vize from source requires Rust 1.95.
- The browser code is TypeScript in `priv/ts`, exported through the package's `package.json`: import `patchLiveSocket` from `phoenix_vapor` and `getHybridHooks` from `phoenix_vapor/hybrid`. `priv/js/hybrid-bridge.js` is gone, and `patchLiveSocket` was not in the Hex package before.
- A hybrid module exports `__mount(el, bridge, props)`, which returns `applyProps/1` and `unmount/0` for that instance, in place of the module-level `__applyProps`, `__setBridge`, and `__unmount`. Hybrid wrappers are `phx-update="ignore"`, and their server HTML has no `phx-*` event attributes.
- Full-runtime LiveViews take a `:globals` option mapping each package their bundle provides to its global, such as `%{"reka-ui" => "RekaDialog"}`. Only `vue` is mapped by default; `reka-ui` and `@vueuse/*` were hardcoded for the demo's bundle.
- Reactive `mount/3` assigns only the URL params the template reads.
- An unknown `:runtime` option raises at compile time instead of falling back to detecting the mode.

### Added

- A page can mount the same hybrid component several times. Each mount has its own props and bridge.
- `defineProps` is read in its object and TypeScript forms as well as as an array, using Vize's script analysis.
- Guides for getting started and for each mode, and a cheatsheet.

### Changed

- Templates compiled into a module parse their expressions and compute fingerprints at compile time. Rendering a 500-row `v-for` went from 55 ms to 0.5 ms.
- vize 0.16's `vapor_split` reports events and `v-model` as data, and PhoenixVapor renders them as `phx-*` attributes itself.
- The full runtime reads its bundle once and caches it until the file changes, instead of reading it on every mount.
- `@vue/reactivity` for Reactive mode is pinned in `priv/ts/package.json` and vendored by `mix volt.priv.vendor`, replacing a hand-copied build of 3.5.30.
- Slot positions for direct DOM patching come from the browser's HTML parser instead of a hand-written one, which mishandled `>` inside attribute values.
- Scoped CSS uses the scope ID from `Vize.SFC.scope_id/2`, passed to Vize, instead of one read back out of the compiled CSS.

### Fixed

- Hybrid server actions threw in the browser: they referenced `__serverProps` and `triggerRef`, which the generated module never defined.
- Hybrid components re-render when LiveView sends new props. Only the first render used them.
- Hybrid components keep working across server updates, and a prop change sends only the new props JSON instead of the whole tree.
- Hybrid components get every prop the template or client-side code reads. Props used only in the template were left out, so they rendered empty once the client mounted.
- Server actions send the values of refs and computeds instead of serialized `Ref` objects.
- Before the client mounted, LiveView acted on hybrid `phx-click` attributes such as `phx-click="pick(c)"` and pushed the handler source to the server as an event name.
- The hybrid bridge applies the initial props before mounting and unmounts the component when the hook is destroyed.
- A QuickBEAM runtime leaked on every hybrid render.
- Rendering never creates atoms. Reactive `mount/3` turned every URL param into an atom, and change tracking, component props, `v-for` variables, and hybrid props and computeds converted names at render time, which `PhoenixVapor.render/2` does for templates built at runtime.
- Computeds may read computeds declared after them, and block-bodied computeds work in Reactive mode.
- Expressions with methods that aren't evaluated in Elixir fall back to QuickBEAM. `list.filter(fun)` and `list.map(fun)` with a function reference returned the list unchanged, and methods such as `padStart` rendered nothing.
- Scope and Vapor metadata attributes go after the root tag's name. They were inserted before the first `>`, which could be inside an attribute value such as `title="a > b"`.
- A `<script lang="elixir">` block is left out of the hybrid client module, even after `<script setup>`.
- Full-runtime LiveViews raise the JavaScript error from mount and events instead of a `MatchError`.
- The Hex package contains only PhoenixVapor's own JavaScript. It included all of `priv/js`, so a locally built bundle such as `reka-dialog.js` would have been published.

## 0.3.4 - 2026-09-30

### Compatibility

- Support Volt 0.19, OXC 0.18, and Vize 0.15, alongside the versions supported before.

## 0.3.3 - 2026-09-15

### Fixed

- Return JavaScript evaluation errors from full-runtime calls and event dispatches instead of reporting successful stale HTML.

### Compatibility

- Support Volt 0.17.11 and the 0.18 series with QuickBEAM 0.11.1 or later in the 0.11 series, resolving the shared dependency conflict when adding PhoenixVapor to a current Volt application.

## 0.3.2 - 2026-08-24

### Added

- Allow full-runtime LiveViews to override and compose generated lifecycle callbacks with `super`.

### Fixed

- Preserve document order when rendering nested property, text, and structural Vapor slots.
- Capture the full-runtime SFC component export reliably before mounting it.
- Resolve relative `.vue` imports from the source component directory in full-runtime mode.

## 0.3.1 - 2026-08-17

### Fixed

- Corrected duplicate static text when rendering interpolations with Vize 0.14.

### Compatibility

- Updated Phoenix Vapor to work with Volt 0.17, OXC 0.17, Vize 0.14, and Phoenix LiveView 1.2.
