Expand description
Bi-directional & multi-target Native View Engine (NV) code generator.
Organized as a compiler pipeline:
-
abi: Askama-rendered host ABI data (Core + Scene ABI, word-table field specs, golden XXH64 vectors) for the staticpackages/core/host-*runtimes. -
schema: Intermediate representations and validation (export,hybrid). -
frontend: Input specification parsers (rn_spec, andhybrid_specvianativeview-hybrid-spec). -
targets: Output-language code emitters (c_cpp,rust,swift,kotlin_java,dart,typescript) plus unified multi-target dispatchers. -
direct_specs: discovery of thepackages/modules/*/src/spec.rsDirect-FFI specs and their module-leaf layout.
Dependencies: nativeview-abi / nativeview-hash (ABI descriptors, XXH64), nativeview-hybrid-spec (the hybrid
spec IR, syn 2 frontend, and Rust emitter), serde derives on the IR, askama (templates),
and toml (module [package.metadata.nativeview] for spec discovery). Reading specs
from JSON files is the CLI’s job (nativeview-cli), so this crate never links serde_json.
Re-exports§
pub use abi::generate_abi_files;pub use abi::generate_all_abi_files;pub use abi::generate_c_abi_header;pub use abi::generate_dart_module_table_file;pub use abi::generate_flat_op_codec_files;pub use abi::generate_flat_op_codec_files_for_module;pub use abi::generate_hash_vector_files;pub use abi::generate_java_module_table_file;pub use abi::generate_module_c_abi_header;pub use abi::generate_module_java_abi_file;pub use abi::generate_module_table_header;pub use abi::generate_swift_module_table_file;pub use abi::generate_table_files;pub use abi::generate_ts_module_table_file;pub use abi::java_host::generate_java_host_files;pub use abi::policy::PolicySymbol;pub use abi::policy::generate_policy_files;pub use abi::policy::policy_container;pub use abi::policy::policy_langs;pub use abi::policy::policy_read_symbols;pub use direct_specs::DirectSpec;pub use direct_specs::ModuleLayout;pub use direct_specs::ModuleLeaf;pub use direct_specs::discover_direct_specs;pub use direct_specs::discover_direct_specs_in;pub use direct_specs::discover_module_layouts_in;pub use direct_specs::generate_direct_spec_host_files;pub use module_catalog::CMAKE_CATALOG_PATH;pub use module_catalog::ModuleCatalog;pub use module_catalog::discover_module_catalog_in;pub use module_catalog::generate_cmake_module_catalog;pub use abi::top_layer_vectors::PressVector;pub use abi::top_layer_vectors::TopLayerVectors;pub use abi::top_layer_vectors::generate_top_layer_vector_files;pub use targets::export_pkg::ExportPackageMeta;pub use targets::export_pkg::IosFrameworkPlistMeta;pub use targets::export_pkg::emit_android_library_manifest_xml;pub use targets::export_pkg::emit_apple_export_anchor_h;pub use targets::export_pkg::emit_apple_export_anchor_m;pub use targets::export_pkg::emit_ios_framework_info_plist;pub use targets::export_pkg::emit_nitro_android_build_gradle;pub use targets::export_pkg::emit_nitro_package_swift;pub use targets::export_pkg::emit_nitro_pkg_index_ts;pub use targets::export_pkg::emit_nitro_pkg_package_json;pub use targets::export_pkg::emit_rn_android_build_gradle;pub use targets::export_pkg::emit_rn_pkg_index_ts;pub use targets::export_pkg::emit_rn_pkg_package_json;pub use targets::export_pkg::emit_rn_podspec;pub use targets::export_pkg::emit_web_pkg_index_ts;pub use targets::export_pkg::emit_web_pkg_package_json;pub use targets::export_pkg::emit_web_pkg_tsconfig_json;pub use targets::export_pkg::xml_escape;pub use targets::nitro_ui::emit_nitro_json_with_module_name;pub use embedded_templates::TemplateDrift;pub use embedded_templates::verify_embedded_templates;pub use error::CodegenError;pub use frontend::parse_hybrid_rust_spec;pub use frontend::parse_hybrid_rust_spec_file;pub use frontend::parse_rn_spec;pub use frontend::parse_rn_spec_file;pub use schema::export::CommandSpec;pub use schema::export::ComponentOptions;pub use schema::export::DefaultValue;pub use schema::export::EventBubbling;pub use schema::export::EventSpec;pub use schema::export::ExportComposeOutput;pub use schema::export::ExportFlutterOutput;pub use schema::export::ExportNitroUiOutput;pub use schema::export::ExportRnOutput;pub use schema::export::ExportSwiftUiOutput;pub use schema::export::ExportTarget;pub use schema::export::ExportWebComponentOutput;pub use schema::export::GeneratedFile;pub use schema::export::ImportRnOutput;pub use schema::export::MultiTargetExportOutput;pub use schema::export::ObjectField;pub use schema::export::ParamSpec;pub use schema::export::ParsedRnSpec;pub use schema::export::PropSpec;pub use schema::export::PropType;pub use schema::export::RnComponentSpec;pub use schema::export::TurboModuleMethod;pub use schema::export::TurboModuleSpec;pub use targets::generate_export_compose;pub use targets::generate_export_flutter;pub use targets::generate_export_nitro_ui;pub use targets::generate_export_rn;pub use targets::generate_export_rn_with_ios_module;pub use targets::generate_export_swiftui;pub use targets::generate_export_web_component;pub use targets::generate_hybrid_all;pub use targets::generate_hybrid_cpp;pub use targets::generate_hybrid_dart;pub use targets::generate_hybrid_kotlin;pub use targets::generate_hybrid_rust;pub use targets::generate_hybrid_swift;pub use targets::generate_hybrid_target;pub use targets::generate_hybrid_ts;pub use targets::generate_import_rn;pub use targets::HybridGenerateOutput;
Modules§
- abi
- Host ABI data generated with Askama templates (
packages/core/codegen/templates/): the Core and runtime scene ABIs, the word-table field specs, and the golden XXH64 vectors. Every file lands next to the static runtime it plugs into (packages/core/host-{cxx,swift,java,dart,ts}). - direct_
specs - Discovery of the Direct-FFI capability specs
nv codegen abirenders, and the module-leaf layout their host bindings (and module-homednv_policy!constants) land in. - embedded_
templates - Proof that this build’s Askama code was compiled from the templates of the checkout it runs in.
- error
- frontend
- Input specification parsers: React Native specs (
rn_spec) and declarative hybrid Rust specs (hybrid_spec, delegated tonativeview_hybrid_spec::frontend). - module_
catalog - Discovery and emission of
cxx/cmake/NvModuleCatalog.generated.cmakefrompackages/modules/*/Cargo.toml([package.metadata.nativeview.direct_host]and[package.metadata.nativeview.component]). - naming
- Identifier and case-conversion utilities for Rust, TypeScript, C++20, ObjC++, and Kotlin.
- schema
- Schema IRs, layout computation, validation, and colocated
AbiFileDescriptorbridges. - targets
- Target-language code emitters organized by output language, plus unified multi-target
dispatchers for Hybrid FFI and RN import/export. Host ABI data lives in
crate::abi.
Structs§
- Flat
OpStream Desc - Derives
NvEncodeandNvDecodefor Tier-2 little-endian structs and enums. - Hybrid
Alias Spec - Opaque handle or typedef alias declared with
#[nv_hybrid_alias] pub type ... = ...;. - Hybrid
Const Spec - Named constant declared with
#[nv_hybrid_const] pub const .... - Hybrid
Enum Spec - C-ABI enum declared with
#[nv_hybrid_enum]. - Hybrid
Enum Variant - One variant of a
#[repr(u8|u16|u32|i32)] #[nv_hybrid_enum]. - Hybrid
Event Spec - Typed event declared with
#[event]or#[event(retained)]on aHybridModuleSpecorHybridViewSpec. - Hybrid
Field Spec - Named field of a
#[nv_hybrid_struct]or#[nv_hybrid_union]. - Hybrid
File Spec - Complete parsed or programmatically constructed Hybrid FFI specification file.
- Hybrid
Method Spec - Method declared on a
HybridModuleSpec, imperative#[method]on aHybridViewSpec, or C API function. - Hybrid
Module Spec - Nitro-style native module declared with
#[nv_hybrid_module(name = "...")]. - Hybrid
Param Spec - Named parameter of a method or view event.
- Hybrid
Prop Spec - Typed prop declared with
#[prop]on aHybridViewSpec. - Hybrid
Struct Spec - Structured record declared with
#[nv_hybrid_struct]or#[nv_hybrid_union]. - Hybrid
View Spec - Nitro-style native view component declared with
#[nv_hybrid_view(name = "...")].
Enums§
- Hybrid
Binding - FFI binding mechanism for a hybrid module or view (
binding = "direct"default, or"vtable"). - Hybrid
Default Value - Typed literal default value for a
#[prop(default = ...)]on aHybridView. - Hybrid
Impl - Which side implements a
binding = "direct"module (impl = "rust"default, or"host"). - Hybrid
Target - Target languages emitted by the Hybrid FFI generator.
- Hybrid
Type - Rich typed system shared across Hybrid modules, views, structs, enums, and events.
Constants§
- NV_
HYBRID_ ABI_ VERSION - Current Hybrid FFI vtable ABI version stamped into every generated vtable (compile-time locked
against
nativeview_abi::hybrid::NV_HYBRID_ABI_VERSIONinnativeview-codegen). - NV_
HYBRID_ INTERFACE_ ID_ BASE - Base interface ID for generated hybrid vtables (
>= 0x1000_0000), keeping the low range (1..=4) permanently reserved for core NV interfaces (NV_IFACE_SURFACE..NV_IFACE_DEV).
Functions§
- compute_
hybrid_ interface_ id - Computes a deterministic hybrid
interface_id >= 0x1000_0000for a module or view. - export_
all_ targets - Exports every
#[nv_hybrid_view]infileacross multipleExportTargets (orExportTarget::ALL). - export_
compose - Export one
#[nv_hybrid_view]to a typed Jetpack Compose@Composablewrappingio.github.nativeview.compose.NvSurface. - export_
flutter - Export one
#[nv_hybrid_view]to a typed FlutterStatefulWidgetusingdart:ffi+nativeview_flutter. - export_
lib_ stem - Crate-level snake_case library stem shared by all views in
file(lib<stem>.so,<stem>_web.js), ensuring multi-view specs load from one compiled crate binary while differentiating views byvtable_symbol/componentName. - export_
nitro_ ui - Export one
#[nv_hybrid_view]to amargelo/nitro-uibare Nitro view package (5 files). - export_
rn - Export one
#[nv_hybrid_view]to a drop-in React Native Fabric NativeComponent package (5 files). - export_
swiftui - Export one
#[nv_hybrid_view]to a typed SwiftUIViewwrappingNativeViewSwiftUI.NvSurfaceRepresentable. - export_
target - Exports every
#[nv_hybrid_view]infileto one requestedExportTarget. - export_
web_ component - Export one
#[nv_hybrid_view]to a Light-DOM Custom Element<nv-...>+.d.ts+ typed React.tsx. - import_
rn_ file - CLI entrypoint (
nv codegen import-rn): parse a.ts/.jsspec file on disk (following RN re-export wrappers automatically) and emit Rust + C++20 files. - import_
rn_ source - Parse RN spec source text and emit zero-JS Rust + C++20 Fabric adapter files.
- ios_
core_ framework_ name - Dynamic iOS
.framework/.xcframeworkbundle name for an exported component (<Mod>Core), keeping the dynamic Rust binary distinct from the CocoaPods/SwiftPM wrapper module<Mod>. - nitro_
ios_ anchor_ fn - C anchor function exported by
<Mod>Anchor’sNvExportAnchor.minnitro-ui-pkgthat resolves each view’s<vtable_symbol>from its isolated<Mod>Core.frameworkviadlopen(RTLD_LOCAL)+dlsym. - rn_
codegen_ spec_ name - Canonical React Native
codegenConfig.nameand<react/renderer/components/<name>/*.h>header directory shared acrosspackage.jsonand generated ObjC++ Fabric ComponentViews.