@visulima/fs 1.11.1 → 2.0.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/dist/utils.d.ts CHANGED
@@ -1,9 +1,13 @@
1
1
  export { J as JSONError } from './json-error-UVjLdb7z.js';
2
2
  import { JsonValue } from 'type-fest';
3
- import { n as CodeFrameOptions, J as JsonReviver } from './types-HVB0D8On.js';
3
+ import { n as CodeFrameOptions, J as JsonReviver } from './types-BtNfXx_X.js';
4
4
  import 'node:fs';
5
5
  import 'yaml';
6
6
 
7
+ declare const assertValidFileContents: (contents: any) => void;
8
+
9
+ declare const assertValidFileOrDirectoryPath: (fileOrDirectoryPath: any) => void;
10
+
7
11
  declare function parseJson<T = JsonValue>(string: string, filename?: string, options?: CodeFrameOptions): T;
8
12
  declare function parseJson<T = JsonValue>(string: string, reviver: JsonReviver, fileName?: string, options?: CodeFrameOptions): T;
9
13
 
@@ -13,4 +17,4 @@ declare const stripJsonComments: (jsonString: string, { whitespace }?: {
13
17
 
14
18
  declare const toPath: (urlOrPath: URL | string) => string;
15
19
 
16
- export { parseJson, stripJsonComments, toPath };
20
+ export { assertValidFileContents, assertValidFileOrDirectoryPath, parseJson, stripJsonComments, toPath };
package/dist/utils.js CHANGED
@@ -1,7 +1,7 @@
1
- export { b as parseJson, a as toPath } from './chunk-4WZBYISP.js';
1
+ export { d as assertValidFileContents, a as assertValidFileOrDirectoryPath, c as parseJson, b as toPath } from './chunk-LMCWM2WT.js';
2
2
  export { a as JSONError } from './chunk-UPN3Y5W3.js';
3
3
 
4
- var f=(t,{whitespace:e=!0}={})=>t.replace(l,r=>r.startsWith('"')||r[1]==="*"&&!r.endsWith("*/")?r:e?r.replaceAll(/\S/g," "):""),l=/"(?:[^"\\]|\\.)*"?|\/\/[^\r\n]*|\/\*(?:[^*]|\*[^/])*(?:\*\/)?/g,u=f;
4
+ var i=(t,{whitespace:e=!0}={})=>t.replace(d,r=>r.startsWith('"')||r[1]==="*"&&!r.endsWith("*/")?r:e?r.replaceAll(/\S/g," "):""),d=/"(?:[^"\\]|\\.)*"?|\/\/[^\r\n]*|\/\*(?:[^*]|\*[^/])*(?:\*\/)?/g,u=i;
5
5
 
6
6
  export { u as stripJsonComments };
7
7
  //# sourceMappingURL=out.js.map
