markstream-react 0.0.56-beta.3 → 0.1.0-beta.2

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.
Files changed (35) hide show
  1. package/README.md +17 -20
  2. package/dist/Tooltip-Bs7FyYvs.js +189 -0
  3. package/dist/codeBlockExtraProps-C_3No_qp.js +8 -0
  4. package/dist/{index-BQgUvQrW.js → index-uI922Np4.js} +46 -44
  5. package/dist/index.css +1 -1
  6. package/dist/index.d.ts +1 -3
  7. package/dist/index.js +1 -1
  8. package/dist/index.px.css +1 -1
  9. package/dist/index.tailwind.css +1 -1
  10. package/dist/markstream-react.css +1 -1
  11. package/dist/next.d.ts +67 -126
  12. package/dist/next.js +1 -1
  13. package/dist/server.d.ts +66 -122
  14. package/dist/server.js +1 -1
  15. package/dist/tailwind.cjs +1 -1
  16. package/dist/tailwind.js +1 -1
  17. package/dist/types/components/CodeBlockNode/PreCodeNode.d.ts +1 -1
  18. package/dist/types/components/CodeBlockNode/codeTypography.d.ts +4 -3
  19. package/dist/types/components/CodeBlockNode/streamDiffs.d.ts +2 -0
  20. package/dist/types/components/NodeRenderer/preloadStreamDiffs.d.ts +1 -0
  21. package/dist/types/index.d.ts +1 -3
  22. package/dist/types/next.d.ts +0 -5
  23. package/dist/types/server-renderer/index.d.ts +0 -2
  24. package/dist/types/server.d.ts +0 -2
  25. package/dist/types/types/component-props.d.ts +53 -66
  26. package/dist/types/types.d.ts +13 -24
  27. package/dist/types/utils/languageIcon.d.ts +1 -1
  28. package/package.json +8 -18
  29. package/dist/Tooltip-DygdyBfV.js +0 -205
  30. package/dist/codeBlockExtraProps-B08PlQGP.js +0 -8
  31. package/dist/types/components/CodeBlockNode/monaco.d.ts +0 -1
  32. package/dist/types/components/CodeBlockNode/monacoThemeRegistry.d.ts +0 -7
  33. package/dist/types/components/CodeBlockNode/monacoThemeScheduler.d.ts +0 -4
  34. package/dist/types/components/MarkdownCodeBlockNode/MarkdownCodeBlockNode.d.ts +0 -34
  35. package/dist/types/components/NodeRenderer/preloadMonaco.d.ts +0 -1
package/README.md CHANGED
@@ -4,6 +4,14 @@ React/Next.js streaming Markdown renderer for AI chat, SSE/WebSocket output, lon
4
4
 
5
5
  `markstream-react` is the React renderer in the Markstream family. It renders raw Markdown strings with `content`, and it can also accept pre-parsed `nodes` when a worker or store already owns parsing.
6
6
 
