@macroforge/mcp-server 0.1.39 → 0.1.42

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.
@@ -1,137 +1,139 @@
1
1
  # Your First Macro
2
2
  *Let's create a class that uses Macroforge's derive macros to automatically generate useful methods.*
3
3
  ## Creating a Class with Derive Macros
4
- Start by creating a simple `User` class. We'll use the `@derive` decorator to automatically generate methods.
5
- **Before:**
4
+ Start by creating a simple <code class="shiki-inline"><span class="line"><span style="--shiki-dark:#E1E4E8;--shiki-light:#24292E">User</code> class. We'll use the <code class="shiki-inline"><span class="line"><span style="--shiki-dark:#E1E4E8;--shiki-light:#24292E">@derive</code> decorator to automatically generate methods.
5
+ <div><div class="flex items-center justify-between gap-2 px-4 py-2 bg-muted rounded-t-lg border border-b-0 border-border">
6
+ **Before:**
6
7
  ```
7
8
  /** @derive(Debug, Clone, PartialEq) */
8
- export class User {
9
+ export class User &#123;
9
10
  name: string;
10
11
  age: number;
11
12
  email: string;
12
13
 
13
- constructor(name: string, age: number, email: string) {
14
+ constructor(name: string, age: number, email: string) &#123;
14
15
  this.name = name;
15
16
  this.age = age;
16
17
  this.email = email;
17
- }
18
- }
19
- ```
18
+ &#125;
19
+ &#125;
20
+ ``` <div class="flex items-center justify-between gap-2 px-4 py-2 bg-muted rounded-t-lg border border-b-0 border-border">
20
21
  **After:**
21
22
  ```
22
- export class User {
23
+ export class User &#123;
23
24
  name: string;
24
25
  age: number;
25
26
  email: string;
26
27
 
27
- constructor(name: string, age: number, email: string) {
28
+ constructor(name: string, age: number, email: string) &#123;
28
29
  this.name = name;
29
30
  this.age = age;
30
31
  this.email = email;
31
- }
32
+ &#125;
32
33
 
33
- static toString(value: User): string {
34
+ static toString(value: User): string &#123;
34
35
  return userToString(value);
35
- }
36
+ &#125;
36
37
 
37
- static clone(value: User): User {
38
+ static clone(value: User): User &#123;
38
39
  return userClone(value);
39
- }
40
+ &#125;
40
41
 
41
- static equals(a: User, b: User): boolean {
42
+ static equals(a: User, b: User): boolean &#123;
42
43
  return userEquals(a, b);
43
- }
44
- }
44
+ &#125;
45
+ &#125;
45
46
 
46
- export function userToString(value: User): string {
47
+ export function userToString(value: User): string &#123;
47
48
  const parts: string[] = [];
48
49
  parts.push('name: ' + value.name);
49
50
  parts.push('age: ' + value.age);
50
51
  parts.push('email: ' + value.email);
51
- return 'User { ' + parts.join(', ') + ' }';
52
- }
52
+ return 'User &#123; ' + parts.join(', ') + ' &#125;';
53
+ &#125;
53
54
 
54
- export function userClone(value: User): User {
55
+ export function userClone(value: User): User &#123;
55
56
  const cloned = Object.create(Object.getPrototypeOf(value));
56
57
  cloned.name = value.name;
57
58
  cloned.age = value.age;
58
59
  cloned.email = value.email;
59
60
  return cloned;
60
- }
61
+ &#125;
61
62
 
62
- export function userEquals(a: User, b: User): boolean {
63
+ export function userEquals(a: User, b: User): boolean &#123;
63
64
  if (a === b) return true;
64
- return a.name === b.name && a.age === b.age && a.email === b.email;
65
- }
65
+ return a.name === b.name &#x26;&#x26; a.age === b.age &#x26;&#x26; a.email === b.email;
66
+ &#125;
66
67
  ``` ## Using the Generated Methods
67
68
  ```
68
- const user = new User("Alice", 30, "alice@example.com");
69
+ const&nbsp;user&nbsp;=&nbsp;new&nbsp;User("Alice",&nbsp;30,&nbsp;"alice@example.com");
69
70
 
70
- // Debug: toString()
71
+ //&nbsp;Debug:&nbsp;toString()
71
72
  console.log(user.toString());
