(text: string, key: string | undefined, projection: Projection, owner: string)
| 326 | } |
| 327 | |
| 328 | function initialResult(text: string, key: string | undefined, projection: Projection, owner: string): RenderResult { |
| 329 | if (!text) return { text, blocks: [] } |
| 330 | const base = key ?? checksum(text) |
| 331 | if (base) { |
| 332 | const blocks = projection.blocks.flatMap((block, index) => { |
| 333 | if (block.mode === "code") return [] |
| 334 | const cacheKey = `${base}:${index}:${block.mode}` |
| 335 | const cached = getCachedMarkdown(cacheKey) |
| 336 | if (cached?.raw !== block.raw) return [] |
| 337 | return [{ key: `${owner}:${cacheKey}`, mode: block.mode, ...cached }] |
| 338 | }) |
| 339 | if (blocks.length === projection.blocks.length) return { text, blocks } |
| 340 | } |
| 341 | return { |
| 342 | text, |
| 343 | blocks: [ |
| 344 | { |
| 345 | key: "initial", |
| 346 | mode: "full", |
| 347 | raw: text, |
| 348 | hash: checksum(text) ?? "", |
| 349 | html: fallback(text), |
| 350 | }, |
| 351 | ], |
| 352 | } |
| 353 | } |
| 354 | |
| 355 | export function Markdown( |
| 356 | props: ComponentProps<"div"> & { |
no test coverage detected