macroforge 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.
Files changed (3) hide show
  1. package/index.d.ts +476 -487
  2. package/index.js +560 -748
  3. package/package.json +10 -7
package/index.d.ts CHANGED
@@ -7,46 +7,46 @@
7
7
  * different JavaScript class name. Used internally by [`NativePlugin::get_mapper`].
8
8
  */
9
9
  export declare class NativeMapper {
10
- /**
11
- * Creates a new mapper wrapping the given source mapping.
12
- *
13
- * # Arguments
14
- *
15
- * * `mapping` - The source mapping result from macro expansion
16
- */
17
- constructor(mapping: SourceMappingResult);
18
- /** Checks if this mapper has no mapping data. */
19
- isEmpty(): boolean;
20
- /**
21
- * Converts a position in the original source to expanded source.
22
- * See [`NativePositionMapper::original_to_expanded`] for details.
23
- */
24
- originalToExpanded(pos: number): number;
25
- /**
26
- * Converts a position in the expanded source back to original.
27
- * See [`NativePositionMapper::expanded_to_original`] for details.
28
- */
29
- expandedToOriginal(pos: number): number | null;
30
- /**
31
- * Returns the name of the macro that generated code at the given position.
32
- * See [`NativePositionMapper::generated_by`] for details.
33
- */
34
- generatedBy(pos: number): string | null;
35
- /**
36
- * Maps a span from expanded source to original source.
37
- * See [`NativePositionMapper::map_span_to_original`] for details.
38
- */
39
- mapSpanToOriginal(start: number, length: number): SpanResult | null;
40
- /**
41
- * Maps a span from original source to expanded source.
42
- * See [`NativePositionMapper::map_span_to_expanded`] for details.
43
- */
44
- mapSpanToExpanded(start: number, length: number): SpanResult;
45
- /**
46
- * Checks if a position is inside macro-generated code.
47
- * See [`NativePositionMapper::is_in_generated`] for details.
48
- */
49
- isInGenerated(pos: number): boolean;
10
+ /**
11
+ * Creates a new mapper wrapping the given source mapping.
12
+ *
13
+ * # Arguments
14
+ *
15
+ * * `mapping` - The source mapping result from macro expansion
16
+ */
17
+ constructor(mapping: SourceMappingResult)
18
+ /** Checks if this mapper has no mapping data. */
19
+ isEmpty(): boolean
20
+ /**
21
+ * Converts a position in the original source to expanded source.
22
+ * See [`NativePositionMapper::original_to_expanded`] for details.
23
+ */
24
+ originalToExpanded(pos: number): number
25
+ /**
26
+ * Converts a position in the expanded source back to original.
27
+ * See [`NativePositionMapper::expanded_to_original`] for details.
28
+ */
29
+ expandedToOriginal(pos: number): number | null
30
+ /**
31
+ * Returns the name of the macro that generated code at the given position.
32
+ * See [`NativePositionMapper::generated_by`] for details.
33
+ */
34
+ generatedBy(pos: number): string | null
35
+ /**
36
+ * Maps a span from expanded source to original source.
37
+ * See [`NativePositionMapper::map_span_to_original`] for details.
38
+ */
39
+ mapSpanToOriginal(start: number, length: number): SpanResult | null
40
+ /**
41
+ * Maps a span from original source to expanded source.
42
+ * See [`NativePositionMapper::map_span_to_expanded`] for details.
43
+ */
44
+ mapSpanToExpanded(start: number, length: number): SpanResult
45
+ /**
46
+ * Checks if a position is inside macro-generated code.
47
+ * See [`NativePositionMapper::is_in_generated`] for details.
48
+ */
49
+ isInGenerated(pos: number): boolean
50
50
  }
51
51
 
52
52
  /**
@@ -78,124 +78,120 @@ export declare class NativeMapper {
78
78
  * ```
79
79
  */