72
- // Output: User &#123; name: Alice, age: 30, email: alice@example.com &#125;
73
+ //&nbsp;Output:&nbsp;User&nbsp;&#123;&nbsp;name:&nbsp;Alice,&nbsp;age:&nbsp;30,&nbsp;email:&nbsp;alice@example.com&nbsp;&#125;
73
74
 
74
- // Clone: clone()
75
- const copy = user.clone();
76
- console.log(copy.name); // "Alice"
75
+ //&nbsp;Clone:&nbsp;clone()
76
+ const&nbsp;copy&nbsp;=&nbsp;user.clone();
77
+ console.log(copy.name);&nbsp;//&nbsp;"Alice"
77
78
 
78
- // Eq: equals()
79
- console.log(user.equals(copy)); // true
79
+ //&nbsp;Eq:&nbsp;equals()
80
+ console.log(user.equals(copy));&nbsp;//&nbsp;true
80
81
 
81
- const different = new User("Bob", 25, "bob@example.com");
82
- console.log(user.equals(different)); // false
82
+ const&nbsp;different&nbsp;=&nbsp;new&nbsp;User("Bob",&nbsp;25,&nbsp;"bob@example.com");
83
+ console.log(user.equals(different));&nbsp;//&nbsp;false
83
84
  ``` ## Customizing Behavior
84
85
  You can customize how macros work using field-level decorators. For example, with the Debug macro:
85
- **Before:**
86
+ <div><div class="flex items-center justify-between gap-2 px-4 py-2 bg-muted rounded-t-lg border border-b-0 border-border">
87
+ **Before:**
86
88
  ```
87
89
  /** @derive(Debug) */
88
- export class User {
89
- /** @debug({ rename: "userId" }) */
90
+ export class User &#123;
91
+ /** @debug(&#123; rename: "userId" &#125;) */
90
92
  id: number;
91
93
 
92
94
  name: string;
93
95
 
94
- /** @debug({ skip: true }) */
96
+ /** @debug(&#123; skip: true &#125;) */
95
97
  password: string;
96
98
 
97
- constructor(id: number, name: string, password: string) {
99
+ constructor(id: number, name: string, password: string) &#123;
98
100
  this.id = id;
99
101
  this.name = name;
100
102
  this.password = password;
101
- }
102
- }
103
- ```
103
+ &#125;
104
+ &#125;
105
+ ``` <div class="flex items-center justify-between gap-2 px-4 py-2 bg-muted rounded-t-lg border border-b-0 border-border">
104
106
  **After:**
105
107
  ```
106
- export class User {
108
+ export class User &#123;
107
109
  id: number;
108
110
 
109
111
  name: string;
110
112
 
111
113
  password: string;
112
114
 
113
- constructor(id: number, name: string, password: string) {
115
+ constructor(id: number, name: string, password: string) &#123;
114
116
  this.id = id;
115
117
  this.name = name;
116
118
  this.password = password;
117
- }
119
+ &#125;
118
120
 
119
- static toString(value: User): string {
121
+ static toString(value: User): string &#123;
120
122
  return userToString(value);
121
- }
122
- }
123
+ &#125;
124
+ &#125;
123
125
 
124
- export function userToString(value: User): string {
126
+ export function userToString(value: User): string &#123;
125
127
  const parts: string[] = [];
126
128
  parts.push('userId: ' + value.id);
127
129
  parts.push('name: ' + value.name);
128
- return 'User { ' + parts.join(', ') + ' }';
129
- }
130
+ return 'User &#123; ' + parts.join(', ') + ' &#125;';
131
+ &#125;
130
132
  ``` ```
131
- const user = new User(42, "Alice", "secret123");
133
+ const&nbsp;user&nbsp;=&nbsp;new&nbsp;User(42,&nbsp;"Alice",&nbsp;"secret123");
132
134
  console.log(user.toString());
133
- // Output: User &#123; userId: 42, name: Alice &#125;
134
- // Note: 'id' is renamed to 'userId', 'password' is skipped
135
+ //&nbsp;Output:&nbsp;User&nbsp;&#123;&nbsp;userId:&nbsp;42,&nbsp;name:&nbsp;Alice&nbsp;&#125;
136
+ //&nbsp;Note:&nbsp;'id'&nbsp;is&nbsp;renamed&nbsp;to&nbsp;'userId',&nbsp;'password'&nbsp;is&nbsp;skipped
135
137
  ``` **Field-level decorators Field-level decorators let you control exactly how each field is handled by the macro. ## Next Steps
