@macroforge/mcp-server 0.1.42 → 0.1.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/LICENSE +22 -0
  2. package/docs/BOOK.md +165 -0
  3. package/docs/api/api-overview.md +67 -48
  4. package/docs/api/expand-sync.md +88 -53
  5. package/docs/api/native-plugin.md +121 -71
  6. package/docs/api/position-mapper.md +115 -55
  7. package/docs/api/transform-sync.md +86 -60
  8. package/docs/builtin-macros/clone.md +0 -20
  9. package/docs/builtin-macros/debug.md +0 -23
  10. package/docs/builtin-macros/default.md +1 -40
  11. package/docs/builtin-macros/deserialize/example.md +8 -1416
  12. package/docs/builtin-macros/deserialize.md +8 -1416
  13. package/docs/builtin-macros/hash.md +0 -42
  14. package/docs/builtin-macros/macros-overview/detailed-documentation.md +13 -0
  15. package/docs/builtin-macros/macros-overview/enum-support.md +30 -0
  16. package/docs/builtin-macros/macros-overview/interface-support.md +28 -0
  17. package/docs/builtin-macros/macros-overview/overview.md +36 -0
  18. package/docs/builtin-macros/macros-overview/type-alias-support.md +62 -0
  19. package/docs/builtin-macros/macros-overview.md +171 -130
  20. package/docs/builtin-macros/ord.md +0 -25
  21. package/docs/builtin-macros/partial-eq.md +0 -84
  22. package/docs/builtin-macros/partial-ord.md +2 -32
  23. package/docs/builtin-macros/serialize.md +2 -62
  24. package/docs/concepts/architecture.md +125 -48
  25. package/docs/concepts/derive-system/built-in-vs-custom-macros.md +13 -0
  26. package/docs/concepts/derive-system/overview.md +200 -0
  27. package/docs/concepts/derive-system.md +157 -104
  28. package/docs/concepts/how-macros-work.md +98 -47
  29. package/docs/custom-macros/custom-overview.md +79 -57
  30. package/docs/custom-macros/rust-setup.md +138 -99
  31. package/docs/custom-macros/ts-macro-derive/accessing-field-data.md +40 -31
  32. package/docs/custom-macros/ts-macro-derive/adding-imports.md +14 -11
  33. package/docs/custom-macros/ts-macro-derive/attribute-options.md +20 -25
  34. package/docs/custom-macros/ts-macro-derive/complete-example.md +40 -38
  35. package/docs/custom-macros/ts-macro-derive/deriveinput-structure.md +49 -47
  36. package/docs/custom-macros/ts-macro-derive/function-signature.md +12 -0
  37. package/docs/custom-macros/ts-macro-derive/overview.md +9 -7
  38. package/docs/custom-macros/ts-macro-derive/parsing-input.md +20 -18
  39. package/docs/custom-macros/ts-macro-derive/returning-errors.md +15 -13
  40. package/docs/custom-macros/ts-macro-derive.md +322 -228
  41. package/docs/custom-macros/ts-quote/backtick-template-literals.md +19 -7
  42. package/docs/custom-macros/ts-quote/comments-and.md +56 -22
  43. package/docs/custom-macros/ts-quote/complete-example-json-derive-macro.md +89 -98
  44. package/docs/custom-macros/ts-quote/conditionals-ifif.md +35 -29
  45. package/docs/custom-macros/ts-quote/identifier-concatenation-content.md +30 -22
  46. package/docs/custom-macros/ts-quote/iteration-for.md +48 -40
  47. package/docs/custom-macros/ts-quote/local-constants-let.md +23 -21
  48. package/docs/custom-macros/ts-quote/match-expressions-match.md +46 -38
  49. package/docs/custom-macros/ts-quote/overview.md +5 -10
  50. package/docs/custom-macros/ts-quote/pattern-matching-iflet.md +39 -0
  51. package/docs/custom-macros/ts-quote/quick-reference.md +50 -129
  52. package/docs/custom-macros/ts-quote/side-effects-do.md +13 -78
  53. package/docs/custom-macros/ts-quote/string-interpolation-textexpr.md +36 -0
  54. package/docs/custom-macros/ts-quote/tsstream-injection-typescript.md +43 -35
  55. package/docs/custom-macros/ts-quote/while-loops-while.md +31 -23
  56. package/docs/custom-macros/ts-quote.md +800 -520
  57. package/docs/getting-started/first-macro.md +98 -71
  58. package/docs/getting-started/installation.md +109 -65
  59. package/docs/integration/cli.md +214 -105
  60. package/docs/integration/configuration.md +115 -72
  61. package/docs/integration/integration-overview.md +55 -18
  62. package/docs/integration/mcp-server.md +84 -43
  63. package/docs/integration/svelte-preprocessor.md +183 -126
  64. package/docs/integration/typescript-plugin.md +101 -53
  65. package/docs/integration/vite-plugin.md +116 -76
  66. package/docs/language-servers/ls-overview.md +37 -21
  67. package/docs/language-servers/svelte.md +69 -38
  68. package/docs/language-servers/zed.md +81 -44
  69. package/docs/roadmap/roadmap.md +75 -53
  70. package/docs/sections.json +333 -44
  71. package/package.json +27 -28
