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
//! Application Binary Interface (ABI) types for stable macro communication.
//!
//! This module provides the foundational types for the Macroforge macro system's
//! ABI. These types are designed to be:
//!
//! - **Serializable**: All types implement `Serialize` and `Deserialize` for
//! communication between the macro host and macro implementations.
//! - **Stable**: The structure is versioned and backward-compatible to ensure
//! macros work across different versions.
//! - **Self-contained**: Types include all information needed for macro execution.
//!
//! ## Module Structure
//!
//! - [`ir`] - Intermediate representation types for TypeScript constructs
//! - [`span`] - Source span representation for position tracking
//! - [`patch`] - Code modification types for macro output
//! - [`source_map`] - Source mapping for expanded code positions
//! - [`helpers`] - Utility functions for common operations
//!
//! ## Key Types
//!
//! | Type | Purpose |
//! |------|---------|
//! | [`SpanIR`] | Byte-offset source spans |
//! | [`Patch`] | Code modification operations |
//! | [`MacroResult`] | Return type from macro functions |
//! | [`Diagnostic`] | Error/warning messages |
//! | [`MacroContextIR`] | Complete macro invocation context |
//!
//! ## Example: Macro Flow
//!
//! ```rust,no_run
//! use macroforge_ts_syn::{MacroContextIR, MacroResult, Patch, SpanIR};
//!
//! pub fn my_macro(ctx: MacroContextIR) -> MacroResult {
//! // 1. Access the target from context
//! let class = ctx.as_class().expect("Expected a class");
//!
//! // 2. Generate code
//! let code = format!("debug() {{ return '{}'; }}", class.name);
//!
//! // 3. Create a patch to insert the code
//! let patch = Patch::Insert {
//! at: SpanIR::new(class.body_span.end - 1, class.body_span.end - 1),
//! code: code.into(),
//! source_macro: Some("Debug".to_string()),
//! };
//!
//! // 4. Return the result
//! MacroResult {
//! runtime_patches: vec![patch],
//! ..Default::default()
//! }
//! }
//! ```
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
/// Re-export of SWC's ECMAScript AST types.
///
/// Available when the `swc` feature is enabled. Provides direct access
/// to the underlying AST types used by the parser.
pub use ast as swc_ast;