80
80
  export declare class NativePlugin {
81
- /**
82
- * Creates a new `NativePlugin` instance.
83
- *
84
- * Initializes the plugin with an empty cache and sets up a default log file
85
- * at `/tmp/macroforge-plugin.log` for debugging purposes.
86
- *
87
- * # Returns
88
- *
89
- * A new `NativePlugin` ready for processing files.
90
- *
91
- * # Side Effects
92
- *
93
- * Creates or clears the log file at `/tmp/macroforge-plugin.log`.
94
- */
95
- constructor();
96
- /**
97
- * Writes a message to the plugin's log file.
98
- *
99
- * Useful for debugging macro expansion issues in production environments.
100
- *
101
- * # Arguments
102
- *
103
- * * `message` - The message to log
104
- *
105
- * # Note
106
- *
107
- * Messages are appended to the log file. If the log file hasn't been
108
- * configured or cannot be written to, the message is silently dropped.
109
- */
110
- log(message: string): void;
111
- /**
112
- * Sets the path for the plugin's log file.
113
- *
114
- * # Arguments
115
- *
116
- * * `path` - The file path to use for logging
117
- *
118
- * # Note
119
- *
120
- * This does not create the file; it will be created when the first
121
- * message is logged.
122
- */
123
- setLogFile(path: string): void;
124
- /**
125
- * Processes a TypeScript file through the macro expansion system.
126
- *
127
- * This is the main entry point for file processing. It handles caching,
128
- * thread isolation (to prevent stack overflow), and error recovery.
129
- *
130
- * # Arguments
131
- *
132
- * * `_env` - NAPI environment (unused but required by NAPI)
133
- * * `filepath` - Path to the file (used for TSX detection and caching)
134
- * * `code` - The TypeScript source code to process
135
- * * `options` - Optional configuration for expansion and caching
136
- *
137
- * # Returns
138
- *
139
- * An [`ExpandResult`] containing the expanded code, diagnostics, and source mapping.
140
- *
141
- * # Errors
142
- *
143
- * Returns an error if:
144
- * - Thread spawning fails
145
- * - The worker thread panics (often due to stack overflow)
146
- * - Macro expansion fails internally
147
- *
148
- * # Performance
149
- *
150
- * - Uses a 32MB thread stack to prevent stack overflow during deep AST recursion
151
- * - Caches results by filepath and version for efficient incremental processing
152
- * - Early bailout for files without `@derive` decorators
153
- *
154
- * # Thread Safety
155
- *
156
- * Macro expansion runs in a separate thread because:
157
- * 1. SWC AST operations can be deeply recursive, exceeding default stack limits
158
- * 2. Node.js thread stack is typically only 2MB
159
- * 3. Panics in the worker thread are caught and reported gracefully
160
- */
161
- processFile(
162
- filepath: string,
163
- code: string,
164
- options?: ProcessFileOptions | undefined | null
165
- ): ExpandResult;
166
- /**
167
- * Retrieves a position mapper for a previously processed file.
168
- *
169
- * The mapper enables translation between original and expanded source positions,
170
- * which is essential for IDE features like error reporting and navigation.
171
- *
172
- * # Arguments
173
- *
174
- * * `filepath` - Path to the file (must have been previously processed)
175
- *
176
- * # Returns
177
- *
178
- * `Some(NativeMapper)` if the file has been processed and has source mapping data,
179
- * `None` if the file hasn't been processed or has no mapping (no macros expanded).
180
- */
181
- getMapper(filepath: string): NativeMapper | null;
182
- /**
183
- * Maps diagnostics from expanded source positions back to original source positions.
184
- *
185
- * This is used by IDE integrations to show errors at the correct locations
186
- * in the user's original code, rather than in the macro-expanded output.
187
- *
188
- * # Arguments
189
- *
190
- * * `filepath` - Path to the file the diagnostics are for
191
- * * `diags` - Diagnostics with positions in the expanded source
192
- *
193
- * # Returns
194
- *
195
- * Diagnostics with positions mapped back to the original source.
196
- * If no mapper is available for the file, returns diagnostics unchanged.
197
- */
198
- mapDiagnostics(filepath: string, diags: Array<JsDiagnostic>): Array<JsDiagnostic>;
81
+ /**
82
+ * Creates a new `NativePlugin` instance.
83
+ *
84
+ * Initializes the plugin with an empty cache and sets up a default log file
85
+ * at `/tmp/macroforge-plugin.log` for debugging purposes.
86
+ *
87
+ * # Returns
88
+ *
89
+ * A new `NativePlugin` ready for processing files.
90
+ *
91
+ * # Side Effects
92
+ *
93
+ * Creates or clears the log file at `/tmp/macroforge-plugin.log`.
94
+ */
95
+ constructor()
96
+ /**
97
+ * Writes a message to the plugin's log file.
98
+ *
99
+ * Useful for debugging macro expansion issues in production environments.
100
+ *
101
+ * # Arguments
102
+ *
103
+ * * `message` - The message to log
104
+ *
105
+ * # Note
106
+ *
107
+ * Messages are appended to the log file. If the log file hasn't been
108
+ * configured or cannot be written to, the message is silently dropped.
109
+ */
110
+ log(message: string): void
111
+ /**
112
+ * Sets the path for the plugin's log file.
113
+ *
114
+ * # Arguments
115
+ *
116
+ * * `path` - The file path to use for logging
117
+ *
118
+ * # Note
119
+ *
120
+ * This does not create the file; it will be created when the first
121
+ * message is logged.
122
+ */
123
+ setLogFile(path: string): void
124
+ /**
125
+ * Processes a TypeScript file through the macro expansion system.
126
+ *
127
+ * This is the main entry point for file processing. It handles caching,
128
+ * thread isolation (to prevent stack overflow), and error recovery.
129
+ *
130
+ * # Arguments
131
+ *
132
+ * * `_env` - NAPI environment (unused but required by NAPI)
133
+ * * `filepath` - Path to the file (used for TSX detection and caching)
134
+ * * `code` - The TypeScript source code to process
135
+ * * `options` - Optional configuration for expansion and caching
136
+ *
137
+ * # Returns
138
+ *
139
+ * An [`ExpandResult`] containing the expanded code, diagnostics, and source mapping.
140
+ *
141
+ * # Errors
142
+ *
143
+ * Returns an error if:
144
+ * - Thread spawning fails
145
+ * - The worker thread panics (often due to stack overflow)
146
+ * - Macro expansion fails internally
147
+ *
148
+ * # Performance
149
+ *
150
+ * - Uses a 32MB thread stack to prevent stack overflow during deep AST recursion
151
+ * - Caches results by filepath and version for efficient incremental processing
152
+ * - Early bailout for files without `@derive` decorators
153
+ *
154
+ * # Thread Safety
155
+ *
156
+ * Macro expansion runs in a separate thread because:
157
+ * 1. SWC AST operations can be deeply recursive, exceeding default stack limits
158
+ * 2. Node.js thread stack is typically only 2MB
159
+ * 3. Panics in the worker thread are caught and reported gracefully
160
+ */
161
+ processFile(filepath: string, code: string, options?: ProcessFileOptions | undefined | null): ExpandResult
162
+ /**
163
+ * Retrieves a position mapper for a previously processed file.
164
+ *
165
+ * The mapper enables translation between original and expanded source positions,
166
+ * which is essential for IDE features like error reporting and navigation.
167
+ *
168
+ * # Arguments
169
+ *
170
+ * * `filepath` - Path to the file (must have been previously processed)
171
+ *
172
+ * # Returns
173
+ *
174
+ * `Some(NativeMapper)` if the file has been processed and has source mapping data,
175
+ * `None` if the file hasn't been processed or has no mapping (no macros expanded).
176
+ */
177
+ getMapper(filepath: string): NativeMapper | null
178
+ /**
179
+ * Maps diagnostics from expanded source positions back to original source positions.
180
+ *
181
+ * This is used by IDE integrations to show errors at the correct locations
182
+ * in the user's original code, rather than in the macro-expanded output.
183
+ *
184
+ * # Arguments
185
+ *
186
+ * * `filepath` - Path to the file the diagnostics are for
187
+ * * `diags` - Diagnostics with positions in the expanded source
188
+ *
189
+ * # Returns
190
+ *
191
+ * Diagnostics with positions mapped back to the original source.
192
+ * If no mapper is available for the file, returns diagnostics unchanged.
193
+ */
194
+ mapDiagnostics(filepath: string, diags: Array<JsDiagnostic>): Array<JsDiagnostic>
199
195
  }
200
196
 
201
197
  /**
@@ -228,124 +224,124 @@ export declare class NativePlugin {
228
224
  * ```
229
225
  */