@@ -1,61 +1,63 @@
1
1
  ## DeriveInput Structure
2
2
 
3
- ```rust
4
- struct DeriveInput {
5
- pub ident: Ident, // The type name
6
- pub span: SpanIR, // Span of the type definition
7
- pub attrs: Vec<Attribute>, // Decorators (excluding @derive)
8
- pub data: Data, // The parsed type data
9
- pub context: MacroContextIR, // Macro context with spans
10
-
11
- // Helper methods
12
- fn name(&self) -> &str; // Get the type name
13
- fn decorator_span(&self) -> SpanIR; // Span of @derive decorator
14
- fn as_class(&self) -> Option<&DataClass>;
15
- fn as_interface(&self) -> Option<&DataInterface>;
16
- fn as_enum(&self) -> Option<&DataEnum>;
3
+ Rust
4
+
5
+ ```
6
+ struct DeriveInput {
7
+     pub ident: Ident,           // The type name
8
+     pub span: SpanIR,           // Span of the type definition
9
+     pub attrs: Vec<Attribute>,  // Decorators (excluding @derive)
10
+     pub data: Data,             // The parsed type data
11
+     pub context: MacroContextIR, // Macro context with spans
12
+
13
+     // Helper methods
14
+     fn name(&self) -> &str;              // Get the type name
15
+     fn decorator_span(&self) -> SpanIR;  // Span of @derive decorator
16
+     fn as_class(&self) -> Option<&DataClass>;
17
+     fn as_interface(&self) -> Option<&DataInterface>;
18
+     fn as_enum(&self) -> Option<&DataEnum>;
17
19
  }
18
20
 
