@decimalturn/toml-patch 3.3.3-dev → 3.3.3-lite
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/patch.js +20 -0
- package/package.json +6 -11
- package/dist/dev/comment-alignment.js +0 -371
- package/dist/dev/comment-alignment.js.map +0 -1
- package/dist/dev/comment-ownership.js +0 -672
- package/dist/dev/comment-ownership.js.map +0 -1
- package/dist/dev/cst-source.js +0 -117
- package/dist/dev/cst-source.js.map +0 -1
- package/dist/dev/cst.js +0 -67
- package/dist/dev/cst.js.map +0 -1
- package/dist/dev/cursor.js +0 -65
- package/dist/dev/cursor.js.map +0 -1
- package/dist/dev/date-format.js +0 -286
- package/dist/dev/date-format.js.map +0 -1
- package/dist/dev/decode-utf8.js +0 -26
- package/dist/dev/decode-utf8.js.map +0 -1
- package/dist/dev/diff-lite.js +0 -107
- package/dist/dev/diff-lite.js.map +0 -1
- package/dist/dev/diff.js +0 -264
- package/dist/dev/diff.js.map +0 -1
- package/dist/dev/encode-lite.js +0 -209
- package/dist/dev/encode-lite.js.map +0 -1
- package/dist/dev/escape-preference.js +0 -165
- package/dist/dev/escape-preference.js.map +0 -1
- package/dist/dev/find-by-path.js +0 -114
- package/dist/dev/find-by-path.js.map +0 -1
- package/dist/dev/formatter.js +0 -297
- package/dist/dev/formatter.js.map +0 -1
- package/dist/dev/generate.js +0 -479
- package/dist/dev/generate.js.map +0 -1
- package/dist/dev/inline-comma-space.js +0 -12
- package/dist/dev/inline-comma-space.js.map +0 -1
- package/dist/dev/inline-format.js +0 -105
- package/dist/dev/inline-format.js.map +0 -1
- package/dist/dev/inline-layout.js +0 -106
- package/dist/dev/inline-layout.js.map +0 -1
- package/dist/dev/line-ending-backslash.js +0 -319
- package/dist/dev/line-ending-backslash.js.map +0 -1
- package/dist/dev/literal-string.js +0 -45
- package/dist/dev/literal-string.js.map +0 -1
- package/dist/dev/location.js +0 -103
- package/dist/dev/location.js.map +0 -1
- package/dist/dev/parse-error.js +0 -26
- package/dist/dev/parse-error.js.map +0 -1
- package/dist/dev/parse-js.js +0 -149
- package/dist/dev/parse-js.js.map +0 -1
- package/dist/dev/parse-string.js +0 -119
- package/dist/dev/parse-string.js.map +0 -1
- package/dist/dev/parse-toml.js +0 -713
- package/dist/dev/parse-toml.js.map +0 -1
- package/dist/dev/patch-lite.js +0 -4
- package/dist/dev/patch-lite2.js +0 -96
- package/dist/dev/patch-lite2.js.map +0 -1
- package/dist/dev/patch.js +0 -3143
- package/dist/dev/patch.js.map +0 -1
- package/dist/dev/smol-toml-date.js +0 -60
- package/dist/dev/smol-toml-date.js.map +0 -1
- package/dist/dev/to-js.js +0 -307
- package/dist/dev/to-js.js.map +0 -1
- package/dist/dev/to-toml.js +0 -873
- package/dist/dev/to-toml.js.map +0 -1
- package/dist/dev/tokenizer.js +0 -224
- package/dist/dev/tokenizer.js.map +0 -1
- package/dist/dev/toml-document.js +0 -220
- package/dist/dev/toml-document.js.map +0 -1
- package/dist/dev/toml-format.js +0 -548
- package/dist/dev/toml-format.js.map +0 -1
- package/dist/dev/toml-patch.js +0 -93
- package/dist/dev/toml-patch.js.map +0 -1
- package/dist/dev/traverse.js +0 -60
- package/dist/dev/traverse.js.map +0 -1
- package/dist/dev/truncate.js +0 -63
- package/dist/dev/truncate.js.map +0 -1
- package/dist/dev/update-order.js +0 -234
- package/dist/dev/update-order.js.map +0 -1
- package/dist/dev/utils.js +0 -295
- package/dist/dev/utils.js.map +0 -1
- package/dist/dev/writer.js +0 -757
- package/dist/dev/writer.js.map +0 -1
- package/dist/toml-patch.d.ts +0 -548
- /package/dist/{patch-lite.d.ts → patch.d.ts} +0 -0
package/dist/patch.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//! @decimalturn/toml-patch v3.3.3 - https://github.com/DecimalTurn/toml-patch - @license: MIT
|
|
2
|
+
function e(e){return e.type===`Document`}function t(e){return e.type===`Table`}function n(e){return e.type===`TableArray`}function r(e){return e.type===`KeyValue`}function i(e){return e.type===`String`}function a(e){return e.type===`Integer`}function o(e){return e.type===`Float`}function s(e){return e.type===`Boolean`}function c(e){return e.type===`DateTime`}function l(e){return e.type===`InlineArray`}function u(e){return e.type===`InlineItem`}function d(e){return e.type===`InlineTable`}function f(r){return e(r)||t(r)||n(r)||d(r)||l(r)}function ee(e){return i(e)||a(e)||o(e)||s(e)||c(e)||l(e)||d(e)}let te,p;function ne(e){if(te===e&&p!==void 0)return p;let t=ae(e);return te=e,p=t,t}function re(){te=void 0,p=void 0}function m(e,t){let n=Array.isArray(e)?e:ae(e);if(n.length===0)return{line:1,column:t};let r=0,i=n.length-1;for(;r<i;){let e=r+i>>>1;n[e]<t?r=e+1:i=e}n[r]<t&&r++;let a=r+1;return{line:a,column:t-(n[a-2]+1||0)}}function ie(e,t){let n=ne(e),r=n[t.line-2]===void 0?0:n[t.line-2]+1,i=n[t.line-1]||e.length;return e.substring(r,i)}function ae(e){let t=[];for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);r===10?t.push(n):r===13&&(e.charCodeAt(n+1)===10?(t.push(n+1),n++):t.push(n))}return t.push(e.length),t}function h(e){return{line:e.line,column:e.column}}function oe(e){return{start:h(e.start),end:h(e.end)}}var g=class extends Error{line;column;constructor(e,t,n){let r=`Error parsing TOML (${t.line}, ${t.column+1}):\n`;if(e){let n=ie(e,t),i=`${se(t.column)}^`;n&&(r+=`${n}\n${i}\n`)}r+=n,super(r),this.line=t.line,this.column=t.column}};function se(e,t=` `){return t.repeat(e)}const ce=/[\w,\d,",',+,\-,_]/;function le(){return{reference:null,mixed:!1}}function*ue(e,t){let n=e.length,r=0,i=t??le(),a=[],o=(e,t)=>({start:m(a,e),end:m(a,t)});for(;r<n;){let t=e.charCodeAt(r);if((t<=31||t===127)&&t!==9&&t!==13&&t!==10)throw new g(e,m(a,r),`Control char 0x${t.toString(16).toUpperCase().padStart(2,`0`)} not allowed`);if(t===13&&(r+1>=n||e.charCodeAt(r+1)!==10))throw new g(e,m(a,r),`Standalone CR; must be CRLF or LF`);if(t!==32&&t!==9&&t!==13){if(t===10)s(r);else if(t===91||t===93)yield{type:`Bracket`,raw:e[r],loc:o(r,r+1)};else if(t===123||t===125)yield{type:`Curly`,raw:e[r],loc:o(r,r+1)};else if(t===61)yield{type:`Equal`,raw:`=`,loc:o(r,r+1)};else if(t===44)yield{type:`Comma`,raw:`,`,loc:o(r,r+1)};else if(t===46)yield{type:`Dot`,raw:`.`,loc:o(r,r+1)};else if(t===35)yield c();else{let t=de(e,r,`'`)||de(e,r,`"`);t?yield l(t):yield u()}}r++}function s(t){a.push(t);let n=t>0&&e.charCodeAt(t-1)===13?`\r
|
|
3
|
+
`:`
|
|
4
|
+
`;i.reference===null?i.reference=n:i.reference!==n&&(i.mixed=!0)}function c(){let t=r;for(;r+1<n;){let t=e.charCodeAt(r+1);if(t===10||t===13)break;r++;let n=e.charCodeAt(r);if((n<=31||n===127)&&n!==9)throw new g(e,m(a,r),`Control char 0x${n.toString(16).toUpperCase().padStart(2,`0`)} not allowed`)}return{type:`Comment`,raw:e.slice(t,r+1),loc:o(t,r+1)}}function l(t){let i=r,c=t+t+t;for(r+=3;r<n;){if(de(e,r,t)){let n=3;for(;e[r+n]===t;)n++;if(n>=6)throw new g(e,m(a,r),`Invalid multiline string: ${n} consecutive ${t} characters`);if(n===3){r+=2;break}r+=n-3,r+=2;break}let i=e.charCodeAt(r);if(i===13&&(r+1>=n||e.charCodeAt(r+1)!==10))throw new g(e,m(a,r),`Standalone CR in multiline string; must be CRLF or LF`);if((i<=31||i===127)&&i!==9&&i!==10&&i!==13){let n=t===`"`?`multiline basic strings`:`multiline literal strings`,o=`0x${i.toString(16).toUpperCase().padStart(2,`0`)}`,s=``;i===0?s=`Null`:i===127&&(s=`DEL`);let c=s?`${s} (${o}) not allowed in ${n}`:`Control char ${o} not allowed in ${n}`;throw new g(e,m(a,r),c)}i===10&&s(r),r++}if(r>=n){if(t===`"`){let t=0,i=n-1;for(;i>=0&&e[i]===`\\`;)t++,i--;if(t>0&&t%2!=0)throw new g(e,m(a,r),`Unterminated multiline ${c} (possible escape issue)`)}throw new g(e,m(a,r),`Unterminated multiline ${c}`)}return{type:`Literal`,raw:e.slice(i,r+1),loc:o(i,r+1)}}function u(){let t=e[r];if(!ce.test(t))throw new g(e,m(a,r),`Unexpected char "${t}"`);let i=r,s=t===`"`,c=t===`'`;for(;r<n&&!(r+1>=n);){let t=e.charCodeAt(r+1);if(!(s||c)&&(t===32||t===9||t===10||t===13||t===44||t===46||t===93||t===125||t===61||t===35))break;if(r++,!(s||c)){let t=e.charCodeAt(r);if(t<=31||t===127)throw new g(e,m(a,r),`Control char 0x${t.toString(16).toUpperCase().padStart(2,`0`)} not allowed in unquoted value`)}if(s||c){let t=e.charCodeAt(r);if((t<=31||t===127)&&t!==9){let n=s?`basic strings`:`literal strings`,i=`0x${t.toString(16).toUpperCase().padStart(2,`0`)}`,o=``;t===10?o=`Newline`:t===13?o=`Carriage return`:t===0?o=`Null`:t===127&&(o=`DEL`);let c=o?`${o} (${i}) not allowed in ${n}`:`Control char ${i} not allowed in ${n}`;throw new g(e,m(a,r),c)}}let i=e[r];if(i===`"`&&!c&&(s=!s),i===`'`&&!s&&(c=!c),r+1>=n)break;if(s&&i===`\\`){let t=e[r+1];(t===`"`||t===`\\`)&&r++}}if(s||c)throw new g(e,m(a,i),`Expected close of string with ${s?`"`:`'`}`);return{type:`Literal`,raw:e.slice(i,r+1),loc:o(i,r+1)}}}function de(e,t,n){if(!n||e[t]!==n||e[t+1]!==n||e[t+2]!==n)return!1;if(n===`'`)return n;let r=0,i=t-1;for(;i>=0&&e[i]===`\\`;)r++,i--;return(r===0||r%2==0)&&n}const _=/* @__PURE__ */ new Int8Array(128);_.fill(-1);for(let e=0;e<10;e++)_[48+e]=e;for(let e=0;e<6;e++)_[65+e]=10+e,_[97+e]=10+e;function v(e){let t=e.charCodeAt(0);return t<128&&_[t]!==-1}function fe(e,t){return _[e.charCodeAt(t)]<<12|_[e.charCodeAt(t+1)]<<8|_[e.charCodeAt(t+2)]<<4|_[e.charCodeAt(t+3)]}function pe(e){return e.startsWith(`'''`)?he(e.slice(3,e.length-3)):e.startsWith(`'`)?e.slice(1,e.length-1):e.startsWith(`"""`)?me(he(e.slice(3,e.length-3)),!0):e.startsWith(`"`)?me(e.slice(1,e.length-1),!1):e}function me(e,t){let n=e.length;if(!t&&e.indexOf(`\\`)===-1)return e;let r=[],i=0;for(let a=0;a<n;a++){if(e[a]!==`\\`)continue;if(a>i&&r.push(e.slice(i,a)),a++,a>=n)throw Error(`Trailing backslash`);let o=e[a];switch(o){case`b`:r.push(`\b`);break;case`t`:r.push(` `);break;case`n`:r.push(`
|
|
5
|
+
`);break;case`f`:r.push(`\f`);break;case`r`:r.push(`\r`);break;case`"`:r.push(`"`);break;case`\\`:r.push(`\\`);break;case`e`:r.push(`\x1B`);break;case`u`:{if(a+4>n||!v(e[a+1])||!v(e[a+2])||!v(e[a+3])||!v(e[a+4]))throw Error(`Invalid Unicode escape: \\u${e.slice(a+1,a+5)}`);let t=fe(e,a+1);if(t>=55296&&t<=57343)throw Error(`Invalid \\u${e.slice(a+1,a+5)}: surrogates not allowed`);r.push(String.fromCharCode(t)),a+=4;break}case`U`:{if(a+8>n)throw Error(`Invalid Unicode escape: \\U${e.slice(a+1,a+9)}`);for(let t=1;t<=8;t++)if(!v(e[a+t]))throw Error(`Invalid Unicode escape: \\U${e.slice(a+1,a+9)}`);let t=parseInt(e.slice(a+1,a+9),16);if(t>=55296&&t<=57343)throw Error(`Invalid \\U${e.slice(a+1,a+9)}: surrogates not allowed`);r.push(String.fromCodePoint(t)),a+=8;break}case`x`:{if(a+2>n||!v(e[a+1])||!v(e[a+2]))throw Error(`Invalid hex escape: \\x${e.slice(a+1,a+3)}`);let t=_[e.charCodeAt(a+1)]<<4|_[e.charCodeAt(a+2)];r.push(String.fromCharCode(t)),a+=2;break}default:if(t&&(o===`
|
|
6
|
+
`||o===`\r`||o===` `||o===` `)){let t=o===`
|
|
7
|
+
`||o===`\r`,r=a;for(;r<n&&(e[r]===` `||e[r]===` `||e[r]===`
|
|
8
|
+
`||e[r]===`\r`);)(e[r]===`
|
|
9
|
+
`||e[r]===`\r`)&&(t=!0),r++;if(!t)throw Error(`Invalid escape sequence: \\${o}`);a=r-1;break}throw Error(`Invalid escape sequence: \\${o}`)}i=a+1}return i===0?e:(i<n&&r.push(e.slice(i)),r.join(``))}function he(e){return e.charCodeAt(0)===10?e.slice(1):e.charCodeAt(0)===13&&e.charCodeAt(1)===10?e.slice(2):e}var ge=class{iterator;index;value;done;peeked;constructor(e){this.iterator=e,this.index=-1,this.value=void 0,this.done=!1,this.peeked=null}next(){if(this.done)return ve();let e=this.peeked||this.iterator.next();return this.index+=1,this.value=e.value,this.done=e.done??!1,this.peeked=null,e}peek(){return this.done?ve():(this.peeked||=this.iterator.next(),this.peeked)}[Symbol.iterator](){return this}};const _e=Object.freeze({value:void 0,done:!0});function ve(){return _e}const ye=/* @__PURE__ */ new WeakMap;function be(e,t){ye.set(e,t)}function y(e){return{year:String(e.getUTCFullYear()).padStart(4,`0`),month:String(e.getUTCMonth()+1).padStart(2,`0`),day:String(e.getUTCDate()).padStart(2,`0`),hours:String(e.getUTCHours()).padStart(2,`0`),minutes:String(e.getUTCMinutes()).padStart(2,`0`),seconds:String(e.getUTCSeconds()).padStart(2,`0`),ms:e.getUTCMilliseconds()}}function xe(e){return e===0?``:String(e).padStart(3,`0`).replace(/0+$/,``)}const Se=/\.(\d+)\s*$/,Ce=/\.(\d+)(?:[Zz]|[+-]\d{2}:\d{2})\s*$/;function we(e,t){var n;return((n=e.match(t))==null?void 0:n[1])??``}function Te(e,t,n){let r=we(t,n),i=r.length>r.replace(/0+$/,``).length?Math.max(r.length,e.length):e.length;return i===0?``:`.`+e.padEnd(i,`0`)}function Ee(e){let t=e.toISOString().match(/\.(\d+)/);return t?t[1]:``}function b(e,t,n,r=Se){let i=Ee(e).replace(/0+$/,``);return i.length>xe(t).length?Te(i,n,r):x(t,n,r)}function x(e,t,n=Se){let r=xe(e);if(t&&t.includes(`.`)){let i=t.match(n);return i&&i[1].startsWith(String(e).padStart(3,`0`))?`.`+i[1]:Te(r,t,n)}return r?`.`+r:``}function De(e){if(e===`Z`)return 0;let t=e[0]===`+`?1:-1,[n,r]=e.slice(1).split(`:`);return t*(parseInt(n)*60+parseInt(r))}var Oe=class e{static IS_DATE_ONLY=/^\d{4}-\d{2}-\d{2}$/;static IS_TIME_ONLY=/^\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?$/;static IS_LOCAL_DATETIME_T=/^\d{4}-\d{2}-\d{2}[Tt]\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?$/;static IS_LOCAL_DATETIME_SPACE=/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}(?::\d{2})?(?:\.\d+)?$/;static IS_OFFSET_DATETIME_T=/^\d{4}-\d{2}-\d{2}[Tt]\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?(?:[Zz]|[+-]\d{2}:\d{2})$/;static IS_OFFSET_DATETIME_SPACE=/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}(?::\d{2})?(?:\.\d+)?(?:[Zz]|[+-]\d{2}:\d{2})$/;static IS_FULL_DATE=/(\d{4})-(\d+)-(\d+)/;static IS_FULL_TIME=/(\d+):(\d+)(?::(\d+))?/;static createDateWithOriginalFormat(t,n){if(e.IS_DATE_ONLY.test(n)){if(t.getUTCHours()!==0||t.getUTCMinutes()!==0||t.getUTCSeconds()!==0||t.getUTCMilliseconds()!==0){if(t instanceof T)return t;let e=t.toISOString().replace(`Z`,``);return e=e.replace(/\.000$/,``),new w(e,!1)}let e=t.toISOString().split(`T`)[0];return new S(e)}if(e.IS_TIME_ONLY.test(n)){let e=y(t),r=b(t,e.ms,n);return new C(`${e.hours}:${e.minutes}:${e.seconds}${r}`)}if(e.IS_LOCAL_DATETIME_T.test(n)){let e=y(t),r=b(t,e.ms,n),i=`${e.year}-${e.month}-${e.day}T${e.hours}:${e.minutes}:${e.seconds}${r}`;return new w(i,!1,i)}if(e.IS_LOCAL_DATETIME_SPACE.test(n)){let e=y(t),r=b(t,e.ms,n),i=`${e.year}-${e.month}-${e.day} ${e.hours}:${e.minutes}:${e.seconds}${r}`;return new w(i,!0,i)}if(e.IS_OFFSET_DATETIME_T.test(n)||e.IS_OFFSET_DATETIME_SPACE.test(n)){let r=n.match(/([+-]\d{2}:\d{2}|[Zz])$/),i=r?r[1]===`z`?`Z`:r[1]:`Z`,a=e.IS_OFFSET_DATETIME_SPACE.test(n),o=y(new Date(t.getTime()+De(i)*6e4)),s=a?` `:`T`,c=b(t,o.ms,n,Ce);return new T(`${o.year}-${o.month}-${o.day}${s}${o.hours}:${o.minutes}:${o.seconds}${c}${i}`,a)}return t}},S=class extends Date{constructor(e){super(e)}toISOString(){let e=y(this);return`${e.year}-${e.month}-${e.day}`}},C=class extends Date{originalFormat;constructor(e,t=e){let n=e;/:\d{2}:\d{2}/.test(e)||(n=e+`:00`),super(`0000-01-01T${n}Z`),this.originalFormat=t}toISOString(){let e=y(this);return`${e.hours}:${e.minutes}:${e.seconds}${x(e.ms,this.originalFormat)}`}},w=class extends Date{useSpaceSeparator=!1;originalFormat;constructor(e,t=!1,n){let r=e;/\d{2}:\d{2}:\d{2}/.test(e)||(r=e.replace(/(\d{2}:\d{2})([\s\-+TZ]|$)/,`$1:00$2`)),super(r.replace(` `,`T`)+`Z`),this.useSpaceSeparator=t,this.originalFormat=n||e}toISOString(){let e=y(this),t=this.useSpaceSeparator?` `:`T`;return`${e.year}-${e.month}-${e.day}${t}${e.hours}:${e.minutes}:${e.seconds}${x(e.ms,this.originalFormat)}`}},T=class extends Date{useSpaceSeparator=!1;originalOffset;originalFormat;constructor(e,t=!1){let n=e;/\d{2}:\d{2}:\d{2}/.test(e)||(n=e.replace(/(\d{2}:\d{2})([\s\-+TZ]|$)/,`$1:00$2`)),super(n.replace(` `,`T`)),this.useSpaceSeparator=t,this.originalFormat=e;let r=e.match(/([+-]\d{2}:\d{2}|[Zz])$/);r&&(this.originalOffset=r[1]===`z`?`Z`:r[1])}toISOString(){if(this.originalOffset){let e=y(new Date(this.getTime()+De(this.originalOffset)*6e4)),t=this.useSpaceSeparator?` `:`T`,n=x(e.ms,this.originalFormat,Ce);return`${e.year}-${e.month}-${e.day}${t}${e.hours}:${e.minutes}:${e.seconds}${n}${this.originalOffset}`}let e=super.toISOString();return this.useSpaceSeparator?e.replace(`T`,` `):e}};const E=Oe,ke=`true`,Ae=/e/i,D=/_/g,je=/^[+-]?inf$/,Me=/^[+-]?nan$/,O=/^[+-]?0x/i;function Ne(e){return e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||e===95||e===45}const k=/^[+-]?0o/i,A=/^[+-]?0b/i;function j(e,t,n){for(let r=0;r<e.length;r++)if(!Ne(e.charCodeAt(r)))throw new g(t,{line:n.line,column:n.column+r},`Invalid bare key char '${e[r]}'`)}function M(e,t,n){if(e.startsWith(`"""`)||e.startsWith(`'''`))throw new g(t,n,`Multiline strings cannot be keys`)}function N(e,t,n){try{return pe(e)}catch(e){throw new g(t,n,e.message)}}function P(e,t,n,r=!0){if(e.endsWith(`_`)||(r?/^[+-]?_/.test(e):e.startsWith(`_`)))throw new g(t,n,`Underscore must be between digits`);if(/__/.test(e))throw new g(t,n,`Consecutive underscores not allowed`)}function F(e,t,n,r){let i=e.replace(D,``);if(/^[+-]?0\d/.test(i)&&!O.test(e)&&!k.test(e)&&!A.test(e))throw new g(t,n,`Leading zeros are not allowed in ${r}`)}function Pe(e,t,n,r){if(/_[eE]/.test(e))throw new g(n,r,`Underscore before exponent is not allowed`);if(/[eE][+-]?_/.test(e))throw new g(n,r,`Underscore at start of exponent is not allowed`);if(/[eE][+-]?$/.test(e))throw new g(n,r,`Invalid float "${t}": incomplete exponent`);if(/[eE][+-]?.*\./.test(e))throw new g(n,r,`Invalid float "${t}": decimal point not allowed in exponent`)}function Fe(e,t,n,r,i,a){if(e.length!==2)throw new g(i,a,`"${r}": hour must be 2 digits`);if(t.length!==2)throw new g(i,a,`"${r}": minute must be 2 digits`);if(n&&n.length!==2)throw new g(i,a,`"${r}": second must be 2 digits`)}function Ie(e,t,n,r,i,a){if(e!==void 0){let t=parseInt(e,10);if(t<0||t>23)throw new g(i,a,`"${r}": hour must be 00-23`)}if(t!==void 0){let e=parseInt(t,10);if(e<0||e>59)throw new g(i,a,`"${r}": minute must be 00-59`)}if(n!==void 0){let e=parseInt(n,10);if(e<0||e>60)throw new g(i,a,`"${r}": second must be 00-60`)}}function Le(e,t,n){if(O.test(e)||k.test(e)||A.test(e))return;let r=e.replace(/^[+-]/,``).replace(/_/g,``);if(!/^[0-9]+$/.test(r))throw new g(t,n,`Invalid integer "${e}"`)}function I(e,t,n,r,i,a,o){let s=r[0]+r[1].toUpperCase();if(RegExp(`^[+\\-]?`+s.replace(/([[\]])/g,`\\$1`)).test(e))throw new g(t,n,`${a} prefix must be lowercase "${r}"`);if(RegExp(`^[+\\-]?`+r+`_`,`i`).test(e))throw new g(t,n,`Underscore must be between digits`);let c=RegExp(`^[+\\-]?`+r,`i`),l=e.replace(c,``);if(!l||l===`_`||l.startsWith(`_`))throw new g(t,n,`Incomplete ${a.toLowerCase()} number`);let u=l.replace(/_/g,``);if(!i.test(u))throw new g(t,n,o??`Invalid ${a.toLowerCase()} digits`);if(/^[+-]/.test(e))throw new g(t,n,`${a} numbers cannot have a sign prefix`)}function*Re(e,t){let n=new ge(ue(e,t));try{for(;!n.next().done;){let t=R(n,e);for(let e of t)yield e}}finally{re()}}function L(e){return{type:`Comment`,loc:e.value.loc,raw:e.value.raw}}function ze(e,t){let n=!e.peek().done&&e.peek().value.type===`Bracket`?`TableArray`:`Table`,r=n===`Table`;if(r&&e.value.raw!==`[`)throw new g(t,e.value.loc.start,`Expected table opening "[", found ${e.value.raw}`);if(!r){let n=e.peek();if(n.done)throw new g(t,e.value.loc.start,`Expected "[[" for Array of Tables, found end of input`);if(e.value.raw!==`[`||n.value.raw!==`[`)throw new g(t,e.value.loc.start,`Expected "[[", found ${e.value.raw+n.value.raw}`);let r=e.value,i=n.value;if(r.loc.end.line!==i.loc.start.line||r.loc.end.column!==i.loc.start.column)throw new g(t,r.loc.start,`"[[" brackets must be adjacent (no whitespace)`)}let i=r?{type:`TableKey`,loc:e.value.loc}:{type:`TableArrayKey`,loc:e.value.loc};if(e.next(),n===`TableArray`&&e.next(),e.done)throw new g(t,i.loc.start,`Expected table key, reached end of file`);if(e.value.type===`Bracket`&&e.value.raw===`]`)throw new g(t,e.value.loc.start,n===`TableArray`?`Array of Tables header [[]] requires a table name`:`Table header [] requires a table name`);let a=e.value.raw;M(a,t,e.value.loc.start),a.startsWith(`"`)||a.startsWith(`'`)||j(a,t,e.value.loc.start);let o;for(o=[N(e.value.raw,t,e.value.loc.start)],i.item={type:`Key`,loc:e.value.loc,raw:e.value.raw,value:o};!e.peek().done&&e.peek().value.type===`Dot`;){e.next();let n=e.value;e.next();let r=e.value.raw;r.startsWith(`"`)||r.startsWith(`'`)||j(r,t,e.value.loc.start);let a=` `.repeat(n.loc.start.column-i.item.loc.end.column),o=` `.repeat(e.value.loc.start.column-n.loc.end.column);i.item.loc.end=e.value.loc.end,i.item.raw+=`${a}.${o}${e.value.raw}`;try{i.item.value.push(pe(e.value.raw))}catch(n){let r=n;throw new g(t,e.value.loc.start,r.message)}}if(e.next(),!e.done){let n=i.loc.start.line;if(e.value.loc.start.line!==n)throw new g(t,e.value.loc.start,r?`Table header must be single-line`:`Array of Tables header must be single-line`)}if(r&&(e.done||e.value.raw!==`]`))throw new g(t,e.done?i.item.loc.end:e.value.loc.start,`Expected table closing "]", found ${e.done?`end of file`:e.value.raw}`);if(!r&&(e.done||e.peek().done||e.value.raw!==`]`||e.peek().value.raw!==`]`))throw new g(t,e.done||e.peek().done?i.item.loc.end:e.value.loc.start,`Expected "]]" closing, found ${e.done||e.peek().done?`end of file`:e.value.raw+e.peek().value.raw}`);if(!r){let n=e.value,r=e.peek().value;if(n.loc.end.line!==r.loc.start.line||n.loc.end.column!==r.loc.start.column)throw new g(t,n.loc.start,`"]]" brackets must be adjacent (no whitespace)`)}if(r||e.next(),i.loc.end=e.value.loc.end,!e.peek().done){let n=e.peek().value;if(n.loc.start.line===i.loc.end.line&&n.type!==`Comment`)throw new g(t,n.loc.start,`Extra content after ${r?`table`:`Array of Tables`} header`)}let s=[];for(;!e.peek().done&&e.peek().value.type!==`Bracket`;){e.next();let n=R(e,t);for(let e=0;e<n.length;e++)s.push(n[e])}return{type:r?`Table`:`TableArray`,loc:{start:h(i.loc.start),end:s.length?h(s[s.length-1].loc.end):h(i.loc.end)},key:i,items:s}}function Be(e,t){let n=N(e.value.raw,t,e.value.loc.start);return{type:`String`,loc:e.value.loc,raw:e.value.raw,value:n}}function Ve(e){return{type:`Boolean`,loc:e.value.loc,value:e.value.raw===ke}}function He(e,t){let n=e.value.loc,r=e.value.raw,i;if(!e.peek().done&&e.peek().value.type===`Literal`&&E.IS_FULL_DATE.test(r)&&/^\d/.test(e.peek().value.raw)&&E.IS_FULL_TIME.test(e.peek().value.raw)){let t=n.start;e.next(),n={start:t,end:e.value.loc.end},r+=` ${e.value.raw}`}if(!e.peek().done&&e.peek().value.type===`Dot`){let i=n.start;if(e.next(),e.peek().done||e.peek().value.type!==`Literal`)throw new g(t,e.value.loc.end,`Expected fractional value for DateTime`);e.next(),n={start:i,end:e.value.loc.end},r+=`.${e.value.raw}`}if(We(r,t,n.start),E.IS_FULL_DATE.test(r))i=E.IS_DATE_ONLY.test(r)?new S(r):E.IS_LOCAL_DATETIME_T.test(r)?new w(r,!1):E.IS_LOCAL_DATETIME_SPACE.test(r)?new w(r,!0):E.IS_OFFSET_DATETIME_T.test(r)?new T(r,!1):E.IS_OFFSET_DATETIME_SPACE.test(r)?new T(r,!0):new Date(r.replace(` `,`T`));else if(E.IS_TIME_ONLY.test(r))i=new C(r,r);else{let[e]=(/* @__PURE__ */ new Date()).toISOString().split(`T`);i=/* @__PURE__ */ new Date(`${e}T${r}`)}return{type:`DateTime`,loc:n,raw:r,value:i}}function Ue(e,t){return t===2?e%4==0&&e%100!=0||e%400==0?29:28:[31,28,31,30,31,30,31,31,30,31,30,31][t-1]}function We(e,t,n){if(/\.([Zz]|[+-])/.test(e))throw new g(t,n,`"${e}": fractional seconds needs digit after dot`);if(/[+-]$/.test(e))throw new g(t,n,`"${e}": offset needs HH:MM`);let r=/\d{2}:\d{2}/.test(e)?e.match(/([+-])(\d+)(:?)(\d*)$/):null;if(r){let e=r[0],i=r[2],a=r[3],o=r[4];if(a!==`:`)throw new g(t,n,`Offset "${e}": missing colon separator`);if(i.length!==2)throw new g(t,n,`Offset "${e}": hour must be 2 digits`);if(!o||o.length===0)throw new g(t,n,`Offset "${e}": minute required`);if(o.length!==2)throw new g(t,n,`Offset "${e}": minute must be 2 digits`);let s=parseInt(i,10);if(s<0||s>23)throw new g(t,n,`Offset "${e}": hour must be 00-23`);let c=parseInt(o,10);if(c<0||c>59)throw new g(t,n,`Offset "${e}": minute must be 00-59`)}if(!/^\d{4}-\d{2}-\d{2}(?:[Tt ]\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?(?:[Zz]|[+-]\d{2}:\d{2})?)?$/.test(e)&&!/^\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?$/.test(e))throw/^\d{4}-\d{2}-\d{2}T$/.test(e)?new g(t,n,`"${e}": 'T' requires time component`):/^\d{4}-\d{2}-\d{2}[a-su-zA-SU-Z]/.test(e)?new g(t,n,`Invalid date "${e}": unexpected character after date`):/^\d{4}-\d{2}-\d{2}\d{2}:\d{2}/.test(e)?new g(t,n,`"${e}": missing 'T' or space separator`):new g(t,n,`Invalid datetime "${e}"`);let i=e.match(/^(\d+)-/);if(i&&i[1].length!==4)throw new g(t,n,`"${e}": year must be 4 digits`);let a=e.match(/^(\d+)-(\d+)-(\d+)/);if(a){let[,,r,i]=a;if(r.length!==2)throw new g(t,n,`"${e}": month must be 2 digits`);if(i.length!==2)throw new g(t,n,`"${e}": day must be 2 digits`)}let o=e.match(/[T ](\d+):(\d+)(?::(\d+))?/);if(o){let[,r,i,a]=o;Fe(r,i,a,e,t,n)}let s=e.match(/^(\d+):(\d+)(?::(\d+))?/);if(s&&!a){let[,r,i,a]=s;Fe(r,i,a,e,t,n)}let c=e.match(/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?)?/),l=e.match(/^(\d{2}):(\d{2})(?::(\d{2}))?/);if(c){let[,r,i,a,o,s,l]=c,u=parseInt(i,10);if(u<1||u>12)throw new g(t,n,`"${e}": month must be 01-12`);let d=parseInt(a,10);if(d<1||d>31)throw new g(t,n,`"${e}": day must be 01-31`);if(d>Ue(parseInt(r,10),u))throw new g(t,n,`"${e}": day ${a} invalid for ${r}-${i}`);Ie(o,s,l,e,t,n)}else if(l){let[,r,i,a]=l;Ie(r,i,a,e,t,n)}}function Ge(e,t){let n=e.value.loc,r=e.value.raw,i;if(je.test(r))i=r.startsWith(`-`)?-1/0:1/0;else if(Me.test(r)){let e=/* @__PURE__ */ new Float64Array(1),t=new DataView(e.buffer);r.startsWith(`-`)?(t.setUint32(0,0,!0),t.setUint32(4,4294443008,!0)):(t.setUint32(0,0,!0),t.setUint32(4,2146959360,!0)),i=e[0];let a=r.startsWith(`+`)?`+`:r.startsWith(`-`)?`-`:void 0;return{type:`Float`,loc:n,raw:r,value:i,nanSign:a}}else if(!e.peek().done&&e.peek().value.type===`Dot`){let a=n.start;{if(Ae.test(r)&&!O.test(r))throw new g(t,n.start,`Float "${r}": dot after exponent`);let e=r;F(e,t,n.start,`the integer part of a float`);let i=e.replace(/^[+-]/,``);if(i===``||i===`_`)throw new g(t,n.start,`Float: digit required before dot`);P(e,t,n.start)}if(e.next(),e.peek().done||e.peek().value.type!==`Literal`)throw new g(t,e.value.loc.end,`Expected fraction value for Float`);e.next(),r+=`.${e.value.raw}`,n={start:a,end:e.value.loc.end};{let n=e.value.raw;if(!/^\d/.test(n))throw new g(t,e.value.loc.start,`Float: fraction must start with digit, found "${n}"`);P(n,t,e.value.loc.start,!1),Pe(n,r,t,e.value.loc.start)}i=Number(r.replace(D,``))}else{if(P(r,t,n.start),Pe(r,r,t,n.start),!e.peek().done&&e.peek().value.type===`Dot`)throw new g(t,e.peek().value.loc.start,`Float "${r}.": dot after exponent`);F(r,t,n.start,`the integer part of a float`),i=Number(r.replace(D,``))}if(Number.isNaN(i)&&!Me.test(r))throw new g(t,n.start,`Invalid float "${r}"`);return{type:`Float`,loc:n,raw:r,value:i}}function Ke(e,t){let n=e.value.raw,r=e.value.loc;if(/^\d{1,}-\d{1,}/.test(n)||/^\d{1,}:\d{1,}/.test(n)||/^\d{6}-\d{2}$/.test(n))throw new g(t,r.start,`Invalid integer "${n}"`);if(n===`-0`||n===`+0`)return{type:`Integer`,loc:r,raw:n,value:0};if(/^[+-]{2,}/.test(n))throw new g(t,r.start,`Double sign is not allowed in integers`);F(n,t,r.start,`decimal integers`),P(n,t,r.start),Le(n,t,r.start);let i=10;O.test(n)?(i=16,I(n,t,r.start,`0x`,/^[0-9a-fA-F]+$/,`Hexadecimal`)):k.test(n)?(i=8,I(n,t,r.start,`0o`,/^[0-7]+$/,`Octal`,`Invalid octal digits (must be 0-7)`)):A.test(n)&&(i=2,I(n,t,r.start,`0b`,/^[01]+$/,`Binary`,`Invalid binary digits (must be 0 or 1)`));let a=parseInt(n.replace(D,``).replace(k,``).replace(A,``),i);if(Number.isNaN(a))throw new g(t,r.start,`Invalid integer "${n}"`);return{type:`Integer`,loc:r,raw:n,value:a}}function R(e,t){if(e.value.type===`Comment`)return[L(e)];if(e.value.type===`Bracket`)return[ze(e,t)];if(e.value.type===`Literal`)return qe(e,t);throw e.value.type===`Equal`?new g(t,e.value.loc.start,`Missing key before '='`):new g(t,e.value.loc.start,`Unexpected token "${e.value.type}"`)}function qe(e,t){let n=e.value.raw;if(n.endsWith(`:`))throw new g(t,{line:e.value.loc.start.line,column:e.value.loc.start.column+[...n].length-1},`Use '=' to separate keys and values, not ':'`);M(n,t,e.value.loc.start),n.startsWith(`"`)||n.startsWith(`'`)||j(n,t,e.value.loc.start);let r;r=[N(e.value.raw,t,e.value.loc.start)];let i={type:`Key`,loc:e.value.loc,raw:e.value.raw,value:r};for(;!e.peek().done&&e.peek().value.type===`Dot`;){e.next();let n=e.value;e.next();let r=e.value.raw;M(r,t,e.value.loc.start),r.startsWith(`"`)||r.startsWith(`'`)||j(r,t,e.value.loc.start);let a=ie(t,i.loc.end),o=ie(t,n.loc.end),s=a.slice(i.loc.end.column,n.loc.start.column),c=o.slice(n.loc.end.column,e.value.loc.start.column);i.loc.end=e.value.loc.end,i.raw+=`${s}.${c}${e.value.raw}`,i.value.push(N(e.value.raw,t,e.value.loc.start))}if(e.next(),!e.done&&e.value.loc.start.line!==i.loc.end.line)throw new g(t,e.value.loc.start,`"=" must be on same line as key`);if(e.done||e.value.type!==`Equal`)throw!e.done&&e.value.raw===`:`?new g(t,e.value.loc.start,`Use '=' to separate keys and values, not ':'`):new g(t,e.done?i.loc.end:e.value.loc.start,`Expected "=" for key-value`);let a=e.value.loc.start.column,o=e.value.loc.start.line;if(e.next(),e.done)throw new g(t,i.loc.start,`Expected value, reached EOF`);if(e.value.loc.start.line!==o)throw new g(t,e.value.loc.start,`Value must be on same line as '='`);if(e.done)throw new g(t,i.loc.start,`Expected value for key-value`);let s=Je(e,t),c=s[0];if(!e.peek().done){let n=e.peek().value;if(n.type===`Dot`&&n.loc.start.line===c.loc.end.line&&(c.type===`Float`||c.type===`Integer`))throw new g(t,n.loc.start,`Invalid number: multiple decimal points not allowed`);if((n.type===`Literal`||n.type===`Bracket`)&&n.loc.start.line===c.loc.end.line)throw new g(t,n.loc.start,`Key/value pairs must be separated by a newline`)}return s[0]={type:`KeyValue`,key:i,value:c,loc:{start:h(i.loc.start),end:h(c.loc.end)},equals:a},s}function Je(e,t){if(e.value.type===`Literal`){let n=e.value.raw;return n[0]===`"`||n[0]===`'`?[Be(e,t)]:n===ke||n===`false`?[Ve(e)]:/^\d/.test(n)&&(/^\d{1,}-\d{1,}/.test(n)||/^\d{1,}:\d{1,}/.test(n))?[He(e,t)]:!e.peek().done&&e.peek().value.type===`Dot`||je.test(n)||Me.test(n)||Ae.test(n)&&!O.test(n)?[Ge(e,t)]:[Ke(e,t)]}if(e.value.type===`Curly`){let[n,r]=Xe(e,t);return[n,...r]}if(e.value.type===`Bracket`){let[n,r]=Ze(e,t);return[n,...r]}throw e.value.type===`Dot`?new g(t,e.value.loc.start,`Number cannot start with a dot`):new g(t,e.value.loc.start,`Unrecognized token type`)}function Ye(e){for(let t=1;t<e.length;t++){let n=e[t-1],r=e[t];if(n.loc.end.line===r.loc.start.line){let e=r.loc.start.column-n.loc.end.column;if(e>=1)return e}}}function Xe(e,t){if(e.value.raw!==`{`)throw new g(t,e.value.loc.start,`Expected "{" for inline table`);let n={type:`InlineTable`,loc:e.value.loc,items:[]},r=[];for(e.next();!e.done&&(e.value.type!==`Curly`||e.value.raw!==`}`);){if(e.value.type===`Comment`){r.push(L(e)),e.next();continue}if(e.value.type===`Comma`){let r=n.items[n.items.length-1];if(!r)throw new g(t,e.value.loc.start,`Leading comma in inline table`);if(r.comma)throw new g(t,e.value.loc.start,`Consecutive commas in inline table`);r.comma=!0,r.loc.end=e.value.loc.start,e.next();continue}let i=n.items[n.items.length-1];if(i&&!i.comma)throw new g(t,e.value.loc.start,`Missing comma between inline table items`);let a=R(e,t),o=a[0];if(o.type===`KeyValue`){n.items.push({type:`InlineItem`,loc:oe(o.loc),item:o,comma:!1});for(let e=1;e<a.length;e++)r.push(a[e])}e.next()}if(e.done||e.value.type!==`Curly`||e.value.raw!==`}`)throw new g(t,e.done?n.loc.start:e.value.loc.start,`Expected "}"`);n.loc.end=e.value.loc.end;{let e=Ye(n.items);e!==void 0&&be(n,e)}return[n,r]}function Ze(e,t){if(e.value.raw!==`[`)throw new g(t,e.value.loc.start,`Expected "[" for inline array`);let n={type:`InlineArray`,loc:e.value.loc,items:[]},r=[];for(e.next();!e.done&&(e.value.type!==`Bracket`||e.value.raw!==`]`);){if(e.value.type===`Comma`){let r=n.items[n.items.length-1];if(!r)throw new g(t,e.value.loc.start,`Leading comma in array`);if(r.comma)throw new g(t,e.value.loc.start,`Consecutive commas in array`);r.comma=!0,r.loc.end=e.value.loc.start}else if(e.value.type===`Comment`)r.push(L(e));else{let i=n.items[n.items.length-1];if(i&&!i.comma)throw new g(t,e.value.loc.start,`Missing comma between array elements`);let a=Je(e,t),o=a[0];n.items.push({type:`InlineItem`,loc:oe(o.loc),item:o,comma:!1});for(let e=1;e<a.length;e++)r.push(a[e])}e.next()}if(e.done||e.value.type!==`Bracket`||e.value.raw!==`]`)throw new g(t,e.done?n.loc.start:e.value.loc.start,`Expected "]"`);n.loc.end=e.value.loc.end;{let e=Ye(n.items);e!==void 0&&be(n,e)}return[n,r]}function z(e){return e[e.length-1]}function B(){return Object.create(null)}function Qe(e,t){return e===t&&(typeof e!=`number`||Object.is(e,t))}const $e=/* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8));function V(e){return Number.isNaN(e)?($e.setFloat64(0,e,!0),!!($e.getUint32(4,!0)&2147483648)):!1}function H(e){return Object.prototype.toString.call(e)===`[object Date]`}const et=/* @__PURE__ */ new Set([`Temporal.PlainDate`,`Temporal.PlainTime`,`Temporal.PlainDateTime`,`Temporal.ZonedDateTime`,`PlainDate`,`PlainTime`,`PlainDateTime`,`ZonedDateTime`]);function U(e){var t;return typeof e==`object`&&!!e&&et.has((t=e.constructor)==null?void 0:t.name)&&typeof e.equals==`function`}function tt(e){var t;let n=((t=e.constructor)==null?void 0:t.name)??``;if(n===`Temporal.ZonedDateTime`||n===`ZonedDateTime`){let t=e.toString(),n=t.match(/\[(.+)\]$/);if(n&&!/^[+-]\d{2}:\d{2}$/.test(n[1]))throw Error(`ZonedDateTime with IANA timezone "${t}" cannot be represented in TOML. TOML only supports offset-based timezones (+05:30, Z).`);return t.replace(/\[.*\]$/,``).replace(/(\+00:00)$/,`Z`)}let r=e.toString();if(/\[.*\]/.test(r))throw Error(`Temporal value contains unsupported annotation: "${r}". TOML only supports ISO 8601 calendar.`);return r}function nt(e,t=/* @__PURE__ */ new WeakSet){return typeof e!=`object`||!e?!1:U(e)?!0:!t.has(e)&&(t.add(e),Object.values(e).some(e=>nt(e,t)))}function rt(e){return e&&typeof e==`object`&&!H(e)&&!U(e)&&!Array.isArray(e)}function W(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function it(e){return/^\d{4}-\d{2}-\d{2}$/.test(e)?`date`:/^\d{2}:\d{2}:\d{2}(?:\.\d+)?$/.test(e)?`time`:/(?:[Zz]|[+-]\d{2}:\d{2})$/.test(e)?`offset`:`datetime`}function at(e){let t=e.match(/\.(\d+)/);return t?t[1].replace(/0+$/,``):``}function ot(e){return e===0?0:String(e).padStart(3,`0`).replace(/0+$/,``).length}function st(e,t){let n=at(t);return n.length>ot(e.getUTCMilliseconds())?n:void 0}function ct(e,t){if(U(e)&&U(t))return e.toString()===t.toString();if(H(e)&&H(t)){if(e.getTime()!==t.getTime())return!1;let n=e.toISOString(),r=t.toISOString();if(it(n)!==it(r))return!1;let i=st(e,n),a=st(t,r);return i===void 0||a===void 0||i===a}return!1}function G(e){let t=[],n=/* @__PURE__ */ new WeakSet,r=[{value:e}];for(;r.length>0;){let e=r.pop();if(`text`in e){t.push(e.text),`leave`in e&&n.delete(e.leave);continue}let i=e.value;if(rt(i)){if(n.has(i))throw TypeError(`Cannot stableStringify a circular structure`);n.add(i);let e=Object.keys(i).sort();t.push(`{`),r.push({leave:i,text:`}`});for(let t=e.length-1;t>=0;t--){let n=e[t];t<e.length-1&&r.push({text:`,`}),r.push({value:i[n]}),r.push({text:`:`}),r.push({text:JSON.stringify(n)})}}else if(Array.isArray(i)){if(n.has(i))throw TypeError(`Cannot stableStringify a circular structure`);n.add(i),t.push(`[`),r.push({leave:i,text:`]`});for(let e=i.length-1;e>=0;e--)e<i.length-1&&r.push({text:`,`}),r.push({value:i[e]})}else if(U(i))t.push(JSON.stringify(i.toString()));else if(H(i))t.push(JSON.stringify(i.toISOString()));else if(typeof i==`bigint`)t.push(i.toString()+`n`);else if(typeof i==`number`&&!Number.isFinite(i)){let e=Number.isNaN(i)?V(i)?`-`:`+`:i<0?`-`:`+`;t.push(`${e}${String(i)}`)}else typeof i==`number`&&Object.is(i,-0)?t.push(`-0`):t.push(JSON.stringify(i))}return t.join(``)}typeof String.prototype.isWellFormed==`function`&&String.prototype.isWellFormed;function lt(e,t=`asNeeded`){let n=e.replace(/_/g,``),r=n;if(/^[+-]?0x/i.test(n)||/^[+-]?0o/i.test(n)||/^[+-]?0b/i.test(n)){let e=n[0]===`+`||n[0]===`-`?n[0]:``;r=e+n.slice(+!!e).toLowerCase()}let i;try{i=BigInt(r)}catch{return Number(n)}return t===!0?i:t===!1||i>=BigInt(-(2**53-1))&&i<=BigInt(2**53-1)?Number(i):i}function ut(e,t,n){for(let r of e.items){let e=r.item;if(e.value.type===`InlineTable`){let r=t.concat(e.key.value);J(n,r,!0).kind=`inline`,ut(e.value,r,n)}}}function dt(e){var t,n,r,i,a,o;if((t=e.constructor)!=null&&(t=t.name)!=null&&(n=t.startsWith)!=null&&n.call(t,`Temporal.`)||((r=e.constructor)==null?void 0:r.name)===`PlainDate`||((i=e.constructor)==null?void 0:i.name)===`PlainTime`||((a=e.constructor)==null?void 0:a.name)===`PlainDateTime`||((o=e.constructor)==null?void 0:o.name)===`ZonedDateTime`)return e;let s=globalThis.Temporal;if(e instanceof S)return s.PlainDate.from(e.toISOString());if(e instanceof C)return s.PlainTime.from(e.toISOString());if(e instanceof w)return s.PlainDateTime.from(e.toISOString().replace(` `,`T`));if(e instanceof T){let t=e.toISOString().replace(` `,`T`),n=t.match(/([+-]\d{2}:\d{2}|Z)$/),r=n?n[1]:`Z`,i=t.replace(/([+-]\d{2}:\d{2}|Z)$/,``),a=r===`Z`?`+00:00`:r;return s.ZonedDateTime.from(`${i}${r}[${a}]`)}return s.PlainDateTime.from(e.toISOString().replace(`Z`,``))}function ft(e,t=``,n={}){let{integersAsBigInt:r=`asNeeded`,temporal:i=!1}=n,a=B(),o=q(),s=a,c=[];for(let t of e)switch(t.type){case`Table`:l(t);for(let e of t.items)e.type===`KeyValue`&&d(e);break;case`TableArray`:u(t);for(let e of t.items)e.type===`KeyValue`&&d(e);break;case`KeyValue`:d(t)}return a;function l(e){let n=e.key.item.value;try{mt(o,[],n,e.type)}catch(n){throw new g(t,e.key.loc.start,n.message)}J(o,n,!0).kind=`explicit`,s=ht(a,n),c=n}function u(e){let n=e.key.item.value;try{mt(o,[],n,e.type)}catch(n){throw new g(t,e.key.loc.start,n.message)}let r=J(o,n,!0);r.kind=`table-array`,r.entries.push(q()),s=gt(a,n),c=n}function d(e){let n=e.key.value;try{mt(o,c,n,e.type)}catch(n){throw new g(t,e.key.loc.start,n.message)}if(n.length>1)for(let e=1;e<n.length;e++){let t=J(o,c.concat(n.slice(0,e)),!0);t.kind===`undefined`&&(t.kind=`implicit`)}let a;try{a=pt(e.value,{integersAsBigInt:r,temporal:i})}catch(n){throw new g(t,e.value.loc.start,n.message)}let l=c.concat(n);if(e.value.type===`InlineTable`)J(o,l,!0).kind=`inline`,ut(e.value,l,o);else{let t=J(o,l,!0);t.kind=e.value.type===`InlineArray`?`array`:e.value.type===`DateTime`?`date`:`value`,e.value.type===`DateTime`&&(t.runtimeValue=a)}let u=n.length>1?ht(s,n.slice(0,-1)):s;u[z(n)]=a}}function pt(e,t={}){let{integersAsBigInt:n=`asNeeded`,temporal:r=!1}=t;switch(e.type){case`InlineTable`:let t=B(),i=/* @__PURE__ */ new Set,a=/* @__PURE__ */ new Map;return e.items.forEach(({item:e})=>{let o=e.key.value,s=pt(e.value,{integersAsBigInt:n,temporal:r}),c=K(o),l=vt(o);if(i.has(l))throw Error(`Duplicate key "${c}" in inline table`);for(let e=1;e<o.length;e++){let t=K(o.slice(0,e));if(i.has(vt(o.slice(0,e))))throw Error(`Key "${c}" conflicts with key: "${t}"`)}if(a.has(l)){let e=a.get(l);throw Error(`Key "${c}" conflicts with key: "${e}"`)}i.add(l);for(let e=1;e<o.length;e++){let t=vt(o.slice(0,e));a.has(t)||a.set(t,c)}let u=o.length>1?ht(t,o.slice(0,-1)):t;u[z(o)]=s}),t;case`InlineArray`:return e.items.map(e=>pt(e.item,{integersAsBigInt:n,temporal:r}));case`DateTime`:if(r){if(globalThis.Temporal===void 0)throw Error(`Temporal API is not available in this runtime. Set temporal: false or use a runtime with Temporal support.`);return dt(e.value)}return e.value;case`String`:return e.value;case`Integer`:return lt(e.raw,n);case`Float`:case`Boolean`:return e.value;default:throw Error(`Unrecognized value type "${e.type}"`)}}function mt(e,t,n,r){let i=t.concat(n),a=K(i),o=J(e,i);for(let t=0;t<i.length-1;t++){let n=i.slice(0,t+1),r=J(e,n),a=i[t+1],o=r.runtimeValue;if(r.kind===`date`&&!r.children.has(a)&&typeof o==`object`&&o&&a in o)throw Error(`Value already defined for ${K(n.concat(a))}`)}if(r===`KeyValue`){if(n.length>1){for(let r=1;r<n.length;r++){let i=t.concat(n.slice(0,r)),a=J(e,i),o=K(i);if(a.kind===`inline`)throw Error(`Cannot extend inline table at ${o}`);if(a.kind===`array`)throw Error(`Cannot add to static array at ${o}`);if(a.kind===`table-array`)throw Error(`Cannot traverse Array of Tables at ${o}`);if(a.kind===`value`)throw Error(`Value already defined for ${o}`)}for(let n=t.length+1;n<=i.length;n++){let t=i.slice(0,n);if(J(e,t).kind===`explicit`)throw Error(`Cannot extend explicit table ${K(t)} with dotted keys`)}}if(o.kind===`implicit`||o.kind===`explicit`||o.kind===`table-array`)throw Error(`Table already defined: ${a}`);if(o.kind===`value`||o.kind===`date`||o.kind===`inline`)throw Error(`Value already defined for ${a}`);if(o.kind===`array`)throw Error(`Cannot add to static array at ${a}`)}else{for(let t=1;t<i.length;t++){let n=i.slice(0,t),r=J(e,n),a=K(n);if(r.kind===`inline`)throw Error(`Cannot extend inline table at ${a}`);if(r.kind===`array`)throw Error(`Cannot add to static array at ${a}`);if(r.kind===`value`)throw Error(`Value already defined for ${a}`)}if(o.kind===`inline`)throw Error(`Cannot extend inline table at ${a}`);if(o.kind===`implicit`)throw Error(`Implicit table already defined: ${a}`);if(o.kind===`array`)throw Error(`Cannot add to static array at ${a}`);if(r===`Table`){if(o.kind===`explicit`||o.kind===`table-array`)throw Error(`Table already defined: ${a}`);if(o.kind===`value`||o.kind===`date`)throw Error(`Value already defined for ${a}`)}else if(o.kind!==`undefined`&&o.kind!==`table-array`||o.kind===`undefined`&&o.children.size>0)throw Error(`Cannot add Array of Tables to table at ${a}`)}}function ht(e,t){let n=_t(e,t.slice(0,-1)),r=z(t);return n[r]||(n[r]=B()),n[r]}function gt(e,t){let n=_t(e,t.slice(0,-1)),r=z(t);n[r]||(n[r]=[]);let i=B();return n[z(t)].push(i),i}function _t(e,t){return t.reduce((e,t)=>(e[t]||(e[t]=B()),Array.isArray(e[t])?z(e[t]):e[t]),e)}function K(e){return e.join(`.`)}function vt(e){return JSON.stringify(e)}function q(){return{kind:`undefined`,children:/* @__PURE__ */ new Map,entries:[]}}function J(e,t,n=!1){let r=e;for(let e of t){r.kind===`table-array`&&(r=r.entries[r.entries.length-1]??r);let t=r.children.get(e);if(!t&&n&&(t=q(),r.children.set(e,t)),!t)return q();r=t}return r}var Y=class extends Error{code;path;constructor(e,t,n){super(n),this.name=`PatchLiteError`,this.code=e,this.path=t}};function X(e){let t=``;for(let n of e)t+=typeof n==`number`?`[${n}]`:t?`.${n}`:n;return t||`(root)`}function yt(e){let t=typeof e;return t===`string`||t===`boolean`||t===`number`||t===`bigint`}function Z(e){if(e===null)return`null`;if(Array.isArray(e))return`array`;if(H(e)||U(e))return`date`;let t=typeof e;return t===`object`?`table`:t}function bt(e,t){return V(e)===V(t)}function Q(e){return H(e)||U(e)}function xt(e,t,n=[]){if(ct(e,t)||Qe(e,t)||typeof e==`number`&&typeof t==`number`&&Number.isNaN(e)&&Number.isNaN(t)&&bt(e,t))return[];let r=Array.isArray(e),i=Array.isArray(t);if(r&&i)return Ct(e,t,n);if(r||i)throw new Y(`TypeChange`,n,`Cannot change a ${r?`array`:Z(e)} to a ${i?`array`:Z(t)} at ${X(n)}`);let a=rt(e),o=rt(t);if(a&&o)return St(e,t,n);if(a||o)throw new Y(`TypeChange`,n,`Cannot change a ${a?`table`:Z(e)} to a ${o?`table`:Z(t)} at ${X(n)}`);if(Q(e)&&Q(t))return[{type:`Edit`,path:n}];if(Q(e)||Q(t))throw new Y(`TypeChange`,n,`Cannot change a ${Z(e)} to a ${Z(t)} at ${X(n)}`);if(!yt(e)||!yt(t))throw new Y(`UnsupportedValue`,n,`Unsupported value type ${Z(t)} at ${X(n)}`);return[{type:`Edit`,path:n}]}function St(e,t,n){let r=Object.keys(e),i=Object.keys(t),a=new Set(i);for(let e of r)if(!a.has(e))throw new Y(`RemovedKey`,n.concat(e),`Cannot remove key ${X(n.concat(e))}`);let o=new Set(r);for(let e of i)if(!o.has(e))throw new Y(`AddedKey`,n.concat(e),`Cannot add key ${X(n.concat(e))}`);let s=[];for(let i of r){let r=xt(e[i],t[i],n.concat(i));for(let e of r)s.push(e)}return s}function Ct(e,t,n){if(e.length!==t.length)throw new Y(`ArrayLengthChange`,n,`Cannot change the length of array at ${X(n)} (${e.length} to ${t.length})`);let r=e.map(G),i=t.map(G);if(!r.every((e,t)=>e===i[t])){let e=r.slice().sort(),t=i.slice().sort();if(e.length===t.length&&e.every((e,n)=>e===t[n]))throw new Y(`ArrayReorder`,n,`Cannot reorder array elements at ${X(n)}`)}let a=[];for(let r=0;r<e.length;r++){let i=xt(e[r],t[r],n.concat(r));for(let e of i)a.push(e)}return a}function wt(e){if(e.includes(`'`))return!1;for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n<32&&n!==9||n===127)return!1}return!0}function Tt(e){if(e.includes(`'''`))return!1;for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n===13){if(e.charCodeAt(t+1)!==10)return!1}else if(n<32&&n!==9&&n!==10||n===127)return!1}return!0}function Et(e,t,n){let r=typeof e;if(r===`string`)return It(e,t==null?void 0:t.raw);if(r===`boolean`)return e?`true`:`false`;if(r===`bigint`)return e.toString();if(r===`number`)return Number.isFinite(e)?Number.isSafeInteger(e)&&!Object.is(e,-0)&&!o(t)?jt(e,t==null?void 0:t.raw):Mt(e,o(t)?t.raw:void 0):Pt(e);if(U(e))return Dt(e,t);if(e instanceof Date)return Ot(e,t);throw new Y(`UnsupportedValue`,n,`Unsupported value type ${Object.prototype.toString.call(e)} at ${X(n)}`)}function Dt(e,t){let n=tt(e),r=t==null?void 0:t.raw;return typeof r==`string`&&(r.includes(` `)&&n.includes(`T`)&&(n=n.replace(`T`,` `)),/(?:\+00:00|-00:00)/.test(r)&&n.endsWith(`Z`)&&(n=n.replace(/Z$/,r.match(/([+-]00:00)/)[1]))),n}function Ot(e,t){let n=t==null?void 0:t.raw,r=kt(e);return typeof n==`string`?Oe.createDateWithOriginalFormat(r,n).toISOString():r.toISOString()}function kt(e){let t=e;if(typeof t.isDate!=`function`||typeof t.isTime!=`function`)return e;let n=e.toISOString().replace(/\.000(?=([Zz]|[+-]\d{2}:\d{2})$|$)/,``);return t.isDate()?new S(n):t.isTime()?new C(n,n):t.isLocal()?new w(n,!1):new T(n,!1)}function At(e){if(e.startsWith(`0x`))return{radix:16,prefix:`0x`};if(e.startsWith(`0o`))return{radix:8,prefix:`0o`};if(e.startsWith(`0b`))return{radix:2,prefix:`0b`}}function jt(e,t){if(t){let n=At(t);if(n&&e>=0){let r=n.radix===16&&/[A-F]/.test(t),i=e.toString(n.radix);return r&&(i=i.toUpperCase()),n.prefix+i}}return String(e)}function Mt(e,t){if(Object.is(e,-0))return`-0.0`;if(t&&/[eE]/.test(t))return Nt(e,t);let n=String(e);return/[.eE]/.test(n)?n:`${n}.0`}function Nt(e,t){let n=t.slice(0,t.search(/[eE]/)),r=n.indexOf(`.`),i=r===-1?``:n.slice(r+1),a=!/[1-9]/.test(i),o=Number.isInteger(e)&&!Object.is(e,-0)&&a?i.length:0,[s,c]=e.toExponential().split(/[eE]/),l=s.includes(`.`)?s.length-s.indexOf(`.`)-1:0,u=Math.max(o,l);return`${u>0?Number(s).toFixed(u):String(Number(s))}${t.includes(`E`)?`E`:`e`}${c.replace(/^\+/,``)}`}function Pt(e){return Number.isNaN(e)?V(e)?`-nan`:`nan`:e>0?`inf`:`-inf`}function Ft(e,t,n){return e.startsWith(t+`\r
|
|
10
|
+
`)?`\r
|
|
11
|
+
`:e.startsWith(t+`
|
|
12
|
+
`)?`
|
|
13
|
+
`:n.startsWith(`\r
|
|
14
|
+
`)?`\r
|
|
15
|
+
`:n.startsWith(`
|
|
16
|
+
`)?`
|
|
17
|
+
`:``}function It(e,t){if(t){if(t.startsWith(`'''`))return Tt(e)?`'''`+Ft(t,`'''`,e)+e+`'''`:zt(e);if(t.startsWith(`"""`))return Lt(e,t);if(t.startsWith(`'`)){if(wt(e))return`'`+e+`'`;if(Tt(e))return`'''`+Ft(t,`'''`,e)+e+`'''`}}return zt(e)}function Lt(e,t){let n=Rt(e);return`"""`+Ft(t,`"""`,n)+n+`"""`}function Rt(e){let t=``;for(let n=0;n<e.length;n++){let r=e[n],i=e.charCodeAt(n);t+=r===`\\`?`\\\\`:r===`\b`?`\\b`:r===` `?`\\t`:r===`
|
|
18
|
+
`?`
|
|
19
|
+
`:r===`\f`?`\\f`:r===`\r`?e.charCodeAt(n+1)===10?`\r`:`\\r`:i>=0&&i<=7||i===11||i>=14&&i<=31||i===127?`\\u`+i.toString(16).padStart(4,`0`).toUpperCase():r}return t.replace(/"""/g,`""\\"`)}function zt(e){let t=`"`;for(let n of e){let e=n.codePointAt(0);t+=n===`"`?`\\"`:n===`\\`?`\\\\`:n===`\b`?`\\b`:n===` `?`\\t`:n===`
|
|
20
|
+
`?`\\n`:n===`\f`?`\\f`:n===`\r`?`\\r`:e<32||e===127?`\\u`+e.toString(16).padStart(4,`0`).toUpperCase():n}return t+=`"`,t}function $(i,a){if(!a.length)return u(i)&&r(i.item)?i.item:i;if(r(i))return $(i.value,a);let o={},s,c;if(f(i)&&i.items.some((l,d)=>{try{let f=[];if(r(l))f=l.key.value;else if(t(l))f=l.key.item.value;else if(n(l)){f=l.key.item.value;let e=G(f);o[e]||(o[e]=0);let t=o[e]++;f=f.concat(t)}else u(l)&&r(l.item)?f=l.item.key.value:u(l)&&(f=[d]);if(f.length&&W(f,a.slice(0,f.length))){let t=a.slice(f.length);if(e(i)&&n(l)&&t.length>0){let e=l.key.item.value,r=i,a=r.items.findIndex((t,r)=>r>d&&n(t)&&W(t.key.item.value,e)),o=a===-1?r.items.length:a;s=Bt(l,t,e,r.items.slice(d+1,o))}else s=u(l)&&r(l.item)?a.length===f.length?l:$(l.item.value,t):u(l)&&a.length>f.length?$(l.item,t):$(l,t);return!0}return(r(l)||u(l)&&r(l.item))&&f.length>a.length&&W(f.slice(0,a.length),a)&&(c||=l),!1}catch{return!1}}),!s&&c&&(s=c),!s)throw Error(`Node not found at ${a.join(`.`)}`);return s}function Bt(e,r,i,a){try{return $(e,r)}catch{}let o={};for(let[e,s]of a.entries()){let c=[];if(t(s)){let e=s.key.item.value;e.length>i.length&&W(e.slice(0,i.length),i)&&(c=e.slice(i.length))}else if(n(s)){let e=s.key.item.value;if(e.length>i.length&&W(e.slice(0,i.length),i)){let t=e.slice(i.length),n=G(t);o[n]||(o[n]=0);let r=o[n]++;c=t.concat(r)}}if(c.length&&W(c,r.slice(0,c.length)))try{let t=r.slice(c.length);if(!t.length||!n(s))return $(s,t);let i=a.findIndex((t,r)=>r>e&&n(t)&&W(t.key.item.value,s.key.item.value)),o=a.slice(e+1,i===-1?a.length:i);return Bt(s,t,s.key.item.value,o)}catch{}}throw Error(`Node not found at (aot scope) ${r.join(`.`)}`)}function Vt(e){return e.charCodeAt(0)===65279}const Ht=/* @__PURE__ */ new WeakMap,Ut=/* @__PURE__ */ new WeakMap;function Wt(e,t){return(e[t.line-1]??e[e.length-1])+t.column}function Gt(e,t){let n=Kt(t);for(let t of e)n(t)}function Kt(e){let i=[0];for(let t=0;t<e.length;t++)e.charCodeAt(t)===10&&i.push(t+1);return a=>{let o=[a];for(;o.length>0;){let a=o.pop(),s=[Wt(i,a.loc.start),Wt(i,a.loc.end)];if(Object.defineProperty(a,"range",{configurable:!0,enumerable:!1,value:s}),Ht.set(a,e),Ut.set(a,qt(a).slice()),r(a))o.push(a.value),o.push(a.key);else if(u(a))o.push(a.item);else if(t(a)||n(a)){o.push(a.key);let e=a.items;for(let t=e.length-1;t>=0;t--)o.push(e[t])}else if(f(a)){let e=a.items;for(let t=e.length-1;t>=0;t--)o.push(e[t])}}}}function qt(e){return r(e)?[e.key,e.value]:u(e)?[e.item]:t(e)||n(e)?[e.key,...e.items]:f(e)?e.items:[]}function Jt(e){let t=1,n=0;for(let r of e){let e=r.loc.end;(e.line>t||e.line===t&&e.column>n)&&(t=e.line,n=e.column)}return{type:`Document`,loc:{start:{line:1,column:0},end:{line:t,column:n}},items:e}}function Yt(e){return r(e)?e.value:u(e)?r(e.item)?e.item.value:e.item:e}function Xt(e,t){let n=e;for(let e of t)n=n==null?void 0:n[e];return n}function Zt(e,t){if(arguments.length>2&&arguments[2]!==void 0&&arguments[2]!==null)throw new Y(`UnsupportedOption`,[],`patch-lite does not support formatting options; use patch() from the main package`);let n=Vt(e),r=n?e.slice(1):e,i=Array.from(Re(r));Gt(i,r);let a=xt(ft(i,r,{integersAsBigInt:`asNeeded`,temporal:nt(t)}),t);if(a.length===0)return e;let o=Jt(i),s=[];for(let e of a){let n=Yt($(o,e.path));if(!ee(n))throw Error(`Cannot locate a value at ${X(e.path)}`);let r=n.range;if(!r)throw Error(`Missing source location for value at ${X(e.path)}`);s.push({start:r[0],end:r[1],text:Et(Xt(t,e.path),n,e.path)})}s.sort((e,t)=>t.start-e.start);let c=r;for(let e of s)c=c.slice(0,e.start)+e.text+c.slice(e.end);return n?``+c:c}export{Zt as patch};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decimalturn/toml-patch",
|
|
3
|
-
"version": "3.3.3-
|
|
4
|
-
"description": "Patch, parse, and stringify TOML while preserving comments, whitespace and formatting.",
|
|
3
|
+
"version": "3.3.3-lite",
|
|
4
|
+
"description": "Patch, parse, and stringify TOML while preserving comments, whitespace and formatting. Lite value-editing distribution.",
|
|
5
5
|
"homepage": "https://github.com/DecimalTurn/toml-patch",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -13,20 +13,15 @@
|
|
|
13
13
|
"node": ">=16"
|
|
14
14
|
},
|
|
15
15
|
"sideEffects": false,
|
|
16
|
-
"types": "./dist/
|
|
16
|
+
"types": "./dist/patch.d.ts",
|
|
17
17
|
"files": [
|
|
18
18
|
"dist/"
|
|
19
19
|
],
|
|
20
20
|
"exports": {
|
|
21
21
|
".": {
|
|
22
|
-
"types": "./dist/
|
|
23
|
-
"import": "./dist/
|
|
24
|
-
"default": "./dist/
|
|
25
|
-
},
|
|
26
|
-
"./patch-lite": {
|
|
27
|
-
"types": "./dist/patch-lite.d.ts",
|
|
28
|
-
"import": "./dist/dev/patch-lite.js",
|
|
29
|
-
"default": "./dist/dev/patch-lite.js"
|
|
22
|
+
"types": "./dist/patch.d.ts",
|
|
23
|
+
"import": "./dist/patch.js",
|
|
24
|
+
"default": "./dist/patch.js"
|
|
30
25
|
}
|
|
31
26
|
},
|
|
32
27
|
"publishConfig": {
|
|
@@ -1,371 +0,0 @@
|
|
|
1
|
-
//! @decimalturn/toml-patch v3.3.3 - https://github.com/DecimalTurn/toml-patch - @license: MIT
|
|
2
|
-
import { hasItems, isComment, isInlineArray, isInlineItem, isInlineTable, isKeyValue, isTable, isTableArray } from "./cst.js";
|
|
3
|
-
import { getSpan } from "./location.js";
|
|
4
|
-
|
|
5
|
-
// src/comment-alignment.ts
|
|
6
|
-
/**
|
|
7
|
-
* @file Comment alignment helpers for the patch pipeline.
|
|
8
|
-
* @module comment-alignment
|
|
9
|
-
*
|
|
10
|
-
* Utilities for preserving and normalizing aligned inline comments during patching.
|
|
11
|
-
*
|
|
12
|
-
* This module owns the comment-column logic used by the patch pipeline:
|
|
13
|
-
* it detects whether an inline comment belongs to an aligned group, preserves
|
|
14
|
-
* that alignment when edits change value width, compensates for inline insert
|
|
15
|
-
* width deltas, and performs a final string-level normalization pass for padded
|
|
16
|
-
* aligned comment blocks.
|
|
17
|
-
*/
|
|
18
|
-
const reserved_comment_spacing = /* @__PURE__ */ new WeakMap();
|
|
19
|
-
const original_comment_column = /* @__PURE__ */ new WeakMap();
|
|
20
|
-
/**
|
|
21
|
-
* Returns the inline comment attached to the item at the given index.
|
|
22
|
-
*
|
|
23
|
-
* An attached inline comment is the first comment that starts on the same line
|
|
24
|
-
* as the item's end position, before any later non-comment row begins.
|
|
25
|
-
*
|
|
26
|
-
* @param items Container items to inspect.
|
|
27
|
-
* @param index Index of the row whose trailing comment should be resolved.
|
|
28
|
-
* @returns The attached inline comment, if present.
|
|
29
|
-
*/
|
|
30
|
-
function getAttachedInlineComment(items, index) {
|
|
31
|
-
const commentLine = items[index].loc.end.line;
|
|
32
|
-
for (let i = index + 1; i < items.length; i++) {
|
|
33
|
-
const candidate = items[i];
|
|
34
|
-
if (isComment(candidate) && candidate.loc.start.line === commentLine) return candidate;
|
|
35
|
-
if (!isComment(candidate) && candidate.loc.start.line > commentLine) return;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Finds the nearest non-comment row index in the requested direction.
|
|
40
|
-
*
|
|
41
|
-
* @param items Container items to scan.
|
|
42
|
-
* @param index Starting row index.
|
|
43
|
-
* @param direction Scan direction: `-1` for upward, `1` for downward.
|
|
44
|
-
* @returns The nearest neighboring row index, if one exists.
|
|
45
|
-
*/
|
|
46
|
-
function getNeighborRowIndex(items, index, direction) {
|
|
47
|
-
for (let i = index + direction; i >= 0 && i < items.length; i += direction) if (!isComment(items[i])) return i;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Repositions an inline comment to keep it aligned after a width change.
|
|
51
|
-
*
|
|
52
|
-
* @param comment Comment node to adjust.
|
|
53
|
-
* @param targetColumn Desired aligned column for the comment start.
|
|
54
|
-
* @param deltaColumns Horizontal width delta introduced by the edit.
|
|
55
|
-
*/
|
|
56
|
-
function applyInlineCommentColumnAdjustment(comment, targetColumn, deltaColumns) {
|
|
57
|
-
if (!original_comment_column.has(comment)) original_comment_column.set(comment, comment.loc.start.column);
|
|
58
|
-
const shiftedColumn = comment.loc.start.column + deltaColumns;
|
|
59
|
-
const adjustment = Math.max(targetColumn, shiftedColumn) - shiftedColumn;
|
|
60
|
-
if (adjustment !== 0) {
|
|
61
|
-
comment.loc.start.column += adjustment;
|
|
62
|
-
comment.loc.end.column += adjustment;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Stores the current minimum spacing between a row and its trailing comment.
|
|
67
|
-
*
|
|
68
|
-
* This data is refreshed each time it is observed so reused CST comment nodes
|
|
69
|
-
* do not retain stale spacing or column values from a previous patch run.
|
|
70
|
-
*
|
|
71
|
-
* @param row Key-value row that owns the trailing comment.
|
|
72
|
-
* @param comment Trailing inline comment attached to the row.
|
|
73
|
-
*/
|
|
74
|
-
function rememberReservedCommentSpacing(row, comment) {
|
|
75
|
-
original_comment_column.set(comment, comment.loc.start.column);
|
|
76
|
-
reserved_comment_spacing.set(comment, comment.loc.start.column - row.loc.end.column);
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Preserves an aligned trailing inline comment when the row's value node is
|
|
80
|
-
* being replaced by another value node.
|
|
81
|
-
*
|
|
82
|
-
* Use this in edit flows where the patch operation has both the old value and
|
|
83
|
-
* the new value available, for example when `a = "x" # note` becomes
|
|
84
|
-
* `a = "much longer text" # note`. The function computes the width delta from
|
|
85
|
-
* `existingValue` and `replacementValue`, then repositions the same-line
|
|
86
|
-
* comment so it stays aligned with the adjacent rows that were already aligned
|
|
87
|
-
* before the edit.
|
|
88
|
-
*
|
|
89
|
-
* In short:
|
|
90
|
-
* - `preserveAlignedInlineCommentColumn` is for replacement edits
|
|
91
|
-
* - it derives `deltaColumns` itself from the old and new value spans
|
|
92
|
-
*
|
|
93
|
-
* The comment is adjusted only when the current row already belongs to a
|
|
94
|
-
* vertically aligned comment group with an immediately adjacent row above or
|
|
95
|
-
* below, and both old and new values are single-line.
|
|
96
|
-
*
|
|
97
|
-
* @param container Parent container that owns the row.
|
|
98
|
-
* @param row Key-value row being edited.
|
|
99
|
-
* @param existingValue Original value before replacement.
|
|
100
|
-
* @param replacementValue Replacement value after editing.
|
|
101
|
-
*/
|
|
102
|
-
function preserveAlignedInlineCommentColumn(container, row, existingValue, replacementValue) {
|
|
103
|
-
if (!hasItems(container)) return;
|
|
104
|
-
const items = container.items;
|
|
105
|
-
const rowIndex = items.indexOf(row);
|
|
106
|
-
if (rowIndex < 0) return;
|
|
107
|
-
const comment = getAttachedInlineComment(items, rowIndex);
|
|
108
|
-
if (!comment) return;
|
|
109
|
-
if (existingValue.loc.start.line !== existingValue.loc.end.line) return;
|
|
110
|
-
if (replacementValue.loc.start.line !== replacementValue.loc.end.line) return;
|
|
111
|
-
const currentColumn = comment.loc.start.column;
|
|
112
|
-
const currentLine = comment.loc.start.line;
|
|
113
|
-
const neighborIndexes = [getNeighborRowIndex(items, rowIndex, -1), getNeighborRowIndex(items, rowIndex, 1)];
|
|
114
|
-
let alignedColumn;
|
|
115
|
-
for (const neighborIndex of neighborIndexes) {
|
|
116
|
-
if (neighborIndex == null) continue;
|
|
117
|
-
const neighborComment = getAttachedInlineComment(items, neighborIndex);
|
|
118
|
-
if (!neighborComment) continue;
|
|
119
|
-
if (Math.abs(neighborComment.loc.start.line - currentLine) !== 1) continue;
|
|
120
|
-
if (neighborComment.loc.start.column !== currentColumn) continue;
|
|
121
|
-
alignedColumn = neighborComment.loc.start.column;
|
|
122
|
-
break;
|
|
123
|
-
}
|
|
124
|
-
if (alignedColumn == null) return;
|
|
125
|
-
const existingSpan = getSpan(existingValue.loc);
|
|
126
|
-
const deltaColumns = getSpan(replacementValue.loc).columns - existingSpan.columns;
|
|
127
|
-
applyInlineCommentColumnAdjustment(comment, alignedColumn, deltaColumns);
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Preserves an aligned trailing inline comment when the row gets wider because
|
|
131
|
-
* content was inserted inside an inline container, but the row value node
|
|
132
|
-
* itself was not replaced.
|
|
133
|
-
*
|
|
134
|
-
* Use this in add/insert flows where the caller already knows the rendered
|
|
135
|
-
* width change, for example when inserting a new element into an inline array
|
|
136
|
-
* on a row like `a = [1, 2] # note`. In that case there is no old-vs-new row
|
|
137
|
-
* value pair available here, so the caller passes the precomputed
|
|
138
|
-
* `deltaColumns` directly.
|
|
139
|
-
*
|
|
140
|
-
* In short:
|
|
141
|
-
* - `preserveAlignedInlineCommentForDelta` is for insertion-driven width shifts
|
|
142
|
-
* - it consumes a precomputed `deltaColumns` instead of comparing two value nodes
|
|
143
|
-
*
|
|
144
|
-
* @param container Parent container that owns the row.
|
|
145
|
-
* @param row Key-value row whose trailing comment may need to move.
|
|
146
|
-
* @param deltaColumns Horizontal width delta introduced by the insertion.
|
|
147
|
-
*/
|
|
148
|
-
function preserveAlignedInlineCommentForDelta(container, row, deltaColumns) {
|
|
149
|
-
if (!hasItems(container)) return;
|
|
150
|
-
const items = container.items;
|
|
151
|
-
const rowIndex = items.indexOf(row);
|
|
152
|
-
if (rowIndex < 0) return;
|
|
153
|
-
const comment = getAttachedInlineComment(items, rowIndex);
|
|
154
|
-
if (!comment) return;
|
|
155
|
-
const currentColumn = comment.loc.start.column;
|
|
156
|
-
const currentLine = comment.loc.start.line;
|
|
157
|
-
const neighborIndexes = [getNeighborRowIndex(items, rowIndex, -1), getNeighborRowIndex(items, rowIndex, 1)];
|
|
158
|
-
for (const neighborIndex of neighborIndexes) {
|
|
159
|
-
if (neighborIndex == null) continue;
|
|
160
|
-
const neighborComment = getAttachedInlineComment(items, neighborIndex);
|
|
161
|
-
if (!neighborComment) continue;
|
|
162
|
-
if (Math.abs(neighborComment.loc.start.line - currentLine) !== 1) continue;
|
|
163
|
-
if (neighborComment.loc.start.column !== currentColumn) continue;
|
|
164
|
-
applyInlineCommentColumnAdjustment(comment, neighborComment.loc.start.column, deltaColumns);
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* Records baseline comment alignment metadata for a row whose value is a
|
|
170
|
-
* single-line inline table and whose internal contents are being edited.
|
|
171
|
-
*
|
|
172
|
-
* This captures the comment's current column and reserved gap (comment start
|
|
173
|
-
* minus row end) so the final normalization pass can preserve spacing
|
|
174
|
-
* expectations after nested inline-table edits.
|
|
175
|
-
*
|
|
176
|
-
* @param container Parent container that owns the row.
|
|
177
|
-
* @param row Key-value row whose trailing comment alignment metadata is refreshed.
|
|
178
|
-
* @param deltaColumns Horizontal width delta introduced by the nested edit; used
|
|
179
|
-
* only as a fast no-op guard when zero.
|
|
180
|
-
*/
|
|
181
|
-
function recordInlineTableCommentDelta(container, row, deltaColumns) {
|
|
182
|
-
if (!hasItems(container) || deltaColumns === 0) return;
|
|
183
|
-
const items = container.items;
|
|
184
|
-
const rowIndex = items.indexOf(row);
|
|
185
|
-
if (rowIndex < 0) return;
|
|
186
|
-
const comment = getAttachedInlineComment(items, rowIndex);
|
|
187
|
-
if (!comment) return;
|
|
188
|
-
rememberReservedCommentSpacing(row, comment);
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* Estimates the horizontal column delta caused by inserting a new inline item.
|
|
192
|
-
*
|
|
193
|
-
* The result includes the inserted value width and the comma/spacing overhead
|
|
194
|
-
* needed by the surrounding inline array or inline table formatting.
|
|
195
|
-
*
|
|
196
|
-
* @param parent Inline container receiving the new child.
|
|
197
|
-
* @param child CST node being inserted.
|
|
198
|
-
* @param index Target insertion index.
|
|
199
|
-
* @returns The number of columns added to the rendered row.
|
|
200
|
-
*/
|
|
201
|
-
function getInlineInsertColumnDelta(parent, child, index) {
|
|
202
|
-
if (!isInlineArray(parent) && !isInlineTable(parent)) return 0;
|
|
203
|
-
const childSpan = getSpan(child.loc);
|
|
204
|
-
const hasSeparatingCommaBefore = index > 0;
|
|
205
|
-
const hasSeparatingCommaAfter = index < parent.items.length;
|
|
206
|
-
const isLastElement = index === parent.items.length;
|
|
207
|
-
const hasTrailingComma = isInlineItem(child) ? child.comma : false;
|
|
208
|
-
const hasTrailingCommaSpacingBug = hasSeparatingCommaBefore && hasTrailingComma && !hasSeparatingCommaAfter && isLastElement;
|
|
209
|
-
return childSpan.columns + (hasSeparatingCommaBefore || hasSeparatingCommaAfter ? 2 : 0) + (hasTrailingComma ? 1 + (hasTrailingCommaSpacingBug ? -1 : 0) : 0);
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* Recursively collects comment nodes from the document and nested tables.
|
|
213
|
-
*
|
|
214
|
-
* @param node Document or table-like node to traverse.
|
|
215
|
-
* @param comments Accumulator used during recursion.
|
|
216
|
-
* @returns All discovered comment nodes.
|
|
217
|
-
*/
|
|
218
|
-
function collectComments(node, comments = []) {
|
|
219
|
-
for (const item of node.items) {
|
|
220
|
-
if (isComment(item)) {
|
|
221
|
-
comments.push(item);
|
|
222
|
-
continue;
|
|
223
|
-
}
|
|
224
|
-
if (isTable(item) || isTableArray(item)) collectComments(item, comments);
|
|
225
|
-
}
|
|
226
|
-
return comments;
|
|
227
|
-
}
|
|
228
|
-
/**
|
|
229
|
-
* Collects the line numbers of single-line key-value rows whose value is a
|
|
230
|
-
* single-line inline table.
|
|
231
|
-
*
|
|
232
|
-
* @param node Document or table-like node to traverse.
|
|
233
|
-
* @param lines Accumulator used during recursion.
|
|
234
|
-
* @returns A set of row end lines for inline-table rows.
|
|
235
|
-
*/
|
|
236
|
-
function collectSingleLineInlineTableCommentLines(node, lines = /* @__PURE__ */ new Set()) {
|
|
237
|
-
for (const item of node.items) {
|
|
238
|
-
if (isKeyValue(item) && isInlineTable(item.value) && item.loc.start.line === item.loc.end.line) {
|
|
239
|
-
lines.add(item.loc.end.line);
|
|
240
|
-
continue;
|
|
241
|
-
}
|
|
242
|
-
if (isTable(item) || isTableArray(item)) collectSingleLineInlineTableCommentLines(item, lines);
|
|
243
|
-
}
|
|
244
|
-
return lines;
|
|
245
|
-
}
|
|
246
|
-
/**
|
|
247
|
-
* Recomputes `loc.end` for the document/table container chain from children.
|
|
248
|
-
*
|
|
249
|
-
* Inline comment normalization can move trailing comments horizontally; this
|
|
250
|
-
* keeps parent containers' end positions consistent with their updated children.
|
|
251
|
-
*
|
|
252
|
-
* @param node Document or table-like container to normalize.
|
|
253
|
-
*/
|
|
254
|
-
function recomputeContainerEnds(node) {
|
|
255
|
-
for (const item of node.items) if (isTable(item) || isTableArray(item)) recomputeContainerEnds(item);
|
|
256
|
-
let maxLine = node.loc.end.line;
|
|
257
|
-
let maxColumn = node.loc.end.column;
|
|
258
|
-
const updateMax = (line, column) => {
|
|
259
|
-
if (line > maxLine || line === maxLine && column > maxColumn) {
|
|
260
|
-
maxLine = line;
|
|
261
|
-
maxColumn = column;
|
|
262
|
-
}
|
|
263
|
-
};
|
|
264
|
-
if (isTable(node) || isTableArray(node)) updateMax(node.key.loc.end.line, node.key.loc.end.column);
|
|
265
|
-
for (const item of node.items) updateMax(item.loc.end.line, item.loc.end.column);
|
|
266
|
-
node.loc.end.line = maxLine;
|
|
267
|
-
node.loc.end.column = maxColumn;
|
|
268
|
-
}
|
|
269
|
-
/**
|
|
270
|
-
* Normalizes padded inline comment groups in the final rendered TOML string.
|
|
271
|
-
*
|
|
272
|
-
* This pass is intentionally limited to comments that already have explicit
|
|
273
|
-
* padding before `#`, which avoids disturbing compact TOML 1.1 inline-table
|
|
274
|
-
* comment styles while still restoring vertical alignment for normal row-based
|
|
275
|
-
* comment blocks.
|
|
276
|
-
*
|
|
277
|
-
* For groups touched by nested inline-table edits, the target column is derived
|
|
278
|
-
* from the widest current row plus the group's original minimum reserved gap.
|
|
279
|
-
*
|
|
280
|
-
* @param document Patched CST document whose comment locations are updated in-place.
|
|
281
|
-
* @param tomlString Rendered TOML output to normalize.
|
|
282
|
-
* @param format Active TOML formatting settings.
|
|
283
|
-
* @returns The normalized TOML string.
|
|
284
|
-
*/
|
|
285
|
-
function normalizeInlineCommentAlignmentInString(document, tomlString, format) {
|
|
286
|
-
const newLine = format.newLine;
|
|
287
|
-
const trailingMatch = tomlString.match(/(?:\r\n|\n)+$/u);
|
|
288
|
-
const trailing = trailingMatch ? trailingMatch[0] : "";
|
|
289
|
-
const body = trailing ? tomlString.slice(0, -trailing.length) : tomlString;
|
|
290
|
-
const lines = body.length ? body.split(newLine) : [];
|
|
291
|
-
const inlineTableCommentLines = collectSingleLineInlineTableCommentLines(document);
|
|
292
|
-
const resolveCommentColumn = (line, comment) => {
|
|
293
|
-
const fromLine = line.lastIndexOf(comment.raw);
|
|
294
|
-
return fromLine >= 0 ? fromLine : comment.loc.start.column;
|
|
295
|
-
};
|
|
296
|
-
const comments = collectComments(document).filter((comment) => {
|
|
297
|
-
const line = lines[comment.loc.start.line - 1] || "";
|
|
298
|
-
const commentColumn = resolveCommentColumn(line, comment);
|
|
299
|
-
const beforeComment = line.slice(0, commentColumn);
|
|
300
|
-
return beforeComment.trim().length > 0 && /\s{2,}$/u.test(beforeComment);
|
|
301
|
-
}).sort((a, b) => a.loc.start.line - b.loc.start.line);
|
|
302
|
-
const groups = [];
|
|
303
|
-
let currentGroup = [];
|
|
304
|
-
for (const comment of comments) {
|
|
305
|
-
const previous = currentGroup[currentGroup.length - 1];
|
|
306
|
-
if (!previous || comment.loc.start.line === previous.loc.start.line + 1) currentGroup.push(comment);
|
|
307
|
-
else {
|
|
308
|
-
if (currentGroup.length > 0) groups.push(currentGroup);
|
|
309
|
-
currentGroup = [comment];
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
if (currentGroup.length > 0) groups.push(currentGroup);
|
|
313
|
-
for (const group of groups) {
|
|
314
|
-
if (group.length < 2) continue;
|
|
315
|
-
let targetColumn = original_comment_column.get(group[0]) ?? group[0].loc.start.column;
|
|
316
|
-
const counts = /* @__PURE__ */ new Map();
|
|
317
|
-
for (const comment of group) {
|
|
318
|
-
const baselineColumn = original_comment_column.get(comment) ?? comment.loc.start.column;
|
|
319
|
-
counts.set(baselineColumn, (counts.get(baselineColumn) || 0) + 1);
|
|
320
|
-
}
|
|
321
|
-
let highestCount = 1;
|
|
322
|
-
for (const [column, count] of counts) if (count > highestCount) {
|
|
323
|
-
highestCount = count;
|
|
324
|
-
targetColumn = column;
|
|
325
|
-
}
|
|
326
|
-
const widestCodeColumn = Math.max(...group.map((comment) => {
|
|
327
|
-
const line = lines[comment.loc.start.line - 1] || "";
|
|
328
|
-
const commentColumn = resolveCommentColumn(line, comment);
|
|
329
|
-
return line.slice(0, commentColumn).trimEnd().length;
|
|
330
|
-
}));
|
|
331
|
-
let groupMinimumGap = Math.min(...group.map((comment) => {
|
|
332
|
-
const line = lines[comment.loc.start.line - 1] || "";
|
|
333
|
-
const commentColumn = resolveCommentColumn(line, comment);
|
|
334
|
-
const code = line.slice(0, commentColumn).trimEnd();
|
|
335
|
-
return Math.max(1, commentColumn - code.length);
|
|
336
|
-
}));
|
|
337
|
-
const reservedComments = group.filter((comment) => reserved_comment_spacing.has(comment));
|
|
338
|
-
const hasNonInlineTableRows = group.some((comment) => !inlineTableCommentLines.has(comment.loc.start.line));
|
|
339
|
-
if (reservedComments.length > 0 && hasNonInlineTableRows) {
|
|
340
|
-
const reservedMinimumGap = Math.min(...group.map((comment) => {
|
|
341
|
-
if (reserved_comment_spacing.has(comment)) return reserved_comment_spacing.get(comment) || 1;
|
|
342
|
-
const line = lines[comment.loc.start.line - 1] || "";
|
|
343
|
-
const commentColumn = resolveCommentColumn(line, comment);
|
|
344
|
-
const code = line.slice(0, commentColumn).trimEnd();
|
|
345
|
-
return Math.max(1, commentColumn - code.length);
|
|
346
|
-
}));
|
|
347
|
-
groupMinimumGap = Math.min(groupMinimumGap, reservedMinimumGap);
|
|
348
|
-
}
|
|
349
|
-
if (targetColumn < widestCodeColumn + 1) {
|
|
350
|
-
const requiredColumn = widestCodeColumn + groupMinimumGap;
|
|
351
|
-
targetColumn = Math.max(targetColumn, requiredColumn);
|
|
352
|
-
}
|
|
353
|
-
for (const comment of group) {
|
|
354
|
-
const lineIndex = comment.loc.start.line - 1;
|
|
355
|
-
const line = lines[lineIndex] || "";
|
|
356
|
-
const commentColumn = resolveCommentColumn(line, comment);
|
|
357
|
-
const code = line.slice(0, commentColumn).trimEnd();
|
|
358
|
-
const actualTargetColumn = Math.max(targetColumn, code.length + 1);
|
|
359
|
-
if (commentColumn !== actualTargetColumn) lines[lineIndex] = code + " ".repeat(actualTargetColumn - code.length) + comment.raw;
|
|
360
|
-
if (comment.loc.start.column !== actualTargetColumn) {
|
|
361
|
-
comment.loc.start.column = actualTargetColumn;
|
|
362
|
-
comment.loc.end.column = actualTargetColumn + comment.raw.length;
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
recomputeContainerEnds(document);
|
|
367
|
-
return lines.join(newLine) + trailing;
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
export { getInlineInsertColumnDelta, normalizeInlineCommentAlignmentInString, preserveAlignedInlineCommentColumn, preserveAlignedInlineCommentForDelta, recordInlineTableCommentDelta };
|
|
371
|
-
//# sourceMappingURL=comment-alignment.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"comment-alignment.js","names":[],"sources":["../../src/comment-alignment.ts"],"sourcesContent":["/**\n * @file Comment alignment helpers for the patch pipeline.\n * @module comment-alignment\n *\n * Utilities for preserving and normalizing aligned inline comments during patching.\n *\n * This module owns the comment-column logic used by the patch pipeline:\n * it detects whether an inline comment belongs to an aligned group, preserves\n * that alignment when edits change value width, compensates for inline insert\n * width deltas, and performs a final string-level normalization pass for padded\n * aligned comment blocks.\n */\nimport {\n Comment,\n Document,\n KeyValue,\n Table,\n TableArray,\n TreeNode,\n Value,\n hasItems,\n isComment,\n isInlineArray,\n isInlineItem,\n isInlineTable,\n isKeyValue,\n isTable,\n isTableArray\n} from './cst';\nimport { getSpan } from './location';\nimport { TomlFormat } from './toml-format';\n\nconst reserved_comment_spacing = new WeakMap<Comment, number>();\nconst original_comment_column = new WeakMap<Comment, number>();\n\n/**\n * Returns the inline comment attached to the item at the given index.\n *\n * An attached inline comment is the first comment that starts on the same line\n * as the item's end position, before any later non-comment row begins.\n *\n * @param items Container items to inspect.\n * @param index Index of the row whose trailing comment should be resolved.\n * @returns The attached inline comment, if present.\n */\nfunction getAttachedInlineComment(items: TreeNode[], index: number): Comment | undefined {\n const current = items[index];\n const commentLine = current.loc.end.line;\n\n for (let i = index + 1; i < items.length; i++) {\n const candidate = items[i];\n if (isComment(candidate) && candidate.loc.start.line === commentLine) {\n return candidate;\n }\n\n if (!isComment(candidate) && candidate.loc.start.line > commentLine) {\n return;\n }\n }\n}\n\n/**\n * Finds the nearest non-comment row index in the requested direction.\n *\n * @param items Container items to scan.\n * @param index Starting row index.\n * @param direction Scan direction: `-1` for upward, `1` for downward.\n * @returns The nearest neighboring row index, if one exists.\n */\nfunction getNeighborRowIndex(items: TreeNode[], index: number, direction: -1 | 1): number | undefined {\n for (let i = index + direction; i >= 0 && i < items.length; i += direction) {\n if (!isComment(items[i])) {\n return i;\n }\n }\n}\n\n/**\n * Repositions an inline comment to keep it aligned after a width change.\n *\n * @param comment Comment node to adjust.\n * @param targetColumn Desired aligned column for the comment start.\n * @param deltaColumns Horizontal width delta introduced by the edit.\n */\nfunction applyInlineCommentColumnAdjustment(comment: Comment, targetColumn: number, deltaColumns: number) {\n if (!original_comment_column.has(comment)) {\n original_comment_column.set(comment, comment.loc.start.column);\n }\n\n const shiftedColumn = comment.loc.start.column + deltaColumns;\n // Never pull a widened row's comment left into its own code; let the\n // normalization pass realign neighboring rows to the widened target.\n const desiredColumn = Math.max(targetColumn, shiftedColumn);\n const adjustment = desiredColumn - shiftedColumn;\n\n if (adjustment !== 0) {\n comment.loc.start.column += adjustment;\n comment.loc.end.column += adjustment;\n }\n}\n\n/**\n * Stores the current minimum spacing between a row and its trailing comment.\n *\n * This data is refreshed each time it is observed so reused CST comment nodes\n * do not retain stale spacing or column values from a previous patch run.\n *\n * @param row Key-value row that owns the trailing comment.\n * @param comment Trailing inline comment attached to the row.\n */\nfunction rememberReservedCommentSpacing(row: KeyValue, comment: Comment) {\n original_comment_column.set(comment, comment.loc.start.column);\n reserved_comment_spacing.set(comment, comment.loc.start.column - row.loc.end.column);\n}\n\n/**\n * Preserves an aligned trailing inline comment when the row's value node is\n * being replaced by another value node.\n *\n * Use this in edit flows where the patch operation has both the old value and\n * the new value available, for example when `a = \"x\" # note` becomes\n * `a = \"much longer text\" # note`. The function computes the width delta from\n * `existingValue` and `replacementValue`, then repositions the same-line\n * comment so it stays aligned with the adjacent rows that were already aligned\n * before the edit.\n *\n * In short:\n * - `preserveAlignedInlineCommentColumn` is for replacement edits\n * - it derives `deltaColumns` itself from the old and new value spans\n *\n * The comment is adjusted only when the current row already belongs to a\n * vertically aligned comment group with an immediately adjacent row above or\n * below, and both old and new values are single-line.\n *\n * @param container Parent container that owns the row.\n * @param row Key-value row being edited.\n * @param existingValue Original value before replacement.\n * @param replacementValue Replacement value after editing.\n */\nexport function preserveAlignedInlineCommentColumn(\n container: TreeNode,\n row: KeyValue,\n existingValue: TreeNode,\n replacementValue: TreeNode\n) {\n if (!hasItems(container)) return;\n\n const items = container.items as TreeNode[];\n const rowIndex = items.indexOf(row);\n if (rowIndex < 0) return;\n\n const comment = getAttachedInlineComment(items, rowIndex);\n if (!comment) return;\n\n if (existingValue.loc.start.line !== existingValue.loc.end.line) return;\n if (replacementValue.loc.start.line !== replacementValue.loc.end.line) return;\n\n const currentColumn = comment.loc.start.column;\n const currentLine = comment.loc.start.line;\n const neighborIndexes = [\n getNeighborRowIndex(items, rowIndex, -1),\n getNeighborRowIndex(items, rowIndex, 1)\n ];\n\n let alignedColumn: number | undefined;\n for (const neighborIndex of neighborIndexes) {\n if (neighborIndex == null) continue;\n\n const neighborComment = getAttachedInlineComment(items, neighborIndex);\n if (!neighborComment) continue;\n if (Math.abs(neighborComment.loc.start.line - currentLine) !== 1) continue;\n if (neighborComment.loc.start.column !== currentColumn) continue;\n\n alignedColumn = neighborComment.loc.start.column;\n break;\n }\n\n if (alignedColumn == null) return;\n\n const existingSpan = getSpan(existingValue.loc);\n const replacementSpan = getSpan(replacementValue.loc);\n const deltaColumns = replacementSpan.columns - existingSpan.columns;\n\n applyInlineCommentColumnAdjustment(comment, alignedColumn, deltaColumns);\n}\n\n/**\n * Preserves an aligned trailing inline comment when the row gets wider because\n * content was inserted inside an inline container, but the row value node\n * itself was not replaced.\n *\n * Use this in add/insert flows where the caller already knows the rendered\n * width change, for example when inserting a new element into an inline array\n * on a row like `a = [1, 2] # note`. In that case there is no old-vs-new row\n * value pair available here, so the caller passes the precomputed\n * `deltaColumns` directly.\n *\n * In short:\n * - `preserveAlignedInlineCommentForDelta` is for insertion-driven width shifts\n * - it consumes a precomputed `deltaColumns` instead of comparing two value nodes\n *\n * @param container Parent container that owns the row.\n * @param row Key-value row whose trailing comment may need to move.\n * @param deltaColumns Horizontal width delta introduced by the insertion.\n */\nexport function preserveAlignedInlineCommentForDelta(\n container: TreeNode,\n row: KeyValue,\n deltaColumns: number\n) {\n if (!hasItems(container)) return;\n\n const items = container.items as TreeNode[];\n const rowIndex = items.indexOf(row);\n if (rowIndex < 0) return;\n\n const comment = getAttachedInlineComment(items, rowIndex);\n if (!comment) return;\n\n const currentColumn = comment.loc.start.column;\n const currentLine = comment.loc.start.line;\n const neighborIndexes = [\n getNeighborRowIndex(items, rowIndex, -1),\n getNeighborRowIndex(items, rowIndex, 1)\n ];\n\n for (const neighborIndex of neighborIndexes) {\n if (neighborIndex == null) continue;\n\n const neighborComment = getAttachedInlineComment(items, neighborIndex);\n if (!neighborComment) continue;\n if (Math.abs(neighborComment.loc.start.line - currentLine) !== 1) continue;\n if (neighborComment.loc.start.column !== currentColumn) continue;\n\n applyInlineCommentColumnAdjustment(comment, neighborComment.loc.start.column, deltaColumns);\n return;\n }\n}\n\n/**\n * Records baseline comment alignment metadata for a row whose value is a\n * single-line inline table and whose internal contents are being edited.\n *\n * This captures the comment's current column and reserved gap (comment start\n * minus row end) so the final normalization pass can preserve spacing\n * expectations after nested inline-table edits.\n *\n * @param container Parent container that owns the row.\n * @param row Key-value row whose trailing comment alignment metadata is refreshed.\n * @param deltaColumns Horizontal width delta introduced by the nested edit; used\n * only as a fast no-op guard when zero.\n */\nexport function recordInlineTableCommentDelta(container: TreeNode, row: KeyValue, deltaColumns: number) {\n if (!hasItems(container) || deltaColumns === 0) return;\n\n const items = container.items as TreeNode[];\n const rowIndex = items.indexOf(row);\n if (rowIndex < 0) return;\n\n const comment = getAttachedInlineComment(items, rowIndex);\n if (!comment) return;\n\n rememberReservedCommentSpacing(row, comment);\n}\n\n/**\n * Estimates the horizontal column delta caused by inserting a new inline item.\n *\n * The result includes the inserted value width and the comma/spacing overhead\n * needed by the surrounding inline array or inline table formatting.\n *\n * @param parent Inline container receiving the new child.\n * @param child CST node being inserted.\n * @param index Target insertion index.\n * @returns The number of columns added to the rendered row.\n */\nexport function getInlineInsertColumnDelta(parent: Value, child: TreeNode, index: number): number {\n if (!isInlineArray(parent) && !isInlineTable(parent)) return 0;\n\n const childSpan = getSpan(child.loc);\n const hasSeparatingCommaBefore = index > 0;\n const hasSeparatingCommaAfter = index < parent.items.length;\n const isLastElement = index === parent.items.length;\n const hasTrailingComma = isInlineItem(child) ? child.comma : false;\n const hasTrailingCommaSpacingBug =\n hasSeparatingCommaBefore && hasTrailingComma && !hasSeparatingCommaAfter && isLastElement;\n\n return (\n childSpan.columns +\n (hasSeparatingCommaBefore || hasSeparatingCommaAfter ? 2 : 0) +\n (hasTrailingComma ? 1 + (hasTrailingCommaSpacingBug ? -1 : 0) : 0)\n );\n}\n\n/**\n * Recursively collects comment nodes from the document and nested tables.\n *\n * @param node Document or table-like node to traverse.\n * @param comments Accumulator used during recursion.\n * @returns All discovered comment nodes.\n */\nfunction collectComments(node: Document | Table | TableArray, comments: Comment[] = []): Comment[] {\n for (const item of node.items) {\n if (isComment(item)) {\n comments.push(item);\n continue;\n }\n\n if (isTable(item) || isTableArray(item)) {\n collectComments(item, comments);\n }\n }\n\n return comments;\n}\n\n/**\n * Collects the line numbers of single-line key-value rows whose value is a\n * single-line inline table.\n *\n * @param node Document or table-like node to traverse.\n * @param lines Accumulator used during recursion.\n * @returns A set of row end lines for inline-table rows.\n */\nfunction collectSingleLineInlineTableCommentLines(\n node: Document | Table | TableArray,\n lines: Set<number> = new Set()\n): Set<number> {\n for (const item of node.items) {\n if (isKeyValue(item) && isInlineTable(item.value) && item.loc.start.line === item.loc.end.line) {\n lines.add(item.loc.end.line);\n continue;\n }\n\n if (isTable(item) || isTableArray(item)) {\n collectSingleLineInlineTableCommentLines(item, lines);\n }\n }\n\n return lines;\n}\n\n/**\n * Recomputes `loc.end` for the document/table container chain from children.\n *\n * Inline comment normalization can move trailing comments horizontally; this\n * keeps parent containers' end positions consistent with their updated children.\n *\n * @param node Document or table-like container to normalize.\n */\nfunction recomputeContainerEnds(node: Document | Table | TableArray) {\n for (const item of node.items) {\n if (isTable(item) || isTableArray(item)) {\n recomputeContainerEnds(item);\n }\n }\n\n let maxLine = node.loc.end.line;\n let maxColumn = node.loc.end.column;\n\n const updateMax = (line: number, column: number) => {\n if (line > maxLine || (line === maxLine && column > maxColumn)) {\n maxLine = line;\n maxColumn = column;\n }\n };\n\n if (isTable(node) || isTableArray(node)) {\n updateMax(node.key.loc.end.line, node.key.loc.end.column);\n }\n\n for (const item of node.items) {\n updateMax(item.loc.end.line, item.loc.end.column);\n }\n\n node.loc.end.line = maxLine;\n node.loc.end.column = maxColumn;\n}\n\n/**\n * Normalizes padded inline comment groups in the final rendered TOML string.\n *\n * This pass is intentionally limited to comments that already have explicit\n * padding before `#`, which avoids disturbing compact TOML 1.1 inline-table\n * comment styles while still restoring vertical alignment for normal row-based\n * comment blocks.\n *\n * For groups touched by nested inline-table edits, the target column is derived\n * from the widest current row plus the group's original minimum reserved gap.\n *\n * @param document Patched CST document whose comment locations are updated in-place.\n * @param tomlString Rendered TOML output to normalize.\n * @param format Active TOML formatting settings.\n * @returns The normalized TOML string.\n */\nexport function normalizeInlineCommentAlignmentInString(\n document: Document,\n tomlString: string,\n format: TomlFormat\n): string {\n const newLine = format.newLine;\n const trailingMatch = tomlString.match(/(?:\\r\\n|\\n)+$/u);\n const trailing = trailingMatch ? trailingMatch[0] : '';\n const body = trailing ? tomlString.slice(0, -trailing.length) : tomlString;\n const lines = body.length ? body.split(newLine) : [];\n const inlineTableCommentLines = collectSingleLineInlineTableCommentLines(document);\n\n const resolveCommentColumn = (line: string, comment: Comment): number => {\n const fromLine = line.lastIndexOf(comment.raw);\n return fromLine >= 0 ? fromLine : comment.loc.start.column;\n };\n\n const comments = collectComments(document)\n .filter(comment => {\n const line = lines[comment.loc.start.line - 1] || '';\n const commentColumn = resolveCommentColumn(line, comment);\n const beforeComment = line.slice(0, commentColumn);\n return beforeComment.trim().length > 0 && /\\s{2,}$/u.test(beforeComment);\n })\n .sort((a, b) => a.loc.start.line - b.loc.start.line);\n\n const groups: Comment[][] = [];\n let currentGroup: Comment[] = [];\n for (const comment of comments) {\n const previous = currentGroup[currentGroup.length - 1];\n if (!previous || comment.loc.start.line === previous.loc.start.line + 1) {\n currentGroup.push(comment);\n } else {\n if (currentGroup.length > 0) {\n groups.push(currentGroup);\n }\n currentGroup = [comment];\n }\n }\n if (currentGroup.length > 0) {\n groups.push(currentGroup);\n }\n\n for (const group of groups) {\n if (group.length < 2) continue;\n\n let targetColumn = original_comment_column.get(group[0]) ?? group[0].loc.start.column;\n const counts = new Map<number, number>();\n for (const comment of group) {\n const baselineColumn = original_comment_column.get(comment) ?? comment.loc.start.column;\n counts.set(baselineColumn, (counts.get(baselineColumn) || 0) + 1);\n }\n\n let highestCount = 1;\n for (const [column, count] of counts) {\n if (count > highestCount) {\n highestCount = count;\n targetColumn = column;\n }\n }\n\n const widestCodeColumn = Math.max(\n ...group.map(comment => {\n const line = lines[comment.loc.start.line - 1] || '';\n const commentColumn = resolveCommentColumn(line, comment);\n const code = line.slice(0, commentColumn).trimEnd();\n return code.length;\n })\n );\n\n const currentGroupMinimumGap = Math.min(\n ...group.map(comment => {\n const line = lines[comment.loc.start.line - 1] || '';\n const commentColumn = resolveCommentColumn(line, comment);\n const code = line.slice(0, commentColumn).trimEnd();\n return Math.max(1, commentColumn - code.length);\n })\n );\n\n let groupMinimumGap = currentGroupMinimumGap;\n const reservedComments = group.filter(comment => reserved_comment_spacing.has(comment));\n const hasNonInlineTableRows = group.some(comment => !inlineTableCommentLines.has(comment.loc.start.line));\n if (reservedComments.length > 0 && hasNonInlineTableRows) {\n const reservedMinimumGap = Math.min(\n ...group.map(comment => {\n if (reserved_comment_spacing.has(comment)) {\n return reserved_comment_spacing.get(comment) || 1;\n }\n\n const line = lines[comment.loc.start.line - 1] || '';\n const commentColumn = resolveCommentColumn(line, comment);\n const code = line.slice(0, commentColumn).trimEnd();\n return Math.max(1, commentColumn - code.length);\n })\n );\n groupMinimumGap = Math.min(groupMinimumGap, reservedMinimumGap);\n }\n\n if (targetColumn < widestCodeColumn + 1) {\n const requiredColumn = widestCodeColumn + groupMinimumGap;\n targetColumn = Math.max(targetColumn, requiredColumn);\n }\n\n for (const comment of group) {\n const lineIndex = comment.loc.start.line - 1;\n const line = lines[lineIndex] || '';\n const commentColumn = resolveCommentColumn(line, comment);\n const code = line.slice(0, commentColumn).trimEnd();\n const actualTargetColumn = Math.max(targetColumn, code.length + 1);\n if (commentColumn !== actualTargetColumn) {\n const spaces = ' '.repeat(actualTargetColumn - code.length);\n lines[lineIndex] = code + spaces + comment.raw;\n }\n\n if (comment.loc.start.column !== actualTargetColumn) {\n comment.loc.start.column = actualTargetColumn;\n comment.loc.end.column = actualTargetColumn + com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