7
+ The coordinated 2.0 family beta will use `markstream-react@next`. Before installing, verify that `npm view markstream-react@next version` reports `0.1.0-beta.1`. It removes the Monaco and Shiki code-block APIs in favor of `stream-diffs`; read the [coordinated 2.0 family migration guide](https://markstream.simonhe.me/guide/migration-2-0) before upgrading.
8
+
9
+ ```bash
10
+ pnpm add markstream-react@next stream-diffs
11
+ ```
12
+
13
+ This beta requires both `react` and `react-dom` 18 or newer.
14
+
7
15
  ## Install
8
16
 
9
17
  ```bash
@@ -127,9 +135,7 @@ export default function Page() {
127
135
 
128
136
  | Feature | Package |
129
137
  | --- | --- |
130
- | Shiki code blocks | `stream-markdown` |
131
138
  | Enhanced code blocks (recommended) | `stream-diffs` |
132
- | Monaco editor code blocks | `stream-monaco` (fallback) |
133
139
  | Mermaid diagrams | `mermaid` |
134
140
  | KaTeX math | `katex` |
135
141
  | D2 diagrams | `@terrastruct/d2` |
@@ -143,20 +149,18 @@ import 'katex/dist/katex.min.css'
143
149
 
144
150
  ## Enhanced Code Blocks
145
151
 
146
- Code blocks use a dual-runtime loader across all Markstream packages: `stream-diffs` is preferred (smaller, no `monaco-editor`), `stream-monaco` is the automatic fallback, and a plain `<pre>` is rendered when neither is installed.
152
+ `stream-diffs` powers enhanced code blocks across all Markstream packages (smaller runtime, no `monaco-editor`); a plain `<pre>` is rendered when it is not installed.
147
153
 
148
- Install the recommended runtime:
154
+ Install the runtime:
149
155
 
150
156
  ```bash
151
157
  pnpm add stream-diffs
152
- # or, to keep the legacy Monaco surface as the fallback:
153
- pnpm add stream-monaco
154
158
  ```
155
159
 
156
160
  `CodeBlockNode` renders a single code block with the header, toolbar, and a `stream-diffs` File / FileDiff surface. Use it directly for one-off blocks, or let `MarkdownRender` resolve it automatically for code blocks in your Markdown:
157
161
 
158
162
  ```tsx
159
- import type { CodeBlockMonacoOptions } from 'markstream-react'
163
+ import type { CodeBlockOptions } from 'markstream-react'
160
164
  import { CodeBlockNode } from 'markstream-react'
161
165
 
162
166
  const node = {
@@ -166,25 +170,18 @@ const node = {
166
170
  raw: 'const answer = 42',
167
171
  }
168
172
 
169
- // fontSize / lineHeight / tabSize also drive the streaming <pre> fallback so
170
- // the enhanced surface swaps in without a visual jump.
171
- const monacoOptions: CodeBlockMonacoOptions = {
172
- fontSize: 14,
173
- lineHeight: 21,
174
- tabSize: 4,
175
- fontFamily: 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace',
176
- wordWrap: 'off',
177
- theme: 'vitesse-dark',
178
- renderSideBySide: true,
179
- MAX_HEIGHT: 640,
173
+ const codeBlockOptions: CodeBlockOptions = {
174
+ overflow: 'wrap',
175
+ diffStyle: 'unified',
176
+ enableLineSelection: true,
180
177
  }
181
178
 
182
179
  export function CodeBlock() {
183
- return <CodeBlockNode node={node} monacoOptions={monacoOptions} isDark />
180
+ return <CodeBlockNode node={node} codeBlockOptions={codeBlockOptions} isDark showHeader />
184
181
  }
185
182
  ```
186
183
 
187
- Component-level options: `isDark` / `darkTheme` / `lightTheme` for theming, `showLineNumbers`, `showHeader`, and `stream` / `loading` for streaming states. `monacoOptions` also covers diff blocks (`renderSideBySide`, `diffHunkActionsOnHover`, `onDiffHunkAction`, `diffHideUnchangedRegions`).
184
+ Direct `CodeBlockNode` and top-level `MarkdownRender` both accept `codeBlockOptions`. The shared `CodeBlockOptions` type covers host-managed typography/layout plus supported File/FileDiff, interaction, annotation, and callback fields; `maxHeight` and the single symmetric `padding` value use numeric CSS pixels. Keep header/toolbar controls in `codeBlockProps`. Theme values are registered names: use `darkTheme` / `lightTheme` for the active names and `themes` for the `[dark, light]` pair to preload. An old Monaco JSON theme is not accepted directly: first convert it to a Shiki `ThemeRegistration`, then call `registerCustomTheme(name, loader)` from `stream-diffs/pierre`; see the [coordinated 2.0 family migration guide](https://markstream.simonhe.me/guide/migration-2-0).
188
185
 
189
186
  ## Tailwind
190
187