@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,186 +0,0 @@
1
- /**
2
- * Import will remove at compile time
3
- */
4
- import type { HighlightSchemeInterface } from "./interfaces/highlighter.interface";
5
- /**
6
- * Imports
7
- */
8
- import * as ts from 'typescript';
9
- /**
10
- * An enum containing ANSI escape sequences for various colors.
11
- *
12
- * This enum is primarily intended for terminal output and won't work directly in JavaScript for web development.
13
- * It defines color codes for various colors and a reset code to return to
14
- * the default text color.
15
- *
16
- * @example
17
- * ```typescript
18
- * console.log(`${Colors.red}This the text will be red in the terminal.${Colors.reset}`);
19
- * ```
20
- *
21
- * This functionality is limited to terminal environments.
22
- * Consider alternative methods
23
- * for color highlighting in web development contexts, such as CSS classes.
24
- */
25
- export declare const enum Colors {
26
- reset = "\u001B[0m",
27
- gray = "\u001B[38;5;243m",
28
- darkGray = "\u001B[38;5;238m",
29
- lightCoral = "\u001B[38;5;203m",
30
- lightOrange = "\u001B[38;5;215m",
31
- oliveGreen = "\u001B[38;5;149m",
32
- burntOrange = "\u001B[38;5;208m",
33
- lightGoldenrodYellow = "\u001B[38;5;221m",
34
- lightYellow = "\u001B[38;5;230m",
35
- canaryYellow = "\u001B[38;5;227m",
36
- deepOrange = "\u001B[38;5;166m",
37
- lightGray = "\u001B[38;5;252m",
38
- brightPink = "\u001B[38;5;197m"
39
- }
40
- /**
41
- * Class responsible for applying semantic highlighting to a source code string based on a given color scheme.
42
- *
43
- * @class
44
- *
45
- * @param sourceFile - The TypeScript AST node representing the source file.
46
- * @param code - The source code string to be highlighted.
47
- * @param schema - The color scheme used for highlighting different elements in the code.
48
- *
49
- * const highlighter = new CodeHighlighter(sourceFile, code, schema);
50
- */
51
- export declare class CodeHighlighter {
52
- private sourceFile;
53
- private code;
54
- private schema;
55
- /**
56
- * A Map of segments where the key is a combination of start and end positions,
57
- * and the value is an object containing the color and reset code.
58
- * This structure ensures unique segments and allows for fast lookups and updates.
59
- *
60
- * @example
61
- * this.segments = new Map([
62
- * ['0-10', { start: 1, end: 11, color: '\x1b[31m', reset: '\x1b[0m' }],
63
- * ['11-20', { start: 12, end: 20, color: '\x1b[32m', reset: '\x1b[0m' }]
64
- * ]);
65
- */
66
- private segments;
67
- /**
68
- * Creates an instance of the CodeHighlighter class.
69
- *
70
- * @param sourceFile - The TypeScript AST node representing the source file.
71
- * @param code - The source code string to be highlighted.
72
- * @param schema - The color scheme used for highlighting different elements in the code.
73
- */
74
- constructor(sourceFile: ts.Node, code: string, schema: HighlightSchemeInterface);
75
- /**
76
- * Parses a TypeScript AST node and processes its comments to identify segments that need highlighting.
77
- *
78
- * @param node - The TypeScript AST node to be parsed.
79
- */
80
- parseNode(node: ts.Node): void;
81
- /**
82
- * Generates a string with highlighted code segments based on the provided color scheme.
83
- *
84
- * This method processes the stored segments, applies the appropriate colors to each segment,
85
- * and returns the resulting highlighted code as a single string.
86
- *
87
- * @returns The highlighted code as a string, with ANSI color codes applied to the segments.
88
- */
89
- highlight(): string;
90
- /**
91
- * Extracts a substring from the code based on the specified start and end positions.
92
- *
93
- * This method is used to retrieve the source code segment that corresponds to the
94
- * given start and end positions. It is primarily used for highlighting specific
95
- * segments of the code.
96
- *
97
- * @param start - The starting index of the segment to be extracted.
98
- * @param end - The ending index of the segment to be extracted.
99
- * @returns The extracted substring from the code.
100
- */
101
- private getSegmentSource;
102
- /**
103
- * Adds a new segment to the list of segments to be highlighted.
104
- * The segment is defined by its start and end positions, the color to apply, and an optional reset code.
105
- *
106
- * @param start - The starting index of the segment in the code string.
107
- * @param end - The ending index of the segment in the code string.
108
- * @param color - The color code to apply to the segment.
109
- * @param reset - The color reset code to apply after the segment, Defaults to the reset code defined in `Colors.reset`.
110
- */
111
- private addSegment;
112
- /**
113
- * Processes comments within a TypeScript AST node and adds segments for highlighting.
114
- * Extracts trailing and leading comments from the node and adds them as segments using the color defined in `this.colorSchema.comments`.
115
- *
116
- * @param node - The TypeScript AST node whose comments are to be processed.
117
- */
118
- private processComments;
119
- /**
120
- * Processes the keywords within a TypeScript AST node and adds them as segments for highlighting.
121
- *
122
- * This method identifies potential keyword tokens within the provided node and adds them to the
123
- * list of segments with the color defined in `this.schema.keywordColor`.
124
- * The method considers the current node, its first token, and its last token to determine if they should be highlighted
125
- * as keywords.
126
- *
127
- * The method checks if the node's kind falls within the range of keyword kinds defined by TypeScript.
128
- * If the node or any of its tokens are identified as keywords, a segment is added to `this.segments`
129
- * with the start and end positions of the node and the specified color for keywords.
130
- *
131
- * @param node - The TypeScript AST node to be processed for keywords.
132
- */
133
- private processKeywords;
134
- /**
135
- * Processes identifiers within a TypeScript AST node and adds them as segments for highlighting
136
- * based on the node's parent type.
137
- *
138
- * This method determines the appropriate color for an identifier based on its parent node's kind.
139
- * If the parent node matches one of the specified kinds, the identifier is highlighted with a cyan color.
140
- * Supported parent kinds include various declarations, expressions, and signatures.
141
- *
142
- * @param node - The TypeScript AST node representing the identifier to be processed.
143
- */
144
- private processIdentifier;
145
- /**
146
- * Processes a TypeScript template expression and adds segments for highlighting its literal parts.
147
- *
148
- * This method adds a segment for the head of the template expression with the color specified in `this.schema.stringColor`.
149
- * It also processes each template span within the expression, adding
150
- * segments for each span's literal part.
151
- *
152
- * @param templateExpression - The TypeScript template expression to be processed.
153
- */
154
- private processTemplateExpression;
155
- /**
156
- * Processes a TypeScript AST node and adds segments for highlighting based on the node's kind.
157
- *
158
- * This method identifies the kind of the node and determines the appropriate color for highlighting.
159
- * It handles various node kinds including string literals, regular expressions, template expressions, and identifiers.
160
- * Specific methods are invoked for more complex node kinds, such as template expressions and identifiers.
161
- *
162
- * @param node - The TypeScript AST node to be processed.
163
- */
164
- private processNode;
165
- }
166
- /**
167
- * Applies semantic highlighting to the provided code string using the specified color scheme.
168
- *
169
- * @param code - The source code to be highlighted.
170
- * @param schema - An optional partial schema defining the color styles for various code elements.
171
- * Defaults to an empty object, which means no specific highlighting will be applied.
172
- *
173
- * @returns A string with the code elements wrapped in the appropriate color styles as specified by the schema.
174
- *
175
- * @example
176
- * const code = 'const x: number = 42;';
177
- * const schema = {
178
- * keywordColor: '\x1b[34m', // Blue
179
- * stringColor: '\x1b[32m', // Green
180
- * numberColor: '\x1b[31m', // Red
181
- * reset: '\x1b[0m' // Reset
182
- * };
183
- * const highlightedCode = highlightCode(code, schema);
184
- * console.log(highlightedCode);
185
- */
186
- export declare function highlightCode(code: string, schema?: Partial<HighlightSchemeInterface>): string;
@@ -1,42 +0,0 @@
1
- /**
2
- * A callback function type used for formatting code lines.
3
- *
4
- * @param lineString - The content of the line to be formatted.
5
- * @param padding - The amount of padding to be applied to the line.
6
- * @param line - The line number of the line to be formatted.
7
- * @returns The formatted line string.
8
- */
9
- export type FormatCodeCallbackType = (lineString: string, padding: number, line: number) => string;
10
- /**
11
- * Configuration options for formatting code.
12
- */
13
- export interface FormatCodeInterface {
14
- /**
15
- * The amount of padding to be applied to each line. If not specified, defaults to 0.
16
- */
17
- padding?: number;
18
- /**
19
- * The starting line number for formatting. If not specified, defaults to 1.
20
- */
21
- startLine?: number;
22
- /**
23
- * An optional action object specifying a line where a callback function should be triggered.
24
- */
25
- action?: {
26
- /**
27
- * The line number at which the callback function should be triggered.
28
- */
29
- triggerLine: number;
30
- /**
31
- * The callback function to be executed when the trigger line is encountered.
32
- */
33
- callback: FormatCodeCallbackType;
34
- };
35
- }
36
- /**
37
- * Set color to an error pointer
38
- */
39
- export interface AnsiOptionInterface {
40
- color: string;
41
- reset: string;
42
- }
@@ -1,48 +0,0 @@
1
- /**
2
- * HighlightSchemeInterface defines the structure for a color style schema
3
- * used in semantic highlighting.
4
- * This interface ensures that the highlighting styles are consistent and easily configurable.
5
- */
6
- export interface HighlightSchemeInterface {
7
- enumColor: string;
8
- typeColor: string;
9
- classColor: string;
10
- stringColor: string;
11
- keywordColor: string;
12
- commentColor: string;
13
- functionColor: string;
14
- variableColor: string;
15
- interfaceColor: string;
16
- parameterColor: string;
17
- getAccessorColor: string;
18
- numericLiteralColor: string;
19
- methodSignatureColor: string;
20
- regularExpressionColor: string;
21
- propertyAssignmentColor: string;
22
- propertyAccessExpressionColor: string;
23
- expressionWithTypeArgumentsColor: string;
24
- }
25
- /**
26
- * Represents a segment of a code string that needs to be highlighted.
27
- *
28
- * @interface
29
- *
30
- * @property start - The starting index of the segment in the code string.
31
- * @property end - The ending index of the segment in the code string.
32
- * @property color - The color code to apply to the segment.
33
- * @property reset - The color reset code to apply after the segment.
34
- *
35
- * @example
36
- * const segment: HighlightNodeSegment = {
37
- * start: 0,
38
- * end: 10,
39
- * color: '\x1b[31m', // Red
40
- * reset: '\x1b[0m' // Reset
41
- * };
42
- */
43
- export interface HighlightNodeSegmentInterface {
44
- end: number;
45
- start: number;
46
- color: string;
47
- reset: string;
48
- }
@@ -1,31 +0,0 @@
1
- /**
2
- * Represents an entry in the stack trace.
3
- */
4
- export interface StackInterface {
5
- /**
6
- * The function or method where the error occurred.
7
- */
8
- at: string;
9
- /**
10
- * The file path where the error occurred.
11
- */
12
- file: string;
13
- /**
14
- * The line number where the error occurred.
15
- */
16
- line: number;
17
- /**
18
- * The column number where the error occurred.
19
- */
20
- column: number;
21
- }
22
- /**
23
- * Represents a detailed entry in the stack trace, which may include an executor stack entry.
24
- */
25
- export interface StackEntryInterface extends StackInterface {
26
- /**
27
- * The executor information if the error occurred within an eval function.
28
- * This will be `null` if the error did not occur within an eval function.
29
- */
30
- executor?: StackInterface | null;
31
- }
@@ -1,11 +0,0 @@
1
- /**
2
- * Import will remove at compile time
3
- */
4
- import type { StackEntryInterface } from "./interfaces/parse.interface";
5
- /**
6
- * Parses an error stack trace and returns an object with a message and an array of stack entries.
7
- *
8
- * @param stackString - The error stack trace.
9
- * @returns The parsed stack trace object.
10
- */
11
- export declare function parseErrorStack(stackString: string): Array<StackEntryInterface>;
@@ -1,9 +0,0 @@
1
- export type * from "./components/interfaces/parse.interface";
2
- export type * from "./components/interfaces/formatter.interface";
3
- export type * from "./components/interfaces/highlighter.interface";
4
- export type * from "./services/interfaces/source.interface";
5
- export * from "./components/parser.component";
6
- export * from "./components/base64.component";
7
- export * from "./components/formatter.component";
8
- export * from "./components/highlighter.component";
9
- export * from "./services/source.service";
@@ -1,52 +0,0 @@
1
- /**
2
- * Represents a mapping segment that corresponds to a position in the source map.
3
- *
4
- * @property line - The original line number in the source file.
5
- * @property column - The original column number in the source file.
6
- * @property nameIndex - The index of the symbol name in the source map, or `null` if there is no associated name.
7
- * @property sourceIndex - The index of the source file in the source map.
8
- * @property generatedLine - The line number in the generated code.
9
- * @property generatedColumn - The column number in the generated code.
10
- */
11
- export interface SegmentInterface {
12
- line: number;
13
- column: number;
14
- nameIndex: number | null;
15
- sourceIndex: number;
16
- generatedLine: number;
17
- generatedColumn: number;
18
- }
19
- /**
20
- * Extends the `SegmentInterface` to represent an offset segment used during mapping calculations.
21
- * The main difference is that `nameIndex` is always a number.
22
- *
23
- * @augments { SegmentInterface }
24
- * @property nameIndex - The index of the symbol name in the source map (cannot be null in this context).
25
- */
26
- export interface SegmentOffsetInterface extends SegmentInterface {
27
- nameIndex: number;
28
- }
29
- /**
30
- * Represents the bias used when searching for segments in the source map.
31
- * This enum is useful for determining the preferred matching behavior
32
- * when the exact line and column cannot be found.
33
- *
34
- * @property BOUND - No preference for column matching; returns the first match found.
35
- * @property LOWER_BOUND - Prefer the closest mapping with a lower column value.
36
- * @property UPPER_BOUND - Prefer the closest mapping with a higher column value.
37
- */
38
- export declare const enum Bias {
39
- BOUND = 0,
40
- LOWER_BOUND = 1,
41
- UPPER_BOUND = 2
42
- }
43
- /**
44
- * A type alias for a frame in the source map, representing an array of segments.
45
- * Each frame consists of multiple mapping segments for a given line in the generated code.
46
- */
47
- export type FrameType = Array<SegmentInterface>;
48
- /**
49
- * A type alias for the source map, where each entry represents a frame of mappings.
50
- * A frame can either be an array of segments (frame) or `null` if the line has no mappings (represented by a semicolon in the mapping string).
51
- */
52
- export type MapType = Array<null | FrameType>;
@@ -1,229 +0,0 @@
1
- /**
2
- * Import will remove at compile time
3
- */
4
- import { Bias, type MapType, type SegmentInterface } from './interfaces/mapping.interface';
5
- /**
6
- * The `MappingProvider` class provides methods to encode and decode mappings
7
- * from a source map or mapping string to an internal structured representation.
8
- */
9
- export declare class MappingProvider {
10
- /**
11
- * The internal mapping representation, where each index represents a frame of segments.
12
- */
13
- private mapping;
14
- /**
15
- * Constructor to initialize the `MappingProvider` with a mapping.
16
- * Can be initialized with either a mapping string or a structured mapping array.
17
- *
18
- * @param mapping - The mapping data, either as a string or structured array.
19
- * @param namesOffset - Optional offset for the names index.
20
- * @param sourceOffset - Optional offset for the sources index.
21
- *
22
- * @example
23
- * ```ts
24
- * const provider = new MappingProvider(";;;AAiBO,SAAS,OAAO;AACnB,UAAQ,IAAI,MAAM;AACtB;;;ACjBA,QAAQ,IAAI,GAAG;AACf,KAAK;", 0, 0);
25
- * const provider2 = new MappingProvider([
26
- * null,
27
- * [
28
- * {
29
- * line: 1,
30
- * column: 1,
31
- * nameIndex: null,
32
- * sourceIndex: 0,
33
- * generatedLine: 2,
34
- * generatedColumn: 1
35
- * }
36
- * ],
37
- * null
38
- * ], 0, 0);
39
- * ```
40
- */
41
- constructor(mapping: string, namesOffset?: number, sourceOffset?: number);
42
- constructor(mapping: MapType, namesOffset?: number, sourceOffset?: number);
43
- constructor(mapping: MappingProvider, namesOffset?: number, sourceOffset?: number);
44
- /**
45
- * Encodes the internal mapping array back into a mapping string.
46
- *
47
- * @returns {string} - The encoded mapping string.
48
- * @example
49
- * ```ts
50
- * const encoded = provider.encode();
51
- * console.log(encoded); // Outputs encoded mapping string
52
- * ```
53
- */
54
- encode(): string;
55
- /**
56
- * Decodes a mapping from either a string or structured array into the internal mapping.
57
- *
58
- * @param mapping - The mapping data to decode.
59
- * @param namesOffset - Offset for the names index.
60
- * @param sourcesOffset - Offset for the sources index.
61
- * @example
62
- * ```ts
63
- * provider.decode(";;;AAiBO,SAAS,OAAO;AACnB,UAAQ,IAAI,MAAM;AACtB;;;ACjBA,QAAQ,IAAI,GAAG;AACf,KAAK;", 0, 0);
64
- * provider.decode([
65
- * null,
66
- * [
67
- * {
68
- * line: 1,
69
- * column: 1,
70
- * nameIndex: null,
71
- * sourceIndex: 0,
72
- * generatedLine: 2,
73
- * generatedColumn: 1
74
- * }
75
- * ],
76
- * null
77
- * ], 0, 0);
78
- * ```
79
- */
80
- decode(mapping: MappingProvider | MapType | string, namesOffset?: number, sourcesOffset?: number): void;
81
- /**
82
- * Retrieves a segment based on the provided generated line and column,
83
- * applying the specified bias when the exact match is not found.
84
- *
85
- * This method performs a binary search on the segments of the specified
86
- * generated line to efficiently locate the segment corresponding to
87
- * the provided generated column. If an exact match is not found,
88
- * the method returns the closest segment based on the specified bias:
89
- * - `Bias.BOUND`: No preference for column matching (returns the closest segment).
90
- * - `Bias.LOWER_BOUND`: Prefers the closest mapping with a lower column value.
91
- * - `Bias.UPPER_BOUND`: Prefers the closest mapping with a higher column value.
92
- *
93
- * @param generatedLine - The line number of the generated code (1-based index).
94
- * @param generatedColumn - The column number of the generated code (0-based index).
95
- * @param bias - The bias to use when the line matches, can be one of:
96
- * - `Bias.BOUND` (default): No preference for column matching.
97
- * - `Bias.LOWER_BOUND`: Prefer the closest mapping with a lower column value.
98
- * - `Bias.UPPER_BOUND`: Prefer the closest mapping with a higher column value.
99
- * @returns The matching segment if found;
100
- * returns null if no segments exist for the specified generated line
101
- * or if the generated line is out of bounds.
102
- *
103
- * @throws { Error } - Throws an error if the generated line is invalid
104
- * (out of bounds).
105
- *
106
- * @example
107
- * ```ts
108
- * const segment = sourceMap.getSegment(5, 10, Bias.UPPER_BOUND);
109
- * if (segment) {
110
- * console.log(`Found segment: line ${segment.line}, column ${segment.column}`);
111
- * } else {
112
- * console.log('No matching segment found.');
113
- * }
114
- * ```
115
- */
116
- getSegment(generatedLine: number, generatedColumn: number, bias?: Bias): SegmentInterface | null;
117
- /**
118
- * Retrieves the original segment based on the provided line, column, and source index.
119
- *
120
- * This method searches for the original segment that corresponds to the specified
121
- * line, column, and source index. It uses binary search to find the closest segment
122
- * based on the provided bias.
123
- *
124
- * @param line - The line number of the original code (1-based index).
125
- * @param column - The column number of the original code (0-based index).
126
- * @param sourceIndex - The index of the source file in the source map.
127
- * @param bias - The bias to apply when multiple segments match; defaults to `Bias.BOUND`.
128
- * @returns {SegmentInterface | null} - The matching original segment if found;
129
- * returns null if no segments exist for the specified line and source index.
130
- *
131
- * @example
132
- * ```ts
133
- * const originalSegment = sourceMap.getOriginalSegment(3, 5, 0, Bias.LOWER_BOUND);
134
- * if (originalSegment) {
135
- * console.log(`Found original segment: line ${originalSegment.line}, column ${originalSegment.column}`);
136
- * } else {
137
- * console.log('No matching original segment found.');
138
- * }
139
- * ```
140
- */
141
- getOriginalSegment(line: number, column: number, sourceIndex: number, bias?: Bias): SegmentInterface | null;
142
- /**
143
- * Initializes the segment offsets used to track the current decoding position.
144
- *
145
- * @param namesOffset - The offset for the names index.
146
- * @param sourceIndex - The offset for the source index.
147
- * @returns { SegmentOffsetInterface } - The initialized segment offset.
148
- */
149
- private initPositionOffsets;
150
- /**
151
- * Validates the format of an encoded mapping string.
152
- *
153
- * @param encodedSourceMap - The encoded source map string to validate.
154
- * @returns Returns `true` if the format is valid, otherwise `false`.
155
- */
156
- private validateMappingString;
157
- /**
158
- * Validates the properties of a segment to ensure they conform to expected types.
159
- *
160
- * This method checks that the segment's properties are finite numbers and that
161
- * the nameIndex, if provided, is either a finite number or null.
162
- * An error is thrown if any of the properties do not meet the specified criteria.
163
- *
164
- * @param segment - The segment object to validate, which must conform to the
165
- * SegmentInterface structure, including:
166
- * - line: number (finite)
167
- * - column: number (finite)
168
- * - nameIndex: number | null (if not null, must be finite)
169
- * - sourceIndex: number (finite)
170
- * - generatedLine: number (finite)
171
- * - generatedColumn: number (finite)
172
- *
173
- * @throws {Error} - Throws an error if any property of the segment is invalid.
174
- * The error message will specify which property is invalid
175
- * and the value that was received.
176
- */
177
- private validateSegment;
178
- /**
179
- * Encodes a segment into a VLQ-encoded string based on the segment offsets.
180
- *
181
- * @param segmentOffset - The current segment offset.
182
- * @param segmentObject - The segment to encode.
183
- * @returns The encoded segment string.
184
- */
185
- private encodeSegment;
186
- /**
187
- * Encodes the entire mapping array into a VLQ-encoded mapping string.
188
- *
189
- * @param map - The mapping array to encode.
190
- * @returns The encoded mapping string.
191
- */
192
- private encodeMappings;
193
- /**
194
- * Decodes a VLQ-encoded segment into a segment object based on the current offset.
195
- *
196
- * @param segmentOffset - The current segment offset.
197
- * @param decodedSegment - The decoded VLQ segment values.
198
- * @returns The decoded segment object.
199
- */
200
- private decodedSegment;
201
- /**
202
- * Decodes a VLQ-encoded mapping string into the internal mapping representation.
203
- *
204
- * @param encodedMap - The VLQ-encoded mapping string.
205
- * @param namesOffset - Offset for the names index.
206
- * @param sourceOffset - Offset for the sources index.
207
- * @throws { Error } - Throws an error if the mapping string is invalid.
208
- */
209
- private decodeMappingString;
210
- /**
211
- * Decodes a mapping array into the internal mapping representation, adjusting for offsets.
212
- *
213
- * This method processes each frame in the provided structured mapping array,
214
- * validating each segment within the frame and adjusting the indices based on the
215
- * specified offsets for names and sources. If a frame is invalid or not an array,
216
- * an error will be thrown.
217
- *
218
- * @param encodedMap - The structured mapping array, which should be an array of frames,
219
- * where each frame is an array of segments. Each segment must conform
220
- * to the SegmentInterface.
221
- * @param namesOffset - Offset for the names index, which will be added to each segment's nameIndex.
222
- * @param sourceOffset - Offset for the sources index, which will be added to each segment's sourceIndex.
223
- * @throws { Error } - Throws an error if:
224
- * - The mapping array is invalid (not an array).
225
- * - Any frame is not an array.
226
- * - Any segment does not conform to the SegmentInterface.
227
- */
228
- private decodeMappingArray;
229
- }
@@ -1,53 +0,0 @@
1
- /**
2
- * Represents a source map structure used for mapping code within a file
3
- * to its original source. Source maps are essential for debugging minified
4
- * or transpiled code, as they allow developers to trace back to the
5
- * original source files and understand the context of the code execution.
6
- *
7
- * @interface SourceMapInterface
8
- * @property file - The generated file's name that the source map is associated with.
9
- * This property is optional and may be null if not specified.
10
- * @property names - An array of variable/function names that are present in the original source.
11
- * These names help in mapping the original code context during debugging.
12
- * @property version - The version of the source map specification.
13
- * This should be set to `3` for the standard source map version.
14
- * @property sources - An array of URLs or paths to the original source files.
15
- * These sources are used to locate the original code that corresponds to the generated code.
16
- * @property mappings - A VLQ (Variable-Length Quantity) encoded string that describes how to map the
17
- * generated code back to the original source code. This property is crucial for the correct functioning of the source map.
18
- * @property sourceRoot - An optional root URL for the sources.
19
- * It can be used to specify a base path for resolving the sources, which may be null if not applicable.
20
- * @property sourcesContent - An optional array containing the content of the original source files.
21
- * This property can be useful when the original files are not available at runtime.
22
- */
23
- export interface SourceMapInterface {
24
- file?: string | null;
25
- names: Array<string>;
26
- version: number;
27
- sources: Array<string>;
28
- mappings: string;
29
- sourceRoot?: string | null;
30
- sourcesContent?: Array<string>;
31
- }
32
- export interface PositionInterface {
33
- name: string | null;
34
- line: number;
35
- column: number;
36
- source: string;
37
- sourceRoot: string | null;
38
- sourceIndex: number;
39
- generatedLine: number;
40
- generatedColumn: number;
41
- }
42
- export interface PositionWithContentInterface extends PositionInterface {
43
- sourcesContent: string;
44
- }
45
- export interface PositionWithCodeInterface extends PositionInterface {
46
- code: string;
47
- endLine: number;
48
- startLine: number;
49
- }
50
- export interface SourceOptionsInterface {
51
- linesAfter?: number;
52
- linesBefore?: number;
53
- }