Commit Graph

31 Commits

Author SHA1 Message Date
Hayden Bleasel ca6feda934 Fix tests and lint 2026-01-20 14:44:23 -08:00
Hayden Bleasel e633ff73f2 Resolves #360 2026-01-20 14:40:32 -08:00
Hayden Bleasel 0b80aed583 Switch to plugin architecture (#352)
* Plugin trial

* Update docs and tests

* Update homepage add new section

* Update usage.tsx

* Split out CJK plugin

* Extract plugins into new packages

* Misc fixes

* Fix lint / formatting

* Fix: The Streamdown component's memo comparison doesn't compare the plugins prop, preventing re-renders when plugins change while other props stay the same

Co-authored-by: haydenbleasel <hello@haydenbleasel.com>

* Fix: TypeScript type mismatch at line 89 in `index.ts`: the visitor function's `index` parameter is typed as `number | undefined`, but the `visit` function expects `number | null`. The `undefined` type is not assignable to `number | null`.

This commit fixes the issue reported at /vercel/path0/packages/streamdown-cjk/index.ts:89

## TypeScript type incompatibility in visitor callback

**What fails:** TypeScript compiler fails during DTS (type definitions) build in `packages/streamdown-cjk/index.ts` at line 89

**How to reproduce:**
```bash
cd packages/streamdown-cjk
pnpm build
```

**Result:**
```
index.ts(89,3): error TS2769: No overload matches this call.
  Overload 1 of 2, '(tree: Root, check: "link", visitor: BuildVisitor<Root, "link">, reverse?: boolean | null | undefined): undefined', gave the following error.
    Argument of type '(node: Link, index: number | null, parent?: Parent) => number | undefined' is not assignable to parameter of type 'BuildVisitor<Root, "link">'.
      Types of parameters 'index' and 'index' are incompatible.
        Type 'number | undefined' is not assignable to type 'number | null'.
          Type 'undefined' is not assignable to type 'number | null'.
```

**Root cause:** The visitor callback function passed to the `visit()` function from `unist-util-visit` was declaring the `index` parameter as `number | null`, but the visitor can also receive `undefined` as the index value. The `BuildVisitor` type signature expects the callback to accept `number | null | undefined` to properly match the library's API.

**Fix:** Updated the `index` parameter type annotation on line 89 from `number | null` to `number | null | undefined` to match the actual possible values that the visitor receives and the expected `BuildVisitor` type signature.

Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com>
Co-authored-by: haydenbleasel <hello@haydenbleasel.com>

* Fix tests

* Remove CDN paths

* Fix tests

* More cleanup

* Remove shiki from main bundle

* Update index.ts

* Cleanup test repo

* Cleanup website

* Delete next-env files

* Update .gitignore

* Fix lockfile

* Upgrade Next and React

* Simplify themes

* Update test site

* Misc fixes

* Type fixes

* Create perky-cobras-punch.md

---------

Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com>
2026-01-17 14:38:20 -08:00
Hayden Bleasel 61b368512d Fix Streamdown URL 2026-01-11 21:06:59 -08:00
Hayden Bleasel 010c1b3132 Full fixes 2026-01-09 14:26:43 -08:00
Hayden Bleasel 2509917b77 Run Ultracite 2026-01-09 14:24:07 -08:00
Hayden Bleasel 23f2a40612 Attempt to fallback to raw to prevent cdn-loader blocking 2026-01-08 21:25:46 -08:00
Hayden Bleasel 3880bab000 Recursively load language files 2026-01-06 17:11:04 -08:00
Hayden Bleasel 2b26070ebc Fix CDN implementation 2026-01-06 16:29:58 -08:00
Hayden Bleasel 3564f8e6c0 Replace lucide-react 2026-01-06 15:19:07 -08:00
Hayden Bleasel 20c7755bb5 Fix bundled themes, load alternate ones dynamically 2026-01-06 14:51:40 -08:00
Hayden Bleasel 8dcb49a9fd Fix bundle size by importing from shiki/core 2026-01-06 14:43:27 -08:00
Hayden Bleasel ee12ec8179 Resolves #297 2025-12-08 14:54:08 -08:00
Hayden Bleasel 75faa2ed26 Reduce bundle size by 98%, create Streamdown CDN (#295)
* Bundle minimal languages, load excess from CDN

* Update cdn-loader.ts

* Proxy rewrite CDN urls

* Create bold-worms-enjoy.md

* Update code-blocks.mdx

* Delete unused pages

* Add new CDN unit tests

* Run Ultracite

* Manual fixes

* Update sidebar.tsx
2025-12-07 22:16:45 -08:00
Hayden Bleasel d1635f016f Resolves #294 2025-12-07 20:49:58 -08:00
Hayden Bleasel d3ed120364 Remend (#279)
* Initial extraction

* Split up files

* Misc cleanup

* Break apart test file

* Add vitest/coverage-v8

* Increase coverage to 99.63%

* Fix cognitive complexity issues

* Run Ultracite

* Delete parse-incomplete-markdown.ts

* Add postbuild script for use client directive

* Update README.md

* Add default export

* Update docs

* Rename package

* Create wicked-badgers-decide.md

* Fix remend tests

* Fix remend benchmarks

* Fix remaining Streamdown tests

* Update underscore-bug.test.tsx

* Update test.yml

* Update test.yml
2025-12-03 11:17:18 -08:00
Eli Ozcan b2e832f667 fix: validate language before creating highlighter (#257)
* fix: validate language before highlighting

* fix: highlighter language validation function types

* add: changeset
2025-11-24 21:45:58 -08:00
kavinkasper a4899494e7 fix: add missing tooltip support to action buttons (#254)
* fix: add missing title attributes to action buttons for accessibility

* Create vast-cameras-move.md

---------

Co-authored-by: kavin kumar <kavin.kumar@agilepoint.com>
Co-authored-by: Hayden Bleasel <hello@haydenbleasel.com>
2025-11-24 09:46:17 -08:00
Hayden Bleasel 49c66e82e7 Misc cleanup 2025-11-23 14:44:51 -08:00
Hayden Bleasel 74cac00f9b Fix code block data attributes 2025-11-23 14:17:34 -08:00
Hayden Bleasel 1e547d492a Fix code blocks in dark mode 2025-11-23 13:58:18 -08:00
Hayden Bleasel dbd198f3cc Undo lucide import optimization 2025-11-23 11:32:29 -08:00
Hayden Bleasel 476167eab7 Bundle size optimization (#244)
* Direct icon imports

* Lazy load mermaid and shiki until used

* Only load KaTeX when maths is present

* Add changesets

* Improve test app output

* Create lucide-react.d.ts

* Update packages/streamdown/lib/code-block/skeleton.tsx

Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>

---------

Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
2025-11-22 18:50:11 -08:00
Hayden Bleasel 62888665f8 Performance improvements, part 2 (#241)
* Add functional benchmarking suite

* Optimize regex performance

* Fix rendering issue with code blocks

* Fix bench commands

* Table optimizations

* Math Block Detection Caching

* Parse blocks optimizations

* More regex-to-loop optimizations

* Update layout.tsx

* Remove dependency on vfile

* Optimize string operations

* Create markdown.test.tsx

* Optimized cache key generation

* Fix display issue

* Add core Markdown parsing benchmarks

* Update section.tsx

* CSV / TSV escaping optimization

* More optimizations

* Run Ultracite

* Fix remaining lint issues
2025-11-21 17:45:53 -08:00
Hayden Bleasel c025bc5a31 Run Ultracite 2025-11-21 15:36:01 -08:00
Hayden Bleasel 606209d10c Fix Code Blocks (#240)
* Display fallback html

* Rebuild code blocks on codeToTokens

* Remove unused code

* Fix flashing during re-rendering

* Remove useRef

* Switch back to JS Regex engine

* Create single highlighter

* Create container

* Restore singleton cache for highlighters

* Update static.tsx

* Fix tests

* Reapply memoization, consolidate effects, etc.

* Remove Static Code Block

* Run Ultracite

* Fix rendering flashes

* Add token highlight cache

* Update settings.json

* Create flat-gifts-fix.md
2025-11-21 14:55:50 -08:00
Hayden Bleasel 4e12df6209 Performance optimizations (#237)
* Merge contexts

* Fix unit tests

* Enhanced memoization

* Add caching layer to markdown parser

* Fix TS / lint errors

* Fix act() warnings in tests

* Add LRU cache to Markdown processor

* Syntax HighlightManager optimizations

* Switch to single highlighting instance

* Update global.css

* Shift light/dark mode syntax highlighting to CSS

* Fix Fumadocs affecting code blocks

* Fix code block static mode

* Run Ultracite

* Fix tests

* Ultracite fixes

* Cleanup code block implementation

* Update packages/streamdown/index.tsx

Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>

* Create every-cats-clean.md

---------

Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
2025-11-20 15:17:41 -08:00
Hayden Bleasel 726e482608 Fix duplicate highlighters being created 2025-11-20 01:10:45 -08:00
Hayden Bleasel c85a42b1d5 Remove excess client directives 2025-11-19 14:25:01 -08:00
Hayden Bleasel b55cbdc954 Fix security issues, improve performance (#233)
* Resolves https://github.com/vercel/streamdown/security/code-scanning/9

* Resolves https://github.com/vercel/streamdown/security/code-scanning/7

* Resolves https://github.com/vercel/streamdown/security/code-scanning/6

* Resolves https://github.com/vercel/streamdown/security/code-scanning/3

* Resolves https://github.com/vercel/streamdown/security/code-scanning/1

* Bump deps, resolves https://github.com/vercel/streamdown/security/dependabot/10

* Run Ultracite

* Create major-spoons-do.md

* Update parse-incomplete-markdown.ts

* Update packages/streamdown/lib/parse-incomplete-markdown.ts

Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>

* Update parse-incomplete-markdown.test.ts

---------

Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
2025-11-19 13:57:04 -08:00
Hayden Bleasel 52db013a3b Static Mode (#231)
* Implement mode

* Add tests

* Create static test page

* Split up code block files

* Load static / streaming code block dynamically

* Extract highlighting from highlight manager

* Remove abort controller from static

* Add static fallback

* Split header

* Update docs

* Create soft-dragons-type.md

* Fix tests
2025-11-19 08:57:58 -08:00