@functional-examples/devkit 0.0.0-alpha.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/dist/glob/glob.d.ts +34 -0
- package/dist/glob/glob.d.ts.map +1 -0
- package/dist/glob/glob.js +36 -0
- package/dist/glob/glob.js.map +1 -0
- package/dist/glob/index.d.ts +3 -0
- package/dist/glob/index.d.ts.map +1 -0
- package/dist/glob/index.js +3 -0
- package/dist/glob/index.js.map +1 -0
- package/dist/glob/match.d.ts +29 -0
- package/dist/glob/match.d.ts.map +1 -0
- package/dist/glob/match.js +50 -0
- package/dist/glob/match.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/json/errors.d.ts +41 -0
- package/dist/json/errors.d.ts.map +1 -0
- package/dist/json/errors.js +102 -0
- package/dist/json/errors.js.map +1 -0
- package/dist/json/index.d.ts +3 -0
- package/dist/json/index.d.ts.map +1 -0
- package/dist/json/index.js +3 -0
- package/dist/json/index.js.map +1 -0
- package/dist/json/parse.d.ts +45 -0
- package/dist/json/parse.d.ts.map +1 -0
- package/dist/json/parse.js +122 -0
- package/dist/json/parse.js.map +1 -0
- package/dist/types/guards.d.ts +2 -0
- package/dist/types/guards.d.ts.map +1 -0
- package/dist/types/guards.js +2 -0
- package/dist/types/guards.js.map +1 -0
- package/dist/types/index.d.ts +463 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +5 -0
- package/dist/types/index.js.map +1 -0
- package/dist/yaml/index.d.ts +2 -0
- package/dist/yaml/index.d.ts.map +1 -0
- package/dist/yaml/index.js +2 -0
- package/dist/yaml/index.js.map +1 -0
- package/dist/yaml/parse.d.ts +48 -0
- package/dist/yaml/parse.d.ts.map +1 -0
- package/dist/yaml/parse.js +84 -0
- package/dist/yaml/parse.js.map +1 -0
- package/package.json +77 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resets the cached import promise. Used for testing only.
|
|
3
|
+
* @internal
|
|
4
|
+
*/
|
|
5
|
+
export declare function _resetGlobImportCache(): void;
|
|
6
|
+
/**
|
|
7
|
+
* Options for the glob function.
|
|
8
|
+
*/
|
|
9
|
+
export interface GlobOptions {
|
|
10
|
+
/** Working directory for pattern resolution */
|
|
11
|
+
cwd?: string;
|
|
12
|
+
/** Patterns to exclude from results */
|
|
13
|
+
ignore?: string[];
|
|
14
|
+
/** Return absolute paths instead of relative */
|
|
15
|
+
absolute?: boolean;
|
|
16
|
+
/** Only return files (not directories) */
|
|
17
|
+
onlyFiles?: boolean;
|
|
18
|
+
/** Expand directory matches to their contents */
|
|
19
|
+
expandDirectories?: boolean;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Find files matching glob patterns.
|
|
23
|
+
*
|
|
24
|
+
* Thin wrapper around tinyglobby that normalizes input
|
|
25
|
+
* and provides a consistent interface across the monorepo.
|
|
26
|
+
*
|
|
27
|
+
* Requires the `tinyglobby` peer dependency to be installed.
|
|
28
|
+
*
|
|
29
|
+
* @param patterns - One or more glob patterns
|
|
30
|
+
* @param options - Glob options
|
|
31
|
+
* @returns Array of matching file paths
|
|
32
|
+
*/
|
|
33
|
+
export declare function glob(patterns: string | string[], options?: GlobOptions): Promise<string[]>;
|
|
34
|
+
//# sourceMappingURL=glob.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glob.d.ts","sourceRoot":"","sources":["../../src/glob/glob.ts"],"names":[],"mappings":"AAeA;;;GAGG;AACH,wBAAgB,qBAAqB,IAAI,IAAI,CAE5C;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,+CAA+C;IAC/C,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,uCAAuC;IACvC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,gDAAgD;IAChD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,0CAA0C;IAC1C,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,iDAAiD;IACjD,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,IAAI,CACxB,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,EAC3B,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,MAAM,EAAE,CAAC,CAInB"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
let tinyglobbyPromise = null;
|
|
2
|
+
function importTinyglobby() {
|
|
3
|
+
if (!tinyglobbyPromise) {
|
|
4
|
+
tinyglobbyPromise = import('tinyglobby').catch(() => {
|
|
5
|
+
tinyglobbyPromise = null;
|
|
6
|
+
throw new Error('tinyglobby is required to use @functional-examples/devkit/glob. ' +
|
|
7
|
+
'Install it with: pnpm add tinyglobby');
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
return tinyglobbyPromise;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Resets the cached import promise. Used for testing only.
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
export function _resetGlobImportCache() {
|
|
17
|
+
tinyglobbyPromise = null;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Find files matching glob patterns.
|
|
21
|
+
*
|
|
22
|
+
* Thin wrapper around tinyglobby that normalizes input
|
|
23
|
+
* and provides a consistent interface across the monorepo.
|
|
24
|
+
*
|
|
25
|
+
* Requires the `tinyglobby` peer dependency to be installed.
|
|
26
|
+
*
|
|
27
|
+
* @param patterns - One or more glob patterns
|
|
28
|
+
* @param options - Glob options
|
|
29
|
+
* @returns Array of matching file paths
|
|
30
|
+
*/
|
|
31
|
+
export async function glob(patterns, options) {
|
|
32
|
+
const { glob: tinyGlob } = await importTinyglobby();
|
|
33
|
+
const patternArray = Array.isArray(patterns) ? patterns : [patterns];
|
|
34
|
+
return tinyGlob(patternArray, options);
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=glob.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glob.js","sourceRoot":"","sources":["../../src/glob/glob.ts"],"names":[],"mappings":"AAAA,IAAI,iBAAiB,GAAgD,IAAI,CAAC;AAE1E,SAAS,gBAAgB;IACvB,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACvB,iBAAiB,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE;YAClD,iBAAiB,GAAG,IAAI,CAAC;YACzB,MAAM,IAAI,KAAK,CACb,kEAAkE;gBAChE,sCAAsC,CACzC,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IACD,OAAO,iBAAiB,CAAC;AAC3B,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,qBAAqB;IACnC,iBAAiB,GAAG,IAAI,CAAC;AAC3B,CAAC;AAkBD;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,IAAI,CACxB,QAA2B,EAC3B,OAAqB;IAErB,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,MAAM,gBAAgB,EAAE,CAAC;IACpD,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;IACrE,OAAO,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/glob/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/glob/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAoB,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resets the cached import promise. Used for testing only.
|
|
3
|
+
* @internal
|
|
4
|
+
*/
|
|
5
|
+
export declare function _resetMatchImportCache(): void;
|
|
6
|
+
/**
|
|
7
|
+
* Test whether a path matches one or more glob patterns.
|
|
8
|
+
*
|
|
9
|
+
* Requires the `picomatch` peer dependency to be installed.
|
|
10
|
+
*
|
|
11
|
+
* @param path - The path to test
|
|
12
|
+
* @param pattern - One or more glob patterns
|
|
13
|
+
* @returns True if the path matches any of the patterns
|
|
14
|
+
*/
|
|
15
|
+
export declare function isMatch(path: string, pattern: string | string[]): Promise<boolean>;
|
|
16
|
+
/**
|
|
17
|
+
* Create a reusable matcher function from one or more glob patterns.
|
|
18
|
+
*
|
|
19
|
+
* Prefer this over repeated {@link isMatch} calls when matching
|
|
20
|
+
* many paths against the same pattern—the compiled matcher is
|
|
21
|
+
* significantly faster for repeated use.
|
|
22
|
+
*
|
|
23
|
+
* Requires the `picomatch` peer dependency to be installed.
|
|
24
|
+
*
|
|
25
|
+
* @param pattern - One or more glob patterns
|
|
26
|
+
* @returns A function that tests a path against the compiled patterns
|
|
27
|
+
*/
|
|
28
|
+
export declare function createMatcher(pattern: string | string[]): Promise<(path: string) => boolean>;
|
|
29
|
+
//# sourceMappingURL=match.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"match.d.ts","sourceRoot":"","sources":["../../src/glob/match.ts"],"names":[],"mappings":"AAmBA;;;GAGG;AACH,wBAAgB,sBAAsB,IAAI,IAAI,CAE7C;AAED;;;;;;;;GAQG;AACH,wBAAsB,OAAO,CAC3B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,GACzB,OAAO,CAAC,OAAO,CAAC,CAGlB;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,aAAa,CACjC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,GACzB,OAAO,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,CAGpC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
let picomatchPromise = null;
|
|
2
|
+
function importPicomatch() {
|
|
3
|
+
if (!picomatchPromise) {
|
|
4
|
+
picomatchPromise = import('picomatch')
|
|
5
|
+
.then((mod) => (mod.default ?? mod))
|
|
6
|
+
.catch(() => {
|
|
7
|
+
picomatchPromise = null;
|
|
8
|
+
throw new Error('picomatch is required to use @functional-examples/devkit/glob. ' +
|
|
9
|
+
'Install it with: pnpm add picomatch');
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
return picomatchPromise;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Resets the cached import promise. Used for testing only.
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
export function _resetMatchImportCache() {
|
|
19
|
+
picomatchPromise = null;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Test whether a path matches one or more glob patterns.
|
|
23
|
+
*
|
|
24
|
+
* Requires the `picomatch` peer dependency to be installed.
|
|
25
|
+
*
|
|
26
|
+
* @param path - The path to test
|
|
27
|
+
* @param pattern - One or more glob patterns
|
|
28
|
+
* @returns True if the path matches any of the patterns
|
|
29
|
+
*/
|
|
30
|
+
export async function isMatch(path, pattern) {
|
|
31
|
+
const picomatch = await importPicomatch();
|
|
32
|
+
return picomatch.isMatch(path, pattern);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Create a reusable matcher function from one or more glob patterns.
|
|
36
|
+
*
|
|
37
|
+
* Prefer this over repeated {@link isMatch} calls when matching
|
|
38
|
+
* many paths against the same pattern—the compiled matcher is
|
|
39
|
+
* significantly faster for repeated use.
|
|
40
|
+
*
|
|
41
|
+
* Requires the `picomatch` peer dependency to be installed.
|
|
42
|
+
*
|
|
43
|
+
* @param pattern - One or more glob patterns
|
|
44
|
+
* @returns A function that tests a path against the compiled patterns
|
|
45
|
+
*/
|
|
46
|
+
export async function createMatcher(pattern) {
|
|
47
|
+
const picomatch = await importPicomatch();
|
|
48
|
+
return picomatch(pattern);
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=match.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"match.js","sourceRoot":"","sources":["../../src/glob/match.ts"],"names":[],"mappings":"AAEA,IAAI,gBAAgB,GAAyC,IAAI,CAAC;AAElE,SAAS,eAAe;IACtB,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,gBAAgB,GAAG,MAAM,CAAC,WAAW,CAAC;aACnC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,OAAO,IAAI,GAAG,CAAyB,CAAC;aAC3D,KAAK,CAAC,GAAG,EAAE;YACV,gBAAgB,GAAG,IAAI,CAAC;YACxB,MAAM,IAAI,KAAK,CACb,iEAAiE;gBAC/D,qCAAqC,CACxC,CAAC;QACJ,CAAC,CAAC,CAAC;IACP,CAAC;IACD,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,sBAAsB;IACpC,gBAAgB,GAAG,IAAI,CAAC;AAC1B,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAC3B,IAAY,EACZ,OAA0B;IAE1B,MAAM,SAAS,GAAG,MAAM,eAAe,EAAE,CAAC;IAC1C,OAAO,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAC1C,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,OAA0B;IAE1B,MAAM,SAAS,GAAG,MAAM,eAAe,EAAE,CAAC;IAC1C,OAAO,SAAS,CAAC,OAAO,CAAC,CAAC;AAC5B,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type { TypeGuard } from './types/guards.js';
|
|
2
|
+
export type { BaseMetadata, Config, ConfigValidationError, ConfigWithRoot, Example, ExampleFile, ExampleMetadata, ExampleMetadataRegistry, Extractor, ExtractorConfig, ExtractorConfigOrFunction, ExtractorError, ExtractorFactory, ExtractorOptions, ExtractorReference, ExtractorResult, FileContentsParser, FileParseContext, GenerateConfig, JSONSchemaObject, ParsedRegion, PathMapping, Plugin, PluginCommands, PluginRegistryInterface, PluginSchemaEntry, PluginSchemas, PluginValidatorEntry, PluginValidators, ResolvedConfig, ScanConfig, ScannedExample, ValidationError, ValidationResult, } from './types/index.js';
|
|
3
|
+
export { createMatcher, glob, isMatch, type GlobOptions, } from './glob/index.js';
|
|
4
|
+
export { JsonParseError, parseJson, tryParseJson } from './json/index.js';
|
|
5
|
+
export { parseYaml, tryParseYaml, YamlParseError } from './yaml/index.js';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,YAAY,EACV,YAAY,EACZ,MAAM,EACN,qBAAqB,EACrB,cAAc,EACd,OAAO,EACP,WAAW,EACX,eAAe,EACf,uBAAuB,EACvB,SAAS,EACT,eAAe,EACf,yBAAyB,EACzB,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,MAAM,EACN,cAAc,EACd,uBAAuB,EACvB,iBAAiB,EACjB,aAAa,EACb,oBAAoB,EACpB,gBAAgB,EAChB,cAAc,EACd,UAAU,EACV,cAAc,EACd,eAAe,EACf,gBAAgB,GACjB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,aAAa,EACb,IAAI,EACJ,OAAO,EACP,KAAK,WAAW,GACjB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE1E,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAuCA,OAAO,EACL,aAAa,EACb,IAAI,EACJ,OAAO,GAER,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE1E,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export interface JsonParseErrorOptions {
|
|
2
|
+
content: string;
|
|
3
|
+
error: Error;
|
|
4
|
+
filePath?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface FormattedJsonError {
|
|
7
|
+
message: string;
|
|
8
|
+
line?: number;
|
|
9
|
+
column?: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Converts a character offset in a string to 1-based line and column numbers.
|
|
13
|
+
*/
|
|
14
|
+
export declare function positionToLineColumn(content: string, offset: number): {
|
|
15
|
+
line: number;
|
|
16
|
+
column: number;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Attempts to extract line/column information from a JSON parse error.
|
|
20
|
+
*
|
|
21
|
+
* Checks for:
|
|
22
|
+
* 1. json5-style errors with `lineNumber`/`columnNumber` properties
|
|
23
|
+
* 2. Node.js JSON.parse errors with "at line X column Y"
|
|
24
|
+
* 3. Node.js JSON.parse errors with "at position N" (converted via positionToLineColumn)
|
|
25
|
+
*/
|
|
26
|
+
export declare function extractErrorPosition(error: Error, content?: string): {
|
|
27
|
+
line?: number;
|
|
28
|
+
column?: number;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Builds a code frame showing context around an error location.
|
|
32
|
+
*
|
|
33
|
+
* Shows approximately 2 lines before and after the error line,
|
|
34
|
+
* with a `>` marker on the error line and a `^` pointer at the column.
|
|
35
|
+
*/
|
|
36
|
+
export declare function buildCodeFrame(content: string, line: number, column?: number): string;
|
|
37
|
+
/**
|
|
38
|
+
* Formats a JSON parse error into a readable message with code frame.
|
|
39
|
+
*/
|
|
40
|
+
export declare function formatJsonError(options: JsonParseErrorOptions): FormattedJsonError;
|
|
41
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/json/errors.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,GACb;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAQlC;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,KAAK,EACZ,OAAO,CAAC,EAAE,MAAM,GACf;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAgCpC;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,MAAM,GACd,MAAM,CAyBR;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,qBAAqB,GAC7B,kBAAkB,CA2BpB"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a character offset in a string to 1-based line and column numbers.
|
|
3
|
+
*/
|
|
4
|
+
export function positionToLineColumn(content, offset) {
|
|
5
|
+
const clamped = Math.max(0, Math.min(offset, content.length));
|
|
6
|
+
const before = content.slice(0, clamped);
|
|
7
|
+
const lines = before.split('\n');
|
|
8
|
+
return {
|
|
9
|
+
line: lines.length,
|
|
10
|
+
column: lines[lines.length - 1].length + 1,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Attempts to extract line/column information from a JSON parse error.
|
|
15
|
+
*
|
|
16
|
+
* Checks for:
|
|
17
|
+
* 1. json5-style errors with `lineNumber`/`columnNumber` properties
|
|
18
|
+
* 2. Node.js JSON.parse errors with "at line X column Y"
|
|
19
|
+
* 3. Node.js JSON.parse errors with "at position N" (converted via positionToLineColumn)
|
|
20
|
+
*/
|
|
21
|
+
export function extractErrorPosition(error, content) {
|
|
22
|
+
// json5 errors have lineNumber and columnNumber
|
|
23
|
+
const errorRecord = error;
|
|
24
|
+
if (typeof errorRecord['lineNumber'] === 'number' &&
|
|
25
|
+
typeof errorRecord['columnNumber'] === 'number') {
|
|
26
|
+
return {
|
|
27
|
+
line: errorRecord['lineNumber'],
|
|
28
|
+
column: errorRecord['columnNumber'],
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
const message = error.message;
|
|
32
|
+
// Node.js "at line X column Y"
|
|
33
|
+
const lineColMatch = message.match(/at line (\d+) column (\d+)/);
|
|
34
|
+
if (lineColMatch) {
|
|
35
|
+
return {
|
|
36
|
+
line: parseInt(lineColMatch[1], 10),
|
|
37
|
+
column: parseInt(lineColMatch[2], 10),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
// Node.js "at position N"
|
|
41
|
+
const posMatch = message.match(/at position (\d+)/);
|
|
42
|
+
if (posMatch && content) {
|
|
43
|
+
const offset = parseInt(posMatch[1], 10);
|
|
44
|
+
return positionToLineColumn(content, offset);
|
|
45
|
+
}
|
|
46
|
+
return {};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Builds a code frame showing context around an error location.
|
|
50
|
+
*
|
|
51
|
+
* Shows approximately 2 lines before and after the error line,
|
|
52
|
+
* with a `>` marker on the error line and a `^` pointer at the column.
|
|
53
|
+
*/
|
|
54
|
+
export function buildCodeFrame(content, line, column) {
|
|
55
|
+
const lines = content.split('\n');
|
|
56
|
+
const startLine = Math.max(1, line - 2);
|
|
57
|
+
const endLine = Math.min(lines.length, line + 2);
|
|
58
|
+
const gutterWidth = String(endLine).length;
|
|
59
|
+
const frameLines = [];
|
|
60
|
+
for (let i = startLine; i <= endLine; i++) {
|
|
61
|
+
const lineContent = lines[i - 1];
|
|
62
|
+
const lineNum = String(i).padStart(gutterWidth);
|
|
63
|
+
if (i === line) {
|
|
64
|
+
frameLines.push(`> ${lineNum} | ${lineContent}`);
|
|
65
|
+
if (column !== undefined) {
|
|
66
|
+
const padding = ' '.repeat(gutterWidth + 4 + column - 1);
|
|
67
|
+
frameLines.push(`${padding}^`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
frameLines.push(` ${lineNum} | ${lineContent}`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return frameLines.join('\n');
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Formats a JSON parse error into a readable message with code frame.
|
|
78
|
+
*/
|
|
79
|
+
export function formatJsonError(options) {
|
|
80
|
+
const { content, error, filePath } = options;
|
|
81
|
+
const { line, column } = extractErrorPosition(error, content);
|
|
82
|
+
let location = '';
|
|
83
|
+
if (filePath) {
|
|
84
|
+
location = filePath;
|
|
85
|
+
if (line !== undefined) {
|
|
86
|
+
location += `:${line}`;
|
|
87
|
+
if (column !== undefined) {
|
|
88
|
+
location += `:${column}`;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
const header = location
|
|
93
|
+
? `Failed to parse JSON (${location}): ${error.message}`
|
|
94
|
+
: `Failed to parse JSON: ${error.message}`;
|
|
95
|
+
let message = header;
|
|
96
|
+
if (line !== undefined) {
|
|
97
|
+
const frame = buildCodeFrame(content, line, column);
|
|
98
|
+
message += '\n\n' + frame;
|
|
99
|
+
}
|
|
100
|
+
return { message, line, column };
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/json/errors.ts"],"names":[],"mappings":"AAYA;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAClC,OAAe,EACf,MAAc;IAEd,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IAC9D,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;IACzC,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACjC,OAAO;QACL,IAAI,EAAE,KAAK,CAAC,MAAM;QAClB,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC;KAC3C,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB,CAClC,KAAY,EACZ,OAAgB;IAEhB,gDAAgD;IAChD,MAAM,WAAW,GAAG,KAA2C,CAAC;IAChE,IACE,OAAO,WAAW,CAAC,YAAY,CAAC,K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B,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;gBACzB,QAAQ,IAAI,IAAI,MAAM,EAAE,CAAC;YAC3B,CAAC;QACH,CAAC;IACH,CAAC;IAED,MAAM,MAAM,GAAG,QAAQ;QACrB,CAAC,CAAC,yBAAyB,QAAQ,MAAM,KAAK,CAAC,OAAO,EAAE;QACxD,CAAC,CAAC,yBAAyB,KAAK,CAAC,OAAO,EAAE,CAAC;IAE7C,IAAI,OAAO,GAAG,MAAM,CAAC;IAErB,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,MAAM,KAAK,GAAG,cAAc,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QACpD,OAAO,IAAI,MAAM,GAAG,KAAK,CAAC;IAC5B,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AACnC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/json/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,cAAc,EACd,eAAe,EACf,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,GACxB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,cAAc,EACd,SAAS,EACT,YAAY,GACb,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/json/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,cAAc,EACd,eAAe,GAGhB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,cAAc,EACd,SAAS,EACT,YAAY,GACb,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type FormattedJsonError } from './errors.js';
|
|
2
|
+
/**
|
|
3
|
+
* Error thrown when JSON parsing fails across all available parsers.
|
|
4
|
+
*/
|
|
5
|
+
export declare class JsonParseError extends Error {
|
|
6
|
+
readonly line?: number;
|
|
7
|
+
readonly column?: number;
|
|
8
|
+
readonly filePath?: string;
|
|
9
|
+
constructor(formatted: FormattedJsonError, filePath?: string);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Resets the cached import promises. Used for testing only.
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
export declare function _resetImportCache(): void;
|
|
16
|
+
/**
|
|
17
|
+
* Parses a JSON string with progressive fallbacks:
|
|
18
|
+
* 1. Standard JSON.parse
|
|
19
|
+
* 2. jsonc-parser (handles comments and trailing commas)
|
|
20
|
+
* 3. json5 (handles extended JSON5 syntax)
|
|
21
|
+
*
|
|
22
|
+
* If all parsers fail, throws a {@link JsonParseError} with a formatted
|
|
23
|
+
* code frame showing the error location.
|
|
24
|
+
*
|
|
25
|
+
* @param content - The JSON string to parse
|
|
26
|
+
* @param filePath - Optional file path for error messages
|
|
27
|
+
* @returns The parsed value
|
|
28
|
+
*/
|
|
29
|
+
export declare function parseJson<T = unknown>(content: string, filePath?: string): Promise<T>;
|
|
30
|
+
/**
|
|
31
|
+
* Wraps {@link parseJson} in a try/catch, returning a discriminated union
|
|
32
|
+
* indicating success or failure.
|
|
33
|
+
*
|
|
34
|
+
* @param content - The JSON string to parse
|
|
35
|
+
* @param filePath - Optional file path for error messages
|
|
36
|
+
* @returns A result object with either `{ success: true, data }` or `{ success: false, error }`
|
|
37
|
+
*/
|
|
38
|
+
export declare function tryParseJson<T = unknown>(content: string, filePath?: string): Promise<{
|
|
39
|
+
success: true;
|
|
40
|
+
data: T;
|
|
41
|
+
} | {
|
|
42
|
+
success: false;
|
|
43
|
+
error: JsonParseError;
|
|
44
|
+
}>;
|
|
45
|
+
//# sourceMappingURL=parse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/json/parse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEvE;;GAEG;AACH,qBAAa,cAAe,SAAQ,KAAK;IACvC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;gBAEf,SAAS,EAAE,kBAAkB,EAAE,QAAQ,CAAC,EAAE,MAAM;CAO7D;AAoBD;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,IAAI,CAGxC;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,SAAS,CAAC,CAAC,GAAG,OAAO,EACzC,OAAO,EAAE,MAAM,EACf,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,CAAC,CAAC,CAmDZ;AAED;;;;;;;GAOG;AACH,wBAAsB,YAAY,CAAC,CAAC,GAAG,OAAO,EAC5C,OAAO,EAAE,MAAM,EACf,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,CAAC,CAAA;CAAE,GAAG;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,cAAc,CAAA;CAAE,CAAC,CAgBjF"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { formatJsonError } from './errors.js';
|
|
2
|
+
/**
|
|
3
|
+
* Error thrown when JSON parsing fails across all available parsers.
|
|
4
|
+
*/
|
|
5
|
+
export class JsonParseError extends Error {
|
|
6
|
+
line;
|
|
7
|
+
column;
|
|
8
|
+
filePath;
|
|
9
|
+
constructor(formatted, filePath) {
|
|
10
|
+
super(formatted.message);
|
|
11
|
+
this.name = 'JsonParseError';
|
|
12
|
+
this.line = formatted.line;
|
|
13
|
+
this.column = formatted.column;
|
|
14
|
+
this.filePath = filePath;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
let jsoncParserPromise = null;
|
|
18
|
+
let json5Promise = null;
|
|
19
|
+
function tryImportJsoncParser() {
|
|
20
|
+
if (!jsoncParserPromise) {
|
|
21
|
+
jsoncParserPromise = import('jsonc-parser').catch(() => null);
|
|
22
|
+
}
|
|
23
|
+
return jsoncParserPromise;
|
|
24
|
+
}
|
|
25
|
+
function tryImportJson5() {
|
|
26
|
+
if (!json5Promise) {
|
|
27
|
+
json5Promise = import('json5').catch(() => null);
|
|
28
|
+
}
|
|
29
|
+
return json5Promise;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Resets the cached import promises. Used for testing only.
|
|
33
|
+
* @internal
|
|
34
|
+
*/
|
|
35
|
+
export function _resetImportCache() {
|
|
36
|
+
jsoncParserPromise = null;
|
|
37
|
+
json5Promise = null;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Parses a JSON string with progressive fallbacks:
|
|
41
|
+
* 1. Standard JSON.parse
|
|
42
|
+
* 2. jsonc-parser (handles comments and trailing commas)
|
|
43
|
+
* 3. json5 (handles extended JSON5 syntax)
|
|
44
|
+
*
|
|
45
|
+
* If all parsers fail, throws a {@link JsonParseError} with a formatted
|
|
46
|
+
* code frame showing the error location.
|
|
47
|
+
*
|
|
48
|
+
* @param content - The JSON string to parse
|
|
49
|
+
* @param filePath - Optional file path for error messages
|
|
50
|
+
* @returns The parsed value
|
|
51
|
+
*/
|
|
52
|
+
export async function parseJson(content, filePath) {
|
|
53
|
+
// 1. Try standard JSON.parse
|
|
54
|
+
try {
|
|
55
|
+
return JSON.parse(content);
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
// Fall through to JSONC
|
|
59
|
+
}
|
|
60
|
+
// Track the best error for final reporting
|
|
61
|
+
let bestError;
|
|
62
|
+
// 2. Try jsonc-parser
|
|
63
|
+
const jsoncParser = await tryImportJsoncParser();
|
|
64
|
+
if (jsoncParser) {
|
|
65
|
+
const errors = [];
|
|
66
|
+
const result = jsoncParser.parse(content, errors, {
|
|
67
|
+
allowTrailingComma: true,
|
|
68
|
+
});
|
|
69
|
+
if (errors.length === 0) {
|
|
70
|
+
return result;
|
|
71
|
+
}
|
|
72
|
+
// Store JSONC error info for later
|
|
73
|
+
const firstError = errors[0];
|
|
74
|
+
bestError = new Error(`JSONC parse error at offset ${firstError.offset} (length ${firstError.length})`);
|
|
75
|
+
}
|
|
76
|
+
// 3. Try json5
|
|
77
|
+
const json5 = await tryImportJson5();
|
|
78
|
+
if (json5) {
|
|
79
|
+
try {
|
|
80
|
+
return json5.parse(content);
|
|
81
|
+
}
|
|
82
|
+
catch (e) {
|
|
83
|
+
bestError = e instanceof Error ? e : new Error(String(e));
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
// 4. Nothing worked - build the best error we can
|
|
87
|
+
if (!bestError) {
|
|
88
|
+
// Re-run JSON.parse to capture the original error
|
|
89
|
+
try {
|
|
90
|
+
JSON.parse(content);
|
|
91
|
+
}
|
|
92
|
+
catch (e) {
|
|
93
|
+
bestError = e instanceof Error ? e : new Error(String(e));
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const error = bestError ?? new Error('Failed to parse JSON');
|
|
97
|
+
const formatted = formatJsonError({ content, error, filePath });
|
|
98
|
+
throw new JsonParseError(formatted, filePath);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Wraps {@link parseJson} in a try/catch, returning a discriminated union
|
|
102
|
+
* indicating success or failure.
|
|
103
|
+
*
|
|
104
|
+
* @param content - The JSON string to parse
|
|
105
|
+
* @param filePath - Optional file path for error messages
|
|
106
|
+
* @returns A result object with either `{ success: true, data }` or `{ success: false, error }`
|
|
107
|
+
*/
|
|
108
|
+
export async function tryParseJson(content, filePath) {
|
|
109
|
+
try {
|
|
110
|
+
const data = await parseJson(content, filePath);
|
|
111
|
+
return { success: true, data };
|
|
112
|
+
}
|
|
113
|
+
catch (e) {
|
|
114
|
+
const error = e instanceof JsonParseError
|
|
115
|
+
? e
|
|
116
|
+
: new JsonParseError({
|
|
117
|
+
message: e instanceof Error ? e.message : String(e),
|
|
118
|
+
}, filePath);
|
|
119
|
+
return { success: false, error };
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=parse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.js","sourceRoot":"","sources":["../../src/json/parse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAA2B,MAAM,aAAa,CAAC;AAEvE;;GAEG;AACH,MAAM,OAAO,cAAe,SAAQ,KAAK;IAC9B,IAAI,CAAU;IACd,MAAM,CAAU;IAChB,QAAQ,CAAU;IAE3B,YAAY,SAA6B,EAAE,QAAiB;QAC1D,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QACzB,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC;QAC/B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;CACF;AAED,IAAI,kBAAkB,GACpB,IAAI,CAAC;AACP,IAAI,YAAY,GAAkD,IAAI,CAAC;AAEvE,SAAS,oBAAoB;IAC3B,IAAI,CAAC,kBAAkB,EAAE,CAAC;QACxB,kBAAkB,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;IAChE,CAAC;IACD,OAAO,kBAAkB,CAAC;AAC5B,CAAC;AAED,SAAS,cAAc;IACrB,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;IACnD,CAAC;IACD,OAAO,YAAY,CAAC;AACtB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iBAAiB;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types/guards.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,KAAK,GAAG,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guards.js","sourceRoot":"","sources":["../../src/types/guards.ts"],"names":[],"mappings":""}
|