@visulima/error 4.1.0 → 4.3.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 CHANGED
@@ -1,3 +1,28 @@
1
+ ## @visulima/error [4.3.0](https://github.com/visulima/visulima/compare/@visulima/error@4.2.0...@visulima/error@4.3.0) (2024-07-02)
2
+
3
+ ### Features
4
+
5
+ * **error:** added a prefix option to renderError ([e164d52](https://github.com/visulima/visulima/commit/e164d528dfef4195a7cbd9f8843f58148dfc5e08))
6
+ * **error:** added stackFilter to parseStacktrace, fixed parsing AggregateError stack, added filterStacktrace to renderError ([bb4b4f7](https://github.com/visulima/visulima/commit/bb4b4f72ab00c63bf0ac5e9e6a9a01110c102a1c))
7
+
8
+ ### Bug Fixes
9
+
10
+ * **error:** renamed stackFilter to filter and changed interface for filterStacktrace ([b95dfb6](https://github.com/visulima/visulima/commit/b95dfb640b0d243122bff2ddf2e32a79101652e1))
11
+
12
+ ### Miscellaneous Chores
13
+
14
+ * changed typescript version back to 5.4.5 ([55d28bb](https://github.com/visulima/visulima/commit/55d28bbdc103718d19f844034b38a0e8e5af798a))
15
+
16
+ ## @visulima/error [4.2.0](https://github.com/visulima/visulima/compare/@visulima/error@4.1.0...@visulima/error@4.2.0) (2024-07-02)
17
+
18
+ ### Features
19
+
20
+ * **error:** added renderError, added cause to visulima-error ([#449](https://github.com/visulima/visulima/issues/449)) ([4e78638](https://github.com/visulima/visulima/commit/4e7863890ccbc66a1427d4e6fd4c1879cf448b77))
21
+
22
+ ### Miscellaneous Chores
23
+
24
+ * updated dev dependencies ([34df456](https://github.com/visulima/visulima/commit/34df4569f2fc074823a406c44a131c8fbae2b147))
25
+
1
26
  ## @visulima/error [4.1.0](https://github.com/visulima/visulima/compare/@visulima/error@4.0.0...@visulima/error@4.1.0) (2024-07-01)
2
27
 
3
28
  ### Features
package/README.md CHANGED
@@ -206,11 +206,11 @@ Currently supported browsers/platforms:
206
206
  - Opera (Chromium based)
207
207
 
208
208
  ```ts
209
- import { parseStack } from "@visulima/error";
209
+ import { parseStacktrace } from "@visulima/error";
210
210
 
211
211
  const error = new Error("My error message");
212
212
 
213
- const stack = parseStack(error);
213
+ const stack = parseStacktrace(error);
214
214
 
215
215
  console.log(stack);
216
216
 
@@ -228,6 +228,30 @@ console.log(stack);
228
228
  // ];
229
229
  ```
230
230
 
231
+ ### API
232
+
233
+ #### error
234
+
235
+ Type: `Error`
236
+
237
+ The error to parse.
238
+
239
+ #### options
240
+
241
+ Type: `object`
242
+
243
+ ##### options.filter
244
+
245
+ Type: `Function`
246
+
247
+ A function to filter the stack frames.
248
+
249
+ ##### options.frameLimit
250
+
251
+ Type: `number`
252
+
253
+ The maximum number of frames to parse.
254
+
231
255
  ## `serialize` an error object
232
256
 
233
257
  - Ensures errors are safe to serialize with JSON
@@ -254,6 +278,102 @@ const errorString = JSON.stringify(errorObject);
254
278
  const newErrorObject = JSON.parse(errorString);
255
279
  ```
256
280
 
281
+ ## renderError - pretty print an error
282
+
283
+ ```ts
284
+ import { renderError } from "@visulima/error";
285
+
286
+ const error = new Error("This is an error message");
287
+
288
+ console.log(renderError(error));
289
+
290
+ // Error: This is an error message
291
+ //
292
+ // at <unknown> file:///home/visulima/visulima/examples/error/node/render-error.js:5
293
+ // 1 | import { renderError } from "@visulima/error";
294
+ // 2 |
295
+ // 3 | const error = new Error("This is an error message");
296
+ // 4 |
297
+ // ❯ 5 | console.log(renderError(new Error("This is an error message")));
298
+ // | ^
299
+ // 6 |
300
+ //
301
+ // at ModuleJob.run node:internal/modules/esm/module_job:195
302
+ // at async ModuleLoader.import node:internal/modules/esm/loader:336
303
+ // at async loadESM node:internal/process/esm_loader:34
304
+ // at async handleMainPromise node:internal/modules/run_main:106
305
+ ```
306
+
307
+ #### colorized output
308
+
309
+ Use the `@visulima/colorize`, `chalk` or some other package to colorize the output.
310
+
311
+ ![colorized output](./__assets__/pretty-error-render-with-cause-and-hint.png)
312
+
313
+ ### API
314
+
315
+ #### error
316
+
317
+ Type: `AggregateError | Error | VisulimaError` \
318
+ The error to render.
319
+
320
+ #### options
321
+
322
+ Type: `object`
323
+
324
+ ##### options.color
325
+
326
+ Type: `object` \
327
+ The color options.
328
+
329
+ ##### options.cwd
330
+
331
+ Type: `string`
332
+
333
+ The current working directory.
334
+
335
+ ##### options.displayShortPath
336
+
337
+ Type: `boolean` \
338
+ Default: `false`
339
+
340
+ Display the short path.
341
+
342
+ ##### options.framesMaxLimit
343
+
344
+ Type: `number` \
345
+ Default: `Number.Infinity`
346
+
347
+ The maximum number of frames to display.
348
+
349
+ ##### options.hideErrorCauseCodeView
350
+
351
+ Type: `boolean` \
352
+ Default: `false`
353
+
354
+ Hide the error cause code view.
355
+
356
+ ##### options.hideErrorCodeView
357
+
358
+ Type: `boolean` \
359
+ Default: `false`
360
+
361
+ Hide the error code view.
362
+
363
+ ##### options.hideErrorTitle
364
+
365
+ Type: `boolean` \
366
+ Default: `false`
367
+
368
+ Hide the error title.
369
+
370
+ ##### options.hideMessage
371
+
372
+ Type: `boolean` \
373
+ Default: `false`
374
+
375
+ Hide the error message.
376
+
257
377
  ## Supported Node.js Versions
258
378
 
259
379
  Libraries in this ecosystem make the best effort to track [Node.js’ release schedule](https://github.com/nodejs/release#release-schedule).
@@ -275,7 +395,6 @@ If you would like to help take a look at the [list of issues](https://github.com
275
395
  ### Related Projects
276
396
 
277
397
  - [baseerr](https://github.com/tjmehta/baseerr): merge another error with additional properties.
278
- - [callsite-record](https://github.com/inikulin/callsite-record): create a fancy log entries for errors and function call sites.
279
398
  - [callsites](https://github.com/sindresorhus/callsites): get callsites from the V8 stack trace API.
280
399
  - [explain-error](https://github.com/dominictarr/explain-error): wrap an error with additional explanation.
281
400
  - [error-wrapper](https://github.com/spudly/error-wrapper): merges the stack of another error to its own.
@@ -284,11 +403,15 @@ If you would like to help take a look at the [list of issues](https://github.com
284
403
  - [clarify](https://github.com/AndreasMadsen/clarify): remove node related stack trace noise.
285
404
  - [piotr-szewczyk/stacktrace-parser-node](https://github.com/piotr-szewczyk/stacktrace-parser-node)
286
405
  - [pretty-error](https://github.com/AriaMinaei/pretty-error): make the call stacks clear.
406
+ - [node-pretty-exceptions](https://github.com/ahmadnassri/node-pretty-exceptions) - Pretty and more helpful uncaught exceptions, automatically
407
+ - [youch-terminal](https://github.com/poppinss/youch-terminal/tree/develop) - Display youch error message on terminal
287
408
  - [ono](https://github.com/bigstickcarpet/ono): allow different types of error to be thrown.
288
- - [ololog](https://github.com/xpl/ololog): another logger with a similar motivation but only support console.log as its sole transport.
289
409
  - [stacktracejs/error-stack-parser](https://github.com/stacktracejs/error-stack-parser)
290
410
  - [marvinhagemeister/errorstacks](https://github.com/marvinhagemeister/errorstacks) Tiny library to parse error stack traces
291
411
  - [getsentry/sentry-javascript](https://github.com/getsentry/sentry-javascript)
412
+ - [serialize-error](https://github.com/sindresorhus/serialize-error) - Serialize/deserialize an error into a plain object
413
+ - [baseerr](https://github.com/tjmehta/baseerr): merge another error with additional properties.
414
+ - [callsite-record](https://github.com/inikulin/callsite-record) - Create fancy log entries for errors and function call sites
292
415
 
293
416
  ## License
294
417
 
@@ -1,6 +1,6 @@
1
1
  "use strict";var P=Object.defineProperty;var v=(t,e)=>P(t,"name",{value:e,configurable:!0});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var F=Object.defineProperty,S=v((t,e)=>F(t,"name",{value:e,configurable:!0}),"r$1");const N=S(t=>t.replaceAll(/\r\n|\r(?!\n)|\n/gu,`
2
- `),"normalizeLF"),T=globalThis.process||Object.create(null),O={versions:{}},j=new Proxy(T,{get(t,e){if(e in t)return t[e];if(e in O)return O[e]}});var _=Object.defineProperty,C=v((t,e)=>_(t,"name",{value:e,configurable:!0}),"b");const R=C((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),b=Math.min(e.length,m+n);o===-1&&(g=0),m===-1&&(b=e.length);const p=m-o,a={};if(p)for(let r=0;r<=p;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===p)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:b,markerLines:a,start:g}},"getMarkerLines");var W=Object.defineProperty,$=v((t,e)=>W(t,"name",{value:e,configurable:!0}),"o");const k=j.platform==="win32"&&!j.env?.WT_SESSION?">":"❯",x=$((t,e,d)=>{const n={linesAbove:2,linesBelow:3,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=N(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:b,message:p}=n.color;let a=i.slice(m,o).map((r,s)=>{const c=m+1+s,h=l[c],M=` ${c}`.slice(-u),w=!l[c+1],y=` ${M}${n.showGutter?" |":""}`;if(h){let A="";if(Array.isArray(h)){const E=r.replaceAll(/[^\t]/g," ").slice(0,Math.max(h[0]-1,0)),L=h[1]||1;A=[`
4
- `,g(y.replaceAll(/\d/g," "))," ",E,b("^").repeat(L)].join(""),w&&n.message&&(A+=` ${p(n.message)}`)}return[b(k),g(y),r.length>0?` ${r}`:"",A].join("")}return` ${g(y)}${r.length>0?` ${r}`:""}`}).join(`
5
- `);return n.message&&!f&&(a=`${" ".repeat(u+1)}${n.message}
6
- ${a}`),a},"codeFrame");exports.CODE_FRAME_POINTER=k;exports.codeFrame=x;
2
+ `),"normalizeLF"),T=globalThis.process||Object.create(null),x={versions:{}},j=new Proxy(T,{get(t,e){if(e in t)return t[e];if(e in x)return x[e]}});var _=Object.defineProperty,C=v((t,e)=>_(t,"name",{value:e,configurable:!0}),"b");const R=C((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,y=v((t,e)=>W(t,"name",{value:e,configurable:!0}),"o");const M=j.platform==="win32"&&!j.env?.WT_SESSION?">":"❯",I=y((t,e,d)=>{const n={linesAbove:2,linesBelow:3,prefix:"",showGutter:!0,showLineNumbers:!0,tabWidth:4,...d,color:{gutter:y(r=>r,"gutter"),marker:y(r=>r,"marker"),message:y(r=>r,"message"),...d?.color}},f=e.start&&typeof e.start.column=="number";let i=N(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),w=!l[c+1],A=" "+k+(n.showGutter?" |":"");if(h){let O="";if(Array.isArray(h)){const E=r.replaceAll(/[^\t]/g," ").slice(0,Math.max(h[0]-1,0)),L=h[1]||1;O=[`
4
+ `,n.prefix+g(A.replaceAll(/\d/g," "))," ",E,p("^").repeat(L)].join(""),w&&n.message&&(O+=` ${b(n.message)}`)}return[n.prefix+p(M),g(A),r.length>0?" "+r:"",O].join("")}return n.prefix+" "+g(A)+(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=M;exports.codeFrame=I;
@@ -1,27 +1,7 @@
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
- showGutter?: boolean;
20
- showLineNumbers?: boolean;
21
- tabWidth?: number | false;
22
- };
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';
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, type CodeFrameLocation, type CodeFrameNodeLocation, type CodeFrameOptions, type ColorizeMethod, codeFrame };
7
+ export { CODE_FRAME_POINTER, CodeFrameNodeLocation, CodeFrameOptions, codeFrame };
@@ -1,27 +1,7 @@
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
- showGutter?: boolean;
20
- showLineNumbers?: boolean;
21
- tabWidth?: number | false;
22
- };
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';
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, type CodeFrameLocation, type CodeFrameNodeLocation, type CodeFrameOptions, type ColorizeMethod, codeFrame };
7
+ export { CODE_FRAME_POINTER, CodeFrameNodeLocation, CodeFrameOptions, codeFrame };
@@ -1,27 +1,7 @@
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
- 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, type CodeFrameLocation, type CodeFrameNodeLocation, type CodeFrameOptions, type ColorizeMethod, codeFrame };
7
+ export { CODE_FRAME_POINTER, CodeFrameNodeLocation, CodeFrameOptions, codeFrame };
@@ -1,6 +1,6 @@
1
- var P=Object.defineProperty;var v=(t,e)=>P(t,"name",{value:e,configurable:!0});var x=Object.defineProperty,E=v((t,e)=>x(t,"name",{value:e,configurable:!0}),"r$1");const F=E(t=>t.replaceAll(/\r\n|\r(?!\n)|\n/gu,`
2
- `),"normalizeLF"),N=globalThis.process||Object.create(null),k={versions:{}},j=new Proxy(N,{get(t,e){if(e in t)return t[e];if(e in k)return k[e]}});var S=Object.defineProperty,W=v((t,e)=>S(t,"name",{value:e,configurable:!0}),"b");const C=W((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 T=Object.defineProperty,$=v((t,e)=>T(t,"name",{value:e,configurable:!0}),"o");const _=j.platform==="win32"&&!j.env?.WT_SESSION?">":"❯",G=$((t,e,h)=>{const n={linesAbove:2,linesBelow:3,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=F(t).split(`
3
- `);typeof n?.tabWidth=="number"&&(i=i.map(r=>r.replaceAll(" "," ".repeat(n.tabWidth))));const{end:o,markerLines:l,start:m}=C(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],w=` ${c}`.slice(-u),L=!l[c+1],A=` ${w}${n.showGutter?" |":""}`;if(d){let y="";if(Array.isArray(d)){const O=r.replaceAll(/[^\t]/g," ").slice(0,Math.max(d[0]-1,0)),M=d[1]||1;y=[`
4
- `,g(A.replaceAll(/\d/g," "))," ",O,p("^").repeat(M)].join(""),L&&n.message&&(y+=` ${b(n.message)}`)}return[p(_),g(A),r.length>0?` ${r}`:"",y].join("")}return` ${g(A)}${r.length>0?` ${r}`:""}`}).join(`
5
- `);return n.message&&!f&&(a=`${" ".repeat(u+1)}${n.message}
6
- ${a}`),a},"codeFrame");export{_ as CODE_FRAME_POINTER,G as codeFrame};
1
+ var P=Object.defineProperty;var v=(t,e)=>P(t,"name",{value:e,configurable:!0});var E=Object.defineProperty,F=v((t,e)=>E(t,"name",{value:e,configurable:!0}),"r$1");const N=F(t=>t.replaceAll(/\r\n|\r(?!\n)|\n/gu,`
2
+ `),"normalizeLF"),S=globalThis.process||Object.create(null),j={versions:{}},k=new Proxy(S,{get(t,e){if(e in t)return t[e];if(e in j)return j[e]}});var W=Object.defineProperty,C=v((t,e)=>W(t,"name",{value:e,configurable:!0}),"b");const T=C((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,x=v((t,e)=>_(t,"name",{value:e,configurable:!0}),"o");const B=k.platform==="win32"&&!k.env?.WT_SESSION?">":"❯",I=x((t,e,h)=>{const n={linesAbove:2,linesBelow:3,prefix:"",showGutter:!0,showLineNumbers:!0,tabWidth:4,...h,color:{gutter:x(r=>r,"gutter"),marker:x(r=>r,"marker"),message:x(r=>r,"message"),...h?.color}},f=e.start&&typeof e.start.column=="number";let i=N(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],w=(" "+c).slice(-u),L=!l[c+1],A=" "+w+(n.showGutter?" |":"");if(d){let y="";if(Array.isArray(d)){const O=r.replaceAll(/[^\t]/g," ").slice(0,Math.max(d[0]-1,0)),M=d[1]||1;y=[`
4
+ `,n.prefix+g(A.replaceAll(/\d/g," "))," ",O,p("^").repeat(M)].join(""),L&&n.message&&(y+=` ${b(n.message)}`)}return[n.prefix+p(B),g(A),r.length>0?" "+r:"",y].join("")}return n.prefix+" "+g(A)+(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,I as codeFrame};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../shared/error.uFKIz5VX.cjs");exports.VisulimaError=r.VisulimaError;exports.getErrorCauses=r.i;exports.isVisulimaError=r.isVisulimaError;exports.serializeError=r.serialize;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../shared/error.CylOaVUk.cjs");exports.VisulimaError=r.VisulimaError;exports.getErrorCauses=r.i;exports.isVisulimaError=r.isVisulimaError;exports.renderError=r.renderError;exports.serializeError=r.serialize;
@@ -1,26 +1,9 @@
1
- declare const getErrorCauses: <E = unknown>(error: E) => E[];
2
-
3
- type SerializedError<ErrorType = Error> = Record<PropertyKey, unknown> & {
4
- aggregateErrors?: SerializedError<ErrorType>[];
5
- cause?: unknown;
6
- code?: string;
7
- message: string;
8
- name: string;
9
- raw?: ErrorType;
10
- stack?: string;
11
- };
1
+ import { b as CodeFrameOptions, c as ColorizeMethod } from '../shared/error.CrVmNoPV.cjs';
12
2
 
13
- interface JsonError extends Error {
14
- toJSON: () => SerializedError;
15
- }
16
- type Options = {
17
- exclude?: string[];
18
- maxDepth?: number;
19
- useToJSON?: boolean;
20
- };
21
- declare const serialize: (error: AggregateError | Error | JsonError, options?: Options) => SerializedError;
3
+ declare const getErrorCauses: <E = unknown>(error: E) => E[];
22
4
 
23
5
  interface ErrorProperties {
6
+ cause?: Error | unknown;
24
7
  hint?: ErrorHint;
25
8
  location?: ErrorLocation;
26
9
  message?: string;
@@ -41,11 +24,52 @@ declare class VisulimaError extends Error {
41
24
  title: string | undefined;
42
25
  hint: ErrorHint | undefined;
43
26
  type: string;
44
- constructor(properties: ErrorProperties, ...parameters: any);
27
+ constructor({ cause, hint, location, message, name, stack, title }: ErrorProperties);
45
28
  setLocation(location: ErrorLocation): void;
46
29
  setName(name: string): void;
47
30
  setMessage(message: string): void;
48
31
  setHint(hint: ErrorHint): void;
49
32
  }
50
33
 
51
- export { type ErrorHint, type ErrorLocation, type ErrorProperties, type Options as ErrorWithCauseSerializerOptions, type SerializedError, VisulimaError, getErrorCauses, isVisulimaError, serialize as serializeError };
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
+ filterStacktrace: ((line: string) => boolean) | undefined;
44
+ framesMaxLimit: number;
45
+ hideErrorCauseCodeView: boolean;
46
+ hideErrorCodeView: boolean;
47
+ hideErrorErrorsCodeView: boolean;
48
+ hideErrorTitle: boolean;
49
+ hideMessage: boolean;
50
+ indentation: number | "\t";
51
+ prefix: string;
52
+ };
53
+ declare const renderError: (error: AggregateError | Error | VisulimaError, options?: Partial<Options$1>) => string;
54
+
55
+ type SerializedError<ErrorType = Error> = Record<PropertyKey, unknown> & {
56
+ aggregateErrors?: SerializedError<ErrorType>[];
57
+ cause?: unknown;
58
+ code?: string;
59
+ message: string;
60
+ name: string;
61
+ raw?: ErrorType;
62
+ stack?: string;
63
+ };
64
+
65
+ interface JsonError extends Error {
66
+ toJSON: () => SerializedError;
67
+ }
68
+ type Options = {
69
+ exclude?: string[];
70
+ maxDepth?: number;
71
+ useToJSON?: boolean;
72
+ };
73
+ declare const serialize: (error: AggregateError | Error | JsonError, options?: Options) => SerializedError;
74
+
75
+ 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 };
@@ -1,26 +1,9 @@
1
- declare const getErrorCauses: <E = unknown>(error: E) => E[];
2
-
3
- type SerializedError<ErrorType = Error> = Record<PropertyKey, unknown> & {
4
- aggregateErrors?: SerializedError<ErrorType>[];
5
- cause?: unknown;
6
- code?: string;
7
- message: string;
8
- name: string;
9
- raw?: ErrorType;
10
- stack?: string;
11
- };
1
+ import { b as CodeFrameOptions, c as ColorizeMethod } from '../shared/error.CrVmNoPV.mjs';
12
2
 
13
- interface JsonError extends Error {
14
- toJSON: () => SerializedError;
15
- }
16
- type Options = {
17
- exclude?: string[];
18
- maxDepth?: number;
19
- useToJSON?: boolean;
20
- };
21
- declare const serialize: (error: AggregateError | Error | JsonError, options?: Options) => SerializedError;
3
+ declare const getErrorCauses: <E = unknown>(error: E) => E[];
22
4
 
23
5
  interface ErrorProperties {
6
+ cause?: Error | unknown;
24
7
  hint?: ErrorHint;
25
8
  location?: ErrorLocation;
26
9
  message?: string;
@@ -41,11 +24,52 @@ declare class VisulimaError extends Error {
41
24
  title: string | undefined;
42
25
  hint: ErrorHint | undefined;
43
26
  type: string;
44
- constructor(properties: ErrorProperties, ...parameters: any);
27
+ constructor({ cause, hint, location, message, name, stack, title }: ErrorProperties);
45
28
  setLocation(location: ErrorLocation): void;
46
29
  setName(name: string): void;
47
30
  setMessage(message: string): void;
48
31
  setHint(hint: ErrorHint): void;
49
32
  }
50
33
 
51
- export { type ErrorHint, type ErrorLocation, type ErrorProperties, type Options as ErrorWithCauseSerializerOptions, type SerializedError, VisulimaError, getErrorCauses, isVisulimaError, serialize as serializeError };
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
+ filterStacktrace: ((line: string) => boolean) | undefined;
44
+ framesMaxLimit: number;
45
+ hideErrorCauseCodeView: boolean;
46
+ hideErrorCodeView: boolean;
47
+ hideErrorErrorsCodeView: boolean;
48
+ hideErrorTitle: boolean;
49
+ hideMessage: boolean;
50
+ indentation: number | "\t";
51
+ prefix: string;
52
+ };
53
+ declare const renderError: (error: AggregateError | Error | VisulimaError, options?: Partial<Options$1>) => string;
54
+
55
+ type SerializedError<ErrorType = Error> = Record<PropertyKey, unknown> & {
56
+ aggregateErrors?: SerializedError<ErrorType>[];
57
+ cause?: unknown;
58
+ code?: string;
59
+ message: string;
60
+ name: string;
61
+ raw?: ErrorType;
62
+ stack?: string;
63
+ };
64
+
65
+ interface JsonError extends Error {
66
+ toJSON: () => SerializedError;
67
+ }
68
+ type Options = {
69
+ exclude?: string[];
70
+ maxDepth?: number;
71
+ useToJSON?: boolean;
72
+ };
73
+ declare const serialize: (error: AggregateError | Error | JsonError, options?: Options) => SerializedError;
74
+
75
+ 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 };
@@ -1,26 +1,9 @@
1
- declare const getErrorCauses: <E = unknown>(error: E) => E[];
2
-
3
- type SerializedError<ErrorType = Error> = Record<PropertyKey, unknown> & {
4
- aggregateErrors?: SerializedError<ErrorType>[];
5
- cause?: unknown;
6
- code?: string;
7
- message: string;
8
- name: string;
9
- raw?: ErrorType;
10
- stack?: string;
11
- };
1
+ import { b as CodeFrameOptions, c as ColorizeMethod } from '../shared/error.CrVmNoPV.js';
12
2
 
13
- interface JsonError extends Error {
14
- toJSON: () => SerializedError;
15
- }
16
- type Options = {
17
- exclude?: string[];
18
- maxDepth?: number;
19
- useToJSON?: boolean;
20
- };
21
- declare const serialize: (error: AggregateError | Error | JsonError, options?: Options) => SerializedError;
3
+ declare const getErrorCauses: <E = unknown>(error: E) => E[];
22
4
 
23
5
  interface ErrorProperties {
6
+ cause?: Error | unknown;
24
7
  hint?: ErrorHint;
25
8
  location?: ErrorLocation;
26
9
  message?: string;
@@ -41,11 +24,52 @@ declare class VisulimaError extends Error {
41
24
  title: string | undefined;
42
25
  hint: ErrorHint | undefined;
43
26
  type: string;
44
- constructor(properties: ErrorProperties, ...parameters: any);
27
+ constructor({ cause, hint, location, message, name, stack, title }: ErrorProperties);
45
28
  setLocation(location: ErrorLocation): void;
46
29
  setName(name: string): void;
47
30
  setMessage(message: string): void;
48
31
  setHint(hint: ErrorHint): void;
49
32
  }
50
33
 
51
- export { type ErrorHint, type ErrorLocation, type ErrorProperties, type Options as ErrorWithCauseSerializerOptions, type SerializedError, VisulimaError, getErrorCauses, isVisulimaError, serialize as serializeError };
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
+ filterStacktrace: ((line: string) => boolean) | undefined;
44
+ framesMaxLimit: number;
45
+ hideErrorCauseCodeView: boolean;
46
+ hideErrorCodeView: boolean;
47
+ hideErrorErrorsCodeView: boolean;
48
+ hideErrorTitle: boolean;
49
+ hideMessage: boolean;
50
+ indentation: number | "\t";
51
+ prefix: string;
52
+ };
53
+ declare const renderError: (error: AggregateError | Error | VisulimaError, options?: Partial<Options$1>) => string;
54
+
55
+ type SerializedError<ErrorType = Error> = Record<PropertyKey, unknown> & {
56
+ aggregateErrors?: SerializedError<ErrorType>[];
57
+ cause?: unknown;
58
+ code?: string;
59
+ message: string;
60
+ name: string;
61
+ raw?: ErrorType;
62
+ stack?: string;
63
+ };
64
+
65
+ interface JsonError extends Error {
66
+ toJSON: () => SerializedError;
67
+ }
68
+ type Options = {
69
+ exclude?: string[];
70
+ maxDepth?: number;
71
+ useToJSON?: boolean;
72
+ };
73
+ declare const serialize: (error: AggregateError | Error | JsonError, options?: Options) => SerializedError;
74
+
75
+ 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 };
@@ -1 +1 @@
1
- import{V as a,i,a as o,s as e}from"../shared/error.CVJAi2IP.mjs";export{a as VisulimaError,i as getErrorCauses,o as isVisulimaError,e as serializeError};
1
+ import{V as a,i,a as e,r as o,s as E}from"../shared/error.rD6X6s7e.mjs";export{a as VisulimaError,i as getErrorCauses,e as isVisulimaError,o as renderError,E as serializeError};
package/dist/index.cjs CHANGED
@@ -1 +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"),s=require("./shared/error.uFKIz5VX.cjs"),f=require("./stacktrace/index.cjs");var g=Object.defineProperty,o=c((r,e)=>g(r,"name",{value:e,configurable:!0}),"l");const u=o((r,e)=>{let i=0,n=e.length-2;for(;i<n;){const t=i+(n-i>>1);if(r<e[t])n=t-1;else if(r>=e[t+1])i=t+1;else{i=t;break}}return i},"binarySearch"),E=o(r=>r.split(/\n|\r(?!\n)/).reduce((e,i)=>(e.push(e.at(-1)+i.length+1),e),[0]),"getLineStartIndexes"),d=o((r,e,i)=>{const n=i?.skipChecks??!1;if(!n&&(!Array.isArray(r)&&typeof r!="string"||(typeof r=="string"||Array.isArray(r))&&r.length===0))return{column:0,line:0};if(!n&&(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=E(r),l=u(e,a);return{column:e-a[l]+1,line:l+1}}const t=u(e,r);return{column:e-r[t]+1,line:t+1}},"indexToLineColumn"),p=d;exports.CODE_FRAME_POINTER=m.CODE_FRAME_POINTER;exports.codeFrame=m.codeFrame;exports.VisulimaError=s.VisulimaError;exports.getErrorCauses=s.i;exports.isVisulimaError=s.isVisulimaError;exports.serializeError=s.serialize;exports.parseStacktrace=f.parseStacktrace;exports.indexToLineColumn=p;
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.CylOaVUk.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 CHANGED
@@ -1,6 +1,7 @@
1
- export { CODE_FRAME_POINTER, CodeFrameLocation, CodeFrameNodeLocation, CodeFrameOptions, ColorizeMethod, codeFrame } from './code-frame/index.cjs';
2
- export { ErrorHint, ErrorLocation, ErrorProperties, ErrorWithCauseSerializerOptions, SerializedError, VisulimaError, getErrorCauses, isVisulimaError, serializeError } from './error/index.cjs';
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
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';
4
5
 
5
6
  declare const indexToLineColumn: (input: number[] | string, index: number, options?: {
6
7
  skipChecks: boolean;
package/dist/index.d.mts CHANGED
@@ -1,6 +1,7 @@
1
- export { CODE_FRAME_POINTER, CodeFrameLocation, CodeFrameNodeLocation, CodeFrameOptions, ColorizeMethod, codeFrame } from './code-frame/index.mjs';
2
- export { ErrorHint, ErrorLocation, ErrorProperties, ErrorWithCauseSerializerOptions, SerializedError, VisulimaError, getErrorCauses, isVisulimaError, serializeError } from './error/index.mjs';
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
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';
4
5
 
5
6
  declare const indexToLineColumn: (input: number[] | string, index: number, options?: {
6
7
  skipChecks: boolean;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
- export { CODE_FRAME_POINTER, CodeFrameLocation, CodeFrameNodeLocation, CodeFrameOptions, ColorizeMethod, codeFrame } from './code-frame/index.js';
2
- export { ErrorHint, ErrorLocation, ErrorProperties, ErrorWithCauseSerializerOptions, SerializedError, VisulimaError, getErrorCauses, isVisulimaError, serializeError } 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 CHANGED
@@ -1 +1 @@
1
- var c=Object.defineProperty;var l=(r,e)=>c(r,"name",{value:e,configurable:!0});import{CODE_FRAME_POINTER as A,codeFrame as E}from"./code-frame/index.mjs";import{V as d,i as C,a as k,s as v}from"./shared/error.CVJAi2IP.mjs";import{parseStacktrace as O}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{A as CODE_FRAME_POINTER,d as VisulimaError,E as codeFrame,C as getErrorCauses,g as indexToLineColumn,k as isVisulimaError,O as parseStacktrace,v as serializeError};
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.rD6X6s7e.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,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,18 @@
1
+ "use strict";var C=Object.defineProperty;var l=(e,t)=>C(e,"name",{value:t,configurable:!0});const P=require("node:util"),E=require("node:fs"),L=require("node:path"),T=require("node:process"),A=require("node:url"),M=require("../code-frame/index.cjs"),v=require("../stacktrace/index.cjs");var I=Object.defineProperty,_=l((e,t)=>I(e,"name",{value:t,configurable:!0}),"a");const J=_(e=>{const t=new Set,r=[];let i=e;for(;i;){if(t.has(i)){console.error(`Circular reference detected in error causes: ${P.inspect(e)}`);break}if(r.push(i),t.add(i),!i.cause)break;i=i.cause}return r},"getErrorCauses"),F=J;var q=Object.defineProperty,a=l((e,t)=>q(e,"name",{value:t,configurable:!0}),"o");const u=a((e,t,r)=>r===0?e+"":t===" "?e+" ".repeat(r):e+" ".repeat(t*r),"getPrefix"),$=a((e,t)=>{const r=e.replace("async file:","file:");return L.relative(t,r.startsWith("file:")?A.fileURLToPath(r):r)},"getRelativePath"),y=a((e,{color:t,hideErrorTitle:r,indentation:i,prefix:o},n)=>u(o,i,n)+(r?t.title(e.message):t.title(e.name+(e.message?": "+e.message:"")))+`
2
+ `,"getMessage"),w=a((e,{color:t,indentation:r,prefix:i},o)=>{if(e.hint===void 0)return;const n=u(i,r,o);let s="";if(Array.isArray(e.hint))for(const c of e.hint)s+=n+c+`
3
+ `;else s+=n+e.hint;return t.hint(s)},"getHint"),b=a((e,{color:t,cwd:r,displayShortPath:i,indentation:o,prefix:n},s=0)=>{const c=i?$(e.file,r):e.file,{fileLine:f,method:h}=t;return u(n,o,s)+"at "+(e.methodName?h(e.methodName)+" ":"")+f(c)+":"+f(e.line+"")},"getMainFrame"),S=a((e,{color:t,indentation:r,linesAbove:i,linesBelow:o,prefix:n,showGutter:s,showLineNumbers:c,tabWidth:f},h)=>{if(e.file===void 0)return;const g=e.file.replace("file://","");if(!E.existsSync(g))return;const k=E.readFileSync(g,"utf8");return M.codeFrame(k,{start:{column:e.column,line:e.line}},{color:t,linesAbove:i,linesBelow:o,prefix:u(n,r,h),showGutter:s,showLineNumbers:c,tabWidth:f})},"getCode"),x=a((e,t,r)=>{if(e.errors.length===0)return;let i=u(t.prefix,t.indentation,r)+`Errors:
4
+
5
+ `,o=!0;for(const n of e.errors)o?o=!1:i+=`
6
+
7
+ `,i+=N(n,{...t,framesMaxLimit:1,hideErrorCodeView:t.hideErrorErrorsCodeView},r+1);return`
8
+ `+i},"getErrors"),O=a((e,t,r)=>{let i=u(t.prefix,t.indentation,r)+`Caused by:
9
+
10
+ `;const o=e.cause;i+=y(o,t,r);const n=v.parseStacktrace(o).shift(),s=w(o,t,r);if(s&&(i+=s+`
11
+ `),i+=b(n,t,r),!t.hideErrorCauseCodeView){const c=S(n,t,r);c!==void 0&&(i+=`
12
+ `+c)}if(o.cause)i+=`
13
+ `+O(o,t,r+1);else if(o instanceof AggregateError){const c=x(o,t,r);c!==void 0&&(i+=`
14
+ `+c)}return`
15
+ `+i},"getCause"),B=a((e,t)=>(e.length>0?`
16
+ `:"")+e.map(r=>b(r,t)).join(`
17
+ `),"getStacktrace"),N=a((e,t,r)=>{const i={cwd:T.cwd(),displayShortPath:!1,filterStacktrace:void 0,framesMaxLimit:Number.POSITIVE_INFINITY,hideErrorCauseCodeView:!1,hideErrorCodeView:!1,hideErrorErrorsCodeView:!1,hideErrorTitle:!1,hideMessage:!1,indentation:4,linesAbove:2,linesBelow:3,prefix:"",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}},o=v.parseStacktrace(e,{filter:t.filterStacktrace,frameLimit:i.framesMaxLimit}),n=o.shift();return[t.hideMessage?void 0:y(e,i,r),w(e,i,r),n?b(n,i,r):void 0,n&&!i.hideErrorCodeView?S(n,i,r):void 0,e instanceof AggregateError?x(e,i,r):void 0,e.cause===void 0?void 0:O(e,i,r),o.length>0?B(o,i):void 0].filter(Boolean).join(`
18
+ `)},"internalRenderError"),D=a((e,t={})=>{if(t.framesMaxLimit!==void 0&&t.framesMaxLimit<=0)throw new RangeError("The 'framesMaxLimit' option must be a positive number");return N(e,t,0)},"renderError");function z(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)}l(z,"isPlainObject");const W=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 R=Object.defineProperty,m=l((e,t)=>R(e,"name",{value:t,configurable:!0}),"c");const p=new WeakSet,G=m(e=>{p.add(e);const t=e.toJSON();return p.delete(e),t},"toJSON"),j=m((e,t,r,i)=>{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,d(e,i,t,r));if(i.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(z(e)){if(r+=1,i.maxDepth&&r>=i.maxDepth)return{};const o={};for(const n in e)o[n]=j(e[n],t,r,i);return o}try{return e}catch{return"[Not Available]"}},"serializeValue"),d=m((e,t,r,i)=>{if(r.push(e),t.maxDepth===0)return{};if(t.useToJSON&&typeof e.toJSON=="function"&&!p.has(e))return G(e);const o=Object.create(W);if(o.name=Object.prototype.toString.call(e.constructor)==="[object Function]"?e.constructor.name:e.name,o.message=e.message,o.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 o.errors=[],o;n.push(d(s,t,r,i))}o.errors=n}e.cause instanceof Error&&!r.includes(e.cause)&&(o.cause=d(e.cause,t,r,i));for(const n in e)if(o[n]===void 0){const s=e[n];o[n]=j(s,r,i,t)}if(Array.isArray(t.exclude)&&t.exclude.length>0)for(const n of t.exclude)try{delete o[n]}catch{}return o},"_serialize"),H=m((e,t={})=>d(e,{exclude:t.exclude??[],maxDepth:t.maxDepth??Number.POSITIVE_INFINITY,useToJSON:t.useToJSON??!1},[],0),"serialize");var U=Object.defineProperty,V=l((e,t)=>U(e,"name",{value:t,configurable:!0}),"t");const Y=V(e=>e instanceof Error&&e.type==="VisulimaError","isVisulimaError");class K extends Error{static{l(this,"VisulimaError")}static{V(this,"VisulimaError")}loc;title;hint;type="VisulimaError";constructor({cause:t,hint:r,location:i,message:o,name:n,stack:s,title:c}){super(o,{cause:t}),this.title=c,this.name=n,this.stack=s??this.stack,this.loc=i,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=K;exports.i=F;exports.isVisulimaError=Y;exports.renderError=D;exports.serialize=H;
@@ -0,0 +1,18 @@
1
+ var k=Object.defineProperty;var l=(e,t)=>k(e,"name",{value:t,configurable:!0});import{inspect as C}from"node:util";import{existsSync as P,readFileSync as L}from"node:fs";import{relative as T}from"node:path";import{cwd as A}from"node:process";import{fileURLToPath as M}from"node:url";import{codeFrame as I}from"../code-frame/index.mjs";import{parseStacktrace as v}from"../stacktrace/index.mjs";var J=Object.defineProperty,$=l((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"),te=F;var B=Object.defineProperty,a=l((e,t)=>B(e,"name",{value:t,configurable:!0}),"o");const u=a((e,t,r)=>r===0?e+"":t===" "?e+" ".repeat(r):e+" ".repeat(t*r),"getPrefix"),D=a((e,t)=>{const r=e.replace("async file:","file:");return T(t,r.startsWith("file:")?M(r):r)},"getRelativePath"),E=a((e,{color:t,hideErrorTitle:r,indentation:o,prefix:i},n)=>u(i,o,n)+(r?t.title(e.message):t.title(e.name+(e.message?": "+e.message:"")))+`
2
+ `,"getMessage"),y=a((e,{color:t,indentation:r,prefix:o},i)=>{if(e.hint===void 0)return;const n=u(o,r,i);let s="";if(Array.isArray(e.hint))for(const c of e.hint)s+=n+c+`
3
+ `;else s+=n+e.hint;return t.hint(s)},"getHint"),b=a((e,{color:t,cwd:r,displayShortPath:o,indentation:i,prefix:n},s=0)=>{const c=o?D(e.file,r):e.file,{fileLine:f,method:h}=t;return u(n,i,s)+"at "+(e.methodName?h(e.methodName)+" ":"")+f(c)+":"+f(e.line+"")},"getMainFrame"),w=a((e,{color:t,indentation:r,linesAbove:o,linesBelow:i,prefix:n,showGutter:s,showLineNumbers:c,tabWidth:f},h)=>{if(e.file===void 0)return;const g=e.file.replace("file://","");if(!P(g))return;const V=L(g,"utf8");return I(V,{start:{column:e.column,line:e.line}},{color:t,linesAbove:o,linesBelow:i,prefix:u(n,r,h),showGutter:s,showLineNumbers:c,tabWidth:f})},"getCode"),S=a((e,t,r)=>{if(e.errors.length===0)return;let o=u(t.prefix,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:1,hideErrorCodeView:t.hideErrorErrorsCodeView},r+1);return`
8
+ `+o},"getErrors"),x=a((e,t,r)=>{let o=u(t.prefix,t.indentation,r)+`Caused by:
9
+
10
+ `;const i=e.cause;o+=E(i,t,r);const n=v(i).shift(),s=y(i,t,r);if(s&&(o+=s+`
11
+ `),o+=b(n,t,r),!t.hideErrorCauseCodeView){const c=w(n,t,r);c!==void 0&&(o+=`
12
+ `+c)}if(i.cause)o+=`
13
+ `+x(i,t,r+1);else if(i instanceof AggregateError){const c=S(i,t,r);c!==void 0&&(o+=`
14
+ `+c)}return`
15
+ `+o},"getCause"),W=a((e,t)=>(e.length>0?`
16
+ `:"")+e.map(r=>b(r,t)).join(`
17
+ `),"getStacktrace"),O=a((e,t,r)=>{const o={cwd:A(),displayShortPath:!1,filterStacktrace:void 0,framesMaxLimit:Number.POSITIVE_INFINITY,hideErrorCauseCodeView:!1,hideErrorCodeView:!1,hideErrorErrorsCodeView:!1,hideErrorTitle:!1,hideMessage:!1,indentation:4,linesAbove:2,linesBelow:3,prefix:"",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=v(e,{filter:t.filterStacktrace,frameLimit:o.framesMaxLimit}),n=i.shift();return[t.hideMessage?void 0:E(e,o,r),y(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:x(e,o,r),i.length>0?W(i,o):void 0].filter(Boolean).join(`
18
+ `)},"internalRenderError"),re=a((e,t={})=>{if(t.framesMaxLimit!==void 0&&t.framesMaxLimit<=0)throw new RangeError("The 'framesMaxLimit' option must be a positive number");return O(e,t,0)},"renderError");function z(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)}l(z,"isPlainObject");const R=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,d=l((e,t)=>G(e,"name",{value:t,configurable:!0}),"c");const p=new WeakSet,_=d(e=>{p.add(e);const t=e.toJSON();return p.delete(e),t},"toJSON"),N=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,m(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(z(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"),m=d((e,t,r,o)=>{if(r.push(e),t.maxDepth===0)return{};if(t.useToJSON&&typeof e.toJSON=="function"&&!p.has(e))return _(e);const i=Object.create(R);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(m(s,t,r,o))}i.errors=n}e.cause instanceof Error&&!r.includes(e.cause)&&(i.cause=m(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"),oe=d((e,t={})=>m(e,{exclude:t.exclude??[],maxDepth:t.maxDepth??Number.POSITIVE_INFINITY,useToJSON:t.useToJSON??!1},[],0),"serialize");var H=Object.defineProperty,j=l((e,t)=>H(e,"name",{value:t,configurable:!0}),"t");const ie=j(e=>e instanceof Error&&e.type==="VisulimaError","isVisulimaError");class ne extends Error{static{l(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:c}){super(i,{cause:t}),this.title=c,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{ne as V,ie as a,te as i,re as r,oe as s};
@@ -1,2 +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;
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 g=Object.defineProperty,d=v((i,e)=>g(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>",N=/^.*?\s*at\s(?:(.+?\)(?:\s\[.+\])?|\(?.*?)\s?\((?:address\sat\s)?)?(?:async\s)?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,S=/\((\S+)\),\s(<[^>]+>)?:(\d+)?:(\d+)?\)?/,h=/(.*?):(\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+)$/,E=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. \/=]+)(?::(\d+))?(?::(\d+))?\s*$/i,J=/(\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"),t=i.includes("safari-web-extension");return n||t?[i.includes("@")?i.split("@")[0]:f,n?`safari-extension:${e}`:`safari-web-extension:${e}`]:[i,e]},"extractSafariExtensionDetails"),$=d((i,e)=>{const n=h.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 t=e[2].split(":");return{column:t[2]?+t[2]:void 0,file:t[0],line:t[1]?+t[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 t={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 $(t,n[2]+":"+n[3]+":"+n[4]),t}},"parseNode"),W=d(i=>{const e=N.exec(i);if(e){u(`parse chrome error stack line: "${i}"`,`found: ${JSON.stringify(e)}`);const n=e[2]?.startsWith("native"),t=e[2]?.startsWith("eval")||e[1]?.startsWith("eval");let o,a;if(t){const s=S.exec(i);if(s){const r=/(\S+):(\d+):(\d+)|(\S+):(\d+)$/.exec(s[1]);r?(e[2]=r[4]??r[1],e[3]=r[5]??r[2],e[4]=r[3]):s[2]&&(e[2]=s[1]),s[2]&&(o={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 r=b.exec(i);r&&(a={column:r[5]?+r[5]:void 0,file:r[3],line:r[4]?+r[4]:void 0},o={column:r[8]?+r[8]:void 0,file:r[2],line:r[7]?+r[7]:void 0,methodName:"eval",raw:r[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:o,file:c,line:e[3]?+e[3]:void 0,methodName:m,raw:i,type:t?"eval":n?"native":void 0};return a?(l.column=a.column,l.file=a.file,l.line=a.line):$(l,c+":"+e[3]+":"+e[4]),l}},"parseChromium"),j=d((i,e)=>{const n=E.exec(i);if(n){u(`parse gecko error stack line: "${i}"`,`found: ${JSON.stringify(n)}`);const t=n[3]?.includes(" > eval"),o=t&&n[3]&&J.exec(n[3]);let a;t&&o&&(n[3]=o[1],a={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]=o[2]);const[m,c]=y(n[1]?n[1].replace(/^Anonymous function$/,"<anonymous>"):f,n[3]);let l;(e?.type==="safari"||!t&&e?.type==="firefox")&&e.column?l=e.column:!t&&n[5]&&(l=+n[5]);let s;return(e?.type==="safari"||!t&&e?.type==="firefox")&&e.line?s=e.line:n[4]&&(s=+n[4]),{column:l,evalOrigin:a,file:c,line:s,methodName:m,raw:i,type:t?"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,{filter:e,frameLimit:n=50}={})=>{let t=(i.stacktrace??i.stack??"").split(`
2
+ `).map(o=>(p.test(o)?o.replace(p,"$1"):o).replace(/^\s+|\s+$/g,"")).filter(o=>!/\S*(?:Error: |AggregateError:)/.test(o)&&o!=="eval code");return e&&(t=t.filter(o=>e(o))),t=t.slice(0,n),t.reduce((o,a,m)=>{if(!a||a.length>1024)return o;let c;if(/^\s*in\s.*/.test(a))c=G(a);else if(/^.*?\s*at\s.*/.test(a))c=W(a);else if(/^.*?\s*@.*|\[native code\]/.test(a)){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(a,l)||j(a,l)}else c=z(a);return c?o.push(c):u(`parse error stack line: "${a}"`,"not parser found"),o},[])},"parse"),L=B;exports.parseStacktrace=L;
@@ -9,7 +9,8 @@ interface Trace {
9
9
  type?: TraceType | undefined;
10
10
  }
11
11
 
12
- declare const parse: (error: Error, options?: Partial<{
12
+ declare const parse: (error: Error, { filter, frameLimit }?: Partial<{
13
+ filter?: (line: string) => boolean;
13
14
  frameLimit: number;
14
15
  }>) => Trace[];
15
16
 
@@ -9,7 +9,8 @@ interface Trace {
9
9
  type?: TraceType | undefined;
10
10
  }
11
11
 
12
- declare const parse: (error: Error, options?: Partial<{
12
+ declare const parse: (error: Error, { filter, frameLimit }?: Partial<{
13
+ filter?: (line: string) => boolean;
13
14
  frameLimit: number;
14
15
  }>) => Trace[];
15
16
 
@@ -9,7 +9,8 @@ interface Trace {
9
9
  type?: TraceType | undefined;
10
10
  }
11
11
 
12
- declare const parse: (error: Error, options?: Partial<{
12
+ declare const parse: (error: Error, { filter, frameLimit }?: Partial<{
13
+ filter?: (line: string) => boolean;
13
14
  frameLimit: number;
14
15
  }>) => Trace[];
15
16
 
@@ -1,2 +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};
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>",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+))?/,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+)$/,E=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. \/=]+)(?::(\d+))?(?::(\d+))?\s*$/i,J=/(\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=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 $(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]?.startsWith("native"),o=e[2]?.startsWith("eval")||e[1]?.startsWith("eval");let t,a;if(o){const s=h.exec(i);if(s){const r=/(\S+):(\d+):(\d+)|(\S+):(\d+)$/.exec(s[1]);r?(e[2]=r[4]??r[1],e[3]=r[5]??r[2],e[4]=r[3]):s[2]&&(e[2]=s[1]),s[2]&&(t={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 r=k.exec(i);r&&(a={column:r[5]?+r[5]:void 0,file:r[3],line:r[4]?+r[4]:void 0},t={column:r[8]?+r[8]:void 0,file:r[2],line:r[7]?+r[7]:void 0,methodName:"eval",raw:r[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:t,file:c,line:e[3]?+e[3]:void 0,methodName:m,raw:i,type:o?"eval":n?"native":void 0};return a?(l.column=a.column,l.file=a.file,l.line=a.line):$(l,c+":"+e[3]+":"+e[4]),l}},"parseChromium"),D=d((i,e)=>{const n=E.exec(i);if(n){u(`parse gecko error stack line: "${i}"`,`found: ${JSON.stringify(n)}`);const o=n[3]?.includes(" > eval"),t=o&&n[3]&&J.exec(n[3]);let a;o&&t&&(n[3]=t[1],a={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]=t[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:a,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,{filter:e,frameLimit:n=50}={})=>{let o=(i.stacktrace??i.stack??"").split(`
2
+ `).map(t=>(p.test(t)?t.replace(p,"$1"):t).replace(/^\s+|\s+$/g,"")).filter(t=>!/\S*(?:Error: |AggregateError:)/.test(t)&&t!=="eval code");return e&&(o=o.filter(t=>e(t))),o=o.slice(0,n),o.reduce((t,a,m)=>{if(!a||a.length>1024)return t;let c;if(/^\s*in\s.*/.test(a))c=G(a);else if(/^.*?\s*at\s.*/.test(a))c=W(a);else if(/^.*?\s*@.*|\[native code\]/.test(a)){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(a,l)||D(a,l)}else c=z(a);return c?t.push(c):u(`parse error stack line: "${a}"`,"not parser found"),t},[])},"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.1.0",
3
+ "version": "4.3.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",
@@ -118,24 +129,24 @@
118
129
  "@types/command-line-args": "^5.2.3",
119
130
  "@types/node": "18.19.15",
120
131
  "@visulima/nextra-theme-docs": "4.0.26",
132
+ "@visulima/packem": "^1.0.0-alpha.46",
121
133
  "@visulima/path": "1.0.2",
122
134
  "@vitest/coverage-v8": "^1.6.0",
123
135
  "@vitest/ui": "^1.6.0",
124
136
  "conventional-changelog-conventionalcommits": "8.0.0",
125
137
  "cross-env": "^7.0.3",
138
+ "esbuild": "0.22.0",
126
139
  "eslint": "^8.57.0",
127
140
  "eslint-plugin-deprecation": "^3.0.0",
128
141
  "eslint-plugin-import": "npm:eslint-plugin-i@^2.29.1",
129
142
  "eslint-plugin-mdx": "^3.1.5",
130
- "is-plain-obj": "^4.1.0",
131
143
  "eslint-plugin-vitest": "^0.4.1",
132
144
  "eslint-plugin-vitest-globals": "^1.5.0",
145
+ "is-plain-obj": "^4.1.0",
133
146
  "prettier": "^3.3.2",
134
147
  "rimraf": "^5.0.7",
135
148
  "semantic-release": "24.0.0",
136
- "@visulima/packem": "^1.0.0-alpha.46",
137
- "esbuild": "^0.21.5",
138
- "typescript": "^5.4.5",
149
+ "typescript": "5.4.5",
139
150
  "vitest": "^1.6.0"
140
151
  },
141
152
  "engines": {
@@ -1 +0,0 @@
1
- var h=Object.defineProperty;var a=(e,t)=>h(e,"name",{value:t,configurable:!0});import{inspect as y}from"node:util";var d=Object.defineProperty,O=a((e,t)=>d(e,"name",{value:t,configurable:!0}),"a");const S=O(e=>{const t=new Set,o=[];let r=e;for(;r;){if(t.has(r)){console.error(`Circular reference detected in error causes: ${y(e)}`);break}if(o.push(r),t.add(r),!r.cause)break;r=r.cause}return o},"getErrorCauses"),w=S;function g(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)}a(g,"isPlainObject");const v=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 E=Object.defineProperty,u=a((e,t)=>E(e,"name",{value:t,configurable:!0}),"c");const l=new WeakSet,j=u(e=>{l.add(e);const t=e.toJSON();return l.delete(e),t},"toJSON"),f=u((e,t,o,r)=>{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]":(o+=1,c(e,r,t,o));if(r.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(g(e)){if(o+=1,r.maxDepth&&o>=r.maxDepth)return{};const n={};for(const s in e)n[s]=f(e[s],t,o,r);return n}try{return e}catch{return"[Not Available]"}},"serializeValue"),c=u((e,t,o,r)=>{if(o.push(e),t.maxDepth===0)return{};if(t.useToJSON&&typeof e.toJSON=="function"&&!l.has(e))return j(e);const n=Object.create(v);if(n.name=Object.prototype.toString.call(e.constructor)==="[object Function]"?e.constructor.name:e.name,n.message=e.message,n.stack=e.stack,Array.isArray(e.errors)){const s=[];for(const i of e.errors){if(!(i instanceof Error))throw new TypeError("All errors in the 'errors' property must be instances of Error");if(o.includes(i))return n.errors=[],n;s.push(c(i,t,o,r))}n.errors=s}e.cause instanceof Error&&!o.includes(e.cause)&&(n.cause=c(e.cause,t,o,r));for(const s in e)if(n[s]===void 0){const i=e[s];n[s]=f(i,o,r,t)}if(Array.isArray(t.exclude)&&t.exclude.length>0)for(const s of t.exclude)try{delete n[s]}catch{}return n},"_serialize"),J=u((e,t={})=>c(e,{exclude:t.exclude??[],maxDepth:t.maxDepth??Number.POSITIVE_INFINITY,useToJSON:t.useToJSON??!1},[],0),"serialize");var N=Object.defineProperty,m=a((e,t)=>N(e,"name",{value:t,configurable:!0}),"t");const T=m(e=>e instanceof Error&&e.type==="VisulimaError","isVisulimaError");class V extends Error{static{a(this,"VisulimaError")}static{m(this,"VisulimaError")}loc;title;hint;type="VisulimaError";constructor(t,...o){super(...o);const{hint:r,location:n,message:s,name:i,stack:b,title:p}=t;this.title=p,this.name=i,s&&(this.message=s),this.stack=b??this.stack,this.loc=n,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{V,T as a,w as i,J as s};
@@ -1 +0,0 @@
1
- "use strict";var h=Object.defineProperty;var a=(e,t)=>h(e,"name",{value:t,configurable:!0});const d=require("node:util");var y=Object.defineProperty,O=a((e,t)=>y(e,"name",{value:t,configurable:!0}),"a");const E=O(e=>{const t=new Set,o=[];let r=e;for(;r;){if(t.has(r)){console.error(`Circular reference detected in error causes: ${d.inspect(e)}`);break}if(o.push(r),t.add(r),!r.cause)break;r=r.cause}return o},"getErrorCauses"),S=E;function g(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)}a(g,"isPlainObject");const v=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 j=Object.defineProperty,u=a((e,t)=>j(e,"name",{value:t,configurable:!0}),"c");const l=new WeakSet,N=u(e=>{l.add(e);const t=e.toJSON();return l.delete(e),t},"toJSON"),f=u((e,t,o,r)=>{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]":(o+=1,c(e,r,t,o));if(r.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(g(e)){if(o+=1,r.maxDepth&&o>=r.maxDepth)return{};const n={};for(const s in e)n[s]=f(e[s],t,o,r);return n}try{return e}catch{return"[Not Available]"}},"serializeValue"),c=u((e,t,o,r)=>{if(o.push(e),t.maxDepth===0)return{};if(t.useToJSON&&typeof e.toJSON=="function"&&!l.has(e))return N(e);const n=Object.create(v);if(n.name=Object.prototype.toString.call(e.constructor)==="[object Function]"?e.constructor.name:e.name,n.message=e.message,n.stack=e.stack,Array.isArray(e.errors)){const s=[];for(const i of e.errors){if(!(i instanceof Error))throw new TypeError("All errors in the 'errors' property must be instances of Error");if(o.includes(i))return n.errors=[],n;s.push(c(i,t,o,r))}n.errors=s}e.cause instanceof Error&&!o.includes(e.cause)&&(n.cause=c(e.cause,t,o,r));for(const s in e)if(n[s]===void 0){const i=e[s];n[s]=f(i,o,r,t)}if(Array.isArray(t.exclude)&&t.exclude.length>0)for(const s of t.exclude)try{delete n[s]}catch{}return n},"_serialize"),x=u((e,t={})=>c(e,{exclude:t.exclude??[],maxDepth:t.maxDepth??Number.POSITIVE_INFINITY,useToJSON:t.useToJSON??!1},[],0),"serialize");var k=Object.defineProperty,m=a((e,t)=>k(e,"name",{value:t,configurable:!0}),"t");const w=m(e=>e instanceof Error&&e.type==="VisulimaError","isVisulimaError");class V extends Error{static{a(this,"VisulimaError")}static{m(this,"VisulimaError")}loc;title;hint;type="VisulimaError";constructor(t,...o){super(...o);const{hint:r,location:n,message:s,name:i,stack:b,title:p}=t;this.title=p,this.name=i,s&&(this.message=s),this.stack=b??this.stack,this.loc=n,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=V;exports.i=S;exports.isVisulimaError=w;exports.serialize=x;