136
138
  - [Learn how macros work under the hood](../../docs/concepts)
137
139
  - [Explore all Debug options](../../docs/builtin-macros/debug)
@@ -6,40 +6,40 @@
6
6
  ## Install the Package
7
7
  Install Macroforge using your preferred package manager:
8
8
  ```
9
- npm install macroforge
9
+ npm&nbsp;install&nbsp;macroforge
10
10
  ``` ```
11
- bun add macroforge
11
+ bun&nbsp;add&nbsp;macroforge
12
12
  ``` ```
13
- pnpm add macroforge
13
+ pnpm&nbsp;add&nbsp;macroforge
14
14
  ``` **Info Macroforge includes pre-built native binaries for macOS (x64, arm64), Linux (x64, arm64), and Windows (x64, arm64). ## Basic Usage
15
- The simplest way to use Macroforge is with the built-in derive macros. Add a `@derive` comment decorator to your class:
15
+ The simplest way to use Macroforge is with the built-in derive macros. Add a **<code class="shiki-inline"><span class="line"><span style="--shiki-dark:#E1E4E8;--shiki-light:#24292E">@derive</code> comment decorator to your class:
16
16
  ```
17
- /** @derive(Debug, Clone, PartialEq) */
18
- class User &#123;
19
- name: string;
20
- age: number;
17
+ /**&nbsp;@derive(Debug,&nbsp;Clone,&nbsp;PartialEq)&nbsp;*/
18
+ class&nbsp;User&nbsp;&#123;
19
+ &nbsp;&nbsp;name:&nbsp;string;
20
+ &nbsp;&nbsp;age:&nbsp;number;
21
21
 
22
- constructor(name: string, age: number) &#123;
23
- this.name = name;
24
- this.age = age;
25
- &#125;
22
+ &nbsp;&nbsp;constructor(name:&nbsp;string,&nbsp;age:&nbsp;number)&nbsp;&#123;
23
+ &nbsp;&nbsp;&nbsp;&nbsp;this.name&nbsp;=&nbsp;name;
24
+ &nbsp;&nbsp;&nbsp;&nbsp;this.age&nbsp;=&nbsp;age;
25
+ &nbsp;&nbsp;&#125;
26
26
  &#125;
27
27
 
28
- // After macro expansion, User has:
29
- // - toString(): string (from Debug)
30
- // - clone(): User (from Clone)
31
- // - equals(other: unknown): boolean (from PartialEq)
28
+ //&nbsp;After&nbsp;macro&nbsp;expansion,&nbsp;User&nbsp;has:
29
+ //&nbsp;-&nbsp;toString():&nbsp;string&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(from&nbsp;Debug)
30
+ //&nbsp;-&nbsp;clone():&nbsp;User&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(from&nbsp;Clone)
31
+ //&nbsp;-&nbsp;equals(other:&nbsp;unknown):&nbsp;boolean&nbsp;(from&nbsp;PartialEq)
32
32
  ``` ## IDE Integration
33
- For the best development experience, add the TypeScript plugin to your `tsconfig.json`:
33
+ For the best development experience, add the TypeScript plugin to your <code class="shiki-inline"><span class="line"><span style="--shiki-dark:#E1E4E8;--shiki-light:#24292E">tsconfig.json</code>:
34
34
  ```
35
35
  &#123;
36
- "compilerOptions": &#123;
37
- "plugins": [
38
- &#123;
39
- "name": "@macroforge/typescript-plugin"
40
- &#125;
41
- ]
42
- &#125;
36
+ &nbsp;&nbsp;"compilerOptions":&nbsp;&#123;
37
+ &nbsp;&nbsp;&nbsp;&nbsp;"plugins":&nbsp;[
38
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#123;
39
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"name":&nbsp;"@macroforge/typescript-plugin"
40
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;
41
+ &nbsp;&nbsp;&nbsp;&nbsp;]
42
+ &nbsp;&nbsp;&#125;
43
43
  &#125;
44
44
  ``` This enables features like:
45
45
  - Accurate error positions in your source code
