@visulima/error 4.2.0 → 4.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,35 @@
1
+ ## @visulima/error [4.3.1](https://github.com/visulima/visulima/compare/@visulima/error@4.3.0...@visulima/error@4.3.1) (2024-08-01)
2
+
3
+ ### Styles
4
+
5
+ * cs fixes ([6f727ec](https://github.com/visulima/visulima/commit/6f727ec36437384883ca4b764d920cf03ffe44df))
6
+
7
+ ### Miscellaneous Chores
8
+
9
+ * added private true into fixture package.json files ([4a9494c](https://github.com/visulima/visulima/commit/4a9494c642fa98f224505a1d231b5af4e73d6c79))
10
+ * updated dev dependencies ([ac67ec1](https://github.com/visulima/visulima/commit/ac67ec1bcba16175d225958e318199f60b10d179))
11
+ * updated dev dependencies and sorted the package.json ([9571572](https://github.com/visulima/visulima/commit/95715725a8ed053ca24fd1405a55205c79342ecb))
12
+
13
+
14
+ ### Dependencies
15
+
16
+ * **@visulima/path:** upgraded to 1.0.3
17
+
18
+ ## @visulima/error [4.3.0](https://github.com/visulima/visulima/compare/@visulima/error@4.2.0...@visulima/error@4.3.0) (2024-07-02)
19
+
20
+ ### Features
21
+
22
+ * **error:** added a prefix option to renderError ([e164d52](https://github.com/visulima/visulima/commit/e164d528dfef4195a7cbd9f8843f58148dfc5e08))
23
+ * **error:** added stackFilter to parseStacktrace, fixed parsing AggregateError stack, added filterStacktrace to renderError ([bb4b4f7](https://github.com/visulima/visulima/commit/bb4b4f72ab00c63bf0ac5e9e6a9a01110c102a1c))
24
+
25
+ ### Bug Fixes
26
+
27
+ * **error:** renamed stackFilter to filter and changed interface for filterStacktrace ([b95dfb6](https://github.com/visulima/visulima/commit/b95dfb640b0d243122bff2ddf2e32a79101652e1))
28
+
29
+ ### Miscellaneous Chores
30
+
31
+ * changed typescript version back to 5.4.5 ([55d28bb](https://github.com/visulima/visulima/commit/55d28bbdc103718d19f844034b38a0e8e5af798a))
32
+
1
33
  ## @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
34
 
3
35
  ### Features
package/README.md CHANGED
@@ -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
@@ -1,6 +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;
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),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,6 +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};
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.B5KA_10i.cjs");exports.VisulimaError=r.VisulimaError;exports.getErrorCauses=r.i;exports.isVisulimaError=r.isVisulimaError;exports.renderError=r.renderError;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;
@@ -40,6 +40,7 @@ type Options$1 = Omit<CodeFrameOptions, "message | prefix"> & {
40
40
  };
41
41
  cwd: string;
42
42
  displayShortPath: boolean;
43
+ filterStacktrace: ((line: string) => boolean) | undefined;
43
44
  framesMaxLimit: number;
44
45
  hideErrorCauseCodeView: boolean;
45
46
  hideErrorCodeView: boolean;
@@ -47,6 +48,7 @@ type Options$1 = Omit<CodeFrameOptions, "message | prefix"> & {
47
48
  hideErrorTitle: boolean;
48
49
  hideMessage: boolean;
49
50
  indentation: number | "\t";
51
+ prefix: string;
50
52
  };
51
53
  declare const renderError: (error: AggregateError | Error | VisulimaError, options?: Partial<Options$1>) => string;
52
54
 
@@ -40,6 +40,7 @@ type Options$1 = Omit<CodeFrameOptions, "message | prefix"> & {
40
40
  };
41
41
  cwd: string;
42
42
  displayShortPath: boolean;
43
+ filterStacktrace: ((line: string) => boolean) | undefined;
43
44
  framesMaxLimit: number;
44
45
  hideErrorCauseCodeView: boolean;
45
46
  hideErrorCodeView: boolean;
@@ -47,6 +48,7 @@ type Options$1 = Omit<CodeFrameOptions, "message | prefix"> & {
47
48
  hideErrorTitle: boolean;
48
49
  hideMessage: boolean;
49
50
  indentation: number | "\t";
51
+ prefix: string;
50
52
  };
51
53
  declare const renderError: (error: AggregateError | Error | VisulimaError, options?: Partial<Options$1>) => string;
52
54
 
@@ -40,6 +40,7 @@ type Options$1 = Omit<CodeFrameOptions, "message | prefix"> & {
40
40
  };
41
41
  cwd: string;
42
42
  displayShortPath: boolean;
43
+ filterStacktrace: ((line: string) => boolean) | undefined;
43
44
  framesMaxLimit: number;
44
45
  hideErrorCauseCodeView: boolean;
45
46
  hideErrorCodeView: boolean;
@@ -47,6 +48,7 @@ type Options$1 = Omit<CodeFrameOptions, "message | prefix"> & {
47
48
  hideErrorTitle: boolean;
48
49
  hideMessage: boolean;
49
50
  indentation: number | "\t";
51
+ prefix: string;
50
52
  };
51
53
  declare const renderError: (error: AggregateError | Error | VisulimaError, options?: Partial<Options$1>) => string;
52
54
 
@@ -1 +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};
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"),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;
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.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 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};
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,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.2.0",
3
+ "version": "4.3.1",
4
4
  "description": "Error with more than just a message, stacktrace parsing.",
5
5
  "keywords": [
6
6
  "anolilab",
@@ -28,13 +28,11 @@
28
28
  "source",
29
29
  "code",
30
30
  "frame",
31
- "stack",
32
31
  "callstack",
33
32
  "call",
34
33
  "source-code",
35
34
  "pretty-error",
36
35
  "pretty-exceptions",
37
- "exception",
38
36
  "pretty",
39
37
  "visulima"
40
38
  ],
@@ -118,36 +116,36 @@
118
116
  "@anolilab/prettier-config": "^5.0.14",
119
117
  "@anolilab/semantic-release-pnpm": "^1.1.3",
120
118
  "@anolilab/semantic-release-preset": "^9.0.0",
121
- "@babel/core": "^7.24.7",
119
+ "@babel/core": "^7.25.2",
122
120
  "@eslint-types/deprecation": "^2.0.0",
123
121
  "@eslint-types/import": "^2.29.1",
124
122
  "@eslint-types/jsdoc": "^48.2.2",
125
123
  "@eslint-types/typescript-eslint": "^7.5.0",
126
124
  "@eslint-types/unicorn": "^52.0.0",
127
- "@rushstack/eslint-plugin-security": "^0.8.1",
125
+ "@rushstack/eslint-plugin-security": "^0.8.2",
128
126
  "@total-typescript/ts-reset": "^0.5.1",
129
127
  "@types/command-line-args": "^5.2.3",
130
128
  "@types/node": "18.19.15",
131
129
  "@visulima/nextra-theme-docs": "4.0.26",
132
- "@visulima/packem": "^1.0.0-alpha.46",
133
- "@visulima/path": "1.0.2",
134
- "@vitest/coverage-v8": "^1.6.0",
135
- "@vitest/ui": "^1.6.0",
130
+ "@visulima/packem": "^1.0.0-alpha.60",
131
+ "@visulima/path": "1.0.3",
132
+ "@vitest/coverage-v8": "^2.0.5",
133
+ "@vitest/ui": "^2.0.5",
136
134
  "conventional-changelog-conventionalcommits": "8.0.0",
137
135
  "cross-env": "^7.0.3",
138
- "esbuild": "0.22.0",
139
- "eslint": "^8.57.0",
136
+ "esbuild": "0.23.0",
137
+ "eslint": "8.57.0",
140
138
  "eslint-plugin-deprecation": "^3.0.0",
141
139
  "eslint-plugin-import": "npm:eslint-plugin-i@^2.29.1",
142
140
  "eslint-plugin-mdx": "^3.1.5",
143
141
  "eslint-plugin-vitest": "^0.4.1",
144
142
  "eslint-plugin-vitest-globals": "^1.5.0",
145
143
  "is-plain-obj": "^4.1.0",
146
- "prettier": "^3.3.2",
147
- "rimraf": "^5.0.7",
144
+ "prettier": "^3.3.3",
145
+ "rimraf": "5.0.9",
148
146
  "semantic-release": "24.0.0",
149
- "typescript": "^5.4.5",
150
- "vitest": "^1.6.0"
147
+ "typescript": "5.4.5",
148
+ "vitest": "^2.0.5"
151
149
  },
152
150
  "engines": {
153
151
  "node": ">=18.* <=22.*"
@@ -1,18 +0,0 @@
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;
@@ -1,18 +0,0 @@
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};