markstream-react 0.0.49 → 0.0.50

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.
@@ -1,2 +1,2 @@
1
1
  import { PreCodeNodeProps } from '../../types/component-props';
2
- export declare function PreCodeNode({ node }: PreCodeNodeProps): import("react/jsx-runtime").JSX.Element;
2
+ export declare function PreCodeNode({ node, className, diffInline, showLineNumbers, style }: PreCodeNodeProps): import("react/jsx-runtime").JSX.Element;
@@ -1,4 +1,5 @@
1
- export interface MarkdownCodeBlockNodeProps {
1
+ import { ShikiCodeBlockProps } from '../../types/component-props';
2
+ export interface MarkdownCodeBlockNodeProps extends ShikiCodeBlockProps {
2
3
  node: {
3
4
  type: 'code_block';
4
5
  language: string;
@@ -17,10 +18,6 @@ export interface MarkdownCodeBlockNodeProps {
17
18
  enableFontSizeControl?: boolean;
18
19
  minWidth?: string | number;
19
20
  maxWidth?: string | number;
20
- themes?: string[];
21
- showHeader?: boolean;
22
- showCopyButton?: boolean;
23
- showExpandButton?: boolean;
24
21
  showPreviewButton?: boolean;
25
22
  showCollapseButton?: boolean;
26
23
  showFontSizeButtons?: boolean;
@@ -58,7 +58,7 @@ export type { SmoothMarkdownStreamOptions, SmoothMarkdownStreamSnapshot, } from
58
58
  export * from './i18n/useSafeI18n';
59
59
  export * from './renderers/renderNode';
60
60
  export type { NodeRendererCodeBlockProps, NodeRendererProps } from './types';
61
- export type { CodeBlockDiffAppearance, CodeBlockDiffHideUnchangedRegions, CodeBlockDiffHideUnchangedRegionsOptions, CodeBlockDiffHunkActionContext, CodeBlockDiffHunkActionKind, CodeBlockDiffHunkSide, CodeBlockDiffLineStyle, CodeBlockDiffUnchangedRegionStyle, CodeBlockMonacoLanguage, CodeBlockMonacoOptions, CodeBlockMonacoTheme, CodeBlockMonacoThemeObject, CodeBlockNodeProps, CodeBlockPreviewPayload, D2BlockNodeProps, ImageNodeProps, InfographicBlockNodeProps, LinkNodeProps, MathBlockNodeProps, MathInlineNodeProps, MermaidBlockEvent, MermaidBlockNodeProps, PreCodeNodeProps, } from './types/component-props';
61
+ export type { CodeBlockDiffAppearance, CodeBlockDiffHideUnchangedRegions, CodeBlockDiffHideUnchangedRegionsOptions, CodeBlockDiffHunkActionContext, CodeBlockDiffHunkActionKind, CodeBlockDiffHunkSide, CodeBlockDiffLineStyle, CodeBlockDiffUnchangedRegionStyle, CodeBlockMonacoLanguage, CodeBlockMonacoOptions, CodeBlockMonacoTheme, CodeBlockMonacoThemeObject, CodeBlockNodeProps, CodeBlockPreviewPayload, D2BlockNodeProps, ImageNodeProps, InfographicBlockNodeProps, LinkNodeProps, MathBlockNodeProps, MathInlineNodeProps, MermaidBlockEvent, MermaidBlockNodeProps, PreCodeNodeProps, ShikiCodeBlockProps, } from './types/component-props';
62
62
  export type { NodeComponentProps } from './types/node-component';
63
63
  export * from './utils/languageIcon';
64
64
  export * from './workers/katexWorkerClient';
@@ -0,0 +1,4 @@
1
+ export interface CodeBlockExtraPropsOptions {
2
+ omit?: readonly string[];
3
+ }
4
+ export declare function getCodeBlockExtraProps(source: unknown, options?: CodeBlockExtraPropsOptions): Record<string, unknown>;
@@ -1,3 +1,4 @@
1
+ import { CSSProperties } from 'react';
1
2
  import { CodeBlockNode } from 'stream-markdown-parser';
2
3
  export interface CodeBlockMonacoThemeObject {
3
4
  name: string;
@@ -9,6 +10,19 @@ export interface CodeBlockMonacoThemeObject {
9
10
  }
10
11
  export type CodeBlockMonacoTheme = string | CodeBlockMonacoThemeObject;
11
12
  export type CodeBlockMonacoLanguage = string | ((...args: unknown[]) => unknown);
13
+ export interface CommonCodeBlockProps {
14
+ showHeader?: boolean;
15
+ showCopyButton?: boolean;
16
+ showExpandButton?: boolean;
17
+ }
18
+ export interface ShikiCodeBlockProps extends CommonCodeBlockProps {
19
+ themes?: readonly string[];
20
+ /**
21
+ * Shiki language preload request forwarded to stream-markdown's registerHighlight().
22
+ * This is not a rendering allow-list; already available Shiki languages may still highlight.
23
+ */
24
+ langs?: readonly string[];
25
+ }
12
26
  export interface CodeBlockDiffHideUnchangedRegionsOptions {
13
27
  enabled?: boolean;
14
28
  contextLineCount?: number;
@@ -64,7 +78,7 @@ export interface CodeBlockMonacoOptions {
64
78
  scrollbar?: Record<string, unknown>;
65
79
  [key: string]: unknown;
66
80
  }
67
- export interface CodeBlockNodeProps {
81
+ export interface CodeBlockNodeProps extends CommonCodeBlockProps {
68
82
  node: CodeBlockNode;
69
83
  isDark?: boolean;
70
84
  loading?: boolean;
@@ -77,9 +91,6 @@ export interface CodeBlockNodeProps {
77
91
  minWidth?: string | number;
78
92
  maxWidth?: string | number;
79
93
  themes?: CodeBlockMonacoTheme[];
80
- showHeader?: boolean;
81
- showCopyButton?: boolean;
82
- showExpandButton?: boolean;
83
94
  showPreviewButton?: boolean;
84
95
  showCollapseButton?: boolean;
85
96
  showFontSizeButtons?: boolean;
@@ -128,6 +139,10 @@ export interface LinkNodeProps {
128
139
  }
129
140
  export interface PreCodeNodeProps {
130
141
  node: CodeBlockNode;
142
+ className?: string;
143
+ style?: CSSProperties;
144
+ showLineNumbers?: boolean;
145
+ diffInline?: boolean;
131
146
  }
132
147
  export interface MermaidBlockNodeProps {
133
148
  node: CodeBlockNode;
@@ -153,6 +168,7 @@ export interface MermaidBlockNodeProps {
153
168
  showZoomControls?: boolean;
154
169
  enableWheelZoom?: boolean;
155
170
  isStrict?: boolean;
171
+ enableMermaidInteractions?: boolean;
156
172
  showTooltips?: boolean;
157
173
  onRenderError?: (error: unknown, code: string, container: HTMLElement) => boolean | void;
158
174
  }
@@ -2,8 +2,11 @@ import { default as React } from 'react';
2
2
  import { BaseNode, HtmlPolicy, MarkdownIt, ParsedNode, ParseOptions } from 'stream-markdown-parser';
3
3
  import { CustomComponentMap } from './customComponents';
4
4
  import { SmoothMarkdownStreamOptions } from './hooks/useSmoothMarkdownStream';
5
- import { CodeBlockMonacoOptions, CodeBlockMonacoTheme, CodeBlockNodeProps, CodeBlockPreviewPayload, D2BlockNodeProps, InfographicBlockNodeProps, MermaidBlockNodeProps } from './types/component-props';
6
- export type NodeRendererCodeBlockProps = Partial<Omit<CodeBlockNodeProps, 'node'>> & Record<string, unknown>;
5
+ import { CodeBlockMonacoOptions, CodeBlockMonacoTheme, CodeBlockNodeProps, CodeBlockPreviewPayload, D2BlockNodeProps, InfographicBlockNodeProps, MermaidBlockNodeProps, ShikiCodeBlockProps } from './types/component-props';
6
+ type NodeRendererCodeBlockThemes = CodeBlockNodeProps['themes'] | ShikiCodeBlockProps['themes'];
7
+ export type NodeRendererCodeBlockProps = Partial<Omit<CodeBlockNodeProps, 'node' | 'themes'>> & Partial<Omit<ShikiCodeBlockProps, 'themes'>> & {
8
+ themes?: NodeRendererCodeBlockThemes;
9
+ } & Record<string, unknown>;
7
10
  export interface NodeRendererProps {
8
11
  content?: string;
9
12
  nodes?: readonly BaseNode[] | null;
@@ -35,7 +38,19 @@ export interface NodeRendererProps {
35
38
  d2Props?: Partial<Omit<D2BlockNodeProps, 'node' | 'loading' | 'isDark'>>;
36
39
  infographicProps?: Partial<Omit<InfographicBlockNodeProps, 'node' | 'loading' | 'isDark'>>;
37
40
  showTooltips?: boolean;
41
+ /**
42
+ * Theme names or theme objects preloaded for Monaco-backed code blocks.
43
+ * When Shiki code blocks are used, only string theme names are forwarded to
44
+ * MarkdownCodeBlockNode / stream-markdown; theme objects are ignored.
45
+ */
38
46
  themes?: CodeBlockMonacoTheme[];
47
+ /**
48
+ * Shiki language preload list forwarded to MarkdownCodeBlockNode.
49
+ *
50
+ * The default React code block renderer is Monaco-backed. This prop is used
51
+ * when a custom `code_block` or language renderer uses MarkdownCodeBlockNode.
52
+ */
53
+ langs?: readonly string[];
39
54
  isDark?: boolean;
40
55
  customId?: string;
41
56
  indexKey?: number | string;
@@ -94,6 +109,7 @@ export interface RenderContext {
94
109
  monacoOptions?: CodeBlockMonacoOptions;
95
110
  minWidth?: string | number;
96
111
  maxWidth?: string | number;
112
+ langs?: readonly string[];
97
113
  };
98
114
  events: {
99
115
  onCopy?: (code: string) => void;
@@ -101,3 +117,4 @@ export interface RenderContext {
101
117
  };
102
118
  }
103
119
  export type RenderNodeFn = (node: ParsedNode, key: React.Key, ctx: RenderContext) => React.ReactNode;
120
+ export {};
@@ -0,0 +1 @@
1
+ export declare function isDevEnvironment(): boolean;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "markstream-react",
3
3
  "type": "module",
4
- "version": "0.0.49",
4
+ "version": "0.0.50",
5
5
  "description": "React Markdown renderer optimized for large documents with progressive Mermaid rendering, streaming diff code blocks, and fast real-time preview. Built on stream-markdown AST for consistent rendering across frameworks. Perfect for documentation sites, AI chat interfaces, and content management systems.",
6
6
  "author": "Simon He",
7
7
  "license": "MIT",
@@ -90,8 +90,8 @@
90
90
  "mermaid": ">=11",
91
91
  "react": ">=18",
92
92
  "react-dom": ">=18",
93
- "stream-markdown": ">=0.0.15",
94
- "stream-monaco": ">=0.0.40"
93
+ "stream-markdown": ">=0.0.16",
94
+ "stream-monaco": ">=0.0.41"
95
95
  },
96
96
  "peerDependenciesMeta": {
97
97
  "@antv/infographic": {
@@ -116,20 +116,20 @@
116
116
  "dependencies": {
117
117
  "@floating-ui/dom": "^1.7.6",
118
118
  "clsx": "^2.1.1",
119
- "markstream-core": "0.0.1",
120
- "stream-markdown-parser": "0.0.95"
119
+ "markstream-core": "1.0.3",
120
+ "stream-markdown-parser": "1.0.5"
121
121
  },
122
122
  "devDependencies": {
123
123
  "@types/react": "^18.3.28",
124
124
  "@types/react-dom": "^18.3.7",
125
125
  "@vitejs/plugin-react-swc": "^3.11.0",
126
- "autoprefixer": "^10.4.27",
126
+ "autoprefixer": "^10.5.0",
127
127
  "rollup": "^3.30.0",
128
128
  "rollup-plugin-dts": "^5.3.1",
129
129
  "rollup-plugin-visualizer": "^6.0.11",
130
130
  "tailwindcss": "^3.4.19",
131
131
  "typescript": "^5.9.3",
132
- "vite": "^7.3.1",
132
+ "vite": "^7.3.3",
133
133
  "vite-plugin-dts": "^4.5.4"
134
134
  },
135
135
  "scripts": {
@@ -141,6 +141,7 @@
141
141
  "typecheck": "tsc --noEmit",
142
142
  "size:check": "node ../../scripts/check-package-size.mjs",
143
143
  "check:core-published": "node ../../scripts/check-core-published.mjs --package-json package.json --core-package-json ../markstream-core/package.json",
144
- "release": "pnpm run check:core-published && bumpp --commit --no-tag --no-push && pnpm publish --access public && node ../../scripts/tag-package.mjs --package-json package.json --push"
144
+ "check:workspace-deps-published": "node ../../scripts/check-workspace-deps-published.mjs --package-json package.json",
145
+ "release": "pnpm run check:workspace-deps-published && bumpp --commit --no-tag --no-push && pnpm publish --access public && node ../../scripts/tag-package.mjs --package-json package.json --push"
145
146
  }
146
147
  }