@visulima/error 3.1.2 → 3.2.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 +15 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/package.json +26 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
## @visulima/error [3.2.1](https://github.com/visulima/visulima/compare/@visulima/error@3.2.0...@visulima/error@3.2.1) (2024-03-16)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Dependencies
|
|
6
|
+
|
|
7
|
+
* **@visulima/nextra-theme-docs:** upgraded to 4.0.18
|
|
8
|
+
|
|
9
|
+
## @visulima/error [3.2.0](https://github.com/visulima/visulima/compare/@visulima/error@3.1.2...@visulima/error@3.2.0) (2024-03-11)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
* added new index-to-line-column function ([c794be0](https://github.com/visulima/visulima/commit/c794be0867eae45ce66096bd15691d7437545a5d))
|
|
15
|
+
|
|
1
16
|
## @visulima/error [3.1.2](https://github.com/visulima/visulima/compare/@visulima/error@3.1.1...@visulima/error@3.1.2) (2024-03-10)
|
|
2
17
|
|
|
3
18
|
|
package/dist/index.d.ts
CHANGED
|
@@ -3,3 +3,12 @@ export { ErrorHint, ErrorLocation, ErrorProperties, VisulimaError, getErrorCause
|
|
|
3
3
|
export { loadSourceMap } from './sourcemap/index.js';
|
|
4
4
|
export { TraceMap, generatedPositionFor, originalPositionFor, sourceContentFor, traceSegment } from '@jridgewell/trace-mapping';
|
|
5
5
|
export { Trace, TraceType, parseStacktrace } from './stacktrace/index.js';
|
|
6
|
+
|
|
7
|
+
declare const indexToLineColumn: (input: number[] | string, index: number, options?: {
|
|
8
|
+
skipChecks: boolean;
|
|
9
|
+
}) => {
|
|
10
|
+
column: number;
|
|
11
|
+
line: number;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { indexToLineColumn };
|
package/dist/index.js
CHANGED
|
@@ -2,5 +2,9 @@ export { a as CODE_FRAME_POINTER, b as codeFrame } from './chunk-CCMH6IHO.js';
|
|
|
2
2
|
export { c as VisulimaError, a as getErrorCauses, b as isVisulimaError } from './chunk-HAVTTG7L.js';
|
|
3
3
|
export { b as generatedPositionFor, a as loadSourceMap, c as originalPositionFor, d as sourceContentFor, e as traceSegment } from './chunk-7G4U7I4C.js';
|
|
4
4
|
export { a as parseStacktrace } from './chunk-57YC2IM6.js';
|
|
5
|
+
|
|
6
|
+
var m=(r,e)=>{let o=0,t=e.length-2;for(;o<t;){let n=o+(t-o>>1);if(r<e[n])t=n-1;else if(r>=e[n+1])o=n+1;else {o=n;break}}return o},E=r=>r.split(/\n|\r(?!\n)/).reduce((e,o)=>(e.push(e.at(-1)+o.length+1),e),[0]),x=(r,e,o)=>{let t=o?.skipChecks??!1;if(!t&&(!Array.isArray(r)&&typeof r!="string"||(typeof r=="string"||Array.isArray(r))&&r.length===0))return {column:0,line:0};if(!t&&(typeof e!="number"||typeof r=="string"&&e>=r.length||Array.isArray(r)&&e+1>=r.at(-1)))return {column:0,line:0};if(typeof r=="string"){let s=E(r),a=m(e,s);return {column:e-s[a]+1,line:a+1}}let n=m(e,r);return {column:e-r[n]+1,line:n+1}},F=x;
|
|
7
|
+
|
|
8
|
+
export { F as indexToLineColumn };
|
|
5
9
|
//# sourceMappingURL=out.js.map
|
|
6
10
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"sources":["../src/code-frame/index-to-line-column.ts"],"names":["binarySearch","element","array","m","n","key","getLineStartIndexes","string_","accumulator","current","indexToLineColumn","input","index","options","skipChecks","startIndexesOfEachLine","line","index_to_line_column_default"],"mappings":"iNAAA,IAAMA,EAAe,CAACC,EAAi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arySearch = (element: number, array: number[]): number => {\n let m = 0;\n let n = array.length - 2;\n\n // eslint-disable-next-line no-loops/no-loops\n while (m < n) {\n // eslint-disable-next-line no-bitwise\n const key = m + ((n - m) >> 1);\n // eslint-disable-next-line security/detect-object-injection\n if (element < (array[key] as number)) {\n n = key - 1;\n } else if (element >= (array[key + 1] as number)) {\n m = key + 1;\n } else {\n m = key;\n break;\n }\n }\n\n return m;\n};\n\n// split by line break characters, CR, LF or CRLF\n// compile an array of indexes, where each line starts\nconst getLineStartIndexes = (string_: string): number[] =>\n // eslint-disable-next-line unicorn/no-array-reduce\n string_.split(/\\n|\\r(?!\\n)/).reduce(\n (accumulator: number[], current) => {\n accumulator.push((accumulator.at(-1) as number) + current.length + 1);\n\n return accumulator;\n },\n [0],\n );\n\nconst indexToLineColumn = (\n input: number[] | string,\n index: number,\n options?: {\n skipChecks: boolean;\n },\n): {\n column: number;\n line: number;\n} => {\n const skipChecks = options?.skipChecks ?? false;\n\n if (!skipChecks && ((!Array.isArray(input) && typeof input !== \"string\") || ((typeof input === \"string\" || Array.isArray(input)) && input.length === 0))) {\n return { column: 0, line: 0 };\n }\n\n if (\n !skipChecks &&\n (typeof index !== \"number\" || (typeof input === \"string\" && index >= input.length) || (Array.isArray(input) && index + 1 >= (input.at(-1) as number)))\n ) {\n return { column: 0, line: 0 };\n }\n\n // it depends, pre-cached input was given or a string\n if (typeof input === \"string\") {\n // not cached - calculate the line start indexes\n const startIndexesOfEachLine = getLineStartIndexes(input);\n const line = binarySearch(index, startIndexesOfEachLine);\n\n return {\n // eslint-disable-next-line security/detect-object-injection\n column: index - (startIndexesOfEachLine[line] as number) + 1,\n line: line + 1,\n };\n }\n\n // ELSE - cached line start indexes - we don't even need the string source!\n const line = binarySearch(index, input);\n\n return {\n // eslint-disable-next-line security/detect-object-injection\n column: index - (input[line] as number) + 1,\n line: line + 1,\n };\n};\n\nexport default indexToLineColumn;\n"]}
|
package/package.json
CHANGED
|
@@ -1,21 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visulima/error",
|
|
3
|
-
"version": "3.1
|
|
3
|
+
"version": "3.2.1",
|
|
4
4
|
"description": "Error with more than just a message, stacktrace parsing and sourcemap loading.",
|
|
5
5
|
"keywords": [
|
|
6
|
-
"visulima",
|
|
7
6
|
"anolilab",
|
|
8
|
-
"
|
|
9
|
-
"exception",
|
|
7
|
+
"character",
|
|
10
8
|
"code-frame",
|
|
11
9
|
"codeframe",
|
|
10
|
+
"column number",
|
|
11
|
+
"column",
|
|
12
|
+
"coordinate",
|
|
13
|
+
"error",
|
|
14
|
+
"exception",
|
|
15
|
+
"index",
|
|
16
|
+
"line number",
|
|
17
|
+
"line",
|
|
18
|
+
"location",
|
|
19
|
+
"parser",
|
|
20
|
+
"position",
|
|
21
|
+
"source-map",
|
|
12
22
|
"stack",
|
|
13
|
-
"stacktrace",
|
|
14
23
|
"stack-trace",
|
|
24
|
+
"stacktrace",
|
|
25
|
+
"string",
|
|
26
|
+
"text",
|
|
15
27
|
"trace",
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"v8"
|
|
28
|
+
"v8",
|
|
29
|
+
"visulima"
|
|
19
30
|
],
|
|
20
31
|
"homepage": "https://www.visulima.com/docs/package/error",
|
|
21
32
|
"repository": {
|
|
@@ -113,23 +124,23 @@
|
|
|
113
124
|
"@total-typescript/ts-reset": "^0.5.1",
|
|
114
125
|
"@types/command-line-args": "^5.2.3",
|
|
115
126
|
"@types/node": "18.18.14",
|
|
116
|
-
"@visulima/nextra-theme-docs": "4.0.
|
|
117
|
-
"@vitest/coverage-v8": "^1.
|
|
118
|
-
"@vitest/ui": "^1.
|
|
127
|
+
"@visulima/nextra-theme-docs": "4.0.18",
|
|
128
|
+
"@vitest/coverage-v8": "^1.4.0",
|
|
129
|
+
"@vitest/ui": "^1.4.0",
|
|
119
130
|
"cross-env": "^7.0.3",
|
|
120
131
|
"eslint": "^8.57.0",
|
|
121
132
|
"eslint-plugin-deprecation": "^2.0.0",
|
|
122
133
|
"eslint-plugin-import": "npm:eslint-plugin-i@^2.29.1",
|
|
123
134
|
"eslint-plugin-mdx": "^3.1.5",
|
|
124
|
-
"eslint-plugin-vitest": "^0.3.
|
|
125
|
-
"eslint-plugin-vitest-globals": "^1.
|
|
135
|
+
"eslint-plugin-vitest": "^0.3.26",
|
|
136
|
+
"eslint-plugin-vitest-globals": "^1.5.0",
|
|
126
137
|
"prettier": "^3.2.5",
|
|
127
138
|
"rimraf": "^5.0.5",
|
|
128
|
-
"semantic-release": "^23.0.
|
|
139
|
+
"semantic-release": "^23.0.4",
|
|
129
140
|
"sort-package-json": "^2.8.0",
|
|
130
141
|
"tsup": "^8.0.2",
|
|
131
142
|
"typescript": "^5.4.2",
|
|
132
|
-
"vitest": "^1.
|
|
143
|
+
"vitest": "^1.4.0"
|
|
133
144
|
},
|
|
134
145
|
"engines": {
|
|
135
146
|
"node": ">=18.* <=21.*"
|