19
- enum Data {
20
- Class(DataClass),
21
- Interface(DataInterface),
22
- Enum(DataEnum),
23
- TypeAlias(DataTypeAlias),
21
+ enum Data {
22
+     Class(DataClass),
23
+     Interface(DataInterface),
24
+     Enum(DataEnum),
25
+     TypeAlias(DataTypeAlias),
24
26
  }
25
27
 
26
- impl DataClass {
27
- fn fields(&self) -> &[FieldIR];
28
- fn methods(&self) -> &[MethodSigIR];
29
- fn field_names(&self) -> impl Iterator<Item = &str>;
30
- fn field(&self, name: &str) -> Option<&FieldIR>;
31
- fn body_span(&self) -> SpanIR; // For inserting code into class body
32
- fn type_params(&self) -> &[String]; // Generic type parameters
33
- fn heritage(&self) -> &[String]; // extends/implements clauses
34
- fn is_abstract(&self) -> bool;
28
+ impl DataClass {
29
+     fn fields(&self) -> &[FieldIR];
30
+     fn methods(&self) -> &[MethodSigIR];
31
+     fn field_names(&self) -> impl Iterator<Item = &str>;
32
+     fn field(&self, name: &str) -> Option<&FieldIR>;
33
+     fn body_span(&self) -> SpanIR;      // For inserting code into class body
34
+     fn type_params(&self) -> &[String]; // Generic type parameters
35
+     fn heritage(&self) -> &[String];    // extends/implements clauses
36
+     fn is_abstract(&self) -> bool;
35
37
  }
36
38
 
37
- impl DataInterface {
38
- fn fields(&self) -> &[InterfaceFieldIR];
39
- fn methods(&self) -> &[InterfaceMethodIR];
40
- fn field_names(&self) -> impl Iterator<Item = &str>;
41
- fn field(&self, name: &str) -> Option<&InterfaceFieldIR>;
42
- fn body_span(&self) -> SpanIR;
43
- fn type_params(&self) -> &[String];
44
- fn heritage(&self) -> &[String]; // extends clauses
39
+ impl DataInterface {
40
+     fn fields(&self) -> &[InterfaceFieldIR];
41
+     fn methods(&self) -> &[InterfaceMethodIR];
42
+     fn field_names(&self) -> impl Iterator<Item = &str>;
43
+     fn field(&self, name: &str) -> Option<&InterfaceFieldIR>;
44
+     fn body_span(&self) -> SpanIR;
45
+     fn type_params(&self) -> &[String];
46
+     fn heritage(&self) -> &[String];    // extends clauses
45
47
  }
46
48
 
47
- impl DataEnum {
48
- fn variants(&self) -> &[EnumVariantIR];
49
- fn variant_names(&self) -> impl Iterator<Item = &str>;
50
- fn variant(&self, name: &str) -> Option<&EnumVariantIR>;
49
+ impl DataEnum {
50
+     fn variants(&self) -> &[EnumVariantIR];
51
+     fn variant_names(&self) -> impl Iterator<Item = &str>;
52
+     fn variant(&self, name: &str) -> Option<&EnumVariantIR>;
51
53
  }
52
54
 
53
- impl DataTypeAlias {
54
- fn body(&self) -> &TypeBody;
55
- fn type_params(&self) -> &[String];
56
- fn is_union(&self) -> bool;
57
- fn is_object(&self) -> bool;
58
- fn as_union(&self) -> Option<&[TypeMember]>;
59
- fn as_object(&self) -> Option<&[InterfaceFieldIR]>;
55
+ impl DataTypeAlias {
56
+     fn body(&self) -> &TypeBody;
57
+     fn type_params(&self) -> &[String];
58
+     fn is_union(&self) -> bool;
59
+     fn is_object(&self) -> bool;
60
+     fn as_union(&self) -> Option<&[TypeMember]>;
61
+     fn as_object(&self) -> Option<&[InterfaceFieldIR]>;
60
62
  }
61
63
  ```
@@ -0,0 +1,12 @@
1
+ ## Function Signature
2
+
3
+ Rust
4
+
5
+ ```
6
+ pub fn my_macro(mut input: TsStream) -> Result<TsStream, MacroforgeError>
7
+ ```
8
+
9
+ | Parameter | Description |
10
+ | ----------------------------------- | ------------------------------------------------------- |
11
+ | `input: TsStream` | Token stream containing the class/interface AST |
12
+ | `Result<TsStream, MacroforgeError>` | Returns generated code or an error with source location |
@@ -1,15 +1,17 @@
1
- # ts_macro_derive
1
+ # ts\_macro\_derive
2
2
 
3
- *The `#[ts_macro_derive]` attribute is a Rust procedural macro that registers your function as a Macroforge derive macro.*
3
+ The `#[ts_macro_derive]` attribute is a Rust procedural macro that registers your function as a Macroforge derive macro.
4
4
 
5
5
  ## Basic Syntax
6
6
 
7
- ```rust
8
- use macroforge_ts::macros::ts_macro_derive;
9
- use macroforge_ts::ts_syn::{TsStream, MacroforgeError};
7
+ Rust
8
+
9
+ ```
10
+ use macroforge_ts::macros::ts_macro_derive;
11
+ use macroforge_ts::ts_syn::{TsStream, MacroforgeError};
10
12
 
11
13
  #[ts_macro_derive(MacroName)]
12
- pub fn my_macro(mut input: TsStream) -> Result<TsStream, MacroforgeError> {
13
- // Macro implementation
14
+ pub fn my_macro(mut input: TsStream) -> Result<TsStream, MacroforgeError> {
15
+     // Macro implementation
14
16
  }
15
17
  ```
@@ -2,26 +2,28 @@
2
2
 
3
3
  Use `parse_ts_macro_input!` to convert the token stream:
4
4
 
5
- ```rust
6
- use macroforge_ts::ts_syn::{Data, DeriveInput, parse_ts_macro_input};
5
+ Rust
6
+
7
+ ```
8
+ use macroforge_ts::ts_syn::{Data, DeriveInput, parse_ts_macro_input};
7
9
 
8
10
  #[ts_macro_derive(MyMacro)]
9
- pub fn my_macro(mut input: TsStream) -> Result<TsStream, MacroforgeError> {
10
- let input = parse_ts_macro_input!(input as DeriveInput);
11
+ pub fn my_macro(mut input: TsStream) -> Result<TsStream, MacroforgeError> {
12
+     let input = parse_ts_macro_input!(input as DeriveInput);
11
13
 
12
- // Access class data
13
- match &input.data {
14
- Data::Class(class) => {
15
- let class_name = input.name();
16
- let fields = class.fields();
17
- // ...
18
- }
19
- Data::Interface(interface) => {
20
- // Handle interfaces
21
- }
22
- Data::Enum(_) => {
23
- // Handle enums (if supported)
24
- }
25
- }
14
+     // Access class data
15
+     match &input.data {
16
+         Data::Class(class) => {
17
+             let class_name = input.name();
18
+             let fields = class.fields();
19
+             // ...
20
+         }
21
+         Data::Interface(interface) => {
22
+             // Handle interfaces
23
+         }
24
+         Data::Enum(_) => {
25
+             // Handle enums (if supported)
26
+         }
27
+     }
26
28
  }
27
29
  ```
@@ -2,20 +2,22 @@
2
2
 
3
3
  Use `MacroforgeError` to report errors with source locations:
4
4
 
5
- ```rust
5
+ Rust
6
+
7
+ ```
6
8
  #[ts_macro_derive(ClassOnly)]
7
- pub fn class_only(mut input: TsStream) -> Result<TsStream, MacroforgeError> {
8
- let input = parse_ts_macro_input!(input as DeriveInput);
9
+ pub fn class_only(mut input: TsStream) -> Result<TsStream, MacroforgeError> {
10
+     let input = parse_ts_macro_input!(input as DeriveInput);
9
11
 
10
- match &input.data {
11
- Data::Class(_) => {
12
- // Generate code...
13
- Ok(body! { /* ... */ })
14
- }
15
- _ => Err(MacroforgeError::new(
16
- input.decorator_span(),
17
- "@derive(ClassOnly) can only be used on classes",
18
- )),
19
- }
12
+     match &input.data {
13
+         Data::Class(_) => {
14
+             // Generate code...
15
+             Ok(body! { /* ... */ })
16
+         }
17
+         _ => Err(MacroforgeError::new(
18
+             input.decorator_span(),
19
+             "@derive(ClassOnly) can only be used on classes",
20
+         )),
21
+     }
20
22
  }
21
23
  ```