@@ -48,20 +48,19 @@ class User &#123;
48
48
  ## Build Integration (Vite)
49
49
  If you're using Vite, add the plugin to your config for automatic macro expansion during build:
50
50
  ```
51
- import macroforge from "@macroforge/vite-plugin";
52
- import &#123; defineConfig &#125; from "vite";
51
+ import&nbsp;macroforge&nbsp;from&nbsp;"@macroforge/vite-plugin";
52
+ import&nbsp;&#123;&nbsp;defineConfig&nbsp;&#125;&nbsp;from&nbsp;"vite";
53
53
 
54
- export default defineConfig(&#123;
55
- plugins: [
56
- macroforge(&#123;
57
- generateTypes: true,
58
- typesOutputDir: ".macroforge/types"
59
- &#125;)
60
- ]
54
+ export&nbsp;default&nbsp;defineConfig(&#123;
55
+ &nbsp;&nbsp;plugins:&nbsp;[
56
+ &nbsp;&nbsp;&nbsp;&nbsp;macroforge(&#123;
57
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;generateTypes:&nbsp;true,
58
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;typesOutputDir:&nbsp;".macroforge/types"
59
+ &nbsp;&nbsp;&nbsp;&nbsp;&#125;)
60
+ &nbsp;&nbsp;]
61
61
  &#125;);
62
62
  ``` ## Next Steps
63
63
  Now that you have Macroforge installed, learn how to use it:
64
64
  - [Create your first macro](../docs/getting-started/first-macro)
65
65
  - [Understand how macros work](../docs/concepts)
66
- - [Explore built-in macros](../docs/builtin-macros)
67
- **
66
+ - [Explore built-in macros](../docs/builtin-macros)
@@ -3,71 +3,71 @@
3
3
  ## Installation
4
4
  The CLI is a Rust binary. You can install it using Cargo:
5
5
  ```
6
- cargo install macroforge_ts
6
+ cargo&nbsp;install&nbsp;macroforge_ts
7
7
  ``` Or build from source:
8
8
  ```
9
- git clone https://github.com/rymskip/macroforge-ts.git
10
- cd macroforge-ts/crates
11
- cargo build --release --bin macroforge
9
+ git&nbsp;clone&nbsp;https://github.com/rymskip/macroforge-ts.git
10
+ cd&nbsp;macroforge-ts/crates
11
+ cargo&nbsp;build&nbsp;--release&nbsp;--bin&nbsp;macroforge
12
12
 
13
- # The binary is at target/release/macroforge
13
+ #&nbsp;The&nbsp;binary&nbsp;is&nbsp;at&nbsp;target/release/macroforge
14
14
  ``` ## Commands
15
15
  ### macroforge expand
16
16
  Expands macros in a TypeScript file and outputs the transformed code.
17
17
  ```
18
- macroforge expand &#x3C;input> [options]
18
+ macroforge&nbsp;expand&nbsp;&#x3C;input>&nbsp;[options]
19
19
  ``` #### Arguments
20
20
  | Argument | Description |
21
21
  | --- | --- |
22
- | `<input>` | Path to the TypeScript or TSX file to expand |
22
+ | <input> | Path to the TypeScript or TSX file to expand |
23
23
  #### Options
24
24
  | Option | Description |
25
25
  | --- | --- |
26
- | `--out <path>` | Write the expanded JavaScript/TypeScript to a file |
27
- | `--types-out <path>` | Write the generated `.d.ts` declarations to a file |
28
- | `--print` | Print output to stdout even when `--out` is specified |
29
- | `--builtin-only` | Use only built-in Rust macros (faster, but no external macro support) |
26
+ | --out <path> | Write the expanded JavaScript/TypeScript to a file |
27
+ | --types-out <path> | Write the generated .d.ts declarations to a file |
28
+ | --print | Print output to stdout even when --out is specified |
29
+ | --builtin-only | Use only built-in Rust macros (faster, but no external macro support) |
30
30
  #### Examples
31
31
  Expand a file and print to stdout:
32
32
  ```
33
- macroforge expand src/user.ts
33
+ macroforge&nbsp;expand&nbsp;src/user.ts
34
34
  ``` Expand and write to a file:
