PhoenixVapor.ScriptSetup (PhoenixVapor v0.3.0)

Copy Markdown View Source

Extracts reactive state and functions from <script setup> blocks.

Parses the script with OXC AST and extracts declarations for the PhoenixVapor.Runtime (persistent QuickBEAM + Vue reactivity):

  • ref(value) → initial expression passed to Runtime's reactive context
  • computed(() => expr) → expression body, auto-wired with .value access
  • defineProps([...]) → maps directly to LiveView assigns
  • Functions → bodies extracted for execution in with(scope) context

Summary

Functions

Evaluate computed expressions against current assigns.

Evaluate initial state from refs using QuickBEAM.

Parse a <script setup> block and extract initial state + event handlers.

Functions

eval_computeds(computeds, assigns)

Evaluate computed expressions against current assigns.

eval_initial_state(refs, assigns \\ %{})

Evaluate initial state from refs using QuickBEAM.

Converts ref(0)%{count: 0}, etc.

parse(script_source)

Parse a <script setup> block and extract initial state + event handlers.

Returns {initial_assigns, computed_exprs, event_handlers}.