@decimalturn/toml-patch 3.3.1-lite → 3.3.2-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 +673 -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 +115 -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 +480 -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 +3128 -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 +308 -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 +221 -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 +296 -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,564 @@
1
+
2
+ //#region src/toml-format.d.ts
3
+ type MultilineContainerMode = boolean | number | 'auto' | 'parent';
4
+ export declare class TomlFormat {
5
+ /**
6
+ * The line ending character(s) to use in the output TOML.
7
+ * This option affects only the stringification process, not the internal representation (CST).
8
+ *
9
+ * @example
10
+ * - '\n' for Unix/Linux line endings
11
+ * - '\r\n' for Windows line endings
12
+ */
13
+ newLine: string;
14
+ /**
15
+ * The number of trailing newlines to add at the end of the TOML document.
16
+ * This option affects only the stringification process, not the internal representation (CST).
17
+ *
18
+ * @example
19
+ * - 0: No trailing newline
20
+ * - 1: One trailing newline (standard)
21
+ * - 2: Two trailing newlines (adds extra spacing)
22
+ */
23
+ trailingNewline: number;
24
+ /**
25
+ * Whether to add trailing commas after the last element in arrays and inline tables.
26
+ *
27
+ * @example
28
+ * - true: [1, 2, 3,] and { x = 1, y = 2, }
29
+ * - false: [1, 2, 3] and { x = 1, y = 2 }
30
+ */
31
+ trailingComma: boolean;
32
+ /**
33
+ * Whether to add spaces after opening brackets/braces and before closing brackets/braces
34
+ * in arrays and inline tables.
35
+ *
36
+ * @example
37
+ * - true: [ 1, 2, 3 ] and { x = 1, y = 2 }
38
+ * - false: [1, 2, 3] and {x = 1, y = 2}
39
+ */
40
+ bracketSpacing: boolean;
41
+ /**
42
+ * Whether the output should include a leading UTF-8 BOM marker (U+FEFF).
43
+ *
44
+ * This is auto-detected from the source TOML and preserved during patching.
45
+ */
46
+ leadingBom: boolean;
47
+ /**
48
+ * The nesting depth at which new tables should start being formatted as inline tables.
49
+ * When adding new tables during patching or stringifying objects:
50
+ * - Tables at depth >= inlineTableStart will be formatted as inline tables
51
+ * - Tables at depth < inlineTableStart will be formatted as separate table sections
52
+ *
53
+ * @example
54
+ * - 0: All tables are inline tables including top-level tables (root level)
55
+ * - 1: Top-level tables as sections, nested tables as inline (default)
56
+ * - 2: Two levels as sections, deeper nesting as inline
57
+ */
58
+ inlineTableStart?: number;
59
+ /**
60
+ * Whether to truncate time components in UTC date fields when they are zero.
61
+ * This setting affects only the stringification process.
62
+ *
63
+ * @example
64
+ * - true: Date('2024-01-15T00:00:00.000Z') serializes as 2024-01-15
65
+ * - false: Date('2024-01-15T00:00:00.000Z') serializes as 2024-01-15T00:00:00.000Z
66
+ *
67
+ */
68
+ truncateZeroTimeInDates?: boolean;
69
+ /**
70
+ * Whether to use tabs instead of spaces for indentation/padding.
71
+ * When enabled, lines that need to be indented will use tabs.
72
+ *
73
+ * @example
74
+ * - true: Uses tabs for indentation
75
+ * - false: Uses spaces for indentation (default)
76
+ *
77
+ */
78
+ useTabsForIndentation?: boolean;
79
+ /**
80
+ * The number of columns used for one indentation level in generated multiline values.
81
+ * This is auto-detected when patching and defaults to two columns.
82
+ */
83
+ indentWidth: number;
84
+ /**
85
+ * The minimum number of decimal places to use when serializing JS numbers as TOML floats.
86
+ * When greater than 0, plain JS integer values are serialized as TOML floats padded with
87
+ * zeros to reach the specified decimal count. BigInt values are always serialized as integers
88
+ * regardless of this setting.
89
+ *
90
+ * @example
91
+ * - 0: stringify({ x: 1, y: 1.5 }) → x = 1 / y = 1.5 (default)
92
+ * - 1: stringify({ x: 1, y: 1.5 }) → x = 1.0 / y = 1.5
93
+ * - 2: stringify({ x: 1, y: 1.5 }) → x = 1.00 / y = 1.50
94
+ */
95
+ minimumDecimals?: number;
96
+ /**
97
+ * The minimum number of fractional-second digits to write for date/time values.
98
+ *
99
+ * When greater than 0, a time or datetime is padded with zeros to reach the specified digit
100
+ * count, and a time written as `HH:MM` gains `:00` before its fraction. Digits already written
101
+ * are never removed, so a value with more digits keeps them, and a date-only value is
102
+ * unaffected because it carries no time. This is separate from `minimumDecimals`, which
103
+ * applies to numbers, so the two can be set independently.
104
+ *
105
+ * Not auto-detectable — caller must set explicitly.
106
+ *
107
+ * @example
108
+ * - 0: t = 07:32:00 (default)
109
+ * - 3: t = 07:32:00.000
110
+ */
111
+ minimumTimeDecimals?: number;
112
+ /**
113
+ * Whether `patch()` should reorder root key-values, `[table]`/`[[array]]` section blocks,
114
+ * and rows inside table bodies to match the key order of the JS object passed to `patch()`,
115
+ * carrying each entry's owned comments along with it (see docs/CommentOwnership.md).
116
+ *
117
+ * Off by default: with the option unset or `false`, `patch()` only ever changes values that
118
+ * actually differ between the existing document and the updated object, preserving the
119
+ * existing document's order even when the JS object's key order differs.
120
+ *
121
+ * Not auto-detectable — the existing document's order says nothing about the caller's
122
+ * intent, so `autoDetectFormatWithCst` always resolves this to `false`.
123
+ *
124
+ * See docs/PLAN-Update-Order.md for the full behavior and current scope limitations.
125
+ */
126
+ updateOrder?: boolean;
127
+ /**
128
+ * Whether newly generated inline tables should use multiline layout.
129
+ *
130
+ * `true` and `false` select a layout directly. A non-negative integer selects
131
+ * multiline layout at that structural container depth or deeper. `'auto'`
132
+ * keeps new containers compact and `'parent'` follows the immediate parent.
133
+ */
134
+ multilineTable: MultilineContainerMode;
135
+ /**
136
+ * Whether newly generated inline arrays should use multiline layout.
137
+ *
138
+ * `true` and `false` select a layout directly. A non-negative integer selects
139
+ * multiline layout at that structural container depth or deeper. `'auto'`
140
+ * keeps new containers compact and `'parent'` follows the immediate parent.
141
+ */
142
+ multilineArray: MultilineContainerMode;
143
+ /**
144
+ * Whether to write `\uXXXX` / `\UXXXXXXXX` / `\xHH` escape sequences with
145
+ * uppercase hex digits. Auto-detected from the first hex escape sequence in
146
+ * the document during patching; defaults to `true` (uppercase hex).
147
+ */
148
+ escapeSequenceUpperCase: boolean;
149
+ constructor(newLine?: string, trailingNewline?: number, trailingComma?: boolean, bracketSpacing?: boolean, inlineTableStart?: number, truncateZeroTimeInDates?: boolean, useTabsForIndentation?: boolean, minimumDecimals?: number, leadingBom?: boolean, updateOrder?: boolean, indentWidth?: number, multilineTable?: MultilineContainerMode | null, multilineArray?: MultilineContainerMode | null, escapeSequenceUpperCase?: boolean, minimumTimeDecimals?: number);
150
+ /**
151
+ * Creates a new TomlFormat instance with default formatting preferences.
152
+ *
153
+ * @returns A new TomlFormat instance with default values:
154
+ * - newLine: '\n'
155
+ * - trailingNewline: 1
156
+ * - trailingComma: false
157
+ * - bracketSpacing: true
158
+ * - leadingBom: false
159
+ * - inlineTableStart: 1
160
+ * - truncateZeroTimeInDates: false
161
+ * - useTabsForIndentation: false
162
+ * - minimumDecimals: 0
163
+ * - minimumTimeDecimals: 0
164
+ * - updateOrder: false
165
+ */
166
+ static default(): TomlFormat;
167
+ /**
168
+ * Auto-detects formatting preferences from an existing TOML string.
169
+ *
170
+ * This method analyzes the provided TOML string to determine formatting
171
+ * preferences such as line endings, trailing newlines, and comma usage.
172
+ *
173
+ * @param tomlString - The TOML string to analyze for formatting patterns
174
+ * @returns A new TomlFormat instance with detected formatting preferences
175
+ *
176
+ * @example
177
+ * ```typescript
178
+ * const toml = 'array = ["a", "b", "c",]\ntable = { x = 1, y = 2, }';
179
+ * const format = TomlFormat.autoDetectFormat(toml);
180
+ * // format.trailingComma will be true
181
+ * // format.newLine will be '\n'
182
+ * // format.trailingNewline will be 0 (no trailing newline)
183
+ * ```
184
+ */
185
+ static autoDetectFormat(tomlString: string): TomlFormat;
186
+ /**
187
+ * Internal method: Auto-detects formatting preferences from a TOML string with optional pre-parsed CST.
188
+ *
189
+ * This is used internally to avoid redundant parsing when the CST is already available.
190
+ * External callers should use `autoDetectFormat(tomlString)` instead.
191
+ *
192
+ * @internal
193
+ * @param tomlString - The TOML string to analyze for formatting patterns
194
+ * @param syntaxTree - Optional pre-parsed CST to avoid redundant parsing
195
+ * @returns A new TomlFormat instance with detected formatting preferences
196
+ */
197
+ static autoDetectFormatWithCst(tomlString: string, syntaxTree?: Iterable<any>): TomlFormat;
198
+ /** @deprecated Use autoDetectFormatWithCst instead. */
199
+ static autoDetectFormatWithAst(tomlString: string, syntaxTree?: Iterable<any>): TomlFormat;
200
+ }
201
+ //#endregion
202
+ //#region src/parse-options.d.ts
203
+ type IntegersAsBigInt = boolean | 'asNeeded';
204
+ interface ParseOptions {
205
+ /**
206
+ * Controls how TOML integers are returned in the parsed JavaScript object.
207
+ * - `true`: All integers are returned as `bigint`.
208
+ * - `false`: All integers are returned as `number` (may lose precision for large integers).
209
+ * - `'asNeeded'` (default): Integers that fit within the JavaScript safe-integer range are returned as `number`; larger integers are returned as `bigint`.
210
+ */
211
+ integersAsBigInt?: IntegersAsBigInt;
212
+ /**
213
+ * When true, TOML date/time values are parsed into Temporal objects
214
+ * (Temporal.PlainDate, Temporal.PlainTime, Temporal.PlainDateTime,
215
+ * Temporal.ZonedDateTime) instead of custom Date subclasses.
216
+ *
217
+ * The Temporal API must be available in the runtime.
218
+ * - Node.js >= v26: full native support.
219
+ * - Node.js < v26: enable with the `--harmony-temporal` flag.
220
+ * - Modern browsers: native support.
221
+ * - Other runtimes: use @js-temporal/polyfill.
222
+ *
223
+ * Default: false (returns custom Date subclasses for backward compatibility).
224
+ */
225
+ temporal?: boolean;
226
+ }
227
+ //#endregion
228
+ //#region src/location.d.ts
229
+ interface Location {
230
+ start: Position;
231
+ end: Position;
232
+ }
233
+ interface Position {
234
+ line: number;
235
+ column: number;
236
+ }
237
+ //#endregion
238
+ //#region src/cst.d.ts
239
+ declare enum NodeType {
240
+ Document = "Document",
241
+ Table = "Table",
242
+ TableKey = "TableKey",
243
+ /**
244
+ * Array of Tables node
245
+ * More info: https://toml.io/en/latest#array-of-tables
246
+ */
247
+ TableArray = "TableArray",
248
+ TableArrayKey = "TableArrayKey",
249
+ KeyValue = "KeyValue",
250
+ Key = "Key",
251
+ String = "String",
252
+ Integer = "Integer",
253
+ Float = "Float",
254
+ Boolean = "Boolean",
255
+ DateTime = "DateTime",
256
+ InlineArray = "InlineArray",
257
+ InlineItem = "InlineItem",
258
+ InlineTable = "InlineTable",
259
+ /**
260
+ * Comment node
261
+ * More info: https://toml.io/en/latest#comment
262
+ */
263
+ Comment = "Comment"
264
+ }
265
+ interface Table extends TreeNode {
266
+ type: NodeType.Table;
267
+ key: TableKey;
268
+ items: RowItem[];
269
+ }
270
+ interface TableKey extends TreeNode {
271
+ type: NodeType.TableKey;
272
+ item: Key;
273
+ }
274
+ interface TableArray extends TreeNode {
275
+ type: NodeType.TableArray;
276
+ key: TableArrayKey;
277
+ items: RowItem[];
278
+ }
279
+ interface TableArrayKey extends TreeNode {
280
+ type: NodeType.TableArrayKey;
281
+ item: Key;
282
+ }
283
+ interface KeyValue extends TreeNode {
284
+ type: NodeType.KeyValue;
285
+ key: Key;
286
+ value: Value;
287
+ equals: number;
288
+ }
289
+ interface Key extends TreeNode {
290
+ type: NodeType.Key;
291
+ raw: string;
292
+ value: string[];
293
+ }
294
+ interface String extends TreeNode {
295
+ type: NodeType.String;
296
+ raw: string;
297
+ value: string;
298
+ }
299
+ interface Integer extends TreeNode {
300
+ type: NodeType.Integer;
301
+ raw: string;
302
+ value: number | bigint;
303
+ }
304
+ interface Float extends TreeNode {
305
+ type: NodeType.Float;
306
+ raw: string;
307
+ value: number;
308
+ /** Sign prefix for NaN values: '+' for +nan, '-' for -nan, undefined for nan */
309
+ nanSign?: '+' | '-';
310
+ }
311
+ interface Boolean extends TreeNode {
312
+ type: NodeType.Boolean;
313
+ value: boolean;
314
+ }
315
+ interface DateTime extends TreeNode {
316
+ type: NodeType.DateTime;
317
+ raw: string;
318
+ value: Date;
319
+ }
320
+ interface InlineArray<TItem = TreeNode> extends TreeNode {
321
+ type: NodeType.InlineArray;
322
+ items: InlineArrayItem<TItem>[];
323
+ }
324
+ interface InlineItem<TItem = TreeNode> extends TreeNode {
325
+ type: NodeType.InlineItem;
326
+ item: TItem;
327
+ comma: boolean;
328
+ }
329
+ interface InlineArrayItem<TItem = TreeNode> extends InlineItem<TItem> {}
330
+ interface InlineTable extends TreeNode {
331
+ type: NodeType.InlineTable;
332
+ items: InlineTableItem[];
333
+ }
334
+ interface InlineTableItem extends InlineItem<KeyValue> {}
335
+ interface Comment extends TreeNode {
336
+ type: NodeType.Comment;
337
+ raw: string;
338
+ }
339
+ /**
340
+ * RowItem represents items that can appear inside Table and TableArray sections.
341
+ * These are the items that form the "rows" of content within table structures.
342
+ *
343
+ * Unlike Block items (which include Table and TableArray), RowItems can only be
344
+ * KeyValue pairs and Comments - you cannot have nested tables within a table section.
345
+ */
346
+ type RowItem = KeyValue | Comment;
347
+ /**
348
+ * Block represents items that can appear at the root level (Document level) in TOML.
349
+ *
350
+ * Context and Usage:
351
+ * - Block items are the fundamental top-level constructs in a TOML document
352
+ * - They appear directly in Document containers and regular Table sections
353
+ * - This is in contrast to InlineItems, which appear within inline containers
354
+ *
355
+ * Important Distinction:
356
+ * - Table and TableArray can ONLY exist as Block items (they cannot appear inside inline containers)
357
+ * - KeyValue and Comment can exist as BOTH Block items AND as InlineItems:
358
+ * * As Block: When they appear at root level or inside regular Table sections
359
+ * * As InlineItem: When they appear inside InlineTable or InlineArray containers
360
+ *
361
+ * Examples:
362
+ * ```toml
363
+ * # These are Block items at root level:
364
+ * name = "value" # KeyValue as Block
365
+ * # This is a comment # Comment as Block
366
+ * [table] # Table as Block
367
+ * [[array]] # TableArray as Block
368
+ *
369
+ * # These are Block items inside a Table:
370
+ * [config]
371
+ * setting = "value" # KeyValue as Block (inside Table)
372
+ * # comment here # Comment as Block (inside Table)
373
+ *
374
+ * # These are InlineItems (NOT Block items):
375
+ * array = [ "a", "b" ] # "a", "b" are InlineItems
376
+ * table = { key = "value" } # key="value" is InlineItem
377
+ * ```
378
+ *
379
+ * Type Safety:
380
+ * This distinction is crucial for the CST structure because:
381
+ * - Document.items: Block[]
382
+ * - Table.items: RowItem[] (KeyValue | Comment)
383
+ * - TableArray.items: RowItem[] (KeyValue | Comment)
384
+ * - InlineArray.items: InlineArrayItem[] (which extends InlineItem)
385
+ * - InlineTable.items: InlineTableItem[] (which extends InlineItem)
386
+ */
387
+ type Block = KeyValue | Table | TableArray | Comment;
388
+ type Value<TInlineArrayItem = TreeNode> = String | Integer | Float | Boolean | DateTime | InlineArray<TInlineArrayItem> | InlineTable;
389
+ interface TreeNode {
390
+ type: NodeType;
391
+ loc: Location;
392
+ /** Absolute UTF-16 offsets into the source that produced this node. */
393
+ readonly range?: readonly [number, number];
394
+ /** Set on generated or mutated nodes and propagated to their ancestors. */
395
+ dirty?: boolean;
396
+ }
397
+ //#endregion
398
+ //#region src/toml-document.d.ts
399
+ /**
400
+ * TomlDocument encapsulates a TOML CST and provides methods to interact with it.
401
+ */
402
+ export declare class TomlDocument {
403
+ private _cst;
404
+ private _currentTomlString;
405
+ private _format;
406
+ private _integersAsBigInt;
407
+ private _temporal;
408
+ /**
409
+ * Initializes the TomlDocument with TOML source, parsing it into a CST.
410
+ *
411
+ * When bytes are provided, they are decoded as UTF-8 in fatal mode.
412
+ * This rejects invalid UTF-8 sequences before parsing.
413
+ *
414
+ * @param tomlSource - The TOML source to parse (string or raw UTF-8 bytes)
415
+ * @param options - Optional parse options
416
+ * @param options.integersAsBigInt - Controls bigint vs number for TOML integers
417
+ * @param options.temporal - When true, returns Temporal objects for date/time values
418
+ */
419
+ constructor(tomlSource: string | Uint8Array, options?: ParseOptions);
420
+ get toTomlString(): string;
421
+ /**
422
+ * Returns the JavaScript object representation of the TOML document.
423
+ */
424
+ get toJsObject(): any;
425
+ /**
426
+ * Returns the internal CST (for testing purposes).
427
+ * @internal
428
+ */
429
+ get cst(): Block[];
430
+ /**
431
+ * Applies a patch to the current CST using a modified JS object.
432
+ * Updates the internal CST. Use toTomlString getter to retrieve the updated TOML string.
433
+ *
434
+ * @param updatedObject - The modified JS object to patch with
435
+ * @param format - Optional formatting options
436
+ */
437
+ patch(updatedObject: any, format?: Partial<TomlFormat> | TomlFormat): void;
438
+ /**
439
+ * Updates the internal document by supplying a modified tomlString.
440
+ * Use toJsObject getter to retrieve the updated JS object representation.
441
+ * @param tomlString - The modified TOML string to update with
442
+ */
443
+ update(tomlString: string): void;
444
+ /**
445
+ * Overwrites the internal syntax tree by fully re-parsing the supplied tomlString.
446
+ * This is simpler but slower than update() which uses incremental parsing.
447
+ * @param tomlString - The TOML string to overwrite with
448
+ */
449
+ overwrite(tomlString: string): void;
450
+ }
451
+ //#endregion
452
+ //#region src/patch.d.ts
453
+ /**
454
+ * Applies modifications to a TOML document by comparing an existing TOML string with updated JavaScript data.
455
+ *
456
+ * This function preserves formatting and comments from the existing TOML document while
457
+ * applying changes from the updated data structure. It performs a diff between the existing
458
+ * and updated data, then strategically applies only the necessary changes to maintain the
459
+ * original document structure as much as possible.
460
+ *
461
+ * @param existing - The original TOML document as a string
462
+ * @param updated - The updated JavaScript object with desired changes
463
+ * @param format - Optional formatting options to apply to new or modified sections
464
+ * @returns A new TOML string with the changes applied
465
+ */
466
+ declare function patch(existing: string, updated: any, format?: Partial<TomlFormat> | TomlFormat): string;
467
+ //#endregion
468
+ //#region src/date-format.d.ts
469
+ /**
470
+ * Custom Date class for local dates (date-only).
471
+ * Format: 1979-05-27
472
+ */
473
+ export declare class LocalDate extends Date {
474
+ constructor(value: string);
475
+ toISOString(): string;
476
+ }
477
+ /**
478
+ * Custom Date class for local times (time-only)
479
+ * Format: 07:32:00 or 07:32:00.999
480
+ */
481
+ export declare class LocalTime extends Date {
482
+ originalFormat: string;
483
+ constructor(value: string, originalFormat?: string);
484
+ toISOString(): string;
485
+ }
486
+ /**
487
+ * Custom Date class for local datetime (no timezone)
488
+ * Format: 1979-05-27T07:32:00 or 1979-05-27 07:32:00
489
+ */
490
+ export declare class LocalDateTime extends Date {
491
+ useSpaceSeparator: boolean;
492
+ originalFormat: string;
493
+ constructor(value: string, useSpaceSeparator?: boolean, originalFormat?: string);
494
+ toISOString(): string;
495
+ }
496
+ /**
497
+ * Custom Date class for offset datetime that preserves space separator
498
+ * Format: 1979-05-27T07:32:00Z or 1979-05-27 07:32:00-07:00
499
+ */
500
+ export declare class OffsetDateTime extends Date {
501
+ useSpaceSeparator: boolean;
502
+ originalOffset?: string;
503
+ originalFormat: string;
504
+ constructor(value: string, useSpaceSeparator?: boolean);
505
+ toISOString(): string;
506
+ }
507
+ //#endregion
508
+ //#region src/index.d.ts
509
+ /**
510
+ * Parses a TOML string or raw UTF-8 bytes into a JavaScript object.
511
+ *
512
+ * When raw bytes (Uint8Array / Buffer) are provided, they are decoded with
513
+ * the WHATWG TextDecoder in fatal mode, which rejects any invalid UTF-8
514
+ * byte sequences before parsing begins. This matches the TOML spec requirement
515
+ * that "A TOML file must be a valid UTF-8 encoded Unicode document."
516
+ *
517
+ * The string path has zero overhead — the bytes path incurs one TextDecoder
518
+ * decode (which also produces the string needed for parsing).
519
+ *
520
+ * By default (`options.integersAsBigInt` unset or `'asNeeded'`), integers that
521
+ * fit within the JavaScript safe-integer range are returned as `number`; integers
522
+ * outside that range are returned as `bigint` to preserve precision. Set
523
+ * `options.integersAsBigInt` to `true` to always return `bigint` for all integers,
524
+ * or `false` to always return `number` (large integers will lose precision).
525
+ *
526
+ * Note: the `'asNeeded'` default is a behavioral change from prior versions (<=1.0.7). If
527
+ * your code serializes the result to JSON or performs arithmetic mixing `number`
528
+ * and `bigint`, set `integersAsBigInt: false` to restore the previous behavior.
529
+ *
530
+ * By default (`options.temporal` unset or `false`), TOML date/time values are
531
+ * returned as custom Date subclasses (LocalDate, LocalTime, LocalDateTime,
532
+ * OffsetDateTime). Set `options.temporal` to `true` to return Temporal API
533
+ * objects instead (Temporal.PlainDate, Temporal.PlainTime, Temporal.PlainDateTime,
534
+ * Temporal.ZonedDateTime). The Temporal API must be available in the runtime.
535
+ *
536
+ * @param value - TOML source as a string or raw UTF-8 bytes
537
+ * @param options - Optional parse options
538
+ * @param options.integersAsBigInt - Controls `bigint` vs `number` for integers.
539
+ * `'asNeeded'` (default) | `true` | `false`
540
+ * @param options.temporal - When true, returns Temporal objects for date/time values.
541
+ * Default: false.
542
+ * @returns The parsed JavaScript object
543
+ */
544
+ export declare function parse(value: string | Uint8Array, options?: ParseOptions): any;
545
+ /**
546
+ * Converts a JavaScript object to a TOML string.
547
+ *
548
+ * @param value - The JavaScript object to stringify
549
+ * @param format - Optional formatting options for the resulting TOML
550
+ * @returns The stringified TOML representation
551
+ */
552
+ export declare function stringify(value: any, format?: Partial<TomlFormat> | TomlFormat): string;
553
+ /**
554
+ * Parses a TOML string or raw UTF-8 bytes into a {@link TomlDocument}.
555
+ *
556
+ * This is a convenience alternative to `new TomlDocument(value, options)`.
557
+ *
558
+ * @param value - TOML source as a string or raw UTF-8 bytes
559
+ * @param options - Optional parse options
560
+ * @returns A {@link TomlDocument} representing the parsed TOML
561
+ */
562
+ export declare function parseDocument(value: string | Uint8Array, options?: ParseOptions): TomlDocument;
563
+ //#endregion
564
+ export { type IntegersAsBigInt, type MultilineContainerMode, type ParseOptions, patch };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@decimalturn/toml-patch",
3
- "version": "3.3.1-lite",
4
- "description": "Patch, parse, and stringify TOML while preserving comments, whitespace and formatting. Lite value-editing distribution.",
3
+ "version": "3.3.2-dev",
4
+ "description": "Patch, parse, and stringify TOML while preserving comments, whitespace and formatting.",
5
5
  "homepage": "https://github.com/DecimalTurn/toml-patch",
6
6
  "repository": {
7
7
  "type": "git",
@@ -13,15 +13,20 @@
13
13
  "node": ">=16"
14
14
  },
15
15
  "sideEffects": false,
16
- "types": "./dist/patch.d.ts",
16
+ "types": "./dist/toml-patch.d.ts",
17
17
  "files": [
18
18
  "dist/"
19
19
  ],
20
20
  "exports": {
21
21
  ".": {
22
- "types": "./dist/patch.d.ts",
23
- "import": "./dist/patch.js",
24
- "default": "./dist/patch.js"
22
+ "types": "./dist/toml-patch.d.ts",
23
+ "import": "./dist/dev/toml-patch.js",
24
+ "default": "./dist/dev/toml-patch.js"
25
+ },
26
+ "./patch-lite": {
27
+ "types": "./dist/patch-lite.d.ts",
28
+ "import": "./dist/dev/patch-lite.js",
29
+ "default": "./dist/dev/patch-lite.js"
25
30
  }
26
31
  },
27
32
  "publishConfig": {