PhoenixVapor.Hybrid.ClientCodegen (PhoenixVapor v0.3.0)

Copy Markdown View Source

Generates client-side JavaScript for hybrid components.

Takes the Vize Vue Vapor SFC compilation output and transforms it:

  1. Replaces __props with a bridge-controlled reactive source
  2. Replaces server action bodies with optimistic update + pushEvent stubs
  3. Adds bridge initialization and props application exports

Summary

Functions

Generate the client JS module for a hybrid component.

Transform Vize's Vue Vapor output for hybrid mode.

Functions

generate(sfc_source, classification)

@spec generate(String.t(), PhoenixVapor.Hybrid.Classifier.classification()) ::
  {:ok, String.t()} | {:error, term()}

Generate the client JS module for a hybrid component.

Takes the raw SFC source and classification, produces a self-contained JS module that can hydrate server-rendered HTML and manage client reactivity.

transform(vize_code, classification)

Transform Vize's Vue Vapor output for hybrid mode.

Performs AST-based rewrites:

  • Wraps __props access in a reactive bridge
  • Replaces server action function bodies
  • Adds bridge exports