230
226
  export declare class PositionMapper {
231
- /**
232
- * Creates a new position mapper from source mapping data.
233
- *
234
- * # Arguments
235
- *
236
- * * `mapping` - The source mapping result from macro expansion
237
- *
238
- * # Returns
239
- *
240
- * A new `NativePositionMapper` ready for position translation.
241
- */
242
- constructor(mapping: SourceMappingResult);
243
- /**
244
- * Checks if this mapper has no mapping data.
245
- *
246
- * An empty mapper indicates no transformations occurred, so position
247
- * translation is an identity operation.
248
- *
249
- * # Returns
250
- *
251
- * `true` if there are no segments and no generated regions.
252
- */
253
- isEmpty(): boolean;
254
- /**
255
- * Converts a position in the original source to the corresponding position in expanded source.
256
- *
257
- * Uses binary search for O(log n) lookup performance.
258
- *
259
- * # Arguments
260
- *
261
- * * `pos` - Byte offset in the original source
262
- *
263
- * # Returns
264
- *
265
- * The corresponding byte offset in the expanded source. If the position falls
266
- * in a gap between segments, returns the position unchanged. If after the last
267
- * segment, extrapolates based on the delta.
268
- *
269
- * # Algorithm
270
- *
271
- * 1. Binary search to find the segment containing or after `pos`
272
- * 2. If inside a segment, compute offset within segment and translate
273
- * 3. If after all segments, extrapolate from the last segment
274
- * 4. Otherwise, return position unchanged (gap or before first segment)
275
- */
276
- originalToExpanded(pos: number): number;
277
- /**
278
- * Converts a position in the expanded source back to the original source position.
279
- *
280
- * Returns `None` if the position is inside macro-generated code that has no
281
- * corresponding location in the original source.
282
- *
283
- * # Arguments
284
- *
285
- * * `pos` - Byte offset in the expanded source
286
- *
287
- * # Returns
288
- *
289
- * `Some(original_pos)` if the position maps to original code,
290
- * `None` if the position is in macro-generated code.
291
- */
292
- expandedToOriginal(pos: number): number | null;
293
- /**
294
- * Returns the name of the macro that generated code at the given position.
295
- *
296
- * # Arguments
297
- *
298
- * * `pos` - Byte offset in the expanded source
299
- *
300
- * # Returns
301
- *
302
- * `Some(macro_name)` if the position is inside generated code (e.g., "Debug"),
303
- * `None` if the position is in original (non-generated) code.
304
- */
305
- generatedBy(pos: number): string | null;
306
- /**
307
- * Maps a span (start + length) from expanded source to original source.
308
- *
309
- * # Arguments
310
- *
311
- * * `start` - Start byte offset in expanded source
312
- * * `length` - Length of the span in bytes
313
- *
314
- * # Returns
315
- *
316
- * `Some(SpanResult)` with the mapped span in original source,
317
- * `None` if either endpoint is in generated code.
318
- */
319
- mapSpanToOriginal(start: number, length: number): SpanResult | null;
320
- /**
321
- * Maps a span (start + length) from original source to expanded source.
322
- *
323
- * This always succeeds since every original position has an expanded equivalent.
324
- *
325
- * # Arguments
326
- *
327
- * * `start` - Start byte offset in original source
328
- * * `length` - Length of the span in bytes
329
- *
330
- * # Returns
331
- *
332
- * A `SpanResult` with the mapped span in expanded source.
333
- */
334
- mapSpanToExpanded(start: number, length: number): SpanResult;
335
- /**
336
- * Checks if a position is inside macro-generated code.
337
- *
338
- * # Arguments
339
- *
340
- * * `pos` - Byte offset in the expanded source
341
- *
342
- * # Returns
343
- *
344
- * `true` if the position is inside a generated region, `false` otherwise.
345
- */
346
- isInGenerated(pos: number): boolean;
227
+ /**
228
+ * Creates a new position mapper from source mapping data.
229
+ *
230
+ * # Arguments
231
+ *
232
+ * * `mapping` - The source mapping result from macro expansion
233
+ *
234
+ * # Returns
235
+ *
236
+ * A new `NativePositionMapper` ready for position translation.
237
+ */
238
+ constructor(mapping: SourceMappingResult)
239
+ /**
240
+ * Checks if this mapper has no mapping data.
241
+ *
242
+ * An empty mapper indicates no transformations occurred, so position
243
+ * translation is an identity operation.
244
+ *
245
+ * # Returns
246
+ *
247
+ * `true` if there are no segments and no generated regions.
248
+ */
249
+ isEmpty(): boolean
250
+ /**
251
+ * Converts a position in the original source to the corresponding position in expanded source.
252
+ *
253
+ * Uses binary search for O(log n) lookup performance.
254
+ *
255
+ * # Arguments
256
+ *
257
+ * * `pos` - Byte offset in the original source
258
+ *
259
+ * # Returns
260
+ *
261
+ * The corresponding byte offset in the expanded source. If the position falls
262
+ * in a gap between segments, returns the position unchanged. If after the last
263
+ * segment, extrapolates based on the delta.
264
+ *
265
+ * # Algorithm
266
+ *
267
+ * 1. Binary search to find the segment containing or after `pos`
268
+ * 2. If inside a segment, compute offset within segment and translate
269
+ * 3. If after all segments, extrapolate from the last segment
270
+ * 4. Otherwise, return position unchanged (gap or before first segment)
271
+ */
272
+ originalToExpanded(pos: number): number
273
+ /**
274
+ * Converts a position in the expanded source back to the original source position.
275
+ *
276
+ * Returns `None` if the position is inside macro-generated code that has no
277
+ * corresponding location in the original source.
278
+ *
279
+ * # Arguments
280
+ *
281
+ * * `pos` - Byte offset in the expanded source
282
+ *
283
+ * # Returns
284
+ *
285
+ * `Some(original_pos)` if the position maps to original code,
286
+ * `None` if the position is in macro-generated code.
287
+ */
288
+ expandedToOriginal(pos: number): number | null
289
+ /**
290
+ * Returns the name of the macro that generated code at the given position.
291
+ *
292
+ * # Arguments
293
+ *
294
+ * * `pos` - Byte offset in the expanded source
295
+ *
296
+ * # Returns
297
+ *
298
+ * `Some(macro_name)` if the position is inside generated code (e.g., "Debug"),
299
+ * `None` if the position is in original (non-generated) code.
300
+ */
301
+ generatedBy(pos: number): string | null
302
+ /**
303
+ * Maps a span (start + length) from expanded source to original source.
304
+ *
305
+ * # Arguments
306
+ *
307
+ * * `start` - Start byte offset in expanded source
308
+ * * `length` - Length of the span in bytes
309
+ *
310
+ * # Returns
311
+ *
312
+ * `Some(SpanResult)` with the mapped span in original source,
313
+ * `None` if either endpoint is in generated code.
314
+ */
315
+ mapSpanToOriginal(start: number, length: number): SpanResult | null
316
+ /**
317
+ * Maps a span (start + length) from original source to expanded source.
318
+ *
319
+ * This always succeeds since every original position has an expanded equivalent.
320
+ *
321
+ * # Arguments
322
+ *
323
+ * * `start` - Start byte offset in original source
324
+ * * `length` - Length of the span in bytes
325
+ *
326
+ * # Returns
327
+ *
328
+ * A `SpanResult` with the mapped span in expanded source.
329
+ */
330
+ mapSpanToExpanded(start: number, length: number): SpanResult
331
+ /**
332
+ * Checks if a position is inside macro-generated code.
333
+ *
334
+ * # Arguments
335
+ *
336
+ * * `pos` - Byte offset in the expanded source
337
+ *
338
+ * # Returns
339
+ *
340
+ * `true` if the position is inside a generated region, `false` otherwise.
341
+ */
342
+ isInGenerated(pos: number): boolean
347
343
  }
