markstream-react 0.0.32 → 0.0.33

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 (97) hide show
  1. package/README.md +11 -0
  2. package/dist/Tooltip-CjIRU2iQ.js +209 -0
  3. package/dist/index-BQw8Blc5.js +87 -0
  4. package/dist/index.css +1 -1
  5. package/dist/index.d.ts +65 -622
  6. package/dist/index.js +1 -211
  7. package/dist/index.px.css +1 -1
  8. package/dist/index.tailwind.css +1 -1
  9. package/dist/languageIcon-BiAQ6aSb.js +3 -0
  10. package/dist/markstream-react.css +1 -0
  11. package/dist/next.d.ts +737 -0
  12. package/dist/next.js +2 -0
  13. package/dist/server.d.ts +543 -0
  14. package/dist/server.js +1 -0
  15. package/dist/tailwind.ts +1 -1
  16. package/dist/types/components/AdmonitionNode/AdmonitionNode.d.ts +11 -0
  17. package/dist/types/components/BlockquoteNode/BlockquoteNode.d.ts +7 -0
  18. package/dist/types/components/CheckboxNode/CheckboxNode.d.ts +6 -0
  19. package/dist/types/components/CodeBlockNode/CodeBlockNode.d.ts +13 -0
  20. package/dist/types/components/CodeBlockNode/HtmlPreviewFrame.d.ts +9 -0
  21. package/dist/types/components/CodeBlockNode/PreCodeNode.d.ts +2 -0
  22. package/dist/types/components/CodeBlockNode/monaco.d.ts +1 -0
  23. package/dist/types/components/CodeBlockNode/monacoThemeRegistry.d.ts +7 -0
  24. package/dist/types/components/CodeBlockNode/monacoThemeScheduler.d.ts +4 -0
  25. package/dist/types/components/D2BlockNode/D2BlockNode.d.ts +2 -0
  26. package/dist/types/components/D2BlockNode/d2.d.ts +6 -0
  27. package/dist/types/components/D2BlockNode/index.d.ts +2 -0
  28. package/dist/types/components/DefinitionListNode/DefinitionListNode.d.ts +6 -0
  29. package/dist/types/components/EmojiNode/EmojiNode.d.ts +7 -0
  30. package/dist/types/components/EmphasisNode/EmphasisNode.d.ts +5 -0
  31. package/dist/types/components/FootnoteAnchorNode/FootnoteAnchorNode.d.ts +6 -0
  32. package/dist/types/components/FootnoteNode/FootnoteNode.d.ts +8 -0
  33. package/dist/types/components/FootnoteReferenceNode/FootnoteReferenceNode.d.ts +6 -0
  34. package/dist/types/components/HardBreakNode/HardBreakNode.d.ts +5 -0
  35. package/dist/types/components/HeadingNode/HeadingNode.d.ts +9 -0
  36. package/dist/types/components/HighlightNode/HighlightNode.d.ts +5 -0
  37. package/dist/types/components/HtmlBlockNode/HtmlBlockNode.d.ts +12 -0
  38. package/dist/types/components/HtmlInlineNode/HtmlInlineNode.d.ts +8 -0
  39. package/dist/types/components/ImageNode/ImageNode.d.ts +9 -0
  40. package/dist/types/components/InfographicBlockNode/InfographicBlockNode.d.ts +15 -0
  41. package/dist/types/components/InfographicBlockNode/index.d.ts +2 -0
  42. package/dist/types/components/InfographicBlockNode/infographic.d.ts +1 -0
  43. package/dist/types/components/InlineCodeNode/InlineCodeNode.d.ts +6 -0
  44. package/dist/types/components/InsertNode/InsertNode.d.ts +5 -0
  45. package/dist/types/components/LinkNode/LinkNode.d.ts +21 -0
  46. package/dist/types/components/ListItemNode/ListItemNode.d.ts +12 -0
  47. package/dist/types/components/ListNode/ListNode.d.ts +8 -0
  48. package/dist/types/components/MarkdownCodeBlockNode/MarkdownCodeBlockNode.d.ts +36 -0
  49. package/dist/types/components/Math/MathBlockNode.d.ts +2 -0
  50. package/dist/types/components/Math/MathInlineNode.d.ts +2 -0
  51. package/dist/types/components/Math/katex.d.ts +1 -0
  52. package/dist/types/components/MathBlockNode/MathBlockNode.d.ts +2 -0
  53. package/dist/types/components/MathInlineNode/MathInlineNode.d.ts +2 -0
  54. package/dist/types/components/MermaidBlockNode/MermaidBlockNode.d.ts +15 -0
  55. package/dist/types/components/MermaidBlockNode/index.d.ts +2 -0
  56. package/dist/types/components/MermaidBlockNode/mermaid.d.ts +1 -0
  57. package/dist/types/components/NodeRenderer/FallbackComponent.d.ts +5 -0
  58. package/dist/types/components/NodeRenderer/preloadMonaco.d.ts +1 -0
  59. package/dist/types/components/NodeRenderer.d.ts +4 -0
  60. package/dist/types/components/ParagraphNode/ParagraphNode.d.ts +7 -0
  61. package/dist/types/components/PreCodeNode/PreCodeNode.d.ts +2 -0
  62. package/dist/types/components/ReferenceNode/ReferenceNode.d.ts +15 -0
  63. package/dist/types/components/StrikethroughNode/StrikethroughNode.d.ts +5 -0
  64. package/dist/types/components/StrongNode/StrongNode.d.ts +5 -0
  65. package/dist/types/components/SubscriptNode/SubscriptNode.d.ts +5 -0
  66. package/dist/types/components/SuperscriptNode/SuperscriptNode.d.ts +5 -0
  67. package/dist/types/components/TableNode/TableNode.d.ts +8 -0
  68. package/dist/types/components/TextNode/TextNode.d.ts +7 -0
  69. package/dist/types/components/ThematicBreakNode/ThematicBreakNode.d.ts +2 -0
  70. package/dist/types/components/Tooltip/Tooltip.d.ts +15 -0
  71. package/dist/types/components/VmrContainerNode/VmrContainerNode.d.ts +9 -0
  72. package/dist/types/context/viewportPriority.d.ts +17 -0
  73. package/dist/types/customComponents.d.ts +9 -0
  74. package/dist/types/i18n/useSafeI18n.d.ts +10 -0
  75. package/dist/types/index.d.ts +65 -0
  76. package/dist/types/next.d.ts +297 -0
  77. package/dist/types/renderers/renderChildren.d.ts +7 -0
  78. package/dist/types/renderers/renderNode.d.ts +4 -0
  79. package/dist/types/server-renderer/html.d.ts +2 -0
  80. package/dist/types/server-renderer/index.d.ts +166 -0
  81. package/dist/types/server-renderer/katex.d.ts +1 -0
  82. package/dist/types/server.d.ts +54 -0
  83. package/dist/types/tailwind-entry.d.ts +1 -0
  84. package/dist/types/tooltip/singletonTooltip.d.ts +7 -0
  85. package/dist/types/types/component-props.d.ts +208 -0
  86. package/dist/types/types/node-component.d.ts +12 -0
  87. package/dist/types/types.d.ts +82 -0
  88. package/dist/types/utils/languageIcon.d.ts +8 -0
  89. package/dist/types/utils/languageIconExtended.d.ts +1 -0
  90. package/dist/types/utils/performanceMonitor.d.ts +78 -0
  91. package/dist/types/utils/safeRaf.d.ts +2 -0
  92. package/dist/types/utils/streamingTextState.d.ts +23 -0
  93. package/dist/types/workers/katexRenderer.worker.d.ts +0 -0
  94. package/dist/types/workers/katexWorkerClient.d.ts +31 -0
  95. package/dist/types/workers/mermaidParser.worker.d.ts +1 -0
  96. package/dist/types/workers/mermaidWorkerClient.d.ts +14 -0
  97. package/package.json +11 -3
