@macroforge/mcp-server 0.1.40 → 0.1.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/LICENSE +22 -0
  2. package/docs/BOOK.md +165 -0
  3. package/docs/api/api-overview.md +65 -46
  4. package/docs/api/expand-sync.md +88 -53
  5. package/docs/api/native-plugin.md +121 -71
  6. package/docs/api/position-mapper.md +114 -54
  7. package/docs/api/transform-sync.md +85 -59
  8. package/docs/builtin-macros/clone.md +0 -20
  9. package/docs/builtin-macros/debug.md +0 -23
  10. package/docs/builtin-macros/default.md +1 -40
  11. package/docs/builtin-macros/deserialize/example.md +8 -1416
  12. package/docs/builtin-macros/deserialize.md +8 -1416
  13. package/docs/builtin-macros/hash.md +0 -42
  14. package/docs/builtin-macros/macros-overview/detailed-documentation.md +13 -0
  15. package/docs/builtin-macros/macros-overview/enum-support.md +30 -0
  16. package/docs/builtin-macros/macros-overview/interface-support.md +28 -0
  17. package/docs/builtin-macros/macros-overview/overview.md +36 -0
  18. package/docs/builtin-macros/macros-overview/type-alias-support.md +62 -0
  19. package/docs/builtin-macros/macros-overview.md +171 -130
  20. package/docs/builtin-macros/ord.md +0 -25
  21. package/docs/builtin-macros/partial-eq.md +0 -84
  22. package/docs/builtin-macros/partial-ord.md +11 -43
  23. package/docs/builtin-macros/serialize.md +2 -62
  24. package/docs/concepts/architecture.md +125 -48
  25. package/docs/concepts/derive-system/built-in-vs-custom-macros.md +13 -0
  26. package/docs/concepts/derive-system/overview.md +200 -0
  27. package/docs/concepts/derive-system.md +171 -97
  28. package/docs/concepts/how-macros-work.md +89 -37
  29. package/docs/custom-macros/custom-overview.md +79 -57
  30. package/docs/custom-macros/rust-setup.md +138 -99
  31. package/docs/custom-macros/ts-macro-derive/accessing-field-data.md +40 -31
  32. package/docs/custom-macros/ts-macro-derive/adding-imports.md +14 -11
  33. package/docs/custom-macros/ts-macro-derive/attribute-options.md +20 -25
  34. package/docs/custom-macros/ts-macro-derive/complete-example.md +40 -38
  35. package/docs/custom-macros/ts-macro-derive/deriveinput-structure.md +49 -47
  36. package/docs/custom-macros/ts-macro-derive/function-signature.md +12 -0
  37. package/docs/custom-macros/ts-macro-derive/overview.md +9 -7
  38. package/docs/custom-macros/ts-macro-derive/parsing-input.md +20 -18
  39. package/docs/custom-macros/ts-macro-derive/returning-errors.md +15 -13
  40. package/docs/custom-macros/ts-macro-derive.md +322 -228
  41. package/docs/custom-macros/ts-quote/backtick-template-literals.md +19 -7
  42. package/docs/custom-macros/ts-quote/comments-and.md +56 -22
  43. package/docs/custom-macros/ts-quote/complete-example-json-derive-macro.md +89 -98
  44. package/docs/custom-macros/ts-quote/conditionals-ifif.md +35 -29
  45. package/docs/custom-macros/ts-quote/identifier-concatenation-content.md +30 -22
  46. package/docs/custom-macros/ts-quote/iteration-for.md +48 -40
  47. package/docs/custom-macros/ts-quote/local-constants-let.md +23 -21
  48. package/docs/custom-macros/ts-quote/match-expressions-match.md +46 -38
  49. package/docs/custom-macros/ts-quote/overview.md +5 -10
  50. package/docs/custom-macros/ts-quote/pattern-matching-iflet.md +39 -0
  51. package/docs/custom-macros/ts-quote/quick-reference.md +50 -129
  52. package/docs/custom-macros/ts-quote/side-effects-do.md +13 -78
  53. package/docs/custom-macros/ts-quote/string-interpolation-textexpr.md +36 -0
  54. package/docs/custom-macros/ts-quote/tsstream-injection-typescript.md +43 -35
  55. package/docs/custom-macros/ts-quote/while-loops-while.md +31 -23
  56. package/docs/custom-macros/ts-quote.md +799 -519
  57. package/docs/getting-started/first-macro.md +61 -32
  58. package/docs/getting-started/installation.md +109 -66
  59. package/docs/integration/cli.md +212 -103
  60. package/docs/integration/configuration.md +114 -71
  61. package/docs/integration/integration-overview.md +54 -17
  62. package/docs/integration/mcp-server.md +83 -42
  63. package/docs/integration/svelte-preprocessor.md +183 -126
  64. package/docs/integration/typescript-plugin.md +101 -54
  65. package/docs/integration/vite-plugin.md +116 -76
  66. package/docs/language-servers/ls-overview.md +37 -21
  67. package/docs/language-servers/svelte.md +69 -39
  68. package/docs/language-servers/zed.md +81 -45
  69. package/docs/roadmap/roadmap.md +75 -53
  70. package/docs/sections.json +333 -44
  71. package/package.json +27 -28
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 rymskip
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
package/docs/BOOK.md ADDED
@@ -0,0 +1,165 @@
1
+ # Macroforge Documentation
2
+
3
+ *TypeScript Macros - Rust-Powered Code Generation*
4
+
5
+ ---
6
+
7
+ ## Table of Contents
8
+
9
+ ### Getting Started
10
+ - [Installation](#installation)
11
+ - [First Macro](#first-macro)
12
+
13
+ ### Core Concepts
14
+ - [How Macros Work](#how-macros-work)
15
+ - [The Derive System](#the-derive-system)
16
+ - [Architecture](#architecture)
17
+
18
+ ### Built-in Macros
19
+ - [Overview](#overview)
20
+ - [Debug](#debug)
21
+ - [Clone](#clone)
22
+ - [Default](#default)
23
+ - [Hash](#hash)
24
+ - [Ord](#ord)
25
+ - [PartialEq](#partialeq)
26
+ - [PartialOrd](#partialord)
27
+ - [Serialize](#serialize)
28
+ - [Deserialize](#deserialize)
29
+
30
+ ### Custom Macros
31
+ - [Overview](#overview)
32
+ - [Rust Setup](#rust-setup)
33
+ - [ts_macro_derive](#ts-macro-derive)
34
+ - [Template Syntax](#template-syntax)
35
+
36
+ ### Integration
37
+ - [Overview](#overview)
38
+ - [CLI](#cli)
39
+ - [TypeScript Plugin](#typescript-plugin)
40
+ - [Vite Plugin](#vite-plugin)
41
+ - [Configuration](#configuration)
42
+
43
+ ### Language Servers
44
+ - [Overview](#overview)
45
+ - [Svelte](#svelte)
46
+ - [Zed Extensions](#zed-extensions)
47
+
48
+ ### API Reference
49
+ - [Overview](#overview)
50
+ - [expandSync()](#expandsync)
51
+ - [transformSync()](#transformsync)
52
+ - [NativePlugin](#nativeplugin)
53
+ - [PositionMapper](#positionmapper)
54
+
55
+ ---
56
+
57
+ # Getting Started
58
+
59
+
60
+ ---
61
+
62
+
63
+ ---
64
+
65
+ # Core Concepts
66
+
67
+
68
+ ---
69
+
70
+
71
+ ---
72
+
73
+
74
+ ---
75
+
76
+ # Built-in Macros
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
+ # Custom Macros
109
+
110
+
111
+ ---
112
+
113
+
114
+ ---
115
+
116
+
117
+ ---
118
+
119
+
120
+ ---
121
+
122
+ # Integration
123
+
124
+
125
+ ---
126
+
127
+
128
+ ---
129
+
130
+
131
+ ---
132
+
133
+
134
+ ---
135
+
136
+
137
+ ---
138
+
139
+ # Language Servers
140
+
141
+
142
+ ---
143
+
144
+
145
+ ---
146
+
147
+
148
+ ---
149
+
150
+ # API Reference
151
+
152
+
153
+ ---
154
+
155
+
156
+ ---
157
+
158
+
159
+ ---
160
+
161
+
162
+ ---
163
+
164
+
165
+ ---
@@ -1,53 +1,72 @@
1
1
  # API Reference
2
- <span class="stats svelte-1c8t0id">52 exported items *Macroforge provides a programmatic API for expanding macros in TypeScript code.*
3
- ## Overview
4
- ```
5
- import &#123;
6
- expandSync,
7
- transformSync,
8
- checkSyntax,
9
- parseImportSources,
10
- NativePlugin,
11
- PositionMapper
12
- &#125; from "macroforge";
13
- ``` ## Core Functions
14
- | Function | Description |
15
- | --- | --- |
16
- | [`expandSync()`](../docs/api/expand-sync) | Expand macros synchronously |
2
+
3
+ macroforge v0.1.43 33 exported items
4
+
5
+ Macroforge provides a programmatic API for expanding macros in TypeScript code.
6
+
7
+ ## Overview
8
+
9
+ TypeScript
10
+
11
+ ```
12
+ import {
13
+   expandSync,
14
+   transformSync,
15
+   checkSyntax,
16
+   parseImportSources,
17
+   NativePlugin,
18
+   PositionMapper
19
+ } from "macroforge";
20
+ ```
21
+
22
+ ## Core Functions
23
+
24
+ | Function | Description |
25
+ | ----------------------------------------------- | --------------------------------------- |
26
+ | [`expandSync()`](../docs/api/expand-sync) | Expand macros synchronously |
17
27
  | [`transformSync()`](../docs/api/transform-sync) | Transform code with additional metadata |
18
- | `checkSyntax()` | Validate TypeScript syntax |
19
- | `parseImportSources()` | Extract import information |
20
- ## Classes
21
- | Class | Description |
22
- | --- | --- |
23
- | [`NativePlugin`](../docs/api/native-plugin) | Stateful plugin with caching |
28
+ | `checkSyntax()` | Validate TypeScript syntax |
29
+ | `parseImportSources()` | Extract import information |
30
+
31
+ ## Classes
32
+
33
+ | Class | Description |
34
+ | ----------------------------------------------- | ------------------------------------------------- |
35
+ | [`NativePlugin`](../docs/api/native-plugin) | Stateful plugin with caching |
24
36
  | [`PositionMapper`](../docs/api/position-mapper) | Maps positions between original and expanded code |
25
- ## Quick Example
26
- ```
27
- import &#123; expandSync &#125; from "macroforge";
28
-
29
- const sourceCode = \`
30
- /** @derive(Debug) */
31
- class User &#123;
32
- name: string;
33
- constructor(name: string) &#123;
34
- this.name = name;
35
- &#125;
36
- &#125;
37
+
38
+ ## Quick Example
39
+
40
+ TypeScript
41
+
42
+ ```
43
+ import { expandSync } from "macroforge";
44
+
45
+ const sourceCode = \`
46
+ /** @derive(Debug) */
47
+ class User {
48
+   name: string;
49
+   constructor(name: string) {
50
+     this.name = name;
51
+   }
52
+ }
37
53
  \`;
38
54
 
39
- const result = expandSync(sourceCode, "user.ts", &#123;
40
- keepDecorators: false
41
- &#125;);
55
+ const result = expandSync(sourceCode, "user.ts", {
56
+   keepDecorators: false
57
+ });
42
58
 
43
59
  console.log(result.code);
44
- // Output: class with toString() method generated
45
-
46
- if (result.diagnostics.length > 0) &#123;
47
- console.error("Errors:", result.diagnostics);
48
- &#125;
49
- ``` ## Detailed Reference
50
- - [`expandSync()`](../docs/api/expand-sync) - Full options and return types
51
- - [`transformSync()`](../docs/api/transform-sync) - Transform with source maps
52
- - [`NativePlugin`](../docs/api/native-plugin) - Caching for language servers
53
- - [`PositionMapper`](../docs/api/position-mapper) - Position mapping utilities
60
+ // Output: class with toString() method generated
61
+
62
+ if (result.diagnostics.length > 0) {
63
+   console.error("Errors:", result.diagnostics);
64
+ }
65
+ ```
66
+
67
+ ## Detailed Reference
68
+
69
+ * [`expandSync()`](../docs/api/expand-sync) - Full options and return types
70
+ * [`transformSync()`](../docs/api/transform-sync) - Transform with source maps
71
+ * [`NativePlugin`](../docs/api/native-plugin) - Caching for language servers
72
+ * [`PositionMapper`](../docs/api/position-mapper) - Position mapping utilities
@@ -1,54 +1,83 @@
1
1
  # expandSync()
2
- *Synchronously expands macros in TypeScript code. This is the standalone macro expansion function that doesn't use caching. For cached expansion, use [`NativePlugin::process_file`] instead.*
3
- ## Signature
4
- ```
5
- function expandSync(
6
- code: string,
7
- filepath: string,
8
- options?: ExpandOptions
9
- ): ExpandResult
10
- ``` ## Parameters
11
- | Parameter | Type | Description |
12
- | --- | --- | --- |
13
- | `code` | `string` | TypeScript source code to transform |
14
- | `filepath` | `string` | File path (used for error reporting) |
15
- | `options` | `ExpandOptions` | Optional configuration |
16
- ## ExpandOptions
17
- ```
18
- interface ExpandOptions &#123;
19
- // Keep @derive decorators in output (default: false)
20
- keepDecorators?: boolean;
21
- &#125;
22
- ``` ## ExpandResult
23
- ```
24
- interface ExpandResult &#123;
25
- // Transformed TypeScript code
26
- code: string;
27
-
28
- // Generated type declarations (.d.ts content)
29
- types?: string;
30
-
31
- // Macro expansion metadata (JSON string)
32
- metadata?: string;
33
-
34
- // Warnings and errors from macro expansion
35
- diagnostics: MacroDiagnostic[];
36
-
37
- // Position mapping data for source maps
38
- sourceMapping?: SourceMappingResult;
39
- &#125;
40
- ``` ## MacroDiagnostic
41
- ```
42
- interface MacroDiagnostic &#123;
43
- message: string;
44
- severity: "error" | "warning" | "info";
45
- span: &#123;
46
- start: number;
47
- end: number;
48
- &#125;;
49
- &#125;
50
- ``` ## Example
51
- ```
2
+
3
+ macroforge v0.1.43
4
+
5
+ Synchronously expands macros in TypeScript code. This is the standalone macro expansion function that doesn't use caching. For cached expansion, use \[\`NativePlugin::process\_file\`\] instead.
6
+
7
+ ## Signature
8
+
9
+ TypeScript
10
+
11
+ ```
12
+ function expandSync(
13
+   codestring,
14
+   filepathstring,
15
+   options?: ExpandOptions
16
+ ): ExpandResult
17
+ ```
18
+
19
+ ## Parameters
20
+
21
+ | Parameter | Type | Description |
22
+ | ---------- | --------------- | ------------------------------------ |
23
+ | `code` | `string` | TypeScript source code to transform |
24
+ | `filepath` | `string` | File path (used for error reporting) |
25
+ | `options` | `ExpandOptions` | Optional configuration |
26
+
27
+ ## ExpandOptions
28
+
29
+ TypeScript
30
+
31
+ ```
32
+ interface ExpandOptions {
33
+   // Keep @derive decorators in output (default: false)
34
+   keepDecorators?: boolean;
35
+ }
36
+ ```
37
+
38
+ ## ExpandResult
39
+
40
+ TypeScript
41
+
42
+ ```
43
+ interface ExpandResult {
44
+   // Transformed TypeScript code
45
+   code: string;
46
+
47
+   // Generated type declarations (.d.ts content)
48
+   types?: string;
49
+
50
+   // Macro expansion metadata (JSON string)
51
+   metadata?: string;
52
+
53
+   // Warnings and errors from macro expansion
54
+   diagnostics: MacroDiagnostic[];
55
+
56
+   // Position mapping data for source maps
57
+   sourceMapping?: SourceMappingResult;
58
+ }
59
+ ```
60
+
61
+ ## MacroDiagnostic
62
+
63
+ TypeScript
64
+
65
+ ```
66
+ interface MacroDiagnostic {
67
+   message: string;
68
+   severity: "error" | "warning" | "info";
69
+   span: {
70
+     start: number;
71
+     end: number;
72
+   };
73
+ }
74
+ ```
75
+
76
+ ## Example
77
+
78
+ TypeScript
79
+
80
+ ```
52
81
  import { expandSync } from "macroforge";
53
82
 
54
83
  const sourceCode = `
@@ -79,9 +108,15 @@ if (result.diagnostics.length > 0) {
79
108
  console.log(`[${diag.severity}] ${diag.message}`);
80
109
  }
81
110
  }
82
- ``` ## Error Handling
83
- Syntax errors and macro errors are returned in the `diagnostics` array, not thrown as exceptions:
84
- ```
111
+ ```
112
+
113
+ ## Error Handling
114
+
115
+ Syntax errors and macro errors are returned in the `diagnostics` array, not thrown as exceptions:
116
+
117
+ TypeScript
118
+
119
+ ```
85
120
  const result = expandSync(invalidCode, "file.ts");
86
121
 
87
122
  for (const diag of result.diagnostics) {
@@ -1,74 +1,124 @@
1
1
  # NativePlugin
2
- *The main plugin class for macro expansion with caching support. `NativePlugin` is designed to be instantiated once and reused across multiple file processing operations. It maintains a cache of expansion results keyed by filepath and version, enabling efficient incremental processing.*
3
- ## Constructor
4
- ```
5
- const plugin = new NativePlugin();
6
- ``` ## Methods
7
- ### processFile()
8
- Process a file with version-based caching:
9
- ```
2
+
3
+ macroforge v0.1.43
4
+
5
+ The main plugin class for macro expansion with caching support. \`NativePlugin\` is designed to be instantiated once and reused across multiple file processing operations. It maintains a cache of expansion results keyed by filepath and version, enabling efficient incremental processing.
6
+
7
+ ## Constructor
8
+
9
+ TypeScript
10
+
11
+ ```
12
+ const plugin = new NativePlugin();
13
+ ```
14
+
15
+ ## Methods
16
+
17
+ ### processFile()
18
+
19
+ Process a file with version-based caching:
20
+
21
+ TypeScript
22
+
23
+ ```
10
24
  processFile(
11
- filepath: string,
12
- code: string,
13
- options?: ProcessFileOptions
14
- ): ExpandResult
15
- ``` ```
16
- interface ProcessFileOptions &#123;
17
- // Cache key - if unchanged, returns cached result
18
- version?: string;
19
- &#125;
20
- ``` ### getMapper()
21
- Get the position mapper for a previously processed file:
22
- ```
23
- getMapper(filepath: string): NativeMapper | null
24
- ``` ### mapDiagnostics()
25
- Map diagnostics from expanded positions to original positions:
26
- ```
25
+   filepath: string,
26
+   code: string,
27
+   options?: ProcessFileOptions
28
+ ): ExpandResult
29
+ ```
30
+
31
+ TypeScript
32
+
33
+ ```
34
+ interface ProcessFileOptions {
35
+   // Cache key - if unchanged, returns cached result
36
+   version?: string;
37
+ }
38
+ ```
39
+
40
+ ### getMapper()
41
+
42
+ Get the position mapper for a previously processed file:
43
+
44
+ TypeScript
45
+
46
+ ```
47
+ getMapper(filepath: string): NativeMapper | null
48
+ ```
49
+
50
+ ### mapDiagnostics()
51
+
52
+ Map diagnostics from expanded positions to original positions:
53
+
54
+ TypeScript
55
+
56
+ ```
27
57
  mapDiagnostics(
28
- filepath: string,
29
- diagnostics: JsDiagnostic[]
30
- ): JsDiagnostic[]
31
- ``` ### log() / setLogFile()
32
- Logging utilities for debugging:
33
- ```
34
- log(message: string): void
35
- setLogFile(path: string): void
36
- ``` ## Caching Behavior
37
- The plugin caches expansion results by file path and version:
38
- ```
39
- const plugin = new NativePlugin();
40
-
41
- // First call - performs expansion
42
- const result1 = plugin.processFile("user.ts", code, &#123; version: "1" &#125;);
43
-
44
- // Same version - returns cached result instantly
45
- const result2 = plugin.processFile("user.ts", code, &#123; version: "1" &#125;);
46
-
47
- // Different version - re-expands
48
- const result3 = plugin.processFile("user.ts", newCode, &#123; version: "2" &#125;);
49
- ``` ## Example: Language Server Integration
50
- ```
51
- import &#123; NativePlugin &#125; from "macroforge";
52
-
53
- class MacroforgeLanguageService &#123;
54
- private plugin = new NativePlugin();
55
-
56
- processDocument(uri: string, content: string, version: number) &#123;
57
- // Process with version-based caching
58
- const result = this.plugin.processFile(uri, content, &#123;
59
- version: String(version)
60
- &#125;);
61
-
62
- // Get mapper for position translation
63
- const mapper = this.plugin.getMapper(uri);
64
-
65
- return &#123; result, mapper &#125;;
66
- &#125;
67
-
68
- getSemanticDiagnostics(uri: string, diagnostics: Diagnostic[]) &#123;
69
- // Map positions from expanded to original
70
- return this.plugin.mapDiagnostics(uri, diagnostics);
71
- &#125;
72
- &#125;
73
- ``` ## Thread Safety
74
- The `NativePlugin` class is thread-safe and can be used from multiple async contexts. Each file is processed in an isolated thread with its own stack space.
58
+   filepath: string,
59
+   diagnostics: JsDiagnostic[]
60
+ ): JsDiagnostic[]
61
+ ```
62
+
63
+ ### log() / setLogFile()
64
+
65
+ Logging utilities for debugging:
66
+
67
+ TypeScript
68
+
69
+ ```
70
+ log(message: string): void
71
+ setLogFile(path: string): void
72
+ ```
73
+
74
+ ## Caching Behavior
75
+
76
+ The plugin caches expansion results by file path and version:
77
+
78
+ TypeScript
79
+
80
+ ```
81
+ const plugin = new NativePlugin();
82
+
83
+ // First call - performs expansion
84
+ const result1 = plugin.processFile("user.ts", code, { version: "1" });
85
+
86
+ // Same version - returns cached result instantly
87
+ const result2 = plugin.processFile("user.ts", code, { version: "1" });
88
+
89
+ // Different version - re-expands
90
+ const result3 = plugin.processFile("user.ts", newCode, { version: "2" });
91
+ ```
92
+
93
+ ## Example: Language Server Integration
94
+
95
+ TypeScript
96
+
97
+ ```
98
+ import { NativePlugin } from "macroforge";
99
+
100
+ class MacroforgeLanguageService {
101
+   private plugin = new NativePlugin();
102
+
103
+   processDocument(uri: string, content: string, version: number) {
104
+     // Process with version-based caching
105
+     const result = this.plugin.processFile(uri, content, {
106
+       version: String(version)
107
+     });
108
+
109
+     // Get mapper for position translation
110
+     const mapper = this.plugin.getMapper(uri);
111
+
112
+     return { result, mapper };
113
+   }
114
+
115
+   getSemanticDiagnostics(uri: string, diagnostics: Diagnostic[]) {
116
+     // Map positions from expanded to original
117
+     return this.plugin.mapDiagnostics(uri, diagnostics);
118
+   }
119
+ }
120
+ ```
121
+
122
+ ## Thread Safety
123
+
124
+ The `NativePlugin` class is thread-safe and can be used from multiple async contexts. Each file is processed in an isolated thread with its own stack space.