@stryke/fs 0.33.72 → 0.33.74
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 +22 -0
- package/dist/copy-file.cjs +7 -8
- package/dist/copy-file.d.cts +1 -1
- package/dist/copy-file.d.mts +1 -1
- package/dist/copy-file.mjs +1 -2
- package/dist/copy-file.mjs.map +1 -1
- package/dist/get-parent-path.d.cts +1 -1
- package/dist/get-parent-path.d.cts.map +1 -1
- package/dist/get-parent-path.d.mts +1 -1
- package/dist/get-parent-path.d.mts.map +1 -1
- package/dist/get-workspace-root.d.cts +4 -4
- package/dist/get-workspace-root.d.mts +4 -4
- package/dist/json.cjs +9 -10
- package/dist/json.d.cts +1 -1
- package/dist/json.d.mts +1 -1
- package/dist/json.mjs +3 -4
- package/dist/json.mjs.map +1 -1
- package/dist/list-files.cjs +3 -4
- package/dist/list-files.d.cts +1 -1
- package/dist/list-files.d.mts +1 -1
- package/dist/list-files.mjs +1 -2
- package/dist/list-files.mjs.map +1 -1
- package/dist/package-fns.cjs +3 -3
- package/dist/package-fns.d.cts +4 -4
- package/dist/package-fns.d.cts.map +1 -1
- package/dist/package-fns.d.mts +4 -4
- package/dist/package-fns.d.mts.map +1 -1
- package/dist/package-fns.mjs +1 -1
- package/dist/semver-fns.cjs +6 -6
- package/dist/semver-fns.mjs +2 -2
- package/dist/tsconfig.cjs +1 -1
- package/dist/tsconfig.d.cts +1 -1
- package/dist/tsconfig.d.mts +1 -1
- package/dist/tsconfig.mjs +1 -1
- package/dist/tsconfig.mjs.map +1 -1
- package/package.json +10 -91
- package/dist/json/src/storm-json.cjs +0 -106
- package/dist/json/src/storm-json.mjs +0 -105
- package/dist/json/src/storm-json.mjs.map +0 -1
- package/dist/json/src/types.d.cts +0 -32
- package/dist/json/src/types.d.cts.map +0 -1
- package/dist/json/src/types.d.mts +0 -32
- package/dist/json/src/types.d.mts.map +0 -1
- package/dist/json/src/utils/code-frames.cjs +0 -77
- package/dist/json/src/utils/code-frames.mjs +0 -77
- package/dist/json/src/utils/code-frames.mjs.map +0 -1
- package/dist/json/src/utils/parse-error.cjs +0 -34
- package/dist/json/src/utils/parse-error.mjs +0 -34
- package/dist/json/src/utils/parse-error.mjs.map +0 -1
- package/dist/json/src/utils/parse.cjs +0 -45
- package/dist/json/src/utils/parse.mjs +0 -46
- package/dist/json/src/utils/parse.mjs.map +0 -1
- package/dist/json/src/utils/stringify.cjs +0 -33
- package/dist/json/src/utils/stringify.mjs +0 -34
- package/dist/json/src/utils/stringify.mjs.map +0 -1
- package/dist/json/src/utils/strip-comments.cjs +0 -85
- package/dist/json/src/utils/strip-comments.mjs +0 -85
- package/dist/json/src/utils/strip-comments.mjs.map +0 -1
- package/dist/type-checks/src/get-object-tag.cjs +0 -15
- package/dist/type-checks/src/get-object-tag.mjs +0 -15
- package/dist/type-checks/src/get-object-tag.mjs.map +0 -1
- package/dist/type-checks/src/index.cjs +0 -14
- package/dist/type-checks/src/index.mjs +0 -16
- package/dist/type-checks/src/is-buffer.cjs +0 -14
- package/dist/type-checks/src/is-buffer.mjs +0 -14
- package/dist/type-checks/src/is-buffer.mjs.map +0 -1
- package/dist/type-checks/src/is-collection.cjs +0 -1
- package/dist/type-checks/src/is-collection.mjs +0 -3
- package/dist/type-checks/src/is-empty.cjs +0 -20
- package/dist/type-checks/src/is-empty.mjs +0 -21
- package/dist/type-checks/src/is-empty.mjs.map +0 -1
- package/dist/type-checks/src/is-error.cjs +0 -29
- package/dist/type-checks/src/is-error.mjs +0 -30
- package/dist/type-checks/src/is-error.mjs.map +0 -1
- package/dist/type-checks/src/is-null.cjs +0 -12
- package/dist/type-checks/src/is-null.mjs +0 -12
- package/dist/type-checks/src/is-null.mjs.map +0 -1
- package/dist/type-checks/src/is-number.cjs +0 -18
- package/dist/type-checks/src/is-number.mjs +0 -18
- package/dist/type-checks/src/is-number.mjs.map +0 -1
- package/dist/type-checks/src/is-object.cjs +0 -19
- package/dist/type-checks/src/is-object.mjs +0 -20
- package/dist/type-checks/src/is-object.mjs.map +0 -1
- package/dist/type-checks/src/is-plain-object.cjs +0 -64
- package/dist/type-checks/src/is-plain-object.mjs +0 -64
- package/dist/type-checks/src/is-plain-object.mjs.map +0 -1
- package/dist/type-checks/src/is-set-string.cjs +0 -20
- package/dist/type-checks/src/is-set-string.mjs +0 -21
- package/dist/type-checks/src/is-set-string.mjs.map +0 -1
- package/dist/type-checks/src/is-set.cjs +0 -19
- package/dist/type-checks/src/is-set.mjs +0 -20
- package/dist/type-checks/src/is-set.mjs.map +0 -1
- package/dist/type-checks/src/is-string.cjs +0 -12
- package/dist/type-checks/src/is-string.mjs +0 -12
- package/dist/type-checks/src/is-string.mjs.map +0 -1
- package/dist/type-checks/src/is-undefined.cjs +0 -8
- package/dist/type-checks/src/is-undefined.mjs +0 -8
- package/dist/type-checks/src/is-undefined.mjs.map +0 -1
- package/dist/type-checks/src/type-detect.cjs +0 -15
- package/dist/type-checks/src/type-detect.mjs +0 -17
- package/dist/type-checks/src/type-detect.mjs.map +0 -1
- package/dist/types/src/file.d.cts +0 -31
- package/dist/types/src/file.d.cts.map +0 -1
- package/dist/types/src/file.d.mts +0 -31
- package/dist/types/src/file.d.mts.map +0 -1
- package/dist/types/src/package-json.d.cts +0 -261
- package/dist/types/src/package-json.d.cts.map +0 -1
- package/dist/types/src/package-json.d.mts +0 -261
- package/dist/types/src/package-json.d.mts.map +0 -1
- package/dist/types/src/package-manager.d.cts +0 -5
- package/dist/types/src/package-manager.d.cts.map +0 -1
- package/dist/types/src/package-manager.d.mts +0 -5
- package/dist/types/src/package-manager.d.mts.map +0 -1
- package/dist/types/src/tsconfig.d.cts +0 -803
- package/dist/types/src/tsconfig.d.cts.map +0 -1
- package/dist/types/src/tsconfig.d.mts +0 -803
- package/dist/types/src/tsconfig.d.mts.map +0 -1
package/dist/semver-fns.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
|
|
4
|
-
const require_is_string = require('./type-checks/src/is-string.cjs');
|
|
3
|
+
let _stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
|
|
5
4
|
let semver = require("semver");
|
|
5
|
+
let _stryke_type_checks_is_object = require("@stryke/type-checks/is-object");
|
|
6
6
|
|
|
7
7
|
//#region src/semver-fns.ts
|
|
8
8
|
const RELEASE_TYPES = [
|
|
@@ -40,7 +40,7 @@ const coerceVersion = (version, options) => {
|
|
|
40
40
|
* @returns Whether the value is a valid {@link SemVer}
|
|
41
41
|
*/
|
|
42
42
|
const isSemver = (val) => {
|
|
43
|
-
return
|
|
43
|
+
return (0, _stryke_type_checks_is_object.isObject)(val) && "version" in val;
|
|
44
44
|
};
|
|
45
45
|
/**
|
|
46
46
|
* Type check for {@link Range}
|
|
@@ -49,7 +49,7 @@ const isSemver = (val) => {
|
|
|
49
49
|
* @returns Whether the value is a valid {@link Range}
|
|
50
50
|
*/
|
|
51
51
|
const isRange = (val) => {
|
|
52
|
-
return
|
|
52
|
+
return (0, _stryke_type_checks_is_object.isObject)(val) && "range" in val;
|
|
53
53
|
};
|
|
54
54
|
/**
|
|
55
55
|
* Check if a {@link SemVer} string is valid
|
|
@@ -62,7 +62,7 @@ const isRange = (val) => {
|
|
|
62
62
|
* @returns Whether the semver string is valid
|
|
63
63
|
*/
|
|
64
64
|
const isValidSemver = (semver$2, loose = true) => {
|
|
65
|
-
return (
|
|
65
|
+
return ((0, _stryke_type_checks_is_string.isString)(semver$2) || isSemver(semver$2)) && (0, semver.valid)(semver$2, loose) !== null;
|
|
66
66
|
};
|
|
67
67
|
/**
|
|
68
68
|
* Check if a {@link Range} string is valid
|
|
@@ -75,7 +75,7 @@ const isValidSemver = (semver$2, loose = true) => {
|
|
|
75
75
|
* @returns Whether the range string is valid
|
|
76
76
|
*/
|
|
77
77
|
const isValidRange = (range, loose = true) => {
|
|
78
|
-
return (
|
|
78
|
+
return ((0, _stryke_type_checks_is_string.isString)(range) || isRange(range)) && (0, semver.validRange)(range, loose) !== null;
|
|
79
79
|
};
|
|
80
80
|
/**
|
|
81
81
|
* Check if a {@link SemVer} or {@link Range} string is valid
|
package/dist/semver-fns.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { isString } from "./type-checks/src/is-string.mjs";
|
|
1
|
+
import { isString } from "@stryke/type-checks/is-string";
|
|
3
2
|
import { coerce, inc, parse, satisfies, valid, validRange } from "semver";
|
|
3
|
+
import { isObject } from "@stryke/type-checks/is-object";
|
|
4
4
|
|
|
5
5
|
//#region src/semver-fns.ts
|
|
6
6
|
const RELEASE_TYPES = [
|
package/dist/tsconfig.cjs
CHANGED
|
@@ -25,7 +25,7 @@ async function loadTsConfig(filePath = (0, _stryke_path_cwd.cwd)()) {
|
|
|
25
25
|
if (!require_exists.existsSync(tsconfigFilePath)) throw new Error(`tsconfig.json not found at ${tsconfigFilePath}. Please ensure the file exists.`);
|
|
26
26
|
}
|
|
27
27
|
let config = await require_json.readJsonFile(tsconfigFilePath);
|
|
28
|
-
if (config?.compilerOptions?.
|
|
28
|
+
if (config?.compilerOptions?.rootDir) config.compilerOptions.rootDir = (0, _stryke_path_join_paths.joinPaths)((0, _stryke_path_file_path_fns.findFilePath)(tsconfigFilePath), config.compilerOptions.rootDir);
|
|
29
29
|
if (config?.extends) for (const extendsName of (0, _stryke_convert_to_array.toArray)(config.extends)) {
|
|
30
30
|
const parentConfig = await loadTsConfig((0, _stryke_path_is_type.isNpmScopedPackage)(extendsName) ? extendsName : (0, _stryke_path_join_paths.joinPaths)((0, _stryke_path_file_path_fns.findFilePath)(tsconfigFilePath), extendsName));
|
|
31
31
|
if (parentConfig) config = (0, defu.default)(config, parentConfig ?? {});
|
package/dist/tsconfig.d.cts
CHANGED
package/dist/tsconfig.d.mts
CHANGED
package/dist/tsconfig.mjs
CHANGED
|
@@ -22,7 +22,7 @@ async function loadTsConfig(filePath = cwd()) {
|
|
|
22
22
|
if (!existsSync(tsconfigFilePath)) throw new Error(`tsconfig.json not found at ${tsconfigFilePath}. Please ensure the file exists.`);
|
|
23
23
|
}
|
|
24
24
|
let config = await readJsonFile(tsconfigFilePath);
|
|
25
|
-
if (config?.compilerOptions?.
|
|
25
|
+
if (config?.compilerOptions?.rootDir) config.compilerOptions.rootDir = joinPaths(findFilePath(tsconfigFilePath), config.compilerOptions.rootDir);
|
|
26
26
|
if (config?.extends) for (const extendsName of toArray(config.extends)) {
|
|
27
27
|
const parentConfig = await loadTsConfig(isNpmScopedPackage(extendsName) ? extendsName : joinPaths(findFilePath(tsconfigFilePath), extendsName));
|
|
28
28
|
if (parentConfig) config = defu(config, parentConfig ?? {});
|
package/dist/tsconfig.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tsconfig.mjs","names":[],"sources":["../src/tsconfig.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { cwd } from \"@stryke/path/cwd\";\nimport { findFileExtension, findFilePath } from \"@stryke/path/file-path-fns\";\nimport { isNpmScopedPackage } from \"@stryke/path/is-type\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport type { TsConfigJson } from \"@stryke/types/tsconfig\";\nimport defu from \"defu\";\nimport { existsSync } from \"./exists\";\nimport { readJsonFile } from \"./json\";\nimport { resolve } from \"./resolve\";\n\n/**\n * Loads a tsconfig.json file and returns the parsed JSON object.\n *\n * @param filePath - The directory to start searching for the tsconfig.json file.\n * @returns The parsed tsconfig.json object or null if not found.\n */\nexport async function loadTsConfig(\n filePath: string = cwd()\n): Promise<TsConfigJson> {\n let tsconfigFilePath =\n findFileExtension(filePath) === \"json\"\n ? filePath\n : joinPaths(filePath, \"tsconfig.json\");\n if (!existsSync(tsconfigFilePath)) {\n tsconfigFilePath = await resolve(filePath, { extensions: [\"json\"] });\n if (!existsSync(tsconfigFilePath)) {\n throw new Error(\n `tsconfig.json not found at ${tsconfigFilePath}. Please ensure the file exists.`\n );\n }\n }\n\n let config = await readJsonFile<TsConfigJson>(tsconfigFilePath);\n if (config?.compilerOptions?.
|
|
1
|
+
{"version":3,"file":"tsconfig.mjs","names":[],"sources":["../src/tsconfig.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { cwd } from \"@stryke/path/cwd\";\nimport { findFileExtension, findFilePath } from \"@stryke/path/file-path-fns\";\nimport { isNpmScopedPackage } from \"@stryke/path/is-type\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport type { TsConfigJson } from \"@stryke/types/tsconfig\";\nimport defu from \"defu\";\nimport { existsSync } from \"./exists\";\nimport { readJsonFile } from \"./json\";\nimport { resolve } from \"./resolve\";\n\n/**\n * Loads a tsconfig.json file and returns the parsed JSON object.\n *\n * @param filePath - The directory to start searching for the tsconfig.json file.\n * @returns The parsed tsconfig.json object or null if not found.\n */\nexport async function loadTsConfig(\n filePath: string = cwd()\n): Promise<TsConfigJson> {\n let tsconfigFilePath =\n findFileExtension(filePath) === \"json\"\n ? filePath\n : joinPaths(filePath, \"tsconfig.json\");\n if (!existsSync(tsconfigFilePath)) {\n tsconfigFilePath = await resolve(filePath, { extensions: [\"json\"] });\n if (!existsSync(tsconfigFilePath)) {\n throw new Error(\n `tsconfig.json not found at ${tsconfigFilePath}. Please ensure the file exists.`\n );\n }\n }\n\n let config = await readJsonFile<TsConfigJson>(tsconfigFilePath);\n if (config?.compilerOptions?.rootDir) {\n config.compilerOptions.rootDir = joinPaths(\n findFilePath(tsconfigFilePath),\n config.compilerOptions.rootDir\n );\n }\n\n if (config?.extends) {\n for (const extendsName of toArray(config.extends)) {\n const parentConfig = await loadTsConfig(\n isNpmScopedPackage(extendsName)\n ? extendsName\n : joinPaths(findFilePath(tsconfigFilePath), extendsName)\n );\n if (parentConfig) {\n config = defu(config, parentConfig ?? {});\n }\n }\n }\n\n config.extends = undefined;\n return config;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAmCA,eAAsB,aACpB,WAAmB,KAAK,EACD;CACvB,IAAI,mBACF,kBAAkB,SAAS,KAAK,SAC5B,WACA,UAAU,UAAU,gBAAgB;AAC1C,KAAI,CAAC,WAAW,iBAAiB,EAAE;AACjC,qBAAmB,MAAM,QAAQ,UAAU,EAAE,YAAY,CAAC,OAAO,EAAE,CAAC;AACpE,MAAI,CAAC,WAAW,iBAAiB,CAC/B,OAAM,IAAI,MACR,8BAA8B,iBAAiB,kCAChD;;CAIL,IAAI,SAAS,MAAM,aAA2B,iBAAiB;AAC/D,KAAI,QAAQ,iBAAiB,QAC3B,QAAO,gBAAgB,UAAU,UAC/B,aAAa,iBAAiB,EAC9B,OAAO,gBAAgB,QACxB;AAGH,KAAI,QAAQ,QACV,MAAK,MAAM,eAAe,QAAQ,OAAO,QAAQ,EAAE;EACjD,MAAM,eAAe,MAAM,aACzB,mBAAmB,YAAY,GAC3B,cACA,UAAU,aAAa,iBAAiB,EAAE,YAAY,CAC3D;AACD,MAAI,aACF,UAAS,KAAK,QAAQ,gBAAgB,EAAE,CAAC;;AAK/C,QAAO,UAAU;AACjB,QAAO"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stryke/fs",
|
|
3
|
-
"version": "0.33.
|
|
3
|
+
"version": "0.33.74",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A package containing various file system utilities that expand the functionality of NodeJs's built-in `fs` module.",
|
|
6
6
|
"repository": {
|
|
@@ -60,30 +60,6 @@
|
|
|
60
60
|
"require": "./dist/is-file.cjs"
|
|
61
61
|
},
|
|
62
62
|
"./json": { "import": "./dist/json.mjs", "require": "./dist/json.cjs" },
|
|
63
|
-
"./json/src/storm-json": {
|
|
64
|
-
"import": "./dist/json/src/storm-json.mjs",
|
|
65
|
-
"require": "./dist/json/src/storm-json.cjs"
|
|
66
|
-
},
|
|
67
|
-
"./json/src/utils/code-frames": {
|
|
68
|
-
"import": "./dist/json/src/utils/code-frames.mjs",
|
|
69
|
-
"require": "./dist/json/src/utils/code-frames.cjs"
|
|
70
|
-
},
|
|
71
|
-
"./json/src/utils/parse": {
|
|
72
|
-
"import": "./dist/json/src/utils/parse.mjs",
|
|
73
|
-
"require": "./dist/json/src/utils/parse.cjs"
|
|
74
|
-
},
|
|
75
|
-
"./json/src/utils/parse-error": {
|
|
76
|
-
"import": "./dist/json/src/utils/parse-error.mjs",
|
|
77
|
-
"require": "./dist/json/src/utils/parse-error.cjs"
|
|
78
|
-
},
|
|
79
|
-
"./json/src/utils/stringify": {
|
|
80
|
-
"import": "./dist/json/src/utils/stringify.mjs",
|
|
81
|
-
"require": "./dist/json/src/utils/stringify.cjs"
|
|
82
|
-
},
|
|
83
|
-
"./json/src/utils/strip-comments": {
|
|
84
|
-
"import": "./dist/json/src/utils/strip-comments.mjs",
|
|
85
|
-
"require": "./dist/json/src/utils/strip-comments.cjs"
|
|
86
|
-
},
|
|
87
63
|
"./list-files": {
|
|
88
64
|
"import": "./dist/list-files.mjs",
|
|
89
65
|
"require": "./dist/list-files.cjs"
|
|
@@ -117,66 +93,6 @@
|
|
|
117
93
|
"import": "./dist/tsconfig.mjs",
|
|
118
94
|
"require": "./dist/tsconfig.cjs"
|
|
119
95
|
},
|
|
120
|
-
"./type-checks/src": {
|
|
121
|
-
"import": "./dist/type-checks/src/index.mjs",
|
|
122
|
-
"require": "./dist/type-checks/src/index.cjs"
|
|
123
|
-
},
|
|
124
|
-
"./type-checks/src/get-object-tag": {
|
|
125
|
-
"import": "./dist/type-checks/src/get-object-tag.mjs",
|
|
126
|
-
"require": "./dist/type-checks/src/get-object-tag.cjs"
|
|
127
|
-
},
|
|
128
|
-
"./type-checks/src/is-buffer": {
|
|
129
|
-
"import": "./dist/type-checks/src/is-buffer.mjs",
|
|
130
|
-
"require": "./dist/type-checks/src/is-buffer.cjs"
|
|
131
|
-
},
|
|
132
|
-
"./type-checks/src/is-collection": {
|
|
133
|
-
"import": "./dist/type-checks/src/is-collection.mjs",
|
|
134
|
-
"require": "./dist/type-checks/src/is-collection.cjs"
|
|
135
|
-
},
|
|
136
|
-
"./type-checks/src/is-empty": {
|
|
137
|
-
"import": "./dist/type-checks/src/is-empty.mjs",
|
|
138
|
-
"require": "./dist/type-checks/src/is-empty.cjs"
|
|
139
|
-
},
|
|
140
|
-
"./type-checks/src/is-error": {
|
|
141
|
-
"import": "./dist/type-checks/src/is-error.mjs",
|
|
142
|
-
"require": "./dist/type-checks/src/is-error.cjs"
|
|
143
|
-
},
|
|
144
|
-
"./type-checks/src/is-null": {
|
|
145
|
-
"import": "./dist/type-checks/src/is-null.mjs",
|
|
146
|
-
"require": "./dist/type-checks/src/is-null.cjs"
|
|
147
|
-
},
|
|
148
|
-
"./type-checks/src/is-number": {
|
|
149
|
-
"import": "./dist/type-checks/src/is-number.mjs",
|
|
150
|
-
"require": "./dist/type-checks/src/is-number.cjs"
|
|
151
|
-
},
|
|
152
|
-
"./type-checks/src/is-object": {
|
|
153
|
-
"import": "./dist/type-checks/src/is-object.mjs",
|
|
154
|
-
"require": "./dist/type-checks/src/is-object.cjs"
|
|
155
|
-
},
|
|
156
|
-
"./type-checks/src/is-plain-object": {
|
|
157
|
-
"import": "./dist/type-checks/src/is-plain-object.mjs",
|
|
158
|
-
"require": "./dist/type-checks/src/is-plain-object.cjs"
|
|
159
|
-
},
|
|
160
|
-
"./type-checks/src/is-set": {
|
|
161
|
-
"import": "./dist/type-checks/src/is-set.mjs",
|
|
162
|
-
"require": "./dist/type-checks/src/is-set.cjs"
|
|
163
|
-
},
|
|
164
|
-
"./type-checks/src/is-set-string": {
|
|
165
|
-
"import": "./dist/type-checks/src/is-set-string.mjs",
|
|
166
|
-
"require": "./dist/type-checks/src/is-set-string.cjs"
|
|
167
|
-
},
|
|
168
|
-
"./type-checks/src/is-string": {
|
|
169
|
-
"import": "./dist/type-checks/src/is-string.mjs",
|
|
170
|
-
"require": "./dist/type-checks/src/is-string.cjs"
|
|
171
|
-
},
|
|
172
|
-
"./type-checks/src/is-undefined": {
|
|
173
|
-
"import": "./dist/type-checks/src/is-undefined.mjs",
|
|
174
|
-
"require": "./dist/type-checks/src/is-undefined.cjs"
|
|
175
|
-
},
|
|
176
|
-
"./type-checks/src/type-detect": {
|
|
177
|
-
"import": "./dist/type-checks/src/type-detect.mjs",
|
|
178
|
-
"require": "./dist/type-checks/src/type-detect.cjs"
|
|
179
|
-
},
|
|
180
96
|
"./write-file": {
|
|
181
97
|
"import": "./dist/write-file.mjs",
|
|
182
98
|
"require": "./dist/write-file.cjs"
|
|
@@ -190,10 +106,13 @@
|
|
|
190
106
|
"dependencies": {
|
|
191
107
|
"@antfu/install-pkg": "^1.1.0",
|
|
192
108
|
"@storm-software/config-tools": "^1.190.1",
|
|
193
|
-
"@stryke/convert": "^0.7.
|
|
194
|
-
"@stryke/helpers": "^0.10.
|
|
195
|
-
"@stryke/
|
|
196
|
-
"@stryke/
|
|
109
|
+
"@stryke/convert": "^0.7.5",
|
|
110
|
+
"@stryke/helpers": "^0.10.14",
|
|
111
|
+
"@stryke/json": "^0.14.19",
|
|
112
|
+
"@stryke/path": "^0.29.1",
|
|
113
|
+
"@stryke/string-format": "^0.17.16",
|
|
114
|
+
"@stryke/type-checks": "^0.6.7",
|
|
115
|
+
"@stryke/types": "^0.12.2",
|
|
197
116
|
"chalk": "^5.6.2",
|
|
198
117
|
"defu": "^6.1.7",
|
|
199
118
|
"glob": "^11.1.0",
|
|
@@ -205,10 +124,10 @@
|
|
|
205
124
|
"yaml": "^2.8.4"
|
|
206
125
|
},
|
|
207
126
|
"devDependencies": {
|
|
208
|
-
"@types/node": "^24.12.
|
|
127
|
+
"@types/node": "^24.12.3",
|
|
209
128
|
"@types/semver": "^7.7.1",
|
|
210
129
|
"tsdown": "^0.21.10"
|
|
211
130
|
},
|
|
212
131
|
"publishConfig": { "access": "public" },
|
|
213
|
-
"gitHead": "
|
|
132
|
+
"gitHead": "76bff7658acfdbaec6928e3df6e66b53db308be2"
|
|
214
133
|
}
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
|
|
2
|
-
const require_is_object = require('../../type-checks/src/is-object.cjs');
|
|
3
|
-
const require_is_string = require('../../type-checks/src/is-string.cjs');
|
|
4
|
-
const require_parse = require('./utils/parse.cjs');
|
|
5
|
-
const require_parse_error = require('./utils/parse-error.cjs');
|
|
6
|
-
const require_stringify = require('./utils/stringify.cjs');
|
|
7
|
-
let node_buffer = require("node:buffer");
|
|
8
|
-
let jsonc_parser = require("jsonc-parser");
|
|
9
|
-
let superjson = require("superjson");
|
|
10
|
-
superjson = require_runtime.__toESM(superjson, 1);
|
|
11
|
-
|
|
12
|
-
//#region ../json/src/storm-json.ts
|
|
13
|
-
/**
|
|
14
|
-
* A static JSON parser class used by Storm Software to serialize and deserialize JSON data
|
|
15
|
-
*
|
|
16
|
-
* @remarks
|
|
17
|
-
* This class uses the [SuperJSON](https://github.com/blitz-js/superjson) library under the hood.
|
|
18
|
-
*/
|
|
19
|
-
var StormJSON = class StormJSON extends superjson.default {
|
|
20
|
-
static #instance;
|
|
21
|
-
static get instance() {
|
|
22
|
-
if (!StormJSON.#instance) StormJSON.#instance = new StormJSON();
|
|
23
|
-
return StormJSON.#instance;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Deserialize the given value with superjson using the given metadata
|
|
27
|
-
*/
|
|
28
|
-
static deserialize(payload) {
|
|
29
|
-
return StormJSON.instance.deserialize(payload);
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Serialize the given value with superjson
|
|
33
|
-
*/
|
|
34
|
-
static serialize(object) {
|
|
35
|
-
return StormJSON.instance.serialize(object);
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Parse the given string value with superjson using the given metadata
|
|
39
|
-
*
|
|
40
|
-
* @param value - The string value to parse
|
|
41
|
-
* @returns The parsed data
|
|
42
|
-
*/
|
|
43
|
-
static parse(value, options = {}) {
|
|
44
|
-
try {
|
|
45
|
-
if (options.expectComments === false) return require_parse.parse(value);
|
|
46
|
-
} catch {}
|
|
47
|
-
const errors = [];
|
|
48
|
-
const result = (0, jsonc_parser.parse)(value, errors, {
|
|
49
|
-
allowTrailingComma: true,
|
|
50
|
-
...options
|
|
51
|
-
});
|
|
52
|
-
if (errors.length > 0 && errors[0]) throw new Error(require_parse_error.formatParseError(value, errors[0]));
|
|
53
|
-
return result;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Serializes the given data to a JSON string.
|
|
57
|
-
* By default the JSON string is formatted with a 2 space indentation to be easy readable.
|
|
58
|
-
*
|
|
59
|
-
* @param value - Object which should be serialized to JSON
|
|
60
|
-
* @param options - JSON serialize options
|
|
61
|
-
* @returns the formatted JSON representation of the object
|
|
62
|
-
*/
|
|
63
|
-
static stringify(value, options) {
|
|
64
|
-
const customTransformer = StormJSON.instance.customTransformerRegistry.findApplicable(value);
|
|
65
|
-
let result = value;
|
|
66
|
-
if (customTransformer && customTransformer.isApplicable(value)) result = customTransformer.serialize(result);
|
|
67
|
-
return require_stringify.stringify(result, options?.spaces ?? 2);
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Register a custom schema with superjson
|
|
71
|
-
*
|
|
72
|
-
* @param name - The name of the schema
|
|
73
|
-
* @param serialize - The function to serialize the schema
|
|
74
|
-
* @param deserialize - The function to deserialize the schema
|
|
75
|
-
* @param isApplicable - The function to check if the schema is applicable
|
|
76
|
-
*/
|
|
77
|
-
static register(name, serialize, deserialize, isApplicable) {
|
|
78
|
-
StormJSON.instance.registerCustom({
|
|
79
|
-
isApplicable,
|
|
80
|
-
serialize,
|
|
81
|
-
deserialize
|
|
82
|
-
}, name);
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Register a class with superjson
|
|
86
|
-
*
|
|
87
|
-
* @param classConstructor - The class constructor to register
|
|
88
|
-
*/
|
|
89
|
-
static registerClass(classConstructor, options) {
|
|
90
|
-
StormJSON.instance.registerClass(classConstructor, {
|
|
91
|
-
identifier: require_is_string.isString(options) ? options : options?.identifier || classConstructor.name,
|
|
92
|
-
allowProps: options && require_is_object.isObject(options) && options?.allowProps && Array.isArray(options.allowProps) ? options.allowProps : ["__typename"]
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
constructor() {
|
|
96
|
-
super({ dedupe: true });
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
StormJSON.instance.registerCustom({
|
|
100
|
-
isApplicable: (v) => typeof node_buffer.Buffer.isBuffer === "function" && node_buffer.Buffer.isBuffer(v),
|
|
101
|
-
serialize: (v) => v.toString("base64"),
|
|
102
|
-
deserialize: (v) => node_buffer.Buffer.from(v, "base64")
|
|
103
|
-
}, "Bytes");
|
|
104
|
-
|
|
105
|
-
//#endregion
|
|
106
|
-
exports.StormJSON = StormJSON;
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { isObject } from "../../type-checks/src/is-object.mjs";
|
|
2
|
-
import { isString } from "../../type-checks/src/is-string.mjs";
|
|
3
|
-
import { parse as parse$1 } from "./utils/parse.mjs";
|
|
4
|
-
import { formatParseError } from "./utils/parse-error.mjs";
|
|
5
|
-
import { stringify } from "./utils/stringify.mjs";
|
|
6
|
-
import { Buffer } from "node:buffer";
|
|
7
|
-
import { parse } from "jsonc-parser";
|
|
8
|
-
import SuperJSON from "superjson";
|
|
9
|
-
|
|
10
|
-
//#region ../json/src/storm-json.ts
|
|
11
|
-
/**
|
|
12
|
-
* A static JSON parser class used by Storm Software to serialize and deserialize JSON data
|
|
13
|
-
*
|
|
14
|
-
* @remarks
|
|
15
|
-
* This class uses the [SuperJSON](https://github.com/blitz-js/superjson) library under the hood.
|
|
16
|
-
*/
|
|
17
|
-
var StormJSON = class StormJSON extends SuperJSON {
|
|
18
|
-
static #instance;
|
|
19
|
-
static get instance() {
|
|
20
|
-
if (!StormJSON.#instance) StormJSON.#instance = new StormJSON();
|
|
21
|
-
return StormJSON.#instance;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Deserialize the given value with superjson using the given metadata
|
|
25
|
-
*/
|
|
26
|
-
static deserialize(payload) {
|
|
27
|
-
return StormJSON.instance.deserialize(payload);
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Serialize the given value with superjson
|
|
31
|
-
*/
|
|
32
|
-
static serialize(object) {
|
|
33
|
-
return StormJSON.instance.serialize(object);
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Parse the given string value with superjson using the given metadata
|
|
37
|
-
*
|
|
38
|
-
* @param value - The string value to parse
|
|
39
|
-
* @returns The parsed data
|
|
40
|
-
*/
|
|
41
|
-
static parse(value, options = {}) {
|
|
42
|
-
try {
|
|
43
|
-
if (options.expectComments === false) return parse$1(value);
|
|
44
|
-
} catch {}
|
|
45
|
-
const errors = [];
|
|
46
|
-
const result = parse(value, errors, {
|
|
47
|
-
allowTrailingComma: true,
|
|
48
|
-
...options
|
|
49
|
-
});
|
|
50
|
-
if (errors.length > 0 && errors[0]) throw new Error(formatParseError(value, errors[0]));
|
|
51
|
-
return result;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Serializes the given data to a JSON string.
|
|
55
|
-
* By default the JSON string is formatted with a 2 space indentation to be easy readable.
|
|
56
|
-
*
|
|
57
|
-
* @param value - Object which should be serialized to JSON
|
|
58
|
-
* @param options - JSON serialize options
|
|
59
|
-
* @returns the formatted JSON representation of the object
|
|
60
|
-
*/
|
|
61
|
-
static stringify(value, options) {
|
|
62
|
-
const customTransformer = StormJSON.instance.customTransformerRegistry.findApplicable(value);
|
|
63
|
-
let result = value;
|
|
64
|
-
if (customTransformer && customTransformer.isApplicable(value)) result = customTransformer.serialize(result);
|
|
65
|
-
return stringify(result, options?.spaces ?? 2);
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Register a custom schema with superjson
|
|
69
|
-
*
|
|
70
|
-
* @param name - The name of the schema
|
|
71
|
-
* @param serialize - The function to serialize the schema
|
|
72
|
-
* @param deserialize - The function to deserialize the schema
|
|
73
|
-
* @param isApplicable - The function to check if the schema is applicable
|
|
74
|
-
*/
|
|
75
|
-
static register(name, serialize, deserialize, isApplicable) {
|
|
76
|
-
StormJSON.instance.registerCustom({
|
|
77
|
-
isApplicable,
|
|
78
|
-
serialize,
|
|
79
|
-
deserialize
|
|
80
|
-
}, name);
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Register a class with superjson
|
|
84
|
-
*
|
|
85
|
-
* @param classConstructor - The class constructor to register
|
|
86
|
-
*/
|
|
87
|
-
static registerClass(classConstructor, options) {
|
|
88
|
-
StormJSON.instance.registerClass(classConstructor, {
|
|
89
|
-
identifier: isString(options) ? options : options?.identifier || classConstructor.name,
|
|
90
|
-
allowProps: options && isObject(options) && options?.allowProps && Array.isArray(options.allowProps) ? options.allowProps : ["__typename"]
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
constructor() {
|
|
94
|
-
super({ dedupe: true });
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
StormJSON.instance.registerCustom({
|
|
98
|
-
isApplicable: (v) => typeof Buffer.isBuffer === "function" && Buffer.isBuffer(v),
|
|
99
|
-
serialize: (v) => v.toString("base64"),
|
|
100
|
-
deserialize: (v) => Buffer.from(v, "base64")
|
|
101
|
-
}, "Bytes");
|
|
102
|
-
|
|
103
|
-
//#endregion
|
|
104
|
-
export { StormJSON };
|
|
105
|
-
//# sourceMappingURL=storm-json.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"storm-json.mjs","names":["#instance","parseValue","stringifyValue"],"sources":["../../../../json/src/storm-json.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { ParseError } from \"jsonc-parser\";\nimport type {\n Class,\n JsonParseOptions,\n JsonParserResult,\n JsonSerializeOptions,\n JsonValue\n} from \"./types\";\n// import { Decimal } from \"decimal.js\";\nimport { isObject } from \"@stryke/type-checks/is-object\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport { parse } from \"jsonc-parser\";\nimport SuperJSON from \"superjson\";\nimport { parse as parseValue } from \"./utils/parse\";\nimport { formatParseError } from \"./utils/parse-error\";\nimport { stringify as stringifyValue } from \"./utils/stringify\";\n\n// eslint-disable-next-line unicorn/prefer-node-protocol\nimport { Buffer } from \"buffer\";\n\n/**\n * A static JSON parser class used by Storm Software to serialize and deserialize JSON data\n *\n * @remarks\n * This class uses the [SuperJSON](https://github.com/blitz-js/superjson) library under the hood.\n */\nexport class StormJSON extends SuperJSON {\n static #instance: StormJSON;\n\n public static get instance(): StormJSON {\n if (!StormJSON.#instance) {\n StormJSON.#instance = new StormJSON();\n }\n\n return StormJSON.#instance;\n }\n\n /**\n * Deserialize the given value with superjson using the given metadata\n */\n public static override deserialize<TData = unknown>(\n payload: JsonParserResult\n ): TData {\n return StormJSON.instance.deserialize(payload);\n }\n\n /**\n * Serialize the given value with superjson\n */\n public static override serialize(object: JsonValue): JsonParserResult {\n return StormJSON.instance.serialize(object);\n }\n\n /**\n * Parse the given string value with superjson using the given metadata\n *\n * @param value - The string value to parse\n * @returns The parsed data\n */\n public static override parse<TData = unknown>(\n value: string,\n options: JsonParseOptions = {}\n ): TData {\n try {\n if (options.expectComments === false) {\n return parseValue<TData>(value);\n }\n } catch {\n // Do nothing\n }\n\n const errors: ParseError[] = [];\n const opts = {\n allowTrailingComma: true,\n ...options\n };\n const result = parse(value, errors, opts) as TData;\n\n if (errors.length > 0 && errors[0]) {\n throw new Error(formatParseError(value, errors[0]));\n }\n\n return result;\n }\n\n /**\n * Serializes the given data to a JSON string.\n * By default the JSON string is formatted with a 2 space indentation to be easy readable.\n *\n * @param value - Object which should be serialized to JSON\n * @param options - JSON serialize options\n * @returns the formatted JSON representation of the object\n */\n public static override stringify<T>(\n value: T,\n options?: JsonSerializeOptions\n ): string {\n const customTransformer =\n StormJSON.instance.customTransformerRegistry.findApplicable(value);\n\n let result = value;\n if (customTransformer && customTransformer.isApplicable(value)) {\n result = customTransformer.serialize(result) as T;\n }\n\n return stringifyValue(result, options?.spaces ?? 2);\n }\n\n /**\n * Register a custom schema with superjson\n *\n * @param name - The name of the schema\n * @param serialize - The function to serialize the schema\n * @param deserialize - The function to deserialize the schema\n * @param isApplicable - The function to check if the schema is applicable\n */\n public static register<\n TData = any,\n TJsonObject extends JsonValue = JsonValue\n >(\n name: string,\n serialize: (data: TData) => TJsonObject,\n deserialize: (json: TJsonObject) => TData,\n isApplicable: (data: any) => data is TData\n ) {\n StormJSON.instance.registerCustom<TData, TJsonObject>(\n {\n isApplicable,\n serialize,\n deserialize\n },\n name\n );\n }\n\n /**\n * Register a class with superjson\n *\n * @param classConstructor - The class constructor to register\n */\n public static override registerClass(\n classConstructor: Class,\n options?: { identifier?: string; allowProps?: string[] } | string\n ) {\n StormJSON.instance.registerClass(classConstructor, {\n identifier: isString(options)\n ? options\n : options?.identifier || classConstructor.name,\n allowProps:\n options &&\n isObject(options) &&\n options?.allowProps &&\n Array.isArray(options.allowProps)\n ? options.allowProps\n : [\"__typename\"]\n });\n }\n\n private constructor() {\n super({ dedupe: true });\n }\n}\n\nStormJSON.instance.registerCustom<Buffer, string>(\n {\n isApplicable: (v): v is Buffer =>\n typeof Buffer.isBuffer === \"function\" && Buffer.isBuffer(v),\n serialize: v => v.toString(\"base64\"),\n deserialize: v => Buffer.from(v, \"base64\")\n },\n \"Bytes\"\n);\n"],"mappings":";;;;;;;;;;;;;;;;AA4CA,IAAa,YAAb,MAAa,kBAAkB,UAAU;CACvC,QAAOA;CAEP,WAAkB,WAAsB;AACtC,MAAI,CAAC,WAAUA,SACb,YAAUA,WAAY,IAAI,WAAW;AAGvC,SAAO,WAAUA;;;;;CAMnB,OAAuB,YACrB,SACO;AACP,SAAO,UAAU,SAAS,YAAY,QAAQ;;;;;CAMhD,OAAuB,UAAU,QAAqC;AACpE,SAAO,UAAU,SAAS,UAAU,OAAO;;;;;;;;CAS7C,OAAuB,MACrB,OACA,UAA4B,EAAE,EACvB;AACP,MAAI;AACF,OAAI,QAAQ,mBAAmB,MAC7B,QAAOC,QAAkB,MAAM;UAE3B;EAIR,MAAM,SAAuB,EAAE;EAK/B,MAAM,SAAS,MAAM,OAAO,QAAQ;GAHlC,oBAAoB;GACpB,GAAG;GAEmC,CAAC;AAEzC,MAAI,OAAO,SAAS,KAAK,OAAO,GAC9B,OAAM,IAAI,MAAM,iBAAiB,OAAO,OAAO,GAAG,CAAC;AAGrD,SAAO;;;;;;;;;;CAWT,OAAuB,UACrB,OACA,SACQ;EACR,MAAM,oBACJ,UAAU,SAAS,0BAA0B,eAAe,MAAM;EAEpE,IAAI,SAAS;AACb,MAAI,qBAAqB,kBAAkB,aAAa,MAAM,CAC5D,UAAS,kBAAkB,UAAU,OAAO;AAG9C,SAAOC,UAAe,QAAQ,SAAS,UAAU,EAAE;;;;;;;;;;CAWrD,OAAc,SAIZ,MACA,WACA,aACA,cACA;AACA,YAAU,SAAS,eACjB;GACE;GACA;GACA;GACD,EACD,KACD;;;;;;;CAQH,OAAuB,cACrB,kBACA,SACA;AACA,YAAU,SAAS,cAAc,kBAAkB;GACjD,YAAY,SAAS,QAAQ,GACzB,UACA,SAAS,cAAc,iBAAiB;GAC5C,YACE,WACA,SAAS,QAAQ,IACjB,SAAS,cACT,MAAM,QAAQ,QAAQ,WAAW,GAC7B,QAAQ,aACR,CAAC,aAAa;GACrB,CAAC;;CAGJ,AAAQ,cAAc;AACpB,QAAM,EAAE,QAAQ,MAAM,CAAC;;;AAI3B,UAAU,SAAS,eACjB;CACE,eAAe,MACb,OAAO,OAAO,aAAa,cAAc,OAAO,SAAS,EAAE;CAC7D,YAAW,MAAK,EAAE,SAAS,SAAS;CACpC,cAAa,MAAK,OAAO,KAAK,GAAG,SAAS;CAC3C,EACD,QACD"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { ParseOptions } from "jsonc-parser";
|
|
2
|
-
|
|
3
|
-
//#region ../json/src/types.d.ts
|
|
4
|
-
interface JsonParseOptions extends ParseOptions {
|
|
5
|
-
/**
|
|
6
|
-
* Expect JSON with javascript-style
|
|
7
|
-
*
|
|
8
|
-
* @defaultValue false
|
|
9
|
-
*/
|
|
10
|
-
expectComments?: boolean;
|
|
11
|
-
/**
|
|
12
|
-
* Disallow javascript-style
|
|
13
|
-
*
|
|
14
|
-
* @defaultValue false
|
|
15
|
-
*/
|
|
16
|
-
disallowComments?: boolean;
|
|
17
|
-
/**
|
|
18
|
-
* Allow trailing commas in the JSON content
|
|
19
|
-
*/
|
|
20
|
-
allowTrailingComma?: boolean;
|
|
21
|
-
}
|
|
22
|
-
interface JsonSerializeOptions {
|
|
23
|
-
/**
|
|
24
|
-
* the whitespaces to add as indentation to make the output more readable.
|
|
25
|
-
*
|
|
26
|
-
* @defaultValue 2
|
|
27
|
-
*/
|
|
28
|
-
spaces?: number;
|
|
29
|
-
}
|
|
30
|
-
//#endregion
|
|
31
|
-
export { JsonParseOptions, JsonSerializeOptions };
|
|
32
|
-
//# sourceMappingURL=types.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.cts","names":[],"sources":["../../../../json/src/types.ts"],"mappings":";;;UAsEiB,gBAAA,SAAyB,YAAA;;;;;;EAMxC,cAAA;;;;;;EAOA,gBAAA;;;;EAKA,kBAAA;AAAA;AAAA,UAGe,oBAAA;;;;;;EAMf,MAAA;AAAA"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { ParseOptions } from "jsonc-parser";
|
|
2
|
-
|
|
3
|
-
//#region ../json/src/types.d.ts
|
|
4
|
-
interface JsonParseOptions extends ParseOptions {
|
|
5
|
-
/**
|
|
6
|
-
* Expect JSON with javascript-style
|
|
7
|
-
*
|
|
8
|
-
* @defaultValue false
|
|
9
|
-
*/
|
|
10
|
-
expectComments?: boolean;
|
|
11
|
-
/**
|
|
12
|
-
* Disallow javascript-style
|
|
13
|
-
*
|
|
14
|
-
* @defaultValue false
|
|
15
|
-
*/
|
|
16
|
-
disallowComments?: boolean;
|
|
17
|
-
/**
|
|
18
|
-
* Allow trailing commas in the JSON content
|
|
19
|
-
*/
|
|
20
|
-
allowTrailingComma?: boolean;
|
|
21
|
-
}
|
|
22
|
-
interface JsonSerializeOptions {
|
|
23
|
-
/**
|
|
24
|
-
* the whitespaces to add as indentation to make the output more readable.
|
|
25
|
-
*
|
|
26
|
-
* @defaultValue 2
|
|
27
|
-
*/
|
|
28
|
-
spaces?: number;
|
|
29
|
-
}
|
|
30
|
-
//#endregion
|
|
31
|
-
export { JsonParseOptions, JsonSerializeOptions };
|
|
32
|
-
//# sourceMappingURL=types.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.mts","names":[],"sources":["../../../../json/src/types.ts"],"mappings":";;;UAsEiB,gBAAA,SAAyB,YAAA;;;;;;EAMxC,cAAA;;;;;;EAOA,gBAAA;;;;EAKA,kBAAA;AAAA;AAAA,UAGe,oBAAA;;;;;;EAMf,MAAA;AAAA"}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
//#region ../json/src/utils/code-frames.ts
|
|
3
|
-
/**
|
|
4
|
-
* RegExp to test for newlines in terminal.
|
|
5
|
-
*/
|
|
6
|
-
const NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
|
|
7
|
-
/**
|
|
8
|
-
* Extract what lines should be marked and highlighted.
|
|
9
|
-
*/
|
|
10
|
-
function getMarkerLines(loc, source, opts = {}) {
|
|
11
|
-
const startLoc = {
|
|
12
|
-
column: 0,
|
|
13
|
-
line: -1,
|
|
14
|
-
...loc.start
|
|
15
|
-
};
|
|
16
|
-
const endLoc = {
|
|
17
|
-
...startLoc,
|
|
18
|
-
...loc.end
|
|
19
|
-
};
|
|
20
|
-
const { linesAbove = 2, linesBelow = 3 } = opts || {};
|
|
21
|
-
const startLine = startLoc.line;
|
|
22
|
-
const startColumn = startLoc.column;
|
|
23
|
-
const endLine = endLoc.line;
|
|
24
|
-
const endColumn = endLoc.column;
|
|
25
|
-
let start = Math.max(startLine - (linesAbove + 1), 0);
|
|
26
|
-
let end = Math.min(source.length, endLine + linesBelow);
|
|
27
|
-
if (startLine === -1) start = 0;
|
|
28
|
-
if (endLine === -1) end = source.length;
|
|
29
|
-
const lineDiff = endLine - startLine;
|
|
30
|
-
const markerLines = {};
|
|
31
|
-
if (lineDiff) for (let i = 0; i <= lineDiff; i++) {
|
|
32
|
-
const lineNumber = i + startLine;
|
|
33
|
-
if (!startColumn) markerLines[lineNumber] = true;
|
|
34
|
-
else if (i === 0) markerLines[lineNumber] = [startColumn, (source[lineNumber - 1]?.length ?? 0) - startColumn + 1];
|
|
35
|
-
else if (i === lineDiff) markerLines[lineNumber] = [0, endColumn];
|
|
36
|
-
else markerLines[lineNumber] = [0, source[lineNumber - i]?.length ?? 0];
|
|
37
|
-
}
|
|
38
|
-
else if (startColumn === endColumn) markerLines[startLine] = startColumn ? [startColumn, 0] : true;
|
|
39
|
-
else markerLines[startLine] = [startColumn, endColumn - startColumn];
|
|
40
|
-
return {
|
|
41
|
-
start,
|
|
42
|
-
end,
|
|
43
|
-
markerLines
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
function codeFrameColumns(rawLines, loc, opts = {}) {
|
|
47
|
-
const { start, end, markerLines } = getMarkerLines(loc, rawLines.split(NEWLINE), opts);
|
|
48
|
-
const numberMaxWidth = String(end).length;
|
|
49
|
-
return (opts.highlight ? opts.highlight(rawLines) : rawLines).split(NEWLINE).slice(start, end).map((line, index) => {
|
|
50
|
-
const number = start + 1 + index;
|
|
51
|
-
const gutter = ` ${` ${number}`.slice(-numberMaxWidth)} | `;
|
|
52
|
-
const hasMarker = Boolean(markerLines[number] ?? false);
|
|
53
|
-
if (hasMarker) {
|
|
54
|
-
let markerLine = "";
|
|
55
|
-
if (Array.isArray(hasMarker)) {
|
|
56
|
-
const markerSpacing = line.slice(0, Math.max(hasMarker[0] - 1, 0)).replace(/[^\t]/g, " ");
|
|
57
|
-
const numberOfMarkers = hasMarker[1] || 1;
|
|
58
|
-
markerLine = [
|
|
59
|
-
"\n ",
|
|
60
|
-
gutter.replace(/\d/g, " "),
|
|
61
|
-
markerSpacing,
|
|
62
|
-
"^".repeat(numberOfMarkers)
|
|
63
|
-
].join("");
|
|
64
|
-
}
|
|
65
|
-
return [
|
|
66
|
-
">",
|
|
67
|
-
gutter,
|
|
68
|
-
line,
|
|
69
|
-
markerLine
|
|
70
|
-
].join("");
|
|
71
|
-
}
|
|
72
|
-
return ` ${gutter}${line}`;
|
|
73
|
-
}).join("\n");
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
//#endregion
|
|
77
|
-
exports.codeFrameColumns = codeFrameColumns;
|