35
35
  ```
36
- macroforge expand src/user.ts --out dist/user.js
36
+ macroforge&nbsp;expand&nbsp;src/user.ts&nbsp;--out&nbsp;dist/user.js
37
37
  ``` Expand with both runtime output and type declarations:
38
38
  ```
39
- macroforge expand src/user.ts --out dist/user.js --types-out dist/user.d.ts
39
+ macroforge&nbsp;expand&nbsp;src/user.ts&nbsp;--out&nbsp;dist/user.js&nbsp;--types-out&nbsp;dist/user.d.ts
40
40
  ``` Use fast built-in macros only (no external macro support):
41
41
  ```
42
- macroforge expand src/user.ts --builtin-only
42
+ macroforge&nbsp;expand&nbsp;src/user.ts&nbsp;--builtin-only
43
43
  ``` > **Note:** By default, the CLI uses Node.js for full macro support (including external macros). It must be run from your project's root directory where macroforge and any external macro packages are installed in node_modules. ### macroforge tsc
44
- Runs TypeScript type checking with macro expansion. This wraps `tsc --noEmit` and expands macros before type checking, so your generated methods are properly type-checked.
44
+ Runs TypeScript type checking with macro expansion. This wraps <code class="shiki-inline"><span class="line"><span style="--shiki-dark:#E1E4E8;--shiki-light:#24292E">tsc <span style="--shiki-dark:#F97583;--shiki-light:#D73A49">--<span style="--shiki-dark:#E1E4E8;--shiki-light:#24292E">noEmit</code> and expands macros before type checking, so your generated methods are properly type-checked.
45
45
  ```
46
- macroforge tsc [options]
46
+ macroforge&nbsp;tsc&nbsp;[options]
47
47
  ``` #### Options
48
48
  | Option | Description |
49
49
  | --- | --- |
50
- | `-p, --project <path>` | Path to `tsconfig.json` (defaults to `tsconfig.json` in current directory) |
50
+ | -p, --project <path> | Path to tsconfig.json (defaults to tsconfig.json in current directory) |
51
51
  #### Examples
52
52
  Type check with default tsconfig.json:
53
53
  ```
54
- macroforge tsc
54
+ macroforge&nbsp;tsc
55
55
  ``` Type check with a specific config:
56
56
  ```
57
- macroforge tsc -p tsconfig.build.json
57
+ macroforge&nbsp;tsc&nbsp;-p&nbsp;tsconfig.build.json
58
58
  ``` ## Output Format
59
59
  ### Expanded Code
60
60
  When expanding a file like this:
61
61
  ```
62
- /** @derive(Debug) */
63
- class User &#123;
64
- name: string;
65
- age: number;
62
+ /**&nbsp;@derive(Debug)&nbsp;*/
63
+ class&nbsp;User&nbsp;&#123;
64
+ &nbsp;&nbsp;name:&nbsp;string;
65
+ &nbsp;&nbsp;age:&nbsp;number;
66
66
 
67
- constructor(name: string, age: number) &#123;
68
- this.name = name;
69
- this.age = age;
70
- &#125;
67
+ &nbsp;&nbsp;constructor(name:&nbsp;string,&nbsp;age:&nbsp;number)&nbsp;&#123;
68
+ &nbsp;&nbsp;&nbsp;&nbsp;this.name&nbsp;=&nbsp;name;
69
+ &nbsp;&nbsp;&nbsp;&nbsp;this.age&nbsp;=&nbsp;age;
70
+ &nbsp;&nbsp;&#125;
71
71
  &#125;
72
72
  ``` The CLI outputs the expanded code with the generated methods:
73
73
  ```
@@ -87,35 +87,35 @@ class User {
87
87
  ``` ### Diagnostics
88
88
  Errors and warnings are printed to stderr in a readable format:
89
89
  ```
90
- [macroforge] error at src/user.ts:5:1: Unknown derive macro: InvalidMacro
91
- [macroforge] warning at src/user.ts:10:3: Field 'unused' is never used
90
+ [macroforge]&nbsp;error&nbsp;at&nbsp;src/user.ts:5:1:&nbsp;Unknown&nbsp;derive&nbsp;macro:&nbsp;InvalidMacro
91
+ [macroforge]&nbsp;warning&nbsp;at&nbsp;src/user.ts:10:3:&nbsp;Field&nbsp;'unused'&nbsp;is&nbsp;never&nbsp;used
92
92
  ``` ## Use Cases
