@decimalturn/toml-patch 3.3.0-dev → 3.3.0-lite
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/patch.js +20 -0
- package/package.json +6 -11
- package/dist/dev/comment-alignment.js +0 -372
- package/dist/dev/comment-alignment.js.map +0 -1
- package/dist/dev/comment-ownership.js +0 -660
- package/dist/dev/comment-ownership.js.map +0 -1
- package/dist/dev/cst-source.js +0 -118
- package/dist/dev/cst-source.js.map +0 -1
- package/dist/dev/cst.js +0 -68
- package/dist/dev/cst.js.map +0 -1
- package/dist/dev/cursor.js +0 -66
- package/dist/dev/cursor.js.map +0 -1
- package/dist/dev/date-format.js +0 -287
- package/dist/dev/date-format.js.map +0 -1
- package/dist/dev/decode-utf8.js +0 -27
- package/dist/dev/decode-utf8.js.map +0 -1
- package/dist/dev/diff-lite.js +0 -108
- package/dist/dev/diff-lite.js.map +0 -1
- package/dist/dev/diff.js +0 -265
- package/dist/dev/diff.js.map +0 -1
- package/dist/dev/encode-lite.js +0 -210
- package/dist/dev/encode-lite.js.map +0 -1
- package/dist/dev/escape-preference.js +0 -166
- package/dist/dev/escape-preference.js.map +0 -1
- package/dist/dev/find-by-path.js +0 -111
- package/dist/dev/find-by-path.js.map +0 -1
- package/dist/dev/formatter.js +0 -298
- package/dist/dev/formatter.js.map +0 -1
- package/dist/dev/generate.js +0 -466
- package/dist/dev/generate.js.map +0 -1
- package/dist/dev/inline-comma-space.js +0 -13
- package/dist/dev/inline-comma-space.js.map +0 -1
- package/dist/dev/inline-format.js +0 -106
- package/dist/dev/inline-format.js.map +0 -1
- package/dist/dev/inline-layout.js +0 -107
- package/dist/dev/inline-layout.js.map +0 -1
- package/dist/dev/line-ending-backslash.js +0 -320
- package/dist/dev/line-ending-backslash.js.map +0 -1
- package/dist/dev/literal-string.js +0 -46
- package/dist/dev/literal-string.js.map +0 -1
- package/dist/dev/location.js +0 -104
- package/dist/dev/location.js.map +0 -1
- package/dist/dev/parse-error.js +0 -27
- package/dist/dev/parse-error.js.map +0 -1
- package/dist/dev/parse-js.js +0 -150
- package/dist/dev/parse-js.js.map +0 -1
- package/dist/dev/parse-string.js +0 -122
- package/dist/dev/parse-string.js.map +0 -1
- package/dist/dev/parse-toml.js +0 -714
- package/dist/dev/parse-toml.js.map +0 -1
- package/dist/dev/patch-lite.js +0 -4
- package/dist/dev/patch-lite2.js +0 -97
- package/dist/dev/patch-lite2.js.map +0 -1
- package/dist/dev/patch.js +0 -2646
- package/dist/dev/patch.js.map +0 -1
- package/dist/dev/smol-toml-date.js +0 -61
- package/dist/dev/smol-toml-date.js.map +0 -1
- package/dist/dev/to-js.js +0 -303
- package/dist/dev/to-js.js.map +0 -1
- package/dist/dev/to-toml.js +0 -874
- package/dist/dev/to-toml.js.map +0 -1
- package/dist/dev/tokenizer.js +0 -225
- package/dist/dev/tokenizer.js.map +0 -1
- package/dist/dev/toml-document.js +0 -220
- package/dist/dev/toml-document.js.map +0 -1
- package/dist/dev/toml-format.js +0 -549
- package/dist/dev/toml-format.js.map +0 -1
- package/dist/dev/toml-patch.js +0 -94
- package/dist/dev/toml-patch.js.map +0 -1
- package/dist/dev/traverse.js +0 -61
- package/dist/dev/traverse.js.map +0 -1
- package/dist/dev/truncate.js +0 -64
- package/dist/dev/truncate.js.map +0 -1
- package/dist/dev/update-order.js +0 -235
- package/dist/dev/update-order.js.map +0 -1
- package/dist/dev/utils.js +0 -302
- package/dist/dev/utils.js.map +0 -1
- package/dist/dev/writer.js +0 -758
- package/dist/dev/writer.js.map +0 -1
- package/dist/toml-patch.d.ts +0 -564
- /package/dist/{patch-lite.d.ts → patch.d.ts} +0 -0
|
@@ -1 +0,0 @@
|
|
|
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(w => ` - ${w}`).join('\\n')\n );\n }\n\n recalcContainerEnd(document);\n}\n"],"mappings":";;;;;;;AAsCA,SAAS,WAAW,QAAyB;CAC3C,MAAM,QAAgB,CAAC;CAEvB,KAAK,MAAM,SAAS,QAAQ;EAC1B,IAAI,MAAM,SAAS,UAAU;GAC3B,MAAM,KAAK;IACT,MAAM;IACN,WAAW;IACX,SAAS;IACT,QAAQ,CAAC,KAAK;IACd,WAAW,MAAM;IACjB,SAAS,MAAM;IACf,OAAO,MAAM;GACf,CAAC;GACD;EACF;EAEA,MAAM,YAAY,QAAQ,MAAM,MAAO,KAAK,aAAa,MAAM,MAAO;EACtE,MAAM,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-
//#region src/utils.ts
|
|
3
|
-
/**
|
|
4
|
-
* @file Utility functions for the TOML patch library.
|
|
5
|
-
* @module utils
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* General utility functions
|
|
9
|
-
*/
|
|
10
|
-
function last(values) {
|
|
11
|
-
return values[values.length - 1];
|
|
12
|
-
}
|
|
13
|
-
function blank() {
|
|
14
|
-
return Object.create(null);
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Equality that keeps the sign of zero.
|
|
18
|
-
*
|
|
19
|
-
* `0 === -0` is true, but TOML spells the sign (`0` against `-0.0`), so an edit
|
|
20
|
-
* that only flips the sign would otherwise look like no change at all.
|
|
21
|
-
*/
|
|
22
|
-
function sameValue(a, b) {
|
|
23
|
-
return a === b && (typeof a !== "number" || Object.is(a, b));
|
|
24
|
-
}
|
|
25
|
-
const signScratch = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8));
|
|
26
|
-
/**
|
|
27
|
-
* Detects a negative NaN through its IEEE 754 sign bit.
|
|
28
|
-
*
|
|
29
|
-
* Arithmetic cannot tell the two apart, but `-nan` is a distinct TOML spelling
|
|
30
|
-
* that round-trips, so the bit pattern is the only way to recognise it.
|
|
31
|
-
*/
|
|
32
|
-
function isNegativeNan(value) {
|
|
33
|
-
if (!Number.isNaN(value)) return false;
|
|
34
|
-
signScratch.setFloat64(0, value, true);
|
|
35
|
-
return (signScratch.getUint32(4, true) & 2147483648) !== 0;
|
|
36
|
-
}
|
|
37
|
-
function isString(value) {
|
|
38
|
-
return typeof value === "string";
|
|
39
|
-
}
|
|
40
|
-
function isInteger(value) {
|
|
41
|
-
return typeof value === "number" && value % 1 === 0 && isFinite(value) && !Object.is(value, -0) && value >= Number.MIN_SAFE_INTEGER && value <= Number.MAX_SAFE_INTEGER;
|
|
42
|
-
}
|
|
43
|
-
function isBigInt(value) {
|
|
44
|
-
return typeof value === "bigint";
|
|
45
|
-
}
|
|
46
|
-
function isFloat(value) {
|
|
47
|
-
return typeof value === "number" && (!isInteger(value) || !isFinite(value) || Object.is(value, -0));
|
|
48
|
-
}
|
|
49
|
-
function isBoolean(value) {
|
|
50
|
-
return typeof value === "boolean";
|
|
51
|
-
}
|
|
52
|
-
function isDate(value) {
|
|
53
|
-
return Object.prototype.toString.call(value) === "[object Date]";
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Duck-type check for Temporal API objects.
|
|
57
|
-
*
|
|
58
|
-
* Works with both the native Temporal (constructor names like
|
|
59
|
-
* "Temporal.PlainDate") and the @js-temporal/polyfill (constructor
|
|
60
|
-
* names like "PlainDate"). Avoids instanceof issues across realms.
|
|
61
|
-
*
|
|
62
|
-
* Only the four TOML-relevant types are checked:
|
|
63
|
-
* PlainDate, PlainTime, PlainDateTime, ZonedDateTime.
|
|
64
|
-
*/
|
|
65
|
-
const TEMPORAL_TYPE_NAMES = /* @__PURE__ */ new Set([
|
|
66
|
-
"Temporal.PlainDate",
|
|
67
|
-
"Temporal.PlainTime",
|
|
68
|
-
"Temporal.PlainDateTime",
|
|
69
|
-
"Temporal.ZonedDateTime",
|
|
70
|
-
"PlainDate",
|
|
71
|
-
"PlainTime",
|
|
72
|
-
"PlainDateTime",
|
|
73
|
-
"ZonedDateTime"
|
|
74
|
-
]);
|
|
75
|
-
function isTemporal(value) {
|
|
76
|
-
var _value$constructor;
|
|
77
|
-
return value != null && typeof value === "object" && TEMPORAL_TYPE_NAMES.has((_value$constructor = value.constructor) === null || _value$constructor === void 0 ? void 0 : _value$constructor.name) && typeof value.equals === "function";
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Converts a Temporal object to its TOML-compatible string representation.
|
|
81
|
-
*
|
|
82
|
-
* For ZonedDateTime, this strips the IANA timezone annotation (e.g. [Asia/Kolkata])
|
|
83
|
-
* and normalizes +00:00 to Z, since TOML only supports offset-based timezones.
|
|
84
|
-
* For other Temporal types, this is equivalent to toString().
|
|
85
|
-
*/
|
|
86
|
-
function temporalToTomlString(value) {
|
|
87
|
-
var _value$constructor2;
|
|
88
|
-
const name = ((_value$constructor2 = value.constructor) === null || _value$constructor2 === void 0 ? void 0 : _value$constructor2.name) ?? "";
|
|
89
|
-
if (name === "Temporal.ZonedDateTime" || name === "ZonedDateTime") {
|
|
90
|
-
const full = value.toString();
|
|
91
|
-
const bracketMatch = full.match(/\[(.+)\]$/);
|
|
92
|
-
if (bracketMatch && !/^[+-]\d{2}:\d{2}$/.test(bracketMatch[1])) throw new Error(`ZonedDateTime with IANA timezone "${full}" cannot be represented in TOML. TOML only supports offset-based timezones (+05:30, Z).`);
|
|
93
|
-
return full.replace(/\[.*\]$/, "").replace(/(\+00:00)$/, "Z");
|
|
94
|
-
}
|
|
95
|
-
const raw = value.toString();
|
|
96
|
-
if (/\[.*\]/.test(raw)) throw new Error(`Temporal value contains unsupported annotation: "${raw}". TOML only supports ISO 8601 calendar.`);
|
|
97
|
-
return raw;
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* True when `value`, or anything nested inside it, is a Temporal object.
|
|
101
|
-
*
|
|
102
|
-
* Both `patch()` and `patch-lite()` use this to decide whether to parse the
|
|
103
|
-
* existing document into Temporal objects: when the caller supplies Temporal
|
|
104
|
-
* values, the diff has to compare like with like, or an unchanged value would
|
|
105
|
-
* look like an edit. `seen` guards against circular structures.
|
|
106
|
-
*/
|
|
107
|
-
function hasTemporal(value, seen = /* @__PURE__ */ new WeakSet()) {
|
|
108
|
-
if (value == null || typeof value !== "object") return false;
|
|
109
|
-
if (isTemporal(value)) return true;
|
|
110
|
-
if (seen.has(value)) return false;
|
|
111
|
-
seen.add(value);
|
|
112
|
-
return Object.values(value).some((child) => hasTemporal(child, seen));
|
|
113
|
-
}
|
|
114
|
-
function isObject(value) {
|
|
115
|
-
return value && typeof value === "object" && !isDate(value) && !isTemporal(value) && !Array.isArray(value);
|
|
116
|
-
}
|
|
117
|
-
function isIterable(value) {
|
|
118
|
-
return value != null && typeof value[Symbol.iterator] === "function";
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* String type detection functions
|
|
122
|
-
*
|
|
123
|
-
* These functions identify the type of TOML string representation from the raw string.
|
|
124
|
-
* The library preserves the preference for escape sequences by maintaining the original
|
|
125
|
-
* string type (basic vs literal, single-line vs multiline) when possible during patching.
|
|
126
|
-
*/
|
|
127
|
-
function isBasicString(raw) {
|
|
128
|
-
return raw.startsWith("\"") && !raw.startsWith("\"\"\"");
|
|
129
|
-
}
|
|
130
|
-
function isMultilineBasicString(raw) {
|
|
131
|
-
return raw.startsWith("\"\"\"");
|
|
132
|
-
}
|
|
133
|
-
function isLiteralString(raw) {
|
|
134
|
-
return raw.startsWith("'") && !raw.startsWith("'''");
|
|
135
|
-
}
|
|
136
|
-
function isMultilineLiteralString(raw) {
|
|
137
|
-
return raw.startsWith("'''");
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* Object and array utilities
|
|
141
|
-
*/
|
|
142
|
-
function has(object, key) {
|
|
143
|
-
return key in object;
|
|
144
|
-
}
|
|
145
|
-
function arraysEqual(a, b) {
|
|
146
|
-
if (a.length !== b.length) return false;
|
|
147
|
-
for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return false;
|
|
148
|
-
return true;
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* Classifies a rendered date by its TOML shape: date-only, time-only, local
|
|
152
|
-
* datetime or offset datetime. Derived from the rendered text so it works for
|
|
153
|
-
* toml-patch's own classes and duck-typed smol-toml `TomlDate` values alike,
|
|
154
|
-
* without importing the date module here.
|
|
155
|
-
*/
|
|
156
|
-
function dateKind(iso) {
|
|
157
|
-
if (/^\d{4}-\d{2}-\d{2}$/.test(iso)) return "date";
|
|
158
|
-
if (/^\d{2}:\d{2}:\d{2}(?:\.\d+)?$/.test(iso)) return "time";
|
|
159
|
-
if (/(?:[Zz]|[+-]\d{2}:\d{2})$/.test(iso)) return "offset";
|
|
160
|
-
return "datetime";
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Fractional-second digits of a rendered date/time with trailing zeros
|
|
164
|
-
* removed, so the same instant spelled `.5` and `.500` agrees.
|
|
165
|
-
*/
|
|
166
|
-
function fractionDigits(iso) {
|
|
167
|
-
const match = iso.match(/\.(\d+)/);
|
|
168
|
-
return match ? match[1].replace(/0+$/, "") : "";
|
|
169
|
-
}
|
|
170
|
-
/** Fractional digits a millisecond count needs, without trailing zeros. */
|
|
171
|
-
function exactMillisecondDigits(ms) {
|
|
172
|
-
if (ms === 0) return 0;
|
|
173
|
-
return String(ms).padStart(3, "0").replace(/0+$/, "").length;
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* The digits a rendered date/time spells out beyond its millisecond part, or
|
|
177
|
-
* `undefined` when it only carries the three digits a `Date` holds. Only the
|
|
178
|
-
* former asserts a sub-millisecond instant; a millisecond-precision value is
|
|
179
|
-
* compatible with whatever fraction the document spelled.
|
|
180
|
-
*/
|
|
181
|
-
function subMillisecondDigits(value, iso) {
|
|
182
|
-
const digits = fractionDigits(iso);
|
|
183
|
-
return digits.length > exactMillisecondDigits(value.getUTCMilliseconds()) ? digits : void 0;
|
|
184
|
-
}
|
|
185
|
-
function datesEqual(a, b) {
|
|
186
|
-
if (isTemporal(a) && isTemporal(b)) return a.toString() === b.toString();
|
|
187
|
-
if (isDate(a) && isDate(b)) {
|
|
188
|
-
if (a.getTime() !== b.getTime()) return false;
|
|
189
|
-
const isoA = a.toISOString();
|
|
190
|
-
const isoB = b.toISOString();
|
|
191
|
-
if (dateKind(isoA) !== dateKind(isoB)) return false;
|
|
192
|
-
const digitsA = subMillisecondDigits(a, isoA);
|
|
193
|
-
const digitsB = subMillisecondDigits(b, isoB);
|
|
194
|
-
return digitsA === void 0 || digitsB === void 0 || digitsA === digitsB;
|
|
195
|
-
}
|
|
196
|
-
return false;
|
|
197
|
-
}
|
|
198
|
-
function stableStringify(object) {
|
|
199
|
-
const output = [];
|
|
200
|
-
const active = /* @__PURE__ */ new WeakSet();
|
|
201
|
-
const pending = [{ value: object }];
|
|
202
|
-
while (pending.length > 0) {
|
|
203
|
-
const token = pending.pop();
|
|
204
|
-
if ("text" in token) {
|
|
205
|
-
output.push(token.text);
|
|
206
|
-
if ("leave" in token) active.delete(token.leave);
|
|
207
|
-
continue;
|
|
208
|
-
}
|
|
209
|
-
const value = token.value;
|
|
210
|
-
if (isObject(value)) {
|
|
211
|
-
if (active.has(value)) throw new TypeError("Cannot stableStringify a circular structure");
|
|
212
|
-
active.add(value);
|
|
213
|
-
const keys = Object.keys(value).sort();
|
|
214
|
-
output.push("{");
|
|
215
|
-
pending.push({
|
|
216
|
-
leave: value,
|
|
217
|
-
text: "}"
|
|
218
|
-
});
|
|
219
|
-
for (let index = keys.length - 1; index >= 0; index--) {
|
|
220
|
-
const key = keys[index];
|
|
221
|
-
if (index < keys.length - 1) pending.push({ text: "," });
|
|
222
|
-
pending.push({ value: value[key] });
|
|
223
|
-
pending.push({ text: ":" });
|
|
224
|
-
pending.push({ text: JSON.stringify(key) });
|
|
225
|
-
}
|
|
226
|
-
} else if (Array.isArray(value)) {
|
|
227
|
-
if (active.has(value)) throw new TypeError("Cannot stableStringify a circular structure");
|
|
228
|
-
active.add(value);
|
|
229
|
-
output.push("[");
|
|
230
|
-
pending.push({
|
|
231
|
-
leave: value,
|
|
232
|
-
text: "]"
|
|
233
|
-
});
|
|
234
|
-
for (let index = value.length - 1; index >= 0; index--) {
|
|
235
|
-
if (index < value.length - 1) pending.push({ text: "," });
|
|
236
|
-
pending.push({ value: value[index] });
|
|
237
|
-
}
|
|
238
|
-
} else if (isTemporal(value)) output.push(JSON.stringify(value.toString()));
|
|
239
|
-
else if (isDate(value)) output.push(JSON.stringify(value.toISOString()));
|
|
240
|
-
else if (typeof value === "bigint") output.push(value.toString() + "n");
|
|
241
|
-
else if (typeof value === "number" && !Number.isFinite(value)) {
|
|
242
|
-
const sign = Number.isNaN(value) ? isNegativeNan(value) ? "-" : "+" : value < 0 ? "-" : "+";
|
|
243
|
-
output.push(`${sign}${String(value)}`);
|
|
244
|
-
} else if (typeof value === "number" && Object.is(value, -0)) output.push("-0");
|
|
245
|
-
else output.push(JSON.stringify(value));
|
|
246
|
-
}
|
|
247
|
-
return output.join("");
|
|
248
|
-
}
|
|
249
|
-
function merge(target, values) {
|
|
250
|
-
const original_length = target.length;
|
|
251
|
-
const added_length = values.length;
|
|
252
|
-
target.length = original_length + added_length;
|
|
253
|
-
for (let i = 0; i < added_length; i++) target[original_length + i] = values[i];
|
|
254
|
-
}
|
|
255
|
-
/**
|
|
256
|
-
* `String.prototype.isWellFormed`, when the runtime has it (Node 20+; this package supports
|
|
257
|
-
* Node 16, so it has to be optional). Returns false exactly when a string contains an unpaired
|
|
258
|
-
* surrogate — the same predicate as `findLoneSurrogate`, but far cheaper.
|
|
259
|
-
*
|
|
260
|
-
* It only yields a boolean, so locating the offending unit for the error message still needs
|
|
261
|
-
* `findLoneSurrogate` — but that only runs on the failing path.
|
|
262
|
-
*/
|
|
263
|
-
const nativeIsWellFormed = typeof String.prototype.isWellFormed === "function" ? String.prototype.isWellFormed : void 0;
|
|
264
|
-
/**
|
|
265
|
-
* Finds the first unpaired surrogate code unit in `value`, if any.
|
|
266
|
-
*
|
|
267
|
-
* JS strings are UTF-16, so an astral character is legitimately stored as a high/low surrogate
|
|
268
|
-
* *pair* — those are fine. An unpaired one is not a Unicode scalar value, so it has no valid
|
|
269
|
-
* UTF-8 encoding and cannot be represented in TOML.
|
|
270
|
-
*/
|
|
271
|
-
function findLoneSurrogate(value) {
|
|
272
|
-
for (let i = 0; i < value.length; i++) {
|
|
273
|
-
const code = value.charCodeAt(i);
|
|
274
|
-
if (code < 55296 || code > 57343) continue;
|
|
275
|
-
if (code <= 56319) {
|
|
276
|
-
const next = value.charCodeAt(i + 1);
|
|
277
|
-
if (next >= 56320 && next <= 57343) {
|
|
278
|
-
i++;
|
|
279
|
-
continue;
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
return {
|
|
283
|
-
index: i,
|
|
284
|
-
code
|
|
285
|
-
};
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
/**
|
|
289
|
-
* Throws if `value` contains an unpaired surrogate. `describe` names what is being encoded
|
|
290
|
-
* (e.g. `'String value'`, `'Key "a"'`) so the message points at the offending input.
|
|
291
|
-
*/
|
|
292
|
-
function assertNoLoneSurrogate(value, describe) {
|
|
293
|
-
if (nativeIsWellFormed !== void 0 && nativeIsWellFormed.call(value)) return;
|
|
294
|
-
const found = findLoneSurrogate(value);
|
|
295
|
-
if (!found) return;
|
|
296
|
-
const hex = found.code.toString(16).toUpperCase().padStart(4, "0");
|
|
297
|
-
throw new Error(`${describe} contains a lone surrogate (U+${hex}) at index ${found.index}. Unpaired surrogates are not Unicode scalar values and cannot be encoded as TOML.`);
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
//#endregion
|
|
301
|
-
export { arraysEqual, assertNoLoneSurrogate, blank, datesEqual, has, hasTemporal, isBasicString, isBigInt, isBoolean, isDate, isFloat, isInteger, isIterable, isLiteralString, isMultilineBasicString, isMultilineLiteralString, isNegativeNan, isObject, isString, isTemporal, last, merge, sameValue, stableStringify, temporalToTomlString };
|
|
302
|
-
//# sourceMappingURL=utils.js.map
|
package/dist/dev/utils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":[],"sources":["../../src/utils.ts"],"sourcesContent":["/**\n * @file Utility functions for the TOML patch library.\n * @module utils\n */\n\n/**\n * General utility functions\n */\n\nexport function last<TValue>(values: TValue[]): TValue | undefined {\n return values[values.length - 1];\n}\n\nexport type BlankObject = { [key: string]: any };\n\nexport function blank(): BlankObject {\n return Object.create(null);\n}\n\n/**\n * Equality that keeps the sign of zero.\n *\n * `0 === -0` is true, but TOML spells the sign (`0` against `-0.0`), so an edit\n * that only flips the sign would otherwise look like no change at all.\n */\nexport function sameValue(a: any, b: any): boolean {\n return a === b && (typeof a !== 'number' || Object.is(a, b));\n}\n\n// Scratch buffer for reading the sign bit of a number. The value has to be\n// written through DataView: `new Float64Array([value])` is not reliable for\n// this, because the engine occasionally canonicalises the NaN payload on the\n// way in, and a `-nan` then reads as positive (about one call in twenty\n// thousand, which is enough to make NaN handling intermittent).\nconst signScratch = new DataView(new ArrayBuffer(8));\n\n/**\n * Detects a negative NaN through its IEEE 754 sign bit.\n *\n * Arithmetic cannot tell the two apart, but `-nan` is a distinct TOML spelling\n * that round-trips, so the bit pattern is the only way to recognise it.\n */\nexport function isNegativeNan(value: number): boolean {\n if (!Number.isNaN(value)) return false;\n signScratch.setFloat64(0, value, true);\n return (signScratch.getUint32(4, true) & 0x80000000) !== 0;\n}\n\nexport function isString(value: any): value is string {\n return typeof value === 'string';\n}\n\nexport function isInteger(value: any): value is number {\n return typeof value === 'number'\n && value % 1 === 0\n && isFinite(value)\n && !Object.is(value, -0)\n && value >= Number.MIN_SAFE_INTEGER\n && value <= Number.MAX_SAFE_INTEGER;\n}\n\nexport function isBigInt(value: any): value is bigint {\n return typeof value === 'bigint';\n}\n\nexport function isFloat(value: any): value is number {\n return typeof value === 'number' && (!isInteger(value) || !isFinite(value) || Object.is(value, -0));\n}\n\nexport function isBoolean(value: any): value is boolean {\n return typeof value === 'boolean';\n}\n\nexport function isDate(value: any): value is Date {\n return Object.prototype.toString.call(value) === '[object Date]';\n}\n\n/**\n * Duck-type check for Temporal API objects.\n *\n * Works with both the native Temporal (constructor names like\n * \"Temporal.PlainDate\") and the @js-temporal/polyfill (constructor\n * names like \"PlainDate\"). Avoids instanceof issues across realms.\n *\n * Only the four TOML-relevant types are checked:\n * PlainDate, PlainTime, PlainDateTime, ZonedDateTime.\n */\nconst TEMPORAL_TYPE_NAMES = new Set([\n 'Temporal.PlainDate', 'Temporal.PlainTime', 'Temporal.PlainDateTime', 'Temporal.ZonedDateTime',\n 'PlainDate', 'PlainTime', 'PlainDateTime', 'ZonedDateTime'\n]);\n\nexport function isTemporal(value: any): boolean {\n return value != null\n && typeof value === 'object'\n && TEMPORAL_TYPE_NAMES.has(value.constructor?.name)\n && typeof (value as any).equals === 'function';\n}\n\n/**\n * Converts a Temporal object to its TOML-compatible string representation.\n *\n * For ZonedDateTime, this strips the IANA timezone annotation (e.g. [Asia/Kolkata])\n * and normalizes +00:00 to Z, since TOML only supports offset-based timezones.\n * For other Temporal types, this is equivalent to toString().\n */\nexport function temporalToTomlString(value: any): string {\n const name: string = value.constructor?.name ?? '';\n\n if (name === 'Temporal.ZonedDateTime' || name === 'ZonedDateTime') {\n // Reject IANA timezone annotations — TOML only supports offsets.\n const full = value.toString();\n const bracketMatch = full.match(/\\[(.+)\\]$/);\n if (bracketMatch && !/^[+-]\\d{2}:\\d{2}$/.test(bracketMatch[1])) {\n throw new Error(\n `ZonedDateTime with IANA timezone \"${full}\" cannot be represented in TOML. ` +\n 'TOML only supports offset-based timezones (+05:30, Z).'\n );\n }\n // Strip bracket annotation, then normalize +00:00 offset suffix to Z\n return full.replace(/\\[.*\\]$/, '').replace(/(\\+00:00)$/, 'Z');\n }\n\n const raw = value.toString();\n // Reject bracket annotations on non-ZonedDateTime types too\n // (non-ISO calendars like [u-ca=...] are not valid TOML).\n if (/\\[.*\\]/.test(raw)) {\n throw new Error(\n `Temporal value contains unsupported annotation: \"${raw}\". ` +\n 'TOML only supports ISO 8601 calendar.'\n );\n }\n return raw;\n}\n\n/**\n * True when `value`, or anything nested inside it, is a Temporal object.\n *\n * Both `patch()` and `patch-lite()` use this to decide whether to parse the\n * existing document into Temporal objects: when the caller supplies Temporal\n * values, the diff has to compare like with like, or an unchanged value would\n * look like an edit. `seen` guards against circular structures.\n */\nexport function hasTemporal(value: any, seen: WeakSet<object> = new WeakSet()): boolean {\n if (value == null || typeof value !== 'object') return false;\n if (isTemporal(value)) return true;\n if (seen.has(value)) return false;\n seen.add(value);\n return Object.values(value).some((child) => hasTemporal(child, seen));\n}\n\nexport function isObject(value: any): boolean {\n return value && typeof value === 'object' && !isDate(value) && !isTemporal(value) && !Array.isArray(value);\n}\n\nexport function isIterable<T>(value: any): value is Iterable<T> {\n return value != null && typeof value[Symbol.iterator] === 'function';\n}\n\n/**\n * String type detection functions\n *\n * These functions identify the type of TOML string representation from the raw string.\n * The library preserves the preference for escape sequences by maintaining the original\n * string type (basic vs literal, single-line vs multiline) when possible during patching.\n */\n\nexport function isBasicString(raw: string): boolean {\n return raw.startsWith('\"') && !raw.startsWith('\"\"\"');\n}\n\nexport function isMultilineBasicString(raw: string): boolean {\n return raw.startsWith('\"\"\"');\n}\n\nexport function isLiteralString(raw: string): boolean {\n return raw.startsWith(\"'\") && !raw.startsWith(\"'''\");\n}\n\nexport function isMultilineLiteralString(raw: string): boolean {\n return raw.startsWith(\"'''\");\n}\n\n/**\n * Object and array utilities\n */\n\nexport function has(object: any, key: string): boolean {\n // All objects come from blank() (Object.create(null)) so there is no\n // prototype chain — `key in object` is safe and avoids the slow\n // Object.prototype.hasOwnProperty.call indirection.\n return key in object;\n}\n\nexport function arraysEqual<TItem>(a: TItem[], b: TItem[]): boolean {\n if (a.length !== b.length) return false;\n\n for (let i = 0; i < a.length; i++) {\n if (a[i] !== b[i]) return false;\n }\n\n return true;\n}\n\n/**\n * Classifies a rendered date by its TOML shape: date-only, time-only, local\n * datetime or offset datetime. Derived from the rendered text so it works for\n * toml-patch's own classes and duck-typed smol-toml `TomlDate` values alike,\n * without importing the date module here.\n */\nfunction dateKind(iso: string): 'date' | 'time' | 'datetime' | 'offset' {\n if (/^\\d{4}-\\d{2}-\\d{2}$/.test(iso)) return 'date';\n if (/^\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?$/.test(iso)) return 'time';\n if (/(?:[Zz]|[+-]\\d{2}:\\d{2})$/.test(iso)) return 'offset';\n return 'datetime';\n}\n\n/**\n * Fractional-second digits of a rendered date/time with trailing zeros\n * removed, so the same instant spelled `.5` and `.500` agrees.\n */\nfunction fractionDigits(iso: string): string {\n const match = iso.match(/\\.(\\d+)/);\n return match ? match[1].replace(/0+$/, '') : '';\n}\n\n/** Fractional digits a millisecond count needs, without trailing zeros. */\nfunction exactMillisecondDigits(ms: number): number {\n if (ms === 0) return 0;\n return String(ms).padStart(3, '0').replace(/0+$/, '').length;\n}\n\n/**\n * The digits a rendered date/time spells out beyond its millisecond part, or\n * `undefined` when it only carries the three digits a `Date` holds. Only the\n * former asserts a sub-millisecond instant; a millisecond-precision value is\n * compatible with whatever fraction the document spelled.\n */\nfunction subMillisecondDigits(value: Date, iso: string): string | undefined {\n const digits = fractionDigits(iso);\n return digits.length > exactMillisecondDigits(value.getUTCMilliseconds()) ? digits : undefined;\n}\n\nexport function datesEqual(a: any, b: any): boolean {\n // Temporal objects: compare via toString(). Two ZonedDateTime values\n // with different IANA zones are NOT the same even if their offsets match.\n if (isTemporal(a) && isTemporal(b)) {\n return a.toString() === b.toString();\n }\n // Custom Date subclasses: compare by instant, kind and sub-millisecond\n // digits, never by rendered text as a whole. Trailing zeros are spelling\n // only, so `.5` equals `.500`, and a millisecond-precision value matches any\n // spelling of its instant. Two values that each spell out digits past the\n // millisecond are different instants and must produce an edit.\n if (isDate(a) && isDate(b)) {\n if (a.getTime() !== b.getTime()) return false;\n const isoA = a.toISOString();\n const isoB = b.toISOString();\n if (dateKind(isoA) !== dateKind(isoB)) return false;\n\n const digitsA = subMillisecondDigits(a, isoA);\n const digitsB = subMillisecondDigits(b, isoB);\n return digitsA === undefined || digitsB === undefined || digitsA === digitsB;\n }\n return false;\n}\n\nexport function stableStringify(object: any): string {\n const output: string[] = [];\n const active = new WeakSet<object>();\n const pending: Array<{ value: any } | { text: string } | { leave: object; text: string }> = [{ value: object }];\n\n while (pending.length > 0) {\n const token = pending.pop()!;\n if ('text' in token) {\n output.push(token.text);\n if ('leave' in token) active.delete(token.leave);\n continue;\n }\n\n const value = token.value;\n if (isObject(value)) {\n if (active.has(value)) {\n throw new TypeError('Cannot stableStringify a circular structure');\n }\n active.add(value);\n const keys = Object.keys(value).sort();\n output.push('{');\n pending.push({ leave: value, text: '}' });\n for (let index = keys.length - 1; index >= 0; index--) {\n const key = keys[index];\n if (index < keys.length - 1) pending.push({ text: ',' });\n pending.push({ value: value[key] });\n pending.push({ text: ':' });\n pending.push({ text: JSON.stringify(key) });\n }\n } else if (Array.isArray(value)) {\n if (active.has(value)) {\n throw new TypeError('Cannot stableStringify a circular structure');\n }\n active.add(value);\n output.push('[');\n pending.push({ leave: value, text: ']' });\n for (let index = value.length - 1; index >= 0; index--) {\n if (index < value.length - 1) pending.push({ text: ',' });\n pending.push({ value: value[index] });\n }\n } else if (isTemporal(value)) {\n // Temporal objects use toString() for a stable ISO representation\n output.push(JSON.stringify(value.toString()));\n } else if (isDate(value)) {\n // Custom Date subclasses use toISOString()\n output.push(JSON.stringify(value.toISOString()));\n } else if (typeof value === 'bigint') {\n output.push(value.toString() + 'n');\n } else if (typeof value === 'number' && !Number.isFinite(value)) {\n // NaN, Infinity and -Infinity all round-trip through JSON.stringify as\n // \"null\", so they collapse into one another (and into a literal `null`\n // value) in the diff's stable form — an array like `[1, inf, 2, nan]`\n // then diffs `inf` and `nan` as the same element and removes the wrong\n // one (fuzz seed 22629). Tag them by their IEEE 754 sign bit so every\n // distinct non-finite number (including -NaN vs +NaN) stays unique.\n const sign = Number.isNaN(value)\n ? (isNegativeNan(value) ? '-' : '+')\n : (value < 0 ? '-' : '+');\n output.push(`${sign}${String(value)}`);\n } else if (typeof value === 'number' && Object.is(value, -0)) {\n // JSON.stringify(-0) is \"0\", so negative zero would compare equal to a\n // plain zero and an edit that only flips the sign would be skipped.\n // TOML spells the sign (`0` against `-0.0`), so keep them apart here too.\n output.push('-0');\n } else {\n output.push(JSON.stringify(value));\n }\n }\n\n return output.join('');\n}\n\nexport function merge<TValue>(target: TValue[], values: TValue[]) {\n // __mutating__: merge values into target\n // Reference: https://dev.to/uilicious/javascript-array-push-is-945x-faster-than-array-concat-1oki\n const original_length = target.length;\n const added_length = values.length;\n target.length = original_length + added_length;\n\n for (let i = 0; i < added_length; i++) {\n target[original_length + i] = values[i];\n }\n}\n\n/**\n * `String.prototype.isWellFormed`, when the runtime has it (Node 20+; this package supports\n * Node 16, so it has to be optional). Returns false exactly when a string contains an unpaired\n * surrogate — the same predicate as `findLoneSurrogate`, but far cheaper.\n * \n * It only yields a boolean, so locating the offending unit for the error message still needs\n * `findLoneSurrogate` — but that only runs on the failing path.\n */\nconst nativeIsWellFormed: ((this: string) => boolean) | undefined =\n typeof String.prototype.isWellFormed === 'function' ? String.prototype.isWellFormed : undefined;\n\n/**\n * Finds the first unpaired surrogate code unit in `value`, if any.\n *\n * JS strings are UTF-16, so an astral character is legitimately stored as a high/low surrogate\n * *pair* — those are fine. An unpaired one is not a Unicode scalar value, so it has no valid\n * UTF-8 encoding and cannot be represented in TOML.\n */\nfunction findLoneSurrogate(value: string): { index: number; code: number } | undefined {\n for (let i = 0; i < value.length; i++) {\n const code = value.charCodeAt(i);\n if (code < 0xd800 || code > 0xdfff) continue;\n\n // A high surrogate is valid only when immediately followed by a low one.\n if (code <= 0xdbff) {\n const next = value.charCodeAt(i + 1); // NaN past the end — fails the range test below\n if (next >= 0xdc00 && next <= 0xdfff) {\n i++; // consume the pair\n continue;\n }\n }\n\n // Either an unpaired high surrogate, or a low surrogate with no high before it (a paired\n // low is always consumed by the branch above).\n return { index: i, code };\n }\n\n return undefined;\n}\n\n/**\n * Throws if `value` contains an unpaired surrogate. `describe` names what is being encoded\n * (e.g. `'String value'`, `'Key \"a\"'`) so the message points at the offending input.\n */\nexport function assertNoLoneSurrogate(value: string, describe: string): void {\n // Fast path for the overwhelmingly common case of a clean string. When the native check is\n // missing we fall through and scan, which is the same work as before.\n if (nativeIsWellFormed !== undefined && nativeIsWellFormed.call(value)) return;\n\n const found = findLoneSurrogate(value);\n if (!found) return;\n\n const hex = found.code.toString(16).toUpperCase().padStart(4, '0');\n throw new Error(\n `${describe} contains a lone surrogate (U+${hex}) at index ${found.index}. ` +\n `Unpaired surrogates are not Unicode scalar values and cannot be encoded as TOML.`\n );\n}\n\n\n"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