348
- export type NativePositionMapper = PositionMapper;
344
+ export type NativePositionMapper = PositionMapper
349
345
 
350
346
  /**
351
347
  * Returns debug information about all registered macro descriptors (debug API).
@@ -357,7 +353,7 @@ export type NativePositionMapper = PositionMapper;
357
353
  *
358
354
  * A vector of strings describing each registered macro descriptor.
359
355
  */
360
- export declare function __macroforgeDebugDescriptors(): Array<string>;
356
+ export declare function __macroforgeDebugDescriptors(): Array<string>
361
357
 
362
358
  /**
363
359
  * Returns all registered macro module names (debug API).
@@ -368,7 +364,7 @@ export declare function __macroforgeDebugDescriptors(): Array<string>;
368
364
  *
369
365
  * A vector of module names.
370
366
  */
371
- export declare function __macroforgeDebugGetModules(): Array<string>;
367
+ export declare function __macroforgeDebugGetModules(): Array<string>
372
368
 
373
369
  /**
374
370
  * Looks up a macro by module and name (debug API).
@@ -384,7 +380,7 @@ export declare function __macroforgeDebugGetModules(): Array<string>;
384
380
  *
385
381
  * A string describing whether the macro was found or not.
386
382
  */
387
- export declare function __macroforgeDebugLookup(module: string, name: string): string;
383
+ export declare function __macroforgeDebugLookup(module: string, name: string): string
388
384
 
389
385
  /**
390
386
  * Returns the names of all registered macros.
@@ -393,7 +389,7 @@ export declare function __macroforgeDebugLookup(module: string, name: string): s
393
389
  *
394
390
  * A vector of macro names (e.g., `["Debug", "Clone", "Serialize"]`).
395
391
  */
396
- export declare function __macroforgeGetMacroNames(): Array<string>;
392
+ export declare function __macroforgeGetMacroNames(): Array<string>
397
393
 
398
394
  /**
399
395
  * Returns the complete manifest of all registered macros and decorators.
@@ -413,7 +409,7 @@ export declare function __macroforgeGetMacroNames(): Array<string>;
413
409
  * // ["Debug", "Clone", "PartialEq", "Hash", "Serialize", "Deserialize", ...]
414
410
  * ```
415
411
  */
416
- export declare function __macroforgeGetManifest(): MacroManifest;
412
+ export declare function __macroforgeGetManifest(): MacroManifest
417
413
 
418
414
  /**
419
415
  * Checks if any macros are registered in this package.
@@ -424,7 +420,7 @@ export declare function __macroforgeGetManifest(): MacroManifest;
424
420
  *
425
421
  * `true` if at least one macro is registered, `false` otherwise.
426
422
  */
427
- export declare function __macroforgeIsMacroPackage(): boolean;
423
+ export declare function __macroforgeIsMacroPackage(): boolean
428
424
 
429
425
  /**
430
426
  * r" Run this macro with the given context.
@@ -452,7 +448,7 @@ export declare function __macroforgeIsMacroPackage(): boolean;
452
448
  * r" - The `TsStream` cannot be created from the context
453
449
  * r" - The result cannot be serialized to JSON
454
450
  */
455
- export declare function __macroforgeRunClone(contextJson: string): string;
451
+ export declare function __macroforgeRunClone(contextJson: string): string
456
452
 
457
453
  /**
458
454
  * r" Run this macro with the given context.
@@ -480,7 +476,7 @@ export declare function __macroforgeRunClone(contextJson: string): string;
480
476
  * r" - The `TsStream` cannot be created from the context
481
477
  * r" - The result cannot be serialized to JSON
482
478
  */
483
- export declare function __macroforgeRunDebug(contextJson: string): string;
479
+ export declare function __macroforgeRunDebug(contextJson: string): string
484
480
 
485
481
  /**
486
482
  * r" Run this macro with the given context.
@@ -508,7 +504,7 @@ export declare function __macroforgeRunDebug(contextJson: string): string;
508
504
  * r" - The `TsStream` cannot be created from the context
509
505
  * r" - The result cannot be serialized to JSON
510
506
  */
511
- export declare function __macroforgeRunDefault(contextJson: string): string;
507
+ export declare function __macroforgeRunDefault(contextJson: string): string
512
508
 
513
509
  /**
514
510
  * r" Run this macro with the given context.
@@ -536,7 +532,7 @@ export declare function __macroforgeRunDefault(contextJson: string): string;
536
532
  * r" - The `TsStream` cannot be created from the context
537
533
  * r" - The result cannot be serialized to JSON
538
534
  */
