macroforge_ts_macros
Derive macros for TypeScript compile-time code generation
This crate provides procedural macros for generating TypeScript macro infrastructure in the Macroforge ecosystem. It simplifies the creation of derive macros that can transform TypeScript classes at compile time.
Overview
The primary macro provided is [ts_macro_derive], which transforms a Rust function
into a fully-fledged TypeScript macro that integrates with the Macroforge runtime.
Example
use ts_macro_derive;
This generates:
- A struct implementing the [
Macroforge] trait - A NAPI function for JavaScript interop
- Registration with the macro registry via
inventory
Architecture
The generated code follows this pattern:
- Macro Struct: A unit struct that implements the
Macroforgetrait - NAPI Bridge: A function exposed to JavaScript that handles JSON serialization
- Descriptor: Static metadata about the macro for runtime discovery
- Registration: Automatic registration with the
inventorycrate
Installation
Add this to your Cargo.toml:
[]
= "0.1.34"
Key Exports
Functions
ts_macro_derive- A procedural macro attribute that transforms a function into a TypeScript derive macro.
API Reference
See the full API documentation on the Macroforge website.
License
MIT