@visulima/error 4.3.2 → 4.4.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 +10 -0
- package/README.md +12 -0
- package/dist/error/index.cjs +1 -1
- package/dist/error/index.d.cts +3 -1
- package/dist/error/index.d.mts +3 -1
- package/dist/error/index.d.ts +3 -1
- package/dist/error/index.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/shared/error.B400_kIl.cjs +18 -0
- package/dist/shared/error.DR_c4iBF.mjs +18 -0
- package/package.json +1 -1
- package/dist/shared/error.CylOaVUk.cjs +0 -18
- package/dist/shared/error.rD6X6s7e.mjs +0 -18
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
## @visulima/error [4.4.0](https://github.com/visulima/visulima/compare/@visulima/error@4.3.2...@visulima/error@4.4.0) (2024-08-08)
|
|
2
|
+
|
|
3
|
+
### Features
|
|
4
|
+
|
|
5
|
+
* **error:** added captureRawStackTrace ([1c988a3](https://github.com/visulima/visulima/commit/1c988a33d6ce9ab1afec6c94efd7fa091205742c))
|
|
6
|
+
|
|
7
|
+
### Tests
|
|
8
|
+
|
|
9
|
+
* **error:** fixed assertions on test ([f315754](https://github.com/visulima/visulima/commit/f3157544173590e8695c1419ba7f29cb480d43cf))
|
|
10
|
+
|
|
1
11
|
## @visulima/error [4.3.2](https://github.com/visulima/visulima/compare/@visulima/error@4.3.1...@visulima/error@4.3.2) (2024-08-04)
|
|
2
12
|
|
|
3
13
|
|
package/README.md
CHANGED
|
@@ -374,6 +374,18 @@ Default: `false`
|
|
|
374
374
|
|
|
375
375
|
Hide the error message.
|
|
376
376
|
|
|
377
|
+
### captureRawStackTrace
|
|
378
|
+
|
|
379
|
+
Capture a raw stack trace.
|
|
380
|
+
|
|
381
|
+
```ts
|
|
382
|
+
import { captureRawStackTrace } from "@visulima/error";
|
|
383
|
+
|
|
384
|
+
const stack = captureRawStackTrace();
|
|
385
|
+
|
|
386
|
+
console.log(stack);
|
|
387
|
+
```
|
|
388
|
+
|
|
377
389
|
## Supported Node.js Versions
|
|
378
390
|
|
|
379
391
|
Libraries in this ecosystem make the best effort to track [Node.js’ release schedule](https://github.com/nodejs/release#release-schedule).
|
package/dist/error/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../shared/error.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../shared/error.B400_kIl.cjs");exports.VisulimaError=r.VisulimaError;exports.captureRawStackTrace=r.c;exports.getErrorCauses=r.i;exports.isVisulimaError=r.isVisulimaError;exports.renderError=r.renderError;exports.serializeError=r.serialize;
|
package/dist/error/index.d.cts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { b as CodeFrameOptions, c as ColorizeMethod } from '../shared/error.CrVmNoPV.cjs';
|
|
2
2
|
|
|
3
|
+
declare const captureRawStackTrace: () => string | undefined;
|
|
4
|
+
|
|
3
5
|
declare const getErrorCauses: <E = unknown>(error: E) => E[];
|
|
4
6
|
|
|
5
7
|
interface ErrorProperties {
|
|
@@ -72,4 +74,4 @@ type Options = {
|
|
|
72
74
|
};
|
|
73
75
|
declare const serialize: (error: AggregateError | Error | JsonError, options?: Options) => SerializedError;
|
|
74
76
|
|
|
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 };
|
|
77
|
+
export { type ErrorHint, type ErrorLocation, type ErrorProperties, type Options as ErrorWithCauseSerializerOptions, type Options$1 as RenderErrorOptions, type SerializedError, VisulimaError, captureRawStackTrace, getErrorCauses, isVisulimaError, renderError, serialize as serializeError };
|
package/dist/error/index.d.mts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { b as CodeFrameOptions, c as ColorizeMethod } from '../shared/error.CrVmNoPV.mjs';
|
|
2
2
|
|
|
3
|
+
declare const captureRawStackTrace: () => string | undefined;
|
|
4
|
+
|
|
3
5
|
declare const getErrorCauses: <E = unknown>(error: E) => E[];
|
|
4
6
|
|
|
5
7
|
interface ErrorProperties {
|
|
@@ -72,4 +74,4 @@ type Options = {
|
|
|
72
74
|
};
|
|
73
75
|
declare const serialize: (error: AggregateError | Error | JsonError, options?: Options) => SerializedError;
|
|
74
76
|
|
|
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 };
|
|
77
|
+
export { type ErrorHint, type ErrorLocation, type ErrorProperties, type Options as ErrorWithCauseSerializerOptions, type Options$1 as RenderErrorOptions, type SerializedError, VisulimaError, captureRawStackTrace, getErrorCauses, isVisulimaError, renderError, serialize as serializeError };
|
package/dist/error/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { b as CodeFrameOptions, c as ColorizeMethod } from '../shared/error.CrVmNoPV.js';
|
|
2
2
|
|
|
3
|
+
declare const captureRawStackTrace: () => string | undefined;
|
|
4
|
+
|
|
3
5
|
declare const getErrorCauses: <E = unknown>(error: E) => E[];
|
|
4
6
|
|
|
5
7
|
interface ErrorProperties {
|
|
@@ -72,4 +74,4 @@ type Options = {
|
|
|
72
74
|
};
|
|
73
75
|
declare const serialize: (error: AggregateError | Error | JsonError, options?: Options) => SerializedError;
|
|
74
76
|
|
|
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 };
|
|
77
|
+
export { type ErrorHint, type ErrorLocation, type ErrorProperties, type Options as ErrorWithCauseSerializerOptions, type Options$1 as RenderErrorOptions, type SerializedError, VisulimaError, captureRawStackTrace, getErrorCauses, isVisulimaError, renderError, serialize as serializeError };
|
package/dist/error/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{V as
|
|
1
|
+
import{V as s,c as e,i,a as o,r as E,s as c}from"../shared/error.DR_c4iBF.mjs";export{s as VisulimaError,e as captureRawStackTrace,i as getErrorCauses,o as isVisulimaError,E as renderError,c as serializeError};
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var y=Object.defineProperty;var
|
|
1
|
+
"use strict";var y=Object.defineProperty;var l=(r,e)=>y(r,"name",{value:e,configurable:!0});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("./code-frame/index.cjs"),a=require("./shared/error.B400_kIl.cjs"),E=require("./stacktrace/index.cjs");var d=Object.defineProperty,o=l((r,e)=>d(r,"name",{value:e,configurable:!0}),"l");const u=o((r,e)=>{let t=0,i=e.length-2;for(;t<i;){const n=t+(i-t>>1);if(r<e[n])i=n-1;else if(r>=e[n+1])t=n+1;else{t=n;break}}return t},"binarySearch"),f=o(r=>r.split(/\n|\r(?!\n)/).reduce((e,t)=>(e.push(e.at(-1)+t.length+1),e),[0]),"getLineStartIndexes"),g=o((r,e,t)=>{const i=t?.skipChecks??!1;if(!i&&(!Array.isArray(r)&&typeof r!="string"||(typeof r=="string"||Array.isArray(r))&&r.length===0))return{column:0,line:0};if(!i&&(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 s=f(r),c=u(e,s);return{column:e-s[c]+1,line:c+1}}const n=u(e,r);return{column:e-r[n]+1,line:n+1}},"indexToLineColumn"),p=g;exports.CODE_FRAME_POINTER=m.CODE_FRAME_POINTER;exports.codeFrame=m.codeFrame;exports.VisulimaError=a.VisulimaError;exports.captureRawStackTrace=a.c;exports.getErrorCauses=a.i;exports.isVisulimaError=a.isVisulimaError;exports.renderError=a.renderError;exports.serializeError=a.serialize;exports.parseStacktrace=E.parseStacktrace;exports.indexToLineColumn=p;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
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';
|
|
2
|
+
export { ErrorHint, ErrorLocation, ErrorProperties, ErrorWithCauseSerializerOptions, RenderErrorOptions, SerializedError, VisulimaError, captureRawStackTrace, getErrorCauses, isVisulimaError, renderError, serializeError } from './error/index.cjs';
|
|
3
3
|
export { Trace, TraceType, parseStacktrace } from './stacktrace/index.cjs';
|
|
4
4
|
export { C as CodeFrameLocation, a as CodeFrameNodeLocation, b as CodeFrameOptions, c as ColorizeMethod } from './shared/error.CrVmNoPV.cjs';
|
|
5
5
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
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';
|
|
2
|
+
export { ErrorHint, ErrorLocation, ErrorProperties, ErrorWithCauseSerializerOptions, RenderErrorOptions, SerializedError, VisulimaError, captureRawStackTrace, getErrorCauses, isVisulimaError, renderError, serializeError } from './error/index.mjs';
|
|
3
3
|
export { Trace, TraceType, parseStacktrace } from './stacktrace/index.mjs';
|
|
4
4
|
export { C as CodeFrameLocation, a as CodeFrameNodeLocation, b as CodeFrameOptions, c as ColorizeMethod } from './shared/error.CrVmNoPV.mjs';
|
|
5
5
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
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';
|
|
2
|
+
export { ErrorHint, ErrorLocation, ErrorProperties, ErrorWithCauseSerializerOptions, RenderErrorOptions, SerializedError, VisulimaError, captureRawStackTrace, getErrorCauses, isVisulimaError, renderError, serializeError } from './error/index.js';
|
|
3
3
|
export { Trace, TraceType, parseStacktrace } from './stacktrace/index.js';
|
|
4
4
|
export { C as CodeFrameLocation, a as CodeFrameNodeLocation, b as CodeFrameOptions, c as ColorizeMethod } from './shared/error.CrVmNoPV.js';
|
|
5
5
|
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var u=Object.defineProperty;var l=(r,e)=>u(r,"name",{value:e,configurable:!0});import{CODE_FRAME_POINTER as h,codeFrame as x}from"./code-frame/index.mjs";import{V as b,c as k,i as C,a as S,r as T,s as v}from"./shared/error.DR_c4iBF.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 c=s((r,e)=>{let n=0,a=e.length-2;for(;n<a;){const t=n+(a-n>>1);if(r<e[t])a=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 a=n?.skipChecks??!1;if(!a&&(!Array.isArray(r)&&typeof r!="string"||(typeof r=="string"||Array.isArray(r))&&r.length===0))return{column:0,line:0};if(!a&&(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 o=m(r),i=c(e,o);return{column:e-o[i]+1,line:i+1}}const t=c(e,r);return{column:e-r[t]+1,line:t+1}},"indexToLineColumn"),g=p;export{h as CODE_FRAME_POINTER,b as VisulimaError,k as captureRawStackTrace,x as codeFrame,C as getErrorCauses,g as indexToLineColumn,S as isVisulimaError,O as parseStacktrace,T as renderError,v as serializeError};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";var T=Object.defineProperty;var u=(e,r)=>T(e,"name",{value:r,configurable:!0});const P=require("node:util"),E=require("node:fs"),C=require("node:path"),L=require("node:process"),A=require("node:url"),M=require("../code-frame/index.cjs"),v=require("../stacktrace/index.cjs");var I=Object.defineProperty,_=u((e,r)=>I(e,"name",{value:r,configurable:!0}),"e");const $=_(()=>{if(!Error.captureStackTrace)return;const e=new Error;return Error.captureStackTrace(e),e.stack},"captureRawStackTrace"),J=$;var F=Object.defineProperty,q=u((e,r)=>F(e,"name",{value:r,configurable:!0}),"a");const B=q(e=>{const r=new Set,t=[];let i=e;for(;i;){if(r.has(i)){console.error(`Circular reference detected in error causes: ${P.inspect(e)}`);break}if(t.push(i),r.add(i),!i.cause)break;i=i.cause}return t},"getErrorCauses"),D=B;var z=Object.defineProperty,s=u((e,r)=>z(e,"name",{value:r,configurable:!0}),"o");const l=s((e,r,t)=>t===0?e+"":r===" "?e+" ".repeat(t):e+" ".repeat(r*t),"getPrefix"),R=s((e,r)=>{const t=e.replace("async file:","file:");return C.relative(r,t.startsWith("file:")?A.fileURLToPath(t):t)},"getRelativePath"),y=s((e,{color:r,hideErrorTitle:t,indentation:i,prefix:o},n)=>l(o,i,n)+(t?r.title(e.message):r.title(e.name+(e.message?": "+e.message:"")))+`
|
|
2
|
+
`,"getMessage"),w=s((e,{color:r,indentation:t,prefix:i},o)=>{if(e.hint===void 0)return;const n=l(i,t,o);let a="";if(Array.isArray(e.hint))for(const c of e.hint)a+=n+c+`
|
|
3
|
+
`;else a+=n+e.hint;return r.hint(a)},"getHint"),b=s((e,{color:r,cwd:t,displayShortPath:i,indentation:o,prefix:n},a=0)=>{const c=i?R(e.file,t):e.file,{fileLine:f,method:h}=r;return l(n,o,a)+"at "+(e.methodName?h(e.methodName)+" ":"")+f(c)+":"+f(e.line+"")},"getMainFrame"),S=s((e,{color:r,indentation:t,linesAbove:i,linesBelow:o,prefix:n,showGutter:a,showLineNumbers:c,tabWidth:f},h)=>{if(e.file===void 0)return;const g=e.file.replace("file://","");if(!E.existsSync(g))return;const V=E.readFileSync(g,"utf8");return M.codeFrame(V,{start:{column:e.column,line:e.line}},{color:r,linesAbove:i,linesBelow:o,prefix:l(n,t,h),showGutter:a,showLineNumbers:c,tabWidth:f})},"getCode"),x=s((e,r,t)=>{if(e.errors.length===0)return;let i=l(r.prefix,r.indentation,t)+`Errors:
|
|
4
|
+
|
|
5
|
+
`,o=!0;for(const n of e.errors)o?o=!1:i+=`
|
|
6
|
+
|
|
7
|
+
`,i+=k(n,{...r,framesMaxLimit:1,hideErrorCodeView:r.hideErrorErrorsCodeView},t+1);return`
|
|
8
|
+
`+i},"getErrors"),O=s((e,r,t)=>{let i=l(r.prefix,r.indentation,t)+`Caused by:
|
|
9
|
+
|
|
10
|
+
`;const o=e.cause;i+=y(o,r,t);const n=v.parseStacktrace(o).shift(),a=w(o,r,t);if(a&&(i+=a+`
|
|
11
|
+
`),i+=b(n,r,t),!r.hideErrorCauseCodeView){const c=S(n,r,t);c!==void 0&&(i+=`
|
|
12
|
+
`+c)}if(o.cause)i+=`
|
|
13
|
+
`+O(o,r,t+1);else if(o instanceof AggregateError){const c=x(o,r,t);c!==void 0&&(i+=`
|
|
14
|
+
`+c)}return`
|
|
15
|
+
`+i},"getCause"),W=s((e,r)=>(e.length>0?`
|
|
16
|
+
`:"")+e.map(t=>b(t,r)).join(`
|
|
17
|
+
`),"getStacktrace"),k=s((e,r,t)=>{const i={cwd:L.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,...r,color:{fileLine:s(a=>a,"fileLine"),gutter:s(a=>a,"gutter"),hint:s(a=>a,"hint"),marker:s(a=>a,"marker"),message:s(a=>a,"message"),method:s(a=>a,"method"),title:s(a=>a,"title"),...r.color}},o=v.parseStacktrace(e,{filter:r.filterStacktrace,frameLimit:i.framesMaxLimit}),n=o.shift();return[r.hideMessage?void 0:y(e,i,t),w(e,i,t),n?b(n,i,t):void 0,n&&!i.hideErrorCodeView?S(n,i,t):void 0,e instanceof AggregateError?x(e,i,t):void 0,e.cause===void 0?void 0:O(e,i,t),o.length>0?W(o,i):void 0].filter(Boolean).join(`
|
|
18
|
+
`)},"internalRenderError"),G=s((e,r={})=>{if(r.framesMaxLimit!==void 0&&r.framesMaxLimit<=0)throw new RangeError("The 'framesMaxLimit' option must be a positive number");return k(e,r,0)},"renderError");function H(e){if(typeof e!="object"||e===null)return!1;const r=Object.getPrototypeOf(e);return(r===null||r===Object.prototype||Object.getPrototypeOf(r)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}u(H,"isPlainObject");const U=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 Y=Object.defineProperty,m=u((e,r)=>Y(e,"name",{value:r,configurable:!0}),"c");const p=new WeakSet,K=m(e=>{p.add(e);const r=e.toJSON();return p.delete(e),r},"toJSON"),N=m((e,r,t,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 r.includes(e)?"[Circular]":(t+=1,d(e,i,r,t));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(H(e)){if(t+=1,i.maxDepth&&t>=i.maxDepth)return{};const o={};for(const n in e)o[n]=N(e[n],r,t,i);return o}try{return e}catch{return"[Not Available]"}},"serializeValue"),d=m((e,r,t,i)=>{if(t.push(e),r.maxDepth===0)return{};if(r.useToJSON&&typeof e.toJSON=="function"&&!p.has(e))return K(e);const o=Object.create(U);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 a of e.errors){if(!(a instanceof Error))throw new TypeError("All errors in the 'errors' property must be instances of Error");if(t.includes(a))return o.errors=[],o;n.push(d(a,r,t,i))}o.errors=n}e.cause instanceof Error&&!t.includes(e.cause)&&(o.cause=d(e.cause,r,t,i));for(const n in e)if(o[n]===void 0){const a=e[n];o[n]=N(a,t,i,r)}if(Array.isArray(r.exclude)&&r.exclude.length>0)for(const n of r.exclude)try{delete o[n]}catch{}return o},"_serialize"),Q=m((e,r={})=>d(e,{exclude:r.exclude??[],maxDepth:r.maxDepth??Number.POSITIVE_INFINITY,useToJSON:r.useToJSON??!1},[],0),"serialize");var X=Object.defineProperty,j=u((e,r)=>X(e,"name",{value:r,configurable:!0}),"t");const Z=j(e=>e instanceof Error&&e.type==="VisulimaError","isVisulimaError");class ee extends Error{static{u(this,"VisulimaError")}static{j(this,"VisulimaError")}loc;title;hint;type="VisulimaError";constructor({cause:r,hint:t,location:i,message:o,name:n,stack:a,title:c}){super(o,{cause:r}),this.title=c,this.name=n,this.stack=a??this.stack,this.loc=i,this.hint=t,Error.captureStackTrace(this,this.constructor)}setLocation(r){this.loc=r}setName(r){this.name=r}setMessage(r){this.message=r}setHint(r){this.hint=r}}exports.VisulimaError=ee;exports.c=J;exports.i=D;exports.isVisulimaError=Z;exports.renderError=G;exports.serialize=Q;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
var T=Object.defineProperty;var l=(e,t)=>T(e,"name",{value:t,configurable:!0});import{inspect as V}from"node:util";import{existsSync as P,readFileSync as C}from"node:fs";import{relative as L}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 $=Object.defineProperty,J=l((e,t)=>$(e,"name",{value:t,configurable:!0}),"e");const F=J(()=>{if(!Error.captureStackTrace)return;const e=new Error;return Error.captureStackTrace(e),e.stack},"captureRawStackTrace"),ie=F;var B=Object.defineProperty,D=l((e,t)=>B(e,"name",{value:t,configurable:!0}),"a");const R=D(e=>{const t=new Set,r=[];let o=e;for(;o;){if(t.has(o)){console.error(`Circular reference detected in error causes: ${V(e)}`);break}if(r.push(o),t.add(o),!o.cause)break;o=o.cause}return r},"getErrorCauses"),ne=R;var W=Object.defineProperty,s=l((e,t)=>W(e,"name",{value:t,configurable:!0}),"o");const u=s((e,t,r)=>r===0?e+"":t===" "?e+" ".repeat(r):e+" ".repeat(t*r),"getPrefix"),z=s((e,t)=>{const r=e.replace("async file:","file:");return L(t,r.startsWith("file:")?M(r):r)},"getRelativePath"),E=s((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=s((e,{color:t,indentation:r,prefix:o},i)=>{if(e.hint===void 0)return;const n=u(o,r,i);let a="";if(Array.isArray(e.hint))for(const c of e.hint)a+=n+c+`
|
|
3
|
+
`;else a+=n+e.hint;return t.hint(a)},"getHint"),b=s((e,{color:t,cwd:r,displayShortPath:o,indentation:i,prefix:n},a=0)=>{const c=o?z(e.file,r):e.file,{fileLine:f,method:h}=t;return u(n,i,a)+"at "+(e.methodName?h(e.methodName)+" ":"")+f(c)+":"+f(e.line+"")},"getMainFrame"),w=s((e,{color:t,indentation:r,linesAbove:o,linesBelow:i,prefix:n,showGutter:a,showLineNumbers:c,tabWidth:f},h)=>{if(e.file===void 0)return;const g=e.file.replace("file://","");if(!P(g))return;const k=C(g,"utf8");return I(k,{start:{column:e.column,line:e.line}},{color:t,linesAbove:o,linesBelow:i,prefix:u(n,r,h),showGutter:a,showLineNumbers:c,tabWidth:f})},"getCode"),S=s((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=s((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(),a=y(i,t,r);if(a&&(o+=a+`
|
|
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"),G=s((e,t)=>(e.length>0?`
|
|
16
|
+
`:"")+e.map(r=>b(r,t)).join(`
|
|
17
|
+
`),"getStacktrace"),O=s((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:s(a=>a,"fileLine"),gutter:s(a=>a,"gutter"),hint:s(a=>a,"hint"),marker:s(a=>a,"marker"),message:s(a=>a,"message"),method:s(a=>a,"method"),title:s(a=>a,"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?G(i,o):void 0].filter(Boolean).join(`
|
|
18
|
+
`)},"internalRenderError"),ae=s((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 _(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(_,"isPlainObject");const H=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 U=Object.defineProperty,d=l((e,t)=>U(e,"name",{value:t,configurable:!0}),"c");const p=new WeakSet,Y=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(_(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 Y(e);const i=Object.create(H);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 a of e.errors){if(!(a instanceof Error))throw new TypeError("All errors in the 'errors' property must be instances of Error");if(r.includes(a))return i.errors=[],i;n.push(m(a,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 a=e[n];i[n]=N(a,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"),se=d((e,t={})=>m(e,{exclude:t.exclude??[],maxDepth:t.maxDepth??Number.POSITIVE_INFINITY,useToJSON:t.useToJSON??!1},[],0),"serialize");var q=Object.defineProperty,j=l((e,t)=>q(e,"name",{value:t,configurable:!0}),"t");const ce=j(e=>e instanceof Error&&e.type==="VisulimaError","isVisulimaError");class le 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:a,title:c}){super(i,{cause:t}),this.title=c,this.name=n,this.stack=a??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{le as V,ce as a,ie as c,ne as i,ae as r,se as s};
|
package/package.json
CHANGED
|
@@ -1,18 +0,0 @@
|
|
|
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;
|
|
@@ -1,18 +0,0 @@
|
|
|
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};
|