539
- export declare function __macroforgeRunDeserialize(contextJson: string): string;
535
+ export declare function __macroforgeRunDeserialize(contextJson: string): string
540
536
 
541
537
  /**
542
538
  * r" Run this macro with the given context.
@@ -564,7 +560,7 @@ export declare function __macroforgeRunDeserialize(contextJson: string): string;
564
560
  * r" - The `TsStream` cannot be created from the context
565
561
  * r" - The result cannot be serialized to JSON
566
562
  */
567
- export declare function __macroforgeRunHash(contextJson: string): string;
563
+ export declare function __macroforgeRunHash(contextJson: string): string
568
564
 
569
565
  /**
570
566
  * r" Run this macro with the given context.
@@ -592,7 +588,7 @@ export declare function __macroforgeRunHash(contextJson: string): string;
592
588
  * r" - The `TsStream` cannot be created from the context
593
589
  * r" - The result cannot be serialized to JSON
594
590
  */
595
- export declare function __macroforgeRunOrd(contextJson: string): string;
591
+ export declare function __macroforgeRunOrd(contextJson: string): string
596
592
 
597
593
  /**
598
594
  * r" Run this macro with the given context.
@@ -620,7 +616,7 @@ export declare function __macroforgeRunOrd(contextJson: string): string;
620
616
  * r" - The `TsStream` cannot be created from the context
621
617
  * r" - The result cannot be serialized to JSON
622
618
  */
623
- export declare function __macroforgeRunPartialEq(contextJson: string): string;
619
+ export declare function __macroforgeRunPartialEq(contextJson: string): string
624
620
 
625
621
  /**
626
622
  * r" Run this macro with the given context.
@@ -648,7 +644,7 @@ export declare function __macroforgeRunPartialEq(contextJson: string): string;
648
644
  * r" - The `TsStream` cannot be created from the context
649
645
  * r" - The result cannot be serialized to JSON
650
646
  */
651
- export declare function __macroforgeRunPartialOrd(contextJson: string): string;
647
+ export declare function __macroforgeRunPartialOrd(contextJson: string): string
652
648
 
653
649
  /**
654
650
  * r" Run this macro with the given context.
@@ -676,7 +672,7 @@ export declare function __macroforgeRunPartialOrd(contextJson: string): string;
676
672
  * r" - The `TsStream` cannot be created from the context
677
673
  * r" - The result cannot be serialized to JSON
678
674
  */
679
- export declare function __macroforgeRunSerialize(contextJson: string): string;
675
+ export declare function __macroforgeRunSerialize(contextJson: string): string
680
676
 
681
677
  /**
682
678
  * Checks if the given TypeScript code has valid syntax.
@@ -702,7 +698,7 @@ export declare function __macroforgeRunSerialize(contextJson: string): string;
702
698
  * }
703
699
  * ```
704
700
  */
705
- export declare function checkSyntax(code: string, filepath: string): SyntaxCheckResult;
701
+ export declare function checkSyntax(code: string, filepath: string): SyntaxCheckResult
706
702
 
707
703
  /**
708
704
  * Clears the configuration cache.
@@ -722,7 +718,7 @@ export declare function checkSyntax(code: string, filepath: string): SyntaxCheck
722
718
  * const result = loadConfig(configContent, configPath);
723
719
  * ```
724
720
  */
725
- export declare function clearConfigCache(): void;
721
+ export declare function clearConfigCache(): void
726
722
 
727
723
  /**
728
724
  * Entry for a registered decorator in the manifest.
@@ -731,14 +727,14 @@ export declare function clearConfigCache(): void;
731
727
  * that can be used with macros.
732
728
  */
733
729
  export interface DecoratorManifestEntry {
734
- /** The module this decorator belongs to (e.g., "serde"). */
735
- module: string;
736
- /** The exported name of the decorator (e.g., "skip", "rename"). */
737
- export: string;
738
- /** The decorator kind: "class", "property", "method", "accessor", "parameter". */
739
- kind: string;
740
- /** Documentation string for the decorator. */
741
- docs: string;
730
+ /** The module this decorator belongs to (e.g., "serde"). */
731
+ module: string
732
+ /** The exported name of the decorator (e.g., "skip", "rename"). */
733
+ export: string
734
+ /** The decorator kind: "class", "property", "method", "accessor", "parameter". */
735
+ kind: string
736
+ /** Documentation string for the decorator. */
737
+ docs: string
742
738
  }
743
739
 
744
740
  /**
@@ -760,7 +756,7 @@ export interface DecoratorManifestEntry {
760
756
  * }
761
757
  * ```
762
758
  */
763
- export declare function Derive(...features: any[]): ClassDecorator;
759
+ export declare function Derive(...features: any[]): ClassDecorator
764
760
 
765
761
  /**
766
762
  * Options for macro expansion.
@@ -768,49 +764,49 @@ export declare function Derive(...features: any[]): ClassDecorator;
768
764
  * Used by [`expand_sync`] to configure expansion behavior.
769
765
  */
