@macroforge/mcp-server 0.1.75 → 0.1.76
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.
- package/docs/builtin-macros/clone.md +16 -14
- package/docs/builtin-macros/debug.md +9 -8
- package/docs/builtin-macros/default.md +23 -22
- package/docs/builtin-macros/deserialize/cycleforward-reference-support.md +2 -3
- package/docs/builtin-macros/deserialize/example.md +1 -2
- package/docs/builtin-macros/deserialize/overview.md +10 -10
- package/docs/builtin-macros/deserialize/union-type-deserialization.md +9 -15
- package/docs/builtin-macros/deserialize/validation.md +1 -5
- package/docs/builtin-macros/deserialize.md +19 -31
- package/docs/builtin-macros/hash.md +35 -29
- package/docs/builtin-macros/ord.md +20 -18
- package/docs/builtin-macros/partial-eq.md +39 -31
- package/docs/builtin-macros/partial-ord.md +18 -18
- package/docs/builtin-macros/serialize.md +22 -23
- package/docs/custom-macros/custom-overview.md +7 -0
- package/docs/integration/vite-plugin.md +40 -0
- package/docs/sections.json +126 -126
- package/package.json +2 -2
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
# Clone
|
|
2
2
|
|
|
3
|
-
The `Clone` macro generates a `clone()` method for deep copying objects.
|
|
4
|
-
`Clone` trait, providing a way to create
|
|
3
|
+
The `Clone` macro generates a `clone()` method for deep copying objects.
|
|
4
|
+
This is analogous to Rust's `Clone` trait, providing a way to create
|
|
5
|
+
independent copies of values.
|
|
5
6
|
|
|
6
7
|
## Generated Output
|
|
7
8
|
|
|
8
|
-
| Type
|
|
9
|
-
|
|
10
|
-
| Class
|
|
11
|
-
| Enum
|
|
12
|
-
| Interface
|
|
13
|
-
| Type Alias | `typeNameClone(value: TypeName): TypeName`
|
|
9
|
+
| Type | Generated Code | Description |
|
|
10
|
+
|------|----------------|-------------|
|
|
11
|
+
| Class | `classNameClone(value)` + `static clone(value)` | Standalone function + static wrapper method |
|
|
12
|
+
| Enum | `enumNameClone(value: EnumName): EnumName` | Standalone function (enums are primitives, returns value as-is) |
|
|
13
|
+
| Interface | `interfaceNameClone(value: InterfaceName): InterfaceName` | Standalone function creating a new object literal |
|
|
14
|
+
| Type Alias | `typeNameClone(value: TypeName): TypeName` | Standalone function with spread copy for objects |
|
|
15
|
+
|
|
14
16
|
|
|
15
17
|
## Cloning Strategy
|
|
16
18
|
|
|
@@ -20,8 +22,8 @@ The generated clone performs a **shallow copy** of all fields:
|
|
|
20
22
|
- **Objects**: Reference is copied (not deep cloned)
|
|
21
23
|
- **Arrays**: Reference is copied (not deep cloned)
|
|
22
24
|
|
|
23
|
-
For deep cloning of nested objects, those objects should also derive `Clone`
|
|
24
|
-
clone them explicitly.
|
|
25
|
+
For deep cloning of nested objects, those objects should also derive `Clone`
|
|
26
|
+
and the caller should clone them explicitly.
|
|
25
27
|
|
|
26
28
|
## Example
|
|
27
29
|
|
|
@@ -53,8 +55,8 @@ export function pointClone(value: Point): Point {
|
|
|
53
55
|
|
|
54
56
|
## Implementation Notes
|
|
55
57
|
|
|
56
|
-
- **Classes**: Uses `Object.create(Object.getPrototypeOf(value))` to preserve
|
|
57
|
-
ensuring `instanceof` checks work correctly
|
|
58
|
+
- **Classes**: Uses `Object.create(Object.getPrototypeOf(value))` to preserve
|
|
59
|
+
the prototype chain, ensuring `instanceof` checks work correctly
|
|
58
60
|
- **Enums**: Simply returns the value (enums are primitives in TypeScript)
|
|
59
|
-
- **Interfaces/Type Aliases**: Creates new object literals with spread operator
|
|
60
|
-
types, or field-by-field copy for object types
|
|
61
|
+
- **Interfaces/Type Aliases**: Creates new object literals with spread operator
|
|
62
|
+
for union/tuple types, or field-by-field copy for object types
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
# Debug
|
|
2
2
|
|
|
3
|
-
The `Debug` macro generates a human-readable `toString()` method for
|
|
4
|
-
enums, and type aliases.
|
|
3
|
+
The `Debug` macro generates a human-readable `toString()` method for
|
|
4
|
+
TypeScript classes, interfaces, enums, and type aliases.
|
|
5
5
|
|
|
6
6
|
## Generated Output
|
|
7
7
|
|
|
8
|
-
**Classes**: Generates a standalone function `classNameToString(value)` and a static wrapper
|
|
9
|
-
`static toString(value)` returning a string like `"ClassName { field1: value1, field2: value2 }"`.
|
|
8
|
+
**Classes**: Generates a standalone function `classNameToString(value)` and a static wrapper
|
|
9
|
+
method `static toString(value)` returning a string like `"ClassName { field1: value1, field2: value2 }"`.
|
|
10
10
|
|
|
11
|
-
**Enums**: Generates a standalone function `enumNameToString(value)` that performs
|
|
12
|
-
numeric enums.
|
|
11
|
+
**Enums**: Generates a standalone function `enumNameToString(value)` that performs
|
|
12
|
+
reverse lookup on numeric enums.
|
|
13
13
|
|
|
14
14
|
**Interfaces**: Generates a standalone function `interfaceNameToString(value)`.
|
|
15
15
|
|
|
16
|
-
**Type Aliases**: Generates a standalone function using JSON.stringify for
|
|
17
|
-
enumeration for object types.
|
|
16
|
+
**Type Aliases**: Generates a standalone function using JSON.stringify for
|
|
17
|
+
complex types, or field enumeration for object types.
|
|
18
|
+
|
|
18
19
|
|
|
19
20
|
## Field-Level Options
|
|
20
21
|
|
|
@@ -1,34 +1,35 @@
|
|
|
1
1
|
# Default
|
|
2
2
|
|
|
3
|
-
The `Default` macro generates a static `defaultValue()` factory method that creates
|
|
4
|
-
default values. This is analogous to Rust's `Default` trait, providing
|
|
5
|
-
"zero" or "empty" instances of types.
|
|
3
|
+
The `Default` macro generates a static `defaultValue()` factory method that creates
|
|
4
|
+
instances with default values. This is analogous to Rust's `Default` trait, providing
|
|
5
|
+
a standard way to create "zero" or "empty" instances of types.
|
|
6
6
|
|
|
7
7
|
## Generated Output
|
|
8
8
|
|
|
9
|
-
| Type
|
|
10
|
-
|
|
11
|
-
| Class
|
|
12
|
-
| Enum
|
|
13
|
-
| Interface
|
|
14
|
-
| Type Alias | `defaultValueTypeName(): TypeName`
|
|
9
|
+
| Type | Generated Code | Description |
|
|
10
|
+
|------|----------------|-------------|
|
|
11
|
+
| Class | `static defaultValue(): ClassName` | Static factory method |
|
|
12
|
+
| Enum | `defaultValueEnumName(): EnumName` | Standalone function returning marked variant |
|
|
13
|
+
| Interface | `defaultValueInterfaceName(): InterfaceName` | Standalone function returning object literal |
|
|
14
|
+
| Type Alias | `defaultValueTypeName(): TypeName` | Standalone function with type-appropriate default |
|
|
15
|
+
|
|
15
16
|
|
|
16
17
|
## Default Values by Type
|
|
17
18
|
|
|
18
19
|
The macro uses Rust-like default semantics:
|
|
19
20
|
|
|
20
|
-
| Type
|
|
21
|
-
|
|
22
|
-
| `string`
|
|
23
|
-
| `number`
|
|
24
|
-
| `boolean`
|
|
25
|
-
| `bigint`
|
|
26
|
-
| `T[]`
|
|
27
|
-
| `Array<T>`
|
|
28
|
-
| `Map<K,V>`
|
|
29
|
-
| `Set<T>`
|
|
30
|
-
| `Date`
|
|
31
|
-
| `T \| null`
|
|
21
|
+
| Type | Default Value |
|
|
22
|
+
|------|---------------|
|
|
23
|
+
| `string` | `""` (empty string) |
|
|
24
|
+
| `number` | `0` |
|
|
25
|
+
| `boolean` | `false` |
|
|
26
|
+
| `bigint` | `0n` |
|
|
27
|
+
| `T[]` | `[]` (empty array) |
|
|
28
|
+
| `Array<T>` | `[]` (empty array) |
|
|
29
|
+
| `Map<K,V>` | `new Map()` |
|
|
30
|
+
| `Set<T>` | `new Set()` |
|
|
31
|
+
| `Date` | `new Date()` (current time) |
|
|
32
|
+
| `T \| null` | `null` |
|
|
32
33
|
| `CustomType` | `CustomType.defaultValue()` (recursive) |
|
|
33
34
|
|
|
34
35
|
## Field-Level Options
|
|
@@ -51,7 +52,7 @@ class UserSettings {
|
|
|
51
52
|
/** @default(10) */
|
|
52
53
|
pageSize: number;
|
|
53
54
|
|
|
54
|
-
notifications: boolean;
|
|
55
|
+
notifications: boolean; // Uses type default: false
|
|
55
56
|
}
|
|
56
57
|
```
|
|
57
58
|
|
|
@@ -7,6 +7,5 @@ Uses deferred patching to handle references:
|
|
|
7
7
|
3. After all objects are created, `ctx.applyPatches()` resolves all pending references
|
|
8
8
|
|
|
9
9
|
References only apply to object-shaped, serializable values. The generator avoids probing for
|
|
10
|
-
`__ref` on primitive-like fields (including literal unions and `T | null` where `T` is
|
|
11
|
-
|
|
12
|
-
references.
|
|
10
|
+
`__ref` on primitive-like fields (including literal unions and `T | null` where `T` is primitive-like),
|
|
11
|
+
and it parses `Date` / `Date | null` from ISO strings without treating them as references.
|
|
@@ -214,5 +214,4 @@ if (Result.isOk(result)) {
|
|
|
214
214
|
## Required Imports
|
|
215
215
|
|
|
216
216
|
The generated code automatically imports:
|
|
217
|
-
|
|
218
|
-
- `DeserializeContext`, `DeserializeError`, `PendingRef` from `macroforge/serde`
|
|
217
|
+
- `DeserializeContext`, `DeserializeError`, `PendingRef` from `macroforge/serde`
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
# Deserialize
|
|
2
2
|
|
|
3
|
-
The `Deserialize` macro generates JSON deserialization methods with **cycle and
|
|
4
|
-
support**, plus comprehensive runtime validation. This enables
|
|
5
|
-
structures including circular references.
|
|
3
|
+
The `Deserialize` macro generates JSON deserialization methods with **cycle and
|
|
4
|
+
forward-reference support**, plus comprehensive runtime validation. This enables
|
|
5
|
+
safe parsing of complex JSON structures including circular references.
|
|
6
6
|
|
|
7
7
|
## Generated Output
|
|
8
8
|
|
|
9
|
-
| Type
|
|
10
|
-
|
|
11
|
-
| Class
|
|
12
|
-
| Enum
|
|
13
|
-
| Interface
|
|
14
|
-
| Type Alias | `typeNameDeserialize(input)`, etc.
|
|
9
|
+
| Type | Generated Code | Description |
|
|
10
|
+
|------|----------------|-------------|
|
|
11
|
+
| Class | `classNameDeserialize(input)` + `static deserialize(input)` | Standalone function + static factory method |
|
|
12
|
+
| Enum | `enumNameDeserialize(input)`, `enumNameDeserializeWithContext(data)`, `enumNameIs(value)` | Standalone functions |
|
|
13
|
+
| Interface | `interfaceNameDeserialize(input)`, etc. | Standalone functions |
|
|
14
|
+
| Type Alias | `typeNameDeserialize(input)`, etc. | Standalone functions |
|
|
15
15
|
|
|
16
16
|
## Return Type
|
|
17
17
|
|
|
18
18
|
All public deserialization methods return `Result<T, Array<{ field: string; message: string }>>`:
|
|
19
19
|
|
|
20
20
|
- `Result.ok(value)` - Successfully deserialized value
|
|
21
|
-
- `Result.err(errors)` - Array of validation errors with field names and messages
|
|
21
|
+
- `Result.err(errors)` - Array of validation errors with field names and messages
|
|
@@ -3,31 +3,25 @@
|
|
|
3
3
|
Union types are deserialized based on their member types:
|
|
4
4
|
|
|
5
5
|
### Literal Unions
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
literals directly.
|
|
6
|
+
For unions of literal values (`"A" | "B" | 123`), the value is validated against
|
|
7
|
+
the allowed literals directly.
|
|
9
8
|
|
|
10
9
|
### Primitive Unions
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
validate the value type. No `__type` discriminator is needed.
|
|
10
|
+
For unions containing primitive types (`string | number`), the deserializer uses
|
|
11
|
+
`typeof` checks to validate the value type. No `__type` discriminator is needed.
|
|
14
12
|
|
|
15
13
|
### Class/Interface Unions
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
JSON to dispatch to the correct type's `deserializeWithContext` method.
|
|
14
|
+
For unions of serializable types (`User | Admin`), the deserializer requires a
|
|
15
|
+
`__type` field in the JSON to dispatch to the correct type's `deserializeWithContext` method.
|
|
19
16
|
|
|
20
17
|
### Generic Type Parameters
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
through as-is since its concrete type is only known at the call site.
|
|
18
|
+
For generic unions like `type Result<T> = T | Error`, the generic type parameter `T`
|
|
19
|
+
is passed through as-is since its concrete type is only known at the call site.
|
|
24
20
|
|
|
25
21
|
### Mixed Unions
|
|
26
|
-
|
|
27
22
|
Mixed unions (e.g., `string | Date | User`) check in order:
|
|
28
|
-
|
|
29
23
|
1. Literal values
|
|
30
24
|
2. Primitives (via `typeof`)
|
|
31
25
|
3. Date (via `instanceof` or ISO string parsing)
|
|
32
26
|
4. Serializable types (via `__type` dispatch)
|
|
33
|
-
5. Generic type parameters (pass-through)
|
|
27
|
+
5. Generic type parameters (pass-through)
|
|
@@ -3,23 +3,19 @@
|
|
|
3
3
|
The macro supports 30+ validators via `@serde(validate(...))`:
|
|
4
4
|
|
|
5
5
|
### String Validators
|
|
6
|
-
|
|
7
6
|
- `email`, `url`, `uuid` - Format validation
|
|
8
7
|
- `minLength(n)`, `maxLength(n)`, `length(n)` - Length constraints
|
|
9
8
|
- `pattern("regex")` - Regular expression matching
|
|
10
9
|
- `nonEmpty`, `trimmed`, `lowercase`, `uppercase` - String properties
|
|
11
10
|
|
|
12
11
|
### Number Validators
|
|
13
|
-
|
|
14
12
|
- `gt(n)`, `gte(n)`, `lt(n)`, `lte(n)`, `between(min, max)` - Range checks
|
|
15
13
|
- `int`, `positive`, `nonNegative`, `finite` - Number properties
|
|
16
14
|
|
|
17
15
|
### Array Validators
|
|
18
|
-
|
|
19
16
|
- `minItems(n)`, `maxItems(n)`, `itemsCount(n)` - Collection size
|
|
20
17
|
|
|
21
18
|
### Date Validators
|
|
22
|
-
|
|
23
19
|
- `validDate`, `afterDate("ISO")`, `beforeDate("ISO")` - Date validation
|
|
24
20
|
|
|
25
21
|
## Field-Level Options
|
|
@@ -35,4 +31,4 @@ The `@serde` decorator supports:
|
|
|
35
31
|
## Container-Level Options
|
|
36
32
|
|
|
37
33
|
- `denyUnknownFields` - Error on unrecognized JSON properties
|
|
38
|
-
- `renameAll = "camelCase"` - Apply naming convention to all fields
|
|
34
|
+
- `renameAll = "camelCase"` - Apply naming convention to all fields
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
# Deserialize
|
|
2
2
|
|
|
3
|
-
The `Deserialize` macro generates JSON deserialization methods with **cycle and
|
|
4
|
-
support**, plus comprehensive runtime validation. This enables
|
|
5
|
-
structures including circular references.
|
|
3
|
+
The `Deserialize` macro generates JSON deserialization methods with **cycle and
|
|
4
|
+
forward-reference support**, plus comprehensive runtime validation. This enables
|
|
5
|
+
safe parsing of complex JSON structures including circular references.
|
|
6
6
|
|
|
7
7
|
## Generated Output
|
|
8
8
|
|
|
9
|
-
| Type
|
|
10
|
-
|
|
11
|
-
| Class
|
|
12
|
-
| Enum
|
|
13
|
-
| Interface
|
|
14
|
-
| Type Alias | `typeNameDeserialize(input)`, etc.
|
|
9
|
+
| Type | Generated Code | Description |
|
|
10
|
+
|------|----------------|-------------|
|
|
11
|
+
| Class | `classNameDeserialize(input)` + `static deserialize(input)` | Standalone function + static factory method |
|
|
12
|
+
| Enum | `enumNameDeserialize(input)`, `enumNameDeserializeWithContext(data)`, `enumNameIs(value)` | Standalone functions |
|
|
13
|
+
| Interface | `interfaceNameDeserialize(input)`, etc. | Standalone functions |
|
|
14
|
+
| Type Alias | `typeNameDeserialize(input)`, etc. | Standalone functions |
|
|
15
15
|
|
|
16
16
|
## Return Type
|
|
17
17
|
|
|
@@ -29,32 +29,27 @@ Uses deferred patching to handle references:
|
|
|
29
29
|
3. After all objects are created, `ctx.applyPatches()` resolves all pending references
|
|
30
30
|
|
|
31
31
|
References only apply to object-shaped, serializable values. The generator avoids probing for
|
|
32
|
-
`__ref` on primitive-like fields (including literal unions and `T | null` where `T` is
|
|
33
|
-
|
|
34
|
-
references.
|
|
32
|
+
`__ref` on primitive-like fields (including literal unions and `T | null` where `T` is primitive-like),
|
|
33
|
+
and it parses `Date` / `Date | null` from ISO strings without treating them as references.
|
|
35
34
|
|
|
36
35
|
## Validation
|
|
37
36
|
|
|
38
37
|
The macro supports 30+ validators via `@serde(validate(...))`:
|
|
39
38
|
|
|
40
39
|
### String Validators
|
|
41
|
-
|
|
42
40
|
- `email`, `url`, `uuid` - Format validation
|
|
43
41
|
- `minLength(n)`, `maxLength(n)`, `length(n)` - Length constraints
|
|
44
42
|
- `pattern("regex")` - Regular expression matching
|
|
45
43
|
- `nonEmpty`, `trimmed`, `lowercase`, `uppercase` - String properties
|
|
46
44
|
|
|
47
45
|
### Number Validators
|
|
48
|
-
|
|
49
46
|
- `gt(n)`, `gte(n)`, `lt(n)`, `lte(n)`, `between(min, max)` - Range checks
|
|
50
47
|
- `int`, `positive`, `nonNegative`, `finite` - Number properties
|
|
51
48
|
|
|
52
49
|
### Array Validators
|
|
53
|
-
|
|
54
50
|
- `minItems(n)`, `maxItems(n)`, `itemsCount(n)` - Collection size
|
|
55
51
|
|
|
56
52
|
### Date Validators
|
|
57
|
-
|
|
58
53
|
- `validDate`, `afterDate("ISO")`, `beforeDate("ISO")` - Date validation
|
|
59
54
|
|
|
60
55
|
## Field-Level Options
|
|
@@ -77,29 +72,23 @@ The `@serde` decorator supports:
|
|
|
77
72
|
Union types are deserialized based on their member types:
|
|
78
73
|
|
|
79
74
|
### Literal Unions
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
literals directly.
|
|
75
|
+
For unions of literal values (`"A" | "B" | 123`), the value is validated against
|
|
76
|
+
the allowed literals directly.
|
|
83
77
|
|
|
84
78
|
### Primitive Unions
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
validate the value type. No `__type` discriminator is needed.
|
|
79
|
+
For unions containing primitive types (`string | number`), the deserializer uses
|
|
80
|
+
`typeof` checks to validate the value type. No `__type` discriminator is needed.
|
|
88
81
|
|
|
89
82
|
### Class/Interface Unions
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
JSON to dispatch to the correct type's `deserializeWithContext` method.
|
|
83
|
+
For unions of serializable types (`User | Admin`), the deserializer requires a
|
|
84
|
+
`__type` field in the JSON to dispatch to the correct type's `deserializeWithContext` method.
|
|
93
85
|
|
|
94
86
|
### Generic Type Parameters
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
through as-is since its concrete type is only known at the call site.
|
|
87
|
+
For generic unions like `type Result<T> = T | Error`, the generic type parameter `T`
|
|
88
|
+
is passed through as-is since its concrete type is only known at the call site.
|
|
98
89
|
|
|
99
90
|
### Mixed Unions
|
|
100
|
-
|
|
101
91
|
Mixed unions (e.g., `string | Date | User`) check in order:
|
|
102
|
-
|
|
103
92
|
1. Literal values
|
|
104
93
|
2. Primitives (via `typeof`)
|
|
105
94
|
3. Date (via `instanceof` or ISO string parsing)
|
|
@@ -322,5 +311,4 @@ if (Result.isOk(result)) {
|
|
|
322
311
|
## Required Imports
|
|
323
312
|
|
|
324
313
|
The generated code automatically imports:
|
|
325
|
-
|
|
326
314
|
- `DeserializeContext`, `DeserializeError`, `PendingRef` from `macroforge/serde`
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
# Hash
|
|
2
2
|
|
|
3
|
-
The `Hash` macro generates a `hashCode()` method for computing numeric hash codes.
|
|
4
|
-
to Rust's `Hash` trait and Java's `hashCode()` method, enabling
|
|
5
|
-
hash-based collections.
|
|
3
|
+
The `Hash` macro generates a `hashCode()` method for computing numeric hash codes.
|
|
4
|
+
This is analogous to Rust's `Hash` trait and Java's `hashCode()` method, enabling
|
|
5
|
+
objects to be used as keys in hash-based collections.
|
|
6
6
|
|
|
7
7
|
## Generated Output
|
|
8
8
|
|
|
9
|
-
| Type
|
|
10
|
-
|
|
11
|
-
| Class
|
|
12
|
-
| Enum
|
|
13
|
-
| Interface
|
|
14
|
-
| Type Alias | `typeNameHashCode(value: TypeName): number`
|
|
9
|
+
| Type | Generated Code | Description |
|
|
10
|
+
|------|----------------|-------------|
|
|
11
|
+
| Class | `classNameHashCode(value)` + `static hashCode(value)` | Standalone function + static wrapper method |
|
|
12
|
+
| Enum | `enumNameHashCode(value: EnumName): number` | Standalone function hashing by enum value |
|
|
13
|
+
| Interface | `interfaceNameHashCode(value: InterfaceName): number` | Standalone function computing hash |
|
|
14
|
+
| Type Alias | `typeNameHashCode(value: TypeName): number` | Standalone function computing hash |
|
|
15
|
+
|
|
15
16
|
|
|
16
17
|
## Hash Algorithm
|
|
17
18
|
|
|
@@ -27,17 +28,17 @@ This algorithm is consistent with Java's `Objects.hash()` implementation.
|
|
|
27
28
|
|
|
28
29
|
## Type-Specific Hashing
|
|
29
30
|
|
|
30
|
-
| Type
|
|
31
|
-
|
|
32
|
-
| `number`
|
|
33
|
-
| `bigint`
|
|
34
|
-
| `string`
|
|
35
|
-
| `boolean` | 1231 for true, 1237 for false (Java convention)
|
|
36
|
-
| `Date`
|
|
37
|
-
| Arrays
|
|
38
|
-
| `Map`
|
|
39
|
-
| `Set`
|
|
40
|
-
| Objects
|
|
31
|
+
| Type | Hash Strategy |
|
|
32
|
+
|------|---------------|
|
|
33
|
+
| `number` | Integer: direct value; Float: string hash of decimal |
|
|
34
|
+
| `bigint` | String hash of decimal representation |
|
|
35
|
+
| `string` | Character-by-character polynomial hash |
|
|
36
|
+
| `boolean` | 1231 for true, 1237 for false (Java convention) |
|
|
37
|
+
| `Date` | `getTime()` timestamp |
|
|
38
|
+
| Arrays | Element-by-element hash combination |
|
|
39
|
+
| `Map` | Entry-by-entry key+value hash |
|
|
40
|
+
| `Set` | Element-by-element hash |
|
|
41
|
+
| Objects | Calls `hashCode()` if available, else JSON string hash |
|
|
41
42
|
|
|
42
43
|
## Field-Level Options
|
|
43
44
|
|
|
@@ -76,14 +77,18 @@ class User {
|
|
|
76
77
|
|
|
77
78
|
export function userHashCode(value: User): number {
|
|
78
79
|
let hash = 17;
|
|
79
|
-
hash =
|
|
80
|
-
(
|
|
81
|
-
.
|
|
82
|
-
|
|
83
|
-
|
|
80
|
+
hash =
|
|
81
|
+
(hash * 31 +
|
|
82
|
+
(Number.isInteger(value.id)
|
|
83
|
+
? value.id | 0
|
|
84
|
+
: value.id
|
|
85
|
+
.toString()
|
|
86
|
+
.split('')
|
|
87
|
+
.reduce((h, c) => (h * 31 + c.charCodeAt(0)) | 0, 0))) |
|
|
84
88
|
0;
|
|
85
|
-
hash =
|
|
86
|
-
(
|
|
89
|
+
hash =
|
|
90
|
+
(hash * 31 +
|
|
91
|
+
(value.name ?? '').split('').reduce((h, c) => (h * 31 + c.charCodeAt(0)) | 0, 0)) |
|
|
87
92
|
0;
|
|
88
93
|
return hash;
|
|
89
94
|
}
|
|
@@ -96,5 +101,6 @@ export function userEquals(a: User, b: User): boolean {
|
|
|
96
101
|
|
|
97
102
|
## Hash Contract
|
|
98
103
|
|
|
99
|
-
Objects that are equal (`PartialEq`) should produce the same hash code.
|
|
100
|
-
ensure the same fields are skipped in both
|
|
104
|
+
Objects that are equal (`PartialEq`) should produce the same hash code.
|
|
105
|
+
When using `@hash(skip)`, ensure the same fields are skipped in both
|
|
106
|
+
`Hash` and `PartialEq` to maintain this contract.
|
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
# Ord
|
|
2
2
|
|
|
3
|
-
The `Ord` macro generates a `compareTo()` method for **total ordering** comparison.
|
|
4
|
-
analogous to Rust's `Ord` trait, enabling objects to be sorted and
|
|
5
|
-
ordering relationship.
|
|
3
|
+
The `Ord` macro generates a `compareTo()` method for **total ordering** comparison.
|
|
4
|
+
This is analogous to Rust's `Ord` trait, enabling objects to be sorted and
|
|
5
|
+
compared with a guaranteed ordering relationship.
|
|
6
6
|
|
|
7
7
|
## Generated Output
|
|
8
8
|
|
|
9
|
-
| Type
|
|
10
|
-
|
|
11
|
-
| Class
|
|
12
|
-
| Enum
|
|
13
|
-
| Interface
|
|
14
|
-
| Type Alias | `typeNameCompare(a: TypeName, b: TypeName): number`
|
|
9
|
+
| Type | Generated Code | Description |
|
|
10
|
+
|------|----------------|-------------|
|
|
11
|
+
| Class | `classNameCompare(a, b)` + `static compareTo(a, b)` | Standalone function + static wrapper method |
|
|
12
|
+
| Enum | `enumNameCompare(a: EnumName, b: EnumName): number` | Standalone function comparing enum values |
|
|
13
|
+
| Interface | `interfaceNameCompare(a: InterfaceName, b: InterfaceName): number` | Standalone function comparing fields |
|
|
14
|
+
| Type Alias | `typeNameCompare(a: TypeName, b: TypeName): number` | Standalone function with type-appropriate comparison |
|
|
15
|
+
|
|
15
16
|
|
|
16
17
|
## Return Values
|
|
17
18
|
|
|
18
|
-
Unlike `PartialOrd`, `Ord` provides **total ordering** - every pair of values
|
|
19
|
+
Unlike `PartialOrd`, `Ord` provides **total ordering** - every pair of values
|
|
20
|
+
can be compared:
|
|
19
21
|
|
|
20
22
|
- **-1**: `a` is less than `b`
|
|
21
23
|
- **0**: `a` is equal to `b`
|
|
@@ -34,14 +36,14 @@ Fields are compared **lexicographically** in declaration order:
|
|
|
34
36
|
|
|
35
37
|
## Type-Specific Comparisons
|
|
36
38
|
|
|
37
|
-
| Type
|
|
38
|
-
|
|
39
|
-
| `number`/`bigint` | Direct `<` and `>` comparison
|
|
40
|
-
| `string`
|
|
41
|
-
| `boolean`
|
|
42
|
-
| Arrays
|
|
43
|
-
| `Date`
|
|
44
|
-
| Objects
|
|
39
|
+
| Type | Comparison Method |
|
|
40
|
+
|------|-------------------|
|
|
41
|
+
| `number`/`bigint` | Direct `<` and `>` comparison |
|
|
42
|
+
| `string` | `localeCompare()` (clamped to -1, 0, 1) |
|
|
43
|
+
| `boolean` | false < true |
|
|
44
|
+
| Arrays | Lexicographic element-by-element |
|
|
45
|
+
| `Date` | `getTime()` timestamp comparison |
|
|
46
|
+
| Objects | Calls `compareTo()` if available, else 0 |
|
|
45
47
|
|
|
46
48
|
## Field-Level Options
|
|
47
49
|
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
# PartialEq
|
|
2
2
|
|
|
3
|
-
The `PartialEq` macro generates an `equals()` method for field-by-field
|
|
4
|
-
comparison. This is analogous to Rust's `PartialEq` trait,
|
|
5
|
-
instead of reference equality.
|
|
3
|
+
The `PartialEq` macro generates an `equals()` method for field-by-field
|
|
4
|
+
structural equality comparison. This is analogous to Rust's `PartialEq` trait,
|
|
5
|
+
enabling value-based equality semantics instead of reference equality.
|
|
6
6
|
|
|
7
7
|
## Generated Output
|
|
8
8
|
|
|
9
|
-
| Type
|
|
10
|
-
|
|
11
|
-
| Class
|
|
12
|
-
| Enum
|
|
13
|
-
| Interface
|
|
14
|
-
| Type Alias | `typeNameEquals(a: TypeName, b: TypeName): boolean`
|
|
9
|
+
| Type | Generated Code | Description |
|
|
10
|
+
|------|----------------|-------------|
|
|
11
|
+
| Class | `classNameEquals(a, b)` + `static equals(a, b)` | Standalone function + static wrapper method |
|
|
12
|
+
| Enum | `enumNameEquals(a: EnumName, b: EnumName): boolean` | Standalone function using strict equality |
|
|
13
|
+
| Interface | `interfaceNameEquals(a: InterfaceName, b: InterfaceName): boolean` | Standalone function comparing fields |
|
|
14
|
+
| Type Alias | `typeNameEquals(a: TypeName, b: TypeName): boolean` | Standalone function with type-appropriate comparison |
|
|
15
15
|
|
|
16
16
|
## Comparison Strategy
|
|
17
17
|
|
|
@@ -22,14 +22,14 @@ The generated equality check:
|
|
|
22
22
|
|
|
23
23
|
## Type-Specific Comparisons
|
|
24
24
|
|
|
25
|
-
| Type
|
|
26
|
-
|
|
27
|
-
| Primitives | Strict equality (`===`)
|
|
28
|
-
| Arrays
|
|
29
|
-
| `Date`
|
|
30
|
-
| `Map`
|
|
31
|
-
| `Set`
|
|
32
|
-
| Objects
|
|
25
|
+
| Type | Comparison Method |
|
|
26
|
+
|------|-------------------|
|
|
27
|
+
| Primitives | Strict equality (`===`) |
|
|
28
|
+
| Arrays | Length + element-by-element (recursive) |
|
|
29
|
+
| `Date` | `getTime()` comparison |
|
|
30
|
+
| `Map` | Size + entry-by-entry comparison |
|
|
31
|
+
| `Set` | Size + membership check |
|
|
32
|
+
| Objects | Calls `equals()` if available, else `===` |
|
|
33
33
|
|
|
34
34
|
## Field-Level Options
|
|
35
35
|
|
|
@@ -73,14 +73,18 @@ export function userEquals(a: User, b: User): boolean {
|
|
|
73
73
|
|
|
74
74
|
export function userHashCode(value: User): number {
|
|
75
75
|
let hash = 17;
|
|
76
|
-
hash =
|
|
77
|
-
(
|
|
78
|
-
.
|
|
79
|
-
|
|
80
|
-
|
|
76
|
+
hash =
|
|
77
|
+
(hash * 31 +
|
|
78
|
+
(Number.isInteger(value.id)
|
|
79
|
+
? value.id | 0
|
|
80
|
+
: value.id
|
|
81
|
+
.toString()
|
|
82
|
+
.split('')
|
|
83
|
+
.reduce((h, c) => (h * 31 + c.charCodeAt(0)) | 0, 0))) |
|
|
81
84
|
0;
|
|
82
|
-
hash =
|
|
83
|
-
(
|
|
85
|
+
hash =
|
|
86
|
+
(hash * 31 +
|
|
87
|
+
(value.name ?? '').split('').reduce((h, c) => (h * 31 + c.charCodeAt(0)) | 0, 0)) |
|
|
84
88
|
0;
|
|
85
89
|
return hash;
|
|
86
90
|
}
|
|
@@ -130,14 +134,18 @@ export function userEquals(a: User, b: User): boolean {
|
|
|
130
134
|
|
|
131
135
|
export function userHashCode(value: User): number {
|
|
132
136
|
let hash = 17;
|
|
133
|
-
hash =
|
|
134
|
-
(
|
|
135
|
-
.
|
|
136
|
-
|
|
137
|
-
|
|
137
|
+
hash =
|
|
138
|
+
(hash * 31 +
|
|
139
|
+
(Number.isInteger(value.id)
|
|
140
|
+
? value.id | 0
|
|
141
|
+
: value.id
|
|
142
|
+
.toString()
|
|
143
|
+
.split('')
|
|
144
|
+
.reduce((h, c) => (h * 31 + c.charCodeAt(0)) | 0, 0))) |
|
|
138
145
|
0;
|
|
139
|
-
hash =
|
|
140
|
-
(
|
|
146
|
+
hash =
|
|
147
|
+
(hash * 31 +
|
|
148
|
+
(value.name ?? '').split('').reduce((h, c) => (h * 31 + c.charCodeAt(0)) | 0, 0)) |
|
|
141
149
|
0;
|
|
142
150
|
return hash;
|
|
143
151
|
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
# PartialOrd
|
|
2
2
|
|
|
3
|
-
The `PartialOrd` macro generates a `compareTo()` method for **partial ordering**
|
|
4
|
-
analogous to Rust's `PartialOrd` trait, enabling comparison
|
|
5
|
-
incomparable.
|
|
3
|
+
The `PartialOrd` macro generates a `compareTo()` method for **partial ordering**
|
|
4
|
+
comparison. This is analogous to Rust's `PartialOrd` trait, enabling comparison
|
|
5
|
+
between values where some pairs may be incomparable.
|
|
6
6
|
|
|
7
7
|
## Generated Output
|
|
8
8
|
|
|
9
|
-
| Type
|
|
10
|
-
|
|
11
|
-
| Class
|
|
12
|
-
| Enum
|
|
13
|
-
| Interface
|
|
14
|
-
| Type Alias | `typeNamePartialCompare(a: TypeName, b: TypeName): Option<number>`
|
|
9
|
+
| Type | Generated Code | Description |
|
|
10
|
+
|------|----------------|-------------|
|
|
11
|
+
| Class | `classNamePartialCompare(a, b)` + `static compareTo(a, b)` | Standalone function + static wrapper method |
|
|
12
|
+
| Enum | `enumNamePartialCompare(a: EnumName, b: EnumName): Option<number>` | Standalone function returning Option |
|
|
13
|
+
| Interface | `interfaceNamePartialCompare(a: InterfaceName, b: InterfaceName): Option<number>` | Standalone function with Option |
|
|
14
|
+
| Type Alias | `typeNamePartialCompare(a: TypeName, b: TypeName): Option<number>` | Standalone function with Option |
|
|
15
15
|
|
|
16
16
|
## Return Values
|
|
17
17
|
|
|
@@ -43,15 +43,15 @@ Fields are compared **lexicographically** in declaration order:
|
|
|
43
43
|
|
|
44
44
|
## Type-Specific Comparisons
|
|
45
45
|
|
|
46
|
-
| Type
|
|
47
|
-
|
|
48
|
-
| `number`/`bigint` | Direct comparison, returns some()
|
|
49
|
-
| `string`
|
|
50
|
-
| `boolean`
|
|
51
|
-
| null/undefined
|
|
52
|
-
| Arrays
|
|
53
|
-
| `Date`
|
|
54
|
-
| Objects
|
|
46
|
+
| Type | Comparison Method |
|
|
47
|
+
|------|-------------------|
|
|
48
|
+
| `number`/`bigint` | Direct comparison, returns some() |
|
|
49
|
+
| `string` | `localeCompare()` wrapped in some() |
|
|
50
|
+
| `boolean` | false < true, wrapped in some() |
|
|
51
|
+
| null/undefined | Returns none() for mismatched nullability |
|
|
52
|
+
| Arrays | Lexicographic, propagates none() on incomparable elements |
|
|
53
|
+
| `Date` | Timestamp comparison, none() if invalid |
|
|
54
|
+
| Objects | Unwraps nested Option from compareTo() |
|
|
55
55
|
|
|
56
56
|
## Field-Level Options
|
|
57
57
|
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
# Serialize
|
|
2
2
|
|
|
3
|
-
The `Serialize` macro generates JSON serialization methods with **cycle detection**
|
|
4
|
-
identity tracking. This enables serialization of complex object graphs
|
|
5
|
-
references.
|
|
3
|
+
The `Serialize` macro generates JSON serialization methods with **cycle detection**
|
|
4
|
+
and object identity tracking. This enables serialization of complex object graphs
|
|
5
|
+
including circular references.
|
|
6
6
|
|
|
7
7
|
## Generated Methods
|
|
8
8
|
|
|
9
|
-
| Type
|
|
10
|
-
|
|
11
|
-
| Class
|
|
12
|
-
| Enum
|
|
13
|
-
| Interface
|
|
14
|
-
| Type Alias | `typeNameSerialize(value)`, etc.
|
|
9
|
+
| Type | Generated Code | Description |
|
|
10
|
+
|------|----------------|-------------|
|
|
11
|
+
| Class | `classNameSerialize(value)` + `static serialize(value)` | Standalone function + static wrapper method |
|
|
12
|
+
| Enum | `enumNameSerialize(value)`, `enumNameSerializeWithContext` | Standalone functions |
|
|
13
|
+
| Interface | `interfaceNameSerialize(value)`, etc. | Standalone functions |
|
|
14
|
+
| Type Alias | `typeNameSerialize(value)`, etc. | Standalone functions |
|
|
15
15
|
|
|
16
16
|
## Cycle Detection Protocol
|
|
17
17
|
|
|
@@ -22,30 +22,29 @@ The generated code handles circular references using `__id` and `__ref` markers:
|
|
|
22
22
|
"__type": "User",
|
|
23
23
|
"__id": 1,
|
|
24
24
|
"name": "Alice",
|
|
25
|
-
"friend": { "__ref": 2 }
|
|
25
|
+
"friend": { "__ref": 2 } // Reference to object with __id: 2
|
|
26
26
|
}
|
|
27
27
|
```
|
|
28
28
|
|
|
29
29
|
When an object is serialized:
|
|
30
|
-
|
|
31
30
|
1. Check if it's already been serialized (has an `__id`)
|
|
32
31
|
2. If so, return `{ "__ref": existingId }` instead
|
|
33
32
|
3. Otherwise, register the object and serialize its fields
|
|
34
33
|
|
|
35
34
|
## Type-Specific Serialization
|
|
36
35
|
|
|
37
|
-
| Type
|
|
38
|
-
|
|
39
|
-
| Primitives | Direct value
|
|
40
|
-
| `Date`
|
|
41
|
-
| Arrays
|
|
42
|
-
| `Map<K,V>` | For primitive-like values, `Object.fromEntries(map.entries())`; for `Date`/`Date
|
|
43
|
-
| `Set<T>`
|
|
44
|
-
| Nullable
|
|
45
|
-
| Objects
|
|
46
|
-
|
|
47
|
-
Note: the generator specializes some code paths based on the declared TypeScript type to
|
|
48
|
-
runtime feature detection on primitives and literal unions.
|
|
36
|
+
| Type | Serialization Strategy |
|
|
37
|
+
|------|------------------------|
|
|
38
|
+
| Primitives | Direct value |
|
|
39
|
+
| `Date` | `toISOString()` |
|
|
40
|
+
| Arrays | For primitive-like element types, pass through; for `Date`/`Date | null`, map to ISO strings; otherwise map and call `SerializeWithContext(ctx)` when available |
|
|
41
|
+
| `Map<K,V>` | For primitive-like values, `Object.fromEntries(map.entries())`; for `Date`/`Date | null`, convert to ISO strings; otherwise call `SerializeWithContext(ctx)` per value when available |
|
|
42
|
+
| `Set<T>` | Convert to array; element handling matches `Array<T>` |
|
|
43
|
+
| Nullable | Include `null` explicitly; for primitive-like and `Date` unions the generator avoids runtime `SerializeWithContext` checks |
|
|
44
|
+
| Objects | Call `SerializeWithContext(ctx)` if available (to support user-defined implementations) |
|
|
45
|
+
|
|
46
|
+
Note: the generator specializes some code paths based on the declared TypeScript type to
|
|
47
|
+
avoid runtime feature detection on primitives and literal unions.
|
|
49
48
|
|
|
50
49
|
## Field-Level Options
|
|
51
50
|
|
|
@@ -75,6 +75,13 @@ Note
|
|
|
75
75
|
|
|
76
76
|
The `import macro` comment tells Macroforge which package provides the macro.
|
|
77
77
|
|
|
78
|
+
## Vite Dev Server
|
|
79
|
+
|
|
80
|
+
When using a custom macro package as a local `file:` dependency, you may need to configure Vite's
|
|
81
|
+
`server.fs.allow` and add `exports` to your package's `package.json` for dev mode to work. See the
|
|
82
|
+
[Vite Plugin integration guide](../integration/vite-plugin.md#custom-macro-packages-with-file-dependencies)
|
|
83
|
+
for details.
|
|
84
|
+
|
|
78
85
|
## Getting Started
|
|
79
86
|
|
|
80
87
|
Follow these guides to create your own macros:
|
|
@@ -110,6 +110,46 @@ During development, the plugin:
|
|
|
110
110
|
- Expands macros on save
|
|
111
111
|
- Provides HMR support for expanded code
|
|
112
112
|
|
|
113
|
+
### Custom Macro Packages with `file:` Dependencies
|
|
114
|
+
|
|
115
|
+
If your custom macro package is a local `file:` dependency (e.g. `"@my/macros": "file:./macros"`),
|
|
116
|
+
the expanded code may contain runtime imports pointing to files inside that package. Vite's dev
|
|
117
|
+
server restricts filesystem access to a set of allowed directories (`src/`, `.svelte-kit/`,
|
|
118
|
+
`node_modules/`, etc.), and local `file:` dependencies outside those paths will be blocked.
|
|
119
|
+
|
|
120
|
+
You must add the package directory to `server.fs.allow`:
|
|
121
|
+
|
|
122
|
+
vite.config.ts
|
|
123
|
+
|
|
124
|
+
```
|
|
125
|
+
export default defineConfig({
|
|
126
|
+
plugins: [macroforge()],
|
|
127
|
+
server: {
|
|
128
|
+
fs: {
|
|
129
|
+
allow: ['macros'] // path to your local macro package
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
The macro package also needs a `package.json` `exports` field so Vite can resolve subpath imports.
|
|
136
|
+
For example, if expanded code imports from `@my/macros/helpers`:
|
|
137
|
+
|
|
138
|
+
macros/package.json
|
|
139
|
+
|
|
140
|
+
```
|
|
141
|
+
{
|
|
142
|
+
"name": "@my/macros",
|
|
143
|
+
"exports": {
|
|
144
|
+
".": { "types": "./index.d.ts", "default": "./index.js" },
|
|
145
|
+
"./helpers": "./helpers.ts"
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Without this, Vite's dev server will fail with `Pre-transform error: Failed to load url ...` even
|
|
151
|
+
though the file exists on disk.
|
|
152
|
+
|
|
113
153
|
## Production Build
|
|
114
154
|
|
|
115
155
|
During production builds, the plugin:
|
package/docs/sections.json
CHANGED
|
@@ -1,127 +1,127 @@
|
|
|
1
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
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
]
|
|
2
|
+
{
|
|
3
|
+
"id": "debug",
|
|
4
|
+
"title": "Debug",
|
|
5
|
+
"category": "builtin-macros",
|
|
6
|
+
"category_title": "Built-in Macros",
|
|
7
|
+
"path": "builtin-macros/debug.md",
|
|
8
|
+
"use_cases": "toString, debugging, logging, output, print"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"id": "clone",
|
|
12
|
+
"title": "Clone",
|
|
13
|
+
"category": "builtin-macros",
|
|
14
|
+
"category_title": "Built-in Macros",
|
|
15
|
+
"path": "builtin-macros/clone.md",
|
|
16
|
+
"use_cases": "copy, clone, duplicate, shallow copy, immutable"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"id": "default",
|
|
20
|
+
"title": "Default",
|
|
21
|
+
"category": "builtin-macros",
|
|
22
|
+
"category_title": "Built-in Macros",
|
|
23
|
+
"path": "builtin-macros/default.md",
|
|
24
|
+
"use_cases": "default values, factory, initialization, constructor"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"id": "hash",
|
|
28
|
+
"title": "Hash",
|
|
29
|
+
"category": "builtin-macros",
|
|
30
|
+
"category_title": "Built-in Macros",
|
|
31
|
+
"path": "builtin-macros/hash.md",
|
|
32
|
+
"use_cases": "hashCode, hashing, hash map, equality, hash function"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"id": "ord",
|
|
36
|
+
"title": "Ord",
|
|
37
|
+
"category": "builtin-macros",
|
|
38
|
+
"category_title": "Built-in Macros",
|
|
39
|
+
"path": "builtin-macros/ord.md",
|
|
40
|
+
"use_cases": "compareTo, ordering, sorting, comparison, total order"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"id": "partial-eq",
|
|
44
|
+
"title": "PartialEq",
|
|
45
|
+
"category": "builtin-macros",
|
|
46
|
+
"category_title": "Built-in Macros",
|
|
47
|
+
"path": "builtin-macros/partial-eq.md",
|
|
48
|
+
"use_cases": "equals, equality, comparison, value equality"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"id": "partial-ord",
|
|
52
|
+
"title": "PartialOrd",
|
|
53
|
+
"category": "builtin-macros",
|
|
54
|
+
"category_title": "Built-in Macros",
|
|
55
|
+
"path": "builtin-macros/partial-ord.md",
|
|
56
|
+
"use_cases": "compareTo, partial ordering, sorting, nullable comparison"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"id": "serialize",
|
|
60
|
+
"title": "Serialize",
|
|
61
|
+
"category": "builtin-macros",
|
|
62
|
+
"category_title": "Built-in Macros",
|
|
63
|
+
"path": "builtin-macros/serialize.md",
|
|
64
|
+
"use_cases": "toJSON, serialization, json, api, data transfer"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"id": "deserialize/overview",
|
|
68
|
+
"title": "Deserialize: Overview",
|
|
69
|
+
"category": "builtin-macros",
|
|
70
|
+
"category_title": "Built-in Macros",
|
|
71
|
+
"path": "builtin-macros/deserialize/overview.md",
|
|
72
|
+
"use_cases": "fromJSON, deserialization, deserialize, classnamedeserialize(input), enumnamedeserialize(input)",
|
|
73
|
+
"parent_id": "deserialize"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"id": "deserialize/cycleforward-reference-support",
|
|
77
|
+
"title": "Deserialize: Cycle/Forward-Reference Support",
|
|
78
|
+
"category": "builtin-macros",
|
|
79
|
+
"category_title": "Built-in Macros",
|
|
80
|
+
"path": "builtin-macros/deserialize/cycleforward-reference-support.md",
|
|
81
|
+
"use_cases": "fromJSON, deserialization, pendingref, ctx.applypatches(), __ref",
|
|
82
|
+
"parent_id": "deserialize"
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"id": "deserialize/validation",
|
|
86
|
+
"title": "Deserialize: Validation",
|
|
87
|
+
"category": "builtin-macros",
|
|
88
|
+
"category_title": "Built-in Macros",
|
|
89
|
+
"path": "builtin-macros/deserialize/validation.md",
|
|
90
|
+
"use_cases": "fromJSON, deserialization, @serde(validate(...)), email, url, uuid",
|
|
91
|
+
"parent_id": "deserialize"
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"id": "deserialize/union-type-deserialization",
|
|
95
|
+
"title": "Deserialize: Union Type Deserialization",
|
|
96
|
+
"category": "builtin-macros",
|
|
97
|
+
"category_title": "Built-in Macros",
|
|
98
|
+
"path": "builtin-macros/deserialize/union-type-deserialization.md",
|
|
99
|
+
"use_cases": "fromJSON, deserialization, typeof, __type",
|
|
100
|
+
"parent_id": "deserialize"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
"id": "deserialize/example",
|
|
104
|
+
"title": "Deserialize: Example",
|
|
105
|
+
"category": "builtin-macros",
|
|
106
|
+
"category_title": "Built-in Macros",
|
|
107
|
+
"path": "builtin-macros/deserialize/example.md",
|
|
108
|
+
"use_cases": "fromJSON, deserialization",
|
|
109
|
+
"parent_id": "deserialize"
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
"id": "deserialize",
|
|
113
|
+
"title": "Deserialize",
|
|
114
|
+
"category": "builtin-macros",
|
|
115
|
+
"category_title": "Built-in Macros",
|
|
116
|
+
"path": "builtin-macros/deserialize.md",
|
|
117
|
+
"use_cases": "fromJSON, deserialization, parsing, validation, json",
|
|
118
|
+
"is_chunked": true,
|
|
119
|
+
"chunk_ids": [
|
|
120
|
+
"deserialize/overview",
|
|
121
|
+
"deserialize/cycleforward-reference-support",
|
|
122
|
+
"deserialize/validation",
|
|
123
|
+
"deserialize/union-type-deserialization",
|
|
124
|
+
"deserialize/example"
|
|
125
|
+
]
|
|
126
|
+
}
|
|
127
|
+
]
|
package/package.json
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"main": "dist/index.js",
|
|
26
26
|
"name": "@macroforge/mcp-server",
|
|
27
27
|
"peerDependencies": {
|
|
28
|
-
"macroforge": "^0.1.
|
|
28
|
+
"macroforge": "^0.1.76"
|
|
29
29
|
},
|
|
30
30
|
"peerDependenciesMeta": {
|
|
31
31
|
"macroforge": {
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"test": "node --test tests/**/*.test.js"
|
|
47
47
|
},
|
|
48
48
|
"type": "module",
|
|
49
|
-
"version": "0.1.
|
|
49
|
+
"version": "0.1.76"
|
|
50
50
|
}
|