93
93
  ### CI/CD Type Checking
94
- Use `macroforge tsc` in your CI pipeline to type-check with macro expansion:
94
+ Use <code class="shiki-inline"><span class="line"><span style="--shiki-dark:#B392F0;--shiki-light:#6F42C1">macroforge<span style="--shiki-dark:#9ECBFF;--shiki-light:#032F62"> tsc</code> in your CI pipeline to type-check with macro expansion:
95
95
  ```
96
- # package.json
96
+ #&nbsp;package.json
97
97
  &#123;
98
- "scripts": &#123;
99
- "typecheck": "macroforge tsc"
100
- &#125;
98
+ &nbsp;&nbsp;"scripts":&nbsp;&#123;
99
+ &nbsp;&nbsp;&nbsp;&nbsp;"typecheck":&nbsp;"macroforge&nbsp;tsc"
100
+ &nbsp;&nbsp;&#125;
101
101
  &#125;
102
102
  ``` ### Debugging Macro Output
103
- Use `macroforge expand` to inspect what code your macros generate:
103
+ Use <code class="shiki-inline"><span class="line"><span style="--shiki-dark:#B392F0;--shiki-light:#6F42C1">macroforge<span style="--shiki-dark:#9ECBFF;--shiki-light:#032F62"> expand</code> to inspect what code your macros generate:
104
104
  ```
105
- macroforge expand src/models/user.ts | less
105
+ macroforge&nbsp;expand&nbsp;src/models/user.ts&nbsp;|&nbsp;less
106
106
  ``` ### Build Pipeline
107
107
  Generate expanded files as part of a custom build:
108
108
  ```
109
109
  #!/bin/bash
110
- for file in src/**/*.ts; do
111
- outfile="dist/$(basename "$file" .ts).js"
112
- macroforge expand "$file" --out "$outfile"
110
+ for&nbsp;file&nbsp;in&nbsp;src/**/*.ts;&nbsp;do
111
+ &nbsp;&nbsp;outfile="dist/$(basename&nbsp;"$file"&nbsp;.ts).js"
112
+ &nbsp;&nbsp;macroforge&nbsp;expand&nbsp;"$file"&nbsp;--out&nbsp;"$outfile"
113
113
  done
114
114
  ``` ## Built-in vs Full Mode
115
- By default, the CLI uses Node.js for full macro support including external macros. Use `--builtin-only` for faster expansion when you only need built-in macros:
116
- | Feature | Default (Node.js) | `--builtin-only` (Rust) |
115
+ By default, the CLI uses Node.js for full macro support including external macros. Use <code class="shiki-inline"><span class="line"><span style="--shiki-dark:#F97583;--shiki-light:#D73A49">--<span style="--shiki-dark:#E1E4E8;--shiki-light:#24292E">builtin<span style="--shiki-dark:#F97583;--shiki-light:#D73A49">-<span style="--shiki-dark:#E1E4E8;--shiki-light:#24292E">only</code> for faster expansion when you only need built-in macros:
116
+ | Feature | Default (Node.js) | --builtin-only (Rust) |
117
117
  | --- | --- | --- |
118
118
  | Built-in macros | Yes | Yes |
119
119
  | External macros | Yes | No |
120
120
  | Performance | Standard | Faster |
121
- | Dependencies | Requires `macroforge` in node_modules | None |
121
+ | Dependencies | Requires macroforge in node_modules | None |
@@ -1,73 +1,73 @@
1
1
  # Configuration
2
- *Macroforge can be configured with a `macroforge.json` file in your project root.*
2
+ *Macroforge can be configured with a <code class="shiki-inline"><span class="line"><span style="--shiki-dark:#E1E4E8;--shiki-light:#24292E">macroforge.json</code> file in your project root.*
3
3
  ## Configuration File