770
766
  export interface ExpandOptions {
771
- /**
772
- * If `true`, preserves `@derive` decorators in the output.
773
- * If `false` (default), decorators are stripped after expansion.
774
- */
775
- keepDecorators?: boolean;
776
- /**
777
- * Additional decorator module names from external macros.
778
- *
779
- * These are used during decorator stripping to identify Macroforge-specific
780
- * decorators that should be removed from the output. Built-in decorator modules
781
- * (like "serde", "debug") are automatically included.
782
- *
783
- * External macro packages should export their decorator module names, which
784
- * plugins can collect and pass here.
785
- *
786
- * # Example
787
- *
788
- * ```javascript
789
- * expandSync(code, filepath, {
790
- * keepDecorators: false,
791
- * externalDecoratorModules: ["myMacro", "customValidator"]
792
- * });
793
- * ```
794
- */
795
- externalDecoratorModules?: Array<string>;
796
- /**
797
- * Path to a previously loaded config file.
798
- *
799
- * When provided, the expansion will use the cached configuration
800
- * (including foreign types) from this path. The config must have been
801
- * previously loaded via [`load_config`].
802
- *
803
- * # Example
804
- *
805
- * ```javascript
806
- * // First, load the config
807
- * const configResult = loadConfig(configContent, configPath);
808
- *
809
- * // Then use it during expansion
810
- * expandSync(code, filepath, { configPath });
811
- * ```
812
- */
813
- configPath?: string;
767
+ /**
768
+ * If `true`, preserves `@derive` decorators in the output.
769
+ * If `false` (default), decorators are stripped after expansion.
770
+ */
771
+ keepDecorators?: boolean
772
+ /**
773
+ * Additional decorator module names from external macros.
774
+ *
775
+ * These are used during decorator stripping to identify Macroforge-specific
776
+ * decorators that should be removed from the output. Built-in decorator modules
777
+ * (like "serde", "debug") are automatically included.
778
+ *
779
+ * External macro packages should export their decorator module names, which
780
+ * plugins can collect and pass here.
781
+ *
782
+ * # Example
783
+ *
784
+ * ```javascript
785
+ * expandSync(code, filepath, {
786
+ * keepDecorators: false,
787
+ * externalDecoratorModules: ["myMacro", "customValidator"]
788
+ * });
789
+ * ```
790
+ */
791
+ externalDecoratorModules?: Array<string>
792
+ /**
793
+ * Path to a previously loaded config file.
794
+ *
795
+ * When provided, the expansion will use the cached configuration
796
+ * (including foreign types) from this path. The config must have been
797
+ * previously loaded via [`load_config`].
798
+ *
799
+ * # Example
800
+ *
801
+ * ```javascript
802
+ * // First, load the config
803
+ * const configResult = loadConfig(configContent, configPath);
804
+ *
805
+ * // Then use it during expansion
806
+ * expandSync(code, filepath, { configPath });
807
+ * ```
808
+ */
809
+ configPath?: string
814
810
  }
815
811
 
816
812
  /**
@@ -840,16 +836,16 @@ export interface ExpandOptions {
840
836
  * ```
841
837
  */
842
838
  export interface ExpandResult {
843
- /** The expanded TypeScript code with all macros processed. */
844
- code: string;
845
- /** Optional TypeScript type declarations for generated methods. */
846
- types?: string;
847
- /** Optional JSON metadata about processed classes. */
848
- metadata?: string;
849
- /** Diagnostics (errors, warnings, info) from the expansion process. */
850
- diagnostics: Array<MacroDiagnostic>;
851
- /** Source mapping for position translation between original and expanded code. */
852
- sourceMapping?: SourceMappingResult;
839
+ /** The expanded TypeScript code with all macros processed. */
840
+ code: string
841
+ /** Optional TypeScript type declarations for generated methods. */
842
+ types?: string
843
+ /** Optional JSON metadata about processed classes. */
844
+ metadata?: string
845
+ /** Diagnostics (errors, warnings, info) from the expansion process. */
846
+ diagnostics: Array<MacroDiagnostic>
847
+ /** Source mapping for position translation between original and expanded code. */
848
+ sourceMapping?: SourceMappingResult
853
849
  }
854
850
 
855
851
  /**
@@ -889,11 +885,7 @@ export interface ExpandResult {
889
885
  * console.log(result.diagnostics); // Any warnings or errors
890
886
  * ```
891
887
  */
892
- export declare function expandSync(
893
- code: string,
894
- filepath: string,
895
- options?: ExpandOptions | undefined | null
896
- ): ExpandResult;
888
+ export declare function expandSync(code: string, filepath: string, options?: ExpandOptions | undefined | null): ExpandResult
897
889
 
898
890
  /**
899
891
  * A region in the expanded source that was generated by a macro.
@@ -908,12 +900,12 @@ export declare function expandSync(
908
900
  * with `source_macro = "Debug"`.
909
901
  */
910
902
  export interface GeneratedRegionResult {
911
- /** Byte offset where the generated region starts in the expanded source. */
912
- start: number;
913
- /** Byte offset where the generated region ends in the expanded source. */
914
- end: number;
915
- /** Name of the macro that generated this region (e.g., "Debug", "Clone"). */
916
- sourceMacro: string;
903
+ /** Byte offset where the generated region starts in the expanded source. */
904
+ start: number
905
+ /** Byte offset where the generated region ends in the expanded source. */
906
+ end: number
907
+ /** Name of the macro that generated this region (e.g., "Debug", "Clone"). */
908
+ sourceMacro: string
917
909
  }
918
910
 
919
911
  /**
@@ -922,10 +914,10 @@ export interface GeneratedRegionResult {
922
914
  * Used to track where decorators and macro-related imports come from.
923
915
  */
924
916
  export interface ImportSourceResult {
925
- /** Local identifier name in the import statement (e.g., `Derive` in `import { Derive }`). */
926
- local: string;
927
- /** Module specifier this identifier was imported from (e.g., `"macroforge-ts"`). */
928
- module: string;
917
+ /** Local identifier name in the import statement (e.g., `Derive` in `import { Derive }`). */
918
+ local: string
919
+ /** Module specifier this identifier was imported from (e.g., `"macroforge-ts"`). */
920
+ module: string
929
921
  }
930
922
 
931
923
  /**
@@ -935,16 +927,16 @@ export interface ImportSourceResult {
935
927
  * with language servers and IDEs.
936
928
  */
937
929
  export interface JsDiagnostic {
938
- /** Byte offset where the diagnostic starts. `None` for global diagnostics. */
939
- start?: number;
940
- /** Length of the diagnostic span in bytes. */
941
- length?: number;
942
- /** Human-readable diagnostic message. */
943
- message?: string;
944
- /** TypeScript diagnostic code (e.g., 2304 for "Cannot find name"). */
945
- code?: number;
946
- /** Diagnostic category: "error", "warning", "suggestion", "message". */
947
- category?: string;
930
+ /** Byte offset where the diagnostic starts. `None` for global diagnostics. */
931
+ start?: number
932
+ /** Length of the diagnostic span in bytes. */
933
+ length?: number
934
+ /** Human-readable diagnostic message. */
935
+ message?: string
936
+ /** TypeScript diagnostic code (e.g., 2304 for "Cannot find name"). */
937
+ code?: number
938
+ /** Diagnostic category: "error", "warning", "suggestion", "message". */
939
+ category?: string
948
940
  }
949
941
 
950
942
  /**
@@ -980,7 +972,7 @@ export interface JsDiagnostic {
980
972
  * const expanded = expandSync(code, filepath, { configPath });
981
973
  * ```
982
974
  */
