1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
//! Ergonomic JavaScript code generation using OXC AST builders
//!
//! This crate provides a high-level, type-safe API for generating JavaScript code
//! using the OXC (Oxidation Compiler) AST infrastructure.
//!
//! # Features
//!
//! - **Type-safe AST building** - Leverage Rust's type system for correct JavaScript generation
//! - **Zero-copy string handling** - Efficient string interning via OXC's `Atom`
//! - **Ergonomic API** - Intuitive method names that mirror JavaScript syntax
//! - **Full module support** - Generate imports, exports, and ES modules
//! - **Modern JS features** - Arrow functions, template literals, destructuring, and more
//!
//! # Examples
//!
//! ## Basic Usage
//!
//! ```rust
//! use fob_gen::ProgramBuilder;
//! use oxc_allocator::Allocator;
//! use oxc_ast::ast::Statement;
//!
//! let allocator = Allocator::default();
//! let mut js = ProgramBuilder::new(&allocator);
//!
//! // Build: const x = 42;
//! let stmt = js.const_decl("x", js.number(42.0));
//! js.push(stmt);
//!
//! // Build: import React from 'react';
//! let import = js.import_default("React", "react");
//! // ModuleDeclarations need to be converted to Statements
//! js.push(Statement::from(import));
//!
//! // Generate code
//! let code = js.generate(&Default::default())?;
//! println!("{}", code);
//! # Ok::<(), fob_gen::GenError>(())
//! ```
//!
//! ## Building Complex Expressions
//!
//! ```rust
//! use fob_gen::ProgramBuilder;
//! use oxc_allocator::Allocator;
//!
//! let allocator = Allocator::default();
//! let mut js = ProgramBuilder::new(&allocator);
//!
//! // Build: console.log("Hello, world!")
//! let console_log = js.call(
//! js.member(js.ident("console"), "log"),
//! vec![js.arg(js.string("Hello, world!"))],
//! );
//! let stmt = js.expr_stmt(console_log);
//! js.push(stmt);
//!
//! let code = js.generate(&Default::default())?;
//! # Ok::<(), fob_gen::GenError>(())
//! ```
//!
//! ## Arrow Functions and Arrays
//!
//! ```rust
//! use fob_gen::ProgramBuilder;
//! use oxc_allocator::Allocator;
//!
//! let allocator = Allocator::default();
//! let mut js = ProgramBuilder::new(&allocator);
//!
//! // Build: const double = x => x * 2;
//! let arrow = js.arrow_fn(
//! vec!["x"],
//! js.binary(
//! js.ident("x"),
//! oxc_ast::ast::BinaryOperator::Multiplication,
//! js.number(2.0),
//! ),
//! );
//! let stmt = js.const_decl("double", arrow);
//! js.push(stmt);
//!
//! let code = js.generate(&Default::default())?;
//! # Ok::<(), fob_gen::GenError>(())
//! ```
pub use ;
pub use ;
pub use ;
pub use JsxBuilder;
pub use ProgramBuilder;
pub use ;
pub use ;
pub use ;
pub use ;
// Re-export commonly used OXC types for convenience
pub use Allocator;
pub use ;
pub use Atom;