@stream-mdx/react 0.5.0 → 1.0.0
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.
- package/CHANGELOG.md +371 -0
- package/README.md +79 -4
- package/dist/blocks-renderer-DAOBFBfi.d.ts +29 -0
- package/dist/blocks-renderer-DQEL1kJW.d.cts +29 -0
- package/dist/components/bottom-stick-scroll-area.cjs +117 -193
- package/dist/components/bottom-stick-scroll-area.mjs +112 -183
- package/dist/components/diff-renderer.cjs +86 -0
- package/dist/components/diff-renderer.d.cts +11 -0
- package/dist/components/diff-renderer.d.ts +11 -0
- package/dist/components/diff-renderer.mjs +66 -0
- package/dist/components/index.cjs +2761 -1508
- package/dist/components/index.d.cts +7 -2
- package/dist/components/index.d.ts +7 -2
- package/dist/components/index.mjs +2730 -1493
- package/dist/components/katex-math.cjs +220 -0
- package/dist/components/katex-math.d.cts +10 -0
- package/dist/components/katex-math.d.ts +10 -0
- package/dist/components/katex-math.mjs +188 -0
- package/dist/contexts/math-tracker.cjs +240 -521
- package/dist/contexts/math-tracker.mjs +235 -513
- package/dist/index-Cmne1yUK.d.cts +723 -0
- package/dist/index-D7dyyu3q.d.ts +723 -0
- package/dist/index.cjs +13029 -6475
- package/dist/index.d.cts +69 -39
- package/dist/index.d.ts +69 -39
- package/dist/index.mjs +13007 -6442
- package/dist/math/display-wrapper.cjs +7 -15
- package/dist/math/display-wrapper.d.cts +2 -2
- package/dist/math/display-wrapper.d.ts +2 -2
- package/dist/math/display-wrapper.mjs +2 -6
- package/dist/node-views-Bpc6Gkgl.d.cts +13 -0
- package/dist/node-views-DpnYdaAS.d.ts +13 -0
- package/dist/renderer/hooks.cjs +35 -20
- package/dist/renderer/hooks.d.cts +22 -1
- package/dist/renderer/hooks.d.ts +22 -1
- package/dist/renderer/hooks.mjs +27 -12
- package/dist/renderer/patch-batching.cjs +5 -8
- package/dist/renderer/patch-coalescing.cjs +5 -8
- package/dist/renderer/patch-commit-scheduler.cjs +138 -356
- package/dist/renderer/patch-commit-scheduler.d.cts +13 -1
- package/dist/renderer/patch-commit-scheduler.d.ts +13 -1
- package/dist/renderer/patch-commit-scheduler.mjs +133 -348
- package/dist/renderer/store.cjs +3775 -1373
- package/dist/renderer/store.d.cts +108 -3
- package/dist/renderer/store.d.ts +108 -3
- package/dist/renderer/store.mjs +3778 -1362
- package/dist/renderer/virtualized-code.cjs +415 -71
- package/dist/renderer/virtualized-code.d.cts +24 -23
- package/dist/renderer/virtualized-code.d.ts +24 -23
- package/dist/renderer/virtualized-code.mjs +409 -62
- package/dist/renderer.cjs +10655 -4334
- package/dist/renderer.d.cts +98 -29
- package/dist/renderer.d.ts +98 -29
- package/dist/renderer.mjs +10582 -4212
- package/dist/server-regions-CPLHGli0.d.cts +32 -0
- package/dist/server-regions-mUhyoKi7.d.ts +32 -0
- package/dist/server.cjs +10195 -3872
- package/dist/server.d.cts +17 -252
- package/dist/server.d.ts +17 -252
- package/dist/server.mjs +9997 -3649
- package/dist/{streaming-markdown-CEI9eDZm.d.ts → streaming-markdown-yELbJxyH.d.ts} +49 -55
- package/dist/{streaming-markdown-DRisClXb.d.cts → streaming-markdown-zVwFuaJG.d.cts} +49 -55
- package/dist/streaming-markdown.cjs +11660 -5378
- package/dist/streaming-markdown.d.cts +7 -2
- package/dist/streaming-markdown.d.ts +7 -2
- package/dist/streaming-markdown.mjs +11679 -5347
- package/dist/trusted-mdx/index.cjs +833 -0
- package/dist/trusted-mdx/index.d.cts +11 -0
- package/dist/trusted-mdx/index.d.ts +11 -0
- package/dist/trusted-mdx/index.mjs +807 -0
- package/dist/trusted-mdx/native-children-slot.cjs +45 -0
- package/dist/trusted-mdx/native-children-slot.d.cts +11 -0
- package/dist/trusted-mdx/native-children-slot.d.ts +11 -0
- package/dist/trusted-mdx/native-children-slot.mjs +24 -0
- package/dist/trusted-mdx/server.cjs +752 -0
- package/dist/trusted-mdx/server.d.cts +24 -0
- package/dist/trusted-mdx/server.d.ts +24 -0
- package/dist/trusted-mdx/server.mjs +724 -0
- package/dist/trusted-mdx-contract-ElKpkDI5.d.cts +113 -0
- package/dist/trusted-mdx-contract-ElKpkDI5.d.ts +113 -0
- package/dist/utils/inline-html.cjs +246 -147
- package/dist/utils/inline-html.d.cts +37 -6
- package/dist/utils/inline-html.d.ts +37 -6
- package/dist/utils/inline-html.mjs +237 -134
- package/package.json +41 -18
- package/dist/index-BVhp_pcF.d.ts +0 -251
- package/dist/index-EaeouYp2.d.cts +0 -251
- package/dist/mdx-client.cjs +0 -408
- package/dist/mdx-client.d.cts +0 -113
- package/dist/mdx-client.d.ts +0 -113
- package/dist/mdx-client.mjs +0 -369
- package/dist/mdx-coordinator.cjs +0 -584
- package/dist/mdx-coordinator.d.cts +0 -21
- package/dist/mdx-coordinator.d.ts +0 -21
- package/dist/mdx-coordinator.mjs +0 -550
- package/dist/renderer/node-views.cjs +0 -1887
- package/dist/renderer/node-views.d.cts +0 -14
- package/dist/renderer/node-views.d.ts +0 -14
- package/dist/renderer/node-views.mjs +0 -1861
package/dist/index-BVhp_pcF.d.ts
DELETED
|
@@ -1,251 +0,0 @@
|
|
|
1
|
-
import './components/bottom-stick-scroll-area.js';
|
|
2
|
-
import { InlineNode, TokenLineV1, CompiledMdxModule, InlineHtmlDescriptor, Block, LazyTokenizationPriority, FormatAnticipationConfig, CodeHighlightingMode, CodeHighlightOutputMode, MixedContentSegment } from '@stream-mdx/core';
|
|
3
|
-
import React from 'react';
|
|
4
|
-
|
|
5
|
-
type GenericComponent = React.ComponentType<any>;
|
|
6
|
-
interface TableElements {
|
|
7
|
-
Table: GenericComponent;
|
|
8
|
-
Thead: GenericComponent;
|
|
9
|
-
Tbody: GenericComponent;
|
|
10
|
-
Tr: GenericComponent;
|
|
11
|
-
Th: GenericComponent;
|
|
12
|
-
Td: GenericComponent;
|
|
13
|
-
}
|
|
14
|
-
type HtmlElements = Record<string, GenericComponent>;
|
|
15
|
-
type InlineHtmlRenderer = (descriptor: InlineHtmlDescriptor, context: {
|
|
16
|
-
key?: React.Key;
|
|
17
|
-
defaultRender: () => React.ReactElement | null;
|
|
18
|
-
}) => React.ReactElement | null;
|
|
19
|
-
type InlineHtmlRendererMap = Record<string, InlineHtmlRenderer>;
|
|
20
|
-
interface BlockComponents {
|
|
21
|
-
paragraph: React.FC<{
|
|
22
|
-
inlines: InlineNode[];
|
|
23
|
-
raw?: string;
|
|
24
|
-
meta?: Record<string, unknown>;
|
|
25
|
-
children?: React.ReactNode;
|
|
26
|
-
}>;
|
|
27
|
-
heading: React.FC<{
|
|
28
|
-
level: 1 | 2 | 3 | 4 | 5 | 6;
|
|
29
|
-
inlines: InlineNode[];
|
|
30
|
-
text?: string;
|
|
31
|
-
meta?: Record<string, unknown>;
|
|
32
|
-
}>;
|
|
33
|
-
code: React.FC<{
|
|
34
|
-
html: string;
|
|
35
|
-
meta?: Record<string, unknown>;
|
|
36
|
-
lines?: ReadonlyArray<{
|
|
37
|
-
id: string;
|
|
38
|
-
index: number;
|
|
39
|
-
text: string;
|
|
40
|
-
html?: string | null;
|
|
41
|
-
tokens?: TokenLineV1 | null;
|
|
42
|
-
}>;
|
|
43
|
-
lang?: string;
|
|
44
|
-
preAttrs?: Record<string, string>;
|
|
45
|
-
codeAttrs?: Record<string, string>;
|
|
46
|
-
}>;
|
|
47
|
-
blockquote: React.FC<{
|
|
48
|
-
inlines: InlineNode[];
|
|
49
|
-
renderedContent?: React.ReactNode;
|
|
50
|
-
}>;
|
|
51
|
-
list: React.FC<{
|
|
52
|
-
ordered: boolean;
|
|
53
|
-
items: InlineNode[][];
|
|
54
|
-
}>;
|
|
55
|
-
html: React.FC<{
|
|
56
|
-
__trustedHtml: TrustedHTML | string;
|
|
57
|
-
elements?: Record<string, GenericComponent>;
|
|
58
|
-
}>;
|
|
59
|
-
mdx: React.FC<{
|
|
60
|
-
compiledRef?: {
|
|
61
|
-
id: string;
|
|
62
|
-
};
|
|
63
|
-
compiledModule?: CompiledMdxModule | null;
|
|
64
|
-
status?: "pending" | "compiled" | "error";
|
|
65
|
-
errorMessage?: string;
|
|
66
|
-
raw?: string;
|
|
67
|
-
}>;
|
|
68
|
-
hr: React.FC<React.HTMLAttributes<HTMLHRElement>>;
|
|
69
|
-
table: React.FC<{
|
|
70
|
-
header?: InlineNode[][];
|
|
71
|
-
rows: InlineNode[][][];
|
|
72
|
-
align?: Array<"left" | "center" | "right" | null>;
|
|
73
|
-
elements?: Partial<TableElements>;
|
|
74
|
-
}>;
|
|
75
|
-
[k: string]: GenericComponent;
|
|
76
|
-
}
|
|
77
|
-
type InlineComponents = Record<string, GenericComponent> & {
|
|
78
|
-
text: React.FC<{
|
|
79
|
-
text: string;
|
|
80
|
-
}>;
|
|
81
|
-
strong: React.FC<{
|
|
82
|
-
children: React.ReactNode;
|
|
83
|
-
}>;
|
|
84
|
-
em: React.FC<{
|
|
85
|
-
children: React.ReactNode;
|
|
86
|
-
}>;
|
|
87
|
-
strike?: React.FC<{
|
|
88
|
-
children: React.ReactNode;
|
|
89
|
-
}>;
|
|
90
|
-
code: React.FC<{
|
|
91
|
-
text: string;
|
|
92
|
-
}>;
|
|
93
|
-
link: React.FC<{
|
|
94
|
-
href?: string;
|
|
95
|
-
title?: string;
|
|
96
|
-
children: React.ReactNode;
|
|
97
|
-
}>;
|
|
98
|
-
image: React.FC<{
|
|
99
|
-
src: string;
|
|
100
|
-
alt?: string;
|
|
101
|
-
title?: string;
|
|
102
|
-
}>;
|
|
103
|
-
br: React.FC<Record<string, never>>;
|
|
104
|
-
};
|
|
105
|
-
interface RendererConfig {
|
|
106
|
-
themes?: {
|
|
107
|
-
light: string;
|
|
108
|
-
dark: string;
|
|
109
|
-
};
|
|
110
|
-
highlight?: {
|
|
111
|
-
browserEngine?: "js" | "wasm";
|
|
112
|
-
serverEngine?: "wasm";
|
|
113
|
-
langs?: string[];
|
|
114
|
-
};
|
|
115
|
-
sanitization?: {
|
|
116
|
-
schemaId?: string;
|
|
117
|
-
};
|
|
118
|
-
mdx?: {
|
|
119
|
-
enabled?: boolean;
|
|
120
|
-
compileEndpoint?: string;
|
|
121
|
-
compileStrategy?: "server" | "worker";
|
|
122
|
-
components?: Record<string, GenericComponent>;
|
|
123
|
-
};
|
|
124
|
-
plugins?: {
|
|
125
|
-
footnotes?: boolean;
|
|
126
|
-
html?: boolean;
|
|
127
|
-
mdx?: boolean;
|
|
128
|
-
tables?: boolean;
|
|
129
|
-
callouts?: boolean;
|
|
130
|
-
math?: boolean;
|
|
131
|
-
formatAnticipation?: FormatAnticipationConfig;
|
|
132
|
-
codeHighlighting?: CodeHighlightingMode;
|
|
133
|
-
outputMode?: CodeHighlightOutputMode;
|
|
134
|
-
liveCodeHighlighting?: boolean;
|
|
135
|
-
liveTokenization?: boolean;
|
|
136
|
-
emitHighlightTokens?: boolean;
|
|
137
|
-
emitDiffBlocks?: boolean;
|
|
138
|
-
};
|
|
139
|
-
performance?: {
|
|
140
|
-
frameBudgetMs?: number;
|
|
141
|
-
flushTimeoutMs?: number;
|
|
142
|
-
maxBatchesPerFlush?: number;
|
|
143
|
-
maxLowPriorityBatchesPerFlush?: number;
|
|
144
|
-
lowPriorityFrameBudgetMs?: number;
|
|
145
|
-
urgentQueueThreshold?: number;
|
|
146
|
-
batch?: "rAF" | "microtask" | "timeout";
|
|
147
|
-
historyLimit?: number;
|
|
148
|
-
startupMicrotaskFlushes?: number;
|
|
149
|
-
adaptiveBudgeting?: boolean;
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
interface RendererStore {
|
|
153
|
-
reset(blocks: Block[]): void;
|
|
154
|
-
getBlocks(): ReadonlyArray<Block>;
|
|
155
|
-
getVersion(): number;
|
|
156
|
-
subscribe(listener: () => void): () => void;
|
|
157
|
-
}
|
|
158
|
-
type CodeHighlightRangeRequest = {
|
|
159
|
-
blockId: string;
|
|
160
|
-
startLine: number;
|
|
161
|
-
endLine: number;
|
|
162
|
-
priority?: LazyTokenizationPriority;
|
|
163
|
-
};
|
|
164
|
-
interface Renderer {
|
|
165
|
-
attachWorker(worker: Worker, options?: {
|
|
166
|
-
skipInit?: boolean;
|
|
167
|
-
}): void;
|
|
168
|
-
append(text: string): void;
|
|
169
|
-
renderStatic(text: string): Promise<Block[]>;
|
|
170
|
-
onUpdate(cb: (blocks: ReadonlyArray<Block>) => void): () => void;
|
|
171
|
-
setBlockComponents(map: Partial<BlockComponents>): void;
|
|
172
|
-
setInlineComponents(map: Partial<InlineComponents>): void;
|
|
173
|
-
setMdxComponents(map: Record<string, GenericComponent>): void;
|
|
174
|
-
getComponentRegistry(): ComponentRegistry;
|
|
175
|
-
getStore(): RendererStore;
|
|
176
|
-
requestCodeHighlightRange(request: CodeHighlightRangeRequest): void;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
type LinkSafetyModalProps = {
|
|
180
|
-
url: string;
|
|
181
|
-
isOpen: boolean;
|
|
182
|
-
isChecking?: boolean;
|
|
183
|
-
onClose: () => void;
|
|
184
|
-
onConfirm: () => void;
|
|
185
|
-
onCopy: () => void;
|
|
186
|
-
};
|
|
187
|
-
declare const DefaultLinkSafetyModal: React.FC<LinkSafetyModalProps>;
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* Render inline nodes to React elements
|
|
191
|
-
*/
|
|
192
|
-
declare function renderInlineNodes(nodes: InlineNode[], components: InlineComponents): React.ReactNode;
|
|
193
|
-
/**
|
|
194
|
-
* Default inline components
|
|
195
|
-
*/
|
|
196
|
-
declare const defaultInlineComponents: InlineComponents;
|
|
197
|
-
/**
|
|
198
|
-
* Default block components
|
|
199
|
-
*/
|
|
200
|
-
declare const defaultBlockComponents: BlockComponents;
|
|
201
|
-
/**
|
|
202
|
-
* Component registry that allows customization
|
|
203
|
-
*/
|
|
204
|
-
declare class ComponentRegistry {
|
|
205
|
-
private blockComponents;
|
|
206
|
-
private inlineComponents;
|
|
207
|
-
private htmlElements;
|
|
208
|
-
private tableElements;
|
|
209
|
-
private blockComponentMapCache;
|
|
210
|
-
private inlineComponentMapCache;
|
|
211
|
-
constructor(blockComponents?: Partial<BlockComponents>, inlineComponents?: Partial<InlineComponents>);
|
|
212
|
-
/**
|
|
213
|
-
* Update block components
|
|
214
|
-
*/
|
|
215
|
-
setBlockComponents(components: Partial<BlockComponents>): void;
|
|
216
|
-
/**
|
|
217
|
-
* Update inline components
|
|
218
|
-
*/
|
|
219
|
-
setInlineComponents(components: Partial<InlineComponents>): void;
|
|
220
|
-
/** Update HTML element mapping for html blocks */
|
|
221
|
-
setHtmlElements(map: Partial<HtmlElements>): void;
|
|
222
|
-
/** Update table element mapping for table blocks */
|
|
223
|
-
setTableElements(map: Partial<TableElements>): void;
|
|
224
|
-
/**
|
|
225
|
-
* Get block component
|
|
226
|
-
*/
|
|
227
|
-
getBlockComponent(type: string): React.ComponentType<Record<string, unknown>>;
|
|
228
|
-
/**
|
|
229
|
-
* Get inline components
|
|
230
|
-
*/
|
|
231
|
-
getInlineComponents(): InlineComponents;
|
|
232
|
-
getBlockComponentMap(): BlockComponents;
|
|
233
|
-
getInlineComponentMap(): InlineComponents;
|
|
234
|
-
getTableElements(): TableElements;
|
|
235
|
-
/**
|
|
236
|
-
* Render a block
|
|
237
|
-
*/
|
|
238
|
-
renderBlock(block: Block): React.ReactElement;
|
|
239
|
-
/**
|
|
240
|
-
* Get props for a block based on its type
|
|
241
|
-
*/
|
|
242
|
-
private getBlockProps;
|
|
243
|
-
/**
|
|
244
|
-
* Extract heading level from raw markdown
|
|
245
|
-
*/
|
|
246
|
-
private extractHeadingLevel;
|
|
247
|
-
}
|
|
248
|
-
declare function mapHtmlToReact(html: string, elements: HtmlElements): React.ReactNode;
|
|
249
|
-
declare function renderParagraphMixedSegments(segments: MixedContentSegment[], inlineComponents: InlineComponents, inlineHtmlRenderers: InlineHtmlRendererMap): React.ReactNode[];
|
|
250
|
-
|
|
251
|
-
export { type BlockComponents as B, ComponentRegistry as C, DefaultLinkSafetyModal as D, type HtmlElements as H, type InlineHtmlRendererMap as I, type LinkSafetyModalProps as L, type Renderer as R, type TableElements as T, type InlineComponents as a, type InlineHtmlRenderer as b, type RendererConfig as c, defaultInlineComponents as d, defaultBlockComponents as e, renderParagraphMixedSegments as f, type CodeHighlightRangeRequest as g, mapHtmlToReact as m, renderInlineNodes as r };
|
|
@@ -1,251 +0,0 @@
|
|
|
1
|
-
import './components/bottom-stick-scroll-area.cjs';
|
|
2
|
-
import { InlineNode, TokenLineV1, CompiledMdxModule, InlineHtmlDescriptor, Block, LazyTokenizationPriority, FormatAnticipationConfig, CodeHighlightingMode, CodeHighlightOutputMode, MixedContentSegment } from '@stream-mdx/core';
|
|
3
|
-
import React from 'react';
|
|
4
|
-
|
|
5
|
-
type GenericComponent = React.ComponentType<any>;
|
|
6
|
-
interface TableElements {
|
|
7
|
-
Table: GenericComponent;
|
|
8
|
-
Thead: GenericComponent;
|
|
9
|
-
Tbody: GenericComponent;
|
|
10
|
-
Tr: GenericComponent;
|
|
11
|
-
Th: GenericComponent;
|
|
12
|
-
Td: GenericComponent;
|
|
13
|
-
}
|
|
14
|
-
type HtmlElements = Record<string, GenericComponent>;
|
|
15
|
-
type InlineHtmlRenderer = (descriptor: InlineHtmlDescriptor, context: {
|
|
16
|
-
key?: React.Key;
|
|
17
|
-
defaultRender: () => React.ReactElement | null;
|
|
18
|
-
}) => React.ReactElement | null;
|
|
19
|
-
type InlineHtmlRendererMap = Record<string, InlineHtmlRenderer>;
|
|
20
|
-
interface BlockComponents {
|
|
21
|
-
paragraph: React.FC<{
|
|
22
|
-
inlines: InlineNode[];
|
|
23
|
-
raw?: string;
|
|
24
|
-
meta?: Record<string, unknown>;
|
|
25
|
-
children?: React.ReactNode;
|
|
26
|
-
}>;
|
|
27
|
-
heading: React.FC<{
|
|
28
|
-
level: 1 | 2 | 3 | 4 | 5 | 6;
|
|
29
|
-
inlines: InlineNode[];
|
|
30
|
-
text?: string;
|
|
31
|
-
meta?: Record<string, unknown>;
|
|
32
|
-
}>;
|
|
33
|
-
code: React.FC<{
|
|
34
|
-
html: string;
|
|
35
|
-
meta?: Record<string, unknown>;
|
|
36
|
-
lines?: ReadonlyArray<{
|
|
37
|
-
id: string;
|
|
38
|
-
index: number;
|
|
39
|
-
text: string;
|
|
40
|
-
html?: string | null;
|
|
41
|
-
tokens?: TokenLineV1 | null;
|
|
42
|
-
}>;
|
|
43
|
-
lang?: string;
|
|
44
|
-
preAttrs?: Record<string, string>;
|
|
45
|
-
codeAttrs?: Record<string, string>;
|
|
46
|
-
}>;
|
|
47
|
-
blockquote: React.FC<{
|
|
48
|
-
inlines: InlineNode[];
|
|
49
|
-
renderedContent?: React.ReactNode;
|
|
50
|
-
}>;
|
|
51
|
-
list: React.FC<{
|
|
52
|
-
ordered: boolean;
|
|
53
|
-
items: InlineNode[][];
|
|
54
|
-
}>;
|
|
55
|
-
html: React.FC<{
|
|
56
|
-
__trustedHtml: TrustedHTML | string;
|
|
57
|
-
elements?: Record<string, GenericComponent>;
|
|
58
|
-
}>;
|
|
59
|
-
mdx: React.FC<{
|
|
60
|
-
compiledRef?: {
|
|
61
|
-
id: string;
|
|
62
|
-
};
|
|
63
|
-
compiledModule?: CompiledMdxModule | null;
|
|
64
|
-
status?: "pending" | "compiled" | "error";
|
|
65
|
-
errorMessage?: string;
|
|
66
|
-
raw?: string;
|
|
67
|
-
}>;
|
|
68
|
-
hr: React.FC<React.HTMLAttributes<HTMLHRElement>>;
|
|
69
|
-
table: React.FC<{
|
|
70
|
-
header?: InlineNode[][];
|
|
71
|
-
rows: InlineNode[][][];
|
|
72
|
-
align?: Array<"left" | "center" | "right" | null>;
|
|
73
|
-
elements?: Partial<TableElements>;
|
|
74
|
-
}>;
|
|
75
|
-
[k: string]: GenericComponent;
|
|
76
|
-
}
|
|
77
|
-
type InlineComponents = Record<string, GenericComponent> & {
|
|
78
|
-
text: React.FC<{
|
|
79
|
-
text: string;
|
|
80
|
-
}>;
|
|
81
|
-
strong: React.FC<{
|
|
82
|
-
children: React.ReactNode;
|
|
83
|
-
}>;
|
|
84
|
-
em: React.FC<{
|
|
85
|
-
children: React.ReactNode;
|
|
86
|
-
}>;
|
|
87
|
-
strike?: React.FC<{
|
|
88
|
-
children: React.ReactNode;
|
|
89
|
-
}>;
|
|
90
|
-
code: React.FC<{
|
|
91
|
-
text: string;
|
|
92
|
-
}>;
|
|
93
|
-
link: React.FC<{
|
|
94
|
-
href?: string;
|
|
95
|
-
title?: string;
|
|
96
|
-
children: React.ReactNode;
|
|
97
|
-
}>;
|
|
98
|
-
image: React.FC<{
|
|
99
|
-
src: string;
|
|
100
|
-
alt?: string;
|
|
101
|
-
title?: string;
|
|
102
|
-
}>;
|
|
103
|
-
br: React.FC<Record<string, never>>;
|
|
104
|
-
};
|
|
105
|
-
interface RendererConfig {
|
|
106
|
-
themes?: {
|
|
107
|
-
light: string;
|
|
108
|
-
dark: string;
|
|
109
|
-
};
|
|
110
|
-
highlight?: {
|
|
111
|
-
browserEngine?: "js" | "wasm";
|
|
112
|
-
serverEngine?: "wasm";
|
|
113
|
-
langs?: string[];
|
|
114
|
-
};
|
|
115
|
-
sanitization?: {
|
|
116
|
-
schemaId?: string;
|
|
117
|
-
};
|
|
118
|
-
mdx?: {
|
|
119
|
-
enabled?: boolean;
|
|
120
|
-
compileEndpoint?: string;
|
|
121
|
-
compileStrategy?: "server" | "worker";
|
|
122
|
-
components?: Record<string, GenericComponent>;
|
|
123
|
-
};
|
|
124
|
-
plugins?: {
|
|
125
|
-
footnotes?: boolean;
|
|
126
|
-
html?: boolean;
|
|
127
|
-
mdx?: boolean;
|
|
128
|
-
tables?: boolean;
|
|
129
|
-
callouts?: boolean;
|
|
130
|
-
math?: boolean;
|
|
131
|
-
formatAnticipation?: FormatAnticipationConfig;
|
|
132
|
-
codeHighlighting?: CodeHighlightingMode;
|
|
133
|
-
outputMode?: CodeHighlightOutputMode;
|
|
134
|
-
liveCodeHighlighting?: boolean;
|
|
135
|
-
liveTokenization?: boolean;
|
|
136
|
-
emitHighlightTokens?: boolean;
|
|
137
|
-
emitDiffBlocks?: boolean;
|
|
138
|
-
};
|
|
139
|
-
performance?: {
|
|
140
|
-
frameBudgetMs?: number;
|
|
141
|
-
flushTimeoutMs?: number;
|
|
142
|
-
maxBatchesPerFlush?: number;
|
|
143
|
-
maxLowPriorityBatchesPerFlush?: number;
|
|
144
|
-
lowPriorityFrameBudgetMs?: number;
|
|
145
|
-
urgentQueueThreshold?: number;
|
|
146
|
-
batch?: "rAF" | "microtask" | "timeout";
|
|
147
|
-
historyLimit?: number;
|
|
148
|
-
startupMicrotaskFlushes?: number;
|
|
149
|
-
adaptiveBudgeting?: boolean;
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
interface RendererStore {
|
|
153
|
-
reset(blocks: Block[]): void;
|
|
154
|
-
getBlocks(): ReadonlyArray<Block>;
|
|
155
|
-
getVersion(): number;
|
|
156
|
-
subscribe(listener: () => void): () => void;
|
|
157
|
-
}
|
|
158
|
-
type CodeHighlightRangeRequest = {
|
|
159
|
-
blockId: string;
|
|
160
|
-
startLine: number;
|
|
161
|
-
endLine: number;
|
|
162
|
-
priority?: LazyTokenizationPriority;
|
|
163
|
-
};
|
|
164
|
-
interface Renderer {
|
|
165
|
-
attachWorker(worker: Worker, options?: {
|
|
166
|
-
skipInit?: boolean;
|
|
167
|
-
}): void;
|
|
168
|
-
append(text: string): void;
|
|
169
|
-
renderStatic(text: string): Promise<Block[]>;
|
|
170
|
-
onUpdate(cb: (blocks: ReadonlyArray<Block>) => void): () => void;
|
|
171
|
-
setBlockComponents(map: Partial<BlockComponents>): void;
|
|
172
|
-
setInlineComponents(map: Partial<InlineComponents>): void;
|
|
173
|
-
setMdxComponents(map: Record<string, GenericComponent>): void;
|
|
174
|
-
getComponentRegistry(): ComponentRegistry;
|
|
175
|
-
getStore(): RendererStore;
|
|
176
|
-
requestCodeHighlightRange(request: CodeHighlightRangeRequest): void;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
type LinkSafetyModalProps = {
|
|
180
|
-
url: string;
|
|
181
|
-
isOpen: boolean;
|
|
182
|
-
isChecking?: boolean;
|
|
183
|
-
onClose: () => void;
|
|
184
|
-
onConfirm: () => void;
|
|
185
|
-
onCopy: () => void;
|
|
186
|
-
};
|
|
187
|
-
declare const DefaultLinkSafetyModal: React.FC<LinkSafetyModalProps>;
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* Render inline nodes to React elements
|
|
191
|
-
*/
|
|
192
|
-
declare function renderInlineNodes(nodes: InlineNode[], components: InlineComponents): React.ReactNode;
|
|
193
|
-
/**
|
|
194
|
-
* Default inline components
|
|
195
|
-
*/
|
|
196
|
-
declare const defaultInlineComponents: InlineComponents;
|
|
197
|
-
/**
|
|
198
|
-
* Default block components
|
|
199
|
-
*/
|
|
200
|
-
declare const defaultBlockComponents: BlockComponents;
|
|
201
|
-
/**
|
|
202
|
-
* Component registry that allows customization
|
|
203
|
-
*/
|
|
204
|
-
declare class ComponentRegistry {
|
|
205
|
-
private blockComponents;
|
|
206
|
-
private inlineComponents;
|
|
207
|
-
private htmlElements;
|
|
208
|
-
private tableElements;
|
|
209
|
-
private blockComponentMapCache;
|
|
210
|
-
private inlineComponentMapCache;
|
|
211
|
-
constructor(blockComponents?: Partial<BlockComponents>, inlineComponents?: Partial<InlineComponents>);
|
|
212
|
-
/**
|
|
213
|
-
* Update block components
|
|
214
|
-
*/
|
|
215
|
-
setBlockComponents(components: Partial<BlockComponents>): void;
|
|
216
|
-
/**
|
|
217
|
-
* Update inline components
|
|
218
|
-
*/
|
|
219
|
-
setInlineComponents(components: Partial<InlineComponents>): void;
|
|
220
|
-
/** Update HTML element mapping for html blocks */
|
|
221
|
-
setHtmlElements(map: Partial<HtmlElements>): void;
|
|
222
|
-
/** Update table element mapping for table blocks */
|
|
223
|
-
setTableElements(map: Partial<TableElements>): void;
|
|
224
|
-
/**
|
|
225
|
-
* Get block component
|
|
226
|
-
*/
|
|
227
|
-
getBlockComponent(type: string): React.ComponentType<Record<string, unknown>>;
|
|
228
|
-
/**
|
|
229
|
-
* Get inline components
|
|
230
|
-
*/
|
|
231
|
-
getInlineComponents(): InlineComponents;
|
|
232
|
-
getBlockComponentMap(): BlockComponents;
|
|
233
|
-
getInlineComponentMap(): InlineComponents;
|
|
234
|
-
getTableElements(): TableElements;
|
|
235
|
-
/**
|
|
236
|
-
* Render a block
|
|
237
|
-
*/
|
|
238
|
-
renderBlock(block: Block): React.ReactElement;
|
|
239
|
-
/**
|
|
240
|
-
* Get props for a block based on its type
|
|
241
|
-
*/
|
|
242
|
-
private getBlockProps;
|
|
243
|
-
/**
|
|
244
|
-
* Extract heading level from raw markdown
|
|
245
|
-
*/
|
|
246
|
-
private extractHeadingLevel;
|
|
247
|
-
}
|
|
248
|
-
declare function mapHtmlToReact(html: string, elements: HtmlElements): React.ReactNode;
|
|
249
|
-
declare function renderParagraphMixedSegments(segments: MixedContentSegment[], inlineComponents: InlineComponents, inlineHtmlRenderers: InlineHtmlRendererMap): React.ReactNode[];
|
|
250
|
-
|
|
251
|
-
export { type BlockComponents as B, ComponentRegistry as C, DefaultLinkSafetyModal as D, type HtmlElements as H, type InlineHtmlRendererMap as I, type LinkSafetyModalProps as L, type Renderer as R, type TableElements as T, type InlineComponents as a, type InlineHtmlRenderer as b, type RendererConfig as c, defaultInlineComponents as d, defaultBlockComponents as e, renderParagraphMixedSegments as f, type CodeHighlightRangeRequest as g, mapHtmlToReact as m, renderInlineNodes as r };
|