4
- Create a `macroforge.json` file:
4
+ Create a <code class="shiki-inline"><span class="line"><span style="--shiki-dark:#E1E4E8;--shiki-light:#24292E">macroforge.json</code> file:
5
5
  ```
6
6
  &#123;
7
- "allowNativeMacros": true,
8
- "macroPackages": [],
9
- "keepDecorators": false,
10
- "limits": &#123;
11
- "maxExecutionTimeMs": 5000,
12
- "maxMemoryBytes": 104857600,
13
- "maxOutputSize": 10485760,
14
- "maxDiagnostics": 100
15
- &#125;
7
+ &nbsp;&nbsp;"allowNativeMacros":&nbsp;true,
8
+ &nbsp;&nbsp;"macroPackages":&nbsp;[],
9
+ &nbsp;&nbsp;"keepDecorators":&nbsp;false,
10
+ &nbsp;&nbsp;"limits":&nbsp;&#123;
11
+ &nbsp;&nbsp;&nbsp;&nbsp;"maxExecutionTimeMs":&nbsp;5000,
12
+ &nbsp;&nbsp;&nbsp;&nbsp;"maxMemoryBytes":&nbsp;104857600,
13
+ &nbsp;&nbsp;&nbsp;&nbsp;"maxOutputSize":&nbsp;10485760,
14
+ &nbsp;&nbsp;&nbsp;&nbsp;"maxDiagnostics":&nbsp;100
15
+ &nbsp;&nbsp;&#125;
16
16
  &#125;
17
17
  ``` ## Options Reference
18
18
  ### allowNativeMacros
19
- | Type | `boolean` |
20
- | Default | `true` |
21
- Enable or disable native (Rust) macro packages. Set to `false` to only allow built-in macros.
19
+ | Type | boolean |
20
+ | Default | true |
21
+ Enable or disable native (Rust) macro packages. Set to <code class="shiki-inline"><span class="line"><span style="--shiki-dark:#79B8FF;--shiki-light:#005CC5">false</code> to only allow built-in macros.
22
22
  ### macroPackages
23
- | Type | `string[]` |
24
- | Default | `[]` |
23
+ | Type | string[] |
24
+ | Default | [] |
25
25
  List of npm packages that provide macros. Macroforge will look for macros in these packages.
26
26
  ```
27
27
  &#123;
28
- "macroPackages": [
29
- "@my-org/custom-macros",
30
- "community-macros"
31
- ]
28
+ &nbsp;&nbsp;"macroPackages":&nbsp;[
29
+ &nbsp;&nbsp;&nbsp;&nbsp;"@my-org/custom-macros",
30
+ &nbsp;&nbsp;&nbsp;&nbsp;"community-macros"
31
+ &nbsp;&nbsp;]
32
32
  &#125;
33
33
  ``` ### keepDecorators
34
- | Type | `boolean` |
35
- | Default | `false` |
36
- Keep `@derive` decorators in the output. Useful for debugging.
34
+ | Type | boolean |
35
+ | Default | false |
36
+ Keep <code class="shiki-inline"><span class="line"><span style="--shiki-dark:#E1E4E8;--shiki-light:#24292E">@derive</code> decorators in the output. Useful for debugging.
37
37
  ### limits
38
38
  Configure resource limits for macro expansion:
39
39
  ```
40
40
  &#123;
41
- "limits": &#123;
42
- // Maximum time for a single macro expansion (ms)
43
- "maxExecutionTimeMs": 5000,
41
+ &nbsp;&nbsp;"limits":&nbsp;&#123;
42
+ &nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;Maximum&nbsp;time&nbsp;for&nbsp;a&nbsp;single&nbsp;macro&nbsp;expansion&nbsp;(ms)
43
+ &nbsp;&nbsp;&nbsp;&nbsp;"maxExecutionTimeMs":&nbsp;5000,
44
44
 
45
- // Maximum memory usage (bytes)
46
- "maxMemoryBytes": 104857600, // 100MB
45
+ &nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;Maximum&nbsp;memory&nbsp;usage&nbsp;(bytes)
46
+ &nbsp;&nbsp;&nbsp;&nbsp;"maxMemoryBytes":&nbsp;104857600,&nbsp;&nbsp;//&nbsp;100MB
47
47
 
48
- // Maximum size of generated code (bytes)
49
- "maxOutputSize": 10485760, // 10MB
48
+ &nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;Maximum&nbsp;size&nbsp;of&nbsp;generated&nbsp;code&nbsp;(bytes)
49
+ &nbsp;&nbsp;&nbsp;&nbsp;"maxOutputSize":&nbsp;10485760,&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;10MB
50
50
 
51
- // Maximum number of diagnostics per file
52
- "maxDiagnostics": 100
53
- &#125;
51
+ &nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;Maximum&nbsp;number&nbsp;of&nbsp;diagnostics&nbsp;per&nbsp;file
52
+ &nbsp;&nbsp;&nbsp;&nbsp;"maxDiagnostics":&nbsp;100
53
+ &nbsp;&nbsp;&#125;
54
54
  &#125;
55
55
  ``` ## Macro Runtime Overrides
