@macroforge/typescript-plugin 0.1.33 → 0.1.35
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/README.md +74 -11
- package/dist/index.d.ts +107 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +727 -46
- package/dist/source-map.d.ts +75 -0
- package/dist/source-map.d.ts.map +1 -1
- package/dist/source-map.js +9 -0
- package/package.json +2 -2
package/dist/source-map.d.ts
CHANGED
|
@@ -1,16 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Source mapping type definitions for the TypeScript plugin.
|
|
3
|
+
*
|
|
4
|
+
* This module re-exports and extends position mapping types from the core
|
|
5
|
+
* macroforge package. These types are used to translate positions between
|
|
6
|
+
* original source code and macro-expanded code.
|
|
7
|
+
*
|
|
8
|
+
* @module @macroforge/typescript-plugin/source-map
|
|
9
|
+
*/
|
|
1
10
|
import type { SourceMappingResult } from "macroforge";
|
|
11
|
+
/**
|
|
12
|
+
* Re-export of the core source mapping result type.
|
|
13
|
+
*
|
|
14
|
+
* Contains the complete mapping data between original and expanded code,
|
|
15
|
+
* including segment information and generated region metadata.
|
|
16
|
+
*/
|
|
2
17
|
export type SourceMapping = SourceMappingResult;
|
|
18
|
+
/**
|
|
19
|
+
* Interface for mapping positions between original and expanded code.
|
|
20
|
+
*
|
|
21
|
+
* The TypeScript plugin uses this interface to translate cursor positions,
|
|
22
|
+
* text spans, and other location data between the original source code
|
|
23
|
+
* (what the user sees) and the expanded code (what TypeScript analyzes).
|
|
24
|
+
*
|
|
25
|
+
* @remarks
|
|
26
|
+
* Position mapping is bidirectional:
|
|
27
|
+
* - Original → Expanded: Used when sending positions TO TypeScript (cursor, selection)
|
|
28
|
+
* - Expanded → Original: Used when receiving positions FROM TypeScript (errors, spans)
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* // Map a cursor position from original to expanded
|
|
33
|
+
* const expandedPos = mapper.originalToExpanded(cursorPosition);
|
|
34
|
+
*
|
|
35
|
+
* // Map an error span from expanded back to original
|
|
36
|
+
* const originalSpan = mapper.mapSpanToOriginal(error.start, error.length);
|
|
37
|
+
* if (originalSpan) {
|
|
38
|
+
* // Error is in user code - show it at originalSpan position
|
|
39
|
+
* } else {
|
|
40
|
+
* // Error is in generated code - show it at decorator position instead
|
|
41
|
+
* }
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
3
44
|
export interface PositionMapper {
|
|
45
|
+
/**
|
|
46
|
+
* Maps a position from original source to expanded code.
|
|
47
|
+
*
|
|
48
|
+
* @param pos - Position in the original source (0-indexed character offset)
|
|
49
|
+
* @returns Corresponding position in the expanded code
|
|
50
|
+
*/
|
|
4
51
|
originalToExpanded(pos: number): number;
|
|
52
|
+
/**
|
|
53
|
+
* Maps a position from expanded code back to original source.
|
|
54
|
+
*
|
|
55
|
+
* @param pos - Position in the expanded code (0-indexed character offset)
|
|
56
|
+
* @returns Corresponding position in the original source, or `null` if the
|
|
57
|
+
* position falls within generated code (no original equivalent)
|
|
58
|
+
*/
|
|
5
59
|
expandedToOriginal(pos: number): number | null;
|
|
60
|
+
/**
|
|
61
|
+
* Maps a text span from expanded code back to original source.
|
|
62
|
+
*
|
|
63
|
+
* @param start - Start position in expanded code
|
|
64
|
+
* @param length - Length of the span in expanded code
|
|
65
|
+
* @returns Object with mapped start and length, or `null` if the span
|
|
66
|
+
* falls within generated code
|
|
67
|
+
*/
|
|
6
68
|
mapSpanToOriginal(start: number, length: number): {
|
|
7
69
|
start: number;
|
|
8
70
|
length: number;
|
|
9
71
|
} | null;
|
|
72
|
+
/**
|
|
73
|
+
* Maps a text span from original source to expanded code.
|
|
74
|
+
*
|
|
75
|
+
* @param start - Start position in original source
|
|
76
|
+
* @param length - Length of the span in original source
|
|
77
|
+
* @returns Object with mapped start and length in expanded code
|
|
78
|
+
*/
|
|
10
79
|
mapSpanToExpanded(start: number, length: number): {
|
|
11
80
|
start: number;
|
|
12
81
|
length: number;
|
|
13
82
|
};
|
|
83
|
+
/**
|
|
84
|
+
* Checks if this mapper has any mapping data.
|
|
85
|
+
*
|
|
86
|
+
* @returns `true` if no macro expansion occurred (original === expanded),
|
|
87
|
+
* `false` if there are position differences to account for
|
|
88
|
+
*/
|
|
14
89
|
isEmpty(): boolean;
|
|
15
90
|
}
|
|
16
91
|
//# sourceMappingURL=source-map.d.ts.map
|
package/dist/source-map.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source-map.d.ts","sourceRoot":"","sources":["../src/source-map.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEtD,MAAM,MAAM,aAAa,GAAG,mBAAmB,CAAC;AAEhD,MAAM,WAAW,cAAc;IAC7B,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"source-map.d.ts","sourceRoot":"","sources":["../src/source-map.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEtD;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG,mBAAmB,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;;OAKG;IACH,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;IAExC;;;;;;OAMG;IACH,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAE/C;;;;;;;OAOG;IACH,iBAAiB,CACf,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACb;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAE5C;;;;;;OAMG;IACH,iBAAiB,CACf,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACb;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAErC;;;;;OAKG;IACH,OAAO,IAAI,OAAO,CAAC;CACpB"}
|
package/dist/source-map.js
CHANGED
|
@@ -1,2 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview Source mapping type definitions for the TypeScript plugin.
|
|
4
|
+
*
|
|
5
|
+
* This module re-exports and extends position mapping types from the core
|
|
6
|
+
* macroforge package. These types are used to translate positions between
|
|
7
|
+
* original source code and macro-expanded code.
|
|
8
|
+
*
|
|
9
|
+
* @module @macroforge/typescript-plugin/source-map
|
|
10
|
+
*/
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@macroforge/typescript-plugin",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.35",
|
|
4
4
|
"description": "TypeScript language service plugin that augments classes decorated with @derive to include macro-generated methods.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"test": "bun run build && node --test tests/**/*.test.js"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"macroforge": "^0.1.
|
|
36
|
+
"macroforge": "^0.1.35"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"typescript": ">=5.0.0"
|