@visulima/error 4.0.0 → 4.2.0
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/CHANGELOG.md +20 -0
- package/LICENSE.md +27 -0
- package/README.md +129 -4
- package/dist/code-frame/index.cjs +6 -0
- package/dist/code-frame/index.d.cts +7 -0
- package/dist/code-frame/index.d.mts +7 -0
- package/dist/code-frame/index.d.ts +3 -23
- package/dist/code-frame/index.mjs +6 -0
- package/dist/error/index.cjs +1 -0
- package/dist/error/index.d.cts +73 -0
- package/dist/error/index.d.mts +73 -0
- package/dist/error/index.d.ts +44 -2
- package/dist/error/index.mjs +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +13 -0
- package/dist/index.d.mts +13 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.mjs +1 -0
- package/dist/shared/error.B5KA_10i.cjs +18 -0
- package/dist/shared/error.BoX3yBJ9.mjs +18 -0
- package/dist/shared/error.CrVmNoPV.d.cts +25 -0
- package/dist/shared/error.CrVmNoPV.d.mts +25 -0
- package/dist/shared/error.CrVmNoPV.d.ts +25 -0
- package/dist/stacktrace/index.cjs +2 -0
- package/dist/stacktrace/index.d.cts +16 -0
- package/dist/stacktrace/index.d.mts +16 -0
- package/dist/stacktrace/index.mjs +2 -0
- package/package.json +44 -19
- package/dist/chunk-BKLPSU5H.js +0 -10
- package/dist/chunk-BKLPSU5H.js.map +0 -1
- package/dist/chunk-HAVTTG7L.js +0 -7
- package/dist/chunk-HAVTTG7L.js.map +0 -1
- package/dist/chunk-WOVTAVVR.js +0 -6
- package/dist/chunk-WOVTAVVR.js.map +0 -1
- package/dist/code-frame/index.js +0 -3
- package/dist/code-frame/index.js.map +0 -1
- package/dist/error/index.js +0 -3
- package/dist/error/index.js.map +0 -1
- package/dist/index.js +0 -9
- package/dist/index.js.map +0 -1
- package/dist/stacktrace/index.js +0 -3
- package/dist/stacktrace/index.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
## @visulima/error [4.2.0](https://github.com/visulima/visulima/compare/@visulima/error@4.1.0...@visulima/error@4.2.0) (2024-07-02)
|
|
2
|
+
|
|
3
|
+
### Features
|
|
4
|
+
|
|
5
|
+
* **error:** added renderError, added cause to visulima-error ([#449](https://github.com/visulima/visulima/issues/449)) ([4e78638](https://github.com/visulima/visulima/commit/4e7863890ccbc66a1427d4e6fd4c1879cf448b77))
|
|
6
|
+
|
|
7
|
+
### Miscellaneous Chores
|
|
8
|
+
|
|
9
|
+
* updated dev dependencies ([34df456](https://github.com/visulima/visulima/commit/34df4569f2fc074823a406c44a131c8fbae2b147))
|
|
10
|
+
|
|
11
|
+
## @visulima/error [4.1.0](https://github.com/visulima/visulima/compare/@visulima/error@4.0.0...@visulima/error@4.1.0) (2024-07-01)
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* **error:** added new error serialize ([#443](https://github.com/visulima/visulima/issues/443)) ([b6f109b](https://github.com/visulima/visulima/commit/b6f109b108e608e310ec1bc95de7e249763ad095))
|
|
16
|
+
|
|
17
|
+
### Miscellaneous Chores
|
|
18
|
+
|
|
19
|
+
* updated dev dependencies ([c889486](https://github.com/visulima/visulima/commit/c889486f8980741f459b993648c1b6d0815e3d66))
|
|
20
|
+
|
|
1
21
|
## @visulima/error [4.0.0](https://github.com/visulima/visulima/compare/@visulima/error@3.2.11...@visulima/error@4.0.0) (2024-06-16)
|
|
2
22
|
|
|
3
23
|
### ⚠ BREAKING CHANGES
|
package/LICENSE.md
CHANGED
|
@@ -19,3 +19,30 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
21
|
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
<!-- DEPENDENCIES -->
|
|
24
|
+
|
|
25
|
+
# Licenses of bundled dependencies
|
|
26
|
+
The published @visulima/error artifact additionally contains code with the following licenses:
|
|
27
|
+
MIT
|
|
28
|
+
|
|
29
|
+
# Bundled dependencies:
|
|
30
|
+
## is-plain-obj
|
|
31
|
+
License: MIT
|
|
32
|
+
By: Sindre Sorhus
|
|
33
|
+
Repository: sindresorhus/is-plain-obj
|
|
34
|
+
|
|
35
|
+
> MIT License
|
|
36
|
+
>
|
|
37
|
+
> Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
|
38
|
+
>
|
|
39
|
+
> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
40
|
+
>
|
|
41
|
+
> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
42
|
+
>
|
|
43
|
+
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
44
|
+
|
|
45
|
+
<!-- DEPENDENCIES -->
|
|
46
|
+
|
|
47
|
+
<!-- TYPE_DEPENDENCIES -->
|
|
48
|
+
<!-- TYPE_DEPENDENCIES -->
|
package/README.md
CHANGED
|
@@ -206,11 +206,11 @@ Currently supported browsers/platforms:
|
|
|
206
206
|
- Opera (Chromium based)
|
|
207
207
|
|
|
208
208
|
```ts
|
|
209
|
-
import {
|
|
209
|
+
import { parseStacktrace } from "@visulima/error";
|
|
210
210
|
|
|
211
211
|
const error = new Error("My error message");
|
|
212
212
|
|
|
213
|
-
const stack =
|
|
213
|
+
const stack = parseStacktrace(error);
|
|
214
214
|
|
|
215
215
|
console.log(stack);
|
|
216
216
|
|
|
@@ -228,6 +228,128 @@ console.log(stack);
|
|
|
228
228
|
// ];
|
|
229
229
|
```
|
|
230
230
|
|
|
231
|
+
## `serialize` an error object
|
|
232
|
+
|
|
233
|
+
- Ensures errors are safe to serialize with JSON
|
|
234
|
+
- Can be used as error.toJSON()
|
|
235
|
+
- Deep serialization, including transforming
|
|
236
|
+
- Custom serialization (e.g. YAML or process.send())
|
|
237
|
+
- Keeps both native (TypeError, etc.) and custom error classes
|
|
238
|
+
- Preserves errors' additional properties
|
|
239
|
+
- Can keep constructor's arguments
|
|
240
|
+
- Works recursively with error.cause and AggregateError
|
|
241
|
+
- Buffer properties are replaced with [object Buffer]
|
|
242
|
+
- Circular references are handled.
|
|
243
|
+
- If the input object has a .toJSON() method, then it's called instead of serializing the object's properties.
|
|
244
|
+
- It's up to .toJSON() implementation to handle circular references and enumerability of the properties.
|
|
245
|
+
|
|
246
|
+
```ts
|
|
247
|
+
import { serializeError } from "@visulima/error";
|
|
248
|
+
|
|
249
|
+
const error = new TypeError("example");
|
|
250
|
+
const errorObject = serializeError(error);
|
|
251
|
+
// Plain object: { name: 'TypeError', message: 'example', stack: '...' }
|
|
252
|
+
|
|
253
|
+
const errorString = JSON.stringify(errorObject);
|
|
254
|
+
const newErrorObject = JSON.parse(errorString);
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
## renderError - pretty print an error
|
|
258
|
+
|
|
259
|
+
```ts
|
|
260
|
+
import { renderError } from "@visulima/error";
|
|
261
|
+
|
|
262
|
+
const error = new Error("This is an error message");
|
|
263
|
+
|
|
264
|
+
console.log(renderError(error));
|
|
265
|
+
|
|
266
|
+
// Error: This is an error message
|
|
267
|
+
//
|
|
268
|
+
// at <unknown> file:///home/visulima/visulima/examples/error/node/render-error.js:5
|
|
269
|
+
// 1 | import { renderError } from "@visulima/error";
|
|
270
|
+
// 2 |
|
|
271
|
+
// 3 | const error = new Error("This is an error message");
|
|
272
|
+
// 4 |
|
|
273
|
+
// ❯ 5 | console.log(renderError(new Error("This is an error message")));
|
|
274
|
+
// | ^
|
|
275
|
+
// 6 |
|
|
276
|
+
//
|
|
277
|
+
// at ModuleJob.run node:internal/modules/esm/module_job:195
|
|
278
|
+
// at async ModuleLoader.import node:internal/modules/esm/loader:336
|
|
279
|
+
// at async loadESM node:internal/process/esm_loader:34
|
|
280
|
+
// at async handleMainPromise node:internal/modules/run_main:106
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
#### colorized output
|
|
284
|
+
|
|
285
|
+
Use the `@visulima/colorize`, `chalk` or some other package to colorize the output.
|
|
286
|
+
|
|
287
|
+

|
|
288
|
+
|
|
289
|
+
### API
|
|
290
|
+
|
|
291
|
+
#### error
|
|
292
|
+
|
|
293
|
+
Type: `AggregateError | Error | VisulimaError` \
|
|
294
|
+
The error to render.
|
|
295
|
+
|
|
296
|
+
#### options
|
|
297
|
+
|
|
298
|
+
Type: `object`
|
|
299
|
+
|
|
300
|
+
##### options.color
|
|
301
|
+
|
|
302
|
+
Type: `object` \
|
|
303
|
+
The color options.
|
|
304
|
+
|
|
305
|
+
##### options.cwd
|
|
306
|
+
|
|
307
|
+
Type: `string`
|
|
308
|
+
|
|
309
|
+
The current working directory.
|
|
310
|
+
|
|
311
|
+
##### options.displayShortPath
|
|
312
|
+
|
|
313
|
+
Type: `boolean` \
|
|
314
|
+
Default: `false`
|
|
315
|
+
|
|
316
|
+
Display the short path.
|
|
317
|
+
|
|
318
|
+
##### options.framesMaxLimit
|
|
319
|
+
|
|
320
|
+
Type: `number` \
|
|
321
|
+
Default: `Number.Infinity`
|
|
322
|
+
|
|
323
|
+
The maximum number of frames to display.
|
|
324
|
+
|
|
325
|
+
##### options.hideErrorCauseCodeView
|
|
326
|
+
|
|
327
|
+
Type: `boolean` \
|
|
328
|
+
Default: `false`
|
|
329
|
+
|
|
330
|
+
Hide the error cause code view.
|
|
331
|
+
|
|
332
|
+
##### options.hideErrorCodeView
|
|
333
|
+
|
|
334
|
+
Type: `boolean` \
|
|
335
|
+
Default: `false`
|
|
336
|
+
|
|
337
|
+
Hide the error code view.
|
|
338
|
+
|
|
339
|
+
##### options.hideErrorTitle
|
|
340
|
+
|
|
341
|
+
Type: `boolean` \
|
|
342
|
+
Default: `false`
|
|
343
|
+
|
|
344
|
+
Hide the error title.
|
|
345
|
+
|
|
346
|
+
##### options.hideMessage
|
|
347
|
+
|
|
348
|
+
Type: `boolean` \
|
|
349
|
+
Default: `false`
|
|
350
|
+
|
|
351
|
+
Hide the error message.
|
|
352
|
+
|
|
231
353
|
## Supported Node.js Versions
|
|
232
354
|
|
|
233
355
|
Libraries in this ecosystem make the best effort to track [Node.js’ release schedule](https://github.com/nodejs/release#release-schedule).
|
|
@@ -249,7 +371,6 @@ If you would like to help take a look at the [list of issues](https://github.com
|
|
|
249
371
|
### Related Projects
|
|
250
372
|
|
|
251
373
|
- [baseerr](https://github.com/tjmehta/baseerr): merge another error with additional properties.
|
|
252
|
-
- [callsite-record](https://github.com/inikulin/callsite-record): create a fancy log entries for errors and function call sites.
|
|
253
374
|
- [callsites](https://github.com/sindresorhus/callsites): get callsites from the V8 stack trace API.
|
|
254
375
|
- [explain-error](https://github.com/dominictarr/explain-error): wrap an error with additional explanation.
|
|
255
376
|
- [error-wrapper](https://github.com/spudly/error-wrapper): merges the stack of another error to its own.
|
|
@@ -258,11 +379,15 @@ If you would like to help take a look at the [list of issues](https://github.com
|
|
|
258
379
|
- [clarify](https://github.com/AndreasMadsen/clarify): remove node related stack trace noise.
|
|
259
380
|
- [piotr-szewczyk/stacktrace-parser-node](https://github.com/piotr-szewczyk/stacktrace-parser-node)
|
|
260
381
|
- [pretty-error](https://github.com/AriaMinaei/pretty-error): make the call stacks clear.
|
|
382
|
+
- [node-pretty-exceptions](https://github.com/ahmadnassri/node-pretty-exceptions) - Pretty and more helpful uncaught exceptions, automatically
|
|
383
|
+
- [youch-terminal](https://github.com/poppinss/youch-terminal/tree/develop) - Display youch error message on terminal
|
|
261
384
|
- [ono](https://github.com/bigstickcarpet/ono): allow different types of error to be thrown.
|
|
262
|
-
- [ololog](https://github.com/xpl/ololog): another logger with a similar motivation but only support console.log as its sole transport.
|
|
263
385
|
- [stacktracejs/error-stack-parser](https://github.com/stacktracejs/error-stack-parser)
|
|
264
386
|
- [marvinhagemeister/errorstacks](https://github.com/marvinhagemeister/errorstacks) Tiny library to parse error stack traces
|
|
265
387
|
- [getsentry/sentry-javascript](https://github.com/getsentry/sentry-javascript)
|
|
388
|
+
- [serialize-error](https://github.com/sindresorhus/serialize-error) - Serialize/deserialize an error into a plain object
|
|
389
|
+
- [baseerr](https://github.com/tjmehta/baseerr): merge another error with additional properties.
|
|
390
|
+
- [callsite-record](https://github.com/inikulin/callsite-record) - Create fancy log entries for errors and function call sites
|
|
266
391
|
|
|
267
392
|
## License
|
|
268
393
|
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";var F=Object.defineProperty;var v=(t,e)=>F(t,"name",{value:e,configurable:!0});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var L=Object.defineProperty,P=v((t,e)=>L(t,"name",{value:e,configurable:!0}),"r$1");const S=P(t=>t.replaceAll(/\r\n|\r(?!\n)|\n/gu,`
|
|
2
|
+
`),"normalizeLF"),T=globalThis.process||Object.create(null),O={versions:{}},x=new Proxy(T,{get(t,e){if(e in t)return t[e];if(e in O)return O[e]}});var _=Object.defineProperty,N=v((t,e)=>_(t,"name",{value:e,configurable:!0}),"b");const R=N((t,e,d,n)=>{const f={column:0,line:-1,...t.start},i={...f,...t.end},o=f.line,l=f.column,m=i.line,u=i.column;let g=Math.max(o-(d+1),0),p=Math.min(e.length,m+n);o===-1&&(g=0),m===-1&&(p=e.length);const b=m-o,a={};if(b)for(let r=0;r<=b;r++){const s=r+o;if(!l)a[s]=!0;else if(r===0){const c=e[s-1]?.length;a[s]=[l,(c??0)-l+1]}else if(r===b)a[s]=[0,u];else{const c=e[s-r]?.length;a[s]=[0,c]}}else l===u?a[o]=l?[l,0]:!0:a[o]=[l,(u??0)-(l??0)];return{end:p,markerLines:a,start:g}},"getMarkerLines");var W=Object.defineProperty,$=v((t,e)=>W(t,"name",{value:e,configurable:!0}),"o");const j=x.platform==="win32"&&!x.env?.WT_SESSION?">":"❯",C=$((t,e,d)=>{const n={linesAbove:2,linesBelow:3,prefix:"",showGutter:!0,showLineNumbers:!0,tabWidth:4,...d,color:{gutter:$(r=>r,"gutter"),marker:$(r=>r,"marker"),message:$(r=>r,"message"),...d?.color}},f=e.start&&typeof e.start.column=="number";let i=S(t).split(`
|
|
3
|
+
`);typeof n?.tabWidth=="number"&&(i=i.map(r=>r.replaceAll(" "," ".repeat(n.tabWidth))));const{end:o,markerLines:l,start:m}=R(e,i,n.linesAbove,n.linesBelow),u=String(o).length,{gutter:g,marker:p,message:b}=n.color;let a=i.slice(m,o).map((r,s)=>{const c=m+1+s,h=l[c],k=` ${c}`.slice(-u),M=!l[c+1],y=` ${k}${n.showGutter?" |":""}`;if(h){let A="";if(Array.isArray(h)){const w=r.replaceAll(/[^\t]/g," ").slice(0,Math.max(h[0]-1,0)),E=h[1]||1;A=[`
|
|
4
|
+
`,n.prefix+g(y.replaceAll(/\d/g," "))," ",w,p("^").repeat(E)].join(""),M&&n.message&&(A+=` ${b(n.message)}`)}return[n.prefix+p(j),g(y),r.length>0?` ${r}`:"",A].join("")}return n.prefix+` ${g(y)}${r.length>0?` ${r}`:""}`}).join(`
|
|
5
|
+
`);return n.message&&!f&&(a=n.prefix+`${" ".repeat(u+1)}${n.message}
|
|
6
|
+
${a}`),a},"codeFrame");exports.CODE_FRAME_POINTER=j;exports.codeFrame=C;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { a as CodeFrameNodeLocation, b as CodeFrameOptions } from '../shared/error.CrVmNoPV.cjs';
|
|
2
|
+
export { C as CodeFrameLocation, c as ColorizeMethod } from '../shared/error.CrVmNoPV.cjs';
|
|
3
|
+
|
|
4
|
+
declare const CODE_FRAME_POINTER: string;
|
|
5
|
+
declare const codeFrame: (source: string, loc: CodeFrameNodeLocation, options?: CodeFrameOptions) => string;
|
|
6
|
+
|
|
7
|
+
export { CODE_FRAME_POINTER, CodeFrameNodeLocation, CodeFrameOptions, codeFrame };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { a as CodeFrameNodeLocation, b as CodeFrameOptions } from '../shared/error.CrVmNoPV.mjs';
|
|
2
|
+
export { C as CodeFrameLocation, c as ColorizeMethod } from '../shared/error.CrVmNoPV.mjs';
|
|
3
|
+
|
|
4
|
+
declare const CODE_FRAME_POINTER: string;
|
|
5
|
+
declare const codeFrame: (source: string, loc: CodeFrameNodeLocation, options?: CodeFrameOptions) => string;
|
|
6
|
+
|
|
7
|
+
export { CODE_FRAME_POINTER, CodeFrameNodeLocation, CodeFrameOptions, codeFrame };
|
|
@@ -1,27 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
line: number;
|
|
4
|
-
};
|
|
5
|
-
type CodeFrameNodeLocation = {
|
|
6
|
-
end?: CodeFrameLocation;
|
|
7
|
-
start: CodeFrameLocation;
|
|
8
|
-
};
|
|
9
|
-
type ColorizeMethod = (value: string) => string;
|
|
10
|
-
type CodeFrameOptions = {
|
|
11
|
-
color?: {
|
|
12
|
-
gutter?: ColorizeMethod;
|
|
13
|
-
marker?: ColorizeMethod;
|
|
14
|
-
message?: ColorizeMethod;
|
|
15
|
-
};
|
|
16
|
-
linesAbove?: number;
|
|
17
|
-
linesBelow?: number;
|
|
18
|
-
message?: string;
|
|
19
|
-
showGutter?: boolean;
|
|
20
|
-
showLineNumbers?: boolean;
|
|
21
|
-
tabWidth?: number | false;
|
|
22
|
-
};
|
|
1
|
+
import { a as CodeFrameNodeLocation, b as CodeFrameOptions } from '../shared/error.CrVmNoPV.js';
|
|
2
|
+
export { C as CodeFrameLocation, c as ColorizeMethod } from '../shared/error.CrVmNoPV.js';
|
|
23
3
|
|
|
24
4
|
declare const CODE_FRAME_POINTER: string;
|
|
25
5
|
declare const codeFrame: (source: string, loc: CodeFrameNodeLocation, options?: CodeFrameOptions) => string;
|
|
26
6
|
|
|
27
|
-
export { CODE_FRAME_POINTER,
|
|
7
|
+
export { CODE_FRAME_POINTER, CodeFrameNodeLocation, CodeFrameOptions, codeFrame };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
var M=Object.defineProperty;var v=(t,e)=>M(t,"name",{value:e,configurable:!0});var F=Object.defineProperty,P=v((t,e)=>F(t,"name",{value:e,configurable:!0}),"r$1");const E=P(t=>t.replaceAll(/\r\n|\r(?!\n)|\n/gu,`
|
|
2
|
+
`),"normalizeLF"),S=globalThis.process||Object.create(null),y={versions:{}},k=new Proxy(S,{get(t,e){if(e in t)return t[e];if(e in y)return y[e]}});var W=Object.defineProperty,N=v((t,e)=>W(t,"name",{value:e,configurable:!0}),"b");const T=N((t,e,h,n)=>{const f={column:0,line:-1,...t.start},i={...f,...t.end},o=f.line,l=f.column,m=i.line,u=i.column;let g=Math.max(o-(h+1),0),p=Math.min(e.length,m+n);o===-1&&(g=0),m===-1&&(p=e.length);const b=m-o,a={};if(b)for(let r=0;r<=b;r++){const s=r+o;if(!l)a[s]=!0;else if(r===0){const c=e[s-1]?.length;a[s]=[l,(c??0)-l+1]}else if(r===b)a[s]=[0,u];else{const c=e[s-r]?.length;a[s]=[0,c]}}else l===u?a[o]=l?[l,0]:!0:a[o]=[l,(u??0)-(l??0)];return{end:p,markerLines:a,start:g}},"getMarkerLines");var _=Object.defineProperty,$=v((t,e)=>_(t,"name",{value:e,configurable:!0}),"o");const B=k.platform==="win32"&&!k.env?.WT_SESSION?">":"❯",G=$((t,e,h)=>{const n={linesAbove:2,linesBelow:3,prefix:"",showGutter:!0,showLineNumbers:!0,tabWidth:4,...h,color:{gutter:$(r=>r,"gutter"),marker:$(r=>r,"marker"),message:$(r=>r,"message"),...h?.color}},f=e.start&&typeof e.start.column=="number";let i=E(t).split(`
|
|
3
|
+
`);typeof n?.tabWidth=="number"&&(i=i.map(r=>r.replaceAll(" "," ".repeat(n.tabWidth))));const{end:o,markerLines:l,start:m}=T(e,i,n.linesAbove,n.linesBelow),u=String(o).length,{gutter:g,marker:p,message:b}=n.color;let a=i.slice(m,o).map((r,s)=>{const c=m+1+s,d=l[c],j=` ${c}`.slice(-u),w=!l[c+1],x=` ${j}${n.showGutter?" |":""}`;if(d){let A="";if(Array.isArray(d)){const L=r.replaceAll(/[^\t]/g," ").slice(0,Math.max(d[0]-1,0)),O=d[1]||1;A=[`
|
|
4
|
+
`,n.prefix+g(x.replaceAll(/\d/g," "))," ",L,p("^").repeat(O)].join(""),w&&n.message&&(A+=` ${b(n.message)}`)}return[n.prefix+p(B),g(x),r.length>0?` ${r}`:"",A].join("")}return n.prefix+` ${g(x)}${r.length>0?` ${r}`:""}`}).join(`
|
|
5
|
+
`);return n.message&&!f&&(a=n.prefix+`${" ".repeat(u+1)}${n.message}
|
|
6
|
+
${a}`),a},"codeFrame");export{B as CODE_FRAME_POINTER,G as codeFrame};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../shared/error.B5KA_10i.cjs");exports.VisulimaError=r.VisulimaError;exports.getErrorCauses=r.i;exports.isVisulimaError=r.isVisulimaError;exports.renderError=r.renderError;exports.serializeError=r.serialize;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { b as CodeFrameOptions, c as ColorizeMethod } from '../shared/error.CrVmNoPV.cjs';
|
|
2
|
+
|
|
3
|
+
declare const getErrorCauses: <E = unknown>(error: E) => E[];
|
|
4
|
+
|
|
5
|
+
interface ErrorProperties {
|
|
6
|
+
cause?: Error | unknown;
|
|
7
|
+
hint?: ErrorHint;
|
|
8
|
+
location?: ErrorLocation;
|
|
9
|
+
message?: string;
|
|
10
|
+
name: string;
|
|
11
|
+
stack?: string;
|
|
12
|
+
title?: string;
|
|
13
|
+
}
|
|
14
|
+
interface ErrorLocation {
|
|
15
|
+
column?: number;
|
|
16
|
+
file?: string;
|
|
17
|
+
line?: number;
|
|
18
|
+
}
|
|
19
|
+
type ErrorHint = string[] | string;
|
|
20
|
+
|
|
21
|
+
declare const isVisulimaError: (error: unknown) => error is VisulimaError;
|
|
22
|
+
declare class VisulimaError extends Error {
|
|
23
|
+
loc: ErrorLocation | undefined;
|
|
24
|
+
title: string | undefined;
|
|
25
|
+
hint: ErrorHint | undefined;
|
|
26
|
+
type: string;
|
|
27
|
+
constructor({ cause, hint, location, message, name, stack, title }: ErrorProperties);
|
|
28
|
+
setLocation(location: ErrorLocation): void;
|
|
29
|
+
setName(name: string): void;
|
|
30
|
+
setMessage(message: string): void;
|
|
31
|
+
setHint(hint: ErrorHint): void;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
type Options$1 = Omit<CodeFrameOptions, "message | prefix"> & {
|
|
35
|
+
color: CodeFrameOptions["color"] & {
|
|
36
|
+
fileLine: ColorizeMethod;
|
|
37
|
+
hint: ColorizeMethod;
|
|
38
|
+
method: ColorizeMethod;
|
|
39
|
+
title: ColorizeMethod;
|
|
40
|
+
};
|
|
41
|
+
cwd: string;
|
|
42
|
+
displayShortPath: boolean;
|
|
43
|
+
framesMaxLimit: number;
|
|
44
|
+
hideErrorCauseCodeView: boolean;
|
|
45
|
+
hideErrorCodeView: boolean;
|
|
46
|
+
hideErrorErrorsCodeView: boolean;
|
|
47
|
+
hideErrorTitle: boolean;
|
|
48
|
+
hideMessage: boolean;
|
|
49
|
+
indentation: number | "\t";
|
|
50
|
+
};
|
|
51
|
+
declare const renderError: (error: AggregateError | Error | VisulimaError, options?: Partial<Options$1>) => string;
|
|
52
|
+
|
|
53
|
+
type SerializedError<ErrorType = Error> = Record<PropertyKey, unknown> & {
|
|
54
|
+
aggregateErrors?: SerializedError<ErrorType>[];
|
|
55
|
+
cause?: unknown;
|
|
56
|
+
code?: string;
|
|
57
|
+
message: string;
|
|
58
|
+
name: string;
|
|
59
|
+
raw?: ErrorType;
|
|
60
|
+
stack?: string;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
interface JsonError extends Error {
|
|
64
|
+
toJSON: () => SerializedError;
|
|
65
|
+
}
|
|
66
|
+
type Options = {
|
|
67
|
+
exclude?: string[];
|
|
68
|
+
maxDepth?: number;
|
|
69
|
+
useToJSON?: boolean;
|
|
70
|
+
};
|
|
71
|
+
declare const serialize: (error: AggregateError | Error | JsonError, options?: Options) => SerializedError;
|
|
72
|
+
|
|
73
|
+
export { type ErrorHint, type ErrorLocation, type ErrorProperties, type Options as ErrorWithCauseSerializerOptions, type Options$1 as RenderErrorOptions, type SerializedError, VisulimaError, getErrorCauses, isVisulimaError, renderError, serialize as serializeError };
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { b as CodeFrameOptions, c as ColorizeMethod } from '../shared/error.CrVmNoPV.mjs';
|
|
2
|
+
|
|
3
|
+
declare const getErrorCauses: <E = unknown>(error: E) => E[];
|
|
4
|
+
|
|
5
|
+
interface ErrorProperties {
|
|
6
|
+
cause?: Error | unknown;
|
|
7
|
+
hint?: ErrorHint;
|
|
8
|
+
location?: ErrorLocation;
|
|
9
|
+
message?: string;
|
|
10
|
+
name: string;
|
|
11
|
+
stack?: string;
|
|
12
|
+
title?: string;
|
|
13
|
+
}
|
|
14
|
+
interface ErrorLocation {
|
|
15
|
+
column?: number;
|
|
16
|
+
file?: string;
|
|
17
|
+
line?: number;
|
|
18
|
+
}
|
|
19
|
+
type ErrorHint = string[] | string;
|
|
20
|
+
|
|
21
|
+
declare const isVisulimaError: (error: unknown) => error is VisulimaError;
|
|
22
|
+
declare class VisulimaError extends Error {
|
|
23
|
+
loc: ErrorLocation | undefined;
|
|
24
|
+
title: string | undefined;
|
|
25
|
+
hint: ErrorHint | undefined;
|
|
26
|
+
type: string;
|
|
27
|
+
constructor({ cause, hint, location, message, name, stack, title }: ErrorProperties);
|
|
28
|
+
setLocation(location: ErrorLocation): void;
|
|
29
|
+
setName(name: string): void;
|
|
30
|
+
setMessage(message: string): void;
|
|
31
|
+
setHint(hint: ErrorHint): void;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
type Options$1 = Omit<CodeFrameOptions, "message | prefix"> & {
|
|
35
|
+
color: CodeFrameOptions["color"] & {
|
|
36
|
+
fileLine: ColorizeMethod;
|
|
37
|
+
hint: ColorizeMethod;
|
|
38
|
+
method: ColorizeMethod;
|
|
39
|
+
title: ColorizeMethod;
|
|
40
|
+
};
|
|
41
|
+
cwd: string;
|
|
42
|
+
displayShortPath: boolean;
|
|
43
|
+
framesMaxLimit: number;
|
|
44
|
+
hideErrorCauseCodeView: boolean;
|
|
45
|
+
hideErrorCodeView: boolean;
|
|
46
|
+
hideErrorErrorsCodeView: boolean;
|
|
47
|
+
hideErrorTitle: boolean;
|
|
48
|
+
hideMessage: boolean;
|
|
49
|
+
indentation: number | "\t";
|
|
50
|
+
};
|
|
51
|
+
declare const renderError: (error: AggregateError | Error | VisulimaError, options?: Partial<Options$1>) => string;
|
|
52
|
+
|
|
53
|
+
type SerializedError<ErrorType = Error> = Record<PropertyKey, unknown> & {
|
|
54
|
+
aggregateErrors?: SerializedError<ErrorType>[];
|
|
55
|
+
cause?: unknown;
|
|
56
|
+
code?: string;
|
|
57
|
+
message: string;
|
|
58
|
+
name: string;
|
|
59
|
+
raw?: ErrorType;
|
|
60
|
+
stack?: string;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
interface JsonError extends Error {
|
|
64
|
+
toJSON: () => SerializedError;
|
|
65
|
+
}
|
|
66
|
+
type Options = {
|
|
67
|
+
exclude?: string[];
|
|
68
|
+
maxDepth?: number;
|
|
69
|
+
useToJSON?: boolean;
|
|
70
|
+
};
|
|
71
|
+
declare const serialize: (error: AggregateError | Error | JsonError, options?: Options) => SerializedError;
|
|
72
|
+
|
|
73
|
+
export { type ErrorHint, type ErrorLocation, type ErrorProperties, type Options as ErrorWithCauseSerializerOptions, type Options$1 as RenderErrorOptions, type SerializedError, VisulimaError, getErrorCauses, isVisulimaError, renderError, serialize as serializeError };
|
package/dist/error/index.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import { b as CodeFrameOptions, c as ColorizeMethod } from '../shared/error.CrVmNoPV.js';
|
|
2
|
+
|
|
1
3
|
declare const getErrorCauses: <E = unknown>(error: E) => E[];
|
|
2
4
|
|
|
3
5
|
interface ErrorProperties {
|
|
6
|
+
cause?: Error | unknown;
|
|
4
7
|
hint?: ErrorHint;
|
|
5
8
|
location?: ErrorLocation;
|
|
6
9
|
message?: string;
|
|
@@ -21,11 +24,50 @@ declare class VisulimaError extends Error {
|
|
|
21
24
|
title: string | undefined;
|
|
22
25
|
hint: ErrorHint | undefined;
|
|
23
26
|
type: string;
|
|
24
|
-
constructor(
|
|
27
|
+
constructor({ cause, hint, location, message, name, stack, title }: ErrorProperties);
|
|
25
28
|
setLocation(location: ErrorLocation): void;
|
|
26
29
|
setName(name: string): void;
|
|
27
30
|
setMessage(message: string): void;
|
|
28
31
|
setHint(hint: ErrorHint): void;
|
|
29
32
|
}
|
|
30
33
|
|
|
31
|
-
|
|
34
|
+
type Options$1 = Omit<CodeFrameOptions, "message | prefix"> & {
|
|
35
|
+
color: CodeFrameOptions["color"] & {
|
|
36
|
+
fileLine: ColorizeMethod;
|
|
37
|
+
hint: ColorizeMethod;
|
|
38
|
+
method: ColorizeMethod;
|
|
39
|
+
title: ColorizeMethod;
|
|
40
|
+
};
|
|
41
|
+
cwd: string;
|
|
42
|
+
displayShortPath: boolean;
|
|
43
|
+
framesMaxLimit: number;
|
|
44
|
+
hideErrorCauseCodeView: boolean;
|
|
45
|
+
hideErrorCodeView: boolean;
|
|
46
|
+
hideErrorErrorsCodeView: boolean;
|
|
47
|
+
hideErrorTitle: boolean;
|
|
48
|
+
hideMessage: boolean;
|
|
49
|
+
indentation: number | "\t";
|
|
50
|
+
};
|
|
51
|
+
declare const renderError: (error: AggregateError | Error | VisulimaError, options?: Partial<Options$1>) => string;
|
|
52
|
+
|
|
53
|
+
type SerializedError<ErrorType = Error> = Record<PropertyKey, unknown> & {
|
|
54
|
+
aggregateErrors?: SerializedError<ErrorType>[];
|
|
55
|
+
cause?: unknown;
|
|
56
|
+
code?: string;
|
|
57
|
+
message: string;
|
|
58
|
+
name: string;
|
|
59
|
+
raw?: ErrorType;
|
|
60
|
+
stack?: string;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
interface JsonError extends Error {
|
|
64
|
+
toJSON: () => SerializedError;
|
|
65
|
+
}
|
|
66
|
+
type Options = {
|
|
67
|
+
exclude?: string[];
|
|
68
|
+
maxDepth?: number;
|
|
69
|
+
useToJSON?: boolean;
|
|
70
|
+
};
|
|
71
|
+
declare const serialize: (error: AggregateError | Error | JsonError, options?: Options) => SerializedError;
|
|
72
|
+
|
|
73
|
+
export { type ErrorHint, type ErrorLocation, type ErrorProperties, type Options as ErrorWithCauseSerializerOptions, type Options$1 as RenderErrorOptions, type SerializedError, VisulimaError, getErrorCauses, isVisulimaError, renderError, serialize as serializeError };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{V as a,i,a as e,r as o,s as E}from"../shared/error.BoX3yBJ9.mjs";export{a as VisulimaError,i as getErrorCauses,e as isVisulimaError,o as renderError,E as serializeError};
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var y=Object.defineProperty;var c=(r,e)=>y(r,"name",{value:e,configurable:!0});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("./code-frame/index.cjs"),o=require("./shared/error.B5KA_10i.cjs"),E=require("./stacktrace/index.cjs");var d=Object.defineProperty,s=c((r,e)=>d(r,"name",{value:e,configurable:!0}),"l");const u=s((r,e)=>{let n=0,t=e.length-2;for(;n<t;){const i=n+(t-n>>1);if(r<e[i])t=i-1;else if(r>=e[i+1])n=i+1;else{n=i;break}}return n},"binarySearch"),f=s(r=>r.split(/\n|\r(?!\n)/).reduce((e,n)=>(e.push(e.at(-1)+n.length+1),e),[0]),"getLineStartIndexes"),g=s((r,e,n)=>{const t=n?.skipChecks??!1;if(!t&&(!Array.isArray(r)&&typeof r!="string"||(typeof r=="string"||Array.isArray(r))&&r.length===0))return{column:0,line:0};if(!t&&(typeof e!="number"||typeof r=="string"&&e>=r.length||Array.isArray(r)&&e+1>=r.at(-1)))return{column:0,line:0};if(typeof r=="string"){const a=f(r),l=u(e,a);return{column:e-a[l]+1,line:l+1}}const i=u(e,r);return{column:e-r[i]+1,line:i+1}},"indexToLineColumn"),p=g;exports.CODE_FRAME_POINTER=m.CODE_FRAME_POINTER;exports.codeFrame=m.codeFrame;exports.VisulimaError=o.VisulimaError;exports.getErrorCauses=o.i;exports.isVisulimaError=o.isVisulimaError;exports.renderError=o.renderError;exports.serializeError=o.serialize;exports.parseStacktrace=E.parseStacktrace;exports.indexToLineColumn=p;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { CODE_FRAME_POINTER, codeFrame } from './code-frame/index.cjs';
|
|
2
|
+
export { ErrorHint, ErrorLocation, ErrorProperties, ErrorWithCauseSerializerOptions, RenderErrorOptions, SerializedError, VisulimaError, getErrorCauses, isVisulimaError, renderError, serializeError } from './error/index.cjs';
|
|
3
|
+
export { Trace, TraceType, parseStacktrace } from './stacktrace/index.cjs';
|
|
4
|
+
export { C as CodeFrameLocation, a as CodeFrameNodeLocation, b as CodeFrameOptions, c as ColorizeMethod } from './shared/error.CrVmNoPV.cjs';
|
|
5
|
+
|
|
6
|
+
declare const indexToLineColumn: (input: number[] | string, index: number, options?: {
|
|
7
|
+
skipChecks: boolean;
|
|
8
|
+
}) => {
|
|
9
|
+
column: number;
|
|
10
|
+
line: number;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export { indexToLineColumn };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { CODE_FRAME_POINTER, codeFrame } from './code-frame/index.mjs';
|
|
2
|
+
export { ErrorHint, ErrorLocation, ErrorProperties, ErrorWithCauseSerializerOptions, RenderErrorOptions, SerializedError, VisulimaError, getErrorCauses, isVisulimaError, renderError, serializeError } from './error/index.mjs';
|
|
3
|
+
export { Trace, TraceType, parseStacktrace } from './stacktrace/index.mjs';
|
|
4
|
+
export { C as CodeFrameLocation, a as CodeFrameNodeLocation, b as CodeFrameOptions, c as ColorizeMethod } from './shared/error.CrVmNoPV.mjs';
|
|
5
|
+
|
|
6
|
+
declare const indexToLineColumn: (input: number[] | string, index: number, options?: {
|
|
7
|
+
skipChecks: boolean;
|
|
8
|
+
}) => {
|
|
9
|
+
column: number;
|
|
10
|
+
line: number;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export { indexToLineColumn };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export { CODE_FRAME_POINTER,
|
|
2
|
-
export { ErrorHint, ErrorLocation, ErrorProperties, VisulimaError, getErrorCauses, isVisulimaError } from './error/index.js';
|
|
1
|
+
export { CODE_FRAME_POINTER, codeFrame } from './code-frame/index.js';
|
|
2
|
+
export { ErrorHint, ErrorLocation, ErrorProperties, ErrorWithCauseSerializerOptions, RenderErrorOptions, SerializedError, VisulimaError, getErrorCauses, isVisulimaError, renderError, serializeError } from './error/index.js';
|
|
3
3
|
export { Trace, TraceType, parseStacktrace } from './stacktrace/index.js';
|
|
4
|
+
export { C as CodeFrameLocation, a as CodeFrameNodeLocation, b as CodeFrameOptions, c as ColorizeMethod } from './shared/error.CrVmNoPV.js';
|
|
4
5
|
|
|
5
6
|
declare const indexToLineColumn: (input: number[] | string, index: number, options?: {
|
|
6
7
|
skipChecks: boolean;
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var c=Object.defineProperty;var l=(r,e)=>c(r,"name",{value:e,configurable:!0});import{CODE_FRAME_POINTER as h,codeFrame as x}from"./code-frame/index.mjs";import{V as b,i as C,a as k,r as v,s as L}from"./shared/error.BoX3yBJ9.mjs";import{parseStacktrace as S}from"./stacktrace/index.mjs";var f=Object.defineProperty,s=l((r,e)=>f(r,"name",{value:e,configurable:!0}),"l");const u=s((r,e)=>{let n=0,o=e.length-2;for(;n<o;){const t=n+(o-n>>1);if(r<e[t])o=t-1;else if(r>=e[t+1])n=t+1;else{n=t;break}}return n},"binarySearch"),m=s(r=>r.split(/\n|\r(?!\n)/).reduce((e,n)=>(e.push(e.at(-1)+n.length+1),e),[0]),"getLineStartIndexes"),p=s((r,e,n)=>{const o=n?.skipChecks??!1;if(!o&&(!Array.isArray(r)&&typeof r!="string"||(typeof r=="string"||Array.isArray(r))&&r.length===0))return{column:0,line:0};if(!o&&(typeof e!="number"||typeof r=="string"&&e>=r.length||Array.isArray(r)&&e+1>=r.at(-1)))return{column:0,line:0};if(typeof r=="string"){const i=m(r),a=u(e,i);return{column:e-i[a]+1,line:a+1}}const t=u(e,r);return{column:e-r[t]+1,line:t+1}},"indexToLineColumn"),g=p;export{h as CODE_FRAME_POINTER,b as VisulimaError,x as codeFrame,C as getErrorCauses,g as indexToLineColumn,k as isVisulimaError,S as parseStacktrace,v as renderError,L as serializeError};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";var k=Object.defineProperty;var c=(e,t)=>k(e,"name",{value:t,configurable:!0});const C=require("node:util"),g=require("node:fs"),P=require("node:path"),T=require("node:process"),A=require("node:url"),I=require("../code-frame/index.cjs"),E=require("../stacktrace/index.cjs");var L=Object.defineProperty,_=c((e,t)=>L(e,"name",{value:t,configurable:!0}),"a");const F=_(e=>{const t=new Set,r=[];let o=e;for(;o;){if(t.has(o)){console.error(`Circular reference detected in error causes: ${C.inspect(e)}`);break}if(r.push(o),t.add(o),!o.cause)break;o=o.cause}return r},"getErrorCauses"),J=F;var M=Object.defineProperty,a=c((e,t)=>M(e,"name",{value:t,configurable:!0}),"o");const u=a((e,t)=>t===0?"":e===" "?" ".repeat(t):" ".repeat(e*t),"getPrefix"),$=a((e,t)=>{const r=e.replace("async file:","file:");return P.relative(t,r.startsWith("file:")?A.fileURLToPath(r):r)},"getRelativePath"),y=a((e,{color:t,hideErrorTitle:r,indentation:o},i)=>u(o,i)+(r?t.title(e.message):t.title(e.name+": "+e.message))+`
|
|
2
|
+
`,"getMessage"),v=a((e,{color:t,indentation:r},o)=>{if(e.hint===void 0)return;const i=u(r,o);let n="";if(Array.isArray(e.hint))for(const s of e.hint)n+=i+s+`
|
|
3
|
+
`;else n+=i+e.hint;return t.hint(n)},"getHint"),b=a((e,{color:t,cwd:r,displayShortPath:o,indentation:i},n=0)=>{const s=o?$(e.file,r):e.file,{fileLine:l,method:h}=t;return u(i,n)+"at "+(e.methodName?h(e.methodName)+" ":"")+l(s)+":"+l(e.line+"")},"getMainFrame"),w=a((e,{color:t,indentation:r,linesAbove:o,linesBelow:i,showGutter:n,showLineNumbers:s,tabWidth:l},h)=>{if(e.file===void 0)return;const p=e.file.replace("file://","");if(!g.existsSync(p))return;const V=g.readFileSync(p,"utf8");return I.codeFrame(V,{start:{column:e.column,line:e.line}},{color:t,linesAbove:o,linesBelow:i,prefix:u(r,h),showGutter:n,showLineNumbers:s,tabWidth:l})},"getCode"),S=a((e,t,r)=>{if(e.errors.length===0)return;let o=u(t.indentation,r)+`Errors:
|
|
4
|
+
|
|
5
|
+
`,i=!0;for(const n of e.errors)i?i=!1:o+=`
|
|
6
|
+
|
|
7
|
+
`,o+=N(n,{...t,framesMaxLimit:0,hideErrorCodeView:t.hideErrorErrorsCodeView},r+1);return`
|
|
8
|
+
`+o},"getErrors"),O=a((e,t,r)=>{let o=u(t.indentation,r)+`Caused by:
|
|
9
|
+
|
|
10
|
+
`;const i=e.cause;o+=y(i,t,r);const n=E.parseStacktrace(i).shift(),s=v(i,t,r);return s&&(o+=s+`
|
|
11
|
+
`),o+=b(n,t,r),t.hideErrorCauseCodeView||(o+=`
|
|
12
|
+
`+w(n,t,r)),i.cause?o+=`
|
|
13
|
+
`+O(i,t,r+1):i instanceof AggregateError&&(o+=`
|
|
14
|
+
`+S(i,t,r)),`
|
|
15
|
+
`+o},"getCause"),q=a((e,t)=>{const r=e.slice(0,t.framesMaxLimit);return(r.length>0?`
|
|
16
|
+
`:"")+r.map(o=>b(o,t)).join(`
|
|
17
|
+
`)},"getStacktrace"),N=a((e,t,r)=>{const o={cwd:T.cwd(),displayShortPath:!1,framesMaxLimit:Number.POSITIVE_INFINITY,hideErrorCauseCodeView:!1,hideErrorCodeView:!1,hideErrorErrorsCodeView:!1,hideErrorTitle:!1,hideMessage:!1,indentation:4,linesAbove:2,linesBelow:3,showGutter:!0,showLineNumbers:!0,tabWidth:4,...t,color:{fileLine:a(s=>s,"fileLine"),gutter:a(s=>s,"gutter"),hint:a(s=>s,"hint"),marker:a(s=>s,"marker"),message:a(s=>s,"message"),method:a(s=>s,"method"),title:a(s=>s,"title"),...t.color}},i=E.parseStacktrace(e),n=i.shift();return[t.hideMessage?void 0:y(e,o,r),"",v(e,o,r),"",n?b(n,o,r):void 0,n&&!o.hideErrorCodeView?w(n,o,r):void 0,e instanceof AggregateError?S(e,o,r):void 0,e.cause===void 0?void 0:O(e,o,r),i.length>0?q(i,o):void 0].filter(Boolean).join(`
|
|
18
|
+
`)},"internalRenderError"),B=a((e,t={})=>N(e,t,0),"renderError");function D(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}c(D,"isPlainObject");const z=Object.create({},{cause:{enumerable:!0,value:void 0,writable:!0},code:{enumerable:!0,value:void 0,writable:!0},errors:{enumerable:!0,value:void 0,writable:!0},message:{enumerable:!0,value:void 0,writable:!0},name:{enumerable:!0,value:void 0,writable:!0},stack:{enumerable:!0,value:void 0,writable:!0}});var W=Object.defineProperty,d=c((e,t)=>W(e,"name",{value:t,configurable:!0}),"c");const m=new WeakSet,G=d(e=>{m.add(e);const t=e.toJSON();return m.delete(e),t},"toJSON"),j=d((e,t,r,o)=>{if(e&&e instanceof Uint8Array&&e.constructor.name==="Buffer")return"[object Buffer]";if(e!==null&&typeof e=="object"&&typeof e.pipe=="function")return"[object Stream]";if(e instanceof Error)return t.includes(e)?"[Circular]":(r+=1,f(e,o,t,r));if(o.useToJSON&&typeof e.toJSON=="function")return e.toJSON();if(typeof e=="object"&&e instanceof Date)return e.toISOString();if(typeof e=="function")return"[Function: "+(e.name||"anonymous")+"]";if(D(e)){if(r+=1,o.maxDepth&&r>=o.maxDepth)return{};const i={};for(const n in e)i[n]=j(e[n],t,r,o);return i}try{return e}catch{return"[Not Available]"}},"serializeValue"),f=d((e,t,r,o)=>{if(r.push(e),t.maxDepth===0)return{};if(t.useToJSON&&typeof e.toJSON=="function"&&!m.has(e))return G(e);const i=Object.create(z);if(i.name=Object.prototype.toString.call(e.constructor)==="[object Function]"?e.constructor.name:e.name,i.message=e.message,i.stack=e.stack,Array.isArray(e.errors)){const n=[];for(const s of e.errors){if(!(s instanceof Error))throw new TypeError("All errors in the 'errors' property must be instances of Error");if(r.includes(s))return i.errors=[],i;n.push(f(s,t,r,o))}i.errors=n}e.cause instanceof Error&&!r.includes(e.cause)&&(i.cause=f(e.cause,t,r,o));for(const n in e)if(i[n]===void 0){const s=e[n];i[n]=j(s,r,o,t)}if(Array.isArray(t.exclude)&&t.exclude.length>0)for(const n of t.exclude)try{delete i[n]}catch{}return i},"_serialize"),R=d((e,t={})=>f(e,{exclude:t.exclude??[],maxDepth:t.maxDepth??Number.POSITIVE_INFINITY,useToJSON:t.useToJSON??!1},[],0),"serialize");var H=Object.defineProperty,x=c((e,t)=>H(e,"name",{value:t,configurable:!0}),"t");const U=x(e=>e instanceof Error&&e.type==="VisulimaError","isVisulimaError");class Y extends Error{static{c(this,"VisulimaError")}static{x(this,"VisulimaError")}loc;title;hint;type="VisulimaError";constructor({cause:t,hint:r,location:o,message:i,name:n,stack:s,title:l}){super(i,{cause:t}),this.title=l,this.name=n,this.stack=s??this.stack,this.loc=o,this.hint=r,Error.captureStackTrace(this,this.constructor)}setLocation(t){this.loc=t}setName(t){this.name=t}setMessage(t){this.message=t}setHint(t){this.hint=t}}exports.VisulimaError=Y;exports.i=J;exports.isVisulimaError=U;exports.renderError=B;exports.serialize=R;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
var V=Object.defineProperty;var c=(e,t)=>V(e,"name",{value:t,configurable:!0});import{inspect as C}from"node:util";import{existsSync as P,readFileSync as T}from"node:fs";import{relative as k}from"node:path";import{cwd as A}from"node:process";import{fileURLToPath as I}from"node:url";import{codeFrame as L}from"../code-frame/index.mjs";import{parseStacktrace as g}from"../stacktrace/index.mjs";var J=Object.defineProperty,$=c((e,t)=>J(e,"name",{value:t,configurable:!0}),"a");const F=$(e=>{const t=new Set,r=[];let o=e;for(;o;){if(t.has(o)){console.error(`Circular reference detected in error causes: ${C(e)}`);break}if(r.push(o),t.add(o),!o.cause)break;o=o.cause}return r},"getErrorCauses"),ee=F;var M=Object.defineProperty,a=c((e,t)=>M(e,"name",{value:t,configurable:!0}),"o");const u=a((e,t)=>t===0?"":e===" "?" ".repeat(t):" ".repeat(e*t),"getPrefix"),B=a((e,t)=>{const r=e.replace("async file:","file:");return k(t,r.startsWith("file:")?I(r):r)},"getRelativePath"),y=a((e,{color:t,hideErrorTitle:r,indentation:o},i)=>u(o,i)+(r?t.title(e.message):t.title(e.name+": "+e.message))+`
|
|
2
|
+
`,"getMessage"),E=a((e,{color:t,indentation:r},o)=>{if(e.hint===void 0)return;const i=u(r,o);let n="";if(Array.isArray(e.hint))for(const s of e.hint)n+=i+s+`
|
|
3
|
+
`;else n+=i+e.hint;return t.hint(n)},"getHint"),p=a((e,{color:t,cwd:r,displayShortPath:o,indentation:i},n=0)=>{const s=o?B(e.file,r):e.file,{fileLine:l,method:d}=t;return u(i,n)+"at "+(e.methodName?d(e.methodName)+" ":"")+l(s)+":"+l(e.line+"")},"getMainFrame"),v=a((e,{color:t,indentation:r,linesAbove:o,linesBelow:i,showGutter:n,showLineNumbers:s,tabWidth:l},d)=>{if(e.file===void 0)return;const b=e.file.replace("file://","");if(!P(b))return;const x=T(b,"utf8");return L(x,{start:{column:e.column,line:e.line}},{color:t,linesAbove:o,linesBelow:i,prefix:u(r,d),showGutter:n,showLineNumbers:s,tabWidth:l})},"getCode"),w=a((e,t,r)=>{if(e.errors.length===0)return;let o=u(t.indentation,r)+`Errors:
|
|
4
|
+
|
|
5
|
+
`,i=!0;for(const n of e.errors)i?i=!1:o+=`
|
|
6
|
+
|
|
7
|
+
`,o+=O(n,{...t,framesMaxLimit:0,hideErrorCodeView:t.hideErrorErrorsCodeView},r+1);return`
|
|
8
|
+
`+o},"getErrors"),S=a((e,t,r)=>{let o=u(t.indentation,r)+`Caused by:
|
|
9
|
+
|
|
10
|
+
`;const i=e.cause;o+=y(i,t,r);const n=g(i).shift(),s=E(i,t,r);return s&&(o+=s+`
|
|
11
|
+
`),o+=p(n,t,r),t.hideErrorCauseCodeView||(o+=`
|
|
12
|
+
`+v(n,t,r)),i.cause?o+=`
|
|
13
|
+
`+S(i,t,r+1):i instanceof AggregateError&&(o+=`
|
|
14
|
+
`+w(i,t,r)),`
|
|
15
|
+
`+o},"getCause"),D=a((e,t)=>{const r=e.slice(0,t.framesMaxLimit);return(r.length>0?`
|
|
16
|
+
`:"")+r.map(o=>p(o,t)).join(`
|
|
17
|
+
`)},"getStacktrace"),O=a((e,t,r)=>{const o={cwd:A(),displayShortPath:!1,framesMaxLimit:Number.POSITIVE_INFINITY,hideErrorCauseCodeView:!1,hideErrorCodeView:!1,hideErrorErrorsCodeView:!1,hideErrorTitle:!1,hideMessage:!1,indentation:4,linesAbove:2,linesBelow:3,showGutter:!0,showLineNumbers:!0,tabWidth:4,...t,color:{fileLine:a(s=>s,"fileLine"),gutter:a(s=>s,"gutter"),hint:a(s=>s,"hint"),marker:a(s=>s,"marker"),message:a(s=>s,"message"),method:a(s=>s,"method"),title:a(s=>s,"title"),...t.color}},i=g(e),n=i.shift();return[t.hideMessage?void 0:y(e,o,r),"",E(e,o,r),"",n?p(n,o,r):void 0,n&&!o.hideErrorCodeView?v(n,o,r):void 0,e instanceof AggregateError?w(e,o,r):void 0,e.cause===void 0?void 0:S(e,o,r),i.length>0?D(i,o):void 0].filter(Boolean).join(`
|
|
18
|
+
`)},"internalRenderError"),te=a((e,t={})=>O(e,t,0),"renderError");function W(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}c(W,"isPlainObject");const z=Object.create({},{cause:{enumerable:!0,value:void 0,writable:!0},code:{enumerable:!0,value:void 0,writable:!0},errors:{enumerable:!0,value:void 0,writable:!0},message:{enumerable:!0,value:void 0,writable:!0},name:{enumerable:!0,value:void 0,writable:!0},stack:{enumerable:!0,value:void 0,writable:!0}});var G=Object.defineProperty,m=c((e,t)=>G(e,"name",{value:t,configurable:!0}),"c");const h=new WeakSet,R=m(e=>{h.add(e);const t=e.toJSON();return h.delete(e),t},"toJSON"),N=m((e,t,r,o)=>{if(e&&e instanceof Uint8Array&&e.constructor.name==="Buffer")return"[object Buffer]";if(e!==null&&typeof e=="object"&&typeof e.pipe=="function")return"[object Stream]";if(e instanceof Error)return t.includes(e)?"[Circular]":(r+=1,f(e,o,t,r));if(o.useToJSON&&typeof e.toJSON=="function")return e.toJSON();if(typeof e=="object"&&e instanceof Date)return e.toISOString();if(typeof e=="function")return"[Function: "+(e.name||"anonymous")+"]";if(W(e)){if(r+=1,o.maxDepth&&r>=o.maxDepth)return{};const i={};for(const n in e)i[n]=N(e[n],t,r,o);return i}try{return e}catch{return"[Not Available]"}},"serializeValue"),f=m((e,t,r,o)=>{if(r.push(e),t.maxDepth===0)return{};if(t.useToJSON&&typeof e.toJSON=="function"&&!h.has(e))return R(e);const i=Object.create(z);if(i.name=Object.prototype.toString.call(e.constructor)==="[object Function]"?e.constructor.name:e.name,i.message=e.message,i.stack=e.stack,Array.isArray(e.errors)){const n=[];for(const s of e.errors){if(!(s instanceof Error))throw new TypeError("All errors in the 'errors' property must be instances of Error");if(r.includes(s))return i.errors=[],i;n.push(f(s,t,r,o))}i.errors=n}e.cause instanceof Error&&!r.includes(e.cause)&&(i.cause=f(e.cause,t,r,o));for(const n in e)if(i[n]===void 0){const s=e[n];i[n]=N(s,r,o,t)}if(Array.isArray(t.exclude)&&t.exclude.length>0)for(const n of t.exclude)try{delete i[n]}catch{}return i},"_serialize"),re=m((e,t={})=>f(e,{exclude:t.exclude??[],maxDepth:t.maxDepth??Number.POSITIVE_INFINITY,useToJSON:t.useToJSON??!1},[],0),"serialize");var _=Object.defineProperty,j=c((e,t)=>_(e,"name",{value:t,configurable:!0}),"t");const oe=j(e=>e instanceof Error&&e.type==="VisulimaError","isVisulimaError");class ie extends Error{static{c(this,"VisulimaError")}static{j(this,"VisulimaError")}loc;title;hint;type="VisulimaError";constructor({cause:t,hint:r,location:o,message:i,name:n,stack:s,title:l}){super(i,{cause:t}),this.title=l,this.name=n,this.stack=s??this.stack,this.loc=o,this.hint=r,Error.captureStackTrace(this,this.constructor)}setLocation(t){this.loc=t}setName(t){this.name=t}setMessage(t){this.message=t}setHint(t){this.hint=t}}export{ie as V,oe as a,ee as i,te as r,re as s};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
type CodeFrameLocation = {
|
|
2
|
+
column?: number;
|
|
3
|
+
line: number;
|
|
4
|
+
};
|
|
5
|
+
type CodeFrameNodeLocation = {
|
|
6
|
+
end?: CodeFrameLocation;
|
|
7
|
+
start: CodeFrameLocation;
|
|
8
|
+
};
|
|
9
|
+
type ColorizeMethod = (value: string) => string;
|
|
10
|
+
type CodeFrameOptions = {
|
|
11
|
+
color?: {
|
|
12
|
+
gutter?: ColorizeMethod;
|
|
13
|
+
marker?: ColorizeMethod;
|
|
14
|
+
message?: ColorizeMethod;
|
|
15
|
+
};
|
|
16
|
+
linesAbove?: number;
|
|
17
|
+
linesBelow?: number;
|
|
18
|
+
message?: string;
|
|
19
|
+
prefix?: string;
|
|
20
|
+
showGutter?: boolean;
|
|
21
|
+
showLineNumbers?: boolean;
|
|
22
|
+
tabWidth?: number | false;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type { CodeFrameLocation as C, CodeFrameNodeLocation as a, CodeFrameOptions as b, ColorizeMethod as c };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
type CodeFrameLocation = {
|
|
2
|
+
column?: number;
|
|
3
|
+
line: number;
|
|
4
|
+
};
|
|
5
|
+
type CodeFrameNodeLocation = {
|
|
6
|
+
end?: CodeFrameLocation;
|
|
7
|
+
start: CodeFrameLocation;
|
|
8
|
+
};
|
|
9
|
+
type ColorizeMethod = (value: string) => string;
|
|
10
|
+
type CodeFrameOptions = {
|
|
11
|
+
color?: {
|
|
12
|
+
gutter?: ColorizeMethod;
|
|
13
|
+
marker?: ColorizeMethod;
|
|
14
|
+
message?: ColorizeMethod;
|
|
15
|
+
};
|
|
16
|
+
linesAbove?: number;
|
|
17
|
+
linesBelow?: number;
|
|
18
|
+
message?: string;
|
|
19
|
+
prefix?: string;
|
|
20
|
+
showGutter?: boolean;
|
|
21
|
+
showLineNumbers?: boolean;
|
|
22
|
+
tabWidth?: number | false;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type { CodeFrameLocation as C, CodeFrameNodeLocation as a, CodeFrameOptions as b, ColorizeMethod as c };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
type CodeFrameLocation = {
|
|
2
|
+
column?: number;
|
|
3
|
+
line: number;
|
|
4
|
+
};
|
|
5
|
+
type CodeFrameNodeLocation = {
|
|
6
|
+
end?: CodeFrameLocation;
|
|
7
|
+
start: CodeFrameLocation;
|
|
8
|
+
};
|
|
9
|
+
type ColorizeMethod = (value: string) => string;
|
|
10
|
+
type CodeFrameOptions = {
|
|
11
|
+
color?: {
|
|
12
|
+
gutter?: ColorizeMethod;
|
|
13
|
+
marker?: ColorizeMethod;
|
|
14
|
+
message?: ColorizeMethod;
|
|
15
|
+
};
|
|
16
|
+
linesAbove?: number;
|
|
17
|
+
linesBelow?: number;
|
|
18
|
+
message?: string;
|
|
19
|
+
prefix?: string;
|
|
20
|
+
showGutter?: boolean;
|
|
21
|
+
showLineNumbers?: boolean;
|
|
22
|
+
tabWidth?: number | false;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type { CodeFrameLocation as C, CodeFrameNodeLocation as a, CodeFrameOptions as b, ColorizeMethod as c };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var x=Object.defineProperty;var v=(i,e)=>x(i,"name",{value:e,configurable:!0});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var N=Object.defineProperty,d=v((i,e)=>N(i,"name",{value:e,configurable:!0}),"u");const u=d((i,...e)=>{process.env.DEBUG&&String(process.env.DEBUG)==="true"&&console.debug(`error:parse-stacktrace: ${i}`,...e)},"debugLog"),f="<unknown>",g=/^.*?\s*at\s(?:(.+?\)(?:\s\[.+\])?|\(?.*?)\s?\((?:address\sat\s)?)?(?:async\s)?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,h=/\((\S+)\),\s(<[^>]+>)?:(\d+)?:(\d+)?\)?/,S=/(.*?):(\d+):(\d+)(\s<-\s(.+):(\d+):(\d+))?/,b=/(eval)\sat\s(<anonymous>)\s\((.*)\)?:(\d+)?:(\d+)\),\s*(<anonymous>)?:(\d+)?:(\d+)/,k=/^\s*in\s(?:([^\\/]+(?:\s\[as\s\S+\])?)\s\(?)?\(at?\s?(.*?):(\d+)(?::(\d+))?\)?\s*$/,w=/in\s(.*)\s\(at\s(.+)\)\sat/,O=/^(?:.*@)?(.*):(\d+):(\d+)$/,J=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. \/=]+)(?::(\d+))?(?::(\d+))?\s*$/i,E=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,A=/(\S[^\s[]*\[.*\]|.*?)@(.*):(\d+):(\d+)/,p=/\(error: (.*)\)/,y=d((i,e)=>{const n=i.includes("safari-extension"),o=i.includes("safari-web-extension");return n||o?[i.includes("@")?i.split("@")[0]:f,n?`safari-extension:${e}`:`safari-web-extension:${e}`]:[i,e]},"extractSafariExtensionDetails"),$=d((i,e)=>{const n=S.exec(e);n&&(i.file=n[1],i.line=+n[2],i.column=+n[3])},"parseMapped"),G=d(i=>{const e=w.exec(i);if(e){u(`parse nested node error stack line: "${i}"`,`found: ${JSON.stringify(e)}`);const o=e[2].split(":");return{column:o[2]?+o[2]:void 0,file:o[0],line:o[1]?+o[1]:void 0,methodName:e[1]||f,raw:i,type:void 0}}const n=k.exec(i);if(n){u(`parse node error stack line: "${i}"`,`found: ${JSON.stringify(n)}`);const o={column:n[4]?+n[4]:void 0,file:n[2]?n[2].replace(/at\s/,""):void 0,line:n[3]?+n[3]:void 0,methodName:n[1]||f,raw:i,type:i.startsWith("internal")?"internal":void 0};return $(o,`${n[2]}:${n[3]}:${n[4]}`),o}},"parseNode"),W=d(i=>{const e=g.exec(i);if(e){u(`parse chrome error stack line: "${i}"`,`found: ${JSON.stringify(e)}`);const n=e[2]&&e[2].startsWith("native"),o=e[2]&&e[2].startsWith("eval")||e[1]&&e[1].startsWith("eval");let r,t;if(o){const s=h.exec(i);if(s){const a=/(\S+):(\d+):(\d+)|(\S+):(\d+)$/.exec(s[1]);a?(e[2]=a[4]??a[1],e[3]=a[5]??a[2],e[4]=a[3]):s[2]&&(e[2]=s[1]),s[2]&&(r={column:s[4]?+s[4]:void 0,file:s[2],line:s[3]?+s[3]:void 0,methodName:"eval",raw:i,type:"eval"})}else{const a=b.exec(i);a&&(t={column:a[5]?+a[5]:void 0,file:a[3],line:a[4]?+a[4]:void 0},r={column:a[8]?+a[8]:void 0,file:a[2],line:a[7]?+a[7]:void 0,methodName:"eval",raw:a[0],type:"eval"})}}const[m,c]=y(e[1]?e[1].replace(/^Anonymous function$/,"<anonymous>"):f,e[2]),l={column:e[4]?+e[4]:void 0,evalOrigin:r,file:c,line:e[3]?+e[3]:void 0,methodName:m,raw:i,type:o?"eval":n?"native":void 0};return t?(l.column=t.column,l.file=t.file,l.line=t.line):$(l,`${c}:${e[3]}:${e[4]}`),l}},"parseChromium"),j=d((i,e)=>{const n=J.exec(i);if(n){u(`parse gecko error stack line: "${i}"`,`found: ${JSON.stringify(n)}`);const o=n[3]?.includes(" > eval"),r=o&&n[3]&&E.exec(n[3]);let t;o&&r&&(n[3]=r[1],t={column:n[5]?+n[5]:void 0,file:n[3],line:n[4]?+n[4]:void 0,methodName:"eval",raw:i,type:"eval"},n[4]=r[2]);const[m,c]=y(n[1]?n[1].replace(/^Anonymous function$/,"<anonymous>"):f,n[3]);let l;(e?.type==="safari"||!o&&e?.type==="firefox")&&e.column?l=e.column:!o&&n[5]&&(l=+n[5]);let s;return(e?.type==="safari"||!o&&e?.type==="firefox")&&e.line?s=e.line:n[4]&&(s=+n[4]),{column:l,evalOrigin:t,file:c,line:s,methodName:m,raw:i,type:o?"eval":c.includes("[native code]")?"native":void 0}}},"parseGecko"),D=d((i,e)=>{const n=A.exec(i);if(!(n&&n[2].includes(" > eval"))&&n)return u(`parse firefox error stack line: "${i}"`,`found: ${JSON.stringify(n)}`),{column:n[4]?+n[4]:e?.column??void 0,file:n[2],line:n[3]?+n[3]:e?.line??void 0,methodName:n[1]||f,raw:i,type:void 0}},"parseFirefox"),z=d(i=>{const e=O.exec(i);if(e)return u(`parse react android native error stack line: "${i}"`,`found: ${JSON.stringify(e)}`),{column:e[3]?+e[3]:void 0,file:e[1],line:e[2]?+e[2]:void 0,methodName:f,raw:i,type:void 0}},"parseReactAndroidNative"),B=d((i,e={})=>{const{frameLimit:n=50}=e;let o=(i.stacktrace??i.stack??"").split(`
|
|
2
|
+
`).map(r=>(p.test(r)?r.replace(p,"$1"):r).replace(/^\s+|\s+$/g,"")).filter(r=>!/\S*Error: /.test(r)&&r!=="eval code");return o.length>n&&(o=o.slice(0,n)),o.reduce((r,t,m)=>{if(!t||t.length>1024)return r;let c;if(/^\s*in\s.*/.test(t))c=G(t);else if(/^.*?\s*at\s.*/.test(t))c=W(t);else if(/^.*?\s*@.*|\[native code\]/.test(t)){let l;m===0&&(i.columnNumber||i.lineNumber?l={column:i.columnNumber,line:i.lineNumber,type:"firefox"}:(i.line||i.column)&&(l={column:i.column,line:i.line,type:"safari"})),c=D(t,l)||j(t,l)}else c=z(t);return c?r.push(c):u(`parse error stack line: "${t}"`,"not parser found"),r},[])},"parse"),L=B;exports.parseStacktrace=L;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
type TraceType = "eval" | "internal" | "native" | undefined;
|
|
2
|
+
interface Trace {
|
|
3
|
+
column: number | undefined;
|
|
4
|
+
evalOrigin?: Trace | undefined;
|
|
5
|
+
file: string | undefined;
|
|
6
|
+
line: number | undefined;
|
|
7
|
+
methodName: string | undefined;
|
|
8
|
+
raw: string;
|
|
9
|
+
type?: TraceType | undefined;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
declare const parse: (error: Error, options?: Partial<{
|
|
13
|
+
frameLimit: number;
|
|
14
|
+
}>) => Trace[];
|
|
15
|
+
|
|
16
|
+
export { type Trace, type TraceType, parse as parseStacktrace };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
type TraceType = "eval" | "internal" | "native" | undefined;
|
|
2
|
+
interface Trace {
|
|
3
|
+
column: number | undefined;
|
|
4
|
+
evalOrigin?: Trace | undefined;
|
|
5
|
+
file: string | undefined;
|
|
6
|
+
line: number | undefined;
|
|
7
|
+
methodName: string | undefined;
|
|
8
|
+
raw: string;
|
|
9
|
+
type?: TraceType | undefined;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
declare const parse: (error: Error, options?: Partial<{
|
|
13
|
+
frameLimit: number;
|
|
14
|
+
}>) => Trace[];
|
|
15
|
+
|
|
16
|
+
export { type Trace, type TraceType, parse as parseStacktrace };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var x=Object.defineProperty;var v=(i,e)=>x(i,"name",{value:e,configurable:!0});var N=Object.defineProperty,d=v((i,e)=>N(i,"name",{value:e,configurable:!0}),"u");const u=d((i,...e)=>{process.env.DEBUG&&String(process.env.DEBUG)==="true"&&console.debug(`error:parse-stacktrace: ${i}`,...e)},"debugLog"),f="<unknown>",h=/^.*?\s*at\s(?:(.+?\)(?:\s\[.+\])?|\(?.*?)\s?\((?:address\sat\s)?)?(?:async\s)?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,g=/\((\S+)\),\s(<[^>]+>)?:(\d+)?:(\d+)?\)?/,S=/(.*?):(\d+):(\d+)(\s<-\s(.+):(\d+):(\d+))?/,k=/(eval)\sat\s(<anonymous>)\s\((.*)\)?:(\d+)?:(\d+)\),\s*(<anonymous>)?:(\d+)?:(\d+)/,w=/^\s*in\s(?:([^\\/]+(?:\s\[as\s\S+\])?)\s\(?)?\(at?\s?(.*?):(\d+)(?::(\d+))?\)?\s*$/,b=/in\s(.*)\s\(at\s(.+)\)\sat/,O=/^(?:.*@)?(.*):(\d+):(\d+)$/,J=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. \/=]+)(?::(\d+))?(?::(\d+))?\s*$/i,E=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,A=/(\S[^\s[]*\[.*\]|.*?)@(.*):(\d+):(\d+)/,p=/\(error: (.*)\)/,$=d((i,e)=>{const n=i.includes("safari-extension"),o=i.includes("safari-web-extension");return n||o?[i.includes("@")?i.split("@")[0]:f,n?`safari-extension:${e}`:`safari-web-extension:${e}`]:[i,e]},"extractSafariExtensionDetails"),y=d((i,e)=>{const n=S.exec(e);n&&(i.file=n[1],i.line=+n[2],i.column=+n[3])},"parseMapped"),G=d(i=>{const e=b.exec(i);if(e){u(`parse nested node error stack line: "${i}"`,`found: ${JSON.stringify(e)}`);const o=e[2].split(":");return{column:o[2]?+o[2]:void 0,file:o[0],line:o[1]?+o[1]:void 0,methodName:e[1]||f,raw:i,type:void 0}}const n=w.exec(i);if(n){u(`parse node error stack line: "${i}"`,`found: ${JSON.stringify(n)}`);const o={column:n[4]?+n[4]:void 0,file:n[2]?n[2].replace(/at\s/,""):void 0,line:n[3]?+n[3]:void 0,methodName:n[1]||f,raw:i,type:i.startsWith("internal")?"internal":void 0};return y(o,`${n[2]}:${n[3]}:${n[4]}`),o}},"parseNode"),W=d(i=>{const e=h.exec(i);if(e){u(`parse chrome error stack line: "${i}"`,`found: ${JSON.stringify(e)}`);const n=e[2]&&e[2].startsWith("native"),o=e[2]&&e[2].startsWith("eval")||e[1]&&e[1].startsWith("eval");let r,t;if(o){const s=g.exec(i);if(s){const a=/(\S+):(\d+):(\d+)|(\S+):(\d+)$/.exec(s[1]);a?(e[2]=a[4]??a[1],e[3]=a[5]??a[2],e[4]=a[3]):s[2]&&(e[2]=s[1]),s[2]&&(r={column:s[4]?+s[4]:void 0,file:s[2],line:s[3]?+s[3]:void 0,methodName:"eval",raw:i,type:"eval"})}else{const a=k.exec(i);a&&(t={column:a[5]?+a[5]:void 0,file:a[3],line:a[4]?+a[4]:void 0},r={column:a[8]?+a[8]:void 0,file:a[2],line:a[7]?+a[7]:void 0,methodName:"eval",raw:a[0],type:"eval"})}}const[m,c]=$(e[1]?e[1].replace(/^Anonymous function$/,"<anonymous>"):f,e[2]),l={column:e[4]?+e[4]:void 0,evalOrigin:r,file:c,line:e[3]?+e[3]:void 0,methodName:m,raw:i,type:o?"eval":n?"native":void 0};return t?(l.column=t.column,l.file=t.file,l.line=t.line):y(l,`${c}:${e[3]}:${e[4]}`),l}},"parseChromium"),D=d((i,e)=>{const n=J.exec(i);if(n){u(`parse gecko error stack line: "${i}"`,`found: ${JSON.stringify(n)}`);const o=n[3]?.includes(" > eval"),r=o&&n[3]&&E.exec(n[3]);let t;o&&r&&(n[3]=r[1],t={column:n[5]?+n[5]:void 0,file:n[3],line:n[4]?+n[4]:void 0,methodName:"eval",raw:i,type:"eval"},n[4]=r[2]);const[m,c]=$(n[1]?n[1].replace(/^Anonymous function$/,"<anonymous>"):f,n[3]);let l;(e?.type==="safari"||!o&&e?.type==="firefox")&&e.column?l=e.column:!o&&n[5]&&(l=+n[5]);let s;return(e?.type==="safari"||!o&&e?.type==="firefox")&&e.line?s=e.line:n[4]&&(s=+n[4]),{column:l,evalOrigin:t,file:c,line:s,methodName:m,raw:i,type:o?"eval":c.includes("[native code]")?"native":void 0}}},"parseGecko"),j=d((i,e)=>{const n=A.exec(i);if(!(n&&n[2].includes(" > eval"))&&n)return u(`parse firefox error stack line: "${i}"`,`found: ${JSON.stringify(n)}`),{column:n[4]?+n[4]:e?.column??void 0,file:n[2],line:n[3]?+n[3]:e?.line??void 0,methodName:n[1]||f,raw:i,type:void 0}},"parseFirefox"),z=d(i=>{const e=O.exec(i);if(e)return u(`parse react android native error stack line: "${i}"`,`found: ${JSON.stringify(e)}`),{column:e[3]?+e[3]:void 0,file:e[1],line:e[2]?+e[2]:void 0,methodName:f,raw:i,type:void 0}},"parseReactAndroidNative"),B=d((i,e={})=>{const{frameLimit:n=50}=e;let o=(i.stacktrace??i.stack??"").split(`
|
|
2
|
+
`).map(r=>(p.test(r)?r.replace(p,"$1"):r).replace(/^\s+|\s+$/g,"")).filter(r=>!/\S*Error: /.test(r)&&r!=="eval code");return o.length>n&&(o=o.slice(0,n)),o.reduce((r,t,m)=>{if(!t||t.length>1024)return r;let c;if(/^\s*in\s.*/.test(t))c=G(t);else if(/^.*?\s*at\s.*/.test(t))c=W(t);else if(/^.*?\s*@.*|\[native code\]/.test(t)){let l;m===0&&(i.columnNumber||i.lineNumber?l={column:i.columnNumber,line:i.lineNumber,type:"firefox"}:(i.line||i.column)&&(l={column:i.column,line:i.line,type:"safari"})),c=j(t,l)||D(t,l)}else c=z(t);return c?r.push(c):u(`parse error stack line: "${t}"`,"not parser found"),r},[])},"parse"),R=B;export{R as parseStacktrace};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visulima/error",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"description": "Error with more than just a message, stacktrace parsing.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"anolilab",
|
|
@@ -25,6 +25,17 @@
|
|
|
25
25
|
"text",
|
|
26
26
|
"trace",
|
|
27
27
|
"v8",
|
|
28
|
+
"source",
|
|
29
|
+
"code",
|
|
30
|
+
"frame",
|
|
31
|
+
"stack",
|
|
32
|
+
"callstack",
|
|
33
|
+
"call",
|
|
34
|
+
"source-code",
|
|
35
|
+
"pretty-error",
|
|
36
|
+
"pretty-exceptions",
|
|
37
|
+
"exception",
|
|
38
|
+
"pretty",
|
|
28
39
|
"visulima"
|
|
29
40
|
],
|
|
30
41
|
"homepage": "https://www.visulima.com/docs/package/error",
|
|
@@ -52,31 +63,49 @@
|
|
|
52
63
|
"type": "module",
|
|
53
64
|
"exports": {
|
|
54
65
|
".": {
|
|
66
|
+
"require": {
|
|
67
|
+
"types": "./dist/index.d.cts",
|
|
68
|
+
"default": "./dist/index.cjs"
|
|
69
|
+
},
|
|
55
70
|
"import": {
|
|
56
|
-
"types": "./dist/index.d.
|
|
57
|
-
"default": "./dist/index.
|
|
71
|
+
"types": "./dist/index.d.mts",
|
|
72
|
+
"default": "./dist/index.mjs"
|
|
58
73
|
}
|
|
59
74
|
},
|
|
60
75
|
"./code-frame": {
|
|
76
|
+
"require": {
|
|
77
|
+
"types": "./dist/code-frame/index.d.cts",
|
|
78
|
+
"default": "./dist/code-frame/index.cjs"
|
|
79
|
+
},
|
|
61
80
|
"import": {
|
|
62
|
-
"types": "./dist/code-frame/index.d.
|
|
63
|
-
"default": "./dist/code-frame/index.
|
|
81
|
+
"types": "./dist/code-frame/index.d.mts",
|
|
82
|
+
"default": "./dist/code-frame/index.mjs"
|
|
64
83
|
}
|
|
65
84
|
},
|
|
66
85
|
"./error": {
|
|
86
|
+
"require": {
|
|
87
|
+
"types": "./dist/error/index.d.cts",
|
|
88
|
+
"default": "./dist/error/index.cjs"
|
|
89
|
+
},
|
|
67
90
|
"import": {
|
|
68
|
-
"types": "./dist/error/index.d.
|
|
69
|
-
"default": "./dist/error/index.
|
|
91
|
+
"types": "./dist/error/index.d.mts",
|
|
92
|
+
"default": "./dist/error/index.mjs"
|
|
70
93
|
}
|
|
71
94
|
},
|
|
72
95
|
"./stacktrace": {
|
|
96
|
+
"require": {
|
|
97
|
+
"types": "./dist/stacktrace/index.d.cts",
|
|
98
|
+
"default": "./dist/stacktrace/index.cjs"
|
|
99
|
+
},
|
|
73
100
|
"import": {
|
|
74
|
-
"types": "./dist/stacktrace/index.d.
|
|
75
|
-
"default": "./dist/stacktrace/index.
|
|
101
|
+
"types": "./dist/stacktrace/index.d.mts",
|
|
102
|
+
"default": "./dist/stacktrace/index.mjs"
|
|
76
103
|
}
|
|
77
104
|
},
|
|
78
105
|
"./package.json": "./package.json"
|
|
79
106
|
},
|
|
107
|
+
"main": "dist/index.cjs",
|
|
108
|
+
"module": "dist/index.mjs",
|
|
80
109
|
"types": "dist/index.d.ts",
|
|
81
110
|
"files": [
|
|
82
111
|
"dist",
|
|
@@ -99,22 +128,24 @@
|
|
|
99
128
|
"@total-typescript/ts-reset": "^0.5.1",
|
|
100
129
|
"@types/command-line-args": "^5.2.3",
|
|
101
130
|
"@types/node": "18.19.15",
|
|
102
|
-
"@visulima/path": "1.0.2",
|
|
103
131
|
"@visulima/nextra-theme-docs": "4.0.26",
|
|
132
|
+
"@visulima/packem": "^1.0.0-alpha.46",
|
|
133
|
+
"@visulima/path": "1.0.2",
|
|
104
134
|
"@vitest/coverage-v8": "^1.6.0",
|
|
105
135
|
"@vitest/ui": "^1.6.0",
|
|
106
136
|
"conventional-changelog-conventionalcommits": "8.0.0",
|
|
107
137
|
"cross-env": "^7.0.3",
|
|
138
|
+
"esbuild": "0.22.0",
|
|
108
139
|
"eslint": "^8.57.0",
|
|
109
140
|
"eslint-plugin-deprecation": "^3.0.0",
|
|
110
141
|
"eslint-plugin-import": "npm:eslint-plugin-i@^2.29.1",
|
|
111
142
|
"eslint-plugin-mdx": "^3.1.5",
|
|
112
143
|
"eslint-plugin-vitest": "^0.4.1",
|
|
113
144
|
"eslint-plugin-vitest-globals": "^1.5.0",
|
|
145
|
+
"is-plain-obj": "^4.1.0",
|
|
114
146
|
"prettier": "^3.3.2",
|
|
115
147
|
"rimraf": "^5.0.7",
|
|
116
148
|
"semantic-release": "24.0.0",
|
|
117
|
-
"tsup": "^8.1.0",
|
|
118
149
|
"typescript": "^5.4.5",
|
|
119
150
|
"vitest": "^1.6.0"
|
|
120
151
|
},
|
|
@@ -143,15 +174,9 @@
|
|
|
143
174
|
"info_on_disabling_etc_no_deprecated": false
|
|
144
175
|
}
|
|
145
176
|
},
|
|
146
|
-
"sources": [
|
|
147
|
-
"src/index.ts",
|
|
148
|
-
"src/code-frame/index.ts",
|
|
149
|
-
"src/error/index.ts",
|
|
150
|
-
"src/stacktrace/index.ts"
|
|
151
|
-
],
|
|
152
177
|
"scripts": {
|
|
153
|
-
"build": "cross-env NODE_ENV=development
|
|
154
|
-
"build:prod": "cross-env NODE_ENV=production
|
|
178
|
+
"build": "cross-env NODE_ENV=development packem build",
|
|
179
|
+
"build:prod": "cross-env NODE_ENV=production packem build",
|
|
155
180
|
"clean": "rimraf node_modules dist .eslintcache",
|
|
156
181
|
"dev": "pnpm run build --watch",
|
|
157
182
|
"lint:eslint": "eslint . --ext js,cjs,mjs,jsx,ts,tsx,json,yaml,yml,md,mdx --max-warnings=0 --config .eslintrc.cjs",
|
package/dist/chunk-BKLPSU5H.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
var w=s=>s.replaceAll(/\r\n|\r(?!\n)|\n/gu,`
|
|
2
|
-
`),x=w;var v=globalThis.process||Object.create(null),y={versions:{}},z=new Proxy(v,{get(s,r){if(r in s)return s[r];if(r in y)return y[r]}}),M=z;var S=(s,r,L,t)=>{let g={column:0,line:-1,...s.start},c={...g,...s.end},i=g.line,n=g.column,l=c.line,u=c.column,d=Math.max(i-(L+1),0),f=Math.min(r.length,l+t);i===-1&&(d=0),l===-1&&(f=r.length);let p=l-i,o={};if(p)for(let e=0;e<=p;e++){let a=e+i;if(!n)o[a]=!0;else if(e===0){let m=r[a-1]?.length;o[a]=[n,(m??0)-n+1];}else if(e===p)o[a]=[0,u];else {let m=r[a-e]?.length;o[a]=[0,m];}}else n===u?o[i]=n?[n,0]:!0:o[i]=[n,(u??0)-(n??0)];return {end:f,markerLines:o,start:d}},$=S;var W=M.platform==="win32"&&!M.env?.WT_SESSION?">":"\u276F",q=(s,r,L)=>{let t={linesAbove:2,linesBelow:3,showGutter:!0,showLineNumbers:!0,tabWidth:4,...L,color:{gutter:e=>e,marker:e=>e,message:e=>e,...L?.color}},g=r.start&&typeof r.start.column=="number",c=x(s).split(`
|
|
3
|
-
`);typeof t?.tabWidth=="number"&&(c=c.map(e=>e.replaceAll(" "," ".repeat(t.tabWidth))));let{end:i,markerLines:n,start:l}=$(r,c,t.linesAbove,t.linesBelow),u=String(i).length,{gutter:d,marker:f,message:p}=t.color,o=c.slice(l,i).map((e,a)=>{let m=l+1+a,b=n[m],N=` ${m}`.slice(-u),A=!n[m+1],h=` ${N}${t.showGutter?" |":""}`;if(b){let k="";if(Array.isArray(b)){let O=e.replaceAll(/[^\t]/g," ").slice(0,Math.max(b[0]-1,0)),P=b[1]||1;k=[`
|
|
4
|
-
`,d(h.replaceAll(/\d/g," "))," ",O,f("^").repeat(P)].join(""),A&&t.message&&(k+=` ${p(t.message)}`);}return [f(W),d(h),e.length>0?` ${e}`:"",k].join("")}return ` ${d(h)}${e.length>0?` ${e}`:""}`}).join(`
|
|
5
|
-
`);return t.message&&!g&&(o=`${" ".repeat(u+1)}${t.message}
|
|
6
|
-
${o}`),o};
|
|
7
|
-
|
|
8
|
-
export { W as a, q as b };
|
|
9
|
-
//# sourceMappingURL=out.js.map
|
|
10
|
-
//# sourceMappingURL=chunk-BKLPSU5H.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/util/normalize-lf.ts","../src/util/process.ts","../src/code-frame/get-marker-lines.ts","../src/code-frame/index.ts"],"names":["normalizeLF","code","normalize_lf_default","_process","processShims","process","target","property","process_default","getMarkerLines","loc","source","linesAbove","linesBelow","startLoc","endLoc","startLine","startColumn","endLine","endColumn","start","end","lineDiff","markerLines","index","lineNumber","sourceLength","get_marker_lines_default","CODE_FRAME_POINTER","codeFrame","options","config","value","hasColumns","lines","ln","numberMaxWidth","colorizeGutter","colorizeMarker","colorizeMessage","frame","line","number","hasMarker","paddedNumber","lastMarkerLine","gutter","markerLine","markerSpacing","numberOfMarkers"],"mappings":"AAAA,IAAMA,EAAeC,GAAyBA,EAAK,WAAW,qBAAsB;AAAA,CAAI,EAEjFC,EAAQF,ECGf,IAAMG,EAAY,WAAW,SAAW,OAAO,OAAO,IAAI,EAEpDC,EAAiC,CACnC,SAAU,CAAC,CACf,EAEMC,EAAU,IAAI,MAAeF,EAAU,CACzC,IAAIG,EAAQC,EAAyB,CACjC,GAAIA,KAAYD,EAEZ,OAAOA,EAAOC,CAAQ,EAG1B,GAAIA,KAAYH,EAEZ,OAAOA,EAAaG,CAAQ,CAIpC,CACJ,CAAC,EAEMC,EAAQH,ECVf,IAAMI,EAAiB,CACnBC,EACAC,EACAC,EACAC,IAMC,CACD,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OAAOW,CAAe,CAAC,EAAE,KACjI,EACJ,EAEIJ,GAAkBd,EAAO,UACzBgB,GAAc,IAAIR,EAAgBR,EAAO,OAAO,CAAC,GAEzD,CAEA,MAAO,CAACO,EAAeV,CAAkB,EAAGS,EAAeS,CAAM,EAAGL,EAAK,OAAS,EAAI,IAAIA,CAAI,GAAK,GAAIM,CAAU,EAAE,KAAK,EAAE,CAC9H,CAEA,MAAO,IAAIV,EAAeS,CAAM,CAAC,GAAGL,EAAK,OAAS,EAAI,IAAIA,CAAI,GAAK,EAAE,EACzE,CAAC,EACA,KAAK;AAAA,CAAI,EAEd,OAAIV,EAAO,SAAW,CAACE,IACnBO,EAAQ,GAAG,IAAI,OAAOJ,EAAiB,CAAC,CAAC,GAAGL,EAAO,OAAO;AAAA,EAAKS,CAAK,IAGjEA,CACX","sourcesContent":["const normalizeLF = (code: string): string => code.replaceAll(/\\r\\n|\\r(?!\\n)|\\n/gu, \"\\n\");\n\nexport default normalizeLF;\n","interface Process extends Partial<Omit<typeof globalThis.process, \"versions\">> {\n versions: Record<string, string>;\n}\n\n// eslint-disable-next-line @typescript-eslint/naming-convention,@typescript-eslint/no-unnecessary-condition,no-underscore-dangle\nconst _process = (globalThis.process || Object.create(null)) as unknown as Process;\n\nconst processShims: Partial<Process> = {\n versions: {},\n};\n\nconst process = new Proxy<Process>(_process, {\n get(target, property: keyof Process) {\n if (property in target) {\n // eslint-disable-next-line security/detect-object-injection\n return target[property];\n }\n\n if (property in processShims) {\n // eslint-disable-next-line security/detect-object-injection\n return processShims[property];\n }\n\n return undefined;\n },\n});\n\nexport default process;\n","// eslint-disable-next-line no-secrets/no-secrets\n/**\n * This is a copy of the codeFrame function from Babel\n * @see https://github.com/babel/babel/blob/85e649203b61b7c908eb04c05511a0d35f893e8e/packages/babel-code-frame/src/index.ts#L68-L143\n *\n * MIT License\n *\n * Copyright (c) 2014-present Sebastian McKenzie and other contributors\n */\n\n/**\n * Extract what lines should be marked and highlighted.\n */\nimport type { CodeFrameLocation, CodeFrameNodeLocation } from \"./types\";\n\ntype MarkerLines = Record<number, true | [number | undefined, number | undefined]>;\n\nconst getMarkerLines = (\n loc: CodeFrameNodeLocation,\n source: string[],\n linesAbove: number,\n linesBelow: number,\n): {\n end: number;\n markerLines: MarkerLines;\n start: number;\n // eslint-disable-next-line sonarjs/cognitive-complexity\n} => {\n const startLoc: CodeFrameLocation = {\n column: 0,\n // @ts-expect-error Can be overwritten\n line: -1,\n ...loc.start,\n };\n const endLoc: CodeFrameLocation = {\n ...startLoc,\n ...loc.end,\n };\n const startLine = startLoc.line;\n const startColumn = startLoc.column;\n const endLine = endLoc.line;\n const endColumn = endLoc.column;\n\n let start = Math.max(startLine - (linesAbove + 1), 0);\n let end = Math.min(source.length, endLine + linesBelow);\n\n if (startLine === -1) {\n start = 0;\n }\n\n if (endLine === -1) {\n end = source.length;\n }\n\n const lineDiff = endLine - startLine;\n const markerLines: MarkerLines = {};\n\n if (lineDiff) {\n // eslint-disable-next-line no-plusplus,no-loops/no-loops\n for (let index = 0; index <= lineDiff; index++) {\n const lineNumber = index + startLine;\n\n if (!startColumn) {\n // eslint-disable-next-line security/detect-object-injection\n markerLines[lineNumber] = true;\n } else if (index === 0) {\n const sourceLength = source[lineNumber - 1]?.length;\n\n // eslint-disable-next-line security/detect-object-injection\n markerLines[lineNumber] = [startColumn, (sourceLength ?? 0) - startColumn + 1];\n } else if (index === lineDiff) {\n // eslint-disable-next-line security/detect-object-injection\n markerLines[lineNumber] = [0, endColumn];\n } else {\n const sourceLength = source[lineNumber - index]?.length;\n\n // eslint-disable-next-line security/detect-object-injection\n markerLines[lineNumber] = [0, sourceLength];\n }\n }\n } else if (startColumn === endColumn) {\n // eslint-disable-next-line security/detect-object-injection\n markerLines[startLine] = startColumn ? [startColumn, 0] : true;\n } else {\n // eslint-disable-next-line security/detect-object-injection\n markerLines[startLine] = [startColumn, (endColumn ?? 0) - (startColumn ?? 0)];\n }\n\n return { end, markerLines, start };\n};\n\nexport default getMarkerLines;\n","// eslint-disable-next-line no-secrets/no-secrets\n/**\n * This is a modified copy of the codeFrameColumns function from Babel\n * @see https://github.com/babel/babel/blob/85e649203b61b7c908eb04c05511a0d35f893e8e/packages/babel-code-frame/src/index.ts#L145-L217\n *\n * MIT License\n *\n * Copyright (c) 2014-present Sebastian McKenzie and other contributors\n */\n\nimport normalizeLF from \"../util/normalize-lf\";\nimport process from \"../util/process\";\nimport getMarkerLines from \"./get-marker-lines\";\nimport type { CodeFrameNodeLocation, CodeFrameOptions } from \"./types\";\n\nexport const CODE_FRAME_POINTER = process.platform === \"win32\" && !process.env?.WT_SESSION ? \">\" : \"❯\";\n\n/** Generate a code frame from string and an error location */\nexport const codeFrame = (\n source: string,\n loc: CodeFrameNodeLocation,\n options?: CodeFrameOptions,\n // eslint-disable-next-line sonarjs/cognitive-complexity\n): string => {\n // grab 2 lines before, and 3 lines after focused line\n const config = {\n linesAbove: 2,\n linesBelow: 3,\n showGutter: true,\n showLineNumbers: true,\n tabWidth: 4,\n ...options,\n color: {\n gutter: (value: string) => value,\n marker: (value: string) => value,\n message: (value: string) => value,\n ...options?.color,\n },\n };\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n const hasColumns = loc.start && typeof loc.start.column === \"number\";\n\n let lines = normalizeLF(source).split(\"\\n\");\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (typeof config?.tabWidth === \"number\") {\n lines = lines.map((ln) => ln.replaceAll(\"\\t\", \" \".repeat(config.tabWidth as number)));\n }\n\n const { end, markerLines, start } = getMarkerLines(loc, lines, config.linesAbove, config.linesBelow);\n\n const numberMaxWidth = String(end).length;\n const { gutter: colorizeGutter, marker: colorizeMarker, message: colorizeMessage } = config.color;\n\n let frame = lines\n .slice(start, end)\n .map((line, index) => {\n const number = start + 1 + index;\n // eslint-disable-next-line security/detect-object-injection\n const hasMarker = markerLines[number];\n const paddedNumber = ` ${number}`.slice(-numberMaxWidth);\n const lastMarkerLine = !markerLines[number + 1];\n\n const gutter = ` ${paddedNumber}${config.showGutter ? ` |` : \"\"}`;\n\n if (hasMarker) {\n let markerLine = \"\";\n\n if (Array.isArray(hasMarker)) {\n const markerSpacing = line.replaceAll(/[^\\t]/g, \" \").slice(0, Math.max((hasMarker[0] as number) - 1, 0));\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n const numberOfMarkers = hasMarker[1] || 1;\n\n markerLine = [\"\\n \", colorizeGutter(gutter.replaceAll(/\\d/g, \" \")), \" \", markerSpacing, colorizeMarker(\"^\").repeat(numberOfMarkers)].join(\n \"\",\n );\n\n if (lastMarkerLine && config.message) {\n markerLine += ` ${colorizeMessage(config.message)}`;\n }\n }\n\n return [colorizeMarker(CODE_FRAME_POINTER), colorizeGutter(gutter), line.length > 0 ? ` ${line}` : \"\", markerLine].join(\"\");\n }\n\n return ` ${colorizeGutter(gutter)}${line.length > 0 ? ` ${line}` : \"\"}`;\n })\n .join(\"\\n\");\n\n if (config.message && !hasColumns) {\n frame = `${\" \".repeat(numberMaxWidth + 1)}${config.message}\\n${frame}`;\n }\n\n return frame;\n};\n\nexport type { CodeFrameLocation, CodeFrameNodeLocation, CodeFrameOptions, ColorizeMethod } from \"./types\";\n"]}
|
package/dist/chunk-HAVTTG7L.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { inspect } from 'node:util';
|
|
2
|
-
|
|
3
|
-
var m=i=>{let r=new Set,e=[],t=i;for(;t;){if(r.has(t)){console.error(`Circular reference detected in error causes: ${inspect(i)}`);break}if(e.push(t),r.add(t),!t.cause)break;t=t.cause;}return e},h=m;var d=i=>i instanceof Error&&i.type==="VisulimaError",s=class extends Error{loc;title;hint;type="VisulimaError";constructor(r,...e){super(...e);let{hint:t,location:c,message:o,name:u,stack:l,title:p}=r;this.title=p,this.name=u,o&&(this.message=o),this.stack=l??this.stack,this.loc=c,this.hint=t,Error.captureStackTrace(this,this.constructor);}setLocation(r){this.loc=r;}setName(r){this.name=r;}setMessage(r){this.message=r;}setHint(r){this.hint=r;}};
|
|
4
|
-
|
|
5
|
-
export { h as a, d as b, s as c };
|
|
6
|
-
//# sourceMappingURL=out.js.map
|
|
7
|
-
//# sourceMappingURL=chunk-HAVTTG7L.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/error/get-error-causes.ts","../src/error/visulima-error.ts"],"names":["inspect","getErrorCauses","error","seen","causes","currentError","get_error_causes_default","isVisulimaError","VisulimaError","properties","parameters","hint","location","message","name","stack","title"],"mappings":"AAAA,OAAS,WAAAA,MAAe,YAQxB,IAAMC,EAAuDC,GAAkB,CAC3E,IAAMC,EAAO,IAAI,IACXC,EAAS,CAAC,EAGZC,EAAwBH,EAG5B,KAAOG,GAAc,CAEjB,GAAIF,EAAK,IAAIE,CAAY,EAAG,CAExB,QAAQ,MAAM,gDAAgDL,EAAQE,CAAK,CAAC,EAAE,EAE9E,KACJ,CAKA,GAHAE,EAAO,KAAKC,CAAY,EACxBF,EAAK,IAAIE,CAAY,EAEjB,CAACA,EAAa,MACd,MAGJA,EAAeA,EAAa,KAChC,CAEA,OAAOD,CACX,EAEOE,EAAQL,ECpCR,IAAMM,EAAmBL,GAA2CA,aAAiB,OAAUA,EAAwB,OAAS,gBAE1HM,EAAN,cAA4B,KAAM,CAC9B,IAEA,MAKA,KAEA,KAAO,gBAGP,YAAYC,KAAgCC,EAAiB,CAEhE,MAAM,GAAGA,CAAU,EAEnB,GAAM,CAAE,KAAAC,EAAM,SAAAC,EAAU,QAAAC,EAAS,KAAAC,EAAM,MAAAC,EAAO,MAAAC,CAAM,EAAIP,EACxD,KAAK,MAAQO,EACb,KAAK,KAAOF,EAERD,IACA,KAAK,QAAUA,GAInB,KAAK,MAAQE,GAAU,KAAK,MAC5B,KAAK,IAAMH,EACX,KAAK,KAAOD,EAEZ,MAAM,kBAAkB,KAAM,KAAK,WAAW,CAClD,CAEO,YAAYC,EAA+B,CAC9C,KAAK,IAAMA,CACf,CAEO,QAAQE,EAAoB,CAC/B,KAAK,KAAOA,CAChB,CAEO,WAAWD,EAAuB,CACrC,KAAK,QAAUA,CACnB,CAEO,QAAQF,EAAuB,CAClC,KAAK,KAAOA,CAChB,CACJ","sourcesContent":["import { inspect } from \"node:util\";\n\nimport type { VisulimaError } from \"./visulima-error\";\n\n/**\n * Will return an array of all causes in the error in the order they occurred.\n */\n// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\nconst getErrorCauses = <E = Error | VisulimaError | unknown>(error: E): E[] => {\n const seen = new Set();\n const causes = [];\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/no-redundant-type-constituents\n let currentError: E | any = error;\n\n // eslint-disable-next-line no-loops/no-loops\n while (currentError) {\n // Check for circular reference\n if (seen.has(currentError)) {\n // eslint-disable-next-line no-console\n console.error(`Circular reference detected in error causes: ${inspect(error)}`);\n\n break;\n }\n\n causes.push(currentError);\n seen.add(currentError);\n\n if (!currentError.cause) {\n break;\n }\n\n currentError = currentError.cause;\n }\n\n return causes as E[];\n};\n\nexport default getErrorCauses;\n","import type { ErrorHint, ErrorLocation, ErrorProperties } from \"./types\";\n\nexport const isVisulimaError = (error: unknown): error is VisulimaError => error instanceof Error && (error as VisulimaError).type === \"VisulimaError\";\n\nexport class VisulimaError extends Error {\n public loc: ErrorLocation | undefined;\n\n public title: string | undefined;\n\n /**\n * A message that explains to the user how they can fix the error.\n */\n public hint: ErrorHint | undefined;\n\n public type = \"VisulimaError\";\n\n // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types,@typescript-eslint/no-explicit-any\n public constructor(properties: ErrorProperties, ...parameters: any) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n super(...parameters);\n\n const { hint, location, message, name, stack, title } = properties;\n this.title = title;\n this.name = name;\n\n if (message) {\n this.message = message;\n }\n\n // Only set this if we actually have a stack passed, otherwise uses Error's\n this.stack = stack ?? (this.stack as string);\n this.loc = location;\n this.hint = hint;\n\n Error.captureStackTrace(this, this.constructor);\n }\n\n public setLocation(location: ErrorLocation): void {\n this.loc = location;\n }\n\n public setName(name: string): void {\n this.name = name;\n }\n\n public setMessage(message: string): void {\n this.message = message;\n }\n\n public setHint(hint: ErrorHint): void {\n this.hint = hint;\n }\n}\n"]}
|
package/dist/chunk-WOVTAVVR.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
var u=(s,...e)=>{process.env.DEBUG&&String(process.env.DEBUG)==="true"&&console.debug(`error:parse-stacktrace: ${s}`,...e);},f="<unknown>",T=/^.*?\s*at\s(?:(.+?\)(?:\s\[.+\])?|\(?.*?)\s?\((?:address\sat\s)?)?(?:async\s)?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,v=/\((\S+)\),\s(<[^>]+>)?:(\d+)?:(\d+)?\)?/,N=/(.*?):(\d+):(\d+)(\s<-\s(.+):(\d+):(\d+))?/,$=/(eval)\sat\s(<anonymous>)\s\((.*)\)?:(\d+)?:(\d+)\),\s*(<anonymous>)?:(\d+)?:(\d+)/,x=/^\s*in\s(?:([^\\/]+(?:\s\[as\s\S+\])?)\s\(?)?\(at?\s?(.*?):(\d+)(?::(\d+))?\)?\s*$/,b=/in\s(.*)\s\(at\s(.+)\)\sat/,O=/^(?:.*@)?(.*):(\d+):(\d+)$/,R=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. \/=]+)(?::(\d+))?(?::(\d+))?\s*$/i,S=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,_=/(\S[^\s[]*\[.*\]|.*?)@(.*):(\d+):(\d+)/,p=/\(error: (.*)\)/,m=(s,e)=>{let n=s.includes("safari-extension"),i=s.includes("safari-web-extension");return n||i?[s.includes("@")?s.split("@")[0]:f,n?`safari-extension:${e}`:`safari-web-extension:${e}`]:[s,e]},E=(s,e)=>{let n=N.exec(e);n&&(s.file=n[1],s.line=+n[2],s.column=+n[3]);},h=s=>{let e=b.exec(s);if(e){u(`parse nested node error stack line: "${s}"`,`found: ${JSON.stringify(e)}`);let i=e[2].split(":");return {column:i[2]?+i[2]:void 0,file:i[0],line:i[1]?+i[1]:void 0,methodName:e[1]||f,raw:s,type:void 0}}let n=x.exec(s);if(n){u(`parse node error stack line: "${s}"`,`found: ${JSON.stringify(n)}`);let i={column:n[4]?+n[4]:void 0,file:n[2]?n[2].replace(/at\s/,""):void 0,line:n[3]?+n[3]:void 0,methodName:n[1]||f,raw:s,type:s.startsWith("internal")?"internal":void 0};return E(i,`${n[2]}:${n[3]}:${n[4]}`),i}},w=s=>{let e=T.exec(s);if(e){u(`parse chrome error stack line: "${s}"`,`found: ${JSON.stringify(e)}`);let n=e[2]&&e[2].startsWith("native"),i=e[2]&&e[2].startsWith("eval")||e[1]&&e[1].startsWith("eval"),r,t;if(i){let c=v.exec(s);if(c){let a=/(\S+):(\d+):(\d+)|(\S+):(\d+)$/.exec(c[1]);a?(e[2]=a[4]??a[1],e[3]=a[5]??a[2],e[4]=a[3]):c[2]&&(e[2]=c[1]),c[2]&&(r={column:c[4]?+c[4]:void 0,file:c[2],line:c[3]?+c[3]:void 0,methodName:"eval",raw:s,type:"eval"});}else {let a=$.exec(s);a&&(t={column:a[5]?+a[5]:void 0,file:a[3],line:a[4]?+a[4]:void 0},r={column:a[8]?+a[8]:void 0,file:a[2],line:a[7]?+a[7]:void 0,methodName:"eval",raw:a[0],type:"eval"});}}let[l,o]=m(e[1]?e[1].replace(/^Anonymous function$/,"<anonymous>"):f,e[2]),d={column:e[4]?+e[4]:void 0,evalOrigin:r,file:o,line:e[3]?+e[3]:void 0,methodName:l,raw:s,type:i?"eval":n?"native":void 0};return t?(d.column=t.column,d.file=t.file,d.line=t.line):E(d,`${o}:${e[3]}:${e[4]}`),d}},G=(s,e)=>{let n=R.exec(s);if(n){u(`parse gecko error stack line: "${s}"`,`found: ${JSON.stringify(n)}`);let i=n[3]?.includes(" > eval"),r=i&&n[3]&&S.exec(n[3]),t;i&&r&&(n[3]=r[1],t={column:n[5]?+n[5]:void 0,file:n[3],line:n[4]?+n[4]:void 0,methodName:"eval",raw:s,type:"eval"},n[4]=r[2]);let[l,o]=m(n[1]?n[1].replace(/^Anonymous function$/,"<anonymous>"):f,n[3]),d;(e?.type==="safari"||!i&&e?.type==="firefox")&&e.column?d=e.column:!i&&n[5]&&(d=+n[5]);let c;return (e?.type==="safari"||!i&&e?.type==="firefox")&&e.line?c=e.line:n[4]&&(c=+n[4]),{column:d,evalOrigin:t,file:o,line:c,methodName:l,raw:s,type:i?"eval":o.includes("[native code]")?"native":void 0}}},k=(s,e)=>{let n=_.exec(s);if(!(n?n[2].includes(" > eval"):!1)&&n)return u(`parse firefox error stack line: "${s}"`,`found: ${JSON.stringify(n)}`),{column:n[4]?+n[4]:e?.column??void 0,file:n[2],line:n[3]?+n[3]:e?.line??void 0,methodName:n[1]||f,raw:s,type:void 0}},A=s=>{let e=O.exec(s);if(e)return u(`parse react android native error stack line: "${s}"`,`found: ${JSON.stringify(e)}`),{column:e[3]?+e[3]:void 0,file:e[1],line:e[2]?+e[2]:void 0,methodName:f,raw:s,type:void 0}},X=(s,e={})=>{let{frameLimit:n=50}=e,i=(s.stacktrace??s.stack??"").split(`
|
|
2
|
-
`).map(r=>(p.test(r)?r.replace(p,"$1"):r).replace(/^\s+|\s+$/g,"")).filter(r=>!/\S*Error: /.test(r)&&r!=="eval code");return i.length>n&&(i=i.slice(0,n)),i.reduce((r,t,l)=>{if(!t||t.length>1024)return r;let o;if(/^\s*in\s.*/.test(t))o=h(t);else if(/^.*?\s*at\s.*/.test(t))o=w(t);else if(/^.*?\s*@.*|\[native code\]/.test(t)){let d;l===0&&(s.columnNumber||s.lineNumber?d={column:s.columnNumber,line:s.lineNumber,type:"firefox"}:(s.line||s.column)&&(d={column:s.column,line:s.line,type:"safari"})),o=k(t,d)||G(t,d);}else o=A(t);return o?r.push(o):u(`parse error stack line: "${t}"`,"not parser found"),r},[])},D=X;
|
|
3
|
-
|
|
4
|
-
export { D as a };
|
|
5
|
-
//# sourceMappingURL=out.js.map
|
|
6
|
-
//# sourceMappingURL=chunk-WOVTAVVR.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/stacktrace/parse-stacktrace.ts"],"names":["debugLog","message","arguments_","UNKNOWN_FUNCTION","CHROMIUM_REGEX","CHROMIUM_EVAL_REGEX","CHROMIUM_MAPPED","WINDOWS_EVAL_REGEX","NODE_REGEX","NODE_NESTED_REGEX","REACT_ANDROID_NATIVE_REGEX","GECKO_REGEX","GECKO_EVAL_REGEX","FIREFOX_REGEX","WEBPACK_ERROR_REGEXP","extractSafariExtensionDetails","methodName","url","isSafariExtension","isSafariWebExtension","parseMapped","trace","maybeMapped","match","parseNode","line","nestedNode","split","node","parseChromium","parts","isNative","isEval","evalOrigin","windowsParts","subMatch","windowsSubMatch","file","parseGecko","topFrameMeta","column","lineNumber","parseFirefox","parseReactAndroidNative","parse","error","options","frameLimit","lines","stack","currentIndex","parseResult","parse_stacktrace_default"],"mappings":"AAQA,IAAMA,EAAW,CAACC,KAAoBC,IAAgC,CAC9D,QAAQ,IAAI,OAAS,OAAO,QAAQ,IAAI,KAAK,IAAM,QAEnD,QAAQ,MAAM,2BAA2BD,CAAO,GAAI,GAAGC,CAAU,CAEzE,EAEMC,EAAmB,YAsBnBC,EAEF,yJAEEC,EAAsB,0CAItBC,EAAkB,6CAIlBC,EAAqB,qFAIrBC,EAAa,qFACbC,EAAoB,6BAGpBC,EAA6B,6BAM7BC,EAAc,wIAEdC,EAAmB,gDAMnBC,EAAgB,yCAGhBC,EAAuB,kBAsBvBC,EAAgC,CAACC,EAAoBC,IAAkC,CACzF,IAAMC,EAAoBF,EAAW,SAAS,kBAAkB,EAC1DG,EAAuBH,EAAW,SAAS,sBAAsB,EAEvE,OAAOE,GAAqBC,EACtB,CACIH,EAAW,SAAS,GAAG,EAAKA,EAAW,MAAM,G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,KAAM,QACV,IAIRM,EAEIT,EAAajB,EAAMc,CAAY,GAAKD,EAAWb,EAAMc,CAAY,CACzE,MACIY,EAAcR,EAAwBlB,CAAI,EAG9C,OAAI0B,EACAF,EAAM,KAAKE,CAAW,EAEtBnD,EAAS,4BAA4ByB,CAAI,IAAK,kBAAkB,EAG7DwB,CACX,EAAG,CAAC,CAAC,CACT,EAEOG,EAAQR","sourcesContent":["import type { Trace, TraceType } from \"./types\";\n\ntype TopFrameMeta = {\n column?: number;\n line?: number;\n type: \"firefox\" | \"safari\";\n};\n\nconst debugLog = (message: string, ...arguments_: unknown[]): void => {\n if (process.env.DEBUG && String(process.env.DEBUG) === \"true\") {\n // eslint-disable-next-line no-console\n console.debug(`error:parse-stacktrace: ${message}`, ...arguments_);\n }\n};\n\nconst UNKNOWN_FUNCTION = \"<unknown>\";\n\n// at <SomeFramework>\n// at <SomeFramework>:123:39\n// -----------------\n// at about:blank:1:7\n// at index.js:23\n// >= Chrome 99\n// at /projects/foo.test.js:689:1 <- /projects/foo.test.js:10:1\n// -----------------\n// at bar (<anonymous>:1:19 <- <anonymous>:2:3)\n// -----------------\n// at foo.bar(bob) (foo.bar.js:123:39)\n// at foo.bar(bob) (foo.bar.js:123:39 <- original.js:123:34)\n// -----------------\n// >= Chrome 88\n// spy() at Component.Foo [as constructor] (original.js:123:34)\n// spy() at Component.Foo [as constructor] (foo.bar.js:123:39 <- original.js:123:34)\n// -----------------\n// at Module.load (internal/modules/cjs/loader.js:641:32)\n// -----------------\n// Chromium based browsers: Chrome, Brave, new Opera, new Edge\nconst CHROMIUM_REGEX =\n // eslint-disable-next-line security/detect-unsafe-regex,regexp/no-super-linear-backtracking\n /^.*?\\s*at\\s(?:(.+?\\)(?:\\s\\[.+\\])?|\\(?.*?)\\s?\\((?:address\\sat\\s)?)?(?:async\\s)?((?:<anonymous>|[-a-z]+:|.*bundle|\\/)?.*?)(?::(\\d+))?(?::(\\d+))?\\)?\\s*$/i;\n// eslint-disable-next-line security/detect-unsafe-regex\nconst CHROMIUM_EVAL_REGEX = /\\((\\S+)\\),\\s(<[^>]+>)?:(\\d+)?:(\\d+)?\\)?/;\n// foo.bar.js:123:39\n// foo.bar.js:123:39 <- original.js:123:34\n// eslint-disable-next-line security/detect-unsafe-regex,regexp/no-unused-capturing-group\nconst CHROMIUM_MAPPED = /(.*?):(\\d+):(\\d+)(\\s<-\\s(.+):(\\d+):(\\d+))?/;\n\n// eval at <anonymous> (C:\\\\Users\\\\user\\\\project\\\\visulima\\\\packages\\\\error\\\\__tests__\\\\stacktrace\\\\parse-stacktrace.test.ts\n// eslint-disable-next-line regexp/optimal-quantifier-concatenation,regexp/no-unused-capturing-group,security/detect-unsafe-regex\nconst WINDOWS_EVAL_REGEX = /(eval)\\sat\\s(<anonymous>)\\s\\((.*)\\)?:(\\d+)?:(\\d+)\\),\\s*(<anonymous>)?:(\\d+)?:(\\d+)/;\n\n// in AppProviders (at App.tsx:28)\n// eslint-disable-next-line security/detect-unsafe-regex\nconst NODE_REGEX = /^\\s*in\\s(?:([^\\\\/]+(?:\\s\\[as\\s\\S+\\])?)\\s\\(?)?\\(at?\\s?(.*?):(\\d+)(?::(\\d+))?\\)?\\s*$/;\nconst NODE_NESTED_REGEX = /in\\s(.*)\\s\\(at\\s(.+)\\)\\sat/;\n\n// eslint-disable-next-line security/detect-unsafe-regex,regexp/no-super-linear-backtracking\nconst REACT_ANDROID_NATIVE_REGEX = /^(?:.*@)?(.*):(\\d+):(\\d+)$/;\n\n// gecko regex: `(?:bundle|\\d+\\.js)`: `bundle` is for react native, `\\d+\\.js` also but specifically for ram bundles because it\n// generates filenames without a prefix like `file://` the filenames in the stacktrace are just 42.js\n// We need this specific case for now because we want no other regex to match.\n// eslint-disable-next-line regexp/no-super-linear-backtracking,security/detect-unsafe-regex,regexp/no-optional-assertion,regexp/no-trivially-nested-quantifier,regexp/no-useless-escape,no-useless-escape,regexp/optimal-quantifier-concatenation\nconst GECKO_REGEX = /^\\s*(.*?)(?:\\((.*?)\\))?(?:^|@)?((?:[-a-z]+)?:\\/.*?|\\[native code\\]|[^@]*(?:bundle|\\d+\\.js)|\\/[\\w\\-. \\/=]+)(?::(\\d+))?(?::(\\d+))?\\s*$/i;\n// eslint-disable-next-line security/detect-unsafe-regex\nconst GECKO_EVAL_REGEX = /(\\S+) line (\\d+)(?: > eval line \\d+)* > eval/i;\n\n// @http://localhost:8080/file.js:33:9\n// foo@debugger eval code:1:27\n// obj[\"@fn\"]@Scratchpad/1:10:29\n// eslint-disable-next-line regexp/no-super-linear-backtracking\nconst FIREFOX_REGEX = /(\\S[^\\s[]*\\[.*\\]|.*?)@(.*):(\\d+):(\\d+)/;\n\n// Used to sanitize webpack (error: *) wrapped stack errors\nconst WEBPACK_ERROR_REGEXP = /\\(error: (.*)\\)/;\n\n/**\n * Safari web extensions, starting version unknown, can produce \"frames-only\" stacktraces.\n * What it means, is that instead of format like:\n *\n * Error: wat\n * at function@url:row:col\n * at function@url:row:col\n * at function@url:row:col\n *\n * it produces something like:\n *\n * function@url:row:col\n * function@url:row:col\n * function@url:row:col\n *\n * Because of that, it won't be captured by `chrome` RegExp and will fall into `Gecko` branch.\n * This function is extracted so that we can use it in both places without duplicating the logic.\n * Unfortunately \"just\" changing RegExp is too complicated now and making it pass all tests\n * and fix this case seems like an impossible, or at least way too time-consuming task.\n */\nconst extractSafariExtensionDetails = (methodName: string, url: string): [string, string] => {\n const isSafariExtension = methodName.includes(\"safari-extension\");\n const isSafariWebExtension = methodName.includes(\"safari-web-extension\");\n\n return isSafariExtension || isSafariWebExtension\n ? [\n methodName.includes(\"@\") ? (methodName.split(\"@\")[0] as string) : UNKNOWN_FUNCTION,\n isSafariExtension ? `safari-extension:${url}` : `safari-web-extension:${url}`,\n ]\n : [methodName, url];\n};\n\nconst parseMapped = (trace: Trace, maybeMapped: string) => {\n const match = CHROMIUM_MAPPED.exec(maybeMapped);\n\n if (match) {\n // eslint-disable-next-line no-param-reassign,prefer-destructuring\n trace.file = match[1];\n // eslint-disable-next-line no-param-reassign\n trace.line = +(<string>match[2]);\n // eslint-disable-next-line no-param-reassign\n trace.column = +(<string>match[3]);\n }\n};\n\n// eslint-disable-next-line sonarjs/cognitive-complexity\nconst parseNode = (line: string): Trace | undefined => {\n const nestedNode = NODE_NESTED_REGEX.exec(line);\n\n if (nestedNode) {\n debugLog(`parse nested node error stack line: \"${line}\"`, `found: ${JSON.stringify(nestedNode)}`);\n\n const split = (nestedNode[2] as string).split(\":\");\n\n return {\n column: split[2] ? +split[2] : undefined,\n file: split[0],\n line: split[1] ? +split[1] : undefined,\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n methodName: nestedNode[1] || UNKNOWN_FUNCTION,\n raw: line,\n type: undefined,\n };\n }\n\n const node = NODE_REGEX.exec(line);\n\n if (node) {\n debugLog(`parse node error stack line: \"${line}\"`, `found: ${JSON.stringify(node)}`);\n\n const trace = {\n column: node[4] ? +node[4] : undefined,\n file: node[2] ? node[2].replace(/at\\s/, \"\") : undefined,\n line: node[3] ? +node[3] : undefined,\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n methodName: node[1] || UNKNOWN_FUNCTION,\n raw: line,\n type: line.startsWith(\"internal\") ? (\"internal\" as TraceType) : undefined,\n };\n\n parseMapped(trace, `${node[2]}:${node[3]}:${node[4]}`);\n\n return trace;\n }\n\n return undefined;\n};\n\n// eslint-disable-next-line sonarjs/cognitive-complexity\nconst parseChromium = (line: string): Trace | undefined => {\n const parts = CHROMIUM_REGEX.exec(line) as (string | undefined)[] | null;\n\n if (parts) {\n debugLog(`parse chrome error stack line: \"${line}\"`, `found: ${JSON.stringify(parts)}`);\n\n const isNative = parts[2] && parts[2].startsWith(\"native\"); // start of line\n const isEval = (parts[2] && parts[2].startsWith(\"eval\")) || (parts[1] && parts[1].startsWith(\"eval\")); // start of line\n\n let evalOrigin: Trace | undefined;\n let windowsParts:\n | {\n column: number | undefined;\n file: string | undefined;\n line: number | undefined;\n }\n | undefined;\n\n if (isEval) {\n const subMatch = CHROMIUM_EVAL_REGEX.exec(line);\n\n if (subMatch) {\n // can be index.js:123:39 or index.js:123 or index.js\n const split = /(\\S+):(\\d+):(\\d+)|(\\S+):(\\d+)$/.exec(subMatch[1] as string);\n\n if (split) {\n // throw out eval line/column and use top-most line/column number\n parts[2] = split[4] ?? split[1]; // url\n parts[3] = split[5] ?? split[2]; // line\n // eslint-disable-next-line prefer-destructuring\n parts[4] = split[3]; // column\n } else if (subMatch[2]) {\n // eslint-disable-next-line prefer-destructuring\n parts[2] = subMatch[1];\n }\n\n if (subMatch[2]) {\n evalOrigin = {\n column: subMatch[4] ? +subMatch[4] : undefined,\n file: subMatch[2],\n line: subMatch[3] ? +subMatch[3] : undefined,\n methodName: \"eval\",\n raw: line,\n type: \"eval\" as TraceType,\n };\n }\n } else {\n const windowsSubMatch = WINDOWS_EVAL_REGEX.exec(line);\n\n if (windowsSubMatch) {\n windowsParts = {\n column: windowsSubMatch[5] ? +windowsSubMatch[5] : undefined,\n file: windowsSubMatch[3],\n line: windowsSubMatch[4] ? +windowsSubMatch[4] : undefined,\n };\n\n evalOrigin = {\n column: windowsSubMatch[8] ? +windowsSubMatch[8] : undefined,\n file: windowsSubMatch[2],\n line: windowsSubMatch[7] ? +windowsSubMatch[7] : undefined,\n methodName: \"eval\",\n raw: windowsSubMatch[0],\n type: \"eval\" as TraceType,\n };\n }\n }\n }\n\n const [methodName, file] = extractSafariExtensionDetails(\n // Normalize IE's 'Anonymous function'\n parts[1] ? parts[1].replace(/^Anonymous function$/, \"<anonymous>\") : UNKNOWN_FUNCTION,\n parts[2] as string,\n );\n\n const trace = {\n column: parts[4] ? +parts[4] : undefined,\n evalOrigin,\n file,\n line: parts[3] ? +parts[3] : undefined,\n methodName,\n raw: line,\n type: (isEval ? \"eval\" : isNative ? \"native\" : undefined) as TraceType,\n };\n\n if (windowsParts) {\n trace.column = windowsParts.column;\n trace.file = windowsParts.file as string;\n trace.line = windowsParts.line;\n } else {\n parseMapped(trace, `${file}:${parts[3]}:${parts[4]}`);\n }\n\n return trace;\n }\n\n return undefined;\n};\n\n// eslint-disable-next-line sonarjs/cognitive-complexity\nconst parseGecko = (line: string, topFrameMeta?: TopFrameMeta): Trace | undefined => {\n const parts = GECKO_REGEX.exec(line);\n\n if (parts) {\n debugLog(`parse gecko error stack line: \"${line}\"`, `found: ${JSON.stringify(parts)}`);\n\n const isEval = parts[3]?.includes(\" > eval\");\n const subMatch = isEval && parts[3] && GECKO_EVAL_REGEX.exec(parts[3]);\n\n let evalOrigin: Trace | undefined;\n\n if (isEval && subMatch) {\n // overwrite file\n parts[3] = <string>subMatch[1];\n\n evalOrigin = {\n column: parts[5] ? +parts[5] : undefined,\n file: parts[3],\n line: parts[4] ? +parts[4] : undefined,\n methodName: \"eval\",\n raw: line,\n type: \"eval\" as TraceType,\n };\n\n // overwrite line\n parts[4] = <string>subMatch[2];\n }\n\n const [methodName, file] = extractSafariExtensionDetails(\n // Normalize IE's 'Anonymous function'\n parts[1] ? parts[1].replace(/^Anonymous function$/, \"<anonymous>\") : UNKNOWN_FUNCTION,\n parts[3] as string,\n );\n\n let column: number | undefined; // no column when eval\n\n if ((topFrameMeta?.type === \"safari\" || (!isEval && topFrameMeta?.type === \"firefox\")) && topFrameMeta.column) {\n column = topFrameMeta.column;\n } else if (!isEval && parts[5]) {\n column = +parts[5];\n }\n\n let lineNumber: number | undefined; // no line when eval\n\n if ((topFrameMeta?.type === \"safari\" || (!isEval && topFrameMeta?.type === \"firefox\")) && topFrameMeta.line) {\n lineNumber = topFrameMeta.line;\n } else if (parts[4]) {\n lineNumber = +parts[4];\n }\n\n return {\n column,\n evalOrigin,\n file,\n line: lineNumber,\n methodName,\n raw: line,\n type: isEval ? \"eval\" : file.includes(\"[native code]\") ? \"native\" : undefined,\n };\n }\n\n return undefined;\n};\n\nconst parseFirefox = (line: string, topFrameMeta?: TopFrameMeta): Trace | undefined => {\n const parts = FIREFOX_REGEX.exec(line);\n\n const isEval = parts ? (parts[2] as string).includes(\" > eval\") : false;\n\n if (!isEval && parts) {\n debugLog(`parse firefox error stack line: \"${line}\"`, `found: ${JSON.stringify(parts)}`);\n\n return {\n column: parts[4] ? +parts[4] : topFrameMeta?.column ?? undefined,\n file: parts[2],\n line: parts[3] ? +parts[3] : topFrameMeta?.line ?? undefined,\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n methodName: parts[1] || UNKNOWN_FUNCTION,\n raw: line,\n type: undefined,\n };\n }\n\n return undefined;\n};\n\nconst parseReactAndroidNative = (line: string): Trace | undefined => {\n const parts = REACT_ANDROID_NATIVE_REGEX.exec(line);\n\n if (parts) {\n debugLog(`parse react android native error stack line: \"${line}\"`, `found: ${JSON.stringify(parts)}`);\n\n return {\n column: parts[3] ? +parts[3] : undefined,\n file: parts[1],\n line: parts[2] ? +parts[2] : undefined,\n methodName: UNKNOWN_FUNCTION,\n raw: line,\n type: undefined,\n };\n }\n\n return undefined;\n};\n\n// eslint-disable-next-line sonarjs/cognitive-complexity\nconst parse = (error: Error, options: Partial<{ frameLimit: number }> = {}): Trace[] => {\n const { frameLimit = 50 } = options;\n\n // @ts-expect-error missing stacktrace property\n let lines = (error.stacktrace ?? error.stack ?? \"\")\n .split(\"\\n\")\n .map((line: string): string => {\n // https://github.com/getsentry/sentry-javascript/issues/5459\n // Remove webpack (error: *) wrappers\n const cleanedLine = WEBPACK_ERROR_REGEXP.test(line) ? line.replace(WEBPACK_ERROR_REGEXP, \"$1\") : line;\n\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n return cleanedLine.replace(/^\\s+|\\s+$/g, \"\");\n })\n // https://github.com/getsentry/sentry-javascript/issues/7813\n // Skip Error: lines\n // Skip eval code without more context\n .filter((line: string): boolean => !/\\S*Error: /.test(line) && line !== \"eval code\");\n\n if (lines.length > frameLimit) {\n lines = lines.slice(0, frameLimit);\n }\n\n // eslint-disable-next-line unicorn/no-array-reduce,@typescript-eslint/no-unsafe-return\n return lines.reduce((stack: Trace[], line: string, currentIndex: number): Trace[] => {\n if (!line) {\n return stack;\n }\n\n // Ignore lines over 1kb as they are unlikely to be stack frames.\n // Many of the regular expressions use backtracking which results in run time that increases exponentially with\n // input size. Huge strings can result in hangs/Denial of Service:\n // https://github.com/getsentry/sentry-javascript/issues/2286\n if (line.length > 1024) {\n return stack;\n }\n\n let parseResult: Trace | undefined;\n\n if (/^\\s*in\\s.*/.test(line)) {\n parseResult = parseNode(line);\n // eslint-disable-next-line regexp/no-super-linear-backtracking\n } else if (/^.*?\\s*at\\s.*/.test(line)) {\n parseResult = parseChromium(line);\n // eslint-disable-next-line regexp/no-super-linear-backtracking\n } else if (/^.*?\\s*@.*|\\[native code\\]/.test(line)) {\n let topFrameMeta: TopFrameMeta | undefined;\n\n if (currentIndex === 0) {\n // @ts-expect-error columnNumber and lineNumber property only exists on Firefox\n if (error.columnNumber || error.lineNumber) {\n topFrameMeta = {\n // @ts-expect-error columnNumber and columnNumber property only exists on Firefox\n column: error.columnNumber,\n // @ts-expect-error columnNumber and lineNumber property only exists on Firefox\n line: error.lineNumber,\n type: \"firefox\",\n };\n // @ts-expect-error line and column property only exists on safari\n } else if (error.line || error.column) {\n topFrameMeta = {\n // @ts-expect-error column property only exists on safari\n column: error.column,\n // @ts-expect-error line property only exists on safari\n line: error.line,\n type: \"safari\",\n };\n }\n }\n\n parseResult =\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n parseFirefox(line, topFrameMeta) || parseGecko(line, topFrameMeta);\n } else {\n parseResult = parseReactAndroidNative(line);\n }\n\n if (parseResult) {\n stack.push(parseResult);\n } else {\n debugLog(`parse error stack line: \"${line}\"`, \"not parser found\");\n }\n\n return stack;\n }, []);\n};\n\nexport default parse;\n"]}
|
package/dist/code-frame/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":""}
|
package/dist/error/index.js
DELETED
package/dist/error/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":""}
|
package/dist/index.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export { a as CODE_FRAME_POINTER, b as codeFrame } from './chunk-BKLPSU5H.js';
|
|
2
|
-
export { c as VisulimaError, a as getErrorCauses, b as isVisulimaError } from './chunk-HAVTTG7L.js';
|
|
3
|
-
export { a as parseStacktrace } from './chunk-WOVTAVVR.js';
|
|
4
|
-
|
|
5
|
-
var m=(r,e)=>{let o=0,t=e.length-2;for(;o<t;){let n=o+(t-o>>1);if(r<e[n])t=n-1;else if(r>=e[n+1])o=n+1;else {o=n;break}}return o},g=r=>r.split(/\n|\r(?!\n)/).reduce((e,o)=>(e.push(e.at(-1)+o.length+1),e),[0]),h=(r,e,o)=>{let t=o?.skipChecks??!1;if(!t&&(!Array.isArray(r)&&typeof r!="string"||(typeof r=="string"||Array.isArray(r))&&r.length===0))return {column:0,line:0};if(!t&&(typeof e!="number"||typeof r=="string"&&e>=r.length||Array.isArray(r)&&e+1>=r.at(-1)))return {column:0,line:0};if(typeof r=="string"){let s=g(r),a=m(e,s);return {column:e-s[a]+1,line:a+1}}let n=m(e,r);return {column:e-r[n]+1,line:n+1}},C=h;
|
|
6
|
-
|
|
7
|
-
export { C as indexToLineColumn };
|
|
8
|
-
//# sourceMappingURL=out.js.map
|
|
9
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/code-frame/index-to-line-column.ts"],"names":["binarySearch","element","array","m","n","key","getLineStartIndexes","string_","accumulator","current","indexToLineColumn","input","index","options","skipChecks","startIndexesOfEachLine","line","index_to_line_column_default"],"mappings":"6IAAA,IAAMA,EAAe,CAACC,EAAiBC,IAA4B,CAC/D,IAAIC,EAAI,EACJC,EAAIF,EAAM,OAAS,EAGvB,KAAOC,EAAIC,GAAG,CAEV,IAAMC,EAAMF,GAAMC,EAAID,GAAM,GAE5B,GAAIF,EAAWC,EAAMG,CAAG,EACpBD,EAAIC,EAAM,UACHJ,GAAYC,EAAMG,EAAM,CAAC,EAChCF,EAAIE,EAAM,MACP,CACHF,EAAIE,EACJ,KACJ,CACJ,CAEA,OAAOF,CACX,EAIMG,EAAuBC,GAEzBA,EAAQ,MAAM,aAAa,EAAE,OACzB,CAACC,EAAuBC,KACpBD,EAAY,KAAMA,EAAY,GAAG,EAAE,EAAeC,EAAQ,OAAS,CAAC,EAE7DD,GAEX,CAAC,CAAC,CACN,EAEEE,EAAoB,CACtBC,EACAC,EACAC,IAMC,CACD,IAAMC,EAAaD,GAAS,YAAc,GAE1C,GAAI,CAACC,IAAgB,CAAC,MAAM,QAAQH,CAAK,GAAK,OAAOA,GAAU,WAAe,OAAOA,GAAU,UAAY,MAAM,QAAQA,CAAK,IAAMA,EAAM,SAAW,GACjJ,MAAO,CAAE,OAAQ,EAAG,KAAM,CAAE,EAGhC,GACI,CAACG,IACA,OAAOF,GAAU,UAAa,OAAOD,GAAU,UAAYC,GAASD,EAAM,QAAY,MAAM,QAAQA,CAAK,GAAKC,EAAQ,GAAMD,EAAM,GAAG,EAAE,GAExI,MAAO,CAAE,OAAQ,EAAG,KAAM,CAAE,EAIhC,GAAI,OAAOA,GAAU,SAAU,CAE3B,IAAMI,EAAyBT,EAAoBK,CAAK,EAClDK,EAAOhB,EAAaY,EAAOG,CAAsB,EAEvD,MAAO,CAEH,OAAQH,EAASG,EAAuBC,CAAI,EAAe,EAC3D,KAAMA,EAAO,CACjB,CACJ,CAGA,IAAMA,EAAOhB,EAAaY,EAAOD,CAAK,EAEtC,MAAO,CAEH,OAAQC,EAASD,EAAMK,CAAI,EAAe,EAC1C,KAAMA,EAAO,CACjB,CACJ,EAEOC,EAAQP","sourcesContent":["const binarySearch = (element: number, array: number[]): number => {\n let m = 0;\n let n = array.length - 2;\n\n // eslint-disable-next-line no-loops/no-loops\n while (m < n) {\n // eslint-disable-next-line no-bitwise\n const key = m + ((n - m) >> 1);\n // eslint-disable-next-line security/detect-object-injection\n if (element < (array[key] as number)) {\n n = key - 1;\n } else if (element >= (array[key + 1] as number)) {\n m = key + 1;\n } else {\n m = key;\n break;\n }\n }\n\n return m;\n};\n\n// split by line break characters, CR, LF or CRLF\n// compile an array of indexes, where each line starts\nconst getLineStartIndexes = (string_: string): number[] =>\n // eslint-disable-next-line unicorn/no-array-reduce\n string_.split(/\\n|\\r(?!\\n)/).reduce(\n (accumulator: number[], current) => {\n accumulator.push((accumulator.at(-1) as number) + current.length + 1);\n\n return accumulator;\n },\n [0],\n );\n\nconst indexToLineColumn = (\n input: number[] | string,\n index: number,\n options?: {\n skipChecks: boolean;\n },\n): {\n column: number;\n line: number;\n} => {\n const skipChecks = options?.skipChecks ?? false;\n\n if (!skipChecks && ((!Array.isArray(input) && typeof input !== \"string\") || ((typeof input === \"string\" || Array.isArray(input)) && input.length === 0))) {\n return { column: 0, line: 0 };\n }\n\n if (\n !skipChecks &&\n (typeof index !== \"number\" || (typeof input === \"string\" && index >= input.length) || (Array.isArray(input) && index + 1 >= (input.at(-1) as number)))\n ) {\n return { column: 0, line: 0 };\n }\n\n // it depends, pre-cached input was given or a string\n if (typeof input === \"string\") {\n // not cached - calculate the line start indexes\n const startIndexesOfEachLine = getLineStartIndexes(input);\n const line = binarySearch(index, startIndexesOfEachLine);\n\n return {\n // eslint-disable-next-line security/detect-object-injection\n column: index - (startIndexesOfEachLine[line] as number) + 1,\n line: line + 1,\n };\n }\n\n // ELSE - cached line start indexes - we don't even need the string source!\n const line = binarySearch(index, input);\n\n return {\n // eslint-disable-next-line security/detect-object-injection\n column: index - (input[line] as number) + 1,\n line: line + 1,\n };\n};\n\nexport default indexToLineColumn;\n"]}
|
package/dist/stacktrace/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":""}
|