@decimalturn/toml-patch 3.3.0-lite → 3.3.1-dev

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/dist/dev/comment-alignment.js +372 -0
  2. package/dist/dev/comment-alignment.js.map +1 -0
  3. package/dist/dev/comment-ownership.js +660 -0
  4. package/dist/dev/comment-ownership.js.map +1 -0
  5. package/dist/dev/cst-source.js +118 -0
  6. package/dist/dev/cst-source.js.map +1 -0
  7. package/dist/dev/cst.js +68 -0
  8. package/dist/dev/cst.js.map +1 -0
  9. package/dist/dev/cursor.js +66 -0
  10. package/dist/dev/cursor.js.map +1 -0
  11. package/dist/dev/date-format.js +287 -0
  12. package/dist/dev/date-format.js.map +1 -0
  13. package/dist/dev/decode-utf8.js +27 -0
  14. package/dist/dev/decode-utf8.js.map +1 -0
  15. package/dist/dev/diff-lite.js +108 -0
  16. package/dist/dev/diff-lite.js.map +1 -0
  17. package/dist/dev/diff.js +265 -0
  18. package/dist/dev/diff.js.map +1 -0
  19. package/dist/dev/encode-lite.js +210 -0
  20. package/dist/dev/encode-lite.js.map +1 -0
  21. package/dist/dev/escape-preference.js +166 -0
  22. package/dist/dev/escape-preference.js.map +1 -0
  23. package/dist/dev/find-by-path.js +111 -0
  24. package/dist/dev/find-by-path.js.map +1 -0
  25. package/dist/dev/formatter.js +298 -0
  26. package/dist/dev/formatter.js.map +1 -0
  27. package/dist/dev/generate.js +466 -0
  28. package/dist/dev/generate.js.map +1 -0
  29. package/dist/dev/inline-comma-space.js +13 -0
  30. package/dist/dev/inline-comma-space.js.map +1 -0
  31. package/dist/dev/inline-format.js +106 -0
  32. package/dist/dev/inline-format.js.map +1 -0
  33. package/dist/dev/inline-layout.js +107 -0
  34. package/dist/dev/inline-layout.js.map +1 -0
  35. package/dist/dev/line-ending-backslash.js +320 -0
  36. package/dist/dev/line-ending-backslash.js.map +1 -0
  37. package/dist/dev/literal-string.js +46 -0
  38. package/dist/dev/literal-string.js.map +1 -0
  39. package/dist/dev/location.js +104 -0
  40. package/dist/dev/location.js.map +1 -0
  41. package/dist/dev/parse-error.js +27 -0
  42. package/dist/dev/parse-error.js.map +1 -0
  43. package/dist/dev/parse-js.js +150 -0
  44. package/dist/dev/parse-js.js.map +1 -0
  45. package/dist/dev/parse-string.js +120 -0
  46. package/dist/dev/parse-string.js.map +1 -0
  47. package/dist/dev/parse-toml.js +714 -0
  48. package/dist/dev/parse-toml.js.map +1 -0
  49. package/dist/dev/patch-lite.js +4 -0
  50. package/dist/dev/patch-lite2.js +97 -0
  51. package/dist/dev/patch-lite2.js.map +1 -0
  52. package/dist/dev/patch.js +2659 -0
  53. package/dist/dev/patch.js.map +1 -0
  54. package/dist/dev/smol-toml-date.js +61 -0
  55. package/dist/dev/smol-toml-date.js.map +1 -0
  56. package/dist/dev/to-js.js +303 -0
  57. package/dist/dev/to-js.js.map +1 -0
  58. package/dist/dev/to-toml.js +874 -0
  59. package/dist/dev/to-toml.js.map +1 -0
  60. package/dist/dev/tokenizer.js +225 -0
  61. package/dist/dev/tokenizer.js.map +1 -0
  62. package/dist/dev/toml-document.js +220 -0
  63. package/dist/dev/toml-document.js.map +1 -0
  64. package/dist/dev/toml-format.js +549 -0
  65. package/dist/dev/toml-format.js.map +1 -0
  66. package/dist/dev/toml-patch.js +94 -0
  67. package/dist/dev/toml-patch.js.map +1 -0
  68. package/dist/dev/traverse.js +61 -0
  69. package/dist/dev/traverse.js.map +1 -0
  70. package/dist/dev/truncate.js +64 -0
  71. package/dist/dev/truncate.js.map +1 -0
  72. package/dist/dev/update-order.js +235 -0
  73. package/dist/dev/update-order.js.map +1 -0
  74. package/dist/dev/utils.js +302 -0
  75. package/dist/dev/utils.js.map +1 -0
  76. package/dist/dev/writer.js +758 -0
  77. package/dist/dev/writer.js.map +1 -0
  78. package/dist/toml-patch.d.ts +564 -0
  79. package/package.json +11 -6
  80. package/dist/patch.js +0 -20
  81. /package/dist/{patch.d.ts → patch-lite.d.ts} +0 -0
