@decimalturn/toml-patch 3.3.1 → 3.3.2-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.
@@ -0,0 +1,18 @@
1
+
2
+ //#region src/patch-lite.d.ts
3
+ /**
4
+ * Applies in-place value edits to an existing TOML document.
5
+ *
6
+ * This is an edit-only distribution: every change must be an edit to an
7
+ * existing scalar value. Added or removed keys, array length changes, array
8
+ * reordering, key renames and scalar/container type changes all throw before
9
+ * the source is mutated. All text outside the edited value spans is preserved
10
+ * byte for byte.
11
+ *
12
+ * @param existing - The original TOML document as a string
13
+ * @param updated - The updated JavaScript object with desired value changes
14
+ * @returns A new TOML string with only the edited values replaced
15
+ */
16
+ declare function patchLite(existing: string, updated: any): string;
17
+ //#endregion
18
+ export { patchLite as patch };
package/dist/patch.js ADDED
@@ -0,0 +1,20 @@
1
+ //! @decimalturn/toml-patch v3.3.2 - 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,122 +1,30 @@
1
1
  {
2
2
  "name": "@decimalturn/toml-patch",
3
- "version": "3.3.1",
4
- "contributors": [
5
- "Tim Hall <tim.hall.engr@gmail.com>",
6
- "Martin Leduc <31558169+DecimalTurn@users.noreply.github.com>"
7
- ],
8
- "license": "MIT",
9
- "description": "Patch, parse, and stringify TOML while preserving comments, whitespace and formatting.",
3
+ "version": "3.3.2-lite",
4
+ "description": "Patch, parse, and stringify TOML while preserving comments, whitespace and formatting. Lite value-editing distribution.",
10
5
  "homepage": "https://github.com/DecimalTurn/toml-patch",
11
6
  "repository": {
12
7
  "type": "git",
13
8
  "url": "git+https://github.com/DecimalTurn/toml-patch.git"
14
9
  },
15
- "publishConfig": {
16
- "access": "public"
17
- },
18
- "keywords": [
19
- "toml",
20
- "patch",
21
- "edit",
22
- "parse",
23
- "stringify",
24
- "parser",
25
- "encoder",
26
- "decoder",
27
- "preserve-whitespace",
28
- "preserve-comments",
29
- "preserve-formatting",
30
- "edit-in-place"
31
- ],
10
+ "license": "MIT",
11
+ "type": "module",
32
12
  "engines": {
33
13
  "node": ">=16"
34
14
  },
35
- "type": "module",
36
15
  "sideEffects": false,
37
- "types": "./dist/toml-patch.d.ts",
38
- "exports": {
39
- ".": {
40
- "types": "./dist/toml-patch.d.ts",
41
- "import": "./dist/toml-patch.js",
42
- "default": "./dist/toml-patch.js"
43
- }
44
- },
45
- "devDependencies": {
46
- "@decimalturn/toml-patch": "npm:@decimalturn/toml-patch@3.3.0",
47
- "@js-temporal/polyfill": "^0.5.1",
48
- "@playwright/test": "^1.59.1",
49
- "@types/dedent": "^1.0.0",
50
- "@types/js-yaml": "^4.0.0",
51
- "@types/node": "^24.12.3",
52
- "benchmark": "^2",
53
- "dedent": "^1.5.3",
54
- "glob": "^13.0.0",
55
- "js-yaml": "4.3.2",
56
- "jsr": "^0.14.0",
57
- "mri": "^1",
58
- "npm-run-all2": "^9.0.0",
59
- "oxlint": "^1.55.0",
60
- "rimraf": "^6.0.0",
61
- "smol-toml": "^1.9.0",
62
- "tsdown": "^0.23.0",
63
- "tslib": "^2.0.0",
64
- "typescript": "7.0.2",
65
- "vitest": "^5.0.0"
66
- },
67
- "prettier": {
68
- "singleQuote": true,
69
- "printWidth": 100
70
- },
16
+ "types": "./dist/patch.d.ts",
71
17
  "files": [
72
- "dist/toml-patch.js",
73
- "dist/toml-patch.d.ts"
18
+ "dist/"
74
19
  ],
75
- "json-comments": {
76
- "tips": "Please install the JsonComments plugin to enable commenting functionality for JSON files, see: https://github.com/zhangfisher/json_comments_extension",
77
- "package.json": {
78
- "devDependencies.js-yaml": "Used by specs/specs.test.ts to parse YAML expected-value fixtures from submodules/spec-tests (https://github.com/iarna/toml-spec-tests).",
79
- "scripts.bench": "Parse and stringify benchmark over the curated fixtures. Fails the CI job when toml-patch exceeds the maxSlowdown budgets in benchmark/thresholds.toml. Set BENCH_BASELINE to a build path to add the branch comparison.",
80
- "scripts.bench:all": "Runs the same benchmark over every fixture in both corpora, including the single-type and scaling documents the curated set leaves out."
20
+ "exports": {
21
+ ".": {
22
+ "types": "./dist/patch.d.ts",
23
+ "import": "./dist/patch.js",
24
+ "default": "./dist/patch.js"
81
25
  }
82
26
  },
83
- "scripts": {
84
- "dev": "pnpm run typecheck && pnpm run build && npm-run-all2 --parallel test:all specs",
85
- "test": "vitest run",
86
- "test:output": "node scripts/test-debug.mjs",
87
- "test:js": "vitest run --config vitest.js.config.ts",
88
- "test:watch": "vitest",
89
- "test:go": "./run-toml-test.bash",
90
- "test:playwright": "playwright test",
91
- "playwright:install": "playwright install --with-deps chromium",
92
- "test:all": "pnpm run test && pnpm run test:js && pnpm run test:playwright",
93
- "typecheck": "tsc",
94
- "specs": "vitest run --config vitest.specs.config.ts",
95
- "bench": "node benchmark/fixture-benchmark.mjs",
96
- "bench:all": "node benchmark/fixture-benchmark.mjs --all",
97
- "benchmark": "npm-run-all2 bench:*",
98
- "benchmark:ci": "npm-run-all2 \"bench:* -- --sample --versions latest\"",
99
- "seed-toml": "npx -y tsx scripts/generate-seed-toml.ts",
100
- "fuzz": "npx -y tsx scripts/fuzz-run.ts --seed 0 --to 9999 --mutations 3 --progress 100",
101
- "fuzz2": "npx -y tsx scripts/fuzz-run2.ts --seed 0 --to 9999 --mutations 3",
102
- "fuzz3": "npx -y tsx scripts/fuzz-run3.ts --seed 0 --to 9999 --mutations 3",
103
- "fuzz4": "npx -y tsx scripts/fuzz-run4.ts --seed 0 --to 9999 --mutations 3",
104
- "bench:bundle-size": "node benchmark/bundle-size.mjs",
105
- "bench:parse": "node benchmark/parse-benchmark.mjs",
106
- "bench:stringify": "node benchmark/stringify-benchmark.mjs",
107
- "bench:patch": "node benchmark/patch-benchmark.mjs",
108
- "bench:patch-lite": "node benchmark/patch-lite-bundle-size.mjs",
109
- "profile": "node benchmark/profile.mjs",
110
- "build": "rimraf dist && tsdown",
111
- "build:demo": "node scripts/build-demo.mjs",
112
- "build:dev": "node scripts/prepare-dev-package.mjs",
113
- "build:lite": "node scripts/prepare-lite-package.mjs",
114
- "test:dev": "pnpm run build:dev && node scripts/test-dev-package.mjs",
115
- "test:lite": "pnpm run build:lite && node scripts/test-lite-package.mjs",
116
- "lint": "oxlint",
117
- "lint:fix": "oxlint --fix",
118
- "check-overrides": "node scripts/check-overrides.mjs",
119
- "compare-branch-size": "node scripts/compare-branch-size.mjs",
120
- "publish:jsr": "jsr publish --allow-dirty"
27
+ "publishConfig": {
28
+ "access": "public"
121
29
  }
122
- }
30
+ }
package/LICENSE DELETED
@@ -1,22 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2019–2025 Tim Hall
4
- Copyright (c) 2025 Martin Leduc
5
-
6
- Permission is hereby granted, free of charge, to any person obtaining a copy
7
- of this software and associated documentation files (the "Software"), to deal
8
- in the Software without restriction, including without limitation the rights
9
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- copies of the Software, and to permit persons to whom the Software is
11
- furnished to do so, subject to the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be included in all
14
- copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- SOFTWARE.
package/README.md DELETED
@@ -1,203 +0,0 @@
1
- <img src="assets/toml-patch-logo.png" alt="toml-patch logo" width="120"/>
2
-
3
- # toml-patch
4
-
5
- [![NPM Version](https://img.shields.io/npm/v/%40decimalturn%2Ftoml-patch?logo=npm&logoColor=white&labelColor=red&color=blue)](https://www.npmjs.com/package/@decimalturn/toml-patch)
6
- [![JSR Version](https://img.shields.io/jsr/v/%40decimalturn/toml-patch?logo=jsr&color=blue)](https://jsr.io/@decimalturn/toml-patch)
7
- [![GitHub branch status](https://img.shields.io/github/check-runs/DecimalTurn/toml-patch/latest)](https://github.com/DecimalTurn/toml-patch/actions/workflows/test-and-build.yml)
8
-
9
- Patch, parse, and stringify [TOML](https://toml.io/en/) (v1.1.0) while preserving comments, whitespace and formatting.
10
-
11
- This project started as a fork of the [original toml-patch](https://github.com/timhall/toml-patch) but has since evolved into a standalone project with significant improvements in reliability and features. We've added TOML v1.1 support, introduced new APIs like `TomlDocument` and `TomlFormat` classes, fixed numerous bugs through increase in testing namely with [toml-test](https://github.com/toml-lang/toml-test).
12
-
13
- We hope that these improvements can be incorporated upstream one day if the original author returns, but until then, this project is the actively maintained version.
14
-
15
- ## Documentation
16
-
17
- - [Installation](#installation)
18
- - [API](#api)
19
- - [Patch-lite](#patch-lite)
20
- - [Comment ownership](#comment-ownership)
21
- - [Date/time handling and Temporal](#datetime-handling--temporal)
22
- - [Formatting](#formatting)
23
- - [Changelog](https://github.com/DecimalTurn/toml-patch/blob/v3.3.1/CHANGELOG.md)
24
- - [Contributing](https://github.com/DecimalTurn/toml-patch/blob/v3.3.1/CONTRIBUTING.md)
25
- - [MIT License](https://github.com/DecimalTurn/toml-patch/blob/v3.3.1/LICENSE)
26
-
27
- ## Installation
28
-
29
- toml-patch is dependency-free and can be installed via your favorite package manager.
30
-
31
- *Example with NPM*
32
-
33
- ```
34
- $ npm install --save @decimalturn/toml-patch
35
- ```
36
-
37
- For the standalone lite distribution, install the `lite` npm dist-tag:
38
-
39
- ```sh
40
- $ npm install --save @decimalturn/toml-patch@lite
41
- ```
42
-
43
- For browser usage, you can use unpkg:
44
-
45
- ```html
46
- <script type="module">
47
- import * as TOML from 'https://unpkg.com/@decimalturn/toml-patch@v3.3.1/dist/toml-patch.js';
48
- </script>
49
- ```
50
-
51
- ## API
52
-
53
- overwrite(tomlString: string): void
54
- toml-patch provides a functional API for one-time operations and a document-oriented API for workflows that need multiple operations on the same TOML document.
55
-
56
- See the [API reference](https://github.com/DecimalTurn/toml-patch/blob/v3.3.1/docs/API.md) for `patch`, `parse`, `stringify` and the `TomlDocument` class.
57
-
58
- For a quick start, patch an existing TOML string like this:
59
-
60
- ```js
61
- import { patch } from '@decimalturn/toml-patch';
62
-
63
- const existing = 'title = "TOML example"\nowner.name = "Bob"\n';
64
- const updated = patch(existing, {
65
- title: 'TOML example',
66
- owner: { name: 'Tim' }
67
- });
68
- ```
69
-
70
- ## Patch-lite
71
-
72
- `patch-lite` is a smaller, edit-only distribution for applications that only need to update existing TOML values, such as bumping a package version. It exposes the same `patch` name with a two-argument `(existing, updated)` signature.
73
-
74
- It is not part of the main package: the main package ships the full API only. Install the lite build from the `lite` npm dist-tag, then import it with the same specifier:
75
-
76
- ```sh
77
- npm install --save @decimalturn/toml-patch@lite
78
- ```
79
-
80
- ```js
81
- import { patch } from '@decimalturn/toml-patch';
82
-
83
- const existing = 'version = "1.0.0"\n';
84
- const updated = patch(existing, { version: '1.0.1' });
85
- // updated === 'version = "1.0.1"\n'
86
- ```
87
-
88
- The dist-tag tarball maps its root export to the lite build, so there is no `patch-lite` subpath: `import { patch } from '@decimalturn/toml-patch/patch-lite'` fails with `ERR_PACKAGE_PATH_NOT_EXPORTED`. Switching between the two is an install change, never a code change.
89
-
90
- The lite function edits existing primitive values only and preserves all source text outside the edited value, including comments, whitespace, line endings and a leading BOM. Added or removed keys, array length changes, reordering, renames, primitive/container type changes and unsupported value types throw before any output is produced. Date/time values may be given as the custom `Date` subclasses or as `Temporal` objects; both are serialized into the existing row's shape. Use the full `patch()` for additions, removals, moves, renames and advanced formatting.
91
-
92
- Unlike the full `patch()`, the lite distribution performs no encoding validation on its output: it does not reject strings containing unpaired UTF-16 surrogates, which cannot be represented as valid TOML/UTF-8. Use the full `patch()` when this validation is required.
93
-
94
- The [Patch-lite guide](https://github.com/DecimalTurn/toml-patch/blob/v3.3.1/docs/Patch-Lite.md) lists every supported and rejected operation with its error code, the value-encoding rules that differ from the full `patch()`, and the measured size and throughput, so you can check whether the lite distribution covers your use case.
95
-
96
- ## Comment Ownership
97
-
98
- When `patch()` removes or reorders an entry, any comment describing it (a same-line trailing
99
- comment, or a line-comment directly above with no blank line in between) travels along with
100
- it, instead of being left behind to describe whatever ends up in that spot. This applies to root
101
- keys, `[table]`/`[[array-of-tables]]` blocks, and elements inside multi-line arrays and inline
102
- tables.
103
-
104
- ```js
105
- import * as TOML from '@decimalturn/toml-patch';
106
- import { strict as assert } from 'assert';
107
-
108
- const existing = `
109
- x = 1 # a note about x
110
- y = 2
111
- `;
112
-
113
- const patched = TOML.patch(existing, { y: 2 });
114
-
115
- assert.strictEqual(patched, `
116
- y = 2
117
- `);
118
- ```
119
-
120
- See the [comment ownership guide](https://github.com/DecimalTurn/toml-patch/blob/v3.3.1/docs/Comment-Ownership.md) for the full behavior, including how a blank line opts a comment out of ownership and current scope limitations.
121
-
122
- Note that `patch()` does not reorder entries by default.
123
- To have it match the key order of the object you pass in, enable `updateOrder` in the [formatting options](https://github.com/DecimalTurn/toml-patch/blob/v3.3.1/docs/Formatting.md#updateorder).
124
-
125
- ## Date/Time Handling & Temporal
126
-
127
- TOML date/time values are parsed into custom `Date` subclasses (`LocalDate`, `LocalTime`, `LocalDateTime`, `OffsetDateTime`) by default. Set `temporal: true` to receive [Temporal](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Temporal) objects instead. `stringify()` and `patch()` auto-detect Temporal objects and serialize them correctly. Fractional seconds keep the source precision, sub-millisecond digits included.
128
-
129
- ### Enabling Temporal
130
-
131
- The `temporal: true` option requires `Temporal` to be available in the runtime:
132
-
133
- | Runtime | How to enable |
134
- |---|---|
135
- | **Node.js 26+** | Built-in (no config needed) |
136
- | **Node.js 20–24** | `node --harmony-temporal` flag |
137
- | **Node.js 14–26** | [@js-temporal/polyfill](https://www.npmjs.com/package/@js-temporal/polyfill) |
138
-
139
- ```js
140
- import * as TOML from '@decimalturn/toml-patch';
141
-
142
- // Node 26+ (native) or Node 20–24 with --harmony-temporal:
143
- const obj = TOML.parse('d = 2024-01-15\n', { temporal: true });
144
- // obj.d → Temporal.PlainDate
145
-
146
- // All Node versions with the polyfill:
147
- import { Temporal } from '@js-temporal/polyfill';
148
- globalThis.Temporal = Temporal;
149
- const obj2 = TOML.parse('d = 2024-01-15\n', { temporal: true });
150
- // obj2.d → PlainDate (polyfill)
151
- ```
152
-
153
- > **Note:** Only offset-based timezones (`+05:30`, `Z`) are supported in TOML. IANA timezone annotations (e.g., `[Asia/Kolkata]`) will throw an error.
154
-
155
- See the [date/time guide](https://github.com/DecimalTurn/toml-patch/blob/v3.3.1/docs/Dates.md) for details and examples.
156
-
157
- ## Formatting
158
-
159
- The `TomlFormat` class controls how TOML documents are formatted during stringification and patching operations.
160
-
161
- ```typescript
162
- class TomlFormat {
163
- newLine: string
164
- trailingNewline: number
165
- trailingComma: boolean
166
- bracketSpacing: boolean
167
- inlineTableStart?: number
168
- truncateZeroTimeInDates: boolean
169
- useTabsForIndentation?: boolean
170
- indentWidth: number
171
- minimumDecimals?: number
172
- minimumTimeDecimals?: number
173
- leadingBom: boolean
174
- updateOrder?: boolean
175
- multilineTable: boolean | number | 'auto' | 'parent'
176
- multilineArray: boolean | number | 'auto' | 'parent'
177
-
178
- static default(): TomlFormat
179
- static autoDetectFormat(tomlString: string): TomlFormat
180
- }
181
- ```
182
-
183
- Start with `TomlFormat.default()` and override the options you need. e.g.:
184
-
185
- ```js
186
- import { stringify, TomlFormat } from '@decimalturn/toml-patch';
187
-
188
- const format = TomlFormat.default();
189
- format.newLine = '\r\n';
190
- format.trailingNewline = 0;
191
- format.trailingComma = true;
192
- format.bracketSpacing = false;
193
- format.indentWidth = 4;
194
- format.multilineTable = 'parent';
195
-
196
- const toml = stringify({
197
- title: 'My App',
198
- tags: ['dev', 'config'],
199
- database: { host: 'localhost', port: 5432 }
200
- }, format);
201
-
202
- ```
203
- See the [formatting reference](https://github.com/DecimalTurn/toml-patch/blob/v3.3.1/docs/Formatting.md) for the complete list of options, auto-detection behavior, `updateOrder` and more examples.