@remotex-labs/xmap 3.0.1 → 3.0.3

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.
@@ -1,216 +0,0 @@
1
- /**
2
- * Import will remove at compile time
3
- */
4
- import type { PositionInterface, SourceMapInterface, SourceOptionsInterface, PositionWithCodeInterface, PositionWithContentInterface } from "./interfaces/source-service.interface";
5
- /**
6
- * Imports
7
- */
8
- import { MappingProvider } from "../providers/mapping.provider";
9
- import { Bias } from "../providers/interfaces/mapping-provider.interface";
10
- /**
11
- * A service for validating and processing source maps that provides functionality for parsing,
12
- * position mapping, concatenation, and code snippet extraction.
13
- *
14
- * @param source - Source map data (SourceService, SourceMapInterface object, or JSON string)
15
- * @param file - Optional file name for the generated bundle
16
- * @returns A new SourceService instance
17
- *
18
- * @example
19
- * ```ts
20
- * const sourceMapJSON = '{"version": 3, "file": "bundle.js", "sources": ["foo.ts"], "names": [], "mappings": "AAAA"}';
21
- * const sourceService = new SourceService(sourceMapJSON);
22
- * console.log(sourceService.file); // 'bundle.js'
23
- * ```
24
- *
25
- * @since 1.0.0
26
- */
27
- export declare class SourceService {
28
- /**
29
- * The name of the generated file this source map applies to.
30
- *
31
- * @since 1.0.0
32
- */
33
- readonly file: string | null;
34
- /**
35
- * Provider for accessing and manipulating the base64 VLQ-encoded mappings.
36
- *
37
- * @since 1.0.0
38
- */
39
- readonly mappings: MappingProvider;
40
- /**
41
- * The root URL for resolving relative paths in the source files.
42
- * @since 1.0.0
43
- */
44
- readonly sourceRoot: string | null;
45
- /**
46
- * List of symbol names referenced by the mappings.
47
- * @since 1.0.0
48
- */
49
- readonly names: Array<string>;
50
- /**
51
- * Array of source file paths.
52
- * @since 1.0.0
53
- */
54
- readonly sources: Array<string>;
55
- /**
56
- * Array of source file contents.
57
- * @since 1.0.0
58
- */
59
- readonly sourcesContent: Array<string>;
60
- /**
61
- * Creates a new SourceService instance.
62
- *
63
- * @param source - Source map data (SourceService, SourceMapInterface object, or JSON string)
64
- * @param file - Optional file name for the generated bundle
65
- *
66
- * @throws Error - When a source map has an invalid format or missing required properties
67
- *
68
- * @since 1.0.0
69
- */
70
- constructor(source: SourceService);
71
- constructor(source: SourceMapInterface | string, file?: string | null);
72
- /**
73
- * Converts the source map data to a plain object.
74
- *
75
- * @returns A SourceMapInterface object representing the current state
76
- *
77
- * @example
78
- * ```ts
79
- * const mapObject = sourceService.getMapObject();
80
- * console.log(mapObject.file); // 'bundle.js'
81
- * ```
82
- *
83
- * @since 1.0.0
84
- */
85
- getMapObject(): SourceMapInterface;
86
- /**
87
- * Concatenates additional source maps into the current instance.
88
- *
89
- * @param maps - Source maps to concatenate with the current map
90
- *
91
- * @example
92
- * ```ts
93
- * sourceService.concat(anotherSourceMap);
94
- * console.log(sourceService.sources); // Updated source paths
95
- * ```
96
- *
97
- * @throws Error - When no maps are provided
98
- *
99
- * @since 1.0.0
100
- */
101
- concat(...maps: Array<SourceMapInterface | SourceService>): void;
102
- /**
103
- * Creates a new SourceService instance with concatenated source maps.
104
- *
105
- * @param maps - Source maps to concatenate with a copy of the current map
106
- * @returns A new SourceService instance with the combined maps
107
- *
108
- * @example
109
- * ```ts
110
- * const newService = sourceService.concatNewMap(anotherSourceMap);
111
- * console.log(newService.sources); // Combined sources array
112
- * ```
113
- *
114
- * @throws Error - When no maps are provided
115
- *
116
- * @since 1.0.0
117
- */
118
- concatNewMap(...maps: Array<SourceMapInterface | SourceService>): SourceService;
119
- /**
120
- * Finds position in generated code based on original source position.
121
- *
122
- * @param line - Line number in the original source
123
- * @param column - Column number in the original source
124
- * @param sourceIndex - Index or file path of the original source
125
- * @param bias - Position matching strategy (default: Bias.BOUND)
126
- * @returns Position information or null if not found
127
- *
128
- * @example
129
- * ```ts
130
- * const position = sourceService.getPositionByOriginal(1, 10, 'foo.ts');
131
- * console.log(position?.generatedLine); // Line in generated code
132
- * ```
133
- *
134
- * @since 1.0.0
135
- */
136
- getPositionByOriginal(line: number, column: number, sourceIndex: number | string, bias?: Bias): PositionInterface | null;
137
- /**
138
- * Finds position in an original source based on generated code position.
139
- *
140
- * @param line - Line number in the generated code
141
- * @param column - Column number in the generated code
142
- * @param bias - Position matching strategy (default: Bias.BOUND)
143
- * @returns Position information or null if not found
144
- *
145
- * @example
146
- * ```ts
147
- * const position = sourceService.getPosition(2, 15);
148
- * console.log(position?.source); // Original source file
149
- * ```
150
- *
151
- * @since 1.0.0
152
- */
153
- getPosition(line: number, column: number, bias?: Bias): PositionInterface | null;
154
- /**
155
- * Retrieves position with source content for a location in generated code.
156
- *
157
- * @param line - Line number in the generated code
158
- * @param column - Column number in the generated code
159
- * @param bias - Position matching strategy (default: Bias.BOUND)
160
- * @returns Position with content information or null if not found
161
- *
162
- * @example
163
- * ```ts
164
- * const posWithContent = sourceService.getPositionWithContent(3, 5);
165
- * console.log(posWithContent?.sourcesContent); // Original source content
166
- * ```
167
- *
168
- * @since 1.0.0
169
- */
170
- getPositionWithContent(line: number, column: number, bias?: Bias): PositionWithContentInterface | null;
171
- /**
172
- * Retrieves position with a code snippet from the original source.
173
- *
174
- * @param line - Line number in the generated code
175
- * @param column - Column number in the generated code
176
- * @param bias - Position matching strategy (default: Bias.BOUND)
177
- * @param options - Configuration for the amount of surrounding lines
178
- * @returns Position with code snippet or null if not found
179
- *
180
- * @example
181
- * ```ts
182
- * const posWithCode = sourceService.getPositionWithCode(4, 8, Bias.BOUND, {
183
- * linesBefore: 2,
184
- * linesAfter: 2
185
- * });
186
- * console.log(posWithCode?.code); // Code snippet with context
187
- * ```
188
- *
189
- * @since 1.0.0
190
- */
191
- getPositionWithCode(line: number, column: number, bias?: Bias, options?: SourceOptionsInterface): PositionWithCodeInterface | null;
192
- /**
193
- * Serializes the source map to a JSON string.
194
- *
195
- * @returns JSON string representation of the source map
196
- *
197
- * @example
198
- * ```ts
199
- * const jsonString = sourceService.toString();
200
- * console.log(jsonString); // '{"version":3,"file":"bundle.js",...}'
201
- * ```
202
- *
203
- * @since 1.0.0
204
- */
205
- toString(): string;
206
- /**
207
- * Validates a source map object has all required properties.
208
- *
209
- * @param input - Source map object to validate
210
- *
211
- * @throws Error - When required properties are missing
212
- *
213
- * @since 1.0.0
214
- */
215
- private validateSourceMap;
216
- }