Skip to main content

Crate lingxia_native_codegen

Crate lingxia_native_codegen 

Source
Expand description

Code generation for #[lingxia::native] host handlers.

Scans Rust source files for #[lingxia::native("route")] / #[native("route")] function attributes and pub struct definitions, then emits one of:

  • .ts — TypeScript client with typed invoke / stream / channel bindings
  • .js — browser global JS client
  • .rs — Rust auto-register module (mod __lingxia_native { pub fn install() })

Intended as a build-dependency so build.rs can produce the artifacts during cargo build, before the lxapp is assembled.

Functions§

generate_rust_registry
Emit the Rust auto-register module that wraps every discovered handler’s register_host_entry(...) call inside mod __lingxia_native { pub fn install() }. out must end in .rs.
generate_ts_client
Emit the TypeScript (or browser-global JS) client for every #[native] handler discovered under rust_dir. Output format is chosen by the extension of out (.ts → TS module, .js → browser global).