@remotex-labs/xmap 2.0.2 → 2.0.4

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 (31) hide show
  1. package/dist/cjs/index.js +6 -5
  2. package/dist/cjs/index.js.map +3 -3
  3. package/dist/cjs/package.json +1 -0
  4. package/dist/esm/index.js +6 -5
  5. package/dist/esm/index.js.map +3 -3
  6. package/dist/esm/package.json +1 -0
  7. package/dist/{cjs/providers → providers}/mapping.provider.d.ts +5 -1
  8. package/package.json +10 -10
  9. package/dist/esm/components/base64.component.d.ts +0 -26
  10. package/dist/esm/components/formatter.component.d.ts +0 -66
  11. package/dist/esm/components/highlighter.component.d.ts +0 -186
  12. package/dist/esm/components/interfaces/formatter.interface.d.ts +0 -42
  13. package/dist/esm/components/interfaces/highlighter.interface.d.ts +0 -48
  14. package/dist/esm/components/interfaces/parse.interface.d.ts +0 -31
  15. package/dist/esm/components/parser.component.d.ts +0 -11
  16. package/dist/esm/index.d.ts +0 -9
  17. package/dist/esm/providers/interfaces/mapping.interface.d.ts +0 -52
  18. package/dist/esm/providers/mapping.provider.d.ts +0 -229
  19. package/dist/esm/services/interfaces/source.interface.d.ts +0 -53
  20. package/dist/esm/services/source.service.d.ts +0 -217
  21. /package/dist/{cjs/components → components}/base64.component.d.ts +0 -0
  22. /package/dist/{cjs/components → components}/formatter.component.d.ts +0 -0
  23. /package/dist/{cjs/components → components}/highlighter.component.d.ts +0 -0
  24. /package/dist/{cjs/components → components}/interfaces/formatter.interface.d.ts +0 -0
  25. /package/dist/{cjs/components → components}/interfaces/highlighter.interface.d.ts +0 -0
  26. /package/dist/{cjs/components → components}/interfaces/parse.interface.d.ts +0 -0
  27. /package/dist/{cjs/components → components}/parser.component.d.ts +0 -0
  28. /package/dist/{cjs/index.d.ts → index.d.ts} +0 -0
  29. /package/dist/{cjs/providers → providers}/interfaces/mapping.interface.d.ts +0 -0
  30. /package/dist/{cjs/services → services}/interfaces/source.interface.d.ts +0 -0
  31. /package/dist/{cjs/services → services}/source.service.d.ts +0 -0
