gear_mesh/
lib.rs

1//! # gear-mesh
2//!
3//! Next-generation Rust to TypeScript type definition sharing library.
4//!
5//! ## Features
6//!
7//! - **Type Conversion**: Automatic Rust → TypeScript type conversion
8//! - **Branded Types**: Newtype pattern → TypeScript Branded Types
9//! - **Doc Comments**: Rust doc comments → JSDoc
10//! - **BigInt Support**: Automatic i64/u64 → bigint conversion
11//! - **Validation**: Runtime validation function generation
12//! - **Serde Integration**: Full serde attribute support
13//!
14//! ## Quick Start
15//!
16//! ```rust
17//! use gear_mesh::GearMesh;
18//!
19//! #[derive(GearMesh)]
20//! #[gear_mesh(branded)]
21//! struct UserId(i32);
22//!
23//! #[derive(GearMesh)]
24//! struct User {
25//!     id: UserId,
26//!     name: String,
27//!     email: Option<String>,
28//! }
29//! ```
30//!
31//! Generated TypeScript:
32//!
33//! ```typescript
34//! type Brand<T, B> = T & { readonly __brand: B };
35//!
36//! export type UserId = Brand<number, "UserId">;
37//! export const UserId = (value: number): UserId => value as UserId;
38//!
39//! export interface User {
40//!     id: UserId;
41//!     name: string;
42//!     email?: string | null;
43//! }
44//! ```
45//!
46//! ## CLI Usage
47//!
48//! Install the CLI tool:
49//!
50//! ```bash
51//! cargo install gear-mesh-cli
52//! ```
53//!
54//! Generate TypeScript definitions:
55//!
56//! ```bash
57//! gear-mesh generate --input src --output bindings
58//! gear-mesh watch --input src --output bindings
59//! ```
60//!
61//! ## Configuration
62//!
63//! Create `gear-mesh.toml`:
64//!
65//! ```toml
66//! [generator]
67//! use_bigint = true
68//! generate_branded = true
69//! generate_jsdoc = true
70//!
71//! [paths]
72//! input = "src"
73//! output = "bindings"
74//! ```
75
76// Re-export everything from gear-mesh-generator (which includes the facade)
77pub use gear_mesh_generator::*;
78
79// Explicitly re-export commonly used items for discoverability
80pub use gear_mesh_core::{DocComment, GearMeshType, TypeKind, ValidationRule};
81
82pub use gear_mesh_derive::GearMesh;
83
84// Re-export inventory for use in proc-macro
85pub use inventory;
86
87// Automatic type collection
88mod inventory_collect;
89pub use inventory_collect::{TypeInfo, generate_types, generate_types_to_dir};
90
91// Output path registry for automatic generation
92mod output_registry;
93mod type_deps;
94pub use output_registry::register_output;
95pub use type_deps::extract_type_dependencies;
96
97// Export types macro for build-time type generation
98#[macro_use]
99mod export_macro;