@remotex-labs/xmap 3.0.5 → 4.0.1
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 +190 -122
- package/dist/cjs/formatter.component.js +3 -3
- package/dist/cjs/formatter.component.js.map +3 -3
- package/dist/cjs/highlighter.component.js +1 -1
- package/dist/cjs/highlighter.component.js.map +4 -4
- package/dist/cjs/index.js +3 -3
- package/dist/cjs/index.js.map +4 -4
- package/dist/cjs/parser.component.js +4 -2
- package/dist/cjs/parser.component.js.map +4 -4
- package/dist/esm/formatter.component.js +4 -4
- package/dist/esm/formatter.component.js.map +3 -3
- package/dist/esm/highlighter.component.js +1 -1
- package/dist/esm/highlighter.component.js.map +4 -4
- package/dist/esm/index.js +3 -3
- package/dist/esm/index.js.map +4 -4
- package/dist/esm/parser.component.js +4 -2
- package/dist/esm/parser.component.js.map +4 -4
- package/dist/formatter.component.d.ts +256 -95
- package/dist/highlighter.component.d.ts +169 -128
- package/dist/index.d.ts +429 -400
- package/dist/parser.component.d.ts +113 -72
- package/package.json +19 -12
|
@@ -1,61 +1,20 @@
|
|
|
1
|
+
|
|
1
2
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
*
|
|
7
|
-
* about the origin of the code.
|
|
8
|
-
*
|
|
9
|
-
* Properties:
|
|
10
|
-
* - source: The source code relevant to the stack frame.
|
|
11
|
-
* - line: An optional line number in the code associated with this frame.
|
|
12
|
-
* - column: An optional column number in the line associated with this frame.
|
|
13
|
-
* - fileName: The name of the file associated with the frame, if available.
|
|
14
|
-
* - functionName: The name of the function where the stack frame is located, if available.
|
|
15
|
-
* - eval: Indicates if the stack frame originates from an evaluated script.
|
|
16
|
-
* - async: Indicates if the stack frame is part of an asynchronous operation.
|
|
17
|
-
* - native: Indicates if the stack frame is part of native code execution.
|
|
18
|
-
* - constructor: Indicates if the frame is related to an object constructor invocation.
|
|
19
|
-
* - evalOrigin: Optional information about the origin of the code if it resulted from an eval execution,
|
|
20
|
-
* including line number, column number, file name, and function name.
|
|
21
|
-
*
|
|
22
|
-
* @since 3.0.0
|
|
3
|
+
* This file was automatically generated by xBuild.
|
|
4
|
+
* DO NOT EDIT MANUALLY.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Export interfaces
|
|
23
8
|
*/
|
|
24
|
-
export interface StackFrame {
|
|
25
|
-
source: string;
|
|
26
|
-
line?: number;
|
|
27
|
-
column?: number;
|
|
28
|
-
fileName?: string;
|
|
29
|
-
functionName?: string;
|
|
30
|
-
eval: boolean;
|
|
31
|
-
async: boolean;
|
|
32
|
-
native: boolean;
|
|
33
|
-
constructor: boolean;
|
|
34
|
-
evalOrigin?: {
|
|
35
|
-
line?: number;
|
|
36
|
-
column?: number;
|
|
37
|
-
fileName?: string;
|
|
38
|
-
functionName?: string;
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
9
|
/**
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* @see StackFrame
|
|
45
|
-
* @since 2.1.0
|
|
10
|
+
* Import will remove at compile time
|
|
46
11
|
*/
|
|
47
|
-
export interface ParsedStackTrace {
|
|
48
|
-
name: string;
|
|
49
|
-
message: string;
|
|
50
|
-
stack: StackFrame[];
|
|
51
|
-
rawStack: string;
|
|
52
|
-
}
|
|
53
12
|
/**
|
|
54
13
|
* Enumeration of JavaScript engines that can be detected from stack traces
|
|
55
14
|
*
|
|
56
15
|
* @since 2.1.0
|
|
57
16
|
*/
|
|
58
|
-
|
|
17
|
+
declare const enum JSEngines {
|
|
59
18
|
V8 = 0,
|
|
60
19
|
SPIDERMONKEY = 1,
|
|
61
20
|
JAVASCRIPT_CORE = 2,
|
|
@@ -107,14 +66,14 @@ export declare function normalizePath(filePath: string): string;
|
|
|
107
66
|
* Creates a default stack frame object with initial values
|
|
108
67
|
*
|
|
109
68
|
* @param source - The original source line from the stack trace
|
|
110
|
-
* @returns A new
|
|
69
|
+
* @returns A new StackFrameInterface object with default null values
|
|
111
70
|
*
|
|
112
|
-
* @see
|
|
113
|
-
* @see
|
|
71
|
+
* @see ParsedStackTraceInterface
|
|
72
|
+
* @see StackFrameInterface
|
|
114
73
|
*
|
|
115
74
|
* @since 2.1.0
|
|
116
75
|
*/
|
|
117
|
-
export declare function createDefaultFrame(source: string):
|
|
76
|
+
export declare function createDefaultFrame(source: string): StackFrameInterface;
|
|
118
77
|
/**
|
|
119
78
|
* Safely parses a string value to an integer, handling undefined and null cases
|
|
120
79
|
*
|
|
@@ -132,10 +91,10 @@ export declare function createDefaultFrame(source: string): StackFrame;
|
|
|
132
91
|
*/
|
|
133
92
|
export declare function safeParseInt(value: string | undefined | null): number | undefined;
|
|
134
93
|
/**
|
|
135
|
-
* Parses a V8 JavaScript engine stack trace line into a structured
|
|
94
|
+
* Parses a V8 JavaScript engine stack trace line into a structured StackFrameInterface object
|
|
136
95
|
*
|
|
137
96
|
* @param line - The stack trace line to parse
|
|
138
|
-
* @returns A
|
|
97
|
+
* @returns A StackFrameInterface object containing the parsed information
|
|
139
98
|
*
|
|
140
99
|
* @remarks
|
|
141
100
|
* Handles both standard V8 stack frames and eval-generated stack frames which
|
|
@@ -152,17 +111,17 @@ export declare function safeParseInt(value: string | undefined | null): number |
|
|
|
152
111
|
*
|
|
153
112
|
* @throws Error - If the line format doesn't match any known V8 pattern
|
|
154
113
|
*
|
|
155
|
-
* @see
|
|
114
|
+
* @see StackFrameInterface
|
|
156
115
|
* @see createDefaultFrame
|
|
157
116
|
*
|
|
158
117
|
* @since 2.1.0
|
|
159
118
|
*/
|
|
160
|
-
export declare function parseV8StackLine(line: string):
|
|
119
|
+
export declare function parseV8StackLine(line: string): StackFrameInterface;
|
|
161
120
|
/**
|
|
162
|
-
* Parses a SpiderMonkey JavaScript engine stack trace line into a structured
|
|
121
|
+
* Parses a SpiderMonkey JavaScript engine stack trace line into a structured StackFrameInterface object
|
|
163
122
|
*
|
|
164
123
|
* @param line - The stack trace line to parse
|
|
165
|
-
* @returns A
|
|
124
|
+
* @returns A StackFrameInterface object containing the parsed information
|
|
166
125
|
*
|
|
167
126
|
* @remarks
|
|
168
127
|
* Handles both standard SpiderMonkey stack frames and eval/Function-generated stack frames
|
|
@@ -177,17 +136,17 @@ export declare function parseV8StackLine(line: string): StackFrame;
|
|
|
177
136
|
* parseSpiderMonkeyStackLine("evalFn@/source.js line 5 > eval:1:5");
|
|
178
137
|
* ```
|
|
179
138
|
*
|
|
180
|
-
* @see
|
|
139
|
+
* @see StackFrameInterface
|
|
181
140
|
* @see createDefaultFrame
|
|
182
141
|
*
|
|
183
142
|
* @since 2.1.0
|
|
184
143
|
*/
|
|
185
|
-
export declare function parseSpiderMonkeyStackLine(line: string):
|
|
144
|
+
export declare function parseSpiderMonkeyStackLine(line: string): StackFrameInterface;
|
|
186
145
|
/**
|
|
187
|
-
* Parses a JavaScriptCore engine stack trace line into a structured
|
|
146
|
+
* Parses a JavaScriptCore engine stack trace line into a structured StackFrameInterface object
|
|
188
147
|
*
|
|
189
148
|
* @param line - The stack trace line to parse
|
|
190
|
-
* @returns A
|
|
149
|
+
* @returns A StackFrameInterface object containing the parsed information
|
|
191
150
|
*
|
|
192
151
|
* @remarks
|
|
193
152
|
* Handles both standard JavaScriptCore stack frames and eval-generated stack frames.
|
|
@@ -202,18 +161,18 @@ export declare function parseSpiderMonkeyStackLine(line: string): StackFrame;
|
|
|
202
161
|
* parseJavaScriptCoreStackLine("eval code@");
|
|
203
162
|
* ```
|
|
204
163
|
*
|
|
205
|
-
* @see
|
|
164
|
+
* @see StackFrameInterface
|
|
206
165
|
* @see createDefaultFrame
|
|
207
166
|
*
|
|
208
167
|
* @since 2.1.0
|
|
209
168
|
*/
|
|
210
|
-
export declare function parseJavaScriptCoreStackLine(line: string):
|
|
169
|
+
export declare function parseJavaScriptCoreStackLine(line: string): StackFrameInterface;
|
|
211
170
|
/**
|
|
212
171
|
* Parses a stack trace line based on the detected JavaScript engine
|
|
213
172
|
*
|
|
214
173
|
* @param line - The stack trace line to parse
|
|
215
174
|
* @param engine - The JavaScript engine type that generated the stack trace
|
|
216
|
-
* @returns A
|
|
175
|
+
* @returns A StackFrameInterface object containing the parsed information
|
|
217
176
|
*
|
|
218
177
|
* @remarks
|
|
219
178
|
* Delegates to the appropriate parsing function based on the JavaScript engine.
|
|
@@ -232,12 +191,41 @@ export declare function parseJavaScriptCoreStackLine(line: string): StackFrame;
|
|
|
232
191
|
*
|
|
233
192
|
* @since 2.1.0
|
|
234
193
|
*/
|
|
235
|
-
export declare function parseStackLine(line: string, engine: JSEngines):
|
|
194
|
+
export declare function parseStackLine(line: string, engine: JSEngines): StackFrameInterface;
|
|
195
|
+
/**
|
|
196
|
+
* Extracts the stack frames from a full stack trace string, removing the error message line.
|
|
197
|
+
*
|
|
198
|
+
* @param stack - The full error stack string, possibly including the error message
|
|
199
|
+
* @returns The stack trace starting from the first stack frame, or an empty string if no frames are found
|
|
200
|
+
*
|
|
201
|
+
* @remarks
|
|
202
|
+
* This function scans the stack string for lines matching common stack frame formats,
|
|
203
|
+
* including V8 (`at ...`) and SpiderMonkey/JavaScriptCore (`function@file:line:column`) patterns.
|
|
204
|
+
* It returns only the portion of the stack that contains the frames, discarding the initial
|
|
205
|
+
* error message or any non-stack lines.
|
|
206
|
+
*
|
|
207
|
+
* @example
|
|
208
|
+
* ```ts
|
|
209
|
+
* const stack = `
|
|
210
|
+
* Error: Something went wrong
|
|
211
|
+
* at doSomething (file.js:10:15)
|
|
212
|
+
* at main (file.js:20:5)
|
|
213
|
+
* `;
|
|
214
|
+
*
|
|
215
|
+
* console.log(getStackWithoutMessage(stack));
|
|
216
|
+
* // Output:
|
|
217
|
+
* // at doSomething (file.js:10:15)
|
|
218
|
+
* // at main (file.js:20:5)
|
|
219
|
+
* ```
|
|
220
|
+
*
|
|
221
|
+
* @since 4.0.1
|
|
222
|
+
*/
|
|
223
|
+
export declare function getStackWithoutMessage(stack: string): string;
|
|
236
224
|
/**
|
|
237
225
|
* Parses a complete error stack trace into a structured format
|
|
238
226
|
*
|
|
239
227
|
* @param error - Error object or error message string to parse
|
|
240
|
-
* @returns A
|
|
228
|
+
* @returns A ParsedStackTraceInterface object containing structured stack trace information
|
|
241
229
|
*
|
|
242
230
|
* @remarks
|
|
243
231
|
* Automatically detects the JavaScript engine from the stack format.
|
|
@@ -252,15 +240,68 @@ export declare function parseStackLine(line: string, engine: JSEngines): StackFr
|
|
|
252
240
|
* const parsedStack = parseErrorStack(error);
|
|
253
241
|
* console.log(parsedStack.name); // "Error"
|
|
254
242
|
* console.log(parsedStack.message); // "Something went wrong"
|
|
255
|
-
* console.log(parsedStack.stack); // Array of
|
|
243
|
+
* console.log(parsedStack.stack); // Array of StackFrameInterface objects
|
|
256
244
|
* }
|
|
257
245
|
* ```
|
|
258
246
|
*
|
|
259
|
-
* @see
|
|
260
|
-
* @see
|
|
247
|
+
* @see ParsedStackTraceInterface
|
|
248
|
+
* @see StackFrameInterface
|
|
261
249
|
* @see parseStackLine
|
|
262
250
|
* @see detectJSEngine
|
|
263
251
|
*
|
|
264
252
|
* @since 2.1.0
|
|
265
253
|
*/
|
|
266
|
-
export declare function parseErrorStack(error: Error | string):
|
|
254
|
+
export declare function parseErrorStack(error: Error | string): ParsedStackTraceInterface;
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Interface representing a stack frame in a stack trace.
|
|
258
|
+
*
|
|
259
|
+
* This structure provides detailed information about the location
|
|
260
|
+
* of a specific frame in the stack trace, primarily used in error debugging and stack analysis.
|
|
261
|
+
* It optionally includes information about the line, column, file, function name, and other details
|
|
262
|
+
* about the origin of the code.
|
|
263
|
+
*
|
|
264
|
+
* Properties:
|
|
265
|
+
* - source: The source code relevant to the stack frame.
|
|
266
|
+
* - line: An optional line number in the code associated with this frame.
|
|
267
|
+
* - column: An optional column number in the line associated with this frame.
|
|
268
|
+
* - fileName: The name of the file associated with the frame, if available.
|
|
269
|
+
* - functionName: The name of the function where the stack frame is located, if available.
|
|
270
|
+
* - eval: Indicates if the stack frame originates from an evaluated script.
|
|
271
|
+
* - async: Indicates if the stack frame is part of an asynchronous operation.
|
|
272
|
+
* - native: Indicates if the stack frame is part of native code execution.
|
|
273
|
+
* - constructor: Indicates if the frame is related to an object constructor invocation.
|
|
274
|
+
* - evalOrigin: Optional information about the origin of the code if it resulted from an eval execution,
|
|
275
|
+
* including line number, column number, file name, and function name.
|
|
276
|
+
*
|
|
277
|
+
* @since 3.0.0
|
|
278
|
+
*/
|
|
279
|
+
export interface StackFrameInterface {
|
|
280
|
+
source: string;
|
|
281
|
+
line?: number;
|
|
282
|
+
column?: number;
|
|
283
|
+
fileName?: string;
|
|
284
|
+
functionName?: string;
|
|
285
|
+
eval: boolean;
|
|
286
|
+
async: boolean;
|
|
287
|
+
native: boolean;
|
|
288
|
+
constructor: boolean;
|
|
289
|
+
evalOrigin?: {
|
|
290
|
+
line?: number;
|
|
291
|
+
column?: number;
|
|
292
|
+
fileName?: string;
|
|
293
|
+
functionName?: string;
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Represents a fully parsed error stack trace with structured information
|
|
298
|
+
*
|
|
299
|
+
* @see StackFrameInterface
|
|
300
|
+
* @since 2.1.0
|
|
301
|
+
*/
|
|
302
|
+
export interface ParsedStackTraceInterface {
|
|
303
|
+
name: string;
|
|
304
|
+
message: string;
|
|
305
|
+
stack: StackFrameInterface[];
|
|
306
|
+
rawStack: string;
|
|
307
|
+
}
|
package/package.json
CHANGED
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
7
7
|
"author": "Garefild",
|
|
8
|
-
"version": "
|
|
8
|
+
"version": "4.0.1",
|
|
9
9
|
"license": "Mozilla Public License Version 2.0",
|
|
10
10
|
"description": "A library with a sourcemap parser and TypeScript code formatter for the CLI",
|
|
11
|
-
"homepage": "https://github.
|
|
11
|
+
"homepage": "https://remotex-labs.github.io/xMap/",
|
|
12
12
|
"repository": {
|
|
13
13
|
"type": "git",
|
|
14
14
|
"url": "git+https://github.com/remotex-lab/xMap.git"
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"typescript runner"
|
|
33
33
|
],
|
|
34
34
|
"engines": {
|
|
35
|
-
"node": ">=
|
|
35
|
+
"node": ">=20"
|
|
36
36
|
},
|
|
37
37
|
"typesVersions": {
|
|
38
38
|
"*": {
|
|
@@ -86,19 +86,26 @@
|
|
|
86
86
|
"lint": "xbuild --tc && eslint . -c ./eslint.config.mjs",
|
|
87
87
|
"ci:test": "jest",
|
|
88
88
|
"ci:clean": "rm -rf ./dist",
|
|
89
|
-
"ci:build": "npm run build"
|
|
89
|
+
"ci:build": "npm run build",
|
|
90
|
+
"docs:dev": "vitepress dev docs",
|
|
91
|
+
"docs:build": "vitepress build docs",
|
|
92
|
+
"docs:preview": "vitepress preview docs"
|
|
90
93
|
},
|
|
91
94
|
"devDependencies": {
|
|
92
|
-
"jest": "^
|
|
93
|
-
"eslint": "^9.
|
|
94
|
-
"
|
|
95
|
+
"jest": "^30.0.5",
|
|
96
|
+
"eslint": "^9.28.0",
|
|
97
|
+
"vitepress": "^1.6.4",
|
|
98
|
+
"typescript-eslint": "^8.40.0",
|
|
95
99
|
"eslint-plugin-tsdoc": "^0.4.0",
|
|
96
|
-
"
|
|
97
|
-
"
|
|
98
|
-
"@
|
|
99
|
-
"@
|
|
100
|
+
"vitepress-versioning-plugin": "^1.3.0",
|
|
101
|
+
"eslint-plugin-perfectionist": "^4.15.0",
|
|
102
|
+
"@swc/jest": "^0.2.39",
|
|
103
|
+
"@types/jest": "^30.0.0",
|
|
104
|
+
"@types/node": "^24.3.0",
|
|
105
|
+
"@remotex-labs/xbuild": "^1.6.0"
|
|
100
106
|
},
|
|
101
107
|
"dependencies": {
|
|
102
|
-
"typescript": "^5.
|
|
108
|
+
"typescript": "^5.9.2",
|
|
109
|
+
"@remotex-labs/xansi": "^1.1.1"
|
|
103
110
|
}
|
|
104
111
|
}
|