983
- export declare function loadConfig(content: string, filepath: string): LoadConfigResult;
975
+ export declare function loadConfig(content: string, filepath: string): LoadConfigResult
984
976
 
985
977
  /**
986
978
  * Result of loading a macroforge configuration file.
@@ -988,14 +980,14 @@ export declare function loadConfig(content: string, filepath: string): LoadConfi
988
980
  * Returned by [`load_config`] after parsing a `macroforge.config.js/ts` file.
989
981
  */
990
982
  export interface LoadConfigResult {
991
- /** Whether to preserve `@derive` decorators in the output code. */
992
- keepDecorators: boolean;
993
- /** Whether to generate a convenience const for non-class types. */
994
- generateConvenienceConst: boolean;
995
- /** Whether the config has any foreign type handlers defined. */
996
- hasForeignTypes: boolean;
997
- /** Number of foreign types configured. */
998
- foreignTypeCount: number;
983
+ /** Whether to preserve `@derive` decorators in the output code. */
984
+ keepDecorators: boolean
985
+ /** Whether to generate a convenience const for non-class types. */
986
+ generateConvenienceConst: boolean
987
+ /** Whether the config has any foreign type handlers defined. */
988
+ hasForeignTypes: boolean
989
+ /** Number of foreign types configured. */
990
+ foreignTypeCount: number
999
991
  }
1000
992
 
1001
993
  /**
@@ -1025,23 +1017,23 @@ export interface LoadConfigResult {
1025
1017
  * ```
1026
1018
  */
1027
1019
  export interface MacroDiagnostic {
1028
- /**
1029
- * Severity level of the diagnostic.
1030
- * One of: "error", "warning", "info".
1031
- */
1032
- level: string;
1033
- /** Human-readable message describing the diagnostic. */
1034
- message: string;
1035
- /**
1036
- * Byte offset in the original source where the issue starts.
1037
- * `None` if the diagnostic is not associated with a specific location.
1038
- */
1039
- start?: number;
1040
- /**
1041
- * Byte offset in the original source where the issue ends.
1042
- * `None` if the diagnostic is not associated with a specific location.
1043
- */
1044
- end?: number;
1020
+ /**
1021
+ * Severity level of the diagnostic.
1022
+ * One of: "error", "warning", "info".
1023
+ */
1024
+ level: string
1025
+ /** Human-readable message describing the diagnostic. */
1026
+ message: string
1027
+ /**
1028
+ * Byte offset in the original source where the issue starts.
1029
+ * `None` if the diagnostic is not associated with a specific location.
1030
+ */
1031
+ start?: number
1032
+ /**
1033
+ * Byte offset in the original source where the issue ends.
1034
+ * `None` if the diagnostic is not associated with a specific location.
1035
+ */
1036
+ end?: number
1045
1037
  }
1046
1038
 
1047
1039
  /**
@@ -1053,12 +1045,12 @@ export interface MacroDiagnostic {
1053
1045
  * - Tooling integration
1054
1046
  */
1055
1047
  export interface MacroManifest {
1056
- /** ABI version for compatibility checking. */
1057
- version: number;
1058
- /** All registered macros (derive, attribute, function). */
1059
- macros: Array<MacroManifestEntry>;
1060
- /** All registered field/class decorators. */
1061
- decorators: Array<DecoratorManifestEntry>;
1048
+ /** ABI version for compatibility checking. */
1049
+ version: number
1050
+ /** All registered macros (derive, attribute, function). */
1051
+ macros: Array<MacroManifestEntry>
1052
+ /** All registered field/class decorators. */
1053
+ decorators: Array<DecoratorManifestEntry>
1062
1054
  }
1063
1055
 
1064
1056
  /**
@@ -1068,14 +1060,14 @@ export interface MacroManifest {
1068
1060
  * such as IDE extensions and documentation generators.
1069
1061
  */
1070
1062
  export interface MacroManifestEntry {
1071
- /** The macro name (e.g., "Debug", "Clone", "Serialize"). */
1072
- name: string;
1073
- /** The macro kind: "derive", "attribute", or "function". */
1074
- kind: string;
1075
- /** Human-readable description of what the macro does. */
1076
- description: string;
1077
- /** The package that provides this macro (e.g., "macroforge-ts"). */
1078
- package: string;
1063
+ /** The macro name (e.g., "Debug", "Clone", "Serialize"). */
1064
+ name: string
1065
+ /** The macro kind: "derive", "attribute", or "function". */
1066
+ kind: string
1067
+ /** Human-readable description of what the macro does. */
1068
+ description: string
1069
+ /** The package that provides this macro (e.g., "macroforge-ts"). */
1070
+ package: string
1079
1071
  }
1080
1072
 
1081
1073
  /**
@@ -1092,14 +1084,14 @@ export interface MacroManifestEntry {
1092
1084
  * - Segments are non-overlapping and sorted by position
1093
1085
  */
1094
1086
  export interface MappingSegmentResult {
1095
- /** Byte offset where this segment starts in the original source. */
1096
- originalStart: number;
1097
- /** Byte offset where this segment ends in the original source. */
1098
- originalEnd: number;
1099
- /** Byte offset where this segment starts in the expanded source. */
1100
- expandedStart: number;
1101
- /** Byte offset where this segment ends in the expanded source. */
1102
- expandedEnd: number;
1087
+ /** Byte offset where this segment starts in the original source. */
1088
+ originalStart: number
1089
+ /** Byte offset where this segment ends in the original source. */
1090
+ originalEnd: number
1091
+ /** Byte offset where this segment starts in the expanded source. */
1092
+ expandedStart: number
1093
+ /** Byte offset where this segment ends in the expanded source. */
1094
+ expandedEnd: number
1103
1095
  }
1104
1096
 
1105
1097
  /**
@@ -1133,10 +1125,7 @@ export interface MappingSegmentResult {
1133
1125
  * // ]
1134
1126
  * ```
1135
1127
  */
1136
- export declare function parseImportSources(
1137
- code: string,
1138
- filepath: string
1139
- ): Array<ImportSourceResult>;
1128
+ export declare function parseImportSources(code: string, filepath: string): Array<ImportSourceResult>
1140
1129
 
