@visulima/fs 2.1.6 → 2.1.7
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/LICENSE.md +67 -0
- package/dist/error.cjs +1 -37
- package/dist/error.d.cts +1 -1
- package/dist/error.d.mts +50 -0
- package/dist/error.d.ts +1 -1
- package/dist/error.mjs +1 -0
- package/dist/index.cjs +7 -65
- package/dist/index.d.cts +2 -3
- package/dist/index.d.mts +90 -0
- package/dist/index.d.ts +2 -3
- package/dist/index.mjs +9 -0
- package/dist/shared/fs.BLXmkvbT.cjs +4 -0
- package/dist/shared/fs.BMHe7vX1.mjs +1 -0
- package/dist/shared/fs.BMslWC0T.cjs +6 -0
- package/dist/shared/fs.BRjynomN.mjs +6 -0
- package/dist/shared/fs.BXbumRuI.mjs +4 -0
- package/dist/shared/fs.CjglVHda.cjs +1 -0
- package/dist/{types-CtYA064B.d.cts → shared/fs.CpT5ICZl.d.cts} +40 -1
- package/dist/{types-CtYA064B.d.ts → shared/fs.CpT5ICZl.d.mts} +40 -1
- package/dist/shared/fs.CpT5ICZl.d.ts +120 -0
- package/dist/shared/fs.ZPgZIXcg.d.ts +11 -0
- package/dist/utils.cjs +1 -31
- package/dist/utils.d.cts +2 -3
- package/dist/utils.d.mts +18 -0
- package/dist/utils.d.ts +2 -3
- package/dist/utils.mjs +1 -0
- package/package.json +14 -13
- package/dist/chunk-BZXQ545V.cjs +0 -12
- package/dist/chunk-BZXQ545V.cjs.map +0 -1
- package/dist/chunk-ELTI4L4F.js +0 -12
- package/dist/chunk-ELTI4L4F.js.map +0 -1
- package/dist/chunk-N5NZURYL.cjs +0 -10
- package/dist/chunk-N5NZURYL.cjs.map +0 -1
- package/dist/chunk-NEXEUEQV.cjs +0 -16
- package/dist/chunk-NEXEUEQV.cjs.map +0 -1
- package/dist/chunk-P3KZLWQC.js +0 -5
- package/dist/chunk-P3KZLWQC.js.map +0 -1
- package/dist/chunk-UPN3Y5W3.js +0 -8
- package/dist/chunk-UPN3Y5W3.js.map +0 -1
- package/dist/error.cjs.map +0 -1
- package/dist/error.js +0 -4
- package/dist/error.js.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js +0 -24
- package/dist/index.js.map +0 -1
- package/dist/utils.cjs.map +0 -1
- package/dist/utils.js +0 -9
- package/dist/utils.js.map +0 -1
- /package/dist/{json-error-ZPgZIXcg.d.cts → shared/fs.ZPgZIXcg.d.cts} +0 -0
- /package/dist/{json-error-ZPgZIXcg.d.ts → shared/fs.ZPgZIXcg.d.mts} +0 -0
|
@@ -78,4 +78,43 @@ type EmptyDirOptions = {
|
|
|
78
78
|
type ReadYamlOptions<C> = DocumentOptions & ParseOptions & ReadFileOptions<C> & SchemaOptions & ToJSOptions;
|
|
79
79
|
type YamlReviver = (key: unknown, value: unknown) => unknown;
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
/**
|
|
82
|
+
Matches a JSON object.
|
|
83
|
+
|
|
84
|
+
This type can be useful to enforce some input to be JSON-compatible or as a super-type to be extended from. Don't use this as a direct return type as the user would have to double-cast it: `jsonObject as unknown as CustomResponse`. Instead, you could extend your CustomResponse type from it to ensure your type only uses JSON-compatible types: `interface CustomResponse extends JsonObject { … }`.
|
|
85
|
+
|
|
86
|
+
@category JSON
|
|
87
|
+
*/
|
|
88
|
+
type JsonObject = {[Key in string]: JsonValue} & {[Key in string]?: JsonValue | undefined};
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
Matches a JSON array.
|
|
92
|
+
|
|
93
|
+
@category JSON
|
|
94
|
+
*/
|
|
95
|
+
type JsonArray = JsonValue[] | readonly JsonValue[];
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
Matches any valid JSON primitive value.
|
|
99
|
+
|
|
100
|
+
@category JSON
|
|
101
|
+
*/
|
|
102
|
+
type JsonPrimitive = string | number | boolean | null;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
Matches any valid JSON value.
|
|
106
|
+
|
|
107
|
+
@see `Jsonify` if you need to transform a type to one that is assignable to `JsonValue`.
|
|
108
|
+
|
|
109
|
+
@category JSON
|
|
110
|
+
*/
|
|
111
|
+
type JsonValue = JsonPrimitive | JsonObject | JsonArray;
|
|
112
|
+
|
|
113
|
+
declare global {
|
|
114
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
|
|
115
|
+
interface SymbolConstructor {
|
|
116
|
+
readonly observable: symbol;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export { type ContentType as C, type EmptyDirOptions as E, type FindUpOptions as F, type JsonValue as J, type Match as M, type ReadFileOptions as R, type WalkOptions as W, X_OK as X, type YamlReviver as Y, type WalkEntry as a, type ReadJsonOptions as b, type JsonReviver as c, type ReadYamlOptions as d, type WriteFileOptions as e, type WriteJsonOptions as f, type YamlReplacer as g, F_OK as h, FIND_UP_STOP as i, R_OK as j, W_OK as k, type CodeFrameLocation as l, type JsonReplacer as m, type ReadFileEncoding as n, type CodeFrameOptions as o };
|
|
@@ -78,4 +78,43 @@ type EmptyDirOptions = {
|
|
|
78
78
|
type ReadYamlOptions<C> = DocumentOptions & ParseOptions & ReadFileOptions<C> & SchemaOptions & ToJSOptions;
|
|
79
79
|
type YamlReviver = (key: unknown, value: unknown) => unknown;
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
/**
|
|
82
|
+
Matches a JSON object.
|
|
83
|
+
|
|
84
|
+
This type can be useful to enforce some input to be JSON-compatible or as a super-type to be extended from. Don't use this as a direct return type as the user would have to double-cast it: `jsonObject as unknown as CustomResponse`. Instead, you could extend your CustomResponse type from it to ensure your type only uses JSON-compatible types: `interface CustomResponse extends JsonObject { … }`.
|
|
85
|
+
|
|
86
|
+
@category JSON
|
|
87
|
+
*/
|
|
88
|
+
type JsonObject = {[Key in string]: JsonValue} & {[Key in string]?: JsonValue | undefined};
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
Matches a JSON array.
|
|
92
|
+
|
|
93
|
+
@category JSON
|
|
94
|
+
*/
|
|
95
|
+
type JsonArray = JsonValue[] | readonly JsonValue[];
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
Matches any valid JSON primitive value.
|
|
99
|
+
|
|
100
|
+
@category JSON
|
|
101
|
+
*/
|
|
102
|
+
type JsonPrimitive = string | number | boolean | null;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
Matches any valid JSON value.
|
|
106
|
+
|
|
107
|
+
@see `Jsonify` if you need to transform a type to one that is assignable to `JsonValue`.
|
|
108
|
+
|
|
109
|
+
@category JSON
|
|
110
|
+
*/
|
|
111
|
+
type JsonValue = JsonPrimitive | JsonObject | JsonArray;
|
|
112
|
+
|
|
113
|
+
declare global {
|
|
114
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
|
|
115
|
+
interface SymbolConstructor {
|
|
116
|
+
readonly observable: symbol;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export { type ContentType as C, type EmptyDirOptions as E, type FindUpOptions as F, type JsonValue as J, type Match as M, type ReadFileOptions as R, type WalkOptions as W, X_OK as X, type YamlReviver as Y, type WalkEntry as a, type ReadJsonOptions as b, type JsonReviver as c, type ReadYamlOptions as d, type WriteFileOptions as e, type WriteJsonOptions as f, type YamlReplacer as g, F_OK as h, FIND_UP_STOP as i, R_OK as j, W_OK as k, type CodeFrameLocation as l, type JsonReplacer as m, type ReadFileEncoding as n, type CodeFrameOptions as o };
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { Dirent } from 'node:fs';
|
|
2
|
+
import { DocumentOptions, ParseOptions, SchemaOptions, ToJSOptions } from 'yaml';
|
|
3
|
+
|
|
4
|
+
declare const F_OK = 0;
|
|
5
|
+
declare const R_OK = 4;
|
|
6
|
+
declare const W_OK = 2;
|
|
7
|
+
declare const X_OK = 1;
|
|
8
|
+
declare const FIND_UP_STOP: unique symbol;
|
|
9
|
+
|
|
10
|
+
type ColorizeMethod = (value: string) => string;
|
|
11
|
+
interface WalkOptions {
|
|
12
|
+
extensions?: string[];
|
|
13
|
+
followSymlinks?: boolean;
|
|
14
|
+
includeDirs?: boolean;
|
|
15
|
+
includeFiles?: boolean;
|
|
16
|
+
includeSymlinks?: boolean;
|
|
17
|
+
match?: (RegExp | string)[];
|
|
18
|
+
maxDepth?: number;
|
|
19
|
+
skip?: (RegExp | string)[];
|
|
20
|
+
}
|
|
21
|
+
interface WalkEntry extends Pick<Dirent, "isDirectory" | "isFile" | "isSymbolicLink" | "name"> {
|
|
22
|
+
path: string;
|
|
23
|
+
}
|
|
24
|
+
type ReadFileEncoding = "ascii" | "base64" | "base64url" | "hex" | "latin1" | "ucs-2" | "ucs2" | "utf-8" | "utf-16le" | "utf8" | "utf16le";
|
|
25
|
+
type ReadFileOptions<C> = {
|
|
26
|
+
buffer?: boolean;
|
|
27
|
+
compression?: C;
|
|
28
|
+
encoding?: ReadFileEncoding | undefined;
|
|
29
|
+
flag?: number | string | undefined;
|
|
30
|
+
};
|
|
31
|
+
type ContentType<O = undefined> = O extends {
|
|
32
|
+
buffer: true;
|
|
33
|
+
} ? Buffer : string;
|
|
34
|
+
type JsonReviver = Parameters<(typeof JSON)["parse"]>["1"];
|
|
35
|
+
type CodeFrameLocation = {
|
|
36
|
+
column?: number;
|
|
37
|
+
line: number;
|
|
38
|
+
};
|
|
39
|
+
type CodeFrameOptions = {
|
|
40
|
+
color?: {
|
|
41
|
+
gutter?: ColorizeMethod;
|
|
42
|
+
marker?: ColorizeMethod;
|
|
43
|
+
message?: ColorizeMethod;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
type ReadJsonOptions = CodeFrameOptions & {
|
|
47
|
+
beforeParse?: (source: string) => string;
|
|
48
|
+
};
|
|
49
|
+
type WriteFileOptions = {
|
|
50
|
+
chown?: {
|
|
51
|
+
gid: number;
|
|
52
|
+
uid: number;
|
|
53
|
+
};
|
|
54
|
+
encoding?: BufferEncoding | null | undefined;
|
|
55
|
+
flag?: string | undefined;
|
|
56
|
+
mode?: number;
|
|
57
|
+
overwrite?: boolean;
|
|
58
|
+
recursive?: boolean;
|
|
59
|
+
};
|
|
60
|
+
type JsonReplacer = (number | string)[] | ((this: unknown, key: string, value: unknown) => unknown) | null;
|
|
61
|
+
type YamlReplacer = JsonReplacer;
|
|
62
|
+
type WriteJsonOptions = WriteFileOptions & {
|
|
63
|
+
detectIndent?: boolean;
|
|
64
|
+
indent?: number | string | undefined;
|
|
65
|
+
replacer?: JsonReplacer;
|
|
66
|
+
stringify?: (data: unknown, replacer: JsonReplacer, space: number | string | undefined) => string;
|
|
67
|
+
};
|
|
68
|
+
type FindUpOptions = {
|
|
69
|
+
cwd?: URL | string;
|
|
70
|
+
stopAt?: URL | string;
|
|
71
|
+
type?: "directory" | "file";
|
|
72
|
+
};
|
|
73
|
+
type Match = string | typeof FIND_UP_STOP | undefined;
|
|
74
|
+
type EmptyDirOptions = {
|
|
75
|
+
maxRetries?: number | undefined;
|
|
76
|
+
retryDelay?: number | undefined;
|
|
77
|
+
};
|
|
78
|
+
type ReadYamlOptions<C> = DocumentOptions & ParseOptions & ReadFileOptions<C> & SchemaOptions & ToJSOptions;
|
|
79
|
+
type YamlReviver = (key: unknown, value: unknown) => unknown;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
Matches a JSON object.
|
|
83
|
+
|
|
84
|
+
This type can be useful to enforce some input to be JSON-compatible or as a super-type to be extended from. Don't use this as a direct return type as the user would have to double-cast it: `jsonObject as unknown as CustomResponse`. Instead, you could extend your CustomResponse type from it to ensure your type only uses JSON-compatible types: `interface CustomResponse extends JsonObject { … }`.
|
|
85
|
+
|
|
86
|
+
@category JSON
|
|
87
|
+
*/
|
|
88
|
+
type JsonObject = {[Key in string]: JsonValue} & {[Key in string]?: JsonValue | undefined};
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
Matches a JSON array.
|
|
92
|
+
|
|
93
|
+
@category JSON
|
|
94
|
+
*/
|
|
95
|
+
type JsonArray = JsonValue[] | readonly JsonValue[];
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
Matches any valid JSON primitive value.
|
|
99
|
+
|
|
100
|
+
@category JSON
|
|
101
|
+
*/
|
|
102
|
+
type JsonPrimitive = string | number | boolean | null;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
Matches any valid JSON value.
|
|
106
|
+
|
|
107
|
+
@see `Jsonify` if you need to transform a type to one that is assignable to `JsonValue`.
|
|
108
|
+
|
|
109
|
+
@category JSON
|
|
110
|
+
*/
|
|
111
|
+
type JsonValue = JsonPrimitive | JsonObject | JsonArray;
|
|
112
|
+
|
|
113
|
+
declare global {
|
|
114
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
|
|
115
|
+
interface SymbolConstructor {
|
|
116
|
+
readonly observable: symbol;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export { type ContentType as C, type EmptyDirOptions as E, type FindUpOptions as F, type JsonValue as J, type Match as M, type ReadFileOptions as R, type WalkOptions as W, X_OK as X, type YamlReviver as Y, type WalkEntry as a, type ReadJsonOptions as b, type JsonReviver as c, type ReadYamlOptions as d, type WriteFileOptions as e, type WriteJsonOptions as f, type YamlReplacer as g, F_OK as h, FIND_UP_STOP as i, R_OK as j, W_OK as k, type CodeFrameLocation as l, type JsonReplacer as m, type ReadFileEncoding as n, type CodeFrameOptions as o };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
declare class JSONError extends Error {
|
|
2
|
+
#private;
|
|
3
|
+
fileName: string | undefined;
|
|
4
|
+
codeFrame: string | undefined;
|
|
5
|
+
readonly name = "JSONError";
|
|
6
|
+
constructor(message: string);
|
|
7
|
+
get message(): string;
|
|
8
|
+
set message(message: string);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { JSONError as J };
|
package/dist/utils.cjs
CHANGED
|
@@ -1,31 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var chunkNEXEUEQV_cjs = require('./chunk-NEXEUEQV.cjs');
|
|
4
|
-
var chunkN5NZURYL_cjs = require('./chunk-N5NZURYL.cjs');
|
|
5
|
-
var utils = require('@visulima/path/utils');
|
|
6
|
-
|
|
7
|
-
var f=(t,{whitespace:e=!0}={})=>t.replace(p,r=>r.startsWith('"')||r[1]==="*"&&!r.endsWith("*/")?r:e?r.replaceAll(/\S/g," "):""),p=/"(?:[^"\\]|\\.)*"?|\/\/[^\r\n]*|\/\*(?:[^*]|\*[^/])*(?:\*\/)?/g,i=f;
|
|
8
|
-
|
|
9
|
-
Object.defineProperty(exports, "assertValidFileContents", {
|
|
10
|
-
enumerable: true,
|
|
11
|
-
get: function () { return chunkNEXEUEQV_cjs.c; }
|
|
12
|
-
});
|
|
13
|
-
Object.defineProperty(exports, "assertValidFileOrDirectoryPath", {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
get: function () { return chunkNEXEUEQV_cjs.a; }
|
|
16
|
-
});
|
|
17
|
-
Object.defineProperty(exports, "parseJson", {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
get: function () { return chunkNEXEUEQV_cjs.b; }
|
|
20
|
-
});
|
|
21
|
-
Object.defineProperty(exports, "JSONError", {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
get: function () { return chunkN5NZURYL_cjs.a; }
|
|
24
|
-
});
|
|
25
|
-
Object.defineProperty(exports, "toPath", {
|
|
26
|
-
enumerable: true,
|
|
27
|
-
get: function () { return utils.toPath; }
|
|
28
|
-
});
|
|
29
|
-
exports.stripJsonComments = i;
|
|
30
|
-
//# sourceMappingURL=out.js.map
|
|
31
|
-
//# sourceMappingURL=utils.cjs.map
|
|
1
|
+
"use strict";var n=Object.defineProperty;var o=(e,t)=>n(e,"name",{value:t,configurable:!0});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./shared/fs.BLXmkvbT.cjs"),r=require("./shared/fs.BMslWC0T.cjs"),a=require("@visulima/path/utils");var l=Object.defineProperty,c=o((e,t)=>l(e,"name",{value:t,configurable:!0}),"n");const u=c((e,{whitespace:t=!0}={})=>e.replace(p,s=>s.startsWith('"')||s[1]==="*"&&!s.endsWith("*/")?s:t?s.replaceAll(/\S/g," "):""),"stripJsonComments"),p=/"(?:[^"\\]|\\.)*"?|\/\/[^\r\n]*|\/\*(?:[^*]|\*[^/])*(?:\*\/)?/g,d=u;exports.JSONError=i.c;exports.assertValidFileContents=r.v;exports.assertValidFileOrDirectoryPath=r.s;exports.parseJson=r.F;exports.toPath=a.toPath;exports.stripJsonComments=d;
|
package/dist/utils.d.cts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export { J as JSONError } from './
|
|
2
|
-
import { JsonValue } from '
|
|
3
|
-
import { n as CodeFrameOptions, J as JsonReviver } from './types-CtYA064B.cjs';
|
|
1
|
+
export { J as JSONError } from './shared/fs.ZPgZIXcg.cjs';
|
|
2
|
+
import { J as JsonValue, o as CodeFrameOptions, c as JsonReviver } from './shared/fs.CpT5ICZl.cjs';
|
|
4
3
|
export { toPath } from '@visulima/path/utils';
|
|
5
4
|
import 'node:fs';
|
|
6
5
|
import 'yaml';
|
package/dist/utils.d.mts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export { J as JSONError } from './shared/fs.ZPgZIXcg.mjs';
|
|
2
|
+
import { J as JsonValue, o as CodeFrameOptions, c as JsonReviver } from './shared/fs.CpT5ICZl.mjs';
|
|
3
|
+
export { toPath } from '@visulima/path/utils';
|
|
4
|
+
import 'node:fs';
|
|
5
|
+
import 'yaml';
|
|
6
|
+
|
|
7
|
+
declare const assertValidFileContents: (contents: any) => void;
|
|
8
|
+
|
|
9
|
+
declare const assertValidFileOrDirectoryPath: (fileOrDirectoryPath: any) => void;
|
|
10
|
+
|
|
11
|
+
declare function parseJson<T = JsonValue>(string: string, filename?: string, options?: CodeFrameOptions): T;
|
|
12
|
+
declare function parseJson<T = JsonValue>(string: string, reviver: JsonReviver, fileName?: string, options?: CodeFrameOptions): T;
|
|
13
|
+
|
|
14
|
+
declare const stripJsonComments: (jsonString: string, { whitespace }?: {
|
|
15
|
+
whitespace?: boolean | undefined;
|
|
16
|
+
}) => string;
|
|
17
|
+
|
|
18
|
+
export { assertValidFileContents, assertValidFileOrDirectoryPath, parseJson, stripJsonComments };
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export { J as JSONError } from './
|
|
2
|
-
import { JsonValue } from '
|
|
3
|
-
import { n as CodeFrameOptions, J as JsonReviver } from './types-CtYA064B.js';
|
|
1
|
+
export { J as JSONError } from './shared/fs.ZPgZIXcg.js';
|
|
2
|
+
import { J as JsonValue, o as CodeFrameOptions, c as JsonReviver } from './shared/fs.CpT5ICZl.js';
|
|
4
3
|
export { toPath } from '@visulima/path/utils';
|
|
5
4
|
import 'node:fs';
|
|
6
5
|
import 'yaml';
|
package/dist/utils.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var a=Object.defineProperty;var r=(e,s)=>a(e,"name",{value:s,configurable:!0});import{c as h}from"./shared/fs.BXbumRuI.mjs";import{v as d,s as v,F as x}from"./shared/fs.BRjynomN.mjs";import{toPath as N}from"@visulima/path/utils";var o=Object.defineProperty,n=r((e,s)=>o(e,"name",{value:s,configurable:!0}),"n");const i=n((e,{whitespace:s=!0}={})=>e.replace(p,t=>t.startsWith('"')||t[1]==="*"&&!t.endsWith("*/")?t:s?t.replaceAll(/\S/g," "):""),"stripJsonComments"),p=/"(?:[^"\\]|\\.)*"?|\/\/[^\r\n]*|\/\*(?:[^*]|\*[^/])*(?:\*\/)?/g,l=i;export{h as JSONError,d as assertValidFileContents,v as assertValidFileOrDirectoryPath,x as parseJson,l as stripJsonComments,N as toPath};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visulima/fs",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.7",
|
|
4
4
|
"description": "Human friendly file system utilities for Node.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"anolilab",
|
|
@@ -80,8 +80,8 @@
|
|
|
80
80
|
"default": "./dist/index.cjs"
|
|
81
81
|
},
|
|
82
82
|
"import": {
|
|
83
|
-
"types": "./dist/index.d.
|
|
84
|
-
"default": "./dist/index.
|
|
83
|
+
"types": "./dist/index.d.mts",
|
|
84
|
+
"default": "./dist/index.mjs"
|
|
85
85
|
}
|
|
86
86
|
},
|
|
87
87
|
"./utils": {
|
|
@@ -90,8 +90,8 @@
|
|
|
90
90
|
"default": "./dist/utils.cjs"
|
|
91
91
|
},
|
|
92
92
|
"import": {
|
|
93
|
-
"types": "./dist/utils.d.
|
|
94
|
-
"default": "./dist/utils.
|
|
93
|
+
"types": "./dist/utils.d.mts",
|
|
94
|
+
"default": "./dist/utils.mjs"
|
|
95
95
|
}
|
|
96
96
|
},
|
|
97
97
|
"./error": {
|
|
@@ -100,14 +100,14 @@
|
|
|
100
100
|
"default": "./dist/error.cjs"
|
|
101
101
|
},
|
|
102
102
|
"import": {
|
|
103
|
-
"types": "./dist/error.d.
|
|
104
|
-
"default": "./dist/error.
|
|
103
|
+
"types": "./dist/error.d.mts",
|
|
104
|
+
"default": "./dist/error.mjs"
|
|
105
105
|
}
|
|
106
106
|
},
|
|
107
107
|
"./package.json": "./package.json"
|
|
108
108
|
},
|
|
109
109
|
"main": "dist/index.cjs",
|
|
110
|
-
"module": "dist/index.
|
|
110
|
+
"module": "dist/index.mjs",
|
|
111
111
|
"types": "dist/index.d.ts",
|
|
112
112
|
"files": [
|
|
113
113
|
"dist/**",
|
|
@@ -116,8 +116,7 @@
|
|
|
116
116
|
"LICENSE.md"
|
|
117
117
|
],
|
|
118
118
|
"dependencies": {
|
|
119
|
-
"@visulima/path": "1.0.2"
|
|
120
|
-
"type-fest": "^4.20.0"
|
|
119
|
+
"@visulima/path": "1.0.2"
|
|
121
120
|
},
|
|
122
121
|
"devDependencies": {
|
|
123
122
|
"@anolilab/eslint-config": "^15.0.3",
|
|
@@ -128,11 +127,13 @@
|
|
|
128
127
|
"@rushstack/eslint-plugin-security": "^0.8.1",
|
|
129
128
|
"@types/node": "18.19.15",
|
|
130
129
|
"@visulima/error": "4.0.0",
|
|
130
|
+
"@visulima/packem": "^1.0.0-alpha.42",
|
|
131
131
|
"@vitest/coverage-v8": "^1.6.0",
|
|
132
132
|
"@vitest/ui": "^1.6.0",
|
|
133
133
|
"conventional-changelog-conventionalcommits": "8.0.0",
|
|
134
134
|
"cross-env": "^7.0.3",
|
|
135
135
|
"detect-indent": "^7.0.1",
|
|
136
|
+
"esbuild": "^0.21.5",
|
|
136
137
|
"eslint": "^8.57.0",
|
|
137
138
|
"eslint-plugin-deprecation": "^3.0.0",
|
|
138
139
|
"eslint-plugin-etc": "^2.0.3",
|
|
@@ -147,7 +148,7 @@
|
|
|
147
148
|
"safe-regex2": "^3.1.0",
|
|
148
149
|
"semantic-release": "24.0.0",
|
|
149
150
|
"tempy": "^3.1.0",
|
|
150
|
-
"
|
|
151
|
+
"type-fest": "^4.20.1",
|
|
151
152
|
"typescript": "^5.4.5",
|
|
152
153
|
"vitest": "^1.6.0",
|
|
153
154
|
"yaml": "^2.4.5"
|
|
@@ -190,8 +191,8 @@
|
|
|
190
191
|
"src/utils.ts"
|
|
191
192
|
],
|
|
192
193
|
"scripts": {
|
|
193
|
-
"build": "cross-env NODE_ENV=development
|
|
194
|
-
"build:prod": "cross-env NODE_ENV=production
|
|
194
|
+
"build": "cross-env NODE_ENV=development packem build",
|
|
195
|
+
"build:prod": "cross-env NODE_ENV=production packem build",
|
|
195
196
|
"clean": "rimraf node_modules dist .eslintcache",
|
|
196
197
|
"dev": "pnpm run build --watch",
|
|
197
198
|
"lint:eslint": "eslint . --ext js,cjs,mjs,jsx,ts,tsx,json,yaml,yml,md,mdx --max-warnings=0 --config .eslintrc.cjs",
|
package/dist/chunk-BZXQ545V.cjs
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var t=class extends Error{constructor(r){super(`EEXIST: ${r}`);}get code(){return "EEXIST"}set code(r){throw new Error("Cannot overwrite code EEXIST")}get name(){return "AlreadyExistsError"}set name(r){throw new Error("Cannot overwrite name of AlreadyExistsError")}},E=t;var n=class extends Error{constructor(r){super(`EISDIR: Illegal operation on a directory, ${r}`);}get code(){return "EISDIR"}set code(r){throw new Error("Cannot overwrite code EISDIR")}get name(){return "DirectoryError"}set name(r){throw new Error("Cannot overwrite name of DirectoryError")}},l=n;var i=class extends Error{constructor(r){super(`ENOTEMPTY: Directory not empty, ${r}`);}get code(){return "ENOTEMPTY"}set code(r){throw new Error("Cannot overwrite code ENOTEMPTY")}get name(){return "NotEmptyError"}set name(r){throw new Error("Cannot overwrite name of NotEmptyError")}},p=i;var s=class extends Error{constructor(r){super(`ENOENT: ${r}`);}get code(){return "ENOENT"}set code(r){throw new Error("Cannot overwrite code ENOENT")}get name(){return "NotFoundError"}set name(r){throw new Error("Cannot overwrite name of NotFoundError")}},d=s;var a=class extends Error{constructor(r){super(`EPERM: Operation not permitted, ${r}`);}get code(){return "EPERM"}set code(r){throw new Error("Cannot overwrite code EPERM")}get name(){return "PermissionError"}set name(r){throw new Error("Cannot overwrite name of PermissionError")}},m=a;var u=class extends Error{root;constructor(r,c){super(`${r instanceof Error?r.message:r} for path "${c}"`),this.cause=r,this.root=c;}get name(){return "WalkError"}set name(r){throw new Error("Cannot overwrite name of WalkError")}},w=u;
|
|
4
|
-
|
|
5
|
-
exports.a = E;
|
|
6
|
-
exports.b = l;
|
|
7
|
-
exports.c = p;
|
|
8
|
-
exports.d = d;
|
|
9
|
-
exports.e = m;
|
|
10
|
-
exports.f = w;
|
|
11
|
-
//# sourceMappingURL=out.js.map
|
|
12
|
-
//# sourceMappingURL=chunk-BZXQ545V.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/error/already-exists-error.ts","../src/error/directory-error.ts","../src/error/not-empty-error.ts","../src/error/not-found-error.ts","../src/error/permission-error.ts","../src/error/walk-error.ts"],"names":["AlreadyExistsError","message","_name","already_exists_error_default","DirectoryError","directory_error_default","NotEmptyError","not_empty_error_default","NotFoundError","not_found_error_default","PermissionError","permission_error_default","WalkError","cause","root","walk_error_default"],"mappings":"AAGA,IAAMA,EAAN,cAAiC,KAAM,CAK5B,YAAYC,EAAiB,CAChC,MAAM,WAAWA,CAAO,EAAE,CAC9B,CAGA,IAAW,MAAe,CACtB,MAAO,QACX,CAGA,IAAW,KAAKC,EAAO,CACnB,MAAM,IAAI,MAAM,8BAA8B,CAClD,CAGA,IAAoB,MAAe,CAC/B,MAAO,oBACX,CAGA,IAAoB,KAAKA,EAAO,CAC5B,MAAM,IAAI,MAAM,6CAA6C,CACjE,CACJ,EAEOC,EAAQH,EC9Bf,IAAMI,EAAN,cAA6B,KAAM,CAKxB,YAAYH,EAAiB,CAChC,MAAM,6CAA6CA,CAAO,EAAE,CAChE,CAGA,IAAW,MAAe,CACtB,MAAO,QACX,CAGA,IAAW,KAAKC,EAAO,CACnB,MAAM,IAAI,MAAM,8BAA8B,CAClD,CAGA,IAAoB,MAAe,CAC/B,MAAO,gBACX,CAGA,IAAoB,KAAKA,EAAO,CAC5B,MAAM,IAAI,MAAM,yCAAyC,CAC7D,CACJ,EAEOG,EAAQD,EC9Bf,IAAME,EAAN,cAA4B,KAAM,CAKvB,YAAYL,EAAiB,CAChC,MAAM,mCAAmCA,CAAO,EAAE,CACtD,CAGA,IAAW,MAAe,CACtB,MAAO,WACX,CAGA,IAAW,KAAKC,EAAO,CACnB,MAAM,IAAI,MAAM,iCAAiC,CACrD,CAGA,IAAoB,MAAe,CAC/B,MAAO,eACX,CAGA,IAAoB,KAAKA,EAAO,CAC5B,MAAM,IAAI,MAAM,wCAAwC,CAC5D,CACJ,EAEOK,EAAQD,EC9Bf,IAAME,EAAN,cAA4B,KAAM,CAKvB,YAAYP,EAAiB,CAChC,MAAM,WAAWA,CAAO,EAAE,CAC9B,CAGA,IAAW,MAAe,CACtB,MAAO,QACX,CAGA,IAAW,KAAKC,EAAO,CACnB,MAAM,IAAI,MAAM,8BAA8B,CAClD,CAGA,IAAoB,MAAe,CAC/B,MAAO,eACX,CAGA,IAAoB,KAAKA,EAAO,CAC5B,MAAM,IAAI,MAAM,wCAAwC,CAC5D,CACJ,EAEOO,EAAQD,EC9Bf,IAAME,EAAN,cAA8B,KAAM,CAKzB,YAAYT,EAAiB,CAChC,MAAM,mCAAmCA,CAAO,EAAE,CACtD,CAGA,IAAW,MAAe,CACtB,MAAO,OACX,CAGA,IAAW,KAAKC,EAAO,CACnB,MAAM,IAAI,MAAM,6BAA6B,CACjD,CAGA,IAAoB,MAAe,CAC/B,MAAO,iBACX,CAGA,IAAoB,KAAKA,EAAO,CAC5B,MAAM,IAAI,MAAM,0CAA0C,CAC9D,CACJ,EAEOS,EAAQD,EC3Bf,IAAME,EAAN,cAAwB,KAAM,CAEnB,KAGA,YAAYC,EAAgBC,EAAc,CAE7C,MAAM,GAAGD,aAAiB,MAAQA,EAAM,QAAUA,CAAK,cAAcC,CAAI,GAAG,EAE5E,KAAK,MAAQD,EACb,KAAK,KAAOC,CAChB,CAGA,IAAoB,MAAe,CAC/B,MAAO,WACX,CAGA,IAAoB,KAAKZ,EAAO,CAC5B,MAAM,IAAI,MAAM,oCAAoC,CACxD,CACJ,EAEOa,EAAQH","sourcesContent":["/**\n * Error thrown when file already exists.\n */\nclass AlreadyExistsError extends Error {\n /**\n * Creates a new instance.\n * @param {string} message The error message.\n */\n public constructor(message: string) {\n super(`EEXIST: ${message}`);\n }\n\n // eslint-disable-next-line class-methods-use-this,@typescript-eslint/class-literal-property-style\n public get code(): string {\n return \"EEXIST\";\n }\n\n // eslint-disable-next-line class-methods-use-this,@typescript-eslint/explicit-module-boundary-types\n public set code(_name) {\n throw new Error(\"Cannot overwrite code EEXIST\");\n }\n\n // eslint-disable-next-line class-methods-use-this,@typescript-eslint/class-literal-property-style\n public override get name(): string {\n return \"AlreadyExistsError\";\n }\n\n // eslint-disable-next-line class-methods-use-this,@typescript-eslint/explicit-module-boundary-types\n public override set name(_name) {\n throw new Error(\"Cannot overwrite name of AlreadyExistsError\");\n }\n}\n\nexport default AlreadyExistsError;\n","/**\n * Error thrown when an operation is not allowed on a directory.\n */\nclass DirectoryError extends Error {\n /**\n * Creates a new instance.\n * @param {string} message The error message.\n */\n public constructor(message: string) {\n super(`EISDIR: Illegal operation on a directory, ${message}`);\n }\n\n // eslint-disable-next-line class-methods-use-this,@typescript-eslint/class-literal-property-style\n public get code(): string {\n return \"EISDIR\";\n }\n\n // eslint-disable-next-line class-methods-use-this,@typescript-eslint/explicit-module-boundary-types\n public set code(_name) {\n throw new Error(\"Cannot overwrite code EISDIR\");\n }\n\n // eslint-disable-next-line class-methods-use-this,@typescript-eslint/class-literal-property-style\n public override get name(): string {\n return \"DirectoryError\";\n }\n\n // eslint-disable-next-line class-methods-use-this,@typescript-eslint/explicit-module-boundary-types\n public override set name(_name) {\n throw new Error(\"Cannot overwrite name of DirectoryError\");\n }\n}\n\nexport default DirectoryError;\n","/**\n * Error thrown when a directory is not empty.\n */\nclass NotEmptyError extends Error {\n /**\n * Creates a new instance.\n * @param {string} message The error message.\n */\n public constructor(message: string) {\n super(`ENOTEMPTY: Directory not empty, ${message}`);\n }\n\n // eslint-disable-next-line class-methods-use-this,@typescript-eslint/class-literal-property-style\n public get code(): string {\n return \"ENOTEMPTY\";\n }\n\n // eslint-disable-next-line class-methods-use-this,@typescript-eslint/explicit-module-boundary-types\n public set code(_name) {\n throw new Error(\"Cannot overwrite code ENOTEMPTY\");\n }\n\n // eslint-disable-next-line class-methods-use-this,@typescript-eslint/class-literal-property-style\n public override get name(): string {\n return \"NotEmptyError\";\n }\n\n // eslint-disable-next-line class-methods-use-this,@typescript-eslint/explicit-module-boundary-types\n public override set name(_name) {\n throw new Error(\"Cannot overwrite name of NotEmptyError\");\n }\n}\n\nexport default NotEmptyError;\n","/**\n * Error thrown when a file or directory is not found.\n */\nclass NotFoundError extends Error {\n /**\n * Creates a new instance.\n * @param {string} message The error message.\n */\n public constructor(message: string) {\n super(`ENOENT: ${message}`);\n }\n\n // eslint-disable-next-line class-methods-use-this,@typescript-eslint/class-literal-property-style\n public get code(): string {\n return \"ENOENT\";\n }\n\n // eslint-disable-next-line class-methods-use-this,@typescript-eslint/explicit-module-boundary-types\n public set code(_name) {\n throw new Error(\"Cannot overwrite code ENOENT\");\n }\n\n // eslint-disable-next-line class-methods-use-this,@typescript-eslint/class-literal-property-style\n public override get name(): string {\n return \"NotFoundError\";\n }\n\n // eslint-disable-next-line class-methods-use-this,@typescript-eslint/explicit-module-boundary-types\n public override set name(_name) {\n throw new Error(\"Cannot overwrite name of NotFoundError\");\n }\n}\n\nexport default NotFoundError;\n","/**\n * Error thrown when an operation is not permitted.\n */\nclass PermissionError extends Error {\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 // eslint-disable-next-line class-methods-use-this,@typescript-eslint/class-literal-property-style\n public get code(): string {\n return \"EPERM\";\n }\n\n // eslint-disable-next-line class-methods-use-this,@typescript-eslint/explicit-module-boundary-types\n public set code(_name) {\n throw new Error(\"Cannot overwrite code EPERM\");\n }\n\n // eslint-disable-next-line class-methods-use-this,@typescript-eslint/class-literal-property-style\n public override get name(): string {\n return \"PermissionError\";\n }\n\n // eslint-disable-next-line class-methods-use-this,@typescript-eslint/explicit-module-boundary-types\n public override set name(_name) {\n throw new Error(\"Cannot overwrite name of PermissionError\");\n }\n}\n\nexport default PermissionError;\n","// 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.root = root;\n }\n\n // eslint-disable-next-line class-methods-use-this,@typescript-eslint/class-literal-property-style\n public override get name(): string {\n return \"WalkError\";\n }\n\n // eslint-disable-next-line class-methods-use-this,@typescript-eslint/explicit-module-boundary-types\n public override set name(_name) {\n throw new Error(\"Cannot overwrite name of WalkError\");\n }\n}\n\nexport default WalkError;\n"]}
|
package/dist/chunk-ELTI4L4F.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { a } from './chunk-UPN3Y5W3.js';
|
|
2
|
-
|
|
3
|
-
var V=e=>{if(!e||!(e instanceof URL)&&typeof e!="string")throw new TypeError("Path must be a non-empty string or URL.")},H=V;var N=e=>e.replaceAll(/\r\n|\r(?!\n)|\n/gu,`
|
|
4
|
-
`),P=N,R=globalThis.process||Object.create(null),$={versions:{}},j=new Proxy(R,{get(e,t){if(t in e)return e[t];if(t in $)return $[t]}}),v=j,B=(e,t,o,n)=>{let r={column:0,line:-1,...e.start},s={...r,...e.end},a=r.line,l=r.column,p=s.line,f=s.column,c=Math.max(a-(o+1),0),d=Math.min(t.length,p+n);a===-1&&(c=0),p===-1&&(d=t.length);let y=p-a,m={};if(y)for(let i=0;i<=y;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===y)m[u]=[0,f];else {let g=t[u-i]?.length;m[u]=[0,g];}}else l===f?m[a]=l?[l,0]:!0:m[a]=[l,(f??0)-(l??0)];return {end:d,markerLines:m,start:c}},M=B,T=v.platform==="win32"&&!v.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=P(e).split(`
|
|
5
|
-
`);typeof n?.tabWidth=="number"&&(s=s.map(i=>i.replaceAll(" "," ".repeat(n.tabWidth))));let{end:a,markerLines:l,start:p}=M(t,s,n.linesAbove,n.linesBelow),f=String(a).length,{gutter:c,marker:d,message:y}=n.color,m=s.slice(p,a).map((i,u)=>{let g=p+1+u,h=l[g],O=` ${g}`.slice(-f),k=!l[g+1],x=` ${O}${n.showGutter?" |":""}`;if(h){let A="";if(Array.isArray(h)){let L=i.replaceAll(/[^\t]/g," ").slice(0,Math.max(h[0]-1,0)),S=h[1]||1;A=[`
|
|
6
|
-
`,c(x.replaceAll(/\d/g," "))," ",L,d("^").repeat(S)].join(""),k&&n.message&&(A+=` ${y(n.message)}`);}return [d(T),c(x),i.length>0?` ${i}`:"",A].join("")}return ` ${c(x)}${i.length>0?` ${i}`:""}`}).join(`
|
|
7
|
-
`);return n.message&&!r&&(m=`${" ".repeat(f+1)}${n.message}
|
|
8
|
-
${m}`),m};var E=(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},W=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=W(e),a=E(t,s);return {column:t-s[a]+1,line:a+1}}let r=E(t,e);return {column:t-e[r]+1,line:r+1}},J=_;var q=e=>`\\u{${e.codePointAt(0).toString(16)}}`,U=(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),J(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$1=new a(r);throw a$1.fileName=o,s&&(a$1.codeFrame=U(e,s,n)),a$1}var oe=z;var D=e=>{if(typeof e!="string"&&!(e instanceof ArrayBuffer)&&!ArrayBuffer.isView(e))throw new TypeError("File contents must be a string, ArrayBuffer, or ArrayBuffer view.")},ae=D;
|
|
9
|
-
|
|
10
|
-
export { H as a, oe as b, ae as c };
|
|
11
|
-
//# sourceMappingURL=out.js.map
|
|
12
|
-
//# sourceMappingURL=chunk-ELTI4L4F.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/assert-valid-file-or-directory-path.ts","../../../node_modules/.pnpm/@visulima+error@3.2.11/node_modules/@visulima/error/src/util/normalize-lf.ts","../../../node_modules/.pnpm/@visulima+error@3.2.11/node_modules/@visulima/error/src/util/process.ts","../../../node_modules/.pnpm/@visulima+error@3.2.11/node_modules/@visulima/error/src/code-frame/get-marker-lines.ts","../../../node_modules/.pnpm/@visulima+error@3.2.11/node_modules/@visulima/error/src/code-frame/index.ts","../src/utils/parse-json.ts","../src/utils/assert-valid-file-contents.ts"],"names":["assertValidFileOrDirectoryPath","fileOrDirectoryPath","assert_valid_file_or_directory_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","assertValidFileContents","contents","assert_valid_file_contents_default"],"mappings":"wCACA,IAAMA,EAAkCC,GAAmC,CACvE,GAAI,CAACA,GAAwB,EAAEA,aAA+B,MAAQ,OAAOA,GAAwB,SACjG,MAAM,IAAI,UAAU,yCAAyC,CAErE,EAEOC,EAAQF,ECPf,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,CA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AiBU,EAAQT,CAAO,EAC3CA,EAAUI,EAA8BJ,CAAO,GAE/CA,GAAW,8BAGf,IAAMa,EAAY,IAAIC,EAAUd,CAAO,EAEvC,MAAAa,EAAU,SAAWF,EAEjBd,IACAgB,EAAU,UAAYjB,EAAkBa,EAAQZ,EAAUjC,CAAO,GAG/DiD,CACV,CAEA,IAAOE,GAAQP,ECxGf,IAAMQ,EAA2BC,GAAwB,CACrD,GAAI,OAAOA,GAAa,UAAY,EAAEA,aAAoB,cAAgB,CAAC,YAAY,OAAOA,CAAQ,EAClG,MAAM,IAAI,UAAU,mEAAmE,CAE/F,EAEOC,GAAQF","sourcesContent":["// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types,@typescript-eslint/no-explicit-any\nconst assertValidFileOrDirectoryPath = (fileOrDirectoryPath: any): void => {\n if (!fileOrDirectoryPath || (!(fileOrDirectoryPath instanceof URL) && typeof fileOrDirectoryPath !== \"string\")) {\n throw new TypeError(\"Path must be a non-empty string or URL.\");\n }\n};\n\nexport default assertValidFileOrDirectoryPath;\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 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 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\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 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-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 jsonError.codeFrame = generateCodeFrame(string, location, options);\n }\n\n throw jsonError;\n}\n\nexport default parseJson;\n","// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types,@typescript-eslint/no-explicit-any\nconst assertValidFileContents = (contents: any): void => {\n if (typeof contents !== \"string\" && !(contents instanceof ArrayBuffer) && !ArrayBuffer.isView(contents)) {\n throw new TypeError(\"File contents must be a string, ArrayBuffer, or ArrayBuffer view.\");\n }\n};\n\nexport default assertValidFileContents;\n"]}
|
package/dist/chunk-N5NZURYL.cjs
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var r=class i extends Error{fileName;codeFrame;name="JSONError";#e;constructor(e){super(),this.#e=e,Error.captureStackTrace(this,i);}get message(){return `${this.#e}${this.fileName?` in ${this.fileName}`:""}${this.codeFrame?`
|
|
4
|
-
|
|
5
|
-
${this.codeFrame}
|
|
6
|
-
`:""}`}set message(e){this.#e=e;}},t=r;
|
|
7
|
-
|
|
8
|
-
exports.a = t;
|
|
9
|
-
//# sourceMappingURL=out.js.map
|
|
10
|
-
//# sourceMappingURL=chunk-N5NZURYL.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/error/json-error.ts"],"names":["JSONError","_JSONError","#message","message","json_error_default"],"mappings":"AAAA,IAAMA,EAAN,MAAMC,UAAkB,KAAM,CACnB,SAEA,UAGW,KAAO,YAEzBC,GAEO,YAAYC,EAAiB,CAGhC,MAAM,EAEN,KAAKD,GAAWC,EAEhB,MAAM,kBAAkB,KAAMF,CAAS,CAC3C,CAEA,IAAoB,SAAkB,CAClC,MAAO,GAAG,KAAKC,EAAQ,GAAG,KAAK,SAAW,OAAO,KAAK,QAAQ,GAAK,EAAE,GAAG,KAAK,UAAY;AAAA;AAAA,EAAO,KAAK,SAAS;AAAA,EAAO,EAAE,EAC3H,CAEA,IAAoB,QAAQC,EAAiB,CACzC,KAAKD,GAAWC,CACpB,CACJ,EAEOC,EAAQJ","sourcesContent":["class JSONError extends Error {\n public fileName: string | undefined;\n\n public codeFrame: string | undefined;\n\n // eslint-disable-next-line @typescript-eslint/explicit-member-accessibility\n override readonly name = \"JSONError\";\n\n #message;\n\n public constructor(message: string) {\n // We cannot pass message to `super()`, otherwise the message accessor will be overridden.\n // https://262.ecma-international.org/14.0/#sec-error-message\n super();\n\n this.#message = message;\n\n Error.captureStackTrace(this, JSONError);\n }\n\n public override get message(): string {\n return `${this.#message}${this.fileName ? ` in ${this.fileName}` : \"\"}${this.codeFrame ? `\\n\\n${this.codeFrame}\\n` : \"\"}`;\n }\n\n public override set message(message: string) {\n this.#message = message;\n }\n}\n\nexport default JSONError;\n"]}
|
package/dist/chunk-NEXEUEQV.cjs
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var chunkN5NZURYL_cjs = require('./chunk-N5NZURYL.cjs');
|
|
4
|
-
|
|
5
|
-
var S=e=>{if(!e||!(e instanceof URL)&&typeof e!="string")throw new TypeError("Path must be a non-empty string or URL.")},D=S;var V=e=>e.replaceAll(/\r\n|\r(?!\n)|\n/gu,`
|
|
6
|
-
`),N=V,P=globalThis.process||Object.create(null),w={versions:{}},R=new Proxy(P,{get(e,t){if(t in e)return e[t];if(t in w)return w[t]}}),$=R,j=(e,t,o,n)=>{let r={column:0,line:-1,...e.start},s={...r,...e.end},a=r.line,l=r.column,p=s.line,f=s.column,c=Math.max(a-(o+1),0),d=Math.min(t.length,p+n);a===-1&&(c=0),p===-1&&(d=t.length);let y=p-a,m={};if(y)for(let i=0;i<=y;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===y)m[u]=[0,f];else {let g=t[u-i]?.length;m[u]=[0,g];}}else l===f?m[a]=l?[l,0]:!0:m[a]=[l,(f??0)-(l??0)];return {end:d,markerLines:m,start:c}},B=j,v=$.platform==="win32"&&!$.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=N(e).split(`
|
|
7
|
-
`);typeof n?.tabWidth=="number"&&(s=s.map(i=>i.replaceAll(" "," ".repeat(n.tabWidth))));let{end:a,markerLines:l,start:p}=B(t,s,n.linesAbove,n.linesBelow),f=String(a).length,{gutter:c,marker:d,message:y}=n.color,m=s.slice(p,a).map((i,u)=>{let g=p+1+u,h=l[g],J=` ${g}`.slice(-f),O=!l[g+1],F=` ${J}${n.showGutter?" |":""}`;if(h){let x="";if(Array.isArray(h)){let k=i.replaceAll(/[^\t]/g," ").slice(0,Math.max(h[0]-1,0)),L=h[1]||1;x=[`
|
|
8
|
-
`,c(F.replaceAll(/\d/g," "))," ",k,d("^").repeat(L)].join(""),O&&n.message&&(x+=` ${y(n.message)}`);}return [d(v),c(F),i.length>0?` ${i}`:"",x].join("")}return ` ${c(F)}${i.length>0?` ${i}`:""}`}).join(`
|
|
9
|
-
`);return n.message&&!r&&(m=`${" ".repeat(f+1)}${n.message}
|
|
10
|
-
${m}`),m};var T=(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},M=e=>e.split(/\n|\r(?!\n)/).reduce((t,o)=>(t.push(t.at(-1)+o.length+1),t),[0]),W=(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=M(e),a=T(t,s);return {column:t-s[a]+1,line:a+1}}let r=T(t,e);return {column:t-e[r]+1,line:r+1}},E=W;var _=e=>`\\u{${e.codePointAt(0).toString(16)}}`,q=(e,t,o)=>A(e,{start:t},{tabWidth:!1,...o}),U=(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),E(e,r))},G=e=>e.replace(/(?<=^Unexpected token )(?<quote>')?(.)\k<quote>/,(t,o,n)=>`"${n}"(${_(n)})`);function I(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=U(e,r),r=G(r)):r+=" while parsing empty string";let a=new chunkN5NZURYL_cjs.a(r);throw a.fileName=o,s&&(a.codeFrame=q(e,s,n)),a}var re=I;var z=e=>{if(typeof e!="string"&&!(e instanceof ArrayBuffer)&&!ArrayBuffer.isView(e))throw new TypeError("File contents must be a string, ArrayBuffer, or ArrayBuffer view.")},se=z;
|
|
11
|
-
|
|
12
|
-
exports.a = D;
|
|
13
|
-
exports.b = re;
|
|
14
|
-
exports.c = se;
|
|
15
|
-
//# sourceMappingURL=out.js.map
|
|
16
|
-
//# sourceMappingURL=chunk-NEXEUEQV.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/assert-valid-file-or-directory-path.ts","../../../node_modules/.pnpm/@visulima+error@3.2.11/node_modules/@visulima/error/src/util/normalize-lf.ts","../../../node_modules/.pnpm/@visulima+error@3.2.11/node_modules/@visulima/error/src/util/process.ts","../../../node_modules/.pnpm/@visulima+error@3.2.11/node_modules/@visulima/error/src/code-frame/get-marker-lines.ts","../../../node_modules/.pnpm/@visulima+error@3.2.11/node_modules/@visulima/error/src/code-frame/index.ts","../src/utils/parse-json.ts","../src/utils/assert-valid-file-contents.ts"],"names":["assertValidFileOrDirectoryPath","fileOrDirectoryPath","assert_valid_file_or_directory_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","assertValidFileContents","contents","assert_valid_file_contents_default"],"mappings":"yCACA,IAAMA,EAAkCC,GAAmC,CACvE,GAAI,CAACA,GAAwB,EAAEA,aAA+B,MAAQ,OAAOA,GAAwB,SACjG,MAAM,IAAI,UAAU,yCAAyC,CAErE,EAEOC,EAAQF,ECPf,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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/C,EAA+B,CAC/I,OAAO8C,GAAY,WACf,OAAOC,GAAa,WAEpB/C,EAAU+C,GAIdA,EAAWD,EAEXA,EAAU,QAGd,IAAIV,EAEJ,GAAI,CACA,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,IACAgB,EAAU,UAAYjB,EAAkBa,EAAQZ,EAAUjC,CAAO,GAG/DiD,CACV,CAEA,IAAOE,GAAQP,ECxGf,IAAMQ,EAA2BC,GAAwB,CACrD,GAAI,OAAOA,GAAa,UAAY,EAAEA,aAAoB,cAAgB,CAAC,YAAY,OAAOA,CAAQ,EAClG,MAAM,IAAI,UAAU,mEAAmE,CAE/F,EAEOC,GAAQF","sourcesContent":["// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types,@typescript-eslint/no-explicit-any\nconst assertValidFileOrDirectoryPath = (fileOrDirectoryPath: any): void => {\n if (!fileOrDirectoryPath || (!(fileOrDirectoryPath instanceof URL) && typeof fileOrDirectoryPath !== \"string\")) {\n throw new TypeError(\"Path must be a non-empty string or URL.\");\n }\n};\n\nexport default assertValidFileOrDirectoryPath;\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 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 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\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 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-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 jsonError.codeFrame = generateCodeFrame(string, location, options);\n }\n\n throw jsonError;\n}\n\nexport default parseJson;\n","// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types,@typescript-eslint/no-explicit-any\nconst assertValidFileContents = (contents: any): void => {\n if (typeof contents !== \"string\" && !(contents instanceof ArrayBuffer) && !ArrayBuffer.isView(contents)) {\n throw new TypeError(\"File contents must be a string, ArrayBuffer, or ArrayBuffer view.\");\n }\n};\n\nexport default assertValidFileContents;\n"]}
|
package/dist/chunk-P3KZLWQC.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
var n=class extends Error{constructor(r){super(`EEXIST: ${r}`);}get code(){return "EEXIST"}set code(r){throw new Error("Cannot overwrite code EEXIST")}get name(){return "AlreadyExistsError"}set name(r){throw new Error("Cannot overwrite name of AlreadyExistsError")}},l=n;var i=class extends Error{constructor(r){super(`EISDIR: Illegal operation on a directory, ${r}`);}get code(){return "EISDIR"}set code(r){throw new Error("Cannot overwrite code EISDIR")}get name(){return "DirectoryError"}set name(r){throw new Error("Cannot overwrite name of DirectoryError")}},p=i;var s=class extends Error{constructor(r){super(`ENOTEMPTY: Directory not empty, ${r}`);}get code(){return "ENOTEMPTY"}set code(r){throw new Error("Cannot overwrite code ENOTEMPTY")}get name(){return "NotEmptyError"}set name(r){throw new Error("Cannot overwrite name of NotEmptyError")}},d=s;var a=class extends Error{constructor(r){super(`ENOENT: ${r}`);}get code(){return "ENOENT"}set code(r){throw new Error("Cannot overwrite code ENOENT")}get name(){return "NotFoundError"}set name(r){throw new Error("Cannot overwrite name of NotFoundError")}},m=a;var u=class extends Error{constructor(r){super(`EPERM: Operation not permitted, ${r}`);}get code(){return "EPERM"}set code(r){throw new Error("Cannot overwrite code EPERM")}get name(){return "PermissionError"}set name(r){throw new Error("Cannot overwrite name of PermissionError")}},w=u;var c=class extends Error{root;constructor(r,E){super(`${r instanceof Error?r.message:r} for path "${E}"`),this.cause=r,this.root=E;}get name(){return "WalkError"}set name(r){throw new Error("Cannot overwrite name of WalkError")}},g=c;
|
|
2
|
-
|
|
3
|
-
export { l as a, p as b, d as c, m as d, w as e, g as f };
|
|
4
|
-
//# sourceMappingURL=out.js.map
|
|
5
|
-
//# sourceMappingURL=chunk-P3KZLWQC.js.map
|