@macroforge/mcp-server 0.1.17 → 0.1.21

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.
@@ -4,40 +4,15 @@
4
4
 
5
5
  ## Basic Usage
6
6
 
7
- ```typescript
8
- /** @derive(Default) */
9
- class Config {
10
- host: string;
11
- port: number;
12
- enabled: boolean;
13
-
14
- constructor(host: string, port: number, enabled: boolean) {
15
- this.host = host;
16
- this.port = port;
17
- this.enabled = enabled;
18
- }
19
- }
7
+ <MacroExample before={data.examples.basic.before} after={data.examples.basic.after} />
20
8
 
9
+ ```typescript
21
10
  const config = Config.default();
22
11
  console.log(config.host); // ""
23
12
  console.log(config.port); // 0
24
13
  console.log(config.enabled); // false
25
14
  ```
26
15
 
27
- ## Generated Code
28
-
29
- The Default macro generates a static factory method:
30
-
31
- ```typescript
32
- static default(): Config {
33
- const instance = new Config();
34
- instance.host = "";
35
- instance.port = 0;
36
- instance.enabled = false;
37
- return instance;
38
- }
39
- ```
40
-
41
16
  ## Automatic Default Values
42
17
 
43
18
  The Default macro automatically determines default values based on field types:
@@ -64,29 +39,9 @@ The Default macro automatically determines default values based on field types:
64
39
 
65
40
  Use the `@defaultValue()` decorator to specify custom default values for fields:
66
41
 
67
- ```typescript
68
- /** @derive(Default) */
69
- class ServerConfig {
70
- /** @defaultValue("localhost") */
71
- host: string;
72
-
73
- /** @defaultValue(8080) */
74
- port: number;
75
-
76
- /** @defaultValue(true) */
77
- enabled: boolean;
78
-
79
- /** @defaultValue(["info", "error"]) */
80
- logLevels: string[];
81
-
82
- constructor(host: string, port: number, enabled: boolean, logLevels: string[]) {
83
- this.host = host;
84
- this.port = port;
85
- this.enabled = enabled;
86
- this.logLevels = logLevels;
87
- }
88
- }
42
+ <MacroExample before={data.examples.custom.before} after={data.examples.custom.after} />
89
43
 
44
+ ```typescript
90
45
  const config = ServerConfig.default();
91
46
  console.log(config.host); // "localhost"
92
47
  console.log(config.port); // 8080
@@ -98,23 +53,9 @@ console.log(config.logLevels); // ["info", "error"]
98
53
 
99
54
  Default also works with interfaces. For interfaces, a namespace is generated with a `default_()` function (note the underscore to avoid conflicts with the reserved word):
100
55
 
101
- ```typescript
102
- /** @derive(Default) */
103
- interface Point {
104
- x: number;
105
- y: number;
106
- }
107
-
108
- // Generated:
109
- // export namespace Point {
110
- // export function default_(): Point {
111
- // return {
112
- // x: 0,
113
- // y: 0
114
- // } as Point;
115
- // }
116
- // }
56
+ <MacroExample before={data.examples.interface.before} after={data.examples.interface.after} />
117
57
 
58
+ ```typescript
118
59
  const origin = Point.default_();
119
60
  console.log(origin); // { x: 0, y: 0 }
120
61
  ```
@@ -123,21 +64,9 @@ console.log(origin); // { x: 0, y: 0 }
123
64
 
124
65
  Default works with enums. For enums, it returns the first variant as the default value:
125
66
 
126
- ```typescript
127
- /** @derive(Default) */
128
- enum Status {
129
- Pending = "pending",
130
- Active = "active",
131
- Completed = "completed",
132
- }
133
-
134
- // Generated:
135
- // export namespace Status {
136
- // export function default_(): Status {
137
- // return Status.Pending;
138
- // }
139
- // }
67
+ <MacroExample before={data.examples.enum.before} after={data.examples.enum.after} />
140
68
 
69
+ ```typescript
141
70
  const defaultStatus = Status.default_();
142
71
  console.log(defaultStatus); // "pending"
143
72
  ```
@@ -146,31 +75,16 @@ console.log(defaultStatus); // "pending"
146
75
 
147
76
  Default works with type aliases. For object types, it creates an object with default field values:
148
77
 
149
- ```typescript
150
- /** @derive(Default) */
151
- type Dimensions = {
152
- width: number;
153
- height: number;
154
- };
155
-
156
- // Generated:
157
- // export namespace Dimensions {
158
- // export function default_(): Dimensions {
159
- // return {
160
- // width: 0,
161
- // height: 0
162
- // } as Dimensions;
163
- // }
164
- // }
78
+ <MacroExample before={data.examples.typeAlias.before} after={data.examples.typeAlias.after} />
165
79
 
80
+ ```typescript
166
81
  const dims = Dimensions.default_();
167
82
  console.log(dims); // { width: 0, height: 0 }
168
83
  ```
169
84
 
170
85
  ## Combining with Other Macros
171
86
 
172
- ```typescript
173
- /** @derive(Default, Debug, Clone, PartialEq) */
87
+ <InteractiveMacro code={`/** @derive(Default, Debug, Clone, PartialEq) */
174
88
  class User {
175
89
  /** @defaultValue("Anonymous") */
176
90
  name: string;
@@ -182,8 +96,9 @@ class User {
182
96
  this.name = name;
183
97
  this.age = age;
184
98
  }
185
- }
99
+ }`} />
186
100
 
101
+ ```typescript
187
102
  const user1 = User.default();
188
103
  const user2 = user1.clone();
189
104