@@ -1,217 +0,0 @@
1
- /**
2
- * Import will remove at compile time
3
- */
4
- import type { PositionInterface, SourceMapInterface, SourceOptionsInterface, PositionWithCodeInterface, PositionWithContentInterface } from "./interfaces/source.interface";
5
- /**
6
- * Imports
7
- */
8
- import { MappingProvider } from "../providers/mapping.provider";
9
- import { Bias } from "../providers/interfaces/mapping.interface";
10
- /**
11
- * A service for validating and processing source maps.
12
- * This class allows parsing and manipulation of source maps, providing functionality such as
13
- * retrieving position mappings between original and generated code, concatenating source maps,
14
- * and getting code snippets based on mappings.
15
- *
16
- * @example
17
- * ```ts
18
- * const sourceMapJSON = '{"version": 3, "file": "bundle.js", "sources": ["foo.ts"], "names": [], "mappings": "AAAA"}';
19
- * const sourceService = new SourceService(sourceMapJSON);
20
- *
21
- * console.log(sourceService.file); // Outputs: 'bundle.js'
22
- * ```
23
- */
24
- export declare class SourceService {
25
- /**
26
- * The name of the generated file (bundle) that this source map applies to.
27
- *
28
- * @example
29
- * ```ts
30
- * console.log(sourceService.file); // 'bundle.js'
31
- * ```
32
- */
33
- readonly file: string | null;
34
- /**
35
- * A MappingProvider instance of base64 VLQ-encoded mappings.
36
- */
37
- readonly mappings: MappingProvider;
38
- /**
39
- * The root URL for the sources, if present in the source map.
40
- */
41
- readonly sourceRoot: string | null;
42
- /**
43
- * A list of symbol names used by the “mappings” entry.
44
- */
45
- readonly names: Array<string>;
46
- /**
47
- * An array of source file paths.
48
- */
49
- readonly sources: Array<string>;
50
- /**
51
- * An array of source files contents.
52
- */
53
- readonly sourcesContent: Array<string>;
54
- /**
55
- * Creates a new instance of the `SourceService` class.
56
- *
57
- * This constructor initializes the class using either a `SourceMapInterface` object,
58
- * a JSON string representing the source map, or an existing `SourceService` instance.
59
- * It validates the source map and populates its properties such as `file`, `sources`, and `mappings`.
60
- *
61
- * @param source - Can be one of the following:
62
- * - An object conforming to the `SourceMapInterface`.
63
- * - A JSON string representing the source map.
64
- * - A `SourceService` instance to copy the properties.
65
- * @param file - (Optional) A string representing the file name of the generated bundle.
66
- * Defaults to `null`. It will overwrite any existing `file` property in the source map.
67
- * @throws {Error} - If the source map does not contain required properties or has an invalid format.
68
- *
69
- * @example
70
- * ```ts
71
- * const sourceMapJSON = '{"version": 3, "file": "bundle.js", "sources": ["foo.ts"], "names": [], "mappings": "AAAA"}';
72
- * const sourceService = new SourceService(sourceMapJSON);
73
- * ```
74
- */
75
- constructor(source: SourceService);
76
- constructor(source: SourceMapInterface | string, file?: string | null);
77
- /**
78
- * Converts the current source map data into a plain object format.
79
- *
80
- * @returns The source map json object.
81
- *
82
- * @example
83
- * ```ts
84
- * const mapObject = sourceService.getMapObject();
85
- * console.log(mapObject.file); // 'bundle.js'
86
- * ```
87
- */
88
- getMapObject(): SourceMapInterface;
89
- /**
90
- * Concatenates one or more source maps to the current source map.
91
- *
92
- * This method merges additional source maps into the current source map,
93
- * updating the `mappings`, `names`, `sources`, and `sourcesContent` arrays.
94
- *
95
- * @param maps - An array of `SourceMapInterface` or `SourceService` instances to be concatenated.
96
- * @throws { Error } If no source maps are provided for concatenation.
97
- *
98
- * @example
99
- * ```ts
100
- * sourceService.concat(anotherSourceMap);
101
- * console.log(sourceService.sources); // Updated source paths
102
- * ```
103
- */
104
- concat(...maps: Array<SourceMapInterface | SourceService>): void;
105
- /**
106
- * Creates a new instance of `SourceService` with concatenated source maps.
107
- *
108
- * @param maps - An array of `SourceMapInterface` or `SourceService` instances to be concatenated.
109
- * @returns { SourceService } A new `SourceService` instance with the concatenated maps.
110
- * @throws { Error } If no source maps are provided.
111
- *
112
- * @example
113
- * ```ts
114
- * const newService = sourceService.concatNewMap(anotherSourceMap);
115
- * console.log(newService.file); // The file from the new source map
116
- * ```
117
- */
118
- concatNewMap(...maps: Array<SourceMapInterface | SourceService>): SourceService;
119
- /**
120
- * Retrieves the position information based on the original source line and column.
121
- *
122
- * @param line - The line number in the generated code.
123
- * @param column - The column number in the generated code.
124
- * @param sourceIndex - The index or file path of the original source.
125
- * @param bias - The bias to use when matching positions (`Bias.LOWER_BOUND`, `Bias.UPPER_BOUND`, or `Bias.BOUND`).
126
- * @returns { PositionInterface | null } The corresponding position in the original source, or `null` if not found.
127
- *
128
- * @example
129
- * ```ts
130
- * const position = sourceService.getPositionByOriginal(1, 10, 'foo.ts');
131
- * console.log(position?.line); // The line number in the original source
132
- * ```
133
- */
134
- getPositionByOriginal(line: number, column: number, sourceIndex: number | string, bias?: Bias): PositionInterface | null;
135
- /**
136
- * Retrieves the position in the original source code based on a given line and column
137
- * in the generated code.
138
- *
139
- * @param line - Line number in the generated code.
140
- * @param column - Column number in the generated code.
141
- * @param bias - The bias to use for matching positions. Defaults to `Bias.BOUND`.
142
- * @returns {PositionInterface | null} The position in the original source, or null if not found.
143
- *
144
- * @example
145
- * ```ts
146
- * const position = sourceService.getPosition(2, 15);
147
- * console.log(position?.source); // The original source file
148
- * ```
149
- */
150
- getPosition(line: number, column: number, bias?: Bias): PositionInterface | null;
151
- /**
152
- * Retrieves the position and original source content for a given position in the generated code.
153
- *
154
- * @param line - Line number in the generated code.
155
- * @param column - Column number in the generated code.
156
- * @param bias - Bias used for position matching.
157
- * @returns { PositionWithContentInterface | null } The position and its associated content, or `null` if not found.
158
- *
159
- * @example
160
- * ```ts
161
- * const positionWithContent = sourceService.getPositionWithContent(3, 5);
162
- * console.log(positionWithContent?.sourcesContent); // The source code content
163
- * ```
164
- */
165
- getPositionWithContent(line: number, column: number, bias?: Bias): PositionWithContentInterface | null;
166
- /**
167
- * Retrieves the position and a code snippet from the original source based on the given
168
- * generated code position, with additional lines of code around the matching line.
169
- *
170
- * @param line - Line number in the generated code.
171
- * @param column - Column number in the generated code.
172
- * @param bias - Bias used for position matching.
173
- * @param options - (Optional) Extra options for the amount of surrounding lines to include.
174
- * @returns { PositionWithCodeInterface | null } The position and code snippet.
175
- *
176
- * @example
177
- * ```ts
178
- * const positionWithCode = sourceService.getPositionWithCode(4, 8, Bias.BOUND, { linesBefore: 2, linesAfter: 2 });
179
- * console.log(positionWithCode?.code); // The code snippet from the original source
180
- * ```
181
- */
182
- getPositionWithCode(line: number, column: number, bias?: Bias, options?: SourceOptionsInterface): PositionWithCodeInterface | null;
183
- /**
184
- * Converts the current source map object to a JSON string.
185
- *
186
- * @returns A stringified version of the source map object.
187
- *
188
- * @example
189
- * ```ts
190
- * console.log(sourceService.toString()); // JSON string of the source map
191
- * ```
192
- */
193
- toString(): string;
194
- /**
195
- * Validates the provided source map object.
196
- *
197
- * This method checks whether all required keys are present in the source map object.
198
- * It throws an error if any required keys are missing.
199
- *
200
- * @private
201
- * @param input - The source map object to be validated.
202
- * @throws Error If any required key is missing from the source map.
203
- *
204
- * @example
205
- * ```ts
206
- * const sourceMap = {
207
- * version: 3,
208
- * file: 'example.js',
209
- * names: ['src', 'maps', 'example', 'function', 'line', 'column'],
210
- * sources: ['source1.js', 'source2.js'],
211
- * mappings: 'AAAA,SAASA,CAAC,CAAC,CAAC;AAAA,CAAC,CAAC;AAAC,CAAC',
212
- * };
213
- * sourceService['validateSource'](sourceMap); // Throws if invalid
214
- * ```
215
- */
216
- private validateSourceMap;
217
- }
File without changes