(previous: Projection | undefined, text: string, live: boolean)
| 91 | } |
| 92 | |
| 93 | export function project(previous: Projection | undefined, text: string, live: boolean): Projection { |
| 94 | if (!live || !previous || !text.startsWith(previous.text)) return { text, blocks: stream(text, live) } |
| 95 | const tail = previous.blocks.at(-1) |
| 96 | const suffix = text.slice(previous.text.length) |
| 97 | if (!suffix || tail?.mode !== "code" || tail.complete || closesFence(tail.raw, suffix)) |
| 98 | return { text, blocks: stream(text, live) } |
| 99 | return { |
| 100 | text, |
| 101 | blocks: [ |
| 102 | ...previous.blocks.slice(0, -1), |
| 103 | { |
| 104 | ...tail, |
| 105 | raw: tail.raw + suffix, |
| 106 | src: tail.src + suffix, |
| 107 | }, |
| 108 | ], |
| 109 | } |
| 110 | } |
no test coverage detected