@@ -0,0 +1,208 @@
1
+ import { CodeBlockNode } from 'stream-markdown-parser';
2
+ export interface CodeBlockMonacoThemeObject {
3
+ name: string;
4
+ base?: string;
5
+ inherit?: boolean;
6
+ colors?: Record<string, string>;
7
+ rules?: Array<Record<string, unknown>>;
8
+ [key: string]: unknown;
9
+ }
10
+ export type CodeBlockMonacoTheme = string | CodeBlockMonacoThemeObject;
11
+ export type CodeBlockMonacoLanguage = string | ((...args: any[]) => unknown);
12
+ export interface CodeBlockDiffHideUnchangedRegionsOptions {
13
+ enabled?: boolean;
14
+ contextLineCount?: number;
15
+ minimumLineCount?: number;
16
+ revealLineCount?: number;
17
+ }
18
+ export type CodeBlockDiffHideUnchangedRegions = boolean | CodeBlockDiffHideUnchangedRegionsOptions;
19
+ export type CodeBlockDiffLineStyle = 'background' | 'bar';
20
+ export type CodeBlockDiffAppearance = 'auto' | 'light' | 'dark';
21
+ export type CodeBlockDiffUnchangedRegionStyle = 'line-info' | 'line-info-basic' | 'metadata' | 'simple';
22
+ export type CodeBlockDiffHunkActionKind = 'revert' | 'stage';
23
+ export type CodeBlockDiffHunkSide = 'upper' | 'lower';
24
+ export interface CodeBlockDiffHunkActionContext {
25
+ action: CodeBlockDiffHunkActionKind;
26
+ side: CodeBlockDiffHunkSide;
27
+ lineChange: unknown;
28
+ originalModel: unknown;
29
+ modifiedModel: unknown;
30
+ }
31
+ export interface CodeBlockMonacoOptions {
32
+ MAX_HEIGHT?: number | string;
33
+ fontSize?: number;
34
+ lineHeight?: number;
35
+ fontFamily?: string;
36
+ tabSize?: number;
37
+ readOnly?: boolean;
38
+ wordWrap?: 'off' | 'on' | 'wordWrapColumn' | 'bounded' | string;
39
+ wrappingIndent?: 'none' | 'same' | 'indent' | 'deepIndent' | string;
40
+ theme?: string;
41
+ themes?: CodeBlockMonacoTheme[];
42
+ languages?: CodeBlockMonacoLanguage[];
43
+ renderSideBySide?: boolean;
44
+ enableSplitViewResizing?: boolean;
45
+ ignoreTrimWhitespace?: boolean;
46
+ maxComputationTime?: number;
47
+ diffAlgorithm?: string;
48
+ renderIndicators?: boolean;
49
+ originalEditable?: boolean;
50
+ revealDebounceMs?: number;
51
+ revealStrategy?: 'bottom' | 'centerIfOutside' | 'center';
52
+ revealBatchOnIdleMs?: number;
53
+ updateThrottleMs?: number;
54
+ diffUpdateThrottleMs?: number;
55
+ diffAutoScroll?: boolean;
56
+ diffHideUnchangedRegions?: CodeBlockDiffHideUnchangedRegions;
57
+ diffLineStyle?: CodeBlockDiffLineStyle;
58
+ diffAppearance?: CodeBlockDiffAppearance;
59
+ diffUnchangedRegionStyle?: CodeBlockDiffUnchangedRegionStyle;
60
+ diffHunkActionsOnHover?: boolean;
61
+ diffHunkHoverHideDelayMs?: number;
62
+ onDiffHunkAction?: (context: CodeBlockDiffHunkActionContext) => void | boolean | Promise<void | boolean>;
63
+ scrollbar?: Record<string, any>;
64
+ [key: string]: any;
65
+ }
66
+ export interface CodeBlockNodeProps {
67
+ node: CodeBlockNode;
68
+ isDark?: boolean;
69
+ loading?: boolean;
70
+ stream?: boolean;
71
+ darkTheme?: CodeBlockMonacoTheme;
72
+ lightTheme?: CodeBlockMonacoTheme;
73
+ isShowPreview?: boolean;
74
+ monacoOptions?: CodeBlockMonacoOptions;
75
+ enableFontSizeControl?: boolean;
76
+ minWidth?: string | number;
77
+ maxWidth?: string | number;
78
+ themes?: CodeBlockMonacoTheme[];
79
+ showHeader?: boolean;
80
+ showCopyButton?: boolean;
81
+ showExpandButton?: boolean;
82
+ showPreviewButton?: boolean;
83
+ showCollapseButton?: boolean;
84
+ showFontSizeButtons?: boolean;
85
+ showTooltips?: boolean;
86
+ customId?: string;
87
+ }
88
+ export interface ImageNodeProps {
89
+ node: {
90
+ type: 'image';
91
+ src: string;
92
+ alt: string;
93
+ title: string | null;
94
+ raw: string;
95
+ loading?: boolean;
96
+ };
97
+ fallbackSrc?: string;
98
+ showCaption?: boolean;
99
+ lazy?: boolean;
100
+ svgMinHeight?: string;
101
+ usePlaceholder?: boolean;
102
+ }
103
+ export interface LinkNodeProps {
104
+ node: {
105
+ type: 'link';
106
+ href: string;
107
+ title: string | null;
108
+ text: string;
109
+ attrs?: [string, string][];
110
+ children: {
111
+ type: string;
112
+ raw: string;
113
+ }[];
114
+ raw: string;
115
+ loading?: boolean;
116
+ };
117
+ indexKey: number | string;
118
+ customId?: string;
119
+ showTooltip?: boolean;
120
+ color?: string;
121
+ underlineHeight?: number;
122
+ underlineBottom?: number | string;
123
+ animationDuration?: number;
124
+ animationOpacity?: number;
125
+ animationTiming?: string;
126
+ animationIteration?: string | number;
127
+ }
128
+ export interface PreCodeNodeProps {
129
+ node: CodeBlockNode;
130
+ }
131
+ export interface MermaidBlockNodeProps {
132
+ node: CodeBlockNode;
133
+ maxHeight?: string | null;
134
+ loading?: boolean;
135
+ isDark?: boolean;
136
+ workerTimeoutMs?: number;
137
+ parseTimeoutMs?: number;
138
+ renderTimeoutMs?: number;
139
+ fullRenderTimeoutMs?: number;
140
+ renderDebounceMs?: number;
141
+ contentStableDelayMs?: number;
142
+ previewPollDelayMs?: number;
143
+ previewPollMaxDelayMs?: number;
144
+ previewPollMaxAttempts?: number;
145
+ showHeader?: boolean;
146
+ showModeToggle?: boolean;
147
+ showCopyButton?: boolean;
148
+ showExportButton?: boolean;
149
+ showFullscreenButton?: boolean;
150
+ showCollapseButton?: boolean;
151
+ showZoomControls?: boolean;
152
+ enableWheelZoom?: boolean;
153
+ isStrict?: boolean;
154
+ showTooltips?: boolean;
155
+ onRenderError?: (error: unknown, code: string, container: HTMLElement) => boolean | void;
156
+ }
157
+ export interface MermaidBlockEvent<TPayload = any> {
158
+ payload?: TPayload;
159
+ defaultPrevented: boolean;
160
+ preventDefault: () => void;
161
+ svgElement?: SVGElement | null;
162
+ svgString?: string | null;
163
+ }
164
+ export interface D2BlockNodeProps {
165
+ node: CodeBlockNode;
166
+ maxHeight?: string | null;
167
+ loading?: boolean;
168
+ isDark?: boolean;
169
+ progressiveRender?: boolean;
170
+ progressiveIntervalMs?: number;
171
+ themeId?: number | null;
172
+ darkThemeId?: number | null;
173
+ showHeader?: boolean;
174
+ showModeToggle?: boolean;
175
+ showCopyButton?: boolean;
176
+ showExportButton?: boolean;
177
+ showCollapseButton?: boolean;
178
+ }
179
+ export interface MathBlockNodeProps {
180
+ node: {
181
+ type: 'math_block';
182
+ content: string;
183
+ raw: string;
184
+ loading?: boolean;
185
+ };
186
+ }
187
+ export interface MathInlineNodeProps {
188
+ node: {
189
+ type: 'math_inline';
190
+ content: string;
191
+ raw: string;
192
+ loading?: boolean;
193
+ markup?: string;
194
+ };
195
+ }
196
+ export interface InfographicBlockNodeProps {
197
+ node: CodeBlockNode;
198
+ maxHeight?: string | null;
199
+ loading?: boolean;
200
+ isDark?: boolean;
201
+ showHeader?: boolean;
202
+ showModeToggle?: boolean;
203
+ showCopyButton?: boolean;
204
+ showCollapseButton?: boolean;
205
+ showExportButton?: boolean;
206
+ showFullscreenButton?: boolean;
207
+ showZoomControls?: boolean;
208
+ }
@@ -0,0 +1,12 @@
1
+ import { default as React } from 'react';
2
+ import { RenderContext, RenderNodeFn } from '../types';
3
+ export interface NodeComponentProps<TNode = unknown> {
4
+ node: TNode;
5
+ ctx?: RenderContext;
6
+ renderNode?: RenderNodeFn;
7
+ indexKey?: React.Key;
8
+ customId?: string;
9
+ isDark?: boolean;
10
+ typewriter?: boolean;
11
+ children?: React.ReactNode;
12
+ }
@@ -0,0 +1,82 @@
1
+ import { default as React } from 'react';
2
+ import { BaseNode, MarkdownIt, ParsedNode, ParseOptions } from 'stream-markdown-parser';
3
+ import { CodeBlockMonacoOptions, CodeBlockMonacoTheme, D2BlockNodeProps, InfographicBlockNodeProps, MermaidBlockNodeProps } from './types/component-props';
4
+ export interface NodeRendererProps {
5
+ content?: string;
6
+ nodes?: readonly BaseNode[] | null;
7
+ /**
8
+ * Whether the input stream is complete (end-of-stream). When true, the parser
9
+ * can stop emitting streaming "loading" nodes for unfinished constructs.
10
+ */
11
+ final?: boolean;
12
+ parseOptions?: ParseOptions;
13
+ customMarkdownIt?: (md: MarkdownIt) => MarkdownIt;
14
+ /** Log parse/render timing stats (dev only). */
15
+ debugPerformance?: boolean;
16
+ /**
17
+ * Custom HTML-like tags that should be emitted as custom nodes (e.g. ['thinking']).
18
+ * Forwarded to `getMarkdown()` and merged into parseOptions.
19
+ */
20
+ customHtmlTags?: readonly string[];
21
+ viewportPriority?: boolean;
22
+ codeBlockStream?: boolean;
23
+ codeBlockDarkTheme?: CodeBlockMonacoTheme;
24
+ codeBlockLightTheme?: CodeBlockMonacoTheme;
25
+ codeBlockMonacoOptions?: CodeBlockMonacoOptions;
26
+ renderCodeBlocksAsPre?: boolean;
27
+ codeBlockMinWidth?: string | number;
28
+ codeBlockMaxWidth?: string | number;
29
+ codeBlockProps?: Record<string, any>;
30
+ mermaidProps?: Partial<Omit<MermaidBlockNodeProps, 'node' | 'loading' | 'isDark'>>;
31
+ d2Props?: Partial<Omit<D2BlockNodeProps, 'node' | 'loading' | 'isDark'>>;
32
+ infographicProps?: Partial<Omit<InfographicBlockNodeProps, 'node' | 'loading' | 'isDark'>>;
33
+ showTooltips?: boolean;
34
+ themes?: CodeBlockMonacoTheme[];
35
+ isDark?: boolean;
36
+ customId?: string;
37
+ indexKey?: number | string;
38
+ typewriter?: boolean;
39
+ batchRendering?: boolean;
40
+ initialRenderBatchSize?: number;
41
+ renderBatchSize?: number;
42
+ renderBatchDelay?: number;
43
+ renderBatchBudgetMs?: number;
44
+ renderBatchIdleTimeoutMs?: number;
45
+ deferNodesUntilVisible?: boolean;
46
+ maxLiveNodes?: number;
47
+ liveNodeBuffer?: number;
48
+ onCopy?: (code: string) => void;
49
+ onHandleArtifactClick?: (payload: any) => void;
50
+ onClick?: (event: React.MouseEvent<HTMLDivElement>) => void;
51
+ onMouseOver?: (event: React.MouseEvent<HTMLElement>) => void;
52
+ onMouseOut?: (event: React.MouseEvent<HTMLElement>) => void;
53
+ }
54
+ export interface RenderContext {
55
+ customId?: string;
56
+ isDark?: boolean;
57
+ indexKey?: string;
58
+ typewriter?: boolean;
59
+ textStreamState?: Map<string, string>;
60
+ streamRenderVersion?: number;
61
+ customComponents?: Record<string, React.ComponentType<any>>;
62
+ codeBlockProps?: Record<string, any>;
63
+ mermaidProps?: Partial<Omit<MermaidBlockNodeProps, 'node' | 'loading' | 'isDark'>>;
64
+ d2Props?: Partial<Omit<D2BlockNodeProps, 'node' | 'loading' | 'isDark'>>;
65
+ infographicProps?: Partial<Omit<InfographicBlockNodeProps, 'node' | 'loading' | 'isDark'>>;
66
+ showTooltips?: boolean;
67
+ codeBlockStream?: boolean;
68
+ renderCodeBlocksAsPre?: boolean;
69
+ codeBlockThemes?: {
70
+ themes?: CodeBlockMonacoTheme[];
71
+ darkTheme?: CodeBlockMonacoTheme;
72
+ lightTheme?: CodeBlockMonacoTheme;
73
+ monacoOptions?: CodeBlockMonacoOptions;
74
+ minWidth?: string | number;
75
+ maxWidth?: string | number;
76
+ };
77
+ events: {
78
+ onCopy?: (code: string) => void;
79
+ onHandleArtifactClick?: (payload: any) => void;
80
+ };
81
+ }
82
+ export type RenderNodeFn = (node: ParsedNode, key: React.Key, ctx: RenderContext) => React.ReactNode;
@@ -0,0 +1,8 @@
1
+ export type LanguageIconResolver = (lang: string) => string | undefined | null;
2
+ export declare function setLanguageIconResolver(resolver?: LanguageIconResolver | null): void;
3
+ export declare function normalizeLanguageIdentifier(lang?: string | null): string;
4
+ export declare function resolveMonacoLanguageId(lang?: string | null): string;
5
+ export declare function preloadExtendedLanguageIcons(): Promise<void>;
6
+ export declare function subscribeLanguageIconsRevision(listener: () => void): () => void;
7
+ export declare function getLanguageIcon(lang: string): string;
8
+ export declare const languageMap: Record<string, string>;
@@ -0,0 +1 @@
1
+ export declare const EXTENDED_LANGUAGE_ICON_MAP: Record<string, string>;
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Lightweight performance monitoring helper for KaTeX rendering.
3
+ * Only used during development to understand Worker/cache benefits.
4
+ */
5
+ interface RenderMetrics {
6
+ type: 'worker' | 'direct' | 'cache-hit';
7
+ duration: number;
8
+ formulaLength: number;
9
+ timestamp: number;
10
+ success: boolean;
11
+ error?: string;
12
+ }
13
+ declare class PerformanceMonitor {
14
+ private metrics;
15
+ private enabled;
16
+ private maxMetrics;
17
+ enable(): void;
18
+ disable(): void;
19
+ recordRender(metrics: RenderMetrics): void;
20
+ private averages;
21
+ getStats(): {
22
+ totalRenders: number;
23
+ cacheHits: number;
24
+ cacheHitRate: string;
25
+ workerCalls: number;
26
+ directCalls: number;
27
+ averageWorkerTime: string;
28
+ averageDirectTime: string;
29
+ averageCacheHitTime: string;
30
+ workerSavings: string;
31
+ recommendation: string;
32
+ };
33
+ printReport(): {
34
+ totalRenders: number;
35
+ cacheHits: number;
36
+ cacheHitRate: string;
37
+ workerCalls: number;
38
+ directCalls: number;
39
+ averageWorkerTime: string;
40
+ averageDirectTime: string;
41
+ averageCacheHitTime: string;
42
+ workerSavings: string;
43
+ recommendation: string;
44
+ };
45
+ reset(): void;
46
+ exportMetrics(): {
47
+ metrics: RenderMetrics[];
48
+ stats: {
49
+ totalRenders: number;
50
+ cacheHits: number;
51
+ cacheHitRate: string;
52
+ workerCalls: number;
53
+ directCalls: number;
54
+ averageWorkerTime: string;
55
+ averageDirectTime: string;
56
+ averageCacheHitTime: string;
57
+ workerSavings: string;
58
+ recommendation: string;
59
+ };
60
+ timestamp: number;
61
+ };
62
+ }
63
+ export declare const perfMonitor: PerformanceMonitor;
64
+ export declare function enablePerfMonitoring(): void;
65
+ export declare function disablePerfMonitoring(): void;
66
+ export declare function getPerfReport(): {
67
+ totalRenders: number;
68
+ cacheHits: number;
69
+ cacheHitRate: string;
70
+ workerCalls: number;
71
+ directCalls: number;
72
+ averageWorkerTime: string;
73
+ averageDirectTime: string;
74
+ averageCacheHitTime: string;
75
+ workerSavings: string;
76
+ recommendation: string;
77
+ };
78
+ export {};
@@ -0,0 +1,2 @@
1
+ export declare function safeRaf(cb: FrameRequestCallback): any;
2
+ export declare function safeCancelRaf(id: number | null | undefined): void;
@@ -0,0 +1,23 @@
1
+ export interface ResolveStreamingTextStateOptions {
2
+ nextContent: string;
3
+ previousContent: string;
4
+ typewriterEnabled: boolean;
5
+ }
6
+ export interface StreamingTextStateResult {
7
+ settledContent: string;
8
+ streamedDelta: string;
9
+ appended: boolean;
10
+ }
11
+ export interface StreamingRenderState {
12
+ settledContent: string;
13
+ streamedDelta: string;
14
+ }
15
+ export interface ResolveStreamingTextUpdateOptions {
16
+ nextContent: string;
17
+ persistedContent?: string;
18
+ currentState: StreamingRenderState;
19
+ typewriterEnabled: boolean;
20
+ streamRenderVersionChanged?: boolean;
21
+ }
22
+ export declare function resolveStreamingTextState({ nextContent, previousContent, typewriterEnabled, }: ResolveStreamingTextStateOptions): StreamingTextStateResult;
23
+ export declare function resolveStreamingTextUpdate({ nextContent, persistedContent, currentState, typewriterEnabled, streamRenderVersionChanged, }: ResolveStreamingTextUpdateOptions): StreamingTextStateResult;
File without changes
@@ -0,0 +1,31 @@
1
+ export declare function setKaTeXWorker(w: Worker): void;
2
+ export declare function clearKaTeXWorker(): void;
3
+ export declare function setKaTeXWorkerDebug(enabled: boolean): void;
4
+ export declare const WORKER_BUSY_CODE = "WORKER_BUSY";
5
+ export declare function renderKaTeXInWorker(content: string, displayMode?: boolean, timeout?: number, signal?: AbortSignal): Promise<string>;
6
+ export declare function setKaTeXCache(content: string, displayMode: boolean, html: string): void;
7
+ export declare function clearKaTeXCache(): void;
8
+ export declare function setKaTeXConcurrencyLimit(limit: number): void;
9
+ export declare function waitForKaTeXWorkerSlot(timeout?: number, signal?: AbortSignal): Promise<void>;
10
+ export interface BackpressureOptions {
11
+ timeout?: number;
12
+ waitTimeout?: number;
13
+ backoffMs?: number;
14
+ maxRetries?: number;
15
+ signal?: AbortSignal;
16
+ }
17
+ declare const defaultBackpressure: {
18
+ timeout: number;
19
+ waitTimeout: number;
20
+ backoffMs: number;
21
+ maxRetries: number;
22
+ };
23
+ export declare function setKaTeXBackpressureDefaults(opts: Partial<typeof defaultBackpressure>): void;
24
+ export declare function getKaTeXBackpressureDefaults(): {
25
+ timeout: number;
26
+ waitTimeout: number;
27
+ backoffMs: number;
28
+ maxRetries: number;
29
+ };
30
+ export declare function renderKaTeXWithBackpressure(content: string, displayMode?: boolean, opts?: BackpressureOptions): Promise<string>;
31
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,14 @@
1
+ type Theme = 'light' | 'dark';
2
+ export declare function setMermaidWorkerClientDebug(enabled: boolean): void;
3
+ export declare function setMermaidWorkerMaxConcurrency(n: number): void;
4
+ export declare function getMermaidWorkerLoad(): {
5
+ inFlight: number;
6
+ max: number;
7
+ };
8
+ export declare const MERMAID_WORKER_BUSY_CODE = "WORKER_BUSY";
9
+ export declare function setMermaidWorker(w: Worker): void;
10
+ export declare function clearMermaidWorker(): void;
11
+ export declare function canParseOffthread(code: string, theme: Theme, timeout?: number): Promise<boolean>;
12
+ export declare function findPrefixOffthread(code: string, theme: Theme, timeout?: number): Promise<string>;
13
+ export declare function terminateWorker(): void;
14
+ export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "markstream-react",
3
3
  "type": "module",
