@decimalturn/toml-patch 3.1.0-dev → 3.1.1-dev
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dev/comment-alignment.js +1 -1
- package/dist/dev/comment-ownership.js +62 -62
- package/dist/dev/comment-ownership.js.map +1 -1
- package/dist/dev/cst-source.js +1 -1
- package/dist/dev/cst.js +1 -1
- package/dist/dev/cursor.js +1 -1
- package/dist/dev/date-format.js +1 -1
- package/dist/dev/decode-utf8.js +1 -1
- package/dist/dev/diff.js +1 -1
- package/dist/dev/escape-preference.js +1 -1
- package/dist/dev/find-by-path.js +1 -1
- package/dist/dev/formatter.js +1 -1
- package/dist/dev/generate.js +1 -1
- package/dist/dev/inline-comma-space.js +1 -1
- package/dist/dev/inline-format.js +1 -1
- package/dist/dev/inline-layout.js +1 -1
- package/dist/dev/line-ending-backslash.js +1 -1
- package/dist/dev/location.js +30 -3
- package/dist/dev/location.js.map +1 -1
- package/dist/dev/parse-error.js +1 -1
- package/dist/dev/parse-js.js +1 -1
- package/dist/dev/parse-string.js +1 -1
- package/dist/dev/parse-toml.js +18 -10
- package/dist/dev/parse-toml.js.map +1 -1
- package/dist/dev/patch.js +27 -27
- package/dist/dev/patch.js.map +1 -1
- package/dist/dev/to-js.js +1 -1
- package/dist/dev/to-toml.js +1 -1
- package/dist/dev/tokenizer.js +1 -1
- package/dist/dev/toml-document.js +1 -1
- package/dist/dev/toml-format.js +1 -1
- package/dist/dev/toml-patch.js +1 -1
- package/dist/dev/traverse.js +1 -1
- package/dist/dev/truncate.js +1 -1
- package/dist/dev/update-order.js +21 -21
- package/dist/dev/update-order.js.map +1 -1
- package/dist/dev/utils.js +1 -1
- package/dist/dev/writer.js +1 -1
- package/dist/toml-patch.d.ts +10 -10
- package/package.json +1 -1
package/dist/dev/to-js.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//! @decimalturn/toml-patch v3.1.
|
|
1
|
+
//! @decimalturn/toml-patch v3.1.1 - https://github.com/DecimalTurn/toml-patch - @license: MIT
|
|
2
2
|
import ParseError from "./parse-error.js";
|
|
3
3
|
import { LocalDate, LocalDateTime, LocalTime, OffsetDateTime } from "./date-format.js";
|
|
4
4
|
import { blank, has, isDate, last } from "./utils.js";
|
package/dist/dev/to-toml.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//! @decimalturn/toml-patch v3.1.
|
|
1
|
+
//! @decimalturn/toml-patch v3.1.1 - https://github.com/DecimalTurn/toml-patch - @license: MIT
|
|
2
2
|
import { hasItem, hasItems, isInlineArray, isInlineItem, isInlineTable, isKeyValue, isTable, isTableArray } from "./cst.js";
|
|
3
3
|
import { getCommaSpace } from "./inline-comma-space.js";
|
|
4
4
|
import { getNodeSource, originalFirstChildStartedAfterOpener, sourceStructureUnchanged } from "./cst-source.js";
|
package/dist/dev/tokenizer.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//! @decimalturn/toml-patch v3.1.
|
|
1
|
+
//! @decimalturn/toml-patch v3.1.1 - https://github.com/DecimalTurn/toml-patch - @license: MIT
|
|
2
2
|
import { findPosition } from "./location.js";
|
|
3
3
|
import ParseError from "./parse-error.js";
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//! @decimalturn/toml-patch v3.1.
|
|
1
|
+
//! @decimalturn/toml-patch v3.1.1 - https://github.com/DecimalTurn/toml-patch - @license: MIT
|
|
2
2
|
import parseTOML, { continueParsingTOML } from "./parse-toml.js";
|
|
3
3
|
import { isObject } from "./utils.js";
|
|
4
4
|
import { decodeUtf8Bytes, hasLeadingBom, stripLeadingBom } from "./decode-utf8.js";
|
package/dist/dev/toml-format.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//! @decimalturn/toml-patch v3.1.
|
|
1
|
+
//! @decimalturn/toml-patch v3.1.1 - https://github.com/DecimalTurn/toml-patch - @license: MIT
|
|
2
2
|
import parseTOML from "./parse-toml.js";
|
|
3
3
|
import { hasLeadingBom, stripLeadingBom } from "./decode-utf8.js";
|
|
4
4
|
|
package/dist/dev/toml-patch.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//! @decimalturn/toml-patch v3.1.
|
|
1
|
+
//! @decimalturn/toml-patch v3.1.1 - https://github.com/DecimalTurn/toml-patch - @license: MIT
|
|
2
2
|
import { LocalDate, LocalDateTime, LocalTime, OffsetDateTime } from "./date-format.js";
|
|
3
3
|
import parseTOML from "./parse-toml.js";
|
|
4
4
|
import { decodeUtf8Bytes, stripLeadingBom } from "./decode-utf8.js";
|
package/dist/dev/traverse.js
CHANGED
package/dist/dev/truncate.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//! @decimalturn/toml-patch v3.1.
|
|
1
|
+
//! @decimalturn/toml-patch v3.1.1 - https://github.com/DecimalTurn/toml-patch - @license: MIT
|
|
2
2
|
//#region src/truncate.ts
|
|
3
3
|
/**
|
|
4
4
|
* Compares two positions to determine their ordering.
|
package/dist/dev/update-order.js
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
//! @decimalturn/toml-patch v3.1.
|
|
1
|
+
//! @decimalturn/toml-patch v3.1.1 - https://github.com/DecimalTurn/toml-patch - @license: MIT
|
|
2
2
|
import { hasItem, isDocument, isInlineItem, isKeyValue, isTable, isTableArray } from "./cst.js";
|
|
3
3
|
import { recalcContainerEnd, shiftNode } from "./writer.js";
|
|
4
4
|
import { tryFindByPath } from "./find-by-path.js";
|
|
5
|
-
import { normalizeSectionComments,
|
|
5
|
+
import { normalizeSectionComments, resolveGroups } from "./comment-ownership.js";
|
|
6
6
|
|
|
7
7
|
//#region src/update-order.ts
|
|
8
|
-
function buildUnits(
|
|
8
|
+
function buildUnits(groups) {
|
|
9
9
|
const units = [];
|
|
10
|
-
for (const
|
|
11
|
-
if (
|
|
10
|
+
for (const group of groups) {
|
|
11
|
+
if (group.kind === "pinned") {
|
|
12
12
|
units.push({
|
|
13
13
|
kind: "pinned",
|
|
14
14
|
isSection: false,
|
|
15
15
|
movable: false,
|
|
16
|
-
|
|
17
|
-
startLine:
|
|
18
|
-
endLine:
|
|
19
|
-
items:
|
|
16
|
+
groups: [group],
|
|
17
|
+
startLine: group.startLine,
|
|
18
|
+
endLine: group.endLine,
|
|
19
|
+
items: group.items
|
|
20
20
|
});
|
|
21
21
|
continue;
|
|
22
22
|
}
|
|
23
|
-
const isSection = isTable(
|
|
23
|
+
const isSection = isTable(group.member) || isTableArray(group.member);
|
|
24
24
|
const previous = units[units.length - 1];
|
|
25
|
-
if (previous && previous.kind === "member" &&
|
|
26
|
-
previous.
|
|
27
|
-
previous.endLine =
|
|
28
|
-
previous.items = previous.items.concat(
|
|
25
|
+
if (previous && previous.kind === "member" && group.key !== void 0 && previous.key === group.key) {
|
|
26
|
+
previous.groups.push(group);
|
|
27
|
+
previous.endLine = group.endLine;
|
|
28
|
+
previous.items = previous.items.concat(group.items);
|
|
29
29
|
continue;
|
|
30
30
|
}
|
|
31
31
|
units.push({
|
|
32
32
|
kind: "member",
|
|
33
|
-
key:
|
|
33
|
+
key: group.key,
|
|
34
34
|
isSection,
|
|
35
|
-
movable:
|
|
36
|
-
|
|
37
|
-
startLine:
|
|
38
|
-
endLine:
|
|
39
|
-
items: [...
|
|
35
|
+
movable: group.key !== void 0,
|
|
36
|
+
groups: [group],
|
|
37
|
+
startLine: group.startLine,
|
|
38
|
+
endLine: group.endLine,
|
|
39
|
+
items: [...group.items]
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
42
|
const countByKey = /* @__PURE__ */ new Map();
|
|
@@ -133,7 +133,7 @@ function isNewMoveTarget(document, move, commentEligibleNodes) {
|
|
|
133
133
|
return target !== void 0 && isInlineItem(target) && !commentEligibleNodes.has(target);
|
|
134
134
|
}
|
|
135
135
|
function applyContainerMoves(container, moves, commentEligibleNodes, warnings, dottedPrefix) {
|
|
136
|
-
const units = buildUnits(
|
|
136
|
+
const units = buildUnits(resolveGroups(container, (node) => commentEligibleNodes.has(node), dottedPrefix ? (member) => {
|
|
137
137
|
if (!isKeyValue(member)) return void 0;
|
|
138
138
|
const key = member.key.value;
|
|
139
139
|
if (key.length !== dottedPrefix.length + 1) return void 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-order.js","names":[],"sources":["../../src/update-order.ts"],"sourcesContent":["import {\n Document,\n Table,\n TableArray,\n TreeNode,\n isDocument,\n isTable,\n isTableArray,\n isKeyValue,\n isInlineItem,\n hasItem\n} from './cst';\nimport { Move } from './diff';\nimport { Path, tryFindByPath } from './find-by-path';\nimport { resolveSlots, normalizeSectionComments, Slot } from './comment-ownership';\nimport { shiftNode, recalcContainerEnd } from './writer';\n\n/**\n * A resolved, orderable unit within a container: either one member slot, or — when the same\n * key resolves to more than one CONSECUTIVE member slot (an [[array-of-tables]]'s entries, or\n * a [table] immediately followed by its own [table.sub]) — all of them coalesced into one\n * group that moves as a rigid block, preserving their own relative order. Pinned slots (no\n * key) are never coalesced and never reordered; see `movable` below.\n */\ninterface Unit {\n kind: 'member' | 'pinned';\n key?: string;\n isSection: boolean;\n /** False for pinned units, and for member units whose key maps to more than one\n * NON-contiguous group (the dotted-key / non-contiguous-document-group hazard) — both\n * are treated as fixed anchors: never reordered, always left exactly where they are. */\n movable: boolean;\n slots: Slot[];\n startLine: number;\n endLine: number;\n items: TreeNode[];\n}\n\nfunction buildUnits(slots: Slot[]): Unit[] {\n const units: Unit[] = [];\n\n for (const slot of slots) {\n if (slot.kind === 'pinned') {\n units.push({\n kind: 'pinned',\n isSection: false,\n movable: false,\n slots: [slot],\n startLine: slot.startLine,\n endLine: slot.endLine,\n items: slot.items\n });\n continue;\n }\n\n const isSection = isTable(slot.member!) || isTableArray(slot.member!);\n const previous = units[units.length - 1];\n if (previous && previous.kind === 'member' && slot.key !== undefined && previous.key === slot.key) {\n // Contiguous run sharing the same first key segment (AOT entries, or [a] then\n // [a.sub]) — coalesce into one unit that will move together.\n previous.slots.push(slot);\n previous.endLine = slot.endLine;\n previous.items = previous.items.concat(slot.items);\n continue;\n }\n\n units.push({\n kind: 'member',\n key: slot.key,\n isSection,\n movable: slot.key !== undefined, // corrected below once every unit for this container is known\n slots: [slot],\n startLine: slot.startLine,\n endLine: slot.endLine,\n items: [...slot.items]\n });\n }\n\n // A key that resolves to more than one, NON-contiguous unit (e.g. `hello.world` / `b` /\n // `hello.moon`) can't be safely reordered: resolveSlots has no way to represent \"hello\" as\n // a single relocatable thing when another key sits between its occurrences. Bail on moving\n // any of them — \"did nothing\" is the safe failure mode (docs/PLAN-Update-Order.md, Scope).\n const countByKey = new Map<string, number>();\n for (const unit of units) {\n if (unit.kind !== 'member' || unit.key === undefined) continue;\n countByKey.set(unit.key, (countByKey.get(unit.key) ?? 0) + 1);\n }\n for (const unit of units) {\n if (unit.kind === 'member' && unit.key !== undefined && countByKey.get(unit.key)! > 1) {\n unit.movable = false;\n }\n }\n\n return units;\n}\n\n/** Replays `moves` against `currentOrder` using the same simulate-and-splice approach\n * compareObjects used to generate them, reconstructing the full requested key order. */\nfunction computeTargetOrder(currentOrder: string[], moves: Move[]): string[] {\n const sim = [...currentOrder];\n for (const move of moves) {\n if (move.key === undefined) continue;\n const from = sim.indexOf(move.key);\n if (from === -1) continue; // not one of this container's movable keys\n const to = Math.max(0, Math.min(move.to, sim.length - 1));\n if (from === to) continue;\n sim.splice(from, 1);\n sim.splice(to, 0, move.key);\n }\n return sim;\n}\n\n/** Full dotted path to the entry a Move targets (its container path plus its own key), for\n * warning messages -- clearer than the bare key alone once anything is nested more than one\n * level deep (e.g. \"t.hello.moon\" rather than just \"moon\"). */\nfunction describeMovePath(move: Move): string {\n return [...move.path, move.key].join('.');\n}\n\n/** Resolves a Move's `path` to the Document/Table/TableArray it targets, unwrapping a\n * KeyValue/InlineItem wrapper if `tryFindByPath` returns one. Dotted-key members inside an\n * AOT entry are returned with a scoped prefix so they can be reordered in that entry. */\ninterface ResolvedContainer {\n container: Document | Table | TableArray;\n dottedPrefix?: string[];\n}\n\nfunction resolveImplicitDottedContainer(\n document: Document,\n path: Path,\n moveKey: string,\n commentEligibleNodes: WeakSet<TreeNode>\n): ResolvedContainer | undefined {\n if (path.some(segment => typeof segment !== 'string')) return undefined;\n\n const target = [...path, moveKey];\n const candidates: { container: Document | Table | TableArray; prefix: string[] }[] = [\n { container: document, prefix: [] }\n ];\n\n for (const item of document.items as TreeNode[]) {\n if (isTable(item) || isTableArray(item)) {\n candidates.push({ container: item, prefix: item.key.item.value });\n }\n }\n\n for (const candidate of candidates) {\n for (const item of candidate.container.items as TreeNode[]) {\n if (!isKeyValue(item) || item.key.value.length < 2) continue;\n if (commentEligibleNodes.has(item)) continue;\n const fullKey = [...candidate.prefix, ...item.key.value];\n if (fullKey.length !== target.length) continue;\n if (!fullKey.every((segment, index) => segment === target[index])) continue;\n return { container: candidate.container, dottedPrefix: item.key.value.slice(0, -1) };\n }\n }\n\n return undefined;\n}\n\nfunction resolveContainer(\n document: Document,\n path: Path,\n moveKey: string | undefined,\n commentEligibleNodes: WeakSet<TreeNode>\n): ResolvedContainer | undefined {\n if (path.length === 0) return { container: document };\n\n let node: TreeNode | undefined;\n try {\n node = tryFindByPath(document, path);\n } catch {\n return undefined;\n }\n if (!node) return undefined;\n\n if (isKeyValue(node)) node = node.value;\n if (node && hasItem(node)) node = node.item;\n\n if (node && (isDocument(node) || isTable(node) || isTableArray(node))) {\n return { container: node };\n }\n\n if (moveKey === undefined) return undefined;\n\n const implicit = resolveImplicitDottedContainer(document, path, moveKey, commentEligibleNodes);\n if (implicit) return implicit;\n\n // A dotted key inside an AOT entry is represented as a KeyValue directly in the\n // entry's items. Its object path contains the AOT index, so resolve the entry first\n // and use the remaining dotted segments as a scoped member prefix.\n let numericIndex = -1;\n for (let i = path.length - 1; i >= 0; i--) {\n if (typeof path[i] === 'number') {\n numericIndex = i;\n break;\n }\n }\n if (numericIndex < 0) return undefined;\n\n const dottedPrefix = path.slice(numericIndex + 1);\n if (dottedPrefix.length === 0 || dottedPrefix.some(segment => typeof segment !== 'string')) {\n return undefined;\n }\n\n const entry = tryFindByPath(document, path.slice(0, numericIndex + 1));\n if (!entry || !isTableArray(entry)) return undefined;\n\n const targetKey = [...dottedPrefix, moveKey];\n const hasTarget = (entry.items as TreeNode[]).some(item =>\n isKeyValue(item) &&\n item.key.value.length === targetKey.length &&\n item.key.value.every((segment, index) => segment === targetKey[index])\n );\n return hasTarget ? { container: entry, dottedPrefix: dottedPrefix as string[] } : undefined;\n}\n\nfunction isNewMoveTarget(\n document: Document,\n move: Move,\n commentEligibleNodes: WeakSet<TreeNode>\n): boolean {\n if (move.key === undefined) return false;\n let target: TreeNode | undefined;\n try {\n target = tryFindByPath(document, move.path.concat(move.key));\n } catch {\n return false;\n }\n return target !== undefined && isInlineItem(target) && !commentEligibleNodes.has(target);\n}\n\nfunction applyContainerMoves(\n container: Document | Table | TableArray,\n moves: Move[],\n commentEligibleNodes: WeakSet<TreeNode>,\n warnings: string[],\n dottedPrefix?: string[]\n): void {\n const memberKey = dottedPrefix\n ? (member: TreeNode): string | undefined => {\n if (!isKeyValue(member)) return undefined;\n const key = member.key.value;\n if (key.length !== dottedPrefix.length + 1) return undefined;\n for (let i = 0; i < dottedPrefix.length; i++) {\n if (key[i] !== dottedPrefix[i]) return undefined;\n }\n return key[dottedPrefix.length];\n }\n : undefined;\n const slots = resolveSlots(container, node => commentEligibleNodes.has(node), memberKey);\n const units = buildUnits(slots);\n\n const movableUnitsByKey = new Map<string, Unit>();\n for (const unit of units) {\n if (unit.kind === 'member' && unit.movable && unit.key !== undefined) {\n movableUnitsByKey.set(unit.key, unit);\n }\n }\n\n // Warn about any requested move whose key genuinely exists here as a member but was marked\n // unmovable by buildUnits (a non-contiguous group) -- the caller asked for a specific\n // position and it was silently left exactly where it was.\n const memberKeys = new Set(\n units.filter(u => u.kind === 'member' && u.key !== undefined).map(u => u.key!)\n );\n for (const move of moves) {\n if (move.key !== undefined && memberKeys.has(move.key) && !movableUnitsByKey.has(move.key)) {\n warnings.push(\n `\"${describeMovePath(move)}\" -- its entries are not contiguous in the document (e.g. the ` +\n `TOML spec's own \"valid but discouraged\" out-of-order table pattern), so reordering was ` +\n `skipped for it`\n );\n }\n }\n\n if (movableUnitsByKey.size === 0) return; // nothing this container can safely reorder\n\n // Move.from/to are indices in the object whose order was diffed. For a scoped AOT move,\n // that object contains only the dotted members under `dottedPrefix`, not every row in the\n // AOT entry. Simulating against unrelated rows would therefore interpret `move.to` in the\n // wrong index space. The final placement below still walks every unit, keeping unrelated\n // rows and pinned slots at their original positions.\n const currentOrder = dottedPrefix\n ? units\n .filter(u => u.kind === 'member' && u.movable)\n .map(u => u.key!)\n : units\n .filter(u => u.kind === 'member')\n .map((u, index) => u.movable ? u.key! : `\\u0000anchor:${index}`);\n\n const relevantMoves = moves.filter(m => m.key !== undefined && movableUnitsByKey.has(m.key));\n if (relevantMoves.length === 0) return;\n\n const targetOrder = computeTargetOrder(currentOrder, relevantMoves)\n .filter(k => movableUnitsByKey.has(k));\n\n // Validity partition (docs/PLAN-Update-Order.md, Scope): a root key-value can never appear\n // after a section header. Root-KV positions and section positions are fixed by the\n // ORIGINAL structure (that's what made them root-KVs vs sections in the first place) —\n // only WHICH key fills each position-of-its-kind is being decided here.\n const rootKvTargetOrder = targetOrder.filter(k => !movableUnitsByKey.get(k)!.isSection);\n const sectionTargetOrder = targetOrder.filter(k => movableUnitsByKey.get(k)!.isSection);\n\n // Warn when the requested order itself asked for a root key-value to land after a section\n // header -- structurally impossible, so each partition falls back to keeping its own\n // requested relative order instead of the literal interleaving that was asked for.\n let sawSection = false;\n for (const key of targetOrder) {\n if (movableUnitsByKey.get(key)!.isSection) {\n sawSection = true;\n } else if (sawSection) {\n warnings.push(\n 'the requested order asked for a root key-value to be positioned after a section header, ' +\n 'which TOML cannot represent -- each group (root key-values, section blocks) was reordered ' +\n 'to match its own requested relative order instead'\n );\n break;\n }\n }\n\n let rootKvCursor = 0;\n let sectionCursor = 0;\n const finalUnits: Unit[] = units.map(unit => {\n if (unit.kind !== 'member' || !unit.movable) return unit;\n const key = unit.isSection ? sectionTargetOrder[sectionCursor++] : rootKvTargetOrder[rootKvCursor++];\n return movableUnitsByKey.get(key)!;\n });\n\n // Nothing to do if the permutation is the identity.\n if (finalUnits.every((u, i) => u === units[i])) return;\n\n // Precompute each POSITION's own gap (number of blank lines before it), before permuting —\n // gaps belong to the position, not to whichever unit ends up there (docs/PLAN-Update-Order.md\n // §3.3 Step 6): this is what makes \"0 within a run, 1 between sections\" fall out for free\n // regardless of which specific key now occupies a given position.\n const containerFirstLine = isDocument(container) ? 1 : container.key.loc.end.line;\n const gapBefore: number[] = units.map((unit, i) => {\n if (i === 0) return unit.startLine - containerFirstLine;\n return unit.startLine - units[i - 1].endLine - 1;\n });\n\n let cursorEnd = containerFirstLine; // end line of whatever was placed immediately before\n for (let i = 0; i < finalUnits.length; i++) {\n const unit = finalUnits[i];\n const gap = gapBefore[i];\n const newStart = (i === 0 ? cursorEnd : cursorEnd + 1) + gap;\n const delta = newStart - unit.startLine;\n\n if (delta !== 0) {\n for (const item of unit.items) {\n shiftNode(item, { lines: delta, columns: 0 });\n }\n }\n\n cursorEnd = unit.endLine + delta;\n }\n\n const newItems = finalUnits.flatMap(u => u.items);\n const items = container.items as TreeNode[];\n items.splice(0, items.length, ...(newItems as any[]));\n\n recalcContainerEnd(container);\n}\n\n/**\n * Reorders `document`'s root key-values, [table]/[[array]] section blocks, and table-body\n * rows to match `moves` (object-key Moves collected from the isMove branch in patch.ts),\n * carrying each entry's owned comments with it. See docs/PLAN-Update-Order.md.\n *\n * Must run after every other structural change in this patch has already been applied to\n * `document` (Add/Remove/Rename/array-Move/structural-edit) — it does no insertion or\n * deletion of its own, only permutes and relays out what's already there.\n */\nexport function applyKeyOrderMoves(document: Document, moves: Move[], commentEligibleNodes: WeakSet<TreeNode>): void {\n if (moves.length === 0) return;\n\n // R5: a comment that visually introduces the next section but is physically parked as a\n // trailing item of the previous one must be re-parented before slots are resolved, or it\n // travels with the wrong block.\n normalizeSectionComments(document);\n\n // Collects every requested reposition this pass couldn't honor, across every container, so\n // a single consolidated console.warn can report them at the end (docs/PLAN-Update-Order.md\n // scope limitations: non-contiguous groups, the root-KV/section validity partition, and\n // shapes reordering doesn't reach yet at all -- inline-table interiors, dotted-key implicit\n // tables outside an AOT entry, and AOT-entry sub-tables. \"Did nothing\" for the affected entry is\n // the safe failure mode in every case; this only makes that silence visible to the caller.\n const warnings: string[] = [];\n\n const movesByContainer = new Map<\n Document | Table | TableArray,\n Map<string, ResolvedContainer & { moves: Move[] }>\n >();\n for (const move of moves) {\n if (move.key === undefined) continue;\n const resolved = resolveContainer(document, move.path, move.key, commentEligibleNodes);\n if (!resolved) {\n if (isNewMoveTarget(document, move, commentEligibleNodes)) continue;\n // Never throw — this is reached for shapes updateOrder doesn't support at all yet:\n // dotted-key implicit tables outside an AOT entry, inline-table interiors, and\n // AOT-entry sub-tables only reachable via document-sibling scanning.\n warnings.push(\n `\"${describeMovePath(move)}\" -- unsupported location for reordering (e.g. a dotted-key ` +\n `implicit table, or an interior of an inline table/array-of-tables entry)`\n );\n continue;\n }\n const scopeKey = resolved.dottedPrefix?.join('\\u0000') ?? '';\n let scopedMoves = movesByContainer.get(resolved.container);\n if (!scopedMoves) {\n scopedMoves = new Map();\n movesByContainer.set(resolved.container, scopedMoves);\n }\n const bucket = scopedMoves.get(scopeKey);\n if (bucket) bucket.moves.push(move);\n else scopedMoves.set(scopeKey, { ...resolved, moves: [move] });\n }\n\n for (const scopedMoves of movesByContainer.values()) {\n for (const target of scopedMoves.values()) {\n applyContainerMoves(target.container, target.moves, commentEligibleNodes, warnings, target.dottedPrefix);\n }\n }\n\n if (warnings.length > 0) {\n const unique = [...new Set(warnings)];\n console.warn(\n `toml-patch: updateOrder could not honor the requested position for ` +\n `${unique.length === 1 ? '1 entry' : `${unique.length} entries`}, left unchanged:\\n` +\n unique.map(w => ` - ${w}`).join('\\n')\n );\n }\n\n recalcContain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GAAG;EACvB,MAAM,SAAS,CAAC,GAAG,IAAI,IAAI,QAAQ,CAAC;EACpC,QAAQ,KACN,sEACG,OAAO,WAAW,IAAI,YAAY,GAAG,OAAO,OAAO,UAAU,uBAChE,OAAO,KAAI,MAAK,OAAO,GAAG,CAAC,CAAC,KAAK,IAAI,CACvC;CACF;CAEA,mBAAmB,QAAQ;AAC7B"}
|
|
1
|
+
{"version":3,"file":"update-order.js","names":[],"sources":["../../src/update-order.ts"],"sourcesContent":["import {\n Document,\n Table,\n TableArray,\n TreeNode,\n isDocument,\n isTable,\n isTableArray,\n isKeyValue,\n isInlineItem,\n hasItem\n} from './cst';\nimport { Move } from './diff';\nimport { Path, tryFindByPath } from './find-by-path';\nimport { resolveGroups, normalizeSectionComments, Group } from './comment-ownership';\nimport { shiftNode, recalcContainerEnd } from './writer';\n\n/**\n * A resolved, orderable unit within a container: either one member group, or — when the same\n * key resolves to more than one CONSECUTIVE member group (an [[array-of-tables]]'s entries, or\n * a [table] immediately followed by its own [table.sub]) — all of them coalesced into one\n * unit that moves as a rigid block, preserving their own relative order. Pinned groups (no\n * key) are never coalesced and never reordered; see `movable` below.\n */\ninterface Unit {\n kind: 'member' | 'pinned';\n key?: string;\n isSection: boolean;\n /** False for pinned units, and for member units whose key maps to more than one\n * NON-contiguous group (the dotted-key / non-contiguous-document-group hazard) — both\n * are treated as fixed anchors: never reordered, always left exactly where they are. */\n movable: boolean;\n groups: Group[];\n startLine: number;\n endLine: number;\n items: TreeNode[];\n}\n\nfunction buildUnits(groups: Group[]): Unit[] {\n const units: Unit[] = [];\n\n for (const group of groups) {\n if (group.kind === 'pinned') {\n units.push({\n kind: 'pinned',\n isSection: false,\n movable: false,\n groups: [group],\n startLine: group.startLine,\n endLine: group.endLine,\n items: group.items\n });\n continue;\n }\n\n const isSection = isTable(group.member!) || isTableArray(group.member!);\n const previous = units[units.length - 1];\n if (previous && previous.kind === 'member' && group.key !== undefined && previous.key === group.key) {\n // Contiguous run sharing the same first key segment (AOT entries, or [a] then\n // [a.sub]) — coalesce into one unit that will move together.\n previous.groups.push(group);\n previous.endLine = group.endLine;\n previous.items = previous.items.concat(group.items);\n continue;\n }\n\n units.push({\n kind: 'member',\n key: group.key,\n isSection,\n movable: group.key !== undefined, // corrected below once every unit for this container is known\n groups: [group],\n startLine: group.startLine,\n endLine: group.endLine,\n items: [...group.items]\n });\n }\n\n // A key that resolves to more than one, NON-contiguous unit (e.g. `hello.world` / `b` /\n // `hello.moon`) can't be safely reordered: resolveGroups has no way to represent \"hello\" as\n // a single relocatable thing when another key sits between its occurrences. Bail on moving\n // any of them — \"did nothing\" is the safe failure mode (docs/PLAN-Update-Order.md, Scope).\n const countByKey = new Map<string, number>();\n for (const unit of units) {\n if (unit.kind !== 'member' || unit.key === undefined) continue;\n countByKey.set(unit.key, (countByKey.get(unit.key) ?? 0) + 1);\n }\n for (const unit of units) {\n if (unit.kind === 'member' && unit.key !== undefined && countByKey.get(unit.key)! > 1) {\n unit.movable = false;\n }\n }\n\n return units;\n}\n\n/** Replays `moves` against `currentOrder` using the same simulate-and-splice approach\n * compareObjects used to generate them, reconstructing the full requested key order. */\nfunction computeTargetOrder(currentOrder: string[], moves: Move[]): string[] {\n const sim = [...currentOrder];\n for (const move of moves) {\n if (move.key === undefined) continue;\n const from = sim.indexOf(move.key);\n if (from === -1) continue; // not one of this container's movable keys\n const to = Math.max(0, Math.min(move.to, sim.length - 1));\n if (from === to) continue;\n sim.splice(from, 1);\n sim.splice(to, 0, move.key);\n }\n return sim;\n}\n\n/** Full dotted path to the entry a Move targets (its container path plus its own key), for\n * warning messages -- clearer than the bare key alone once anything is nested more than one\n * level deep (e.g. \"t.hello.moon\" rather than just \"moon\"). */\nfunction describeMovePath(move: Move): string {\n return [...move.path, move.key].join('.');\n}\n\n/** Resolves a Move's `path` to the Document/Table/TableArray it targets, unwrapping a\n * KeyValue/InlineItem wrapper if `tryFindByPath` returns one. Dotted-key members inside an\n * AOT entry are returned with a scoped prefix so they can be reordered in that entry. */\ninterface ResolvedContainer {\n container: Document | Table | TableArray;\n dottedPrefix?: string[];\n}\n\nfunction resolveImplicitDottedContainer(\n document: Document,\n path: Path,\n moveKey: string,\n commentEligibleNodes: WeakSet<TreeNode>\n): ResolvedContainer | undefined {\n if (path.some(segment => typeof segment !== 'string')) return undefined;\n\n const target = [...path, moveKey];\n const candidates: { container: Document | Table | TableArray; prefix: string[] }[] = [\n { container: document, prefix: [] }\n ];\n\n for (const item of document.items as TreeNode[]) {\n if (isTable(item) || isTableArray(item)) {\n candidates.push({ container: item, prefix: item.key.item.value });\n }\n }\n\n for (const candidate of candidates) {\n for (const item of candidate.container.items as TreeNode[]) {\n if (!isKeyValue(item) || item.key.value.length < 2) continue;\n if (commentEligibleNodes.has(item)) continue;\n const fullKey = [...candidate.prefix, ...item.key.value];\n if (fullKey.length !== target.length) continue;\n if (!fullKey.every((segment, index) => segment === target[index])) continue;\n return { container: candidate.container, dottedPrefix: item.key.value.slice(0, -1) };\n }\n }\n\n return undefined;\n}\n\nfunction resolveContainer(\n document: Document,\n path: Path,\n moveKey: string | undefined,\n commentEligibleNodes: WeakSet<TreeNode>\n): ResolvedContainer | undefined {\n if (path.length === 0) return { container: document };\n\n let node: TreeNode | undefined;\n try {\n node = tryFindByPath(document, path);\n } catch {\n return undefined;\n }\n if (!node) return undefined;\n\n if (isKeyValue(node)) node = node.value;\n if (node && hasItem(node)) node = node.item;\n\n if (node && (isDocument(node) || isTable(node) || isTableArray(node))) {\n return { container: node };\n }\n\n if (moveKey === undefined) return undefined;\n\n const implicit = resolveImplicitDottedContainer(document, path, moveKey, commentEligibleNodes);\n if (implicit) return implicit;\n\n // A dotted key inside an AOT entry is represented as a KeyValue directly in the\n // entry's items. Its object path contains the AOT index, so resolve the entry first\n // and use the remaining dotted segments as a scoped member prefix.\n let numericIndex = -1;\n for (let i = path.length - 1; i >= 0; i--) {\n if (typeof path[i] === 'number') {\n numericIndex = i;\n break;\n }\n }\n if (numericIndex < 0) return undefined;\n\n const dottedPrefix = path.slice(numericIndex + 1);\n if (dottedPrefix.length === 0 || dottedPrefix.some(segment => typeof segment !== 'string')) {\n return undefined;\n }\n\n const entry = tryFindByPath(document, path.slice(0, numericIndex + 1));\n if (!entry || !isTableArray(entry)) return undefined;\n\n const targetKey = [...dottedPrefix, moveKey];\n const hasTarget = (entry.items as TreeNode[]).some(item =>\n isKeyValue(item) &&\n item.key.value.length === targetKey.length &&\n item.key.value.every((segment, index) => segment === targetKey[index])\n );\n return hasTarget ? { container: entry, dottedPrefix: dottedPrefix as string[] } : undefined;\n}\n\nfunction isNewMoveTarget(\n document: Document,\n move: Move,\n commentEligibleNodes: WeakSet<TreeNode>\n): boolean {\n if (move.key === undefined) return false;\n let target: TreeNode | undefined;\n try {\n target = tryFindByPath(document, move.path.concat(move.key));\n } catch {\n return false;\n }\n return target !== undefined && isInlineItem(target) && !commentEligibleNodes.has(target);\n}\n\nfunction applyContainerMoves(\n container: Document | Table | TableArray,\n moves: Move[],\n commentEligibleNodes: WeakSet<TreeNode>,\n warnings: string[],\n dottedPrefix?: string[]\n): void {\n const memberKey = dottedPrefix\n ? (member: TreeNode): string | undefined => {\n if (!isKeyValue(member)) return undefined;\n const key = member.key.value;\n if (key.length !== dottedPrefix.length + 1) return undefined;\n for (let i = 0; i < dottedPrefix.length; i++) {\n if (key[i] !== dottedPrefix[i]) return undefined;\n }\n return key[dottedPrefix.length];\n }\n : undefined;\n const groups = resolveGroups(container, node => commentEligibleNodes.has(node), memberKey);\n const units = buildUnits(groups);\n\n const movableUnitsByKey = new Map<string, Unit>();\n for (const unit of units) {\n if (unit.kind === 'member' && unit.movable && unit.key !== undefined) {\n movableUnitsByKey.set(unit.key, unit);\n }\n }\n\n // Warn about any requested move whose key genuinely exists here as a member but was marked\n // unmovable by buildUnits (a non-contiguous group) -- the caller asked for a specific\n // position and it was silently left exactly where it was.\n const memberKeys = new Set(\n units.filter(u => u.kind === 'member' && u.key !== undefined).map(u => u.key!)\n );\n for (const move of moves) {\n if (move.key !== undefined && memberKeys.has(move.key) && !movableUnitsByKey.has(move.key)) {\n warnings.push(\n `\"${describeMovePath(move)}\" -- its entries are not contiguous in the document (e.g. the ` +\n `TOML spec's own \"valid but discouraged\" out-of-order table pattern), so reordering was ` +\n `skipped for it`\n );\n }\n }\n\n if (movableUnitsByKey.size === 0) return; // nothing this container can safely reorder\n\n // Move.from/to are indices in the object whose order was diffed. For a scoped AOT move,\n // that object contains only the dotted members under `dottedPrefix`, not every row in the\n // AOT entry. Simulating against unrelated rows would therefore interpret `move.to` in the\n // wrong index space. The final placement below still walks every unit, keeping unrelated\n // rows and pinned groups at their original positions.\n const currentOrder = dottedPrefix\n ? units\n .filter(u => u.kind === 'member' && u.movable)\n .map(u => u.key!)\n : units\n .filter(u => u.kind === 'member')\n .map((u, index) => u.movable ? u.key! : `\\u0000anchor:${index}`);\n\n const relevantMoves = moves.filter(m => m.key !== undefined && movableUnitsByKey.has(m.key));\n if (relevantMoves.length === 0) return;\n\n const targetOrder = computeTargetOrder(currentOrder, relevantMoves)\n .filter(k => movableUnitsByKey.has(k));\n\n // Validity partition (docs/PLAN-Update-Order.md, Scope): a root key-value can never appear\n // after a section header. Root-KV positions and section positions are fixed by the\n // ORIGINAL structure (that's what made them root-KVs vs sections in the first place) —\n // only WHICH key fills each position-of-its-kind is being decided here.\n const rootKvTargetOrder = targetOrder.filter(k => !movableUnitsByKey.get(k)!.isSection);\n const sectionTargetOrder = targetOrder.filter(k => movableUnitsByKey.get(k)!.isSection);\n\n // Warn when the requested order itself asked for a root key-value to land after a section\n // header -- structurally impossible, so each partition falls back to keeping its own\n // requested relative order instead of the literal interleaving that was asked for.\n let sawSection = false;\n for (const key of targetOrder) {\n if (movableUnitsByKey.get(key)!.isSection) {\n sawSection = true;\n } else if (sawSection) {\n warnings.push(\n 'the requested order asked for a root key-value to be positioned after a section header, ' +\n 'which TOML cannot represent -- each group (root key-values, section blocks) was reordered ' +\n 'to match its own requested relative order instead'\n );\n break;\n }\n }\n\n let rootKvCursor = 0;\n let sectionCursor = 0;\n const finalUnits: Unit[] = units.map(unit => {\n if (unit.kind !== 'member' || !unit.movable) return unit;\n const key = unit.isSection ? sectionTargetOrder[sectionCursor++] : rootKvTargetOrder[rootKvCursor++];\n return movableUnitsByKey.get(key)!;\n });\n\n // Nothing to do if the permutation is the identity.\n if (finalUnits.every((u, i) => u === units[i])) return;\n\n // Precompute each POSITION's own gap (number of blank lines before it), before permuting —\n // gaps belong to the position, not to whichever unit ends up there (docs/PLAN-Update-Order.md\n // §3.3 Step 6): this is what makes \"0 within a run, 1 between sections\" fall out for free\n // regardless of which specific key now occupies a given position.\n const containerFirstLine = isDocument(container) ? 1 : container.key.loc.end.line;\n const gapBefore: number[] = units.map((unit, i) => {\n if (i === 0) return unit.startLine - containerFirstLine;\n return unit.startLine - units[i - 1].endLine - 1;\n });\n\n let cursorEnd = containerFirstLine; // end line of whatever was placed immediately before\n for (let i = 0; i < finalUnits.length; i++) {\n const unit = finalUnits[i];\n const gap = gapBefore[i];\n const newStart = (i === 0 ? cursorEnd : cursorEnd + 1) + gap;\n const delta = newStart - unit.startLine;\n\n if (delta !== 0) {\n for (const item of unit.items) {\n shiftNode(item, { lines: delta, columns: 0 });\n }\n }\n\n cursorEnd = unit.endLine + delta;\n }\n\n const newItems = finalUnits.flatMap(u => u.items);\n const items = container.items as TreeNode[];\n items.splice(0, items.length, ...(newItems as any[]));\n\n recalcContainerEnd(container);\n}\n\n/**\n * Reorders `document`'s root key-values, [table]/[[array]] section blocks, and table-body\n * rows to match `moves` (object-key Moves collected from the isMove branch in patch.ts),\n * carrying each entry's owned comments with it. See docs/PLAN-Update-Order.md.\n *\n * Must run after every other structural change in this patch has already been applied to\n * `document` (Add/Remove/Rename/array-Move/structural-edit) — it does no insertion or\n * deletion of its own, only permutes and relays out what's already there.\n */\nexport function applyKeyOrderMoves(document: Document, moves: Move[], commentEligibleNodes: WeakSet<TreeNode>): void {\n if (moves.length === 0) return;\n\n // R5: a comment that visually introduces the next section but is physically parked as a\n // trailing item of the previous one must be re-parented before groups are resolved, or it\n // travels with the wrong block.\n normalizeSectionComments(document);\n\n // Collects every requested reposition this pass couldn't honor, across every container, so\n // a single consolidated console.warn can report them at the end (docs/PLAN-Update-Order.md\n // scope limitations: non-contiguous groups, the root-KV/section validity partition, and\n // shapes reordering doesn't reach yet at all -- inline-table interiors, dotted-key implicit\n // tables outside an AOT entry, and AOT-entry sub-tables. \"Did nothing\" for the affected entry is\n // the safe failure mode in every case; this only makes that silence visible to the caller.\n const warnings: string[] = [];\n\n const movesByContainer = new Map<\n Document | Table | TableArray,\n Map<string, ResolvedContainer & { moves: Move[] }>\n >();\n for (const move of moves) {\n if (move.key === undefined) continue;\n const resolved = resolveContainer(document, move.path, move.key, commentEligibleNodes);\n if (!resolved) {\n if (isNewMoveTarget(document, move, commentEligibleNodes)) continue;\n // Never throw — this is reached for shapes updateOrder doesn't support at all yet:\n // dotted-key implicit tables outside an AOT entry, inline-table interiors, and\n // AOT-entry sub-tables only reachable via document-sibling scanning.\n warnings.push(\n `\"${describeMovePath(move)}\" -- unsupported location for reordering (e.g. a dotted-key ` +\n `implicit table, or an interior of an inline table/array-of-tables entry)`\n );\n continue;\n }\n const scopeKey = resolved.dottedPrefix?.join('\\u0000') ?? '';\n let scopedMoves = movesByContainer.get(resolved.container);\n if (!scopedMoves) {\n scopedMoves = new Map();\n movesByContainer.set(resolved.container, scopedMoves);\n }\n const bucket = scopedMoves.get(scopeKey);\n if (bucket) bucket.moves.push(move);\n else scopedMoves.set(scopeKey, { ...resolved, moves: [move] });\n }\n\n for (const scopedMoves of movesByContainer.values()) {\n for (const target of scopedMoves.values()) {\n applyContainerMoves(target.container, target.moves, commentEligibleNodes, warnings, target.dottedPrefix);\n }\n }\n\n if (warnings.length > 0) {\n const unique = [...new Set(warnings)];\n console.warn(\n `toml-patch: updateOrder could not honor the requested position for ` +\n `${unique.length === 1 ? '1 entry' : `${unique.length} entries`}, left unchanged:\\n` +\n unique.map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UAAU,OAAO,YAAY;CAI3G,IAAI,SAAS,SAAS,GAAG;EACvB,MAAM,SAAS,CAAC,GAAG,IAAI,IAAI,QAAQ,CAAC;EACpC,QAAQ,KACN,sEACG,OAAO,WAAW,IAAI,YAAY,GAAG,OAAO,OAAO,UAAU,uBAChE,OAAO,KAAI,MAAK,OAAO,GAAG,CAAC,CAAC,KAAK,IAAI,CACvC;CACF;CAEA,mBAAmB,QAAQ;AAC7B"}
|
package/dist/dev/utils.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//! @decimalturn/toml-patch v3.1.
|
|
1
|
+
//! @decimalturn/toml-patch v3.1.1 - https://github.com/DecimalTurn/toml-patch - @license: MIT
|
|
2
2
|
//#region src/utils.ts
|
|
3
3
|
/**
|
|
4
4
|
* @file Utility functions for the TOML patch library.
|
package/dist/dev/writer.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//! @decimalturn/toml-patch v3.1.
|
|
1
|
+
//! @decimalturn/toml-patch v3.1.1 - https://github.com/DecimalTurn/toml-patch - @license: MIT
|
|
2
2
|
import { hasItem, hasItems, isBlock, isComment, isDocument, isInlineArray, isInlineItem, isInlineTable, isKeyValue, isTable, isTableArray } from "./cst.js";
|
|
3
3
|
import { clonePosition, getSpan } from "./location.js";
|
|
4
4
|
import { getCommaSpace } from "./inline-comma-space.js";
|
package/dist/toml-patch.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
//#region src/toml-format.d.ts
|
|
3
3
|
type MultilineContainerMode = boolean | number | 'auto' | 'parent';
|
|
4
|
-
declare class TomlFormat {
|
|
4
|
+
export declare class TomlFormat {
|
|
5
5
|
/**
|
|
6
6
|
* The line ending character(s) to use in the output TOML.
|
|
7
7
|
* This option affects only the stringification process, not the internal representation (CST).
|
|
@@ -376,7 +376,7 @@ interface TreeNode {
|
|
|
376
376
|
/**
|
|
377
377
|
* TomlDocument encapsulates a TOML CST and provides methods to interact with it.
|
|
378
378
|
*/
|
|
379
|
-
declare class TomlDocument {
|
|
379
|
+
export declare class TomlDocument {
|
|
380
380
|
private _cst;
|
|
381
381
|
private _currentTomlString;
|
|
382
382
|
private _format;
|
|
@@ -447,7 +447,7 @@ declare function patch(existing: string, updated: any, format?: Partial<TomlForm
|
|
|
447
447
|
* Custom Date class for local dates (date-only).
|
|
448
448
|
* Format: 1979-05-27
|
|
449
449
|
*/
|
|
450
|
-
declare class LocalDate extends Date {
|
|
450
|
+
export declare class LocalDate extends Date {
|
|
451
451
|
constructor(value: string);
|
|
452
452
|
toISOString(): string;
|
|
453
453
|
}
|
|
@@ -455,7 +455,7 @@ declare class LocalDate extends Date {
|
|
|
455
455
|
* Custom Date class for local times (time-only)
|
|
456
456
|
* Format: 07:32:00 or 07:32:00.999
|
|
457
457
|
*/
|
|
458
|
-
declare class LocalTime extends Date {
|
|
458
|
+
export declare class LocalTime extends Date {
|
|
459
459
|
originalFormat: string;
|
|
460
460
|
constructor(value: string, originalFormat: string);
|
|
461
461
|
toISOString(): string;
|
|
@@ -464,7 +464,7 @@ declare class LocalTime extends Date {
|
|
|
464
464
|
* Custom Date class for local datetime (no timezone)
|
|
465
465
|
* Format: 1979-05-27T07:32:00 or 1979-05-27 07:32:00
|
|
466
466
|
*/
|
|
467
|
-
declare class LocalDateTime extends Date {
|
|
467
|
+
export declare class LocalDateTime extends Date {
|
|
468
468
|
useSpaceSeparator: boolean;
|
|
469
469
|
originalFormat: string;
|
|
470
470
|
constructor(value: string, useSpaceSeparator?: boolean, originalFormat?: string);
|
|
@@ -474,7 +474,7 @@ declare class LocalDateTime extends Date {
|
|
|
474
474
|
* Custom Date class for offset datetime that preserves space separator
|
|
475
475
|
* Format: 1979-05-27T07:32:00Z or 1979-05-27 07:32:00-07:00
|
|
476
476
|
*/
|
|
477
|
-
declare class OffsetDateTime extends Date {
|
|
477
|
+
export declare class OffsetDateTime extends Date {
|
|
478
478
|
useSpaceSeparator: boolean;
|
|
479
479
|
originalOffset?: string;
|
|
480
480
|
originalFormat: string;
|
|
@@ -518,7 +518,7 @@ declare class OffsetDateTime extends Date {
|
|
|
518
518
|
* Default: false.
|
|
519
519
|
* @returns The parsed JavaScript object
|
|
520
520
|
*/
|
|
521
|
-
declare function parse(value: string | Uint8Array, options?: ParseOptions): any;
|
|
521
|
+
export declare function parse(value: string | Uint8Array, options?: ParseOptions): any;
|
|
522
522
|
/**
|
|
523
523
|
* Converts a JavaScript object to a TOML string.
|
|
524
524
|
*
|
|
@@ -526,7 +526,7 @@ declare function parse(value: string | Uint8Array, options?: ParseOptions): any;
|
|
|
526
526
|
* @param format - Optional formatting options for the resulting TOML
|
|
527
527
|
* @returns The stringified TOML representation
|
|
528
528
|
*/
|
|
529
|
-
declare function stringify(value: any, format?: Partial<TomlFormat> | TomlFormat): string;
|
|
529
|
+
export declare function stringify(value: any, format?: Partial<TomlFormat> | TomlFormat): string;
|
|
530
530
|
/**
|
|
531
531
|
* Parses a TOML string or raw UTF-8 bytes into a {@link TomlDocument}.
|
|
532
532
|
*
|
|
@@ -536,6 +536,6 @@ declare function stringify(value: any, format?: Partial<TomlFormat> | TomlFormat
|
|
|
536
536
|
* @param options - Optional parse options
|
|
537
537
|
* @returns A {@link TomlDocument} representing the parsed TOML
|
|
538
538
|
*/
|
|
539
|
-
declare function parseDocument(value: string | Uint8Array, options?: ParseOptions): TomlDocument;
|
|
539
|
+
export declare function parseDocument(value: string | Uint8Array, options?: ParseOptions): TomlDocument;
|
|
540
540
|
//#endregion
|
|
541
|
-
export { type IntegersAsBigInt,
|
|
541
|
+
export { type IntegersAsBigInt, type MultilineContainerMode, type ParseOptions, patch };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decimalturn/toml-patch",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.1-dev",
|
|
4
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": {
|