Skip to main content

Crate crepuscularity_native

Crate crepuscularity_native 

Source
Expand description

Lower .crepus templates to a JSON view tree for SwiftUI, Jetpack Compose, and future android-activity / objc2 shells.

§Crate layout

  • ir — serializable ViewIr / ViewNode / ViewStyle (the contract with shells).
  • style — Tailwind-like class → style hints (extend here for GPUI parity).
  • include_expandinclude(Vec<Node>, TemplateContext) without IR cycles.
  • render — AST lowering and public render_* entry points.
  • mutations — renderer-agnostic, path-based IR mutations and diffing.
  • hot_reload — structured hot-reload protocol + conservative AST gate.

§Sharing / codegen (bindgen, other repos)

  • bindgen generates Rust FFI from C/C++ headers. It does not extract types from Rust for Swift/Kotlin, and it does not import arbitrary “other project” sources—it wraps existing native (C) APIs.
  • Single source of truth options that do fit native shells:
    • schemars on ViewIr + JSON Schemaquicktype, OpenAPI generators, etc. for Swift/Kotlin.
    • A tiny build.rs that emits fixture.json and optional bindings (same repo or path dependency / git submodule).
    • Publish crepuscularity-native to crates.io and depend on it from another Rust workspace as usual.

§Coverage vs GPUI / web

Not 100% parity with GPUI styler.rs—expand style.

Re-exports§

pub use codegen::generate_native_source;
pub use codegen::NativeCodegenTarget;
pub use colors::resolve_rgba;
pub use hot_reload::ast_shape_compatible;
pub use hot_reload::plan_hot_reload;
pub use hot_reload::HotReloadEnvelope;
pub use hot_reload::HotReloadMessage;
pub use ir::PickerOption;
pub use ir::StackAxis;
pub use ir::ViewIr;
pub use ir::ViewNode;
pub use ir::ViewStyle;
pub use ir::IR_VERSION;
pub use mutations::apply_mutations;
pub use mutations::diff_ir;
pub use mutations::IrMutation;

Modules§

codegen
colors
Tailwind CSS v4 colors and CSS color resolution for native View IR.
hot_reload
ir
JSON-serializable view intermediate representation (platform-neutral).
mutations
style
Maps Tailwind utility classes onto ViewStyle and stack alignment hints.

Enums§

CrepusError
Primary error type for crate::parser, crate::eval, and related core APIs.

Functions§

render_component_file_to_ir
Lower a named component from a multi-component .crepus file.
render_from_files
Render from a virtual file map (entry may use #Component suffix).
render_nodes_to_ir
Lower already-parsed nodes into a ViewIr.
render_template_to_ir
Parse and lower a template string to IR.
to_json
Serialize IR to JSON (compact).
to_json_pretty
Serialize IR to pretty-printed JSON (fixtures / debugging).