@decimalturn/toml-patch 3.1.0 → 3.1.1-dev
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dev/comment-alignment.js +372 -0
- package/dist/dev/comment-alignment.js.map +1 -0
- package/dist/dev/comment-ownership.js +660 -0
- package/dist/dev/comment-ownership.js.map +1 -0
- package/dist/dev/cst-source.js +108 -0
- package/dist/dev/cst-source.js.map +1 -0
- package/dist/dev/cst.js +59 -0
- package/dist/dev/cst.js.map +1 -0
- package/dist/dev/cursor.js +66 -0
- package/dist/dev/cursor.js.map +1 -0
- package/dist/dev/date-format.js +196 -0
- package/dist/dev/date-format.js.map +1 -0
- package/dist/dev/decode-utf8.js +27 -0
- package/dist/dev/decode-utf8.js.map +1 -0
- package/dist/dev/diff.js +269 -0
- package/dist/dev/diff.js.map +1 -0
- package/dist/dev/escape-preference.js +144 -0
- package/dist/dev/escape-preference.js.map +1 -0
- package/dist/dev/find-by-path.js +111 -0
- package/dist/dev/find-by-path.js.map +1 -0
- package/dist/dev/formatter.js +295 -0
- package/dist/dev/formatter.js.map +1 -0
- package/dist/dev/generate.js +451 -0
- package/dist/dev/generate.js.map +1 -0
- package/dist/dev/inline-comma-space.js +13 -0
- package/dist/dev/inline-comma-space.js.map +1 -0
- package/dist/dev/inline-format.js +106 -0
- package/dist/dev/inline-format.js.map +1 -0
- package/dist/dev/inline-layout.js +107 -0
- package/dist/dev/inline-layout.js.map +1 -0
- package/dist/dev/line-ending-backslash.js +320 -0
- package/dist/dev/line-ending-backslash.js.map +1 -0
- package/dist/dev/location.js +104 -0
- package/dist/dev/location.js.map +1 -0
- package/dist/dev/parse-error.js +27 -0
- package/dist/dev/parse-error.js.map +1 -0
- package/dist/dev/parse-js.js +103 -0
- package/dist/dev/parse-js.js.map +1 -0
- package/dist/dev/parse-string.js +122 -0
- package/dist/dev/parse-string.js.map +1 -0
- package/dist/dev/parse-toml.js +677 -0
- package/dist/dev/parse-toml.js.map +1 -0
- package/dist/dev/patch.js +2537 -0
- package/dist/dev/patch.js.map +1 -0
- package/dist/dev/to-js.js +303 -0
- package/dist/dev/to-js.js.map +1 -0
- package/dist/dev/to-toml.js +569 -0
- package/dist/dev/to-toml.js.map +1 -0
- package/dist/dev/tokenizer.js +225 -0
- package/dist/dev/tokenizer.js.map +1 -0
- package/dist/dev/toml-document.js +215 -0
- package/dist/dev/toml-document.js.map +1 -0
- package/dist/dev/toml-format.js +476 -0
- package/dist/dev/toml-format.js.map +1 -0
- package/dist/dev/toml-patch.js +84 -0
- package/dist/dev/toml-patch.js.map +1 -0
- package/dist/dev/traverse.js +61 -0
- package/dist/dev/traverse.js.map +1 -0
- package/dist/dev/truncate.js +64 -0
- package/dist/dev/truncate.js.map +1 -0
- package/dist/dev/update-order.js +235 -0
- package/dist/dev/update-order.js.map +1 -0
- package/dist/dev/utils.js +223 -0
- package/dist/dev/utils.js.map +1 -0
- package/dist/dev/writer.js +758 -0
- package/dist/dev/writer.js.map +1 -0
- package/dist/toml-patch.d.ts +10 -10
- package/package.json +11 -92
- package/LICENSE +0 -22
- package/README.md +0 -169
- package/dist/toml-patch.js +0 -54
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
//! @decimalturn/toml-patch v3.1.1 - https://github.com/DecimalTurn/toml-patch - @license: MIT
|
|
2
|
+
//#region src/escape-preference.ts
|
|
3
|
+
/**
|
|
4
|
+
* @file Escape-style helpers used to preserve escape sequences as preferred encoding (e.g. \u263A)
|
|
5
|
+
* when rewriting TOML basic strings and quoted key parts.
|
|
6
|
+
*
|
|
7
|
+
* @module escape-preference
|
|
8
|
+
*
|
|
9
|
+
* Summary:
|
|
10
|
+
* The problem with naive parsing + re-serializing of TOML strings is that it normalizes
|
|
11
|
+
* all escape sequences to their decoded character values.
|
|
12
|
+
*
|
|
13
|
+
* For example, if a TOML string contains `\u263A`, the JS string value will contain the raw ☺ character.
|
|
14
|
+
* If we then naively return that string for TOML output, we would get `☺` instead of the original `\u263A`.
|
|
15
|
+
* This module provides functions to scan existing raw TOML strings to infer the preferred representation of certain characters
|
|
16
|
+
* and then reuse those preferred escapes when generating new TOML output, thus preserving the original style where possible.
|
|
17
|
+
*
|
|
18
|
+
* Note that we are taking the presence of a single instance of an escape sequence in the original raw string as
|
|
19
|
+
* an indication of the user's preferred rendering for that character. A more faithful preservation of style
|
|
20
|
+
* would be to track all instances of each character and their various rendered forms, but this would add
|
|
21
|
+
* complexity and overhead. The current approach tries to balance things out by capturing the first seen
|
|
22
|
+
* escape for each character, which should cover the vast majority of use cases for TOML.
|
|
23
|
+
*
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* Decodes a TOML single-character escape code to its JS character.
|
|
27
|
+
*
|
|
28
|
+
* @param ch - Escape code character (without the leading backslash).
|
|
29
|
+
* @returns The decoded character, or null if the code is not a supported simple escape.
|
|
30
|
+
*/
|
|
31
|
+
function decodeSimpleEscape(ch) {
|
|
32
|
+
switch (ch) {
|
|
33
|
+
case "b": return "\b";
|
|
34
|
+
case "t": return " ";
|
|
35
|
+
case "n": return "\n";
|
|
36
|
+
case "f": return "\f";
|
|
37
|
+
case "r": return "\r";
|
|
38
|
+
case "\"": return "\"";
|
|
39
|
+
case "\\": return "\\";
|
|
40
|
+
default: return null;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function isDisallowedControl(code, mode) {
|
|
44
|
+
if (mode === "singleline-basic") return code <= 31 || code === 127;
|
|
45
|
+
return code >= 0 && code <= 7 || code === 11 || code >= 14 && code <= 31 || code === 127;
|
|
46
|
+
}
|
|
47
|
+
function mandatoryEscaping(ch, mode) {
|
|
48
|
+
switch (ch) {
|
|
49
|
+
case "\\": return "\\\\";
|
|
50
|
+
case "\b": return "\\b";
|
|
51
|
+
case " ": return "\\t";
|
|
52
|
+
case "\f": return "\\f";
|
|
53
|
+
case "\"": return mode === "singleline-basic" ? "\\\"" : "\"";
|
|
54
|
+
case "\n": return mode === "singleline-basic" ? "\\n" : "\n";
|
|
55
|
+
case "\r": return mode === "singleline-basic" ? "\\r" : "\r";
|
|
56
|
+
default: {
|
|
57
|
+
const code = ch.charCodeAt(0);
|
|
58
|
+
if (isDisallowedControl(code, mode)) return `\\u${code.toString(16).padStart(4, "0").toUpperCase()}`;
|
|
59
|
+
return ch;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Scans a raw TOML string token and records preferred escape sequence representations for characters.
|
|
65
|
+
*
|
|
66
|
+
* Example: if `existingRaw` contains `\u263A`, this map stores `☺ -> "\\u263A"`.
|
|
67
|
+
* The first seen escape for a character wins to preserve original style.
|
|
68
|
+
*
|
|
69
|
+
* @param existingRaw - Raw TOML string content including escape sequences.
|
|
70
|
+
* @returns A map from decoded character to preferred TOML escape sequence representation.
|
|
71
|
+
*/
|
|
72
|
+
function collectPreferredEscapes(existingRaw) {
|
|
73
|
+
const preferred = /* @__PURE__ */ new Map();
|
|
74
|
+
for (let i = 0; i < existingRaw.length; i++) {
|
|
75
|
+
if (existingRaw[i] !== "\\") continue;
|
|
76
|
+
const n1 = existingRaw[i + 1];
|
|
77
|
+
if (!n1) continue;
|
|
78
|
+
const simple = decodeSimpleEscape(n1);
|
|
79
|
+
if (simple !== null) {
|
|
80
|
+
if (simple !== "\n" && simple !== "\r" && !preferred.has(simple)) preferred.set(simple, "\\" + n1);
|
|
81
|
+
i += 1;
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
if (n1 === "x" && /^[0-9A-Fa-f]{2}$/.test(existingRaw.slice(i + 2, i + 4))) {
|
|
85
|
+
const rawEscape = existingRaw.slice(i, i + 4);
|
|
86
|
+
const code = Number.parseInt(existingRaw.slice(i + 2, i + 4), 16);
|
|
87
|
+
const decoded = String.fromCharCode(code);
|
|
88
|
+
if (!preferred.has(decoded)) preferred.set(decoded, rawEscape);
|
|
89
|
+
i += 3;
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
if (n1 === "u" && /^[0-9A-Fa-f]{4}$/.test(existingRaw.slice(i + 2, i + 6))) {
|
|
93
|
+
const rawEscape = existingRaw.slice(i, i + 6);
|
|
94
|
+
const code = Number.parseInt(existingRaw.slice(i + 2, i + 6), 16);
|
|
95
|
+
const decoded = String.fromCodePoint(code);
|
|
96
|
+
if (!preferred.has(decoded)) preferred.set(decoded, rawEscape);
|
|
97
|
+
i += 5;
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
if (n1 === "U" && /^[0-9A-Fa-f]{8}$/.test(existingRaw.slice(i + 2, i + 10))) {
|
|
101
|
+
const rawEscape = existingRaw.slice(i, i + 10);
|
|
102
|
+
const code = Number.parseInt(existingRaw.slice(i + 2, i + 10), 16);
|
|
103
|
+
const decoded = String.fromCodePoint(code);
|
|
104
|
+
if (!preferred.has(decoded)) preferred.set(decoded, rawEscape);
|
|
105
|
+
i += 9;
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return preferred;
|
|
110
|
+
}
|
|
111
|
+
function applyPreferredAndMandatoryEscapes(value, preferred, mode) {
|
|
112
|
+
let escaped = "";
|
|
113
|
+
for (const ch of value) {
|
|
114
|
+
const preferredEscape = preferred.get(ch);
|
|
115
|
+
if (preferredEscape) {
|
|
116
|
+
escaped += preferredEscape;
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
escaped += mandatoryEscaping(ch, mode);
|
|
120
|
+
}
|
|
121
|
+
return escaped;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Escapes TOML basic-string content while preserving preferred escape sequences representation from existing raw text.
|
|
125
|
+
*
|
|
126
|
+
* In `singleline-basic` mode, output is suitable for `"..."` strings.
|
|
127
|
+
* In `multiline-basic` mode, output is suitable for `"""..."""` strings and additionally
|
|
128
|
+
* protects embedded triple quotes.
|
|
129
|
+
*
|
|
130
|
+
* @param value - Unescaped JS string value.
|
|
131
|
+
* @param existingRaw - Existing TOML raw string used to infer preferred escapes.
|
|
132
|
+
* @param mode - String rendering mode (`singleline-basic` or `multiline-basic`).
|
|
133
|
+
* @returns Escaped TOML string content without surrounding delimiters.
|
|
134
|
+
*/
|
|
135
|
+
function escapeStringContent(value, existingRaw, mode) {
|
|
136
|
+
const preferred = collectPreferredEscapes(existingRaw);
|
|
137
|
+
if (preferred.size === 0 && mode === "singleline-basic") return JSON.stringify(value).slice(1, -1).replace(/\x7f/g, "\\u007F");
|
|
138
|
+
const escaped = applyPreferredAndMandatoryEscapes(value, preferred, mode);
|
|
139
|
+
return mode === "multiline-basic" ? escaped.replace(/"""/g, "\"\"\\\"") : escaped;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
//#endregion
|
|
143
|
+
export { collectPreferredEscapes, escapeStringContent };
|
|
144
|
+
//# sourceMappingURL=escape-preference.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"escape-preference.js","names":[],"sources":["../../src/escape-preference.ts"],"sourcesContent":["/**\n * @file Escape-style helpers used to preserve escape sequences as preferred encoding (e.g. \\u263A)\n * when rewriting TOML basic strings and quoted key parts.\n * \n * @module escape-preference\n * \n * Summary:\n * The problem with naive parsing + re-serializing of TOML strings is that it normalizes \n * all escape sequences to their decoded character values.\n * \n * For example, if a TOML string contains `\\u263A`, the JS string value will contain the raw ☺ character.\n * If we then naively return that string for TOML output, we would get `☺` instead of the original `\\u263A`.\n * This module provides functions to scan existing raw TOML strings to infer the preferred representation of certain characters\n * and then reuse those preferred escapes when generating new TOML output, thus preserving the original style where possible.\n * \n * Note that we are taking the presence of a single instance of an escape sequence in the original raw string as \n * an indication of the user's preferred rendering for that character. A more faithful preservation of style \n * would be to track all instances of each character and their various rendered forms, but this would add \n * complexity and overhead. The current approach tries to balance things out by capturing the first seen \n * escape for each character, which should cover the vast majority of use cases for TOML.\n * \n */\n\n/**\n * Decodes a TOML single-character escape code to its JS character.\n *\n * @param ch - Escape code character (without the leading backslash).\n * @returns The decoded character, or null if the code is not a supported simple escape.\n */\nfunction decodeSimpleEscape(ch: string): string | null {\n switch (ch) {\n case 'b': return '\\b';\n case 't': return '\\t';\n case 'n': return '\\n';\n case 'f': return '\\f';\n case 'r': return '\\r';\n case '\"': return '\"'; // Note that double quotes don't need escaping in JS.\n // Note that single quotes are not escaped in TOML basic strings, so no case for '\\'' is needed.\n case '\\\\': return '\\\\';\n default: return null;\n }\n}\n\nexport type EscapeMode = 'singleline-basic' | 'multiline-basic';\n\nfunction isDisallowedControl(code: number, mode: EscapeMode): boolean {\n if (mode === 'singleline-basic') {\n return code <= 0x1f || code === 0x7f;\n }\n\n return (\n (code >= 0x00 && code <= 0x07) ||\n code === 0x0b ||\n (code >= 0x0e && code <= 0x1f) ||\n code === 0x7f\n );\n}\n\nfunction mandatoryEscaping(ch: string, mode: EscapeMode): string {\n switch (ch) {\n case '\\\\':\n return '\\\\\\\\';\n case '\\b':\n return '\\\\b';\n case '\\t':\n return '\\\\t';\n case '\\f':\n return '\\\\f';\n case '\"':\n return mode === 'singleline-basic' ? '\\\\\"' : '\"';\n case '\\n':\n return mode === 'singleline-basic' ? '\\\\n' : '\\n';\n case '\\r':\n return mode === 'singleline-basic' ? '\\\\r' : '\\r';\n default: {\n const code = ch.charCodeAt(0);\n if (isDisallowedControl(code, mode)) {\n return `\\\\u${code.toString(16).padStart(4, '0').toUpperCase()}`;\n }\n return ch;\n }\n }\n}\n\n/**\n * Scans a raw TOML string token and records preferred escape sequence representations for characters.\n *\n * Example: if `existingRaw` contains `\\u263A`, this map stores `☺ -> \"\\\\u263A\"`.\n * The first seen escape for a character wins to preserve original style.\n *\n * @param existingRaw - Raw TOML string content including escape sequences.\n * @returns A map from decoded character to preferred TOML escape sequence representation.\n */\nexport function collectPreferredEscapes(existingRaw: string): Map<string, string> {\n const preferred = new Map<string, string>();\n\n for (let i = 0; i < existingRaw.length; i++) {\n if (existingRaw[i] !== '\\\\') continue;\n\n const n1 = existingRaw[i + 1];\n if (!n1) continue;\n\n const simple = decodeSimpleEscape(n1);\n if (simple !== null) {\n // Newlines (\\n, \\r) are handled separately and excluded from preference tracking.\n if (simple !== '\\n' && simple !== '\\r' && !preferred.has(simple)) {\n preferred.set(simple, '\\\\' + n1);\n }\n i += 1;\n continue;\n }\n\n if (n1 === 'x' && /^[0-9A-Fa-f]{2}$/.test(existingRaw.slice(i + 2, i + 4))) {\n const rawEscape = existingRaw.slice(i, i + 4);\n const code = Number.parseInt(existingRaw.slice(i + 2, i + 4), 16);\n const decoded = String.fromCharCode(code);\n if (!preferred.has(decoded)) preferred.set(decoded, rawEscape);\n i += 3;\n continue;\n }\n\n if (n1 === 'u' && /^[0-9A-Fa-f]{4}$/.test(existingRaw.slice(i + 2, i + 6))) {\n const rawEscape = existingRaw.slice(i, i + 6);\n const code = Number.parseInt(existingRaw.slice(i + 2, i + 6), 16);\n const decoded = String.fromCodePoint(code);\n if (!preferred.has(decoded)) preferred.set(decoded, rawEscape);\n i += 5;\n continue;\n }\n\n if (n1 === 'U' && /^[0-9A-Fa-f]{8}$/.test(existingRaw.slice(i + 2, i + 10))) {\n const rawEscape = existingRaw.slice(i, i + 10);\n const code = Number.parseInt(existingRaw.slice(i + 2, i + 10), 16);\n const decoded = String.fromCodePoint(code);\n if (!preferred.has(decoded)) preferred.set(decoded, rawEscape);\n i += 9;\n continue;\n }\n }\n\n return preferred;\n}\n\nfunction applyPreferredAndMandatoryEscapes(\n value: string,\n preferred: Map<string, string>,\n mode: EscapeMode\n): string {\n let escaped = '';\n\n for (const ch of value) {\n const preferredEscape = preferred.get(ch);\n if (preferredEscape) {\n escaped += preferredEscape;\n continue;\n }\n\n escaped += mandatoryEscaping(ch, mode);\n }\n\n return escaped;\n}\n\n/**\n * Escapes TOML basic-string content while preserving preferred escape sequences representation from existing raw text.\n *\n * In `singleline-basic` mode, output is suitable for `\"...\"` strings.\n * In `multiline-basic` mode, output is suitable for `\"\"\"...\"\"\"` strings and additionally\n * protects embedded triple quotes.\n *\n * @param value - Unescaped JS string value.\n * @param existingRaw - Existing TOML raw string used to infer preferred escapes.\n * @param mode - String rendering mode (`singleline-basic` or `multiline-basic`).\n * @returns Escaped TOML string content without surrounding delimiters.\n */\nexport function escapeStringContent(value: string, existingRaw: string, mode: EscapeMode): string {\n const preferred = collectPreferredEscapes(existingRaw);\n\n if (preferred.size === 0 && mode === 'singleline-basic') {\n const escaped = JSON.stringify(value).slice(1, -1);\n // JSON.stringify only escapes U+0000–U+001F, but TOML also forbids U+007F (DEL).\n return escaped.replace(/\\x7f/g, '\\\\u007F');\n }\n\n const escaped = applyPreferredAndMandatoryEscapes(value, preferred, mode);\n\n return mode === 'multiline-basic' ? escaped.replace(/\"\"\"/g, '\"\"\\\\\"') : escaped;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,SAAS,mBAAmB,IAA2B;CACrD,QAAQ,IAAR;EACE,KAAK,KAAK,OAAO;EACjB,KAAK,KAAK,OAAO;EACjB,KAAK,KAAK,OAAO;EACjB,KAAK,KAAK,OAAO;EACjB,KAAK,KAAK,OAAO;EACjB,KAAK,MAAK,OAAO;EAEjB,KAAK,MAAM,OAAO;EAClB,SAAS,OAAO;CAClB;AACF;AAIA,SAAS,oBAAoB,MAAc,MAA2B;CACpE,IAAI,SAAS,oBACX,OAAO,QAAQ,MAAQ,SAAS;CAGlC,OACG,QAAQ,KAAQ,QAAQ,KACzB,SAAS,MACR,QAAQ,MAAQ,QAAQ,MACzB,SAAS;AAEb;AAEA,SAAS,kBAAkB,IAAY,MAA0B;CAC/D,QAAQ,IAAR;EACE,KAAK,MACH,OAAO;EACT,KAAK,MACH,OAAO;EACT,KAAK,KACH,OAAO;EACT,KAAK,MACH,OAAO;EACT,KAAK,MACH,OAAO,SAAS,qBAAqB,SAAQ;EAC/C,KAAK,MACH,OAAO,SAAS,qBAAqB,QAAQ;EAC/C,KAAK,MACH,OAAO,SAAS,qBAAqB,QAAQ;EAC/C,SAAS;GACP,MAAM,OAAO,GAAG,WAAW,CAAC;GAC5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AAO,OAAO,mBAAmB,KAAK,YAAY,MAAM,IAAI,GAAG,IAAI,EAAE,CAAC,GAAG;GAC3E,MAAM,YAAY,YAAY,MAAM,GAAG,IAAI,EAAE;GAC7C,MAAM,OAAO,OAAO,SAAS,YAAY,MAAM,IAAI,GAAG,IAAI,EAAE,GAAG,EAAE;GACjE,MAAM,UAAU,OAAO,cAAc,IAAI;GACzC,IAAI,CAAC,UAAU,IAAI,OAAO,GAAG,UAAU,IAAI,SAAS,SAAS;GAC7D,KAAK;GACL;EACF;CACF;CAEA,OAAO;AACT;AAEA,SAAS,kCACP,OACA,WACA,MACQ;CACR,IAAI,UAAU;CAEd,KAAK,MAAM,MAAM,OAAO;EACtB,MAAM,kBAAkB,UAAU,IAAI,EAAE;EACxC,IAAI,iBAAiB;GACnB,WAAW;GACX;EACF;EAEA,WAAW,kBAAkB,IAAI,IAAI;CACvC;CAEA,OAAO;AACT;;;;;;;;;;;;;AAcA,SAAgB,oBAAoB,OAAe,aAAqB,MAA0B;CAChG,MAAM,YAAY,wBAAwB,WAAW;CAErD,IAAI,UAAU,SAAS,KAAK,SAAS,oBAGnC,OAFgB,KAAK,UAAU,KAAK,CAAC,CAAC,MAAM,GAAG,EAElC,CAAC,CAAC,QAAQ,SAAS,SAAS;CAG3C,MAAM,UAAU,kCAAkC,OAAO,WAAW,IAAI;CAExE,OAAO,SAAS,oBAAoB,QAAQ,QAAQ,QAAQ,UAAO,IAAI;AACzE"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
//! @decimalturn/toml-patch v3.1.1 - https://github.com/DecimalTurn/toml-patch - @license: MIT
|
|
2
|
+
import { hasItems, isDocument, isInlineItem, isKeyValue, isTable, isTableArray } from "./cst.js";
|
|
3
|
+
import { arraysEqual, stableStringify } from "./utils.js";
|
|
4
|
+
|
|
5
|
+
//#region src/find-by-path.ts
|
|
6
|
+
function findByPath(node, path) {
|
|
7
|
+
if (!path.length) {
|
|
8
|
+
if (isInlineItem(node) && isKeyValue(node.item)) return node.item;
|
|
9
|
+
return node;
|
|
10
|
+
}
|
|
11
|
+
if (isKeyValue(node)) return findByPath(node.value, path);
|
|
12
|
+
const indexes = {};
|
|
13
|
+
let found;
|
|
14
|
+
let prefixCandidate;
|
|
15
|
+
if (hasItems(node)) node.items.some((item, itemIndex) => {
|
|
16
|
+
try {
|
|
17
|
+
let key = [];
|
|
18
|
+
if (isKeyValue(item)) key = item.key.value;
|
|
19
|
+
else if (isTable(item)) key = item.key.item.value;
|
|
20
|
+
else if (isTableArray(item)) {
|
|
21
|
+
key = item.key.item.value;
|
|
22
|
+
const key_string = stableStringify(key);
|
|
23
|
+
if (!indexes[key_string]) indexes[key_string] = 0;
|
|
24
|
+
const array_index = indexes[key_string]++;
|
|
25
|
+
key = key.concat(array_index);
|
|
26
|
+
} else if (isInlineItem(item) && isKeyValue(item.item)) key = item.item.key.value;
|
|
27
|
+
else if (isInlineItem(item)) key = [itemIndex];
|
|
28
|
+
if (key.length && arraysEqual(key, path.slice(0, key.length))) {
|
|
29
|
+
const remainingPath = path.slice(key.length);
|
|
30
|
+
if (isDocument(node) && isTableArray(item) && remainingPath.length > 0) {
|
|
31
|
+
const aotKey = item.key.item.value;
|
|
32
|
+
const doc = node;
|
|
33
|
+
const nextSameKeyDocIndex = doc.items.findIndex((sibling, i) => i > itemIndex && isTableArray(sibling) && arraysEqual(sibling.key.item.value, aotKey));
|
|
34
|
+
const scopeEnd = nextSameKeyDocIndex === -1 ? doc.items.length : nextSameKeyDocIndex;
|
|
35
|
+
found = findByPathInAotScope(item, remainingPath, aotKey, doc.items.slice(itemIndex + 1, scopeEnd));
|
|
36
|
+
} else if (isInlineItem(item) && isKeyValue(item.item)) {
|
|
37
|
+
if (path.length === key.length) found = item;
|
|
38
|
+
else found = findByPath(item.item.value, remainingPath);
|
|
39
|
+
} else if (isInlineItem(item) && path.length > key.length) found = findByPath(item.item, remainingPath);
|
|
40
|
+
else found = findByPath(item, remainingPath);
|
|
41
|
+
return true;
|
|
42
|
+
} else if ((isKeyValue(item) || isInlineItem(item) && isKeyValue(item.item)) && key.length > path.length && arraysEqual(key.slice(0, path.length), path)) {
|
|
43
|
+
if (!prefixCandidate) prefixCandidate = item;
|
|
44
|
+
return false;
|
|
45
|
+
} else return false;
|
|
46
|
+
} catch (err) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
if (!found && prefixCandidate) found = prefixCandidate;
|
|
51
|
+
if (!found) throw new Error(`Node not found at ${path.join(".")}`);
|
|
52
|
+
return found;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Searches for a path within an AOT entry's logical scope.
|
|
56
|
+
*
|
|
57
|
+
* In the TOML CST, sub-tables and sub-AOTs under a [[name]] entry are stored
|
|
58
|
+
* as siblings in the Document rather than as children of the entry node.
|
|
59
|
+
* This function first tries the entry's own items, then falls back to the
|
|
60
|
+
* scoped document items (those between this [[name]] and the next [[name]]).
|
|
61
|
+
*
|
|
62
|
+
* @param entry - The TableArray entry node (e.g. the first [[fruit]])
|
|
63
|
+
* @param remainingPath - The path segments still to be resolved (e.g. ['variety', 1, 'name'])
|
|
64
|
+
* @param entryKey - The full key of the entry (e.g. ['fruit'])
|
|
65
|
+
* @param scopedItems - Document items logically belonging to this entry's scope
|
|
66
|
+
*/
|
|
67
|
+
function findByPathInAotScope(entry, remainingPath, entryKey, scopedItems) {
|
|
68
|
+
try {
|
|
69
|
+
return findByPath(entry, remainingPath);
|
|
70
|
+
} catch {}
|
|
71
|
+
const indexes = {};
|
|
72
|
+
for (const item of scopedItems) {
|
|
73
|
+
let key = [];
|
|
74
|
+
if (isTable(item)) {
|
|
75
|
+
const fullKey = item.key.item.value;
|
|
76
|
+
if (fullKey.length > entryKey.length && arraysEqual(fullKey.slice(0, entryKey.length), entryKey)) key = fullKey.slice(entryKey.length);
|
|
77
|
+
} else if (isTableArray(item)) {
|
|
78
|
+
const fullKey = item.key.item.value;
|
|
79
|
+
if (fullKey.length > entryKey.length && arraysEqual(fullKey.slice(0, entryKey.length), entryKey)) {
|
|
80
|
+
const relativeKey = fullKey.slice(entryKey.length);
|
|
81
|
+
const key_string = stableStringify(relativeKey);
|
|
82
|
+
if (!indexes[key_string]) indexes[key_string] = 0;
|
|
83
|
+
const array_index = indexes[key_string]++;
|
|
84
|
+
key = relativeKey.concat(array_index);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (key.length && arraysEqual(key, remainingPath.slice(0, key.length))) try {
|
|
88
|
+
return findByPath(item, remainingPath.slice(key.length));
|
|
89
|
+
} catch {}
|
|
90
|
+
}
|
|
91
|
+
throw new Error(`Node not found at (aot scope) ${remainingPath.join(".")}`);
|
|
92
|
+
}
|
|
93
|
+
function tryFindByPath(node, path) {
|
|
94
|
+
try {
|
|
95
|
+
return findByPath(node, path);
|
|
96
|
+
} catch (err) {}
|
|
97
|
+
}
|
|
98
|
+
function findParent(node, path) {
|
|
99
|
+
let parent_path = path;
|
|
100
|
+
let parent;
|
|
101
|
+
while (parent_path.length && !parent) {
|
|
102
|
+
parent_path = parent_path.slice(0, -1);
|
|
103
|
+
parent = tryFindByPath(node, parent_path);
|
|
104
|
+
}
|
|
105
|
+
if (!parent) throw new Error(`Parent not found for ${path.join(".")}`);
|
|
106
|
+
return parent;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
//#endregion
|
|
110
|
+
export { findByPath as default, findParent, tryFindByPath };
|
|
111
|
+
//# sourceMappingURL=find-by-path.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find-by-path.js","names":[],"sources":["../../src/find-by-path.ts"],"sourcesContent":["import { TreeNode, isKeyValue, isTable, isTableArray, isDocument, hasItems, isInlineItem, Document, Table, TableArray, Block } from './cst';\nimport { arraysEqual, stableStringify } from './utils';\n\nexport type Path = Array<string | number>;\n\nexport default function findByPath(node: TreeNode, path: Path): TreeNode {\n if (!path.length) {\n // If this is an InlineItem containing a KeyValue, return the KeyValue\n if (isInlineItem(node) && isKeyValue(node.item)) {\n return node.item;\n }\n return node;\n }\n\n if (isKeyValue(node)) {\n return findByPath(node.value, path);\n }\n\n const indexes: { [key: string]: number } = {};\n let found;\n // Strict-prefix matches (key longer than the path) are deferred: an exact\n // key match elsewhere in the container must win. Otherwise a dotted row\n // like `\"\".\"\".\"mfn31vru\"` shadows the plain `\"\"` row the path points at,\n // and the caller edits the wrong key (fuzz seed 13057).\n let prefixCandidate: TreeNode | undefined;\n if (hasItems(node)) {\n node.items.some((item, itemIndex) => {\n try {\n let key: Path = [];\n if (isKeyValue(item)) {\n key = item.key.value;\n } else if (isTable(item)) {\n key = item.key.item.value;\n } else if (isTableArray(item)) {\n key = item.key.item.value;\n\n const key_string = stableStringify(key);\n if (!indexes[key_string]) {\n indexes[key_string] = 0;\n }\n const array_index = indexes[key_string]++;\n\n key = key.concat(array_index);\n } else if (isInlineItem(item) && isKeyValue(item.item)) {\n // For InlineItems wrapping KeyValues, extract the key\n key = item.item.key.value;\n } else if (isInlineItem(item)) {\n key = [itemIndex];\n }\n\n if (key.length && arraysEqual(key, path.slice(0, key.length))) {\n const remainingPath = path.slice(key.length);\n\n // Special handling for TableArray items within a Document:\n // sub-tables ([fruit.physical]) and sub-AOTs ([[fruit.variety]]) under\n // this entry are siblings in the Document, not children of the entry node.\n // When the remaining path can't be satisfied by the entry's own items,\n // fall back to a scoped search over the document items that logically\n // belong to this AOT entry (everything between this entry and the next\n // entry with the same key).\n if (isDocument(node) && isTableArray(item) && remainingPath.length > 0) {\n const aotKey = (item as TableArray).key.item.value;\n const doc = node as Document;\n const nextSameKeyDocIndex = doc.items.findIndex((sibling, i) =>\n i > itemIndex &&\n isTableArray(sibling) &&\n arraysEqual((sibling as TableArray).key.item.value, aotKey)\n );\n const scopeEnd = nextSameKeyDocIndex === -1 ? doc.items.length : nextSameKeyDocIndex;\n const scopedItems = doc.items.slice(itemIndex + 1, scopeEnd) as Block[];\n\n found = findByPathInAotScope(item as TableArray, remainingPath, aotKey, scopedItems);\n } else if (isInlineItem(item) && isKeyValue(item.item)) {\n if (path.length === key.length) {\n // If we've matched the full path, return the InlineItem itself\n // so it can be found and replaced in the parent's items array\n found = item;\n } else {\n // Continue searching within the KeyValue's value\n found = findByPath(item.item.value, remainingPath);\n }\n } else if (isInlineItem(item) && path.length > key.length) {\n // For non-KeyValue InlineItems (e.g. an InlineTable inside an array),\n // when there is still path to resolve, recurse into the inner node.\n // Without this, findByPath(InlineItem, ['key']) would fail because\n // InlineItem itself has no .items to traverse.\n found = findByPath(item.item, remainingPath);\n } else {\n found = findByPath(item, remainingPath);\n }\n return true;\n } else if ((isKeyValue(item) ||\n (isInlineItem(item) && isKeyValue(item.item))) &&\n key.length > path.length && arraysEqual(key.slice(0, path.length), path)) {\n // Path is a prefix of a dotted KeyValue's key (e.g. path ['a','b']\n // matching key ['a','b','c']) — or of a dotted key inside an\n // InlineTableItem. The path is fully consumed; the caller can\n // handle the key-length mismatch as a structural edit. Deferred:\n // keep scanning, an exact key match must take precedence.\n if (!prefixCandidate) prefixCandidate = item;\n return false;\n } else {\n return false;\n }\n } catch (err) {\n return false;\n }\n });\n }\n\n if (!found && prefixCandidate) {\n found = prefixCandidate;\n }\n\n if (!found) {\n throw new Error(`Node not found at ${path.join('.')}`);\n }\n\n return found;\n}\n\n/**\n * Searches for a path within an AOT entry's logical scope.\n *\n * In the TOML CST, sub-tables and sub-AOTs under a [[name]] entry are stored\n * as siblings in the Document rather than as children of the entry node.\n * This function first tries the entry's own items, then falls back to the\n * scoped document items (those between this [[name]] and the next [[name]]).\n *\n * @param entry - The TableArray entry node (e.g. the first [[fruit]])\n * @param remainingPath - The path segments still to be resolved (e.g. ['variety', 1, 'name'])\n * @param entryKey - The full key of the entry (e.g. ['fruit'])\n * @param scopedItems - Document items logically belonging to this entry's scope\n */\nfunction findByPathInAotScope(\n entry: TableArray,\n remainingPath: Path,\n entryKey: string[],\n scopedItems: Block[]\n): TreeNode {\n // First try the entry's own items (normal path resolution)\n try {\n return findByPath(entry, remainingPath);\n } catch {}\n\n // Search scoped document items for sub-tables and sub-AOTs whose keys\n // start with the AOT entry key and match the remaining path.\n const indexes: { [key: string]: number } = {};\n\n for (const item of scopedItems) {\n let key: Path = [];\n\n if (isTable(item)) {\n const fullKey = (item as Table).key.item.value;\n if (\n fullKey.length > entryKey.length &&\n arraysEqual(fullKey.slice(0, entryKey.length), entryKey)\n ) {\n key = fullKey.slice(entryKey.length);\n }\n } else if (isTableArray(item)) {\n const fullKey = (item as TableArray).key.item.value;\n if (\n fullKey.length > entryKey.length &&\n arraysEqual(fullKey.slice(0, entryKey.length), entryKey)\n ) {\n const relativeKey = fullKey.slice(entryKey.length);\n const key_string = stableStringify(relativeKey);\n if (!indexes[key_string]) indexes[key_string] = 0;\n const array_index = indexes[key_string]++;\n key = (relativeKey as Path).concat(array_index);\n }\n }\n\n if (key.length && arraysEqual(key, remainingPath.slice(0, key.length))) {\n try {\n return findByPath(item, remainingPath.slice(key.length));\n } catch {}\n }\n }\n\n throw new Error(`Node not found at (aot scope) ${remainingPath.join('.')}`);\n}\n\n\nexport function tryFindByPath(node: TreeNode, path: Path): TreeNode | undefined {\n try {\n return findByPath(node, path);\n } catch (err) {}\n}\n\nexport function findParent(node: TreeNode, path: Path): TreeNode {\n let parent_path = path;\n let parent;\n while (parent_path.length && !parent) {\n parent_path = parent_path.slice(0, -1);\n parent = tryFindByPath(node, parent_path);\n }\n\n if (!parent) {\n throw new Error(`Parent not found for ${path.join('.')}`);\n }\n\n return parent;\n}\n"],"mappings":";;;;;AAKA,SAAwB,WAAW,MAAgB,MAAsB;CACvE,IAAI,CAAC,KAAK,QAAQ;EAEhB,IAAI,aAAa,IAAI,KAAK,WAAW,KAAK,IAAI,GAC5C,OAAO,KAAK;EAEd,OAAO;CACT;CAEA,IAAI,WAAW,IAAI,GACjB,OAAO,WAAW,KAAK,OAAO,IAAI;CAGpC,MAAM,UAAqC,CAAC;CAC5C,IAAI;CAKJ,IAAI;CACJ,IAAI,SAAS,IAAI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,IAAI,UAAU,YAAY,KAAK,cAAc,MAAM,GAAG,IAAI,MAAM,CAAC,GACnE,IAAI;GACF,OAAO,WAAW,MAAM,cAAc,MAAM,IAAI,MAAM,CAAC;EACzD,QAAQ,CAAC;CAEb;CAEA,MAAM,IAAI,MAAM,iCAAiC,cAAc,KAAK,GAAG,GAAG;AAC5E;AAGA,SAAgB,cAAc,MAAgB,MAAkC;CAC9E,IAAI;EACF,OAAO,WAAW,MAAM,IAAI;CAC9B,SAAS,KAAK,CAAC;AACjB;AAEA,SAAgB,WAAW,MAAgB,MAAsB;CAC/D,IAAI,cAAc;CAClB,IAAI;CACJ,OAAO,YAAY,UAAU,CAAC,QAAQ;EACpC,cAAc,YAAY,MAAM,GAAG,EAAE;EACrC,SAAS,cAAc,MAAM,WAAW;CAC1C;CAEA,IAAI,CAAC,QACH,MAAM,IAAI,MAAM,wBAAwB,KAAK,KAAK,GAAG,GAAG;CAG1D,OAAO;AACT"}
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
//! @decimalturn/toml-patch v3.1.1 - https://github.com/DecimalTurn/toml-patch - @license: MIT
|
|
2
|
+
import { isInlineArray, isInlineItem, isInlineTable, isKeyValue, isTable, isTableArray } from "./cst.js";
|
|
3
|
+
import { getCommaSpace } from "./inline-comma-space.js";
|
|
4
|
+
import { getInlineContainerLayout, hasStructuralMultilineRows } from "./inline-format.js";
|
|
5
|
+
import { applyWrites, insert, remove, shiftNode } from "./writer.js";
|
|
6
|
+
import { generateDocument, generateTable, generateTableArray } from "./generate.js";
|
|
7
|
+
|
|
8
|
+
//#region src/formatter.ts
|
|
9
|
+
function arrayHadTrailingCommas(node) {
|
|
10
|
+
if (!isInlineArray(node)) return false;
|
|
11
|
+
if (node.items.length === 0) return false;
|
|
12
|
+
return node.items[node.items.length - 1].comma === true;
|
|
13
|
+
}
|
|
14
|
+
function tableHadTrailingCommas(node) {
|
|
15
|
+
if (!isInlineTable(node)) return false;
|
|
16
|
+
if (node.items.length === 0) return false;
|
|
17
|
+
return node.items[node.items.length - 1].comma === true;
|
|
18
|
+
}
|
|
19
|
+
function formatTopLevel(document, format) {
|
|
20
|
+
if (format.inlineTableStart === 0) return document;
|
|
21
|
+
document.items.filter((item) => {
|
|
22
|
+
if (!isKeyValue(item)) return false;
|
|
23
|
+
const is_inline_table = isInlineTable(item.value);
|
|
24
|
+
const is_inline_array = isInlineArray(item.value) && item.value.items.length > 0 && item.value.items.every((i) => isInlineTable(i.item));
|
|
25
|
+
if (is_inline_table || is_inline_array) {
|
|
26
|
+
const depth = calculateTableDepth(item.key.value);
|
|
27
|
+
return format.inlineTableStart === void 0 || depth < format.inlineTableStart;
|
|
28
|
+
}
|
|
29
|
+
return false;
|
|
30
|
+
}).forEach((node) => {
|
|
31
|
+
remove(document, document, node);
|
|
32
|
+
if (isInlineTable(node.value)) {
|
|
33
|
+
if (node.value.items.length === 0) insert(document, document, generateTable(node.key.value));
|
|
34
|
+
else insert(document, document, formatTable(node, format.bracketSpacing));
|
|
35
|
+
} else formatTableArray(node, format.bracketSpacing).forEach((table_array) => {
|
|
36
|
+
insert(document, document, table_array);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
applyWrites(document);
|
|
40
|
+
return document;
|
|
41
|
+
}
|
|
42
|
+
function formatTable(key_value, bracketSpacing) {
|
|
43
|
+
const table = generateTable(key_value.key.value);
|
|
44
|
+
for (const item of key_value.value.items) insert(table, table, item.item, void 0, void 0, void 0, void 0, true);
|
|
45
|
+
applyWrites(table);
|
|
46
|
+
normalizeGeneratedInlineRows(table, 1, bracketSpacing);
|
|
47
|
+
return table;
|
|
48
|
+
}
|
|
49
|
+
function formatTableArray(key_value, bracketSpacing) {
|
|
50
|
+
const root = generateDocument();
|
|
51
|
+
for (const inline_array_item of key_value.value.items) {
|
|
52
|
+
const table_array = generateTableArray(key_value.key.value);
|
|
53
|
+
insert(root, root, table_array);
|
|
54
|
+
for (const inline_table_item of inline_array_item.item.items) insert(root, table_array, inline_table_item.item, void 0, void 0, void 0, void 0, true);
|
|
55
|
+
}
|
|
56
|
+
applyWrites(root);
|
|
57
|
+
for (const item of root.items) if (isTable(item) || isTableArray(item)) normalizeGeneratedInlineRows(item, 1, bracketSpacing);
|
|
58
|
+
return root.items;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Whether an inline container lays its items out one per row. A container
|
|
62
|
+
* regenerated through a TOML round-trip carries no layout flag, so fall back to
|
|
63
|
+
* the physical rows: a row on a later line than the previous item's end means
|
|
64
|
+
* multiline. A compact container whose items merely SPAN several lines (because
|
|
65
|
+
* one of them is a multiline value) stays compact — its closing bracket still
|
|
66
|
+
* follows its last item.
|
|
67
|
+
*/
|
|
68
|
+
function isMultilineInlineContainer(container) {
|
|
69
|
+
const layout = getInlineContainerLayout(container);
|
|
70
|
+
return layout !== void 0 ? layout : hasStructuralMultilineRows(container);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Row indent for a container that is an array ELEMENT (no key of its own).
|
|
74
|
+
* Keyless rows keep the historical minimum of two columns, matching
|
|
75
|
+
* positionGeneratedNestedInlineTables so element rows and their closing
|
|
76
|
+
* bracket stay aligned the same way no matter which path laid them out.
|
|
77
|
+
*/
|
|
78
|
+
function elementIndentWidth(indentWidth) {
|
|
79
|
+
return Math.max(indentWidth, 2);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Lays out a generated inline container so that its rows and closing bracket
|
|
83
|
+
* line up with the key (or, for an array element, the element) that owns it:
|
|
84
|
+
*
|
|
85
|
+
* - a multiline container puts one row per line at `anchorColumn + indentWidth`
|
|
86
|
+
* and its closing bracket at `anchorColumn`;
|
|
87
|
+
* - a nested multiline container inside a row does the same, using that row's
|
|
88
|
+
* key column as its own anchor.
|
|
89
|
+
*
|
|
90
|
+
* `anchorColumn` is the column of the owning key's start. It only has to be
|
|
91
|
+
* correct for containers the generator built: containers parsed from an
|
|
92
|
+
* existing document keep their own formatting, so callers must restrict this
|
|
93
|
+
* to freshly generated/replaced subtrees.
|
|
94
|
+
*
|
|
95
|
+
* Returns whether a nested container's end position moved.
|
|
96
|
+
*/
|
|
97
|
+
function normalizeInlineContainerRows(container, anchorColumn, indentWidth, bracketSpacing = true) {
|
|
98
|
+
const multiline = isMultilineInlineContainer(container);
|
|
99
|
+
let nestedEndChanged = false;
|
|
100
|
+
if (multiline) {
|
|
101
|
+
const rowIndent = anchorColumn + indentWidth;
|
|
102
|
+
for (const item of container.items) {
|
|
103
|
+
shiftNode(item, {
|
|
104
|
+
lines: 0,
|
|
105
|
+
columns: rowIndent - item.loc.start.column
|
|
106
|
+
});
|
|
107
|
+
if (isInlineItem(item)) {
|
|
108
|
+
if (isInlineArray(item.item) || isInlineTable(item.item)) {
|
|
109
|
+
if (normalizeInlineContainerRows(item.item, item.item.loc.start.column, elementIndentWidth(indentWidth), bracketSpacing)) {
|
|
110
|
+
item.loc.end = { ...item.item.loc.end };
|
|
111
|
+
nestedEndChanged = true;
|
|
112
|
+
}
|
|
113
|
+
} else if (isKeyValue(item.item) && (isInlineArray(item.item.value) || isInlineTable(item.item.value))) {
|
|
114
|
+
if (normalizeInlineContainerRows(item.item.value, item.item.loc.start.column, indentWidth, bracketSpacing)) {
|
|
115
|
+
item.item.loc.end = { ...item.item.value.loc.end };
|
|
116
|
+
item.loc.end = { ...item.item.loc.end };
|
|
117
|
+
nestedEndChanged = true;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
container.loc.end.column = anchorColumn + 1;
|
|
123
|
+
nestedEndChanged = true;
|
|
124
|
+
}
|
|
125
|
+
for (const item of container.items) {
|
|
126
|
+
if (!isInlineItem(item)) continue;
|
|
127
|
+
if (isInlineArray(item.item) || isInlineTable(item.item)) {
|
|
128
|
+
if (normalizeInlineContainerRows(item.item, item.item.loc.start.column, elementIndentWidth(indentWidth), bracketSpacing)) {
|
|
129
|
+
item.loc.end = { ...item.item.loc.end };
|
|
130
|
+
nestedEndChanged = true;
|
|
131
|
+
}
|
|
132
|
+
} else if (isKeyValue(item.item) && (isInlineArray(item.item.value) || isInlineTable(item.item.value))) {
|
|
133
|
+
const value = item.item.value;
|
|
134
|
+
const anchorColumn = item.item.loc.start.column;
|
|
135
|
+
const valueMultiline = isMultilineInlineContainer(value);
|
|
136
|
+
if (normalizeInlineContainerRows(value, anchorColumn, indentWidth, bracketSpacing)) {
|
|
137
|
+
if (valueMultiline) value.loc.end.column = anchorColumn + 1;
|
|
138
|
+
item.item.loc.end = { ...value.loc.end };
|
|
139
|
+
item.loc.end = { ...item.item.loc.end };
|
|
140
|
+
nestedEndChanged = true;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
const commaSpace = getCommaSpace(container) ?? 2;
|
|
145
|
+
for (let index = 1; index < container.items.length; index++) {
|
|
146
|
+
const previous = container.items[index - 1];
|
|
147
|
+
const next = container.items[index];
|
|
148
|
+
if (previous.loc.end.line !== next.loc.start.line) continue;
|
|
149
|
+
const targetColumn = previous.loc.end.column + (previous.comma ? commaSpace : 1);
|
|
150
|
+
shiftNode(next, {
|
|
151
|
+
lines: 0,
|
|
152
|
+
columns: targetColumn - next.loc.start.column
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
if (nestedEndChanged && !multiline && container.items.length > 0) {
|
|
156
|
+
const lastItem = container.items[container.items.length - 1];
|
|
157
|
+
container.loc.end = {
|
|
158
|
+
line: lastItem.loc.end.line,
|
|
159
|
+
column: lastItem.loc.end.column + (lastItem.comma ? 1 : 0) + (bracketSpacing ? 2 : 1)
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
return nestedEndChanged;
|
|
163
|
+
}
|
|
164
|
+
function normalizeGeneratedInlineRows(block, indentWidth, bracketSpacing = true) {
|
|
165
|
+
const rows = isKeyValue(block) ? [block] : block.items;
|
|
166
|
+
for (const item of rows) {
|
|
167
|
+
if (!isKeyValue(item)) continue;
|
|
168
|
+
if (isInlineArray(item.value) || isInlineTable(item.value)) normalizeInlineContainerRows(item.value, item.loc.start.column, indentWidth, bracketSpacing);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
function normalizeGeneratedInlineContainerRows(container, indentWidth) {
|
|
172
|
+
const normalize = (current, normalizeCurrent) => {
|
|
173
|
+
if (normalizeCurrent) {
|
|
174
|
+
delete current.range;
|
|
175
|
+
if (getInlineContainerLayout(current) === true || hasStructuralMultilineRows(current)) {
|
|
176
|
+
const rowIndent = current.loc.start.column + indentWidth;
|
|
177
|
+
for (const item of current.items) shiftNode(item, {
|
|
178
|
+
lines: 0,
|
|
179
|
+
columns: rowIndent - item.loc.start.column
|
|
180
|
+
});
|
|
181
|
+
current.loc.end.column = current.loc.start.column + 1;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
for (const item of current.items) {
|
|
185
|
+
if (!isInlineItem(item)) continue;
|
|
186
|
+
if (isInlineArray(item.item) || isInlineTable(item.item)) normalize(item.item, isInlineArray(current) && isInlineTable(item.item));
|
|
187
|
+
else if (isKeyValue(item.item) && (isInlineArray(item.item.value) || isInlineTable(item.item.value))) normalize(item.item.value, false);
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
normalize(container, false);
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Updates a table's location end position after removing inline table items.
|
|
194
|
+
* When inline table content is removed from a parent table, the parent table's
|
|
195
|
+
* end position needs to be adjusted to reflect where the content actually ends.
|
|
196
|
+
*
|
|
197
|
+
* @param table - The table whose end position should be updated
|
|
198
|
+
*/
|
|
199
|
+
function postInlineItemRemovalAdjustment(table) {
|
|
200
|
+
if (table.items.length > 0) {
|
|
201
|
+
const lastItem = table.items[table.items.length - 1];
|
|
202
|
+
table.loc.end.line = lastItem.loc.end.line;
|
|
203
|
+
table.loc.end.column = lastItem.loc.end.column;
|
|
204
|
+
} else {
|
|
205
|
+
table.loc.end.line = table.key.loc.end.line;
|
|
206
|
+
table.loc.end.column = table.key.loc.end.column;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Calculates the nesting depth of a table based on its key path.
|
|
211
|
+
* Root level tables (e.g., [table]) have depth 0.
|
|
212
|
+
* First level nested tables (e.g., [table.nested]) have depth 1.
|
|
213
|
+
*
|
|
214
|
+
* @param keyPath - Array representing the table key path (e.g., ['table', 'nested'])
|
|
215
|
+
* @returns The nesting depth (0 for root level, 1+ for nested levels)
|
|
216
|
+
*/
|
|
217
|
+
function calculateTableDepth(keyPath) {
|
|
218
|
+
return Math.max(0, keyPath.length - 1);
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Converts nested inline tables to separate table sections based on the inlineTableStart depth setting.
|
|
222
|
+
* This function recursively processes all tables in the document and extracts inline tables that are
|
|
223
|
+
* at a depth less than the inlineTableStart threshold.
|
|
224
|
+
*/
|
|
225
|
+
function formatNestedTablesMultiline(document, format) {
|
|
226
|
+
if (format.inlineTableStart === void 0 || format.inlineTableStart === 0) return document;
|
|
227
|
+
const additionalTables = [];
|
|
228
|
+
for (const item of document.items) if (isKeyValue(item) && isInlineTable(item.value)) {
|
|
229
|
+
if (calculateTableDepth(item.key.value) < format.inlineTableStart) {
|
|
230
|
+
const table = formatTable(item, format.bracketSpacing);
|
|
231
|
+
remove(document, document, item);
|
|
232
|
+
insert(document, document, table);
|
|
233
|
+
processTableForNestedInlines(table, additionalTables, format);
|
|
234
|
+
}
|
|
235
|
+
} else if (item.type === "Table") processTableForNestedInlines(item, additionalTables, format);
|
|
236
|
+
else if (isTableArray(item)) processTableForNestedInlines(item, additionalTables, format);
|
|
237
|
+
const insertedAfter = /* @__PURE__ */ new Map();
|
|
238
|
+
for (const { table, parent } of additionalTables) {
|
|
239
|
+
const index = document.items.indexOf(parent);
|
|
240
|
+
const offset = (insertedAfter.get(parent) ?? 0) + 1;
|
|
241
|
+
insertedAfter.set(parent, offset);
|
|
242
|
+
insert(document, document, table, index + offset);
|
|
243
|
+
}
|
|
244
|
+
applyWrites(document);
|
|
245
|
+
return document;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Recursively processes a table for nested inline tables and extracts them as separate tables
|
|
249
|
+
* when they are at a depth less than the inlineTableStart threshold.
|
|
250
|
+
*/
|
|
251
|
+
function processTableForNestedInlines(table, additionalTables, format) {
|
|
252
|
+
const toExtract = [];
|
|
253
|
+
for (let i = 0; i < table.items.length; i++) {
|
|
254
|
+
const item = table.items[i];
|
|
255
|
+
if (isKeyValue(item) && isInlineTable(item.value)) {
|
|
256
|
+
const nestedTableKey = [...table.key.item.value, ...item.key.value];
|
|
257
|
+
if (calculateTableDepth(nestedTableKey) < (format.inlineTableStart ?? 1)) toExtract.push({
|
|
258
|
+
item,
|
|
259
|
+
nestedTableKey
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
for (const { item, nestedTableKey } of toExtract) {
|
|
264
|
+
const separateTable = generateTable(nestedTableKey);
|
|
265
|
+
const inlineTable = item.value;
|
|
266
|
+
for (const inlineItem of inlineTable.items) insert(separateTable, separateTable, inlineItem.item);
|
|
267
|
+
applyWrites(separateTable);
|
|
268
|
+
remove(table, table, item);
|
|
269
|
+
postInlineItemRemovalAdjustment(table);
|
|
270
|
+
additionalTables.push({
|
|
271
|
+
table: separateTable,
|
|
272
|
+
parent: table
|
|
273
|
+
});
|
|
274
|
+
processTableForNestedInlines(separateTable, additionalTables, format);
|
|
275
|
+
}
|
|
276
|
+
if (toExtract.length > 0) applyWrites(table);
|
|
277
|
+
}
|
|
278
|
+
function formatEmptyLines(document) {
|
|
279
|
+
let shift = 0;
|
|
280
|
+
let previous = 0;
|
|
281
|
+
for (const item of document.items) {
|
|
282
|
+
if (previous === 0 && item.loc.start.line > 1) shift = 1 - item.loc.start.line;
|
|
283
|
+
else if (item.loc.start.line + shift > previous + 2) shift += previous + 2 - (item.loc.start.line + shift);
|
|
284
|
+
shiftNode(item, {
|
|
285
|
+
lines: shift,
|
|
286
|
+
columns: 0
|
|
287
|
+
});
|
|
288
|
+
previous = item.loc.end.line;
|
|
289
|
+
}
|
|
290
|
+
return document;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
//#endregion
|
|
294
|
+
export { arrayHadTrailingCommas, calculateTableDepth, formatEmptyLines, formatNestedTablesMultiline, formatTopLevel, normalizeGeneratedInlineContainerRows, normalizeGeneratedInlineRows, normalizeInlineContainerRows, postInlineItemRemovalAdjustment, tableHadTrailingCommas };
|
|
295
|
+
//# sourceMappingURL=formatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatter.js","names":[],"sources":["../../src/formatter.ts"],"sourcesContent":["import {\n KeyValue,\n Table,\n InlineTable,\n TableArray,\n InlineArray,\n isInlineTable,\n isInlineArray,\n isKeyValue,\n isInlineItem,\n isTable,\n isTableArray,\n Document,\n Block,\n TreeNode\n} from './cst';\nimport { generateTable, generateDocument, generateTableArray } from './generate';\nimport { insert, remove, applyWrites, shiftNode } from './writer';\nimport { TomlFormat } from './toml-format';\nimport { getInlineContainerLayout, hasStructuralMultilineRows } from './inline-format';\nimport { getCommaSpace } from './inline-comma-space';\n\n// Helper function to detect if an InlineArray originally had trailing commas\nexport function arrayHadTrailingCommas(node: TreeNode): boolean {\n if (!isInlineArray(node)) return false;\n if (node.items.length === 0) return false;\n // Check if the last item has a trailing comma\n const lastItem = node.items[node.items.length - 1];\n return lastItem.comma === true;\n}\n\n// Helper function to detect if an InlineTable originally had trailing commas\nexport function tableHadTrailingCommas(node: TreeNode): boolean {\n if (!isInlineTable(node)) return false;\n if (node.items.length === 0) return false;\n // Check if the last item has a trailing comma\n const lastItem = node.items[node.items.length - 1];\n return lastItem.comma === true;\n}\n\nexport function formatTopLevel(document: Document, format: TomlFormat): Document {\n\n // If inlineTableStart is 0, convert all top-level tables to inline tables\n if (format.inlineTableStart === 0) {\n return document;\n }\n\n const move_to_top_level = document.items.filter(item => {\n if (!isKeyValue(item)) return false;\n\n const is_inline_table = isInlineTable(item.value);\n const is_inline_array =\n isInlineArray(item.value) &&\n item.value.items.length > 0 &&\n item.value.items.every(i => isInlineTable(i.item));\n\n // Only move to top level if the depth is less than inlineTableStart\n if (is_inline_table || is_inline_array) {\n const depth = calculateTableDepth(item.key.value);\n return format.inlineTableStart === undefined || depth < format.inlineTableStart;\n }\n\n return false;\n }) as KeyValue[];\n\n move_to_top_level.forEach(node => {\n remove(document, document, node);\n\n if (isInlineTable(node.value)) {\n // Fast path: empty inline tables don't need the full formatTable\n // machinery (inline table copy, insert loop, applyWrites).\n if ((node.value as InlineTable).items.length === 0) {\n insert(document, document, generateTable(node.key.value));\n } else {\n insert(document, document, formatTable(node, format.bracketSpacing));\n }\n } else {\n formatTableArray(node, format.bracketSpacing).forEach(table_array => {\n insert(document, document, table_array);\n });\n }\n });\n\n applyWrites(document);\n return document;\n}\n\nfunction formatTable(key_value: KeyValue, bracketSpacing: boolean): Table {\n const table = generateTable(key_value.key.value);\n\n for (const item of (key_value.value as InlineTable).items) {\n insert(table, table, item.item, undefined, undefined, undefined, undefined, true);\n }\n\n applyWrites(table);\n normalizeGeneratedInlineRows(table, 1, bracketSpacing);\n return table;\n}\n\nfunction formatTableArray(key_value: KeyValue, bracketSpacing: boolean): TableArray[] {\n const root = generateDocument();\n\n for (const inline_array_item of (key_value.value as InlineArray).items) {\n const table_array = generateTableArray(key_value.key.value);\n insert(root, root, table_array);\n\n for (const inline_table_item of (inline_array_item.item as InlineTable).items) {\n insert(root, table_array, inline_table_item.item, undefined, undefined, undefined, undefined, true);\n }\n }\n\n applyWrites(root);\n for (const item of root.items) {\n if (isTable(item) || isTableArray(item)) normalizeGeneratedInlineRows(item, 1, bracketSpacing);\n }\n return root.items as TableArray[];\n}\n\n/**\n * Whether an inline container lays its items out one per row. A container\n * regenerated through a TOML round-trip carries no layout flag, so fall back to\n * the physical rows: a row on a later line than the previous item's end means\n * multiline. A compact container whose items merely SPAN several lines (because\n * one of them is a multiline value) stays compact — its closing bracket still\n * follows its last item.\n */\nfunction isMultilineInlineContainer(container: InlineArray | InlineTable): boolean {\n const layout = getInlineContainerLayout(container);\n return layout !== undefined ? layout : hasStructuralMultilineRows(container);\n}\n\n/**\n * Row indent for a container that is an array ELEMENT (no key of its own).\n * Keyless rows keep the historical minimum of two columns, matching\n * positionGeneratedNestedInlineTables so element rows and their closing\n * bracket stay aligned the same way no matter which path laid them out.\n */\nfunction elementIndentWidth(indentWidth: number): number {\n return Math.max(indentWidth, 2);\n}\n\n/**\n * Lays out a generated inline container so that its rows and closing bracket\n * line up with the key (or, for an array element, the element) that owns it:\n *\n * - a multiline container puts one row per line at `anchorColumn + indentWidth`\n * and its closing bracket at `anchorColumn`;\n * - a nested multiline container inside a row does the same, using that row's\n * key column as its own anchor.\n *\n * `anchorColumn` is the column of the owning key's start. It only has to be\n * correct for containers the generator built: containers parsed from an\n * existing document keep their own formatting, so callers must restrict this\n * to freshly generated/replaced subtrees.\n *\n * Returns whether a nested container's end position moved.\n */\nexport function normalizeInlineContainerRows(\n container: InlineArray | InlineTable,\n anchorColumn: number,\n indentWidth: number,\n bracketSpacing = true\n): boolean {\n const multiline = isMultilineInlineContainer(container);\n let nestedEndChanged = false;\n if (multiline) {\n const rowIndent = anchorColumn + indentWidth;\n for (const item of container.items) {\n shiftNode(item, { lines: 0, columns: rowIndent - item.loc.start.column });\n if (isInlineItem(item)) {\n if (isInlineArray(item.item) || isInlineTable(item.item)) {\n if (normalizeInlineContainerRows(item.item, item.item.loc.start.column, elementIndentWidth(indentWidth), bracketSpacing)) {\n item.loc.end = { ...item.item.loc.end };\n nestedEndChanged = true;\n }\n } else if (isKeyValue(item.item) &&\n (isInlineArray(item.item.value) || isInlineTable(item.item.value))) {\n // The nested container's rows hang off the ROW's key, so it has to\n // be laid out from the key's own column — not from the enclosing\n // container's indent (fuzz3 seed 18515).\n if (normalizeInlineContainerRows(item.item.value, item.item.loc.start.column, indentWidth, bracketSpacing)) {\n item.item.loc.end = { ...item.item.value.loc.end };\n item.loc.end = { ...item.item.loc.end };\n nestedEndChanged = true;\n }\n }\n }\n }\n container.loc.end.column = anchorColumn + 1;\n // The container's own closing bracket moved, so the enclosing item has to\n // re-sync its end from it (its comma is written at that end).\n nestedEndChanged = true;\n }\n\n for (const item of container.items) {\n if (!isInlineItem(item)) continue;\n if (isInlineArray(item.item) || isInlineTable(item.item)) {\n if (normalizeInlineContainerRows(item.item, item.item.loc.start.column, elementIndentWidth(indentWidth), bracketSpacing)) {\n item.loc.end = { ...item.item.loc.end };\n nestedEndChanged = true;\n }\n } else if (isKeyValue(item.item) &&\n (isInlineArray(item.item.value) || isInlineTable(item.item.value))) {\n const value = item.item.value;\n const anchorColumn = item.item.loc.start.column;\n const valueMultiline = isMultilineInlineContainer(value);\n if (normalizeInlineContainerRows(value, anchorColumn, indentWidth, bracketSpacing)) {\n // A MULTILINE nested value closes on its own row, level with the row's\n // key. A compact one closes right after its last item — that end was\n // already computed by its own pass, so snapping it to the key column\n // would place the closing bracket before the item it follows\n // (fuzz3 seed 14739).\n if (valueMultiline) value.loc.end.column = anchorColumn + 1;\n item.item.loc.end = { ...value.loc.end };\n item.loc.end = { ...item.item.loc.end };\n nestedEndChanged = true;\n }\n }\n }\n // A nested container that grew pushes its following siblings along: the\n // siblings were positioned against its OLD end, so the ones still sharing its\n // end row must be re-anchored to its new end before the container's own\n // closing bracket is placed from the last item.\n const commaSpace = getCommaSpace(container) ?? 2;\n for (let index = 1; index < container.items.length; index++) {\n const previous = container.items[index - 1];\n const next = container.items[index];\n if (previous.loc.end.line !== next.loc.start.line) continue;\n const targetColumn = previous.loc.end.column + (previous.comma ? commaSpace : 1);\n shiftNode(next, { lines: 0, columns: targetColumn - next.loc.start.column });\n }\n if (nestedEndChanged && !multiline && container.items.length > 0) {\n const lastItem = container.items[container.items.length - 1];\n container.loc.end = {\n line: lastItem.loc.end.line,\n column: lastItem.loc.end.column + (lastItem.comma ? 1 : 0) + (bracketSpacing ? 2 : 1)\n };\n }\n return nestedEndChanged;\n}\n\nexport function normalizeGeneratedInlineRows(\n block: Table | TableArray | KeyValue,\n indentWidth: number,\n bracketSpacing = true\n): void {\n // A root-level key-value is normalized like the rows of a table: its own key\n // column is the anchor the nested container hangs off.\n const rows: Block[] = isKeyValue(block) ? [block] : block.items;\n for (const item of rows) {\n if (!isKeyValue(item)) continue;\n if (isInlineArray(item.value) || isInlineTable(item.value)) {\n normalizeInlineContainerRows(item.value, item.loc.start.column, indentWidth, bracketSpacing);\n }\n }\n}\n\nexport function normalizeGeneratedInlineContainerRows(\n container: InlineArray | InlineTable,\n indentWidth: number\n): void {\n const normalize = (\n current: InlineArray | InlineTable,\n normalizeCurrent: boolean\n ): void => {\n if (normalizeCurrent) {\n delete (current as { range?: [number, number] }).range;\n const multiline = getInlineContainerLayout(current) === true ||\n hasStructuralMultilineRows(current);\n if (multiline) {\n const rowIndent = current.loc.start.column + indentWidth;\n for (const item of current.items) {\n shiftNode(item, { lines: 0, columns: rowIndent - item.loc.start.column });\n }\n current.loc.end.column = current.loc.start.column + 1;\n }\n }\n\n for (const item of current.items) {\n if (!isInlineItem(item)) continue;\n if (isInlineArray(item.item) || isInlineTable(item.item)) {\n normalize(item.item, isInlineArray(current) && isInlineTable(item.item));\n } else if (isKeyValue(item.item) &&\n (isInlineArray(item.item.value) || isInlineTable(item.item.value))) {\n normalize(item.item.value, false);\n }\n }\n };\n\n normalize(container, false);\n}\n\n/**\n * Updates a table's location end position after removing inline table items.\n * When inline table content is removed from a parent table, the parent table's \n * end position needs to be adjusted to reflect where the content actually ends.\n * \n * @param table - The table whose end position should be updated\n */\nexport function postInlineItemRemovalAdjustment(table: Table | TableArray): void {\n if (table.items.length > 0) {\n const lastItem = table.items[table.items.length - 1];\n table.loc.end.line = lastItem.loc.end.line;\n table.loc.end.column = lastItem.loc.end.column;\n } else {\n // If no items left, table ends at the header line\n table.loc.end.line = table.key.loc.end.line;\n table.loc.end.column = table.key.loc.end.column;\n }\n}\n\n/**\n * Calculates the nesting depth of a table based on its key path.\n * Root level tables (e.g., [table]) have depth 0.\n * First level nested tables (e.g., [table.nested]) have depth 1.\n * \n * @param keyPath - Array representing the table key path (e.g., ['table', 'nested'])\n * @returns The nesting depth (0 for root level, 1+ for nested levels)\n */\nexport function calculateTableDepth(keyPath: string[]): number {\n return Math.max(0, keyPath.length - 1);\n}\n\n/**\n * Converts nested inline tables to separate table sections based on the inlineTableStart depth setting.\n * This function recursively processes all tables in the document and extracts inline tables that are\n * at a depth less than the inlineTableStart threshold.\n */\nexport function formatNestedTablesMultiline(document: Document, format: TomlFormat): Document {\n // If inlineTableStart is undefined, use the default behavior (no conversion)\n // If inlineTableStart is 0, all should be inline (no conversion)\n if (format.inlineTableStart === undefined || format.inlineTableStart === 0) {\n return document;\n }\n\n const additionalTables: { table: Table; parent: Table | TableArray }[] = [];\n \n // Process all existing tables for nested inline tables\n for (const item of document.items) {\n if (isKeyValue(item) && isInlineTable(item.value)) {\n // This is a top-level inline table (depth 0)\n const depth = calculateTableDepth(item.key.value);\n if (depth < format.inlineTableStart) {\n // Convert to a separate table\n const table = formatTable(item, format.bracketSpacing);\n remove(document, document, item);\n insert(document, document, table);\n \n processTableForNestedInlines(table, additionalTables, format);\n }\n } else if (item.type === 'Table') {\n processTableForNestedInlines(item as Table, additionalTables, format);\n } else if (isTableArray(item)) {\n processTableForNestedInlines(item, additionalTables, format);\n }\n }\n \n // Insert each extracted table immediately after its parent block, preserving\n // the parent-child positional relationship. A flat append at the document\n // end (the previous behaviour) misplaced a sub-table of an earlier entry —\n // e.g. `[tp6.k41]` (a sub-table of `[[tp6]]` entry 0) landed after `[[tp6]]`\n // entry 1, reassigning `k41` to the wrong entry. `additionalTables` is in\n // depth-first pre-order (a child is pushed before its own children), so\n // inserting in order with a per-parent counter keeps every sub-table after\n // its parent and before the parent's next sibling.\n const insertedAfter = new Map<Table | TableArray, number>();\n for (const { table, parent } of additionalTables) {\n const index = document.items.indexOf(parent);\n const offset = (insertedAfter.get(parent) ?? 0) + 1;\n insertedAfter.set(parent, offset);\n insert(document, document, table, index + offset);\n }\n\n applyWrites(document);\n return document;\n}\n\n/**\n * Recursively processes a table for nested inline tables and extracts them as separate tables\n * when they are at a depth less than the inlineTableStart threshold.\n */\nfunction processTableForNestedInlines(table: Table | TableArray, additionalTables: { table: Table; parent: Table | TableArray }[], format: TomlFormat): void {\n // Collect all inline tables that need extraction, then process in forward order\n // to preserve the original key order in the output.\n const toExtract: { item: KeyValue; nestedTableKey: string[] }[] = [];\n for (let i = 0; i < table.items.length; i++) {\n const item = table.items[i];\n if (isKeyValue(item) && isInlineTable(item.value)) {\n const nestedTableKey = [...table.key.item.value, ...item.key.value];\n const depth = calculateTableDepth(nestedTableKey);\n if (depth < (format.inlineTableStart ?? 1)) {\n toExtract.push({ item, nestedTableKey });\n }\n }\n }\n\n // Process in forward order. Each item reference captured above is stable\n // even after previous iterations call remove() — the KeyValue node itself\n // stays valid regardless of index shifts.\n for (const { item, nestedTableKey } of toExtract) {\n const separateTable = generateTable(nestedTableKey);\n const inlineTable = item.value as InlineTable;\n\n for (const inlineItem of inlineTable.items) {\n insert(separateTable, separateTable, inlineItem.item);\n }\n // Finalize the separateTable's internal offsets and recalculate its span\n // so it can be safely inserted into the document later.\n applyWrites(separateTable);\n\n remove(table, table, item);\n postInlineItemRemovalAdjustment(table);\n\n additionalTables.push({ table: separateTable, parent: table });\n\n processTableForNestedInlines(separateTable, additionalTables, format);\n }\n // Apply removal offsets accumulated on this table so remaining items\n // (if any) are shifted to the correct positions.\n if (toExtract.length > 0) {\n applyWrites(table);\n }\n}\n\nexport function formatEmptyLines(document: Document): Document {\n let shift = 0;\n let previous = 0;\n for (const item of document.items) {\n if (previous === 0 && item.loc.start.line > 1) {\n // Remove leading newlines\n shift = 1 - item.loc.start.line;\n } else if (item.loc.start.line + shift > previous + 2) {\n shift += previous + 2 - (item.loc.start.line + shift);\n }\n\n shiftNode(item, {\n lines: shift,\n columns: 0\n });\n previous = item.loc.end.line;\n }\n\n return document;\n}\n"],"mappings":";;;;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