56
56
  Override settings for specific macros:
57
57
  ```
58
58
  &#123;
59
- "macroRuntimeOverrides": &#123;
60
- "@my-org/macros": &#123;
61
- "maxExecutionTimeMs": 10000
62
- &#125;
63
- &#125;
59
+ &nbsp;&nbsp;"macroRuntimeOverrides":&nbsp;&#123;
60
+ &nbsp;&nbsp;&nbsp;&nbsp;"@my-org/macros":&nbsp;&#123;
61
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"maxExecutionTimeMs":&nbsp;10000
62
+ &nbsp;&nbsp;&nbsp;&nbsp;&#125;
63
+ &nbsp;&nbsp;&#125;
64
64
  &#125;
65
65
  ``` **Warning Be careful when increasing limits, as this could allow malicious macros to consume excessive resources. ## Environment Variables
66
66
  Some settings can be overridden with environment variables:
67
67
  | Variable | Description |
68
68
  | --- | --- |
69
- | `MACROFORGE_DEBUG` | Enable debug logging |
70
- | `MACROFORGE_LOG_FILE` | Write logs to a file |
69
+ | MACROFORGE_DEBUG | Enable debug logging |
70
+ | MACROFORGE_LOG_FILE | Write logs to a file |
71
71
  ```
72
- MACROFORGE_DEBUG=1 npm run dev
72
+ MACROFORGE_DEBUG=1&nbsp;npm&nbsp;run&nbsp;dev
73
73
  ```**
@@ -3,15 +3,15 @@
3
3
  ## Overview
4
4
  | Integration | Purpose | Package |
5
5
  | --- | --- | --- |
6
- | TypeScript Plugin | IDE support (errors, completions) | `@macroforge/typescript-plugin` |
7
- | Vite Plugin | Build-time macro expansion | `@macroforge/vite-plugin` |
6
+ | TypeScript Plugin | IDE support (errors, completions) | @macroforge/typescript-plugin |
7
+ | Vite Plugin | Build-time macro expansion | @macroforge/vite-plugin |
8
8
  ## Recommended Setup
9
9
  For the best development experience, use both integrations:
10
10
  1. **TypeScript Plugin**: Provides real-time feedback in your IDE
11
11
  2. **Vite Plugin**: Expands macros during development and production builds
12
12
  ```
13
- # Install both plugins
14
- npm install -D @macroforge/typescript-plugin @macroforge/vite-plugin
13
+ #&nbsp;Install&nbsp;both&nbsp;plugins
14
+ npm&nbsp;install&nbsp;-D&nbsp;@macroforge/typescript-plugin&nbsp;@macroforge/vite-plugin
15
15
  ``` ## How They Work Together
16
16
  <div class="flex justify-center"><div class="border-2 border-primary bg-primary/10 rounded-lg px-6 py-3 text-center"><div class="font-semibold text-primary">Your Code TypeScript with @derive decorators <div class="absolute top-0 h-px bg-border" style="width: 50%; left: 25%;"> <div class="flex flex-col items-center"> <div class="border border-border bg-card rounded-lg px-4 py-3 text-center w-full mt-1"><div class="font-medium text-foreground">TypeScript Plugin Language service integration <div class="border border-success/30 bg-success/10 rounded-md px-3 py-2 text-center"><div class="text-sm font-medium text-success-foreground">IDE Feedback Errors & completions <div class="border border-border bg-card rounded-lg px-4 py-3 text-center w-full mt-1"><div class="font-medium text-foreground">Vite Plugin Build-time transformation <div class="border border-success/30 bg-success/10 rounded-md px-3 py-2 text-center"><div class="text-sm font-medium text-success-foreground">Dev Server Hot reload<div class="text-sm font-medium text-success-foreground">Production Build Optimized output ## Detailed Guides
17
17
  - [TypeScript Plugin setup](../docs/integration/typescript-plugin)