From 4852a09a769d8c44cb8f9e29b1f9f8faafd62582 Mon Sep 17 00:00:00 2001 From: Johann Schopplich Date: Fri, 5 Dec 2025 13:39:50 +0100 Subject: [PATCH] fix: remove deprecated bare list item decoder logic --- packages/toon/src/decode/decoders.ts | 86 +++------------------------- 1 file changed, 8 insertions(+), 78 deletions(-) diff --git a/packages/toon/src/decode/decoders.ts b/packages/toon/src/decode/decoders.ts index 442a0c7..7f05c85 100644 --- a/packages/toon/src/decode/decoders.ts +++ b/packages/toon/src/decode/decoders.ts @@ -405,45 +405,10 @@ function* decodeListItemSync( let afterHyphen: string if (line.content === LIST_ITEM_MARKER) { - // Bare list item marker: either an empty object or fields at depth +1 - const followDepth = baseDepth + 1 - const nextLine = cursor.peekSync() - - if (!nextLine || nextLine.depth < followDepth) { - // No fields at the next depth: treat as empty object - yield { type: 'startObject' } - yield { type: 'endObject' } - return - } - - if (nextLine.depth === followDepth && !nextLine.content.startsWith(LIST_ITEM_PREFIX)) { - // Fields at depth +1: parse them as an object - yield { type: 'startObject' } - - while (!cursor.atEndSync()) { - const fieldLine = cursor.peekSync() - if (!fieldLine || fieldLine.depth < followDepth) { - break - } - - if (fieldLine.depth === followDepth && !fieldLine.content.startsWith(LIST_ITEM_PREFIX)) { - cursor.advanceSync() - yield* decodeKeyValueSync(fieldLine.content, cursor, followDepth, options) - } - else { - break - } - } - - yield { type: 'endObject' } - return - } - else { - // Next line is another list item or at a different depth: treat as empty object - yield { type: 'startObject' } - yield { type: 'endObject' } - return - } + // Bare list item marker: always an empty object + yield { type: 'startObject' } + yield { type: 'endObject' } + return } else if (line.content.startsWith(LIST_ITEM_PREFIX)) { afterHyphen = line.content.slice(LIST_ITEM_PREFIX.length) @@ -826,45 +791,10 @@ async function* decodeListItemAsync( let afterHyphen: string if (line.content === LIST_ITEM_MARKER) { - // Bare list item marker: either an empty object or fields at depth +1 - const followDepth = baseDepth + 1 - const nextLine = await cursor.peek() - - if (!nextLine || nextLine.depth < followDepth) { - // No fields at the next depth: treat as empty object - yield { type: 'startObject' } - yield { type: 'endObject' } - return - } - - if (nextLine.depth === followDepth && !nextLine.content.startsWith(LIST_ITEM_PREFIX)) { - // Fields at depth +1: parse them as an object - yield { type: 'startObject' } - - while (!cursor.atEnd()) { - const fieldLine = await cursor.peek() - if (!fieldLine || fieldLine.depth < followDepth) { - break - } - - if (fieldLine.depth === followDepth && !fieldLine.content.startsWith(LIST_ITEM_PREFIX)) { - await cursor.advance() - yield* decodeKeyValueAsync(fieldLine.content, cursor, followDepth, options) - } - else { - break - } - } - - yield { type: 'endObject' } - return - } - else { - // Next line is another list item or at a different depth: treat as empty object - yield { type: 'startObject' } - yield { type: 'endObject' } - return - } + // Bare list item marker: always an empty object + yield { type: 'startObject' } + yield { type: 'endObject' } + return } else if (line.content.startsWith(LIST_ITEM_PREFIX)) { afterHyphen = line.content.slice(LIST_ITEM_PREFIX.length)