package/dist/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/utils/strip-json-comments.ts"],"names":["stripJsonComments","jsonString","whitespace","INTERNAL_STRIP_JSON_REGEX","match","strip_json_comments_default"],"mappings":"uFAEA,IAAMA,EAAoB,CAACC,EAAoB,CAAE,WAAAC,EAAa,EAAK,EAAI,CAAC,IASpED,EAAW,QAAQE,EAA4BC,GAEvCA,EAAM,WAAW,GAAG,GAAMA,EAAM,CAAC,IAAM,KAAO,CAACA,EAAM,SAAS,IAAI,EAC3DA,EAIJF,EAAaE,EAAM,WAAW,MAAO,GAAG,EAAI,EACtD,EAEQD,EAA4B,iEAElCE,EAAQL","sourcesContent":["// Copyright by https://github.com/swansontec\n\nconst stripJsonComments = (jsonString: string, { whitespace = true } = {}): string =>\n // This regular expression translates to:\n //\n // /quoted-string|line-comment|block-comment/g\n //\n // This means that comment characters inside of strings will match\n // as strings, not comments, so we can just skip the whole string\n // in the replacer function.\n // eslint-disable-next-line unicorn/prefer-string-replace-all,@typescript-eslint/no-use-before-define\n jsonString.replace(INTERNAL_STRIP_JSON_REGEX, (match) => {\n // Skip strings & broken block comments:\n if (match.startsWith('\"') || (match[1] === \"*\" && !match.endsWith(\"*/\"))) {\n return match;\n }\n\n // Replace comments with whitespace (or not):\n return whitespace ? match.replaceAll(/\\S/g, \" \") : \"\";\n });\n\nexport const INTERNAL_STRIP_JSON_REGEX = /\"(?:[^\"\\\\]|\\\\.)*\"?|\\/\\/[^\\r\\n]*|\\/\\*(?:[^*]|\\*[^/])*(?:\\*\\/)?/g;\n\nexport default stripJsonComments;\n"]}
1
+ {"version":3,"sources":["../src/utils/strip-json-comments.ts"],"names":["stripJsonComments","jsonString","whitespace","INTERNAL_STRIP_JSON_REGEX","match","strip_json_comments_default"],"mappings":"gGAEA,IAAMA,EAAoB,CAACC,EAAoB,CAAE,WAAAC,EAAa,EAAK,EAAI,CAAC,IASpED,EAAW,QAAQE,EAA4BC,GAEvCA,EAAM,WAAW,GAAG,GAAMA,EAAM,CAAC,IAAM,KAAO,CAACA,EAAM,SAAS,IAAI,EAC3DA,EAIJF,EAAaE,EAAM,WAAW,MAAO,GAAG,EAAI,EACtD,EAEQD,EAA4B,iEAElCE,EAAQL","sourcesContent":["// Copyright by https://github.com/swansontec\n\nconst stripJsonComments = (jsonString: string, { whitespace = true } = {}): string =>\n // This regular expression translates to:\n //\n // /quoted-string|line-comment|block-comment/g\n //\n // This means that comment characters inside of strings will match\n // as strings, not comments, so we can just skip the whole string\n // in the replacer function.\n // eslint-disable-next-line unicorn/prefer-string-replace-all,@typescript-eslint/no-use-before-define\n jsonString.replace(INTERNAL_STRIP_JSON_REGEX, (match) => {\n // Skip strings & broken block comments:\n if (match.startsWith('\"') || (match[1] === \"*\" && !match.endsWith(\"*/\"))) {\n return match;\n }\n\n // Replace comments with whitespace (or not):\n return whitespace ? match.replaceAll(/\\S/g, \" \") : \"\";\n });\n\nexport const INTERNAL_STRIP_JSON_REGEX = /\"(?:[^\"\\\\]|\\\\.)*\"?|\\/\\/[^\\r\\n]*|\\/\\*(?:[^*]|\\*[^/])*(?:\\*\\/)?/g;\n\nexport default stripJsonComments;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/fs",
3
- "version": "1.11.1",
3
+ "version": "2.0.0",
4
4
  "description": "Human friendly file system utilities for Node.js",
5
5
  "keywords": [
6
6
  "anolilab",
@@ -132,6 +132,7 @@
132
132
  "test:watch": "vitest"
133
133
  },
134
134
  "dependencies": {
135
+ "pathe": "^1.1.2",
135
136
  "type-fest": "^4.13.1"
136
137
  },
137
138
  "devDependencies": {
@@ -1,5 +0,0 @@
1
- var t=class extends Error{root;constructor(r,o){super(`${r instanceof Error?r.message:r} for path "${o}"`),this.cause=r,this.name="WalkError",this.root=o;}},p=t;var e=class extends Error{name="PermissionError";code="EPERM";constructor(r){super(`EPERM: Operation not permitted, ${r}`);}},l=e;
2
-
3
- export { p as a, l as b };
4
- //# sourceMappingURL=out.js.map
5
- //# sourceMappingURL=chunk-3EHZOWRU.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/error/walk-error.ts","../src/error/permission-error.ts"],"names":["WalkError","cause","root","walk_error_default","PermissionError","message","permission_error_default"],"mappings":"AAMA,IAAMA,EAAN,cAAwB,KAAM,CAEnB,KAGA,YAAYC,EAAgBC,EAAc,CAE7C,MAAM,GAAGD,aAAiB,MAAQA,EAAM,QAAUA,CAAK,cAAcC,CAAI,GAAG,EAE5E,KAAK,MAAQD,EACb,KAAK,KAAO,YACZ,KAAK,KAAOC,CAChB,CACJ,EAEOC,EAAQH,EClBf,IAAMI,EAAN,cAA8B,KAAM,CAMd,KAAO,kBAMlB,KAAO,QAMP,YAAYC,EAAiB,CAChC,MAAM,mCAAmCA,CAAO,EAAE,CACtD,CACJ,EAEOC,EAAQF","sourcesContent":["// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.\n// Documentation and interface for walk were adapted from Go\n// https://golang.org/pkg/path/filepath/#Walk\n// Copyright 2009 The Go Authors. All rights reserved. BSD license.\n\n/** Error thrown in {@linkcode walk} or {@linkcode walkSync} during iteration. */\nclass WalkError extends Error {\n /** File path of the root that's being walked. */\n public root: string;\n\n /** Constructs a new instance. */\n public constructor(cause: unknown, root: string) {\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n super(`${cause instanceof Error ? cause.message : cause} for path \"${root}\"`);\n\n this.cause = cause;\n this.name = \"WalkError\";\n this.root = root;\n }\n}\n\nexport default WalkError;\n","/**\n * Error thrown when an operation is not permitted.\n */\nclass PermissionError extends Error {\n /**\n * Name of the error class.\n * @type {string}\n */\n // eslint-disable-next-line @typescript-eslint/explicit-member-accessibility\n override readonly name = \"PermissionError\";\n\n /**\n * Error code.\n * @type {string}\n */\n public code = \"EPERM\";\n\n /**\n * Creates a new instance.\n * @param {string} message The error message.\n */\n public constructor(message: string) {\n super(`EPERM: Operation not permitted, ${message}`);\n }\n}\n\nexport default PermissionError;\n"]}
@@ -1,13 +0,0 @@
1
- import { a } from './chunk-UPN3Y5W3.js';
2
- import { fileURLToPath } from 'node:url';
3
-
4
- var P=e=>e instanceof URL?fileURLToPath(e):e,K=P;var R=e=>e.replaceAll(/\r\n|\r(?!\n)|\n/gu,`
5
- `),j=R,M=globalThis.process||Object.create(null),T={versions:{}},V=new Proxy(M,{get(e,t){if(t in e)return e[t];if(t in T)return T[t]}}),J=V,W=(e,t,o,n)=>{let r={column:0,line:-1,...e.start},s={...r,...e.end},a=r.line,l=r.column,c=s.line,p=s.column,f=Math.max(a-(o+1),0),d=Math.min(t.length,c+n);a===-1&&(f=0),c===-1&&(d=t.length);let h=c-a,m={};if(h)for(let i=0;i<=h;i++){let u=i+a;if(!l)m[u]=!0;else if(i===0){let g=t[u-1]?.length;m[u]=[l,(g??0)-l+1];}else if(i===h)m[u]=[0,p];else {let g=t[u-i]?.length;m[u]=[0,g];}}else l===p?m[a]=l?[l,0]:!0:m[a]=[l,(p??0)-(l??0)];return {end:d,markerLines:m,start:f}},U=W,v=J.platform==="win32"&&!J.env?.WT_SESSION?">":"\u276F",A=(e,t,o)=>{let n={linesAbove:2,linesBelow:3,showGutter:!0,showLineNumbers:!0,tabWidth:4,...o,color:{gutter:i=>i,marker:i=>i,message:i=>i,...o?.color}},r=t.start&&typeof t.start.column=="number",s=j(e).split(`
6
- `);typeof n?.tabWidth=="number"&&(s=s.map(i=>i.replaceAll(" "," ".repeat(n.tabWidth))));let{end:a,markerLines:l,start:c}=U(t,s,n.linesAbove,n.linesBelow),p=String(a).length,{gutter:f,marker:d,message:h}=n.color,m=s.slice(c,a).map((i,u)=>{let g=c+1+u,y=l[g],w=` ${g}`.slice(-p),E=!l[g+1],b=` ${w}${n.showGutter?" |":""}`;if(y){let x="";if(Array.isArray(y)){let O=i.replaceAll(/[^\t]/g," ").slice(0,Math.max(y[0]-1,0)),S=y[1]||1;x=[`
7
- `,f(b.replaceAll(/\d/g," "))," ",O,d("^").repeat(S)].join(""),E&&n.message&&(x+=` ${h(n.message)}`);}return [d(v),f(b),i.length>0?` ${i}`:"",x].join("")}return ` ${f(b)}${i.length>0?` ${i}`:""}`}).join(`
8
- `);return n.message&&!r&&(m=`${" ".repeat(p+1)}${n.message}
9
- ${m}`),m};var L=(e,t)=>{let o=0,n=t.length-2;for(;o<n;){let r=o+(n-o>>1);if(e<t[r])n=r-1;else if(e>=t[r+1])o=r+1;else {o=r;break}}return o},_=e=>e.split(/\n|\r(?!\n)/).reduce((t,o)=>(t.push(t.at(-1)+o.length+1),t),[0]),q=(e,t,o)=>{let n=o?.skipChecks??!1;if(!n&&(!Array.isArray(e)&&typeof e!="string"||(typeof e=="string"||Array.isArray(e))&&e.length===0))return {column:0,line:0};if(!n&&(typeof t!="number"||typeof e=="string"&&t>=e.length||Array.isArray(e)&&t+1>=e.at(-1)))return {column:0,line:0};if(typeof e=="string"){let s=_(e),a=L(t,s);return {column:t-s[a]+1,line:a+1}}let r=L(t,e);return {column:t-e[r]+1,line:r+1}},k=q;var B=e=>`\\u{${e.codePointAt(0).toString(16)}}`,G=(e,t,o)=>A(e,{start:t},{tabWidth:!1,...o}),I=(e,t)=>{let o=/in JSON at position (?<index>\d+)(?: \(line (?<line>\d+) column (?<column>\d+)\))?$/.exec(t);if(!o)return;let{column:n,index:r,line:s}=o.groups;return s&&n?{column:Number(n),line:Number(s)}:(r=Number(r),r===e.length&&(r=e.length-1),k(e,r))},z=e=>e.replace(/(?<=^Unexpected token )(?<quote>')?(.)\k<quote>/,(t,o,n)=>`"${n}"(${B(n)})`);function D(e,t,o,n){typeof t=="string"&&(typeof o=="object"&&(n=o),o=t,t=void 0);let r;try{return JSON.parse(e,t)}catch(l){r=l.message;}let s;e?(s=I(e,r),r=z(r)):r+=" while parsing empty string";let a$1=new a(r);throw a$1.fileName=o,s&&(a$1.codeFrame=G(e,s,n)),a$1}var ie=D;
10
-
11
- export { K as a, ie as b };
12
- //# sourceMappingURL=out.js.map
13
- //# sourceMappingURL=chunk-4WZBYISP.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/utils/to-path.ts","../../error/src/util/normalize-lf.ts","../../error/src/util/process.ts","../../error/src/code-frame/get-marker-lines.ts","../../error/src/code-frame/index.ts","../src/utils/parse-json.ts"],"names":["fileURLToPath","toPath","urlOrPath","to_path_default","normalizeLF","code","normalize_lf_default","_process","processShims","process","target","property","process_default","getMarkerLines","loc","source","linesAbove","linesBelow","startLoc","endLoc","startLine","startColumn","endLine","endColumn","start","end","lineDiff","markerLines","index","lineNumber","sourceLength","a","u","e","m","o","n","i","f","get_marker_lines_default","$","S","W","M","options","L","config","t","value","hasColumns","g","r","x","s","lines","ln","numberMaxWidth","colorizeGutter","colorizeMarker","colorizeMessage","frame","line","number","hasMarker","paddedNumber","lastMarkerLine","gutter","markerLine","markerSpacing","numberOfMarkers","CODE_FRAME_POINTER","h","k","d","getCodePoint","character","generateCodeFrame","location","q","getErrorLocation","message","match","column","F","addCodePointToUnexpectedToken","_","_quote","token","parseJson","string","reviver","fileName","error","jsonError","json_error_default","parse_json_default"],"mappings":"wCAAA,OAAS,iBAAAA,MAAqB,WAE9B,IAAMC,EAAUC,GAAqCA,aAAqB,IAAMF,EAAcE,CAAS,EAAIA,EAEpGC,EAAQF,ECJf,IAAMG,EAAeC,GAAyBA,EAAK,WAAW,qBAAsB;CAAI,EAEjFC,EAAQF,ECGTG,EAAY,WAAW,SAAW,OAAO,OAAO,IAAI,EAEpDC,EAAiC,CACnC,SAAU,CAAC,CACf,EAEMC,EAAU,IAAI,MAAeF,EAAU,CACzC,IAAIG,EAAQC,EAAyB,CACjC,GAAIA,KAAYD,EAEZ,OAAOA,EAAOC,CAAQ,EAG1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,EAAQa,CAAK,EAC1C,EAEMwD,EAAiCJ,GACnCA,EAAQ,QAGJ,kDAEA,CAACK,EAAGC,EAAQC,IAAU,IAAIA,CAAK,KAAKb,EAAaa,CAAK,CAAC,GAC3D,EAKJ,SAASC,EAAyBC,EAAgBC,EAAgCC,EAAsC/C,EAA+B,CAC/I,OAAO8C,GAAY,WACf,OAAOC,GAAa,WAEpB/C,EAAU+C,GAIdA,EAAWD,EAEXA,EAAU,QAGd,IAAIV,EAEJ,GAAI,CAEA,OAAO,KAAK,MAAMS,EAAQC,CAAO,CAErC,OAASE,EAAY,CAEjBZ,EAAUY,EAAM,OACpB,CAEA,IAAIf,EAEAY,GACAZ,EAAWE,EAAiBU,EAAQT,CAAO,EAC3CA,EAAUI,EAA8BJ,CAAO,GAE/CA,GAAW,8BAGf,IAAMa,EAAY,IAAIC,EAAUd,CAAO,EAEvC,MAAAa,EAAU,SAAWF,EAEjBd,IAEAgB,EAAU,UAAYjB,EAAkBa,EAAQZ,EAAUjC,CAAO,GAG/DiD,CACV,CAEA,IAAOE,GAAQP","sourcesContent":["import { fileURLToPath } from \"node:url\";\n\nconst toPath = (urlOrPath: URL | string): string => (urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath);\n\nexport default toPath;\n","const normalizeLF = (code: string): string => code.replaceAll(/\\r\\n|\\r(?!\\n)|\\n/gu, \"\\n\");\n\nexport default normalizeLF;\n","interface Process extends Partial<Omit<typeof globalThis.process, \"versions\">> {\n versions: Record<string, string>;\n}\n\n// eslint-disable-next-line @typescript-eslint/naming-convention,@typescript-eslint/no-unnecessary-condition,no-underscore-dangle\nconst _process = (globalThis.process || Object.create(null)) as unknown as Process;\n\nconst processShims: Partial<Process> = {\n versions: {},\n};\n\nconst process = new Proxy<Process>(_process, {\n get(target, property: keyof Process) {\n if (property in target) {\n // eslint-disable-next-line security/detect-object-injection\n return target[property];\n }\n\n if (property in processShims) {\n // eslint-disable-next-line security/detect-object-injection\n return processShims[property];\n }\n\n return undefined;\n },\n});\n\nexport default process;\n","// eslint-disable-next-line no-secrets/no-secrets\n/**\n * This is a copy of the codeFrame function from Babel\n * @see https://github.com/babel/babel/blob/85e649203b61b7c908eb04c05511a0d35f893e8e/packages/babel-code-frame/src/index.ts#L68-L143\n *\n * MIT License\n *\n * Copyright (c) 2014-present Sebastian McKenzie and other contributors\n */\n\n/**\n * Extract what lines should be marked and highlighted.\n */\nimport type { CodeFrameLocation, CodeFrameNodeLocation } from \"./types\";\n\ntype MarkerLines = Record<number, true | [number | undefined, number | undefined]>;\n\nconst getMarkerLines = (\n loc: CodeFrameNodeLocation,\n source: string[],\n linesAbove: number,\n linesBelow: number,\n): {\n end: number;\n markerLines: MarkerLines;\n start: number;\n // eslint-disable-next-line sonarjs/cognitive-complexity\n} => {\n const startLoc: CodeFrameLocation = {\n column: 0,\n // @ts-expect-error Can be overwritten\n line: -1,\n ...loc.start,\n };\n const endLoc: CodeFrameLocation = {\n ...startLoc,\n ...loc.end,\n };\n const startLine = startLoc.line;\n const startColumn = startLoc.column;\n const endLine = endLoc.line;\n const endColumn = endLoc.column;\n\n let start = Math.max(startLine - (linesAbove + 1), 0);\n let end = Math.min(source.length, endLine + linesBelow);\n\n if (startLine === -1) {\n start = 0;\n }\n\n if (endLine === -1) {\n end = source.length;\n }\n\n const lineDiff = endLine - startLine;\n const markerLines: MarkerLines = {};\n\n if (lineDiff) {\n // eslint-disable-next-line no-plusplus,no-loops/no-loops\n for (let index = 0; index <= lineDiff; index++) {\n const lineNumber = index + startLine;\n\n if (!startColumn) {\n // eslint-disable-next-line security/detect-object-injection\n markerLines[lineNumber] = true;\n } else if (index === 0) {\n const sourceLength = source[lineNumber - 1]?.length;\n\n // eslint-disable-next-line security/detect-object-injection\n markerLines[lineNumber] = [startColumn, (sourceLength ?? 0) - startColumn + 1];\n } else if (index === lineDiff) {\n // eslint-disable-next-line security/detect-object-injection\n markerLines[lineNumber] = [0, endColumn];\n } else {\n const sourceLength = source[lineNumber - index]?.length;\n\n // eslint-disable-next-line security/detect-object-injection\n markerLines[lineNumber] = [0, sourceLength];\n }\n }\n } else if (startColumn === endColumn) {\n // eslint-disable-next-line security/detect-object-injection\n markerLines[startLine] = startColumn ? [startColumn, 0] : true;\n } else {\n // eslint-disable-next-line security/detect-object-injection\n markerLines[startLine] = [startColumn, (endColumn ?? 0) - (startColumn ?? 0)];\n }\n\n return { end, markerLines, start };\n};\n\nexport default getMarkerLines;\n","// eslint-disable-next-line no-secrets/no-secrets\n/**\n * This is a modified copy of the codeFrameColumns function from Babel\n * @see https://github.com/babel/babel/blob/85e649203b61b7c908eb04c05511a0d35f893e8e/packages/babel-code-frame/src/index.ts#L145-L217\n *\n * MIT License\n *\n * Copyright (c) 2014-present Sebastian McKenzie and other contributors\n */\n\nimport normalizeLF from \"../util/normalize-lf\";\nimport process from \"../util/process\";\nimport getMarkerLines from \"./get-marker-lines\";\nimport type { CodeFrameNodeLocation, CodeFrameOptions } from \"./types\";\n\nexport const CODE_FRAME_POINTER = process.platform === \"win32\" && !process.env?.[\"WT_SESSION\"] ? \">\" : \"❯\";\n\n/** Generate a code frame from string and an error location */\nexport const codeFrame = (\n source: string,\n loc: CodeFrameNodeLocation,\n options?: CodeFrameOptions,\n // eslint-disable-next-line sonarjs/cognitive-complexity\n): string => {\n // grab 2 lines before, and 3 lines after focused line\n const config = {\n linesAbove: 2,\n linesBelow: 3,\n showGutter: true,\n showLineNumbers: true,\n tabWidth: 4,\n ...options,\n color: {\n gutter: (value: string) => value,\n marker: (value: string) => value,\n message: (value: string) => value,\n ...options?.color,\n },\n };\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n const hasColumns = loc.start && typeof loc.start.column === \"number\";\n\n let lines = normalizeLF(source).split(\"\\n\");\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (typeof config?.tabWidth === \"number\") {\n lines = lines.map((ln) => ln.replaceAll(\"\\t\", \" \".repeat(config.tabWidth as number)));\n }\n\n const { end, markerLines, start } = getMarkerLines(loc, lines, config.linesAbove, config.linesBelow);\n\n const numberMaxWidth = String(end).length;\n const { gutter: colorizeGutter, marker: colorizeMarker, message: colorizeMessage } = config.color;\n\n let frame = lines\n .slice(start, end)\n .map((line, index) => {\n const number = start + 1 + index;\n // eslint-disable-next-line security/detect-object-injection\n const hasMarker = markerLines[number];\n const paddedNumber = ` ${number}`.slice(-numberMaxWidth);\n const lastMarkerLine = !markerLines[number + 1];\n\n const gutter = ` ${paddedNumber}${config.showGutter ? ` |` : \"\"}`;\n\n if (hasMarker) {\n let markerLine = \"\";\n\n if (Array.isArray(hasMarker)) {\n const markerSpacing = line.replaceAll(/[^\\t]/g, \" \").slice(0, Math.max((hasMarker[0] as number) - 1, 0));\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n const numberOfMarkers = hasMarker[1] || 1;\n\n markerLine = [\"\\n \", colorizeGutter(gutter.replaceAll(/\\d/g, \" \")), \" \", markerSpacing, colorizeMarker(\"^\").repeat(numberOfMarkers)].join(\n \"\",\n );\n\n if (lastMarkerLine && config.message) {\n markerLine += ` ${colorizeMessage(config.message)}`;\n }\n }\n\n return [colorizeMarker(CODE_FRAME_POINTER), colorizeGutter(gutter), line.length > 0 ? ` ${line}` : \"\", markerLine].join(\"\");\n }\n\n return ` ${colorizeGutter(gutter)}${line.length > 0 ? ` ${line}` : \"\"}`;\n })\n .join(\"\\n\");\n\n if (config.message && !hasColumns) {\n frame = `${\" \".repeat(numberMaxWidth + 1)}${config.message}\\n${frame}`;\n }\n\n return frame;\n};\n\nexport type { CodeFrameLocation, CodeFrameNodeLocation, CodeFrameOptions, ColorizeMethod } from \"./types\";\n","/**\n * A modified version of `parse-json` from `https://github.com/sindresorhus/parse-json/blob/main/index.js`\n *\n * MIT License\n * Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)\n */\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport { codeFrame, indexToLineColumn } from \"@visulima/error\";\nimport type { JsonValue } from \"type-fest\";\n\nimport JsonError from \"../error/json-error\";\nimport type { CodeFrameLocation, CodeFrameOptions, JsonReviver } from \"../types\";\n\nconst getCodePoint = (character: string): string => `\\\\u{${(character.codePointAt(0) as number).toString(16)}}`;\n\nconst generateCodeFrame = (source: string, location: CodeFrameLocation, options?: CodeFrameOptions) =>\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-return\n codeFrame(\n source,\n { start: location },\n {\n tabWidth: false,\n ...options,\n },\n );\n\nconst getErrorLocation = (source: string, message: string): CodeFrameLocation | undefined => {\n // eslint-disable-next-line security/detect-unsafe-regex\n const match = /in JSON at position (?<index>\\d+)(?: \\(line (?<line>\\d+) column (?<column>\\d+)\\))?$/.exec(message);\n\n if (!match) {\n return undefined;\n }\n\n // eslint-disable-next-line prefer-const\n let { column, index, line } = match.groups as { column?: string; index: number | string; line?: string };\n\n if (line && column) {\n return { column: Number(column), line: Number(line) };\n }\n\n index = Number(index);\n\n // The error location can be out of bounds.\n if (index === source.length) {\n index = source.length - 1;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-return\n return indexToLineColumn(source, index);\n};\n\nconst addCodePointToUnexpectedToken = (message: string): string =>\n message.replace(\n // TODO[engine:node@>=20]: The token always quoted after Node.js 20\n // eslint-disable-next-line regexp/no-potentially-useless-backreference\n /(?<=^Unexpected token )(?<quote>')?(.)\\k<quote>/,\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n (_, _quote, token) => `\"${token}\"(${getCodePoint(token)})`,\n );\n\nfunction parseJson<T = JsonValue>(string: string, filename?: string, options?: CodeFrameOptions): T;\nfunction parseJson<T = JsonValue>(string: string, reviver: JsonReviver, fileName?: string, options?: CodeFrameOptions): T;\n// eslint-disable-next-line func-style\nfunction parseJson<T = JsonValue>(string: string, reviver?: JsonReviver | string, fileName?: CodeFrameOptions | string, options?: CodeFrameOptions): T {\n if (typeof reviver === \"string\") {\n if (typeof fileName === \"object\") {\n // eslint-disable-next-line no-param-reassign\n options = fileName;\n }\n\n // eslint-disable-next-line no-param-reassign\n fileName = reviver;\n // eslint-disable-next-line no-param-reassign\n reviver = undefined;\n }\n\n let message: string;\n\n try {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return JSON.parse(string, reviver);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access\n message = error.message;\n }\n\n let location: CodeFrameLocation | undefined;\n\n if (string) {\n location = getErrorLocation(string, message);\n message = addCodePointToUnexpectedToken(message);\n } else {\n message += \" while parsing empty string\";\n }\n\n const jsonError = new JsonError(message);\n\n jsonError.fileName = fileName as string;\n\n if (location) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n jsonError.codeFrame = generateCodeFrame(string, location, options);\n }\n\n throw jsonError;\n}\n\nexport default parseJson;\n"]}
@@ -1,8 +0,0 @@
1
- 'use strict';
2
-
3
- var t=class extends Error{root;constructor(r,o){super(`${r instanceof Error?r.message:r} for path "${o}"`),this.cause=r,this.name="WalkError",this.root=o;}},i=t;var e=class extends Error{name="PermissionError";code="EPERM";constructor(r){super(`EPERM: Operation not permitted, ${r}`);}},a=e;
4
-
5
- exports.a = i;
6
- exports.b = a;
7
- //# sourceMappingURL=out.js.map
8
- //# sourceMappingURL=chunk-KXYI7M76.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/error/walk-error.ts","../src/error/permission-error.ts"],"names":["WalkError","cause","root","walk_error_default","PermissionError","message","permission_error_default"],"mappings":"AAMA,IAAMA,EAAN,cAAwB,KAAM,CAEnB,KAGA,YAAYC,EAAgBC,EAAc,CAE7C,MAAM,GAAGD,aAAiB,MAAQA,EAAM,QAAUA,CAAK,cAAcC,CAAI,GAAG,EAE5E,KAAK,MAAQD,EACb,KAAK,KAAO,YACZ,KAAK,KAAOC,CAChB,CACJ,EAEOC,EAAQH,EClBf,IAAMI,EAAN,cAA8B,KAAM,CAMd,KAAO,kBAMlB,KAAO,QAMP,YAAYC,EAAiB,CAChC,MAAM,mCAAmCA,CAAO,EAAE,CACtD,CACJ,EAEOC,EAAQF","sourcesContent":["// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.\n// Documentation and interface for walk were adapted from Go\n// https://golang.org/pkg/path/filepath/#Walk\n// Copyright 2009 The Go Authors. All rights reserved. BSD license.\n\n/** Error thrown in {@linkcode walk} or {@linkcode walkSync} during iteration. */\nclass WalkError extends Error {\n /** File path of the root that's being walked. */\n public root: string;\n\n /** Constructs a new instance. */\n public constructor(cause: unknown, root: string) {\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n super(`${cause instanceof Error ? cause.message : cause} for path \"${root}\"`);\n\n this.cause = cause;\n this.name = \"WalkError\";\n this.root = root;\n }\n}\n\nexport default WalkError;\n","/**\n * Error thrown when an operation is not permitted.\n */\nclass PermissionError extends Error {\n /**\n * Name of the error class.\n * @type {string}\n */\n // eslint-disable-next-line @typescript-eslint/explicit-member-accessibility\n override readonly name = \"PermissionError\";\n\n /**\n * Error code.\n * @type {string}\n */\n public code = \"EPERM\";\n\n /**\n * Creates a new instance.\n * @param {string} message The error message.\n */\n public constructor(message: string) {\n super(`EPERM: Operation not permitted, ${message}`);\n }\n}\n\nexport default PermissionError;\n"]}
@@ -1,16 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkN5NZURYL_cjs = require('./chunk-N5NZURYL.cjs');
4
- var url = require('url');
5
-
6
- var N=e=>e instanceof URL?url.fileURLToPath(e):e,H=N;var P=e=>e.replaceAll(/\r\n|\r(?!\n)|\n/gu,`
7
- `),R=P,j=globalThis.process||Object.create(null),$={versions:{}},M=new Proxy(j,{get(e,t){if(t in e)return e[t];if(t in $)return $[t]}}),T=M,V=(e,t,o,n)=>{let r={column:0,line:-1,...e.start},s={...r,...e.end},a=r.line,l=r.column,c=s.line,p=s.column,f=Math.max(a-(o+1),0),d=Math.min(t.length,c+n);a===-1&&(f=0),c===-1&&(d=t.length);let h=c-a,m={};if(h)for(let i=0;i<=h;i++){let u=i+a;if(!l)m[u]=!0;else if(i===0){let g=t[u-1]?.length;m[u]=[l,(g??0)-l+1];}else if(i===h)m[u]=[0,p];else {let g=t[u-i]?.length;m[u]=[0,g];}}else l===p?m[a]=l?[l,0]:!0:m[a]=[l,(p??0)-(l??0)];return {end:d,markerLines:m,start:f}},W=V,J=T.platform==="win32"&&!T.env?.WT_SESSION?">":"\u276F",C=(e,t,o)=>{let n={linesAbove:2,linesBelow:3,showGutter:!0,showLineNumbers:!0,tabWidth:4,...o,color:{gutter:i=>i,marker:i=>i,message:i=>i,...o?.color}},r=t.start&&typeof t.start.column=="number",s=R(e).split(`
8
- `);typeof n?.tabWidth=="number"&&(s=s.map(i=>i.replaceAll(" "," ".repeat(n.tabWidth))));let{end:a,markerLines:l,start:c}=W(t,s,n.linesAbove,n.linesBelow),p=String(a).length,{gutter:f,marker:d,message:h}=n.color,m=s.slice(c,a).map((i,u)=>{let g=c+1+u,y=l[g],k=` ${g}`.slice(-p),w=!l[g+1],b=` ${k}${n.showGutter?" |":""}`;if(y){let x="";if(Array.isArray(y)){let E=i.replaceAll(/[^\t]/g," ").slice(0,Math.max(y[0]-1,0)),O=y[1]||1;x=[`
9
- `,f(b.replaceAll(/\d/g," "))," ",E,d("^").repeat(O)].join(""),w&&n.message&&(x+=` ${h(n.message)}`);}return [d(J),f(b),i.length>0?` ${i}`:"",x].join("")}return ` ${f(b)}${i.length>0?` ${i}`:""}`}).join(`
10
- `);return n.message&&!r&&(m=`${" ".repeat(p+1)}${n.message}
11
- ${m}`),m};var v=(e,t)=>{let o=0,n=t.length-2;for(;o<n;){let r=o+(n-o>>1);if(e<t[r])n=r-1;else if(e>=t[r+1])o=r+1;else {o=r;break}}return o},U=e=>e.split(/\n|\r(?!\n)/).reduce((t,o)=>(t.push(t.at(-1)+o.length+1),t),[0]),_=(e,t,o)=>{let n=o?.skipChecks??!1;if(!n&&(!Array.isArray(e)&&typeof e!="string"||(typeof e=="string"||Array.isArray(e))&&e.length===0))return {column:0,line:0};if(!n&&(typeof t!="number"||typeof e=="string"&&t>=e.length||Array.isArray(e)&&t+1>=e.at(-1)))return {column:0,line:0};if(typeof e=="string"){let s=U(e),a=v(t,s);return {column:t-s[a]+1,line:a+1}}let r=v(t,e);return {column:t-e[r]+1,line:r+1}},L=_;var q=e=>`\\u{${e.codePointAt(0).toString(16)}}`,B=(e,t,o)=>C(e,{start:t},{tabWidth:!1,...o}),G=(e,t)=>{let o=/in JSON at position (?<index>\d+)(?: \(line (?<line>\d+) column (?<column>\d+)\))?$/.exec(t);if(!o)return;let{column:n,index:r,line:s}=o.groups;return s&&n?{column:Number(n),line:Number(s)}:(r=Number(r),r===e.length&&(r=e.length-1),L(e,r))},I=e=>e.replace(/(?<=^Unexpected token )(?<quote>')?(.)\k<quote>/,(t,o,n)=>`"${n}"(${q(n)})`);function z(e,t,o,n){typeof t=="string"&&(typeof o=="object"&&(n=o),o=t,t=void 0);let r;try{return JSON.parse(e,t)}catch(l){r=l.message;}let s;e?(s=G(e,r),r=I(r)):r+=" while parsing empty string";let a=new chunkN5NZURYL_cjs.a(r);throw a.fileName=o,s&&(a.codeFrame=B(e,s,n)),a}var oe=z;
12
-
13
- exports.a = H;
14
- exports.b = oe;
15
- //# sourceMappingURL=out.js.map
16
- //# sourceMappingURL=chunk-QHWRBSYR.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/utils/to-path.ts","../../error/src/util/normalize-lf.ts","../../error/src/util/process.ts","../../error/src/code-frame/get-marker-lines.ts","../../error/src/code-frame/index.ts","../src/utils/parse-json.ts"],"names":["fileURLToPath","toPath","urlOrPath","to_path_default","normalizeLF","code","normalize_lf_default","_process","processShims","process","target","property","process_default","getMarkerLines","loc","source","linesAbove","linesBelow","startLoc","endLoc","startLine","startColumn","endLine","endColumn","start","end","lineDiff","markerLines","index","lineNumber","sourceLength","a","u","e","m","o","n","i","f","get_marker_lines_default","$","S","W","M","options","L","config","t","value","hasColumns","g","r","x","s","lines","ln","numberMaxWidth","colorizeGutter","colorizeMarker","colorizeMessage","frame","line","number","hasMarker","paddedNumber","lastMarkerLine","gutter","markerLine","markerSpacing","numberOfMarkers","CODE_FRAME_POINTER","h","k","d","getCodePoint","character","generateCodeFrame","location","q","getErrorLocation","message","match","column","F","addCodePointToUnexpectedToken","_","_quote","token","parseJson","string","reviver","fileName","error","jsonError","json_error_default","parse_json_default"],"mappings":"yCAAA,OAAS,iBAAAA,MAAqB,MAE9B,IAAMC,EAAUC,GAAqCA,aAAqB,IAAMF,EAAcE,CAAS,EAAIA,EAEpGC,EAAQF,ECJf,IAAMG,EAAeC,GAAyBA,EAAK,WAAW,qBAAsB;CAAI,EAEjFC,EAAQF,ECGTG,EAAY,WAAW,SAAW,OAAO,OAAO,IAAI,EAEpDC,EAAiC,CACnC,SAAU,CAAC,CACf,EAEMC,EAAU,IAAI,MAAeF,EAAU,CACzC,IAAIG,EAAQC,EAAyB,CACjC,GAAIA,KAAYD,EAEZ,OAAOA,EAAOC,CAAQ,EAG1B,GAAIA,KAAYH,EAEZ,OAAOA,EAAaG,CAAQ,CAIpC,CACJ,CAAC,EAEMC,EAAQH,ECVTI,EAAiB,CACnBC,EACAC,EACAC,EACAC,IAMC,CACD,IAAMC,EAA8B,CAChC,OAAQ,EAER,KAAM,GACN,GAAGJ,EAAI,KACX,EACMK,EAA4B,CAC9B,GAAGD,EACH,GAAGJ,EAAI,GACX,EACMM,EAAYF,EAAS,KACrBG,EAAcH,EAAS,OACvBI,EAAUH,EAAO,KACjBI,EAAYJ,EAAO,OAErBK,EAAQ,KAAK,IAAIJ,GAAaJ,EAAa,GAAI,CAAC,EAChDS,EAAM,KAAK,IAAIV,EAAO,OAAQO,EAAUL,CAAU,EAElDG,IAAc,KACdI,EAAQ,GAGRF,IAAY,KACZG,EAAMV,EAAO,QAGjB,IAAMW,EAAWJ,EAAUF,EACrBO,EAA2B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,EAEvC,MAAAa,EAAU,SAAWF,EAEjBd,IAEAgB,EAAU,UAAYjB,EAAkBa,EAAQZ,EAAUjC,CAAO,GAG/DiD,CACV,CAEA,IAAOE,GAAQP","sourcesContent":["import { fileURLToPath } from \"node:url\";\n\nconst toPath = (urlOrPath: URL | string): string => (urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath);\n\nexport default toPath;\n","const normalizeLF = (code: string): string => code.replaceAll(/\\r\\n|\\r(?!\\n)|\\n/gu, \"\\n\");\n\nexport default normalizeLF;\n","interface Process extends Partial<Omit<typeof globalThis.process, \"versions\">> {\n versions: Record<string, string>;\n}\n\n// eslint-disable-next-line @typescript-eslint/naming-convention,@typescript-eslint/no-unnecessary-condition,no-underscore-dangle\nconst _process = (globalThis.process || Object.create(null)) as unknown as Process;\n\nconst processShims: Partial<Process> = {\n versions: {},\n};\n\nconst process = new Proxy<Process>(_process, {\n get(target, property: keyof Process) {\n if (property in target) {\n // eslint-disable-next-line security/detect-object-injection\n return target[property];\n }\n\n if (property in processShims) {\n // eslint-disable-next-line security/detect-object-injection\n return processShims[property];\n }\n\n return undefined;\n },\n});\n\nexport default process;\n","// eslint-disable-next-line no-secrets/no-secrets\n/**\n * This is a copy of the codeFrame function from Babel\n * @see https://github.com/babel/babel/blob/85e649203b61b7c908eb04c05511a0d35f893e8e/packages/babel-code-frame/src/index.ts#L68-L143\n *\n * MIT License\n *\n * Copyright (c) 2014-present Sebastian McKenzie and other contributors\n */\n\n/**\n * Extract what lines should be marked and highlighted.\n */\nimport type { CodeFrameLocation, CodeFrameNodeLocation } from \"./types\";\n\ntype MarkerLines = Record<number, true | [number | undefined, number | undefined]>;\n\nconst getMarkerLines = (\n loc: CodeFrameNodeLocation,\n source: string[],\n linesAbove: number,\n linesBelow: number,\n): {\n end: number;\n markerLines: MarkerLines;\n start: number;\n // eslint-disable-next-line sonarjs/cognitive-complexity\n} => {\n const startLoc: CodeFrameLocation = {\n column: 0,\n // @ts-expect-error Can be overwritten\n line: -1,\n ...loc.start,\n };\n const endLoc: CodeFrameLocation = {\n ...startLoc,\n ...loc.end,\n };\n const startLine = startLoc.line;\n const startColumn = startLoc.column;\n const endLine = endLoc.line;\n const endColumn = endLoc.column;\n\n let start = Math.max(startLine - (linesAbove + 1), 0);\n let end = Math.min(source.length, endLine + linesBelow);\n\n if (startLine === -1) {\n start = 0;\n }\n\n if (endLine === -1) {\n end = source.length;\n }\n\n const lineDiff = endLine - startLine;\n const markerLines: MarkerLines = {};\n\n if (lineDiff) {\n // eslint-disable-next-line no-plusplus,no-loops/no-loops\n for (let index = 0; index <= lineDiff; index++) {\n const lineNumber = index + startLine;\n\n if (!startColumn) {\n // eslint-disable-next-line security/detect-object-injection\n markerLines[lineNumber] = true;\n } else if (index === 0) {\n const sourceLength = source[lineNumber - 1]?.length;\n\n // eslint-disable-next-line security/detect-object-injection\n markerLines[lineNumber] = [startColumn, (sourceLength ?? 0) - startColumn + 1];\n } else if (index === lineDiff) {\n // eslint-disable-next-line security/detect-object-injection\n markerLines[lineNumber] = [0, endColumn];\n } else {\n const sourceLength = source[lineNumber - index]?.length;\n\n // eslint-disable-next-line security/detect-object-injection\n markerLines[lineNumber] = [0, sourceLength];\n }\n }\n } else if (startColumn === endColumn) {\n // eslint-disable-next-line security/detect-object-injection\n markerLines[startLine] = startColumn ? [startColumn, 0] : true;\n } else {\n // eslint-disable-next-line security/detect-object-injection\n markerLines[startLine] = [startColumn, (endColumn ?? 0) - (startColumn ?? 0)];\n }\n\n return { end, markerLines, start };\n};\n\nexport default getMarkerLines;\n","// eslint-disable-next-line no-secrets/no-secrets\n/**\n * This is a modified copy of the codeFrameColumns function from Babel\n * @see https://github.com/babel/babel/blob/85e649203b61b7c908eb04c05511a0d35f893e8e/packages/babel-code-frame/src/index.ts#L145-L217\n *\n * MIT License\n *\n * Copyright (c) 2014-present Sebastian McKenzie and other contributors\n */\n\nimport normalizeLF from \"../util/normalize-lf\";\nimport process from \"../util/process\";\nimport getMarkerLines from \"./get-marker-lines\";\nimport type { CodeFrameNodeLocation, CodeFrameOptions } from \"./types\";\n\nexport const CODE_FRAME_POINTER = process.platform === \"win32\" && !process.env?.[\"WT_SESSION\"] ? \">\" : \"❯\";\n\n/** Generate a code frame from string and an error location */\nexport const codeFrame = (\n source: string,\n loc: CodeFrameNodeLocation,\n options?: CodeFrameOptions,\n // eslint-disable-next-line sonarjs/cognitive-complexity\n): string => {\n // grab 2 lines before, and 3 lines after focused line\n const config = {\n linesAbove: 2,\n linesBelow: 3,\n showGutter: true,\n showLineNumbers: true,\n tabWidth: 4,\n ...options,\n color: {\n gutter: (value: string) => value,\n marker: (value: string) => value,\n message: (value: string) => value,\n ...options?.color,\n },\n };\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n const hasColumns = loc.start && typeof loc.start.column === \"number\";\n\n let lines = normalizeLF(source).split(\"\\n\");\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (typeof config?.tabWidth === \"number\") {\n lines = lines.map((ln) => ln.replaceAll(\"\\t\", \" \".repeat(config.tabWidth as number)));\n }\n\n const { end, markerLines, start } = getMarkerLines(loc, lines, config.linesAbove, config.linesBelow);\n\n const numberMaxWidth = String(end).length;\n const { gutter: colorizeGutter, marker: colorizeMarker, message: colorizeMessage } = config.color;\n\n let frame = lines\n .slice(start, end)\n .map((line, index) => {\n const number = start + 1 + index;\n // eslint-disable-next-line security/detect-object-injection\n const hasMarker = markerLines[number];\n const paddedNumber = ` ${number}`.slice(-numberMaxWidth);\n const lastMarkerLine = !markerLines[number + 1];\n\n const gutter = ` ${paddedNumber}${config.showGutter ? ` |` : \"\"}`;\n\n if (hasMarker) {\n let markerLine = \"\";\n\n if (Array.isArray(hasMarker)) {\n const markerSpacing = line.replaceAll(/[^\\t]/g, \" \").slice(0, Math.max((hasMarker[0] as number) - 1, 0));\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n const numberOfMarkers = hasMarker[1] || 1;\n\n markerLine = [\"\\n \", colorizeGutter(gutter.replaceAll(/\\d/g, \" \")), \" \", markerSpacing, colorizeMarker(\"^\").repeat(numberOfMarkers)].join(\n \"\",\n );\n\n if (lastMarkerLine && config.message) {\n markerLine += ` ${colorizeMessage(config.message)}`;\n }\n }\n\n return [colorizeMarker(CODE_FRAME_POINTER), colorizeGutter(gutter), line.length > 0 ? ` ${line}` : \"\", markerLine].join(\"\");\n }\n\n return ` ${colorizeGutter(gutter)}${line.length > 0 ? ` ${line}` : \"\"}`;\n })\n .join(\"\\n\");\n\n if (config.message && !hasColumns) {\n frame = `${\" \".repeat(numberMaxWidth + 1)}${config.message}\\n${frame}`;\n }\n\n return frame;\n};\n\nexport type { CodeFrameLocation, CodeFrameNodeLocation, CodeFrameOptions, ColorizeMethod } from \"./types\";\n","/**\n * A modified version of `parse-json` from `https://github.com/sindresorhus/parse-json/blob/main/index.js`\n *\n * MIT License\n * Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)\n */\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport { codeFrame, indexToLineColumn } from \"@visulima/error\";\nimport type { JsonValue } from \"type-fest\";\n\nimport JsonError from \"../error/json-error\";\nimport type { CodeFrameLocation, CodeFrameOptions, JsonReviver } from \"../types\";\n\nconst getCodePoint = (character: string): string => `\\\\u{${(character.codePointAt(0) as number).toString(16)}}`;\n\nconst generateCodeFrame = (source: string, location: CodeFrameLocation, options?: CodeFrameOptions) =>\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-return\n codeFrame(\n source,\n { start: location },\n {\n tabWidth: false,\n ...options,\n },\n );\n\nconst getErrorLocation = (source: string, message: string): CodeFrameLocation | undefined => {\n // eslint-disable-next-line security/detect-unsafe-regex\n const match = /in JSON at position (?<index>\\d+)(?: \\(line (?<line>\\d+) column (?<column>\\d+)\\))?$/.exec(message);\n\n if (!match) {\n return undefined;\n }\n\n // eslint-disable-next-line prefer-const\n let { column, index, line } = match.groups as { column?: string; index: number | string; line?: string };\n\n if (line && column) {\n return { column: Number(column), line: Number(line) };\n }\n\n index = Number(index);\n\n // The error location can be out of bounds.\n if (index === source.length) {\n index = source.length - 1;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-return\n return indexToLineColumn(source, index);\n};\n\nconst addCodePointToUnexpectedToken = (message: string): string =>\n message.replace(\n // TODO[engine:node@>=20]: The token always quoted after Node.js 20\n // eslint-disable-next-line regexp/no-potentially-useless-backreference\n /(?<=^Unexpected token )(?<quote>')?(.)\\k<quote>/,\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n (_, _quote, token) => `\"${token}\"(${getCodePoint(token)})`,\n );\n\nfunction parseJson<T = JsonValue>(string: string, filename?: string, options?: CodeFrameOptions): T;\nfunction parseJson<T = JsonValue>(string: string, reviver: JsonReviver, fileName?: string, options?: CodeFrameOptions): T;\n// eslint-disable-next-line func-style\nfunction parseJson<T = JsonValue>(string: string, reviver?: JsonReviver | string, fileName?: CodeFrameOptions | string, options?: CodeFrameOptions): T {\n if (typeof reviver === \"string\") {\n if (typeof fileName === \"object\") {\n // eslint-disable-next-line no-param-reassign\n options = fileName;\n }\n\n // eslint-disable-next-line no-param-reassign\n fileName = reviver;\n // eslint-disable-next-line no-param-reassign\n reviver = undefined;\n }\n\n let message: string;\n\n try {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return JSON.parse(string, reviver);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access\n message = error.message;\n }\n\n let location: CodeFrameLocation | undefined;\n\n if (string) {\n location = getErrorLocation(string, message);\n message = addCodePointToUnexpectedToken(message);\n } else {\n message += \" while parsing empty string\";\n }\n\n const jsonError = new JsonError(message);\n\n jsonError.fileName = fileName as string;\n\n if (location) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n jsonError.codeFrame = generateCodeFrame(string, location, options);\n }\n\n throw jsonError;\n}\n\nexport default parseJson;\n"]}