4
- "version": "0.0.32",
4
+ "version": "0.0.33",
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",
@@ -62,6 +62,14 @@
62
62
  "types": "./dist/index.d.ts",
63
63
  "import": "./dist/index.js"
64
64
  },
65
+ "./next": {
66
+ "types": "./dist/next.d.ts",
67
+ "import": "./dist/next.js"
68
+ },
69
+ "./server": {
70
+ "types": "./dist/server.d.ts",
71
+ "import": "./dist/server.js"
72
+ },
65
73
  "./index.css": "./dist/index.css",
66
74
  "./index.px.css": "./dist/index.px.css",
67
75
  "./index.tailwind.css": "./dist/index.tailwind.css",
@@ -108,7 +116,7 @@
108
116
  "dependencies": {
109
117
  "@floating-ui/dom": "^1.7.6",
110
118
  "clsx": "^2.1.1",
111
- "stream-markdown-parser": "0.0.75"
119
+ "stream-markdown-parser": "0.0.76"
112
120
  },
113
121
  "devDependencies": {
114
122
  "@types/react": "^18.3.28",
@@ -125,7 +133,7 @@
125
133
  },
126
134
  "scripts": {
127
135
  "dev": "vite dev",
128
- "build": "vite build --mode npm && vite build -c vite.config.tailwind.ts --mode npm && node ./scripts/copy-tailwind-css.mjs && node ../../scripts/generate-px-css.mjs && pnpm run build:dts",
136
+ "build": "vite build --mode npm && vite build -c vite.config.tailwind.ts --mode npm && node ./scripts/copy-tailwind-css.mjs && node ../../scripts/generate-px-css.mjs && pnpm run build:dts && node ./scripts/ensure-next-client-directive.mjs",
129
137
  "build:analyze": "ANALYZE=true pnpm build",
130
138
  "build:dts": "rollup -c ./scripts/rollup.dts.config.mjs && node ./scripts/clean-dts.cjs",
131
139
  "preview": "vite preview",