@@ -0,0 +1,287 @@
1
+ //! @decimalturn/toml-patch v3.3.1 - https://github.com/DecimalTurn/toml-patch - @license: MIT
2
+ //#region src/date-format.ts
3
+ /**
4
+ * Central module for TOML date/time format handling and custom date classes.
5
+ * This module provides all the patterns, classes, and utilities needed to work
6
+ * with the different date/time formats supported by the TOML specification.
7
+ */
8
+ /** Extract UTC date/time parts as zero-padded strings. */
9
+ function fmtParts(d) {
10
+ return {
11
+ year: String(d.getUTCFullYear()).padStart(4, "0"),
12
+ month: String(d.getUTCMonth() + 1).padStart(2, "0"),
13
+ day: String(d.getUTCDate()).padStart(2, "0"),
14
+ hours: String(d.getUTCHours()).padStart(2, "0"),
15
+ minutes: String(d.getUTCMinutes()).padStart(2, "0"),
16
+ seconds: String(d.getUTCSeconds()).padStart(2, "0"),
17
+ ms: d.getUTCMilliseconds()
18
+ };
19
+ }
20
+ /**
21
+ * The fractional digits needed to write a millisecond count exactly, or "" for
22
+ * a value on the whole second. `750` needs two digits and `500` needs one.
23
+ */
24
+ function valueFractionDigits(ms) {
25
+ if (ms === 0) return "";
26
+ return String(ms).padStart(3, "0").replace(/0+$/, "");
27
+ }
28
+ /** The fraction that ends the raw text, as in `07:32:00.123456`. */
29
+ const TRAILING_FRACTION = /\.(\d+)\s*$/;
30
+ /** The fraction that precedes a timezone offset, as in `07:32:00.123456Z`. */
31
+ const OFFSET_FRACTION = /\.(\d+)(?:[Zz]|[+-]\d{2}:\d{2})\s*$/;
32
+ /** The fraction the source wrote, or "" when its pattern does not match. */
33
+ function sourceFraction(originalRaw, msRe) {
34
+ var _originalRaw$match;
35
+ return ((_originalRaw$match = originalRaw.match(msRe)) === null || _originalRaw$match === void 0 ? void 0 : _originalRaw$match[1]) ?? "";
36
+ }
37
+ /**
38
+ * Formats `digits` at the width the source declared.
39
+ *
40
+ * A source that wrote zeros past its own significant digits declared padding,
41
+ * and that width is kept: `.500` stays three digits and `.500000` stays six. A
42
+ * source whose extra digits were significant declared a precision the new value
43
+ * does not have, so only the digits the value needs are written: `.123456`
44
+ * edited to 750 ms becomes `.75`. This is the rule numbers already follow,
45
+ * where `1.00` keeps its decimals and `1.50` collapses to what the value needs.
46
+ */
47
+ function formatFraction(digits, originalRaw, msRe) {
48
+ const source = sourceFraction(originalRaw, msRe);
49
+ const width = source.length > source.replace(/0+$/, "").length ? Math.max(source.length, digits.length) : digits.length;
50
+ return width === 0 ? "" : "." + digits.padEnd(width, "0");
51
+ }
52
+ /**
53
+ * The fractional-second digits a value spells out, or "" when it has none.
54
+ * The custom classes render their own fraction, so this is the caller's
55
+ * spelling for them and the millisecond part for a plain `Date`.
56
+ */
57
+ function renderedFraction(value) {
58
+ const match = value.toISOString().match(/\.(\d+)/);
59
+ return match ? match[1] : "";
60
+ }
61
+ /**
62
+ * The fraction to write for `value` when the source wrote `originalRaw`.
63
+ *
64
+ * A `Date` holds milliseconds, so `.123999` and `.123456` are both 123 ms to
65
+ * `getTime()`, but a value that spells out digits beyond the millisecond part
66
+ * names a different instant and writes the digits it spells. Everything else
67
+ * keeps the document's spelling.
68
+ */
69
+ function fractionSuffix(value, ms, originalRaw, msRe = TRAILING_FRACTION) {
70
+ const spelled = renderedFraction(value).replace(/0+$/, "");
71
+ if (spelled.length > valueFractionDigits(ms).length) return formatFraction(spelled, originalRaw, msRe);
72
+ return fmtMs(ms, originalRaw, msRe);
73
+ }
74
+ /**
75
+ * Format the fractional-second suffix, preserving the original precision.
76
+ *
77
+ * TOML allows any number of fractional digits, but a `Date` only holds
78
+ * milliseconds. When the value's millisecond part still matches the leading
79
+ * digits of the source fraction, the whole source fraction is emitted, so
80
+ * sub-millisecond digits survive a parse → stringify round trip.
81
+ *
82
+ * Otherwise the digits the value needs are written, widened to the source's
83
+ * width when the source declared zeros there: `.5` and 750 ms become `.75`,
84
+ * because slicing to one digit would write `.7` and silently change the value
85
+ * to 700 ms, while `.500` stays three digits as `.750` and `.123456` drops to
86
+ * the `.75` the value needs. `TomlFormat.minimumTimeDecimals` raises the count
87
+ * when a document wants a wider fraction.
88
+ *
89
+ * Returns "" when the source had no fraction and the value has none either.
90
+ */
91
+ function fmtMs(ms, origFmt, msRe = TRAILING_FRACTION) {
92
+ const digits = valueFractionDigits(ms);
93
+ if (origFmt && origFmt.includes(".")) {
94
+ const match = origFmt.match(msRe);
95
+ if (match && match[1].startsWith(String(ms).padStart(3, "0"))) return "." + match[1];
96
+ return formatFraction(digits, origFmt, msRe);
97
+ }
98
+ return digits ? "." + digits : "";
99
+ }
100
+ /** Parse a timezone offset string like "+09:00" or "Z" into minutes. */
101
+ function parseOffsetMinutes(offset) {
102
+ if (offset === "Z") return 0;
103
+ const sign = offset[0] === "+" ? 1 : -1;
104
+ const [h, m] = offset.slice(1).split(":");
105
+ return sign * (parseInt(h) * 60 + parseInt(m));
106
+ }
107
+ /**
108
+ * Pads the fractional seconds of a rendered TOML date/time so at least
109
+ * `minimumTimeDecimals` digits are written.
110
+ *
111
+ * This is the `TomlFormat.minimumTimeDecimals` floor. It is separate from
112
+ * `minimumDecimals`, which applies to numbers. Padding only: digits already
113
+ * written are kept, so the represented value never changes. A date-only value
114
+ * carries no time and is returned unchanged, and a non-positive count is a
115
+ * no-op.
116
+ *
117
+ * TOML 1.1 allows the seconds to be omitted, so a value written as `HH:MM`
118
+ * gains `:00` before its fraction.
119
+ */
120
+ function padFractionalSeconds(raw, minimumTimeDecimals) {
121
+ if (minimumTimeDecimals <= 0) return raw;
122
+ return raw.replace(/(\d{2}:\d{2})(?::(\d{2}))?(?:\.(\d+))?/, (whole, hourMinute, seconds, fraction) => {
123
+ const written = fraction ?? "";
124
+ if (written.length >= minimumTimeDecimals) return whole;
125
+ return `${hourMinute}:${seconds ?? "00"}.${written.padEnd(minimumTimeDecimals, "0")}`;
126
+ });
127
+ }
128
+ /**
129
+ * Helper class containing all date format patterns and utilities for TOML date/time handling
130
+ */
131
+ var DateFormatHelper = class DateFormatHelper {
132
+ static IS_DATE_ONLY = /^\d{4}-\d{2}-\d{2}$/;
133
+ static IS_TIME_ONLY = /^\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?$/;
134
+ static IS_LOCAL_DATETIME_T = /^\d{4}-\d{2}-\d{2}[Tt]\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?$/;
135
+ static IS_LOCAL_DATETIME_SPACE = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}(?::\d{2})?(?:\.\d+)?$/;
136
+ static IS_OFFSET_DATETIME_T = /^\d{4}-\d{2}-\d{2}[Tt]\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?(?:[Zz]|[+-]\d{2}:\d{2})$/;
137
+ static IS_OFFSET_DATETIME_SPACE = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}(?::\d{2})?(?:\.\d+)?(?:[Zz]|[+-]\d{2}:\d{2})$/;
138
+ static IS_FULL_DATE = /(\d{4})-(\d+)-(\d+)/;
139
+ static IS_FULL_TIME = /(\d+):(\d+)(?::(\d+))?/;
140
+ /**
141
+ * Creates a custom date/time object that preserves the original TOML date/time format.
142
+ *
143
+ * This method detects the TOML date/time format from the raw string and returns an appropriate
144
+ * custom date/time instance (e.g., LocalDate, LocalTime, LocalDateTime, OffsetDateTime) or a Date,
145
+ * using the provided new JavaScript Date value.
146
+ *
147
+ * @param {Date} newJSDate - The new JavaScript Date object representing the updated
148
+ * date/time value. This is used as the source for constructing the custom date/time object.
149
+ * In some cases, this may be a custom date/time object (e.g., LocalTime) instead of a native Date.
150
+ * @param {string} originalRaw - The original TOML date/time string as it appeared in the input.
151
+ * Used to detect the specific TOML date/time format and to extract formatting details (e.g., separator, offset).
152
+ *
153
+ * @returns {Date | LocalDate | LocalTime | LocalDateTime | OffsetDateTime}
154
+ * Returns a custom date/time object that matches the original TOML format:
155
+ * - LocalDate for date-only values (e.g., "2024-01-15")
156
+ * - LocalTime for time-only values (e.g., "10:30:00")
157
+ * - LocalDateTime for local datetimes (e.g., "2024-01-15T10:30:00" or "2024-01-15 10:30:00")
158
+ * - OffsetDateTime for datetimes with offsets (e.g., "2024-01-15T10:30:00+02:00")
159
+ * - Date (native JS Date) as a fallback if the format is unrecognized
160
+ *
161
+ * Format-specific behavior:
162
+ * - Date-only: Returns a LocalDate constructed from the date part of newJSDate.
163
+ * - Time-only: Returns a LocalTime built from newJSDate's time part, with the original's fractional digits.
164
+ * - Local datetime: Returns a LocalDateTime, preserving the separator (T or space).
165
+ * - Offset datetime: Returns an OffsetDateTime, reconstructing the date/time with the original offset and separator.
166
+ * - Fallback: Returns newJSDate as-is.
167
+ */
168
+ static createDateWithOriginalFormat(newJSDate, originalRaw) {
169
+ if (DateFormatHelper.IS_DATE_ONLY.test(originalRaw)) {
170
+ if (newJSDate.getUTCHours() !== 0 || newJSDate.getUTCMinutes() !== 0 || newJSDate.getUTCSeconds() !== 0 || newJSDate.getUTCMilliseconds() !== 0) {
171
+ if (newJSDate instanceof OffsetDateTime) return newJSDate;
172
+ let isoString = newJSDate.toISOString().replace("Z", "");
173
+ isoString = isoString.replace(/\.000$/, "");
174
+ return new LocalDateTime(isoString, false);
175
+ }
176
+ const dateStr = newJSDate.toISOString().split("T")[0];
177
+ return new LocalDate(dateStr);
178
+ } else if (DateFormatHelper.IS_TIME_ONLY.test(originalRaw)) {
179
+ const p = fmtParts(newJSDate);
180
+ const msSuffix = fractionSuffix(newJSDate, p.ms, originalRaw);
181
+ const time = `${p.hours}:${p.minutes}:${p.seconds}${msSuffix}`;
182
+ return new LocalTime(time);
183
+ } else if (DateFormatHelper.IS_LOCAL_DATETIME_T.test(originalRaw)) {
184
+ const p = fmtParts(newJSDate);
185
+ const msSuffix = fractionSuffix(newJSDate, p.ms, originalRaw);
186
+ const dateTime = `${p.year}-${p.month}-${p.day}T${p.hours}:${p.minutes}:${p.seconds}${msSuffix}`;
187
+ return new LocalDateTime(dateTime, false, dateTime);
188
+ } else if (DateFormatHelper.IS_LOCAL_DATETIME_SPACE.test(originalRaw)) {
189
+ const p = fmtParts(newJSDate);
190
+ const msSuffix = fractionSuffix(newJSDate, p.ms, originalRaw);
191
+ const dateTime = `${p.year}-${p.month}-${p.day} ${p.hours}:${p.minutes}:${p.seconds}${msSuffix}`;
192
+ return new LocalDateTime(dateTime, true, dateTime);
193
+ } else if (DateFormatHelper.IS_OFFSET_DATETIME_T.test(originalRaw) || DateFormatHelper.IS_OFFSET_DATETIME_SPACE.test(originalRaw)) {
194
+ const offsetMatch = originalRaw.match(/([+-]\d{2}:\d{2}|[Zz])$/);
195
+ const originalOffset = offsetMatch ? offsetMatch[1] === "z" ? "Z" : offsetMatch[1] : "Z";
196
+ const useSpaceSeparator = DateFormatHelper.IS_OFFSET_DATETIME_SPACE.test(originalRaw);
197
+ const p = fmtParts(new Date(newJSDate.getTime() + parseOffsetMinutes(originalOffset) * 6e4));
198
+ const sep = useSpaceSeparator ? " " : "T";
199
+ const msSuffix = fractionSuffix(newJSDate, p.ms, originalRaw, OFFSET_FRACTION);
200
+ const newDateTimeString = `${p.year}-${p.month}-${p.day}${sep}${p.hours}:${p.minutes}:${p.seconds}${msSuffix}${originalOffset}`;
201
+ return new OffsetDateTime(newDateTimeString, useSpaceSeparator);
202
+ } else return newJSDate;
203
+ }
204
+ };
205
+ /**
206
+ * Custom Date class for local dates (date-only).
207
+ * Format: 1979-05-27
208
+ */
209
+ var LocalDate = class extends Date {
210
+ constructor(value) {
211
+ super(value);
212
+ }
213
+ toISOString() {
214
+ const p = fmtParts(this);
215
+ return `${p.year}-${p.month}-${p.day}`;
216
+ }
217
+ };
218
+ /**
219
+ * Custom Date class for local times (time-only)
220
+ * Format: 07:32:00 or 07:32:00.999
221
+ */
222
+ var LocalTime = class extends Date {
223
+ originalFormat;
224
+ constructor(value, originalFormat = value) {
225
+ let normalizedValue = value;
226
+ if (!/:\d{2}:\d{2}/.test(value)) normalizedValue = value + ":00";
227
+ super(`0000-01-01T${normalizedValue}Z`);
228
+ this.originalFormat = originalFormat;
229
+ }
230
+ toISOString() {
231
+ const p = fmtParts(this);
232
+ return `${p.hours}:${p.minutes}:${p.seconds}${fmtMs(p.ms, this.originalFormat)}`;
233
+ }
234
+ };
235
+ /**
236
+ * Custom Date class for local datetime (no timezone)
237
+ * Format: 1979-05-27T07:32:00 or 1979-05-27 07:32:00
238
+ */
239
+ var LocalDateTime = class extends Date {
240
+ useSpaceSeparator = false;
241
+ originalFormat;
242
+ constructor(value, useSpaceSeparator = false, originalFormat) {
243
+ let normalizedValue = value;
244
+ if (!/\d{2}:\d{2}:\d{2}/.test(value)) normalizedValue = value.replace(/(\d{2}:\d{2})([\s\-+TZ]|$)/, "$1:00$2");
245
+ super(normalizedValue.replace(" ", "T") + "Z");
246
+ this.useSpaceSeparator = useSpaceSeparator;
247
+ this.originalFormat = originalFormat || value;
248
+ }
249
+ toISOString() {
250
+ const p = fmtParts(this);
251
+ const sep = this.useSpaceSeparator ? " " : "T";
252
+ return `${p.year}-${p.month}-${p.day}${sep}${p.hours}:${p.minutes}:${p.seconds}${fmtMs(p.ms, this.originalFormat)}`;
253
+ }
254
+ };
255
+ /**
256
+ * Custom Date class for offset datetime that preserves space separator
257
+ * Format: 1979-05-27T07:32:00Z or 1979-05-27 07:32:00-07:00
258
+ */
259
+ var OffsetDateTime = class extends Date {
260
+ useSpaceSeparator = false;
261
+ originalOffset;
262
+ originalFormat;
263
+ constructor(value, useSpaceSeparator = false) {
264
+ let normalizedValue = value;
265
+ if (!/\d{2}:\d{2}:\d{2}/.test(value)) normalizedValue = value.replace(/(\d{2}:\d{2})([\s\-+TZ]|$)/, "$1:00$2");
266
+ super(normalizedValue.replace(" ", "T"));
267
+ this.useSpaceSeparator = useSpaceSeparator;
268
+ this.originalFormat = value;
269
+ const offsetMatch = value.match(/([+-]\d{2}:\d{2}|[Zz])$/);
270
+ if (offsetMatch) this.originalOffset = offsetMatch[1] === "z" ? "Z" : offsetMatch[1];
271
+ }
272
+ toISOString() {
273
+ if (this.originalOffset) {
274
+ const p = fmtParts(new Date(this.getTime() + parseOffsetMinutes(this.originalOffset) * 6e4));
275
+ const sep = this.useSpaceSeparator ? " " : "T";
276
+ const msSuffix = fmtMs(p.ms, this.originalFormat, OFFSET_FRACTION);
277
+ return `${p.year}-${p.month}-${p.day}${sep}${p.hours}:${p.minutes}:${p.seconds}${msSuffix}${this.originalOffset}`;
278
+ }
279
+ const isoString = super.toISOString();
280
+ if (this.useSpaceSeparator) return isoString.replace("T", " ");
281
+ return isoString;
282
+ }
283
+ };
284
+
285
+ //#endregion
286
+ export { DateFormatHelper, LocalDate, LocalDateTime, LocalTime, OffsetDateTime, padFractionalSeconds };
287
+ //# sourceMappingURL=date-format.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date-format.js","names":[],"sources":["../../src/date-format.ts"],"sourcesContent":["/**\n * Central module for TOML date/time format handling and custom date classes.\n * This module provides all the patterns, classes, and utilities needed to work\n * with the different date/time formats supported by the TOML specification.\n */\n\n// ---------------------------------------------------------------------------\n// Shared formatting helpers (extracted to reduce duplication)\n// ---------------------------------------------------------------------------\n\n/** Extract UTC date/time parts as zero-padded strings. */\nfunction fmtParts(d: Date) {\n return {\n year: String(d.getUTCFullYear()).padStart(4, '0'),\n month: String(d.getUTCMonth() + 1).padStart(2, '0'),\n day: String(d.getUTCDate()).padStart(2, '0'),\n hours: String(d.getUTCHours()).padStart(2, '0'),\n minutes: String(d.getUTCMinutes()).padStart(2, '0'),\n seconds: String(d.getUTCSeconds()).padStart(2, '0'),\n ms: d.getUTCMilliseconds(),\n };\n}\n\n/**\n * The fractional digits needed to write a millisecond count exactly, or \"\" for\n * a value on the whole second. `750` needs two digits and `500` needs one.\n */\nfunction valueFractionDigits(ms: number): string {\n if (ms === 0) return '';\n return String(ms).padStart(3, '0').replace(/0+$/, '');\n}\n\n/** The fraction that ends the raw text, as in `07:32:00.123456`. */\nconst TRAILING_FRACTION = /\\.(\\d+)\\s*$/;\n\n/** The fraction that precedes a timezone offset, as in `07:32:00.123456Z`. */\nconst OFFSET_FRACTION = /\\.(\\d+)(?:[Zz]|[+-]\\d{2}:\\d{2})\\s*$/;\n\n/** The fraction the source wrote, or \"\" when its pattern does not match. */\nfunction sourceFraction(originalRaw: string, msRe: RegExp): string {\n return originalRaw.match(msRe)?.[1] ?? '';\n}\n\n/**\n * Formats `digits` at the width the source declared.\n *\n * A source that wrote zeros past its own significant digits declared padding,\n * and that width is kept: `.500` stays three digits and `.500000` stays six. A\n * source whose extra digits were significant declared a precision the new value\n * does not have, so only the digits the value needs are written: `.123456`\n * edited to 750 ms becomes `.75`. This is the rule numbers already follow,\n * where `1.00` keeps its decimals and `1.50` collapses to what the value needs.\n */\nfunction formatFraction(digits: string, originalRaw: string, msRe: RegExp): string {\n const source = sourceFraction(originalRaw, msRe);\n const declaredPadding = source.length > source.replace(/0+$/, '').length;\n const width = declaredPadding ? Math.max(source.length, digits.length) : digits.length;\n return width === 0 ? '' : '.' + digits.padEnd(width, '0');\n}\n\n/**\n * The fractional-second digits a value spells out, or \"\" when it has none.\n * The custom classes render their own fraction, so this is the caller's\n * spelling for them and the millisecond part for a plain `Date`.\n */\nfunction renderedFraction(value: Date): string {\n const match = value.toISOString().match(/\\.(\\d+)/);\n return match ? match[1] : '';\n}\n\n/**\n * The fraction to write for `value` when the source wrote `originalRaw`.\n *\n * A `Date` holds milliseconds, so `.123999` and `.123456` are both 123 ms to\n * `getTime()`, but a value that spells out digits beyond the millisecond part\n * names a different instant and writes the digits it spells. Everything else\n * keeps the document's spelling.\n */\nfunction fractionSuffix(value: Date, ms: number, originalRaw: string, msRe: RegExp = TRAILING_FRACTION): string {\n const spelled = renderedFraction(value).replace(/0+$/, '');\n if (spelled.length > valueFractionDigits(ms).length) {\n return formatFraction(spelled, originalRaw, msRe);\n }\n return fmtMs(ms, originalRaw, msRe);\n}\n\n/**\n * Format the fractional-second suffix, preserving the original precision.\n *\n * TOML allows any number of fractional digits, but a `Date` only holds\n * milliseconds. When the value's millisecond part still matches the leading\n * digits of the source fraction, the whole source fraction is emitted, so\n * sub-millisecond digits survive a parse → stringify round trip.\n *\n * Otherwise the digits the value needs are written, widened to the source's\n * width when the source declared zeros there: `.5` and 750 ms become `.75`,\n * because slicing to one digit would write `.7` and silently change the value\n * to 700 ms, while `.500` stays three digits as `.750` and `.123456` drops to\n * the `.75` the value needs. `TomlFormat.minimumTimeDecimals` raises the count\n * when a document wants a wider fraction.\n *\n * Returns \"\" when the source had no fraction and the value has none either.\n */\nfunction fmtMs(ms: number, origFmt: string, msRe: RegExp = TRAILING_FRACTION): string {\n const digits = valueFractionDigits(ms);\n if (origFmt && origFmt.includes('.')) {\n const match = origFmt.match(msRe);\n if (match && match[1].startsWith(String(ms).padStart(3, '0'))) return '.' + match[1];\n return formatFraction(digits, origFmt, msRe);\n }\n return digits ? '.' + digits : '';\n}\n\n/** Parse a timezone offset string like \"+09:00\" or \"Z\" into minutes. */\nfunction parseOffsetMinutes(offset: string): number {\n if (offset === 'Z') return 0;\n const sign = offset[0] === '+' ? 1 : -1;\n const [h, m] = offset.slice(1).split(':');\n return sign * (parseInt(h) * 60 + parseInt(m));\n}\n\n/**\n * Pads the fractional seconds of a rendered TOML date/time so at least\n * `minimumTimeDecimals` digits are written.\n *\n * This is the `TomlFormat.minimumTimeDecimals` floor. It is separate from\n * `minimumDecimals`, which applies to numbers. Padding only: digits already\n * written are kept, so the represented value never changes. A date-only value\n * carries no time and is returned unchanged, and a non-positive count is a\n * no-op.\n *\n * TOML 1.1 allows the seconds to be omitted, so a value written as `HH:MM`\n * gains `:00` before its fraction.\n */\nexport function padFractionalSeconds(raw: string, minimumTimeDecimals: number): string {\n if (minimumTimeDecimals <= 0) return raw;\n return raw.replace(\n /(\\d{2}:\\d{2})(?::(\\d{2}))?(?:\\.(\\d+))?/,\n (whole: string, hourMinute: string, seconds?: string, fraction?: string) => {\n const written = fraction ?? '';\n if (written.length >= minimumTimeDecimals) return whole;\n return `${hourMinute}:${seconds ?? '00'}.${written.padEnd(minimumTimeDecimals, '0')}`;\n }\n );\n}\n\n// ---------------------------------------------------------------------------\n\n/**\n * Helper class containing all date format patterns and utilities for TOML date/time handling\n */\nexport class DateFormatHelper {\n // Patterns for different date/time formats\n static readonly IS_DATE_ONLY = /^\\d{4}-\\d{2}-\\d{2}$/;\n static readonly IS_TIME_ONLY = /^\\d{2}:\\d{2}(?::\\d{2})?(?:\\.\\d+)?$/;\n static readonly IS_LOCAL_DATETIME_T = /^\\d{4}-\\d{2}-\\d{2}[Tt]\\d{2}:\\d{2}(?::\\d{2})?(?:\\.\\d+)?$/;\n static readonly IS_LOCAL_DATETIME_SPACE = /^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}(?::\\d{2})?(?:\\.\\d+)?$/;\n static readonly IS_OFFSET_DATETIME_T = /^\\d{4}-\\d{2}-\\d{2}[Tt]\\d{2}:\\d{2}(?::\\d{2})?(?:\\.\\d+)?(?:[Zz]|[+-]\\d{2}:\\d{2})$/;\n static readonly IS_OFFSET_DATETIME_SPACE = /^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}(?::\\d{2})?(?:\\.\\d+)?(?:[Zz]|[+-]\\d{2}:\\d{2})$/;\n \n // Legacy patterns from parse-toml.ts (for compatibility)\n // Made more permissive to catch malformed dates (e.g., 1987-7-05) for validation\n static readonly IS_FULL_DATE = /(\\d{4})-(\\d+)-(\\d+)/;\n static readonly IS_FULL_TIME = /(\\d+):(\\d+)(?::(\\d+))?/;\n\n /**\n * Creates a custom date/time object that preserves the original TOML date/time format.\n * \n * This method detects the TOML date/time format from the raw string and returns an appropriate\n * custom date/time instance (e.g., LocalDate, LocalTime, LocalDateTime, OffsetDateTime) or a Date,\n * using the provided new JavaScript Date value.\n * \n * @param {Date} newJSDate - The new JavaScript Date object representing the updated \n * date/time value. This is used as the source for constructing the custom date/time object.\n * In some cases, this may be a custom date/time object (e.g., LocalTime) instead of a native Date.\n * @param {string} originalRaw - The original TOML date/time string as it appeared in the input.\n * Used to detect the specific TOML date/time format and to extract formatting details (e.g., separator, offset).\n * \n * @returns {Date | LocalDate | LocalTime | LocalDateTime | OffsetDateTime}\n * Returns a custom date/time object that matches the original TOML format:\n * - LocalDate for date-only values (e.g., \"2024-01-15\")\n * - LocalTime for time-only values (e.g., \"10:30:00\")\n * - LocalDateTime for local datetimes (e.g., \"2024-01-15T10:30:00\" or \"2024-01-15 10:30:00\")\n * - OffsetDateTime for datetimes with offsets (e.g., \"2024-01-15T10:30:00+02:00\")\n * - Date (native JS Date) as a fallback if the format is unrecognized\n * \n * Format-specific behavior:\n * - Date-only: Returns a LocalDate constructed from the date part of newJSDate.\n * - Time-only: Returns a LocalTime built from newJSDate's time part, with the original's fractional digits.\n * - Local datetime: Returns a LocalDateTime, preserving the separator (T or space).\n * - Offset datetime: Returns an OffsetDateTime, reconstructing the date/time with the original offset and separator.\n * - Fallback: Returns newJSDate as-is.\n */\n static createDateWithOriginalFormat(newJSDate: Date, originalRaw: string): Date {\n if (DateFormatHelper.IS_DATE_ONLY.test(originalRaw)) {\n // Local date (date-only) - format: 2024-01-15\n // Check if newJSDate has time components - if so, upgrade appropriately\n if (\n newJSDate.getUTCHours() !== 0 ||\n newJSDate.getUTCMinutes() !== 0 ||\n newJSDate.getUTCSeconds() !== 0 ||\n newJSDate.getUTCMilliseconds() !== 0\n ) {\n // Check if the new value is an OffsetDateTime (has offset information)\n if (newJSDate instanceof OffsetDateTime) {\n // Upgrade to OffsetDateTime - it already has the right format\n return newJSDate;\n }\n \n // Upgrade from date-only to local datetime with time components\n // Use T separator as it's the more common format\n let isoString = newJSDate.toISOString().replace('Z', '');\n // Strip .000 milliseconds if present (don't show unnecessary precision)\n isoString = isoString.replace(/\\.000$/, '');\n return new LocalDateTime(isoString, false);\n }\n const dateStr = newJSDate.toISOString().split('T')[0];\n return new LocalDate(dateStr);\n } else if (DateFormatHelper.IS_TIME_ONLY.test(originalRaw)) {\n // Local time (time-only) - format: 10:30:00\n // Rebuilt from the source format like the other kinds: a value that is\n // already a LocalTime still takes its fractional-digit count from the\n // document, not from how the caller built the object.\n const p = fmtParts(newJSDate);\n const msSuffix = fractionSuffix(newJSDate, p.ms, originalRaw);\n // The rebuilt value carries the text it was written with, so an edit that\n // spends more digits than the document used does not collapse back to\n // the document's fraction on the next render.\n const time = `${p.hours}:${p.minutes}:${p.seconds}${msSuffix}`;\n return new LocalTime(time);\n } else if (DateFormatHelper.IS_LOCAL_DATETIME_T.test(originalRaw)) {\n // Local datetime with T separator - format: 2024-01-15T10:30:00\n const p = fmtParts(newJSDate);\n const msSuffix = fractionSuffix(newJSDate, p.ms, originalRaw);\n const dateTime = `${p.year}-${p.month}-${p.day}T${p.hours}:${p.minutes}:${p.seconds}${msSuffix}`;\n return new LocalDateTime(dateTime, false, dateTime);\n } else if (DateFormatHelper.IS_LOCAL_DATETIME_SPACE.test(originalRaw)) {\n // Local datetime with space separator - format: 2024-01-15 10:30:00\n const p = fmtParts(newJSDate);\n const msSuffix = fractionSuffix(newJSDate, p.ms, originalRaw);\n const dateTime = `${p.year}-${p.month}-${p.day} ${p.hours}:${p.minutes}:${p.seconds}${msSuffix}`;\n return new LocalDateTime(dateTime, true, dateTime);\n } else if (DateFormatHelper.IS_OFFSET_DATETIME_T.test(originalRaw) || DateFormatHelper.IS_OFFSET_DATETIME_SPACE.test(originalRaw)) {\n // Offset datetime - preserve the original timezone offset and separator\n const offsetMatch = originalRaw.match(/([+-]\\d{2}:\\d{2}|[Zz])$/);\n const originalOffset = offsetMatch ? (offsetMatch[1] === 'z' ? 'Z' : offsetMatch[1]) : 'Z';\n const useSpaceSeparator = DateFormatHelper.IS_OFFSET_DATETIME_SPACE.test(originalRaw);\n \n // Convert UTC time to local time in the original timezone\n const localTime = new Date(newJSDate.getTime() + parseOffsetMinutes(originalOffset) * 60000);\n const p = fmtParts(localTime);\n const sep = useSpaceSeparator ? ' ' : 'T';\n const msSuffix = fractionSuffix(newJSDate, p.ms, originalRaw, OFFSET_FRACTION);\n \n const newDateTimeString = `${p.year}-${p.month}-${p.day}${sep}${p.hours}:${p.minutes}:${p.seconds}${msSuffix}${originalOffset}`;\n return new OffsetDateTime(newDateTimeString, useSpaceSeparator);\n } else {\n // Fallback to regular Date\n return newJSDate;\n }\n }\n}\n\n/**\n * Custom Date class for local dates (date-only).\n * Format: 1979-05-27\n */\nexport class LocalDate extends Date {\n\n constructor(value: string) {\n super(value);\n }\n \n toISOString(): string {\n const p = fmtParts(this);\n return `${p.year}-${p.month}-${p.day}`;\n }\n}\n\n/**\n * Custom Date class for local times (time-only)\n * Format: 07:32:00 or 07:32:00.999\n */\nexport class LocalTime extends Date {\n originalFormat: string;\n \n constructor(value: string, originalFormat: string = value) {\n // Normalize time to include seconds if missing (TOML 1.1.0 allows optional seconds)\n let normalizedValue = value;\n if (!/:\\d{2}:\\d{2}/.test(value)) {\n // No seconds present, add :00\n normalizedValue = value + ':00';\n }\n // For local time, use year 0000 as the base (TOML spec compliance)\n // Add 'Z' to ensure it's parsed as UTC regardless of system timezone\n super(`0000-01-01T${normalizedValue}Z`);\n this.originalFormat = originalFormat;\n }\n \n toISOString(): string {\n const p = fmtParts(this);\n return `${p.hours}:${p.minutes}:${p.seconds}${fmtMs(p.ms, this.originalFormat)}`;\n }\n}\n\n/**\n * Custom Date class for local datetime (no timezone)\n * Format: 1979-05-27T07:32:00 or 1979-05-27 07:32:00\n */\nexport class LocalDateTime extends Date {\n useSpaceSeparator: boolean = false;\n originalFormat: string;\n \n constructor(value: string, useSpaceSeparator: boolean = false, originalFormat?: string) {\n // Normalize time part to include seconds if missing (TOML 1.1.0 allows optional seconds)\n let normalizedValue = value;\n if (!/\\d{2}:\\d{2}:\\d{2}/.test(value)) {\n normalizedValue = value.replace(/(\\d{2}:\\d{2})([\\s\\-+TZ]|$)/, '$1:00$2');\n }\n // Convert space to T for Date parsing, but remember the original format\n super(normalizedValue.replace(' ', 'T') + 'Z');\n this.useSpaceSeparator = useSpaceSeparator;\n this.originalFormat = originalFormat || value;\n }\n \n toISOString(): string {\n const p = fmtParts(this);\n const sep = this.useSpaceSeparator ? ' ' : 'T';\n return `${p.year}-${p.month}-${p.day}${sep}${p.hours}:${p.minutes}:${p.seconds}${fmtMs(p.ms, this.originalFormat)}`;\n }\n}\n\n/**\n * Custom Date class for offset datetime that preserves space separator\n * Format: 1979-05-27T07:32:00Z or 1979-05-27 07:32:00-07:00\n */\nexport class OffsetDateTime extends Date {\n useSpaceSeparator: boolean = false;\n originalOffset?: string;\n originalFormat: string;\n \n constructor(value: string, useSpaceSeparator: boolean = false) {\n // Normalize time part to include seconds if missing (TOML 1.1.0 allows optional seconds)\n let normalizedValue = value;\n if (!/\\d{2}:\\d{2}:\\d{2}/.test(value)) {\n normalizedValue = value.replace(/(\\d{2}:\\d{2})([\\s\\-+TZ]|$)/, '$1:00$2');\n }\n super(normalizedValue.replace(' ', 'T'));\n this.useSpaceSeparator = useSpaceSeparator;\n this.originalFormat = value;\n \n // Extract and preserve the original offset\n const offsetMatch = value.match(/([+-]\\d{2}:\\d{2}|[Zz])$/);\n if (offsetMatch) {\n this.originalOffset = offsetMatch[1] === 'z' ? 'Z' : offsetMatch[1];\n }\n }\n \n toISOString(): string {\n if (this.originalOffset) {\n const localTime = new Date(this.getTime() + parseOffsetMinutes(this.originalOffset) * 60000);\n const p = fmtParts(localTime);\n const sep = this.useSpaceSeparator ? ' ' : 'T';\n const msSuffix = fmtMs(p.ms, this.originalFormat, OFFSET_FRACTION);\n return `${p.year}-${p.month}-${p.day}${sep}${p.hours}:${p.minutes}:${p.seconds}${msSuffix}${this.originalOffset}`;\n }\n \n const isoString = super.toISOString();\n if (this.useSpaceSeparator) {\n return isoString.replace('T', ' ');\n }\n return isoString;\n }\n}"],"mappings":";;;;;;;;AAWA,SAAS,SAAS,GAAS;CACzB,OAAO;EACL,MAAM,OAAO,EAAE,eAAe,CAAC,CAAC,CAAC,SAAS,GAAG,GAAG;EAChD,OAAO,OAAO,EAAE,YAAY,IAAI,CAAC,CAAC,CAAC,SAAS,GAAG,GAAG;EAClD,KAAK,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC,SAAS,GAAG,GAAG;EAC3C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EACnG;EAEA,MAAM,YAAY,MAAM,YAAY;EACpC,IAAI,KAAK,mBACP,OAAO,UAAU,QAAQ,KAAK,GAAG;EAEnC,OAAO;CACT;AACF"}
@@ -0,0 +1,27 @@
1
+ //! @decimalturn/toml-patch v3.3.1 - https://github.com/DecimalTurn/toml-patch - @license: MIT
2
+ //#region src/decode-utf8.ts
3
+ /**
4
+ * Decodes UTF-8 bytes in fatal mode, preserving any leading BOM.
5
+ */
6
+ function decodeUtf8Bytes(value) {
7
+ return new TextDecoder("utf-8", {
8
+ fatal: true,
9
+ ignoreBOM: true
10
+ }).decode(value);
11
+ }
12
+ /**
13
+ * Returns true when the input starts with a Unicode BOM character (U+FEFF).
14
+ */
15
+ function hasLeadingBom(value) {
16
+ return value.charCodeAt(0) === 65279;
17
+ }
18
+ /**
19
+ * Strips a leading Unicode BOM character (U+FEFF) from string input.
20
+ */
21
+ function stripLeadingBom(value) {
22
+ return hasLeadingBom(value) ? value.slice(1) : value;
23
+ }
24
+
25
+ //#endregion
26
+ export { decodeUtf8Bytes, hasLeadingBom, stripLeadingBom };
27
+ //# sourceMappingURL=decode-utf8.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decode-utf8.js","names":[],"sources":["../../src/decode-utf8.ts"],"sourcesContent":["/**\n * UTF-8 BOM marker (U+FEFF).\n */\nexport const UTF8_BOM = '\\uFEFF';\n\n/**\n * Decodes UTF-8 bytes in fatal mode, preserving any leading BOM.\n */\nexport function decodeUtf8Bytes(value: Uint8Array): string {\n return new TextDecoder('utf-8', { fatal: true, ignoreBOM: true }).decode(value);\n}\n\n/**\n * Returns true when the input starts with a Unicode BOM character (U+FEFF).\n */\nexport function hasLeadingBom(value: string): boolean {\n return value.charCodeAt(0) === 0xfeff;\n}\n\n/**\n * Returns true when raw bytes start with a UTF-8 BOM prefix.\n */\nexport function hasLeadingUtf8BomBytes(value: Uint8Array): boolean {\n return value.length >= 3 && value[0] === 0xef && value[1] === 0xbb && value[2] === 0xbf;\n}\n\n/**\n * Strips a leading Unicode BOM character (U+FEFF) from string input.\n */\nexport function stripLeadingBom(value: string): string {\n return hasLeadingBom(value) ? value.slice(1) : value;\n}\n"],"mappings":";;;;;AAQA,SAAgB,gBAAgB,OAA2B;CACzD,OAAO,IAAI,YAAY,SAAS;EAAE,OAAO;EAAM,WAAW;CAAK,CAAC,CAAC,CAAC,OAAO,KAAK;AAChF;;;;AAKA,SAAgB,cAAc,OAAwB;CACpD,OAAO,MAAM,WAAW,CAAC,MAAM;AACjC;;;;AAYA,SAAgB,gBAAgB,OAAuB;CACrD,OAAO,cAAc,KAAK,IAAI,MAAM,MAAM,CAAC,IAAI;AACjD"}
@@ -0,0 +1,108 @@
1
+ //! @decimalturn/toml-patch v3.3.1 - https://github.com/DecimalTurn/toml-patch - @license: MIT
2
+ import { datesEqual, isDate, isNegativeNan, isObject, isTemporal, sameValue, stableStringify } from "./utils.js";
3
+
4
+ //#region src/diff-lite.ts
5
+ var PatchLiteError = class extends Error {
6
+ code;
7
+ path;
8
+ constructor(code, path, message) {
9
+ super(message);
10
+ this.name = "PatchLiteError";
11
+ this.code = code;
12
+ this.path = path;
13
+ }
14
+ };
15
+ /**
16
+ * Formats a path as `a.b[0].c` for error messages.
17
+ */
18
+ function formatPath(path) {
19
+ let out = "";
20
+ for (const segment of path) if (typeof segment === "number") out += `[${segment}]`;
21
+ else out += out ? `.${segment}` : segment;
22
+ return out || "(root)";
23
+ }
24
+ function isSupportedLeaf(value) {
25
+ const type = typeof value;
26
+ return type === "string" || type === "boolean" || type === "number" || type === "bigint";
27
+ }
28
+ function describe(value) {
29
+ if (value === null) return "null";
30
+ if (Array.isArray(value)) return "array";
31
+ if (isDate(value) || isTemporal(value)) return "date";
32
+ const type = typeof value;
33
+ return type === "object" ? "table" : type;
34
+ }
35
+ function sameNanSign(a, b) {
36
+ return isNegativeNan(a) === isNegativeNan(b);
37
+ }
38
+ /**
39
+ * A value the edit path writes as a TOML date/time. `patch-lite` accepts both
40
+ * the custom `Date` subclasses it parses and Temporal objects the caller
41
+ * supplies, and an edit may switch between them, so the diff groups both under
42
+ * one kind instead of treating the mix as a type change.
43
+ */
44
+ function isDateLike(value) {
45
+ return isDate(value) || isTemporal(value);
46
+ }
47
+ /**
48
+ * Compares the existing and updated JavaScript values and returns the list of
49
+ * in-place edits. Any structural difference throws a `PatchLiteError` before
50
+ * the source is mutated.
51
+ */
52
+ function diffLite(before, after, path = []) {
53
+ if (datesEqual(before, after)) return [];
54
+ if (sameValue(before, after)) return [];
55
+ if (typeof before === "number" && typeof after === "number" && Number.isNaN(before) && Number.isNaN(after) && sameNanSign(before, after)) return [];
56
+ const beforeIsArray = Array.isArray(before);
57
+ const afterIsArray = Array.isArray(after);
58
+ if (beforeIsArray && afterIsArray) return compareArrays(before, after, path);
59
+ if (beforeIsArray || afterIsArray) throw new PatchLiteError("TypeChange", path, `Cannot change a ${beforeIsArray ? "array" : describe(before)} to a ${afterIsArray ? "array" : describe(after)} at ${formatPath(path)}`);
60
+ const beforeIsObject = isObject(before);
61
+ const afterIsObject = isObject(after);
62
+ if (beforeIsObject && afterIsObject) return compareObjects(before, after, path);
63
+ if (beforeIsObject || afterIsObject) throw new PatchLiteError("TypeChange", path, `Cannot change a ${beforeIsObject ? "table" : describe(before)} to a ${afterIsObject ? "table" : describe(after)} at ${formatPath(path)}`);
64
+ if (isDateLike(before) && isDateLike(after)) return [{
65
+ type: "Edit",
66
+ path
67
+ }];
68
+ if (isDateLike(before) || isDateLike(after)) throw new PatchLiteError("TypeChange", path, `Cannot change a ${describe(before)} to a ${describe(after)} at ${formatPath(path)}`);
69
+ if (!isSupportedLeaf(before) || !isSupportedLeaf(after)) throw new PatchLiteError("UnsupportedValue", path, `Unsupported value type ${describe(after)} at ${formatPath(path)}`);
70
+ return [{
71
+ type: "Edit",
72
+ path
73
+ }];
74
+ }
75
+ function compareObjects(before, after, path) {
76
+ const beforeKeys = Object.keys(before);
77
+ const afterKeys = Object.keys(after);
78
+ const afterKeySet = new Set(afterKeys);
79
+ for (const key of beforeKeys) if (!afterKeySet.has(key)) throw new PatchLiteError("RemovedKey", path.concat(key), `Cannot remove key ${formatPath(path.concat(key))}`);
80
+ const beforeKeySet = new Set(beforeKeys);
81
+ for (const key of afterKeys) if (!beforeKeySet.has(key)) throw new PatchLiteError("AddedKey", path.concat(key), `Cannot add key ${formatPath(path.concat(key))}`);
82
+ const changes = [];
83
+ for (const key of beforeKeys) {
84
+ const sub = diffLite(before[key], after[key], path.concat(key));
85
+ for (const change of sub) changes.push(change);
86
+ }
87
+ return changes;
88
+ }
89
+ function compareArrays(before, after, path) {
90
+ if (before.length !== after.length) throw new PatchLiteError("ArrayLengthChange", path, `Cannot change the length of array at ${formatPath(path)} (${before.length} to ${after.length})`);
91
+ const beforeStable = before.map(stableStringify);
92
+ const afterStable = after.map(stableStringify);
93
+ if (!beforeStable.every((value, index) => value === afterStable[index])) {
94
+ const beforeBag = beforeStable.slice().sort();
95
+ const afterBag = afterStable.slice().sort();
96
+ if (beforeBag.length === afterBag.length && beforeBag.every((value, index) => value === afterBag[index])) throw new PatchLiteError("ArrayReorder", path, `Cannot reorder array elements at ${formatPath(path)}`);
97
+ }
98
+ const changes = [];
99
+ for (let index = 0; index < before.length; index++) {
100
+ const sub = diffLite(before[index], after[index], path.concat(index));
101
+ for (const change of sub) changes.push(change);
102
+ }
103
+ return changes;
104
+ }
105
+
106
+ //#endregion
107
+ export { PatchLiteError, diffLite as default, formatPath };
108
+ //# sourceMappingURL=diff-lite.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diff-lite.js","names":[],"sources":["../../src/diff-lite.ts"],"sourcesContent":["import { isObject, isDate, isTemporal, datesEqual, stableStringify, sameValue, isNegativeNan } from './utils';\n\n/**\n * A path into a JavaScript object, mixing object keys and array indices.\n */\nexport type Path = Array<string | number>;\n\n/**\n * The only change patch-lite can apply: replacing an existing value in place.\n */\nexport interface Edit {\n type: 'Edit';\n path: Path;\n}\n\n/**\n * The unsupported operations patch-lite rejects. The code is part of the\n * public error contract so callers can branch on it without parsing messages.\n */\nexport type PatchLiteErrorCode =\n | 'AddedKey'\n | 'RemovedKey'\n | 'ArrayLengthChange'\n | 'ArrayReorder'\n | 'TypeChange'\n | 'UnsupportedValue'\n | 'UnsupportedOption';\n\nexport class PatchLiteError extends Error {\n readonly code: PatchLiteErrorCode;\n readonly path: Path;\n\n constructor(code: PatchLiteErrorCode, path: Path, message: string) {\n super(message);\n this.name = 'PatchLiteError';\n this.code = code;\n this.path = path;\n }\n}\n\n/**\n * Formats a path as `a.b[0].c` for error messages.\n */\nexport function formatPath(path: Path): string {\n let out = '';\n for (const segment of path) {\n if (typeof segment === 'number') out += `[${segment}]`;\n else out += out ? `.${segment}` : segment;\n }\n return out || '(root)';\n}\n\nfunction isSupportedLeaf(value: any): boolean {\n const type = typeof value;\n return type === 'string' || type === 'boolean' || type === 'number' || type === 'bigint';\n}\n\nfunction describe(value: any): string {\n if (value === null) return 'null';\n if (Array.isArray(value)) return 'array';\n if (isDate(value) || isTemporal(value)) return 'date';\n const type = typeof value;\n return type === 'object' ? 'table' : type;\n}\n\nfunction sameNanSign(a: number, b: number): boolean {\n return isNegativeNan(a) === isNegativeNan(b);\n}\n\n/**\n * A value the edit path writes as a TOML date/time. `patch-lite` accepts both\n * the custom `Date` subclasses it parses and Temporal objects the caller\n * supplies, and an edit may switch between them, so the diff groups both under\n * one kind instead of treating the mix as a type change.\n */\nfunction isDateLike(value: any): boolean {\n return isDate(value) || isTemporal(value);\n}\n\n/**\n * Compares the existing and updated JavaScript values and returns the list of\n * in-place edits. Any structural difference throws a `PatchLiteError` before\n * the source is mutated.\n */\nexport default function diffLite(before: any, after: any, path: Path = []): Edit[] {\n if (datesEqual(before, after)) return [];\n\n if (sameValue(before, after)) return [];\n\n if (\n typeof before === 'number' &&\n typeof after === 'number' &&\n Number.isNaN(before) &&\n Number.isNaN(after) &&\n sameNanSign(before, after)\n ) {\n return [];\n }\n\n const beforeIsArray = Array.isArray(before);\n const afterIsArray = Array.isArray(after);\n\n if (beforeIsArray && afterIsArray) {\n return compareArrays(before, after, path);\n }\n\n if (beforeIsArray || afterIsArray) {\n throw new PatchLiteError(\n 'TypeChange',\n path,\n `Cannot change a ${beforeIsArray ? 'array' : describe(before)} to a ${\n afterIsArray ? 'array' : describe(after)\n } at ${formatPath(path)}`\n );\n }\n\n const beforeIsObject = isObject(before);\n const afterIsObject = isObject(after);\n\n if (beforeIsObject && afterIsObject) {\n return compareObjects(before, after, path);\n }\n\n if (beforeIsObject || afterIsObject) {\n throw new PatchLiteError(\n 'TypeChange',\n path,\n `Cannot change a ${beforeIsObject ? 'table' : describe(before)} to a ${\n afterIsObject ? 'table' : describe(after)\n } at ${formatPath(path)}`\n );\n }\n\n if (isDateLike(before) && isDateLike(after)) {\n return [{ type: 'Edit', path }];\n }\n\n if (isDateLike(before) || isDateLike(after)) {\n throw new PatchLiteError(\n 'TypeChange',\n path,\n `Cannot change a ${describe(before)} to a ${describe(after)} at ${formatPath(path)}`\n );\n }\n\n if (!isSupportedLeaf(before) || !isSupportedLeaf(after)) {\n throw new PatchLiteError(\n 'UnsupportedValue',\n path,\n `Unsupported value type ${describe(after)} at ${formatPath(path)}`\n );\n }\n\n return [{ type: 'Edit', path }];\n}\n\nfunction compareObjects(before: any, after: any, path: Path): Edit[] {\n // Only key membership matters, not key order: patch-lite edits values by\n // path and never reorders keys, so the key order of `after` does not affect\n // the output and is intentionally ignored.\n const beforeKeys = Object.keys(before);\n const afterKeys = Object.keys(after);\n\n const afterKeySet = new Set(afterKeys);\n for (const key of beforeKeys) {\n if (!afterKeySet.has(key)) {\n throw new PatchLiteError(\n 'RemovedKey',\n path.concat(key),\n `Cannot remove key ${formatPath(path.concat(key))}`\n );\n }\n }\n\n const beforeKeySet = new Set(beforeKeys);\n for (const key of afterKeys) {\n if (!beforeKeySet.has(key)) {\n throw new PatchLiteError(\n 'AddedKey',\n path.concat(key),\n `Cannot add key ${formatPath(path.concat(key))}`\n );\n }\n }\n\n const changes: Edit[] = [];\n for (const key of beforeKeys) {\n const sub = diffLite(before[key], after[key], path.concat(key));\n for (const change of sub) changes.push(change);\n }\n return changes;\n}\n\nfunction compareArrays(before: any[], after: any[], path: Path): Edit[] {\n if (before.length !== after.length) {\n throw new PatchLiteError(\n 'ArrayLengthChange',\n path,\n `Cannot change the length of array at ${formatPath(path)} (${before.length} to ${after.length})`\n );\n }\n\n // A reorder keeps the same multiset of elements but changes their order.\n // Detect it via stable deep forms so genuine element edits still pass.\n const beforeStable = before.map(stableStringify);\n const afterStable = after.map(stableStringify);\n\n const positionsDiffer = !beforeStable.every((value, index) => value === afterStable[index]);\n if (positionsDiffer) {\n const beforeBag = beforeStable.slice().sort();\n const afterBag = afterStable.slice().sort();\n const sameElements =\n beforeBag.length === afterBag.length &&\n beforeBag.every((value, index) => value === afterBag[index]);\n\n if (sameElements) {\n throw new PatchLiteError(\n 'ArrayReorder',\n path,\n `Cannot reorder array elements at ${formatPath(path)}`\n );\n }\n }\n\n const changes: Edit[] = [];\n for (let index = 0; index < before.length; index++) {\n const sub = diffLite(before[index], after[index], path.concat(index));\n for (const change of sub) changes.push(change);\n }\n return changes;\n}\n"],"mappings":";;;;AA4BA,IAAa,iBAAb,cAAoC,MAAM;CACxC,AAAS;CACT,AAAS;CAET,YAAY,MAA0B,MAAY,SAAiB;EACjE,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,OAAO;EACZ,KAAK,OAAO;CACd;AACF;;;;AAKA,SAAgB,WAAW,MAAoB;CAC7C,IAAI,MAAM;CACV,KAAK,MAAM,WAAW,MACpB,IAAI,OAAO,YAAY,UAAU,OAAO,IAAI,QAAQ;MAC/C,OAAO,MAAM,IAAI,YAAY;CAEpC,OAAO,OAAO;AAChB;AAEA,SAAS,gBAAgB,OAAqB;CAC5C,MAAM,OAAO,OAAO;CACpB,OAAO,SAAS,YAAY,SAAS,aAAa,SAAS,YAAY,SAAS;AAClF;AAEA,SAAS,SAAS,OAAoB;CACpC,IAAI,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