1141
1130
  /**
1142
1131
  * Options for processing a file through the macro system.
@@ -1145,26 +1134,26 @@ export declare function parseImportSources(
1145
1134
  * and caching.
1146
1135
  */
1147
1136
  export interface ProcessFileOptions {
1148
- /**
1149
- * If `true`, preserves `@derive` decorators in the output.
1150
- * If `false` (default), decorators are stripped after expansion.
1151
- */
1152
- keepDecorators?: boolean;
1153
- /**
1154
- * Version string for cache invalidation.
1155
- * When provided, cached results are only reused if versions match.
1156
- */
1157
- version?: string;
1158
- /**
1159
- * Additional decorator module names from external macros.
1160
- * See [`ExpandOptions::external_decorator_modules`] for details.
1161
- */
1162
- externalDecoratorModules?: Array<string>;
1163
- /**
1164
- * Path to a previously loaded config file (for foreign types lookup).
1165
- * See [`ExpandOptions::config_path`] for details.
1166
- */
1167
- configPath?: string;
1137
+ /**
1138
+ * If `true`, preserves `@derive` decorators in the output.
1139
+ * If `false` (default), decorators are stripped after expansion.
1140
+ */
1141
+ keepDecorators?: boolean
1142
+ /**
1143
+ * Version string for cache invalidation.
1144
+ * When provided, cached results are only reused if versions match.
1145
+ */
1146
+ version?: string
1147
+ /**
1148
+ * Additional decorator module names from external macros.
1149
+ * See [`ExpandOptions::external_decorator_modules`] for details.
1150
+ */
1151
+ externalDecoratorModules?: Array<string>
1152
+ /**
1153
+ * Path to a previously loaded config file (for foreign types lookup).
1154
+ * See [`ExpandOptions::config_path`] for details.
1155
+ */
1156
+ configPath?: string
1168
1157
  }
1169
1158
 
1170
1159
  /**
@@ -1181,16 +1170,16 @@ export interface ProcessFileOptions {
1181
1170
  * - Mapping IDE diagnostics from expanded code back to original source
1182
1171
  */
1183
1172
  export interface SourceMappingResult {
1184
- /**
1185
- * Segments mapping preserved regions between original and expanded source.
1186
- * Sorted by position for efficient binary search lookups.
1187
- */
1188
- segments: Array<MappingSegmentResult>;
1189
- /**
1190
- * Regions in the expanded source that were generated by macros.
1191
- * Used to identify synthetic code with no original source location.
1192
- */
1193
- generatedRegions: Array<GeneratedRegionResult>;
1173
+ /**
1174
+ * Segments mapping preserved regions between original and expanded source.
1175
+ * Sorted by position for efficient binary search lookups.
1176
+ */
1177
+ segments: Array<MappingSegmentResult>
1178
+ /**
1179
+ * Regions in the expanded source that were generated by macros.
1180
+ * Used to identify synthetic code with no original source location.
1181
+ */
1182
+ generatedRegions: Array<GeneratedRegionResult>
1194
1183
  }
1195
1184
 
1196
1185
  /**
@@ -1199,10 +1188,10 @@ export interface SourceMappingResult {
1199
1188
  * Used for mapping diagnostics and other positional information.
1200
1189
  */
1201
1190
  export interface SpanResult {
1202
- /** Byte offset where the span starts. */
1203
- start: number;
1204
- /** Length of the span in bytes. */
1205
- length: number;
1191
+ /** Byte offset where the span starts. */
1192
+ start: number
1193
+ /** Length of the span in bytes. */
1194
+ length: number
1206
1195
  }
1207
1196
 
1208
1197
  /**
@@ -1211,10 +1200,10 @@ export interface SpanResult {
1211
1200
  * Returned by [`check_syntax`] to indicate whether code parses successfully.
1212
1201
  */
1213
1202
  export interface SyntaxCheckResult {
1214
- /** `true` if the code parsed without errors, `false` otherwise. */
1215
- ok: boolean;
1216
- /** Error message if parsing failed, `None` if successful. */
1217
- error?: string;
1203
+ /** `true` if the code parsed without errors, `false` otherwise. */
1204
+ ok: boolean
1205
+ /** Error message if parsing failed, `None` if successful. */
1206
+ error?: string
1218
1207
  }
1219
1208
 
1220
1209
  /**
@@ -1231,23 +1220,23 @@ export interface SyntaxCheckResult {
1231
1220
  * * `metadata` - Optional JSON metadata about processed classes
1232
1221
  */
1233
1222
  export interface TransformResult {
1234
- /** The transformed TypeScript/JavaScript code with all macros expanded. */
1235
- code: string;
1236
- /**
1237
- * Source map for mapping transformed positions back to original.
1238
- * Currently always `None` - source mapping is handled separately via `SourceMappingResult`.
1239
- */
1240
- map?: string;
1241
- /**
1242
- * TypeScript type declarations (`.d.ts` content) for generated methods.
1243
- * Used by IDEs to provide type information for macro-generated code.
1244
- */
1245
- types?: string;
1246
- /**
1247
- * JSON-serialized metadata about processed classes.
1248
- * Contains information about which classes were processed and what was generated.
1249
- */
1250
- metadata?: string;
1223
+ /** The transformed TypeScript/JavaScript code with all macros expanded. */
1224
+ code: string
1225
+ /**
1226
+ * Source map for mapping transformed positions back to original.
1227
+ * Currently always `None` - source mapping is handled separately via `SourceMappingResult`.
1228
+ */
1229
+ map?: string
1230
+ /**
1231
+ * TypeScript type declarations (`.d.ts` content) for generated methods.
1232
+ * Used by IDEs to provide type information for macro-generated code.
1233
+ */
1234
+ types?: string
1235
+ /**
1236
+ * JSON-serialized metadata about processed classes.
1237
+ * Contains information about which classes were processed and what was generated.
1238
+ */
1239
+ metadata?: string
1251
1240
  }
1252
1241
 
1253
1242
  /**
@@ -1277,4 +1266,4 @@ export interface TransformResult {
1277
1266
  *
1278
1267
  * Uses a 32MB thread stack to prevent stack overflow during deep AST recursion.
1279
1268
  */
1280
- export declare function transformSync(code: string, filepath: string): TransformResult;
1269
+ export declare function transformSync(code: string, filepath: string): TransformResult