gray-matter-es 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +129 -0
- package/dist/defaults.mjs +19 -0
- package/dist/defaults.mjs.map +1 -0
- package/dist/engines.d.mts +8 -0
- package/dist/engines.mjs +63 -0
- package/dist/engines.mjs.map +1 -0
- package/dist/excerpt.mjs +26 -0
- package/dist/excerpt.mjs.map +1 -0
- package/dist/index.d.mts +12 -0
- package/dist/index.mjs +126 -0
- package/dist/index.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/_chars.mjs +45 -0
- package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/_chars.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/_dumper_state.mjs +437 -0
- package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/_dumper_state.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/_loader_state.mjs +909 -0
- package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/_loader_state.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/_schema.mjs +115 -0
- package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/_schema.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/binary.mjs +89 -0
- package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/binary.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/bool.mjs +35 -0
- package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/bool.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/float.mjs +55 -0
- package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/float.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/int.mjs +114 -0
- package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/int.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/map.mjs +15 -0
- package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/map.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/merge.mjs +11 -0
- package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/merge.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/nil.mjs +20 -0
- package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/nil.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/omap.mjs +28 -0
- package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/omap.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/pairs.mjs +19 -0
- package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/pairs.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/regexp.mjs +26 -0
- package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/regexp.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/seq.mjs +11 -0
- package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/seq.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/set.mjs +14 -0
- package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/set.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/str.mjs +11 -0
- package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/str.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/timestamp.mjs +54 -0
- package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/timestamp.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/undefined.mjs +19 -0
- package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/undefined.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/_utils.mjs +14 -0
- package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/_utils.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/mod.mjs +4 -0
- package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/parse.mjs +50 -0
- package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/parse.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/stringify.mjs +32 -0
- package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/stringify.mjs.map +1 -0
- package/dist/parse.mjs +13 -0
- package/dist/parse.mjs.map +1 -0
- package/dist/stringify.mjs +52 -0
- package/dist/stringify.mjs.map +1 -0
- package/dist/to-file.mjs +44 -0
- package/dist/to-file.mjs.map +1 -0
- package/dist/types.d.mts +85 -0
- package/dist/utils.mjs +60 -0
- package/dist/utils.mjs.map +1 -0
- package/package.json +61 -0
- package/src/defaults.ts +17 -0
- package/src/engines.ts +217 -0
- package/src/excerpt.ts +146 -0
- package/src/index.ts +481 -0
- package/src/parse.ts +9 -0
- package/src/stringify.ts +187 -0
- package/src/to-file.ts +178 -0
- package/src/types.ts +84 -0
- package/src/utils.ts +158 -0
package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/map.mjs
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region node_modules/.pnpm/@jsr+std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/map.js
|
|
2
|
+
const map = {
|
|
3
|
+
tag: "tag:yaml.org,2002:map",
|
|
4
|
+
resolve() {
|
|
5
|
+
return true;
|
|
6
|
+
},
|
|
7
|
+
construct(data) {
|
|
8
|
+
return data !== null ? data : {};
|
|
9
|
+
},
|
|
10
|
+
kind: "mapping"
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
export { map };
|
|
15
|
+
//# sourceMappingURL=map.mjs.map
|
package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/map.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map.mjs","names":[],"sources":["../../../../../../../../node_modules/.pnpm/@jsr+std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/map.js"],"sourcesContent":["// Ported from js-yaml v3.13.1:\n// https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da\n// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.\n// Copyright 2018-2025 the Deno authors. MIT license.\nexport const map = {\n tag: \"tag:yaml.org,2002:map\",\n resolve () {\n return true;\n },\n construct (data) {\n return data !== null ? data : {};\n },\n kind: \"mapping\"\n};\n//# sourceMappingURL=map.js.map"],"x_google_ignoreList":[0],"mappings":";AAIA,MAAa,MAAM;CACjB,KAAK;CACL,UAAW;AACT,SAAO;;CAET,UAAW,MAAM;AACf,SAAO,SAAS,OAAO,OAAO,EAAE;;CAElC,MAAM;CACP"}
|
package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/merge.mjs
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region node_modules/.pnpm/@jsr+std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/merge.js
|
|
2
|
+
const merge = {
|
|
3
|
+
tag: "tag:yaml.org,2002:merge",
|
|
4
|
+
kind: "scalar",
|
|
5
|
+
resolve: (data) => data === "<<" || data === null,
|
|
6
|
+
construct: (data) => data
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
export { merge };
|
|
11
|
+
//# sourceMappingURL=merge.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merge.mjs","names":[],"sources":["../../../../../../../../node_modules/.pnpm/@jsr+std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/merge.js"],"sourcesContent":["// Ported from js-yaml v3.13.1:\n// https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da\n// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.\n// Copyright 2018-2025 the Deno authors. MIT license.\nexport const merge = {\n tag: \"tag:yaml.org,2002:merge\",\n kind: \"scalar\",\n resolve: (data)=>data === \"<<\" || data === null,\n construct: (data)=>data\n};\n//# sourceMappingURL=merge.js.map"],"x_google_ignoreList":[0],"mappings":";AAIA,MAAa,QAAQ;CACnB,KAAK;CACL,MAAM;CACN,UAAU,SAAO,SAAS,QAAQ,SAAS;CAC3C,YAAY,SAAO;CACpB"}
|
package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/nil.mjs
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//#region node_modules/.pnpm/@jsr+std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/nil.js
|
|
2
|
+
const nil = {
|
|
3
|
+
tag: "tag:yaml.org,2002:null",
|
|
4
|
+
kind: "scalar",
|
|
5
|
+
defaultStyle: "lowercase",
|
|
6
|
+
predicate: (object) => object === null,
|
|
7
|
+
construct: () => null,
|
|
8
|
+
resolve: (data) => {
|
|
9
|
+
return data === "~" || data === "null" || data === "Null" || data === "NULL";
|
|
10
|
+
},
|
|
11
|
+
represent: {
|
|
12
|
+
lowercase: () => "null",
|
|
13
|
+
uppercase: () => "NULL",
|
|
14
|
+
camelcase: () => "Null"
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
export { nil };
|
|
20
|
+
//# sourceMappingURL=nil.mjs.map
|
package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/nil.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nil.mjs","names":[],"sources":["../../../../../../../../node_modules/.pnpm/@jsr+std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/nil.js"],"sourcesContent":["// Ported from js-yaml v3.13.1:\n// https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da\n// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.\n// Copyright 2018-2025 the Deno authors. MIT license.\nexport const nil = {\n tag: \"tag:yaml.org,2002:null\",\n kind: \"scalar\",\n defaultStyle: \"lowercase\",\n predicate: (object)=>object === null,\n construct: ()=>null,\n resolve: (data)=>{\n return data === \"~\" || data === \"null\" || data === \"Null\" || data === \"NULL\";\n },\n represent: {\n lowercase: ()=>\"null\",\n uppercase: ()=>\"NULL\",\n camelcase: ()=>\"Null\"\n }\n};\n//# sourceMappingURL=nil.js.map"],"x_google_ignoreList":[0],"mappings":";AAIA,MAAa,MAAM;CACjB,KAAK;CACL,MAAM;CACN,cAAc;CACd,YAAY,WAAS,WAAW;CAChC,iBAAe;CACf,UAAU,SAAO;AACf,SAAO,SAAS,OAAO,SAAS,UAAU,SAAS,UAAU,SAAS;;CAExE,WAAW;EACT,iBAAe;EACf,iBAAe;EACf,iBAAe;EAChB;CACF"}
|
package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/omap.mjs
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { isPlainObject } from "../_utils.mjs";
|
|
2
|
+
|
|
3
|
+
//#region node_modules/.pnpm/@jsr+std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/omap.js
|
|
4
|
+
function resolveYamlOmap(data) {
|
|
5
|
+
const objectKeys = /* @__PURE__ */ new Set();
|
|
6
|
+
for (const object of data) {
|
|
7
|
+
if (!isPlainObject(object)) return false;
|
|
8
|
+
const keys = Object.keys(object);
|
|
9
|
+
if (keys.length !== 1) return false;
|
|
10
|
+
for (const key of keys) {
|
|
11
|
+
if (objectKeys.has(key)) return false;
|
|
12
|
+
objectKeys.add(key);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
const omap = {
|
|
18
|
+
tag: "tag:yaml.org,2002:omap",
|
|
19
|
+
kind: "sequence",
|
|
20
|
+
resolve: resolveYamlOmap,
|
|
21
|
+
construct(data) {
|
|
22
|
+
return data;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
export { omap };
|
|
28
|
+
//# sourceMappingURL=omap.mjs.map
|
package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/omap.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"omap.mjs","names":[],"sources":["../../../../../../../../node_modules/.pnpm/@jsr+std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/omap.js"],"sourcesContent":["// Ported from js-yaml v3.13.1:\n// https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da\n// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.\n// Copyright 2018-2025 the Deno authors. MIT license.\nimport { isPlainObject } from \"../_utils.js\";\nfunction resolveYamlOmap(data) {\n const objectKeys = new Set();\n for (const object of data){\n if (!isPlainObject(object)) return false;\n const keys = Object.keys(object);\n if (keys.length !== 1) return false;\n for (const key of keys){\n if (objectKeys.has(key)) return false;\n objectKeys.add(key);\n }\n }\n return true;\n}\nexport const omap = {\n tag: \"tag:yaml.org,2002:omap\",\n kind: \"sequence\",\n resolve: resolveYamlOmap,\n construct (data) {\n return data;\n }\n};\n//# sourceMappingURL=omap.js.map"],"x_google_ignoreList":[0],"mappings":";;;AAKA,SAAS,gBAAgB,MAAM;CAC7B,MAAM,6BAAa,IAAI,KAAK;AAC5B,MAAK,MAAM,UAAU,MAAK;AACxB,MAAI,CAAC,cAAc,OAAO,CAAE,QAAO;EACnC,MAAM,OAAO,OAAO,KAAK,OAAO;AAChC,MAAI,KAAK,WAAW,EAAG,QAAO;AAC9B,OAAK,MAAM,OAAO,MAAK;AACrB,OAAI,WAAW,IAAI,IAAI,CAAE,QAAO;AAChC,cAAW,IAAI,IAAI;;;AAGvB,QAAO;;AAET,MAAa,OAAO;CAClB,KAAK;CACL,MAAM;CACN,SAAS;CACT,UAAW,MAAM;AACf,SAAO;;CAEV"}
|
package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/pairs.mjs
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { isPlainObject } from "../_utils.mjs";
|
|
2
|
+
|
|
3
|
+
//#region node_modules/.pnpm/@jsr+std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/pairs.js
|
|
4
|
+
function resolveYamlPairs(data) {
|
|
5
|
+
if (data === null) return true;
|
|
6
|
+
return data.every((it) => isPlainObject(it) && Object.keys(it).length === 1);
|
|
7
|
+
}
|
|
8
|
+
const pairs = {
|
|
9
|
+
tag: "tag:yaml.org,2002:pairs",
|
|
10
|
+
construct(data) {
|
|
11
|
+
return data?.flatMap(Object.entries) ?? [];
|
|
12
|
+
},
|
|
13
|
+
kind: "sequence",
|
|
14
|
+
resolve: resolveYamlPairs
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
export { pairs };
|
|
19
|
+
//# sourceMappingURL=pairs.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pairs.mjs","names":[],"sources":["../../../../../../../../node_modules/.pnpm/@jsr+std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/pairs.js"],"sourcesContent":["// Ported from js-yaml v3.13.1:\n// https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da\n// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.\n// Copyright 2018-2025 the Deno authors. MIT license.\nimport { isPlainObject } from \"../_utils.js\";\nfunction resolveYamlPairs(data) {\n if (data === null) return true;\n return data.every((it)=>isPlainObject(it) && Object.keys(it).length === 1);\n}\nexport const pairs = {\n tag: \"tag:yaml.org,2002:pairs\",\n construct (data) {\n // Converts an array of objects into an array of key-value pairs.\n return data?.flatMap(Object.entries) ?? [];\n },\n kind: \"sequence\",\n resolve: resolveYamlPairs\n};\n//# sourceMappingURL=pairs.js.map"],"x_google_ignoreList":[0],"mappings":";;;AAKA,SAAS,iBAAiB,MAAM;AAC9B,KAAI,SAAS,KAAM,QAAO;AAC1B,QAAO,KAAK,OAAO,OAAK,cAAc,GAAG,IAAI,OAAO,KAAK,GAAG,CAAC,WAAW,EAAE;;AAE5E,MAAa,QAAQ;CACnB,KAAK;CACL,UAAW,MAAM;AAEf,SAAO,MAAM,QAAQ,OAAO,QAAQ,IAAI,EAAE;;CAE5C,MAAM;CACN,SAAS;CACV"}
|
package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/regexp.mjs
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//#region node_modules/.pnpm/@jsr+std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/regexp.js
|
|
2
|
+
const REGEXP = /^\/(?<regexp>[\s\S]+)\/(?<modifiers>[gismuy]*)$/;
|
|
3
|
+
const regexp = {
|
|
4
|
+
tag: "tag:yaml.org,2002:js/regexp",
|
|
5
|
+
kind: "scalar",
|
|
6
|
+
resolve(data) {
|
|
7
|
+
if (data === null || !data.length) return false;
|
|
8
|
+
if (data.charAt(0) === "/") {
|
|
9
|
+
const groups = data.match(REGEXP)?.groups;
|
|
10
|
+
if (!groups) return false;
|
|
11
|
+
const modifiers = groups.modifiers ?? "";
|
|
12
|
+
if (new Set(modifiers).size < modifiers.length) return false;
|
|
13
|
+
}
|
|
14
|
+
return true;
|
|
15
|
+
},
|
|
16
|
+
construct(data) {
|
|
17
|
+
const { regexp: regexp$1 = data, modifiers = "" } = data.match(REGEXP)?.groups ?? {};
|
|
18
|
+
return new RegExp(regexp$1, modifiers);
|
|
19
|
+
},
|
|
20
|
+
predicate: (object) => object instanceof RegExp,
|
|
21
|
+
represent: (object) => object.toString()
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
export { regexp };
|
|
26
|
+
//# sourceMappingURL=regexp.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"regexp.mjs","names":["regexp"],"sources":["../../../../../../../../node_modules/.pnpm/@jsr+std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/regexp.js"],"sourcesContent":["// Ported and adapted from js-yaml-js-types v1.0.0:\n// https://github.com/nodeca/js-yaml-js-types/tree/ac537e7bbdd3c2cbbd9882ca3919c520c2dc022b\n// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.\n// Copyright 2018-2025 the Deno authors. MIT license.\nconst REGEXP = /^\\/(?<regexp>[\\s\\S]+)\\/(?<modifiers>[gismuy]*)$/;\nexport const regexp = {\n tag: \"tag:yaml.org,2002:js/regexp\",\n kind: \"scalar\",\n resolve (data) {\n if (data === null || !data.length) return false;\n if (data.charAt(0) === \"/\") {\n // Ensure regex is properly terminated\n const groups = data.match(REGEXP)?.groups;\n if (!groups) return false;\n // Check no duplicate modifiers\n const modifiers = groups.modifiers ?? \"\";\n if (new Set(modifiers).size < modifiers.length) return false;\n }\n return true;\n },\n construct (data) {\n const { regexp = data, modifiers = \"\" } = data.match(REGEXP)?.groups ?? {};\n return new RegExp(regexp, modifiers);\n },\n predicate: (object)=>object instanceof RegExp,\n represent: (object)=>object.toString()\n};\n//# sourceMappingURL=regexp.js.map"],"x_google_ignoreList":[0],"mappings":";AAIA,MAAM,SAAS;AACf,MAAa,SAAS;CACpB,KAAK;CACL,MAAM;CACN,QAAS,MAAM;AACb,MAAI,SAAS,QAAQ,CAAC,KAAK,OAAQ,QAAO;AAC1C,MAAI,KAAK,OAAO,EAAE,KAAK,KAAK;GAE1B,MAAM,SAAS,KAAK,MAAM,OAAO,EAAE;AACnC,OAAI,CAAC,OAAQ,QAAO;GAEpB,MAAM,YAAY,OAAO,aAAa;AACtC,OAAI,IAAI,IAAI,UAAU,CAAC,OAAO,UAAU,OAAQ,QAAO;;AAEzD,SAAO;;CAET,UAAW,MAAM;EACf,MAAM,EAAE,mBAAS,MAAM,YAAY,OAAO,KAAK,MAAM,OAAO,EAAE,UAAU,EAAE;AAC1E,SAAO,IAAI,OAAOA,UAAQ,UAAU;;CAEtC,YAAY,WAAS,kBAAkB;CACvC,YAAY,WAAS,OAAO,UAAU;CACvC"}
|
package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/seq.mjs
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region node_modules/.pnpm/@jsr+std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/seq.js
|
|
2
|
+
const seq = {
|
|
3
|
+
tag: "tag:yaml.org,2002:seq",
|
|
4
|
+
kind: "sequence",
|
|
5
|
+
resolve: () => true,
|
|
6
|
+
construct: (data) => data !== null ? data : []
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
export { seq };
|
|
11
|
+
//# sourceMappingURL=seq.mjs.map
|
package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/seq.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"seq.mjs","names":[],"sources":["../../../../../../../../node_modules/.pnpm/@jsr+std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/seq.js"],"sourcesContent":["// Ported from js-yaml v3.13.1:\n// https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da\n// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.\n// Copyright 2018-2025 the Deno authors. MIT license.\nexport const seq = {\n tag: \"tag:yaml.org,2002:seq\",\n kind: \"sequence\",\n resolve: ()=>true,\n construct: (data)=>data !== null ? data : []\n};\n//# sourceMappingURL=seq.js.map"],"x_google_ignoreList":[0],"mappings":";AAIA,MAAa,MAAM;CACjB,KAAK;CACL,MAAM;CACN,eAAa;CACb,YAAY,SAAO,SAAS,OAAO,OAAO,EAAE;CAC7C"}
|
package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/set.mjs
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region node_modules/.pnpm/@jsr+std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/set.js
|
|
2
|
+
const set = {
|
|
3
|
+
tag: "tag:yaml.org,2002:set",
|
|
4
|
+
kind: "mapping",
|
|
5
|
+
construct: (data) => data !== null ? data : {},
|
|
6
|
+
resolve: (data) => {
|
|
7
|
+
if (data === null) return true;
|
|
8
|
+
return Object.values(data).every((it) => it === null);
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
export { set };
|
|
14
|
+
//# sourceMappingURL=set.mjs.map
|
package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/set.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set.mjs","names":[],"sources":["../../../../../../../../node_modules/.pnpm/@jsr+std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/set.js"],"sourcesContent":["// Ported from js-yaml v3.13.1:\n// https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da\n// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.\n// Copyright 2018-2025 the Deno authors. MIT license.\nexport const set = {\n tag: \"tag:yaml.org,2002:set\",\n kind: \"mapping\",\n construct: (data)=>data !== null ? data : {},\n resolve: (data)=>{\n if (data === null) return true;\n return Object.values(data).every((it)=>it === null);\n }\n};\n//# sourceMappingURL=set.js.map"],"x_google_ignoreList":[0],"mappings":";AAIA,MAAa,MAAM;CACjB,KAAK;CACL,MAAM;CACN,YAAY,SAAO,SAAS,OAAO,OAAO,EAAE;CAC5C,UAAU,SAAO;AACf,MAAI,SAAS,KAAM,QAAO;AAC1B,SAAO,OAAO,OAAO,KAAK,CAAC,OAAO,OAAK,OAAO,KAAK;;CAEtD"}
|
package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/str.mjs
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region node_modules/.pnpm/@jsr+std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/str.js
|
|
2
|
+
const str = {
|
|
3
|
+
tag: "tag:yaml.org,2002:str",
|
|
4
|
+
kind: "scalar",
|
|
5
|
+
resolve: () => true,
|
|
6
|
+
construct: (data) => data !== null ? data : ""
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
export { str };
|
|
11
|
+
//# sourceMappingURL=str.mjs.map
|
package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/str.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"str.mjs","names":[],"sources":["../../../../../../../../node_modules/.pnpm/@jsr+std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/str.js"],"sourcesContent":["// Ported from js-yaml v3.13.1:\n// https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da\n// Copyright 2018-2025 the Deno authors. MIT license.\nexport const str = {\n tag: \"tag:yaml.org,2002:str\",\n kind: \"scalar\",\n resolve: ()=>true,\n construct: (data)=>data !== null ? data : \"\"\n};\n//# sourceMappingURL=str.js.map"],"x_google_ignoreList":[0],"mappings":";AAGA,MAAa,MAAM;CACjB,KAAK;CACL,MAAM;CACN,eAAa;CACb,YAAY,SAAO,SAAS,OAAO,OAAO;CAC3C"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
//#region node_modules/.pnpm/@jsr+std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/timestamp.js
|
|
2
|
+
const YAML_DATE_REGEXP = /* @__PURE__ */ new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$");
|
|
3
|
+
const YAML_TIMESTAMP_REGEXP = /* @__PURE__ */ new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");
|
|
4
|
+
function resolveYamlTimestamp(data) {
|
|
5
|
+
if (data === null) return false;
|
|
6
|
+
if (YAML_DATE_REGEXP.exec(data) !== null) return true;
|
|
7
|
+
if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true;
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
function constructYamlTimestamp(data) {
|
|
11
|
+
let match = YAML_DATE_REGEXP.exec(data);
|
|
12
|
+
if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data);
|
|
13
|
+
if (match === null) throw new Error("Cannot construct YAML timestamp: date resolve error");
|
|
14
|
+
const year = +match[1];
|
|
15
|
+
const month = +match[2] - 1;
|
|
16
|
+
const day = +match[3];
|
|
17
|
+
if (!match[4]) return new Date(Date.UTC(year, month, day));
|
|
18
|
+
const hour = +match[4];
|
|
19
|
+
const minute = +match[5];
|
|
20
|
+
const second = +match[6];
|
|
21
|
+
let fraction = 0;
|
|
22
|
+
if (match[7]) {
|
|
23
|
+
let partFraction = match[7].slice(0, 3);
|
|
24
|
+
while (partFraction.length < 3) partFraction += "0";
|
|
25
|
+
fraction = +partFraction;
|
|
26
|
+
}
|
|
27
|
+
let delta = null;
|
|
28
|
+
if (match[9] && match[10]) {
|
|
29
|
+
const tzHour = +match[10];
|
|
30
|
+
const tzMinute = +(match[11] || 0);
|
|
31
|
+
delta = (tzHour * 60 + tzMinute) * 6e4;
|
|
32
|
+
if (match[9] === "-") delta = -delta;
|
|
33
|
+
}
|
|
34
|
+
const date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
|
|
35
|
+
if (delta) date.setTime(date.getTime() - delta);
|
|
36
|
+
return date;
|
|
37
|
+
}
|
|
38
|
+
function representYamlTimestamp(date) {
|
|
39
|
+
return date.toISOString();
|
|
40
|
+
}
|
|
41
|
+
const timestamp = {
|
|
42
|
+
tag: "tag:yaml.org,2002:timestamp",
|
|
43
|
+
construct: constructYamlTimestamp,
|
|
44
|
+
predicate(object) {
|
|
45
|
+
return object instanceof Date;
|
|
46
|
+
},
|
|
47
|
+
kind: "scalar",
|
|
48
|
+
represent: representYamlTimestamp,
|
|
49
|
+
resolve: resolveYamlTimestamp
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
//#endregion
|
|
53
|
+
export { timestamp };
|
|
54
|
+
//# sourceMappingURL=timestamp.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timestamp.mjs","names":[],"sources":["../../../../../../../../node_modules/.pnpm/@jsr+std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/timestamp.js"],"sourcesContent":["// Ported from js-yaml v3.13.1:\n// https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da\n// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.\n// Copyright 2018-2025 the Deno authors. MIT license.\nconst YAML_DATE_REGEXP = new RegExp(\"^([0-9][0-9][0-9][0-9])\" + // [1] year\n\"-([0-9][0-9])\" + // [2] month\n\"-([0-9][0-9])$\");\nconst YAML_TIMESTAMP_REGEXP = new RegExp(\"^([0-9][0-9][0-9][0-9])\" + // [1] year\n\"-([0-9][0-9]?)\" + // [2] month\n\"-([0-9][0-9]?)\" + // [3] day\n\"(?:[Tt]|[ \\\\t]+)\" + // ...\n\"([0-9][0-9]?)\" + // [4] hour\n\":([0-9][0-9])\" + // [5] minute\n\":([0-9][0-9])\" + // [6] second\n\"(?:\\\\.([0-9]*))?\" + // [7] fraction\n\"(?:[ \\\\t]*(Z|([-+])([0-9][0-9]?)\" + // [8] tz [9] tz_sign [10] tz_hour\n\"(?::([0-9][0-9]))?))?$\");\nfunction resolveYamlTimestamp(data) {\n if (data === null) return false;\n if (YAML_DATE_REGEXP.exec(data) !== null) return true;\n if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true;\n return false;\n}\nfunction constructYamlTimestamp(data) {\n let match = YAML_DATE_REGEXP.exec(data);\n if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data);\n if (match === null) {\n throw new Error(\"Cannot construct YAML timestamp: date resolve error\");\n }\n // match: [1] year [2] month [3] day\n const year = +match[1];\n const month = +match[2] - 1; // JS month starts with 0\n const day = +match[3];\n if (!match[4]) {\n // no hour\n return new Date(Date.UTC(year, month, day));\n }\n // match: [4] hour [5] minute [6] second [7] fraction\n const hour = +match[4];\n const minute = +match[5];\n const second = +match[6];\n let fraction = 0;\n if (match[7]) {\n let partFraction = match[7].slice(0, 3);\n while(partFraction.length < 3){\n // milli-seconds\n partFraction += \"0\";\n }\n fraction = +partFraction;\n }\n // match: [8] tz [9] tz_sign [10] tz_hour [11] tz_minute\n let delta = null;\n if (match[9] && match[10]) {\n const tzHour = +match[10];\n const tzMinute = +(match[11] || 0);\n delta = (tzHour * 60 + tzMinute) * 60000; // delta in milli-seconds\n if (match[9] === \"-\") delta = -delta;\n }\n const date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));\n if (delta) date.setTime(date.getTime() - delta);\n return date;\n}\nfunction representYamlTimestamp(date) {\n return date.toISOString();\n}\nexport const timestamp = {\n tag: \"tag:yaml.org,2002:timestamp\",\n construct: constructYamlTimestamp,\n predicate (object) {\n return object instanceof Date;\n },\n kind: \"scalar\",\n represent: representYamlTimestamp,\n resolve: resolveYamlTimestamp\n};\n//# sourceMappingURL=timestamp.js.map"],"x_google_ignoreList":[0],"mappings":";AAIA,MAAM,mCAAmB,IAAI,OAAO,qDAEnB;AACjB,MAAM,wCAAwB,IAAI,OAAO,mLAShB;AACzB,SAAS,qBAAqB,MAAM;AAClC,KAAI,SAAS,KAAM,QAAO;AAC1B,KAAI,iBAAiB,KAAK,KAAK,KAAK,KAAM,QAAO;AACjD,KAAI,sBAAsB,KAAK,KAAK,KAAK,KAAM,QAAO;AACtD,QAAO;;AAET,SAAS,uBAAuB,MAAM;CACpC,IAAI,QAAQ,iBAAiB,KAAK,KAAK;AACvC,KAAI,UAAU,KAAM,SAAQ,sBAAsB,KAAK,KAAK;AAC5D,KAAI,UAAU,KACZ,OAAM,IAAI,MAAM,sDAAsD;CAGxE,MAAM,OAAO,CAAC,MAAM;CACpB,MAAM,QAAQ,CAAC,MAAM,KAAK;CAC1B,MAAM,MAAM,CAAC,MAAM;AACnB,KAAI,CAAC,MAAM,GAET,QAAO,IAAI,KAAK,KAAK,IAAI,MAAM,OAAO,IAAI,CAAC;CAG7C,MAAM,OAAO,CAAC,MAAM;CACpB,MAAM,SAAS,CAAC,MAAM;CACtB,MAAM,SAAS,CAAC,MAAM;CACtB,IAAI,WAAW;AACf,KAAI,MAAM,IAAI;EACZ,IAAI,eAAe,MAAM,GAAG,MAAM,GAAG,EAAE;AACvC,SAAM,aAAa,SAAS,EAE1B,iBAAgB;AAElB,aAAW,CAAC;;CAGd,IAAI,QAAQ;AACZ,KAAI,MAAM,MAAM,MAAM,KAAK;EACzB,MAAM,SAAS,CAAC,MAAM;EACtB,MAAM,WAAW,EAAE,MAAM,OAAO;AAChC,WAAS,SAAS,KAAK,YAAY;AACnC,MAAI,MAAM,OAAO,IAAK,SAAQ,CAAC;;CAEjC,MAAM,OAAO,IAAI,KAAK,KAAK,IAAI,MAAM,OAAO,KAAK,MAAM,QAAQ,QAAQ,SAAS,CAAC;AACjF,KAAI,MAAO,MAAK,QAAQ,KAAK,SAAS,GAAG,MAAM;AAC/C,QAAO;;AAET,SAAS,uBAAuB,MAAM;AACpC,QAAO,KAAK,aAAa;;AAE3B,MAAa,YAAY;CACvB,KAAK;CACL,WAAW;CACX,UAAW,QAAQ;AACjB,SAAO,kBAAkB;;CAE3B,MAAM;CACN,WAAW;CACX,SAAS;CACV"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region node_modules/.pnpm/@jsr+std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/undefined.js
|
|
2
|
+
const undefinedType = {
|
|
3
|
+
tag: "tag:yaml.org,2002:js/undefined",
|
|
4
|
+
kind: "scalar",
|
|
5
|
+
resolve() {
|
|
6
|
+
return true;
|
|
7
|
+
},
|
|
8
|
+
construct() {},
|
|
9
|
+
predicate(object) {
|
|
10
|
+
return typeof object === "undefined";
|
|
11
|
+
},
|
|
12
|
+
represent() {
|
|
13
|
+
return "";
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
export { undefinedType };
|
|
19
|
+
//# sourceMappingURL=undefined.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"undefined.mjs","names":[],"sources":["../../../../../../../../node_modules/.pnpm/@jsr+std__yaml@1.0.10/node_modules/@jsr/std__yaml/_type/undefined.js"],"sourcesContent":["// Ported and adapted from js-yaml-js-types v1.0.0:\n// https://github.com/nodeca/js-yaml-js-types/tree/ac537e7bbdd3c2cbbd9882ca3919c520c2dc022b\n// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.\n// Copyright 2018-2025 the Deno authors. MIT license.\nexport const undefinedType = {\n tag: \"tag:yaml.org,2002:js/undefined\",\n kind: \"scalar\",\n resolve () {\n return true;\n },\n construct () {\n return undefined;\n },\n predicate (object) {\n return typeof object === \"undefined\";\n },\n represent () {\n return \"\";\n }\n};\n//# sourceMappingURL=undefined.js.map"],"x_google_ignoreList":[0],"mappings":";AAIA,MAAa,gBAAgB;CAC3B,KAAK;CACL,MAAM;CACN,UAAW;AACT,SAAO;;CAET,YAAa;CAGb,UAAW,QAAQ;AACjB,SAAO,OAAO,WAAW;;CAE3B,YAAa;AACX,SAAO;;CAEV"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region node_modules/.pnpm/@jsr+std__yaml@1.0.10/node_modules/@jsr/std__yaml/_utils.js
|
|
2
|
+
function isObject(value) {
|
|
3
|
+
return value !== null && typeof value === "object";
|
|
4
|
+
}
|
|
5
|
+
function isNegativeZero(i) {
|
|
6
|
+
return i === 0 && Number.NEGATIVE_INFINITY === 1 / i;
|
|
7
|
+
}
|
|
8
|
+
function isPlainObject(object) {
|
|
9
|
+
return Object.prototype.toString.call(object) === "[object Object]";
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
export { isNegativeZero, isObject, isPlainObject };
|
|
14
|
+
//# sourceMappingURL=_utils.mjs.map
|
package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/_utils.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_utils.mjs","names":[],"sources":["../../../../../../../node_modules/.pnpm/@jsr+std__yaml@1.0.10/node_modules/@jsr/std__yaml/_utils.js"],"sourcesContent":["// Ported from js-yaml v3.13.1:\n// https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da\n// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.\n// Copyright 2018-2025 the Deno authors. MIT license.\nexport function isObject(value) {\n return value !== null && typeof value === \"object\";\n}\nexport function isNegativeZero(i) {\n return i === 0 && Number.NEGATIVE_INFINITY === 1 / i;\n}\nexport function isPlainObject(object) {\n return Object.prototype.toString.call(object) === \"[object Object]\";\n}\n//# sourceMappingURL=_utils.js.map"],"x_google_ignoreList":[0],"mappings":";AAIA,SAAgB,SAAS,OAAO;AAC9B,QAAO,UAAU,QAAQ,OAAO,UAAU;;AAE5C,SAAgB,eAAe,GAAG;AAChC,QAAO,MAAM,KAAK,OAAO,sBAAsB,IAAI;;AAErD,SAAgB,cAAc,QAAQ;AACpC,QAAO,OAAO,UAAU,SAAS,KAAK,OAAO,KAAK"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { isEOL } from "./_chars.mjs";
|
|
2
|
+
import { SCHEMA_MAP } from "./_schema.mjs";
|
|
3
|
+
import { LoaderState } from "./_loader_state.mjs";
|
|
4
|
+
|
|
5
|
+
//#region node_modules/.pnpm/@jsr+std__yaml@1.0.10/node_modules/@jsr/std__yaml/parse.js
|
|
6
|
+
function sanitizeInput(input) {
|
|
7
|
+
input = String(input);
|
|
8
|
+
if (input.length > 0) {
|
|
9
|
+
if (!isEOL(input.charCodeAt(input.length - 1))) input += "\n";
|
|
10
|
+
if (input.charCodeAt(0) === 65279) input = input.slice(1);
|
|
11
|
+
}
|
|
12
|
+
input += "\0";
|
|
13
|
+
return input;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Parse and return a YAML string as a parsed YAML document object.
|
|
17
|
+
*
|
|
18
|
+
* Note: This does not support functions. Untrusted data is safe to parse.
|
|
19
|
+
*
|
|
20
|
+
* @example Usage
|
|
21
|
+
* ```ts
|
|
22
|
+
* import { parse } from "@std/yaml/parse";
|
|
23
|
+
* import { assertEquals } from "@std/assert";
|
|
24
|
+
*
|
|
25
|
+
* const data = parse(`
|
|
26
|
+
* id: 1
|
|
27
|
+
* name: Alice
|
|
28
|
+
* `);
|
|
29
|
+
*
|
|
30
|
+
* assertEquals(data, { id: 1, name: "Alice" });
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* @throws {SyntaxError} Throws error on invalid YAML.
|
|
34
|
+
* @param content YAML string to parse.
|
|
35
|
+
* @param options Parsing options.
|
|
36
|
+
* @returns Parsed document.
|
|
37
|
+
*/ function parse(content, options = {}) {
|
|
38
|
+
content = sanitizeInput(content);
|
|
39
|
+
const documentGenerator = new LoaderState(content, {
|
|
40
|
+
...options,
|
|
41
|
+
schema: SCHEMA_MAP.get(options.schema)
|
|
42
|
+
}).readDocuments();
|
|
43
|
+
const document = documentGenerator.next().value;
|
|
44
|
+
if (!documentGenerator.next().done) throw new SyntaxError("Found more than 1 document in the stream: expected a single document");
|
|
45
|
+
return document ?? null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
//#endregion
|
|
49
|
+
export { parse };
|
|
50
|
+
//# sourceMappingURL=parse.mjs.map
|
package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/parse.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.mjs","names":[],"sources":["../../../../../../../node_modules/.pnpm/@jsr+std__yaml@1.0.10/node_modules/@jsr/std__yaml/parse.js"],"sourcesContent":["// Ported from js-yaml v3.13.1:\n// https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da\n// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.\n// Copyright 2018-2025 the Deno authors. MIT license.\n// This module is browser compatible.\nimport { isEOL } from \"./_chars.js\";\nimport { LoaderState } from \"./_loader_state.js\";\nimport { SCHEMA_MAP } from \"./_schema.js\";\nfunction sanitizeInput(input) {\n input = String(input);\n if (input.length > 0) {\n // Add trailing `\\n` if not exists\n if (!isEOL(input.charCodeAt(input.length - 1))) input += \"\\n\";\n // Strip BOM\n if (input.charCodeAt(0) === 0xfeff) input = input.slice(1);\n }\n // Use 0 as string terminator. That significantly simplifies bounds check.\n input += \"\\0\";\n return input;\n}\n/**\n * Parse and return a YAML string as a parsed YAML document object.\n *\n * Note: This does not support functions. Untrusted data is safe to parse.\n *\n * @example Usage\n * ```ts\n * import { parse } from \"@std/yaml/parse\";\n * import { assertEquals } from \"@std/assert\";\n *\n * const data = parse(`\n * id: 1\n * name: Alice\n * `);\n *\n * assertEquals(data, { id: 1, name: \"Alice\" });\n * ```\n *\n * @throws {SyntaxError} Throws error on invalid YAML.\n * @param content YAML string to parse.\n * @param options Parsing options.\n * @returns Parsed document.\n */ export function parse(content, options = {}) {\n content = sanitizeInput(content);\n const state = new LoaderState(content, {\n ...options,\n schema: SCHEMA_MAP.get(options.schema)\n });\n const documentGenerator = state.readDocuments();\n const document = documentGenerator.next().value;\n if (!documentGenerator.next().done) {\n throw new SyntaxError(\"Found more than 1 document in the stream: expected a single document\");\n }\n return document ?? null;\n}\n/**\n * Same as {@linkcode parse}, but understands multi-document YAML sources, and\n * returns multiple parsed YAML document objects.\n *\n * @example Usage\n * ```ts\n * import { parseAll } from \"@std/yaml/parse\";\n * import { assertEquals } from \"@std/assert\";\n *\n * const data = parseAll(`\n * ---\n * id: 1\n * name: Alice\n * ---\n * id: 2\n * name: Bob\n * ---\n * id: 3\n * name: Eve\n * `);\n * assertEquals(data, [ { id: 1, name: \"Alice\" }, { id: 2, name: \"Bob\" }, { id: 3, name: \"Eve\" }]);\n * ```\n *\n * @param content YAML string to parse.\n * @param options Parsing options.\n * @returns Array of parsed documents.\n */ export function parseAll(content, options = {}) {\n content = sanitizeInput(content);\n const state = new LoaderState(content, {\n ...options,\n schema: SCHEMA_MAP.get(options.schema)\n });\n return [\n ...state.readDocuments()\n ];\n}\n//# sourceMappingURL=parse.js.map"],"x_google_ignoreList":[0],"mappings":";;;;;AAQA,SAAS,cAAc,OAAO;AAC5B,SAAQ,OAAO,MAAM;AACrB,KAAI,MAAM,SAAS,GAAG;AAEpB,MAAI,CAAC,MAAM,MAAM,WAAW,MAAM,SAAS,EAAE,CAAC,CAAE,UAAS;AAEzD,MAAI,MAAM,WAAW,EAAE,KAAK,MAAQ,SAAQ,MAAM,MAAM,EAAE;;AAG5D,UAAS;AACT,QAAO;;;;;;;;;;;;;;;;;;;;;;;;GAwBL,SAAgB,MAAM,SAAS,UAAU,EAAE,EAAE;AAC/C,WAAU,cAAc,QAAQ;CAKhC,MAAM,oBAJQ,IAAI,YAAY,SAAS;EACrC,GAAG;EACH,QAAQ,WAAW,IAAI,QAAQ,OAAO;EACvC,CAAC,CAC8B,eAAe;CAC/C,MAAM,WAAW,kBAAkB,MAAM,CAAC;AAC1C,KAAI,CAAC,kBAAkB,MAAM,CAAC,KAC5B,OAAM,IAAI,YAAY,uEAAuE;AAE/F,QAAO,YAAY"}
|
package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/stringify.mjs
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { SCHEMA_MAP } from "./_schema.mjs";
|
|
2
|
+
import { DumperState } from "./_dumper_state.mjs";
|
|
3
|
+
|
|
4
|
+
//#region node_modules/.pnpm/@jsr+std__yaml@1.0.10/node_modules/@jsr/std__yaml/stringify.js
|
|
5
|
+
/**
|
|
6
|
+
* Converts a JavaScript object or value to a YAML document string.
|
|
7
|
+
*
|
|
8
|
+
* @example Usage
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { stringify } from "@std/yaml/stringify";
|
|
11
|
+
* import { assertEquals } from "@std/assert";
|
|
12
|
+
*
|
|
13
|
+
* const data = { id: 1, name: "Alice" };
|
|
14
|
+
* const yaml = stringify(data);
|
|
15
|
+
*
|
|
16
|
+
* assertEquals(yaml, "id: 1\nname: Alice\n");
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @throws {TypeError} If `data` contains invalid types.
|
|
20
|
+
* @param data The data to serialize.
|
|
21
|
+
* @param options The options for serialization.
|
|
22
|
+
* @returns A YAML string.
|
|
23
|
+
*/ function stringify(data, options = {}) {
|
|
24
|
+
return new DumperState({
|
|
25
|
+
...options,
|
|
26
|
+
schema: SCHEMA_MAP.get(options.schema)
|
|
27
|
+
}).stringify(data);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
export { stringify };
|
|
32
|
+
//# sourceMappingURL=stringify.mjs.map
|
package/dist/node_modules/.pnpm/@jsr_std__yaml@1.0.10/node_modules/@jsr/std__yaml/stringify.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stringify.mjs","names":[],"sources":["../../../../../../../node_modules/.pnpm/@jsr+std__yaml@1.0.10/node_modules/@jsr/std__yaml/stringify.js"],"sourcesContent":["// Ported from js-yaml v3.13.1:\n// https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da\n// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.\n// Copyright 2018-2025 the Deno authors. MIT license.\n// This module is browser compatible.\nimport { DumperState } from \"./_dumper_state.js\";\nimport { SCHEMA_MAP } from \"./_schema.js\";\n/**\n * Converts a JavaScript object or value to a YAML document string.\n *\n * @example Usage\n * ```ts\n * import { stringify } from \"@std/yaml/stringify\";\n * import { assertEquals } from \"@std/assert\";\n *\n * const data = { id: 1, name: \"Alice\" };\n * const yaml = stringify(data);\n *\n * assertEquals(yaml, \"id: 1\\nname: Alice\\n\");\n * ```\n *\n * @throws {TypeError} If `data` contains invalid types.\n * @param data The data to serialize.\n * @param options The options for serialization.\n * @returns A YAML string.\n */ export function stringify(data, options = {}) {\n const state = new DumperState({\n ...options,\n schema: SCHEMA_MAP.get(options.schema)\n });\n return state.stringify(data);\n}\n//# sourceMappingURL=stringify.js.map"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;;;;;;;;;;;;;GAyBI,SAAgB,UAAU,MAAM,UAAU,EAAE,EAAE;AAKhD,QAJc,IAAI,YAAY;EAC5B,GAAG;EACH,QAAQ,WAAW,IAAI,QAAQ,OAAO;EACvC,CAAC,CACW,UAAU,KAAK"}
|
package/dist/parse.mjs
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { getEngine } from "./engines.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/parse.ts
|
|
4
|
+
/**
|
|
5
|
+
* Parse front matter string using the specified language engine
|
|
6
|
+
*/
|
|
7
|
+
function parse(language, str) {
|
|
8
|
+
return getEngine(language).parse(str);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
export { parse };
|
|
13
|
+
//# sourceMappingURL=parse.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.mjs","names":[],"sources":["../src/parse.ts"],"sourcesContent":["import { type BuiltinLanguage, getEngine } from \"./engines.ts\";\n\n/**\n * Parse front matter string using the specified language engine\n */\nexport function parse(language: BuiltinLanguage, str: string): Record<string, unknown> {\n const engine = getEngine(language);\n return engine.parse(str);\n}\n"],"mappings":";;;;;;AAKA,SAAgB,MAAM,UAA2B,KAAsC;AAErF,QADe,UAAU,SAAS,CACpB,MAAM,IAAI"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { isObject } from "./utils.mjs";
|
|
2
|
+
import { defaults } from "./defaults.mjs";
|
|
3
|
+
import { getEngine, toBuiltinLanguage } from "./engines.mjs";
|
|
4
|
+
|
|
5
|
+
//#region src/stringify.ts
|
|
6
|
+
/**
|
|
7
|
+
* Type guard for GrayMatterFile
|
|
8
|
+
*/
|
|
9
|
+
function isGrayMatterFile(val) {
|
|
10
|
+
return isObject(val) && "content" in val && "data" in val;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Ensure string ends with newline
|
|
14
|
+
*/
|
|
15
|
+
function newline(str) {
|
|
16
|
+
return str.slice(-1) !== "\n" ? str + "\n" : str;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Stringify file object to string with front matter
|
|
20
|
+
*/
|
|
21
|
+
function stringify(file, data, options) {
|
|
22
|
+
if (data == null && options == null) if (isGrayMatterFile(file)) {
|
|
23
|
+
data = file.data;
|
|
24
|
+
options = {};
|
|
25
|
+
} else if (typeof file === "string") return file;
|
|
26
|
+
else throw new TypeError("expected file to be a string or object");
|
|
27
|
+
if (!isGrayMatterFile(file)) throw new TypeError("expected file to be a string or object");
|
|
28
|
+
const str = file.content;
|
|
29
|
+
const opts = defaults(options);
|
|
30
|
+
if (data == null) {
|
|
31
|
+
if (!opts.data) return str;
|
|
32
|
+
data = opts.data;
|
|
33
|
+
}
|
|
34
|
+
const engine = getEngine(toBuiltinLanguage(file.language || opts.language));
|
|
35
|
+
data = {
|
|
36
|
+
...file.data,
|
|
37
|
+
...data
|
|
38
|
+
};
|
|
39
|
+
const open = opts.delimiters[0];
|
|
40
|
+
const close = opts.delimiters[1];
|
|
41
|
+
const matter = engine.stringify(data).trim();
|
|
42
|
+
let buf = "";
|
|
43
|
+
if (matter !== "{}") buf = newline(open) + newline(matter) + newline(close);
|
|
44
|
+
if (typeof file.excerpt === "string" && file.excerpt !== "") {
|
|
45
|
+
if (str.indexOf(file.excerpt.trim()) === -1) buf += newline(file.excerpt) + newline(close);
|
|
46
|
+
}
|
|
47
|
+
return buf + newline(str);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
//#endregion
|
|
51
|
+
export { stringify };
|
|
52
|
+
//# sourceMappingURL=stringify.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stringify.mjs","names":[],"sources":["../src/stringify.ts"],"sourcesContent":["import { defaults } from \"./defaults.ts\";\nimport { getEngine, toBuiltinLanguage } from \"./engines.ts\";\nimport type { GrayMatterFile, GrayMatterOptions } from \"./types.ts\";\nimport { isObject } from \"./utils.ts\";\n\n/**\n * Type guard for GrayMatterFile\n */\nfunction isGrayMatterFile(val: unknown): val is GrayMatterFile {\n return isObject(val) && \"content\" in val && \"data\" in val;\n}\n\n/**\n * Ensure string ends with newline\n */\nfunction newline(str: string): string {\n return str.slice(-1) !== \"\\n\" ? str + \"\\n\" : str;\n}\n\n/**\n * Stringify file object to string with front matter\n */\nexport function stringify(\n file: GrayMatterFile | string,\n data?: Record<string, unknown> | null,\n options?: GrayMatterOptions,\n): string {\n if (data == null && options == null) {\n if (isGrayMatterFile(file)) {\n data = file.data;\n options = {};\n } else if (typeof file === \"string\") {\n return file;\n } else {\n throw new TypeError(\"expected file to be a string or object\");\n }\n }\n\n if (!isGrayMatterFile(file)) {\n throw new TypeError(\"expected file to be a string or object\");\n }\n\n const str = file.content;\n const opts = defaults(options);\n\n if (data == null) {\n if (!opts.data) return str;\n data = opts.data;\n }\n\n const language = toBuiltinLanguage(file.language || opts.language);\n const engine = getEngine(language);\n\n data = { ...file.data, ...data };\n const open = opts.delimiters[0];\n const close = opts.delimiters[1];\n const matter = engine.stringify!(data).trim();\n let buf = \"\";\n\n if (matter !== \"{}\") {\n buf = newline(open) + newline(matter) + newline(close);\n }\n\n if (typeof file.excerpt === \"string\" && file.excerpt !== \"\") {\n if (str.indexOf(file.excerpt.trim()) === -1) {\n buf += newline(file.excerpt) + newline(close);\n }\n }\n\n return buf + newline(str);\n}\n\nif (import.meta.vitest) {\n const { fc, test } = await import(\"@fast-check/vitest\");\n\n describe(\"stringify\", () => {\n it(\"should stringify file object with data\", () => {\n const file = {\n content: \"hello world\",\n data: { title: \"Test\" },\n excerpt: \"\",\n orig: Buffer.from(\"\"),\n language: \"yaml\",\n matter: \"\",\n isEmpty: false,\n stringify: () => \"\",\n };\n const result = stringify(file);\n expect(result).toContain(\"---\");\n expect(result).toContain(\"title: Test\");\n expect(result).toContain(\"hello world\");\n });\n\n it(\"should return string as-is when only string provided\", () => {\n expect(stringify(\"hello\")).toBe(\"hello\");\n });\n\n it(\"should throw for invalid input\", () => {\n expect(() => stringify(123 as unknown as string)).toThrow(TypeError);\n });\n\n it(\"should ensure trailing newline\", () => {\n const file = {\n content: \"no newline\",\n data: { key: \"value\" },\n excerpt: \"\",\n orig: Buffer.from(\"\"),\n language: \"yaml\",\n matter: \"\",\n isEmpty: false,\n stringify: () => \"\",\n };\n const result = stringify(file);\n expect(result.endsWith(\"\\n\")).toBe(true);\n });\n\n it(\"should not add front matter for empty data\", () => {\n const file = {\n content: \"content only\",\n data: {},\n excerpt: \"\",\n orig: Buffer.from(\"\"),\n language: \"yaml\",\n matter: \"\",\n isEmpty: false,\n stringify: () => \"\",\n };\n const result = stringify(file, {});\n expect(result).toBe(\"content only\\n\");\n });\n\n it(\"should include excerpt when present and not in content\", () => {\n const file = {\n content: \"main content\",\n data: { title: \"Test\" },\n excerpt: \"This is excerpt\",\n orig: Buffer.from(\"\"),\n language: \"yaml\",\n matter: \"\",\n isEmpty: false,\n stringify: () => \"\",\n };\n const result = stringify(file);\n expect(result).toContain(\"This is excerpt\");\n });\n\n test.prop([\n fc.record({\n title: fc.string({ minLength: 1, maxLength: 50 }),\n count: fc.integer({ min: 0, max: 1000 }),\n enabled: fc.boolean(),\n }),\n ])(\"should always produce string ending with newline for any data\", (data) => {\n const file = {\n content: \"test content\",\n data,\n excerpt: \"\",\n orig: Buffer.from(\"\"),\n language: \"yaml\",\n matter: \"\",\n isEmpty: false,\n stringify: () => \"\",\n };\n const result = stringify(file);\n expect(result.endsWith(\"\\n\")).toBe(true);\n });\n\n test.prop([fc.string({ minLength: 0, maxLength: 100 })])(\n \"should handle any content string\",\n (content) => {\n const file = {\n content,\n data: { key: \"value\" },\n excerpt: \"\",\n orig: Buffer.from(\"\"),\n language: \"yaml\",\n matter: \"\",\n isEmpty: false,\n stringify: () => \"\",\n };\n const result = stringify(file);\n expect(typeof result).toBe(\"string\");\n expect(result.endsWith(\"\\n\")).toBe(true);\n },\n );\n });\n}\n"],"mappings":";;;;;;;;AAQA,SAAS,iBAAiB,KAAqC;AAC7D,QAAO,SAAS,IAAI,IAAI,aAAa,OAAO,UAAU;;;;;AAMxD,SAAS,QAAQ,KAAqB;AACpC,QAAO,IAAI,MAAM,GAAG,KAAK,OAAO,MAAM,OAAO;;;;;AAM/C,SAAgB,UACd,MACA,MACA,SACQ;AACR,KAAI,QAAQ,QAAQ,WAAW,KAC7B,KAAI,iBAAiB,KAAK,EAAE;AAC1B,SAAO,KAAK;AACZ,YAAU,EAAE;YACH,OAAO,SAAS,SACzB,QAAO;KAEP,OAAM,IAAI,UAAU,yCAAyC;AAIjE,KAAI,CAAC,iBAAiB,KAAK,CACzB,OAAM,IAAI,UAAU,yCAAyC;CAG/D,MAAM,MAAM,KAAK;CACjB,MAAM,OAAO,SAAS,QAAQ;AAE9B,KAAI,QAAQ,MAAM;AAChB,MAAI,CAAC,KAAK,KAAM,QAAO;AACvB,SAAO,KAAK;;CAId,MAAM,SAAS,UADE,kBAAkB,KAAK,YAAY,KAAK,SAAS,CAChC;AAElC,QAAO;EAAE,GAAG,KAAK;EAAM,GAAG;EAAM;CAChC,MAAM,OAAO,KAAK,WAAW;CAC7B,MAAM,QAAQ,KAAK,WAAW;CAC9B,MAAM,SAAS,OAAO,UAAW,KAAK,CAAC,MAAM;CAC7C,IAAI,MAAM;AAEV,KAAI,WAAW,KACb,OAAM,QAAQ,KAAK,GAAG,QAAQ,OAAO,GAAG,QAAQ,MAAM;AAGxD,KAAI,OAAO,KAAK,YAAY,YAAY,KAAK,YAAY,IACvD;MAAI,IAAI,QAAQ,KAAK,QAAQ,MAAM,CAAC,KAAK,GACvC,QAAO,QAAQ,KAAK,QAAQ,GAAG,QAAQ,MAAM;;AAIjD,QAAO,MAAM,QAAQ,IAAI"}
|
package/dist/to-file.mjs
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { getStringProp, isObject, toBuffer, toString } from "./utils.mjs";
|
|
2
|
+
import { stringify } from "./stringify.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/to-file.ts
|
|
5
|
+
/**
|
|
6
|
+
* Normalize input to a consistent shape
|
|
7
|
+
*/
|
|
8
|
+
function normalizeInput(input) {
|
|
9
|
+
if (isObject(input)) return {
|
|
10
|
+
content: getStringProp(input, "content"),
|
|
11
|
+
data: input.data,
|
|
12
|
+
language: getStringProp(input, "language"),
|
|
13
|
+
matter: getStringProp(input, "matter")
|
|
14
|
+
};
|
|
15
|
+
return { content: input };
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Normalize the given value to ensure an object is returned
|
|
19
|
+
* with the expected properties.
|
|
20
|
+
*/
|
|
21
|
+
function toFile(input) {
|
|
22
|
+
const normalized = normalizeInput(input);
|
|
23
|
+
const data = isObject(normalized.data) ? normalized.data : {};
|
|
24
|
+
const content = toString(normalized.content ?? "");
|
|
25
|
+
const language = normalized.language ?? "";
|
|
26
|
+
const matter = normalized.matter ?? "";
|
|
27
|
+
return {
|
|
28
|
+
data,
|
|
29
|
+
content,
|
|
30
|
+
excerpt: "",
|
|
31
|
+
orig: toBuffer(normalized.content ?? ""),
|
|
32
|
+
language,
|
|
33
|
+
matter,
|
|
34
|
+
isEmpty: false,
|
|
35
|
+
stringify(newData, options) {
|
|
36
|
+
if (options?.language) this.language = options.language;
|
|
37
|
+
return stringify(this, newData, options);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
//#endregion
|
|
43
|
+
export { toFile };
|
|
44
|
+
//# sourceMappingURL=to-file.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"to-file.mjs","names":[],"sources":["../src/to-file.ts"],"sourcesContent":["import type { GrayMatterFile, GrayMatterInput, GrayMatterOptions } from \"./types.ts\";\nimport { getStringProp, isObject, toBuffer, toString } from \"./utils.ts\";\nimport { stringify } from \"./stringify.ts\";\n\n/**\n * Internal input shape after normalization\n */\ninterface NormalizedInput {\n content: string | Buffer;\n data?: unknown;\n language?: string;\n matter?: string;\n}\n\n/**\n * Normalize input to a consistent shape\n */\nfunction normalizeInput(input: GrayMatterInput): NormalizedInput {\n if (isObject(input)) {\n return {\n content: getStringProp(input, \"content\"),\n data: input.data,\n language: getStringProp(input, \"language\"),\n matter: getStringProp(input, \"matter\"),\n };\n }\n // string or Buffer\n return { content: input };\n}\n\n/**\n * Normalize the given value to ensure an object is returned\n * with the expected properties.\n */\nexport function toFile(input: GrayMatterInput): GrayMatterFile {\n const normalized = normalizeInput(input);\n const data = isObject(normalized.data) ? normalized.data : {};\n const content = toString(normalized.content ?? \"\");\n const language = normalized.language ?? \"\";\n const matter = normalized.matter ?? \"\";\n const orig = toBuffer(normalized.content ?? \"\");\n\n const file: GrayMatterFile = {\n data,\n content,\n excerpt: \"\",\n orig,\n language,\n matter,\n isEmpty: false,\n stringify(\n this: GrayMatterFile,\n newData?: Record<string, unknown>,\n options?: GrayMatterOptions,\n ) {\n if (options?.language) {\n this.language = options.language;\n }\n return stringify(this, newData, options);\n },\n };\n\n return file;\n}\n\nif (import.meta.vitest) {\n const { fc, test } = await import(\"@fast-check/vitest\");\n const { Buffer } = await import(\"node:buffer\");\n\n describe(\"toFile\", () => {\n it(\"should convert string to file object\", () => {\n const result = toFile(\"hello world\");\n expect(result.content).toBe(\"hello world\");\n expect(result.data).toEqual({});\n expect(result.isEmpty).toBe(false);\n expect(result.excerpt).toBe(\"\");\n expect(result.language).toBe(\"\");\n expect(result.matter).toBe(\"\");\n });\n\n it(\"should convert Buffer to file object\", () => {\n const result = toFile(Buffer.from(\"buffer content\"));\n expect(result.content).toBe(\"buffer content\");\n expect(result.data).toEqual({});\n });\n\n it(\"should handle object with content property\", () => {\n const result = toFile({ content: \"object content\", data: { key: \"value\" } });\n expect(result.content).toBe(\"object content\");\n expect(result.data).toEqual({ key: \"value\" });\n });\n\n it(\"should preserve orig as Buffer\", () => {\n const result = toFile(\"test\");\n expect(Buffer.isBuffer(result.orig)).toBe(true);\n expect(result.orig.toString()).toBe(\"test\");\n });\n\n it(\"should set stringify as a function\", () => {\n const result = toFile(\"content\");\n expect(typeof result.stringify).toBe(\"function\");\n });\n\n it(\"should initialize data to empty object if not provided\", () => {\n const result = toFile({ content: \"test\" });\n expect(result.data).toEqual({});\n });\n\n it(\"should strip BOM from content\", () => {\n const bomString = \"\\uFEFFhello\";\n const result = toFile(bomString);\n expect(result.content).toBe(\"hello\");\n });\n\n it(\"should preserve existing language\", () => {\n const result = toFile({ content: \"test\", language: \"json\" } as GrayMatterInput);\n expect(result.language).toBe(\"json\");\n });\n\n it(\"should preserve existing matter\", () => {\n const result = toFile({ content: \"test\", matter: \"raw matter\" } as GrayMatterInput);\n expect(result.matter).toBe(\"raw matter\");\n });\n\n test.prop([fc.string({ minLength: 0, maxLength: 200 })])(\n \"should always return valid file object for any string\",\n (input) => {\n const result = toFile(input);\n expect(typeof result.content).toBe(\"string\");\n expect(typeof result.data).toBe(\"object\");\n expect(result.data).not.toBeNull();\n expect(typeof result.isEmpty).toBe(\"boolean\");\n expect(typeof result.excerpt).toBe(\"string\");\n expect(typeof result.language).toBe(\"string\");\n expect(typeof result.matter).toBe(\"string\");\n expect(Buffer.isBuffer(result.orig)).toBe(true);\n expect(typeof result.stringify).toBe(\"function\");\n },\n );\n\n test.prop([fc.uint8Array({ minLength: 0, maxLength: 200 })])(\n \"should handle any Buffer input\",\n (arr) => {\n const buffer = Buffer.from(arr);\n const result = toFile(buffer);\n expect(typeof result.content).toBe(\"string\");\n expect(Buffer.isBuffer(result.orig)).toBe(true);\n },\n );\n\n test.prop([\n fc.record({\n content: fc.string({ minLength: 0, maxLength: 100 }),\n data: fc.option(fc.dictionary(fc.string(), fc.string(), { maxKeys: 5 }), {\n nil: undefined,\n }),\n }),\n ])(\"should handle object input with optional data\", ({ content, data }) => {\n const input = data !== undefined ? { content, data } : { content };\n const result = toFile(input);\n expect(result.content).toBe(content);\n expect(typeof result.data).toBe(\"object\");\n if (data !== undefined) {\n expect(result.data).toEqual(data);\n }\n });\n\n test.prop([fc.string({ minLength: 1, maxLength: 50 })])(\n \"should strip BOM consistently\",\n (str) => {\n const withBom = \"\\uFEFF\" + str;\n const result = toFile(withBom);\n expect(result.content).toBe(str);\n expect(result.content.charCodeAt(0)).not.toBe(0xfeff);\n },\n );\n });\n}\n"],"mappings":";;;;;;;AAiBA,SAAS,eAAe,OAAyC;AAC/D,KAAI,SAAS,MAAM,CACjB,QAAO;EACL,SAAS,cAAc,OAAO,UAAU;EACxC,MAAM,MAAM;EACZ,UAAU,cAAc,OAAO,WAAW;EAC1C,QAAQ,cAAc,OAAO,SAAS;EACvC;AAGH,QAAO,EAAE,SAAS,OAAO;;;;;;AAO3B,SAAgB,OAAO,OAAwC;CAC7D,MAAM,aAAa,eAAe,MAAM;CACxC,MAAM,OAAO,SAAS,WAAW,KAAK,GAAG,WAAW,OAAO,EAAE;CAC7D,MAAM,UAAU,SAAS,WAAW,WAAW,GAAG;CAClD,MAAM,WAAW,WAAW,YAAY;CACxC,MAAM,SAAS,WAAW,UAAU;AAuBpC,QApB6B;EAC3B;EACA;EACA,SAAS;EACT,MANW,SAAS,WAAW,WAAW,GAAG;EAO7C;EACA;EACA,SAAS;EACT,UAEE,SACA,SACA;AACA,OAAI,SAAS,SACX,MAAK,WAAW,QAAQ;AAE1B,UAAO,UAAU,MAAM,SAAS,QAAQ;;EAE3C"}
|