react-native-nitro-markdown 0.7.1 → 0.8.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/README.md +179 -27
- package/ios/HybridMarkdownSession.swift +11 -4
- package/lib/commonjs/MarkdownContext.js +1 -3
- package/lib/commonjs/MarkdownContext.js.map +1 -1
- package/lib/commonjs/index.js +6 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/markdown-stream.js +113 -29
- package/lib/commonjs/markdown-stream.js.map +1 -1
- package/lib/commonjs/markdown.js +96 -38
- package/lib/commonjs/markdown.js.map +1 -1
- package/lib/commonjs/renderers/image.js +11 -2
- package/lib/commonjs/renderers/image.js.map +1 -1
- package/lib/commonjs/renderers/math.js +22 -2
- package/lib/commonjs/renderers/math.js.map +1 -1
- package/lib/commonjs/renderers/table/index.js +4 -4
- package/lib/commonjs/renderers/table/index.js.map +1 -1
- package/lib/commonjs/renderers/table/table-utils.js +1 -1
- package/lib/commonjs/renderers/table/table-utils.js.map +1 -1
- package/lib/commonjs/use-markdown-stream.js +2 -6
- package/lib/commonjs/use-markdown-stream.js.map +1 -1
- package/lib/commonjs/utils/code-highlight.js +1 -1
- package/lib/commonjs/utils/code-highlight.js.map +1 -1
- package/lib/commonjs/utils/incremental-ast.js +67 -14
- package/lib/commonjs/utils/incremental-ast.js.map +1 -1
- package/lib/commonjs/utils/link-security.js +2 -2
- package/lib/commonjs/utils/link-security.js.map +1 -1
- package/lib/commonjs/utils/stream-timeline.js +13 -7
- package/lib/commonjs/utils/stream-timeline.js.map +1 -1
- package/lib/module/MarkdownContext.js +1 -3
- package/lib/module/MarkdownContext.js.map +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/markdown-stream.js +113 -30
- package/lib/module/markdown-stream.js.map +1 -1
- package/lib/module/markdown.js +96 -38
- package/lib/module/markdown.js.map +1 -1
- package/lib/module/renderers/image.js +12 -3
- package/lib/module/renderers/image.js.map +1 -1
- package/lib/module/renderers/math.js +22 -2
- package/lib/module/renderers/math.js.map +1 -1
- package/lib/module/renderers/table/index.js +4 -4
- package/lib/module/renderers/table/index.js.map +1 -1
- package/lib/module/renderers/table/table-utils.js +1 -1
- package/lib/module/renderers/table/table-utils.js.map +1 -1
- package/lib/module/use-markdown-stream.js +2 -6
- package/lib/module/use-markdown-stream.js.map +1 -1
- package/lib/module/utils/code-highlight.js +1 -1
- package/lib/module/utils/code-highlight.js.map +1 -1
- package/lib/module/utils/incremental-ast.js +65 -13
- package/lib/module/utils/incremental-ast.js.map +1 -1
- package/lib/module/utils/link-security.js +2 -2
- package/lib/module/utils/link-security.js.map +1 -1
- package/lib/module/utils/stream-timeline.js +13 -7
- package/lib/module/utils/stream-timeline.js.map +1 -1
- package/lib/typescript/commonjs/MarkdownContext.d.ts +1 -0
- package/lib/typescript/commonjs/MarkdownContext.d.ts.map +1 -1
- package/lib/typescript/commonjs/index.d.ts +3 -3
- package/lib/typescript/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/markdown-stream.d.ts +28 -7
- package/lib/typescript/commonjs/markdown-stream.d.ts.map +1 -1
- package/lib/typescript/commonjs/markdown.d.ts.map +1 -1
- package/lib/typescript/commonjs/renderers/image.d.ts.map +1 -1
- package/lib/typescript/commonjs/renderers/math.d.ts.map +1 -1
- package/lib/typescript/commonjs/use-markdown-stream.d.ts.map +1 -1
- package/lib/typescript/commonjs/utils/incremental-ast.d.ts +1 -0
- package/lib/typescript/commonjs/utils/incremental-ast.d.ts.map +1 -1
- package/lib/typescript/commonjs/utils/stream-timeline.d.ts.map +1 -1
- package/lib/typescript/module/MarkdownContext.d.ts +1 -0
- package/lib/typescript/module/MarkdownContext.d.ts.map +1 -1
- package/lib/typescript/module/index.d.ts +3 -3
- package/lib/typescript/module/index.d.ts.map +1 -1
- package/lib/typescript/module/markdown-stream.d.ts +28 -7
- package/lib/typescript/module/markdown-stream.d.ts.map +1 -1
- package/lib/typescript/module/markdown.d.ts.map +1 -1
- package/lib/typescript/module/renderers/image.d.ts.map +1 -1
- package/lib/typescript/module/renderers/math.d.ts.map +1 -1
- package/lib/typescript/module/use-markdown-stream.d.ts.map +1 -1
- package/lib/typescript/module/utils/incremental-ast.d.ts +1 -0
- package/lib/typescript/module/utils/incremental-ast.d.ts.map +1 -1
- package/lib/typescript/module/utils/stream-timeline.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/MarkdownContext.ts +2 -2
- package/src/index.ts +10 -2
- package/src/markdown-stream.tsx +153 -36
- package/src/markdown.tsx +82 -42
- package/src/renderers/image.tsx +13 -2
- package/src/renderers/math.tsx +20 -2
- package/src/renderers/table/index.tsx +4 -4
- package/src/renderers/table/table-utils.ts +1 -1
- package/src/use-markdown-stream.ts +2 -6
- package/src/utils/code-highlight.ts +1 -1
- package/src/utils/incremental-ast.ts +104 -11
- package/src/utils/link-security.ts +3 -3
- package/src/utils/stream-timeline.ts +10 -7
package/README.md
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
# react-native-nitro-markdown
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/react-native-nitro-markdown)
|
|
4
|
+
[](https://www.npmjs.com/package/react-native-nitro-markdown)
|
|
5
|
+
[](https://github.com/JoaoPauloCMarra/react-native-nitro-markdown/actions/workflows/ci.yml)
|
|
4
6
|
[](https://github.com/JoaoPauloCMarra/react-native-nitro-markdown/blob/main/LICENSE)
|
|
5
7
|
[](https://reactnative.dev/)
|
|
6
|
-
[](https://expo.dev/)
|
|
7
|
-
[](https://
|
|
8
|
+
[](https://docs.expo.dev/versions/v56.0.0/)
|
|
9
|
+
[](https://www.npmjs.com/package/react-native-nitro-modules)
|
|
10
|
+
[](https://www.typescriptlang.org/)
|
|
8
11
|
|
|
9
12
|
Markdown parsing, rendering, streaming, and headless AST access for React
|
|
10
13
|
Native, powered by md4c and Nitro Modules.
|
|
11
14
|
|
|
12
|
-
Use it when you need GitHub-flavored Markdown, custom renderers,
|
|
13
|
-
chat
|
|
14
|
-
without building your own
|
|
15
|
+
Use it when you need GitHub-flavored Markdown, custom native renderers,
|
|
16
|
+
streaming chat or LLM output, syntax highlighting, math rendering, or headless
|
|
17
|
+
AST access without building your own parser pipeline.
|
|
15
18
|
|
|
16
19
|
<p align="center">
|
|
17
20
|
<img src="https://raw.githubusercontent.com/JoaoPauloCMarra/react-native-nitro-markdown/main/readme/demo.gif" alt="react-native-nitro-markdown demo" width="400" />
|
|
@@ -23,6 +26,9 @@ without building your own renderer pipeline.
|
|
|
23
26
|
bun add react-native-nitro-markdown react-native-nitro-modules ratex-react-native
|
|
24
27
|
```
|
|
25
28
|
|
|
29
|
+
`react-native-nitro-modules` and `ratex-react-native` are peer dependencies
|
|
30
|
+
because parsing and math rendering use native code.
|
|
31
|
+
|
|
26
32
|
For Expo development builds:
|
|
27
33
|
|
|
28
34
|
```sh
|
|
@@ -53,7 +59,7 @@ import { Markdown } from "react-native-nitro-markdown";
|
|
|
53
59
|
|
|
54
60
|
export function Article() {
|
|
55
61
|
return (
|
|
56
|
-
<Markdown options={{ gfm: true }}>
|
|
62
|
+
<Markdown options={{ gfm: true, math: true }}>
|
|
57
63
|
{"# Hello\nThis is **native** markdown."}
|
|
58
64
|
</Markdown>
|
|
59
65
|
);
|
|
@@ -63,13 +69,18 @@ export function Article() {
|
|
|
63
69
|
## Streaming
|
|
64
70
|
|
|
65
71
|
```tsx
|
|
72
|
+
import { useEffect } from "react";
|
|
66
73
|
import {
|
|
67
74
|
MarkdownStream,
|
|
68
75
|
useMarkdownSession,
|
|
69
76
|
} from "react-native-nitro-markdown";
|
|
70
77
|
|
|
71
78
|
export function ChatMessage({ text }: { text: string }) {
|
|
72
|
-
const session = useMarkdownSession(
|
|
79
|
+
const session = useMarkdownSession();
|
|
80
|
+
|
|
81
|
+
useEffect(() => {
|
|
82
|
+
session.reset(text);
|
|
83
|
+
}, [session, text]);
|
|
73
84
|
|
|
74
85
|
return (
|
|
75
86
|
<MarkdownStream session={session} updateStrategy="raf" incrementalParsing />
|
|
@@ -77,12 +88,65 @@ export function ChatMessage({ text }: { text: string }) {
|
|
|
77
88
|
}
|
|
78
89
|
```
|
|
79
90
|
|
|
80
|
-
|
|
91
|
+
For token-by-token output, append to the hook-owned session and let
|
|
92
|
+
`MarkdownStream` subscribe to range updates:
|
|
93
|
+
|
|
94
|
+
```tsx
|
|
95
|
+
const session = useMarkdownSession();
|
|
96
|
+
|
|
97
|
+
session.getSession().append("Hello ");
|
|
98
|
+
session.getSession().append("**world**");
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
`MarkdownStream` batches updates for append-only text. Use
|
|
102
|
+
`updateStrategy="raf"` for visual streaming, or `updateStrategy="interval"` with
|
|
103
|
+
`updateIntervalMs={50}` to bound update frequency. If any plugin uses
|
|
81
104
|
`beforeParse`, incremental AST optimization is disabled so the full pipeline can
|
|
82
105
|
run correctly. `MarkdownStream` accepts the controller returned by
|
|
83
106
|
`useMarkdownSession()`. Pass `session.getSession()` only when another API needs
|
|
84
107
|
direct access to the native session object.
|
|
85
108
|
|
|
109
|
+
### Custom stream rendering
|
|
110
|
+
|
|
111
|
+
Use `renderMarkdown` when you want `MarkdownStream` to keep the session
|
|
112
|
+
subscription, batching, and incremental AST updates while another component owns
|
|
113
|
+
the rendering. The callback receives the current text, the reusable source AST
|
|
114
|
+
when available, and `markdownProps` that match the built-in `Markdown`
|
|
115
|
+
component:
|
|
116
|
+
|
|
117
|
+
```tsx
|
|
118
|
+
<MarkdownStream
|
|
119
|
+
session={session}
|
|
120
|
+
renderMarkdown={({ text, sourceAst, markdownProps }) => (
|
|
121
|
+
<MyMarkdownRenderer
|
|
122
|
+
markdown={text}
|
|
123
|
+
ast={sourceAst}
|
|
124
|
+
fallbackProps={markdownProps}
|
|
125
|
+
/>
|
|
126
|
+
)}
|
|
127
|
+
/>
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Use `useMarkdownStreamState` when you want the streaming state without the
|
|
131
|
+
`MarkdownStream` wrapper:
|
|
132
|
+
|
|
133
|
+
```tsx
|
|
134
|
+
const { text, sourceAst, sourceAstStatus } = useMarkdownStreamState({
|
|
135
|
+
session,
|
|
136
|
+
updateStrategy: "raf",
|
|
137
|
+
});
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
`sourceAst` is available when the stream can safely reuse Nitro's parsed AST.
|
|
141
|
+
When a `beforeParse` plugin is present, `sourceAstStatus` becomes `"disabled"`
|
|
142
|
+
and `sourceAstDisabledReason` is `"beforeParse-plugin"`. In that state,
|
|
143
|
+
`sourceAst` is omitted; render from `text` so the full plugin pipeline can run.
|
|
144
|
+
|
|
145
|
+
`MarkdownStream` avoids full-buffer reads on stable parent renders. It uses
|
|
146
|
+
native range reads for append-only updates, then falls back to a full session
|
|
147
|
+
read only for reset-like changes, replacements inside existing text, or native
|
|
148
|
+
range-read failures.
|
|
149
|
+
|
|
86
150
|
## Headless Parsing
|
|
87
151
|
|
|
88
152
|
```ts
|
|
@@ -93,8 +157,8 @@ import {
|
|
|
93
157
|
} from "react-native-nitro-markdown/headless";
|
|
94
158
|
|
|
95
159
|
const ast = parseMarkdown("# Title");
|
|
96
|
-
const
|
|
97
|
-
|
|
160
|
+
const astWithMath = parseMarkdownWithOptions("Inline $x^2$", {
|
|
161
|
+
math: true,
|
|
98
162
|
});
|
|
99
163
|
const text = extractPlainText("Hello **world**");
|
|
100
164
|
```
|
|
@@ -102,22 +166,53 @@ const text = extractPlainText("Hello **world**");
|
|
|
102
166
|
Use the `react-native-nitro-markdown/headless` export when you need AST data,
|
|
103
167
|
plain text extraction, indexing, validation, or tests without rendering UI.
|
|
104
168
|
|
|
169
|
+
## Source AST Rendering
|
|
170
|
+
|
|
171
|
+
If you already have a `MarkdownNode`, pass it through the `sourceAst` prop to
|
|
172
|
+
skip native parsing during render:
|
|
173
|
+
|
|
174
|
+
```tsx
|
|
175
|
+
import {
|
|
176
|
+
Markdown,
|
|
177
|
+
parseMarkdown,
|
|
178
|
+
type MarkdownNode,
|
|
179
|
+
} from "react-native-nitro-markdown";
|
|
180
|
+
|
|
181
|
+
const ast: MarkdownNode = parseMarkdown("# Cached AST", { gfm: true });
|
|
182
|
+
|
|
183
|
+
<Markdown sourceAst={ast}>{"# Cached AST"}</Markdown>;
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
When `sourceAst` is provided, `beforeParse` plugins are skipped because parsing
|
|
187
|
+
already happened. `afterParse` plugins and `astTransform` still run.
|
|
188
|
+
|
|
105
189
|
## Common Options
|
|
106
190
|
|
|
107
|
-
|
|
|
108
|
-
|
|
|
109
|
-
| `gfm`
|
|
110
|
-
| `
|
|
111
|
-
| `
|
|
112
|
-
| `
|
|
113
|
-
| `
|
|
114
|
-
| `
|
|
191
|
+
| Prop or parser option | Default | What it does |
|
|
192
|
+
| --------------------- | ----------------- | --------------------------------------------------------- |
|
|
193
|
+
| `options.gfm` | `true` | Enables tables, strikethrough, task lists, and autolinks. |
|
|
194
|
+
| `options.math` | `true` | Parses inline and block math nodes. |
|
|
195
|
+
| `options.html` | `false` | Preserves raw HTML nodes for custom renderers. |
|
|
196
|
+
| `parseCache` | `true` | Reuses parsed ASTs for repeated content. |
|
|
197
|
+
| `sourceAst` | `undefined` | Renders a pre-parsed AST instead of parsing `children`. |
|
|
198
|
+
| `highlightCode` | `false` | Enables built-in syntax highlighting. |
|
|
199
|
+
| `tableOptions` | Built-in defaults | Controls table measurement and minimum widths. |
|
|
200
|
+
|
|
201
|
+
## Compatibility
|
|
202
|
+
|
|
203
|
+
| Dependency | Supported range or baseline |
|
|
204
|
+
| ---------- | --------------------------- |
|
|
205
|
+
| [React Native](https://reactnative.dev/) | `>=0.75.0` |
|
|
206
|
+
| [Nitro Modules](https://www.npmjs.com/package/react-native-nitro-modules) | `>=0.35.7` |
|
|
207
|
+
| [RaTeX React Native](https://www.npmjs.com/package/ratex-react-native) | `>=0.1.4` |
|
|
208
|
+
| [Expo](https://docs.expo.dev/versions/v56.0.0/) | SDK 56 development builds |
|
|
209
|
+
| [TypeScript](https://www.typescriptlang.org/) | 6.0 in this package workspace |
|
|
115
210
|
|
|
116
211
|
## Custom Rendering
|
|
117
212
|
|
|
118
213
|
```tsx
|
|
119
|
-
import
|
|
120
|
-
import { Markdown } from "react-native-nitro-markdown";
|
|
214
|
+
import { Text } from "react-native";
|
|
215
|
+
import { Markdown, type MarkdownRenderers } from "react-native-nitro-markdown";
|
|
121
216
|
|
|
122
217
|
const renderers: MarkdownRenderers = {
|
|
123
218
|
paragraph({ children }) {
|
|
@@ -131,6 +226,16 @@ const renderers: MarkdownRenderers = {
|
|
|
131
226
|
Custom renderers receive parsed nodes and pre-mapped props for common node
|
|
132
227
|
types. For `html_inline` and `html_block`, read `node.content` directly.
|
|
133
228
|
|
|
229
|
+
For stronger component-local typing, use the node-specific renderer props:
|
|
230
|
+
|
|
231
|
+
```tsx
|
|
232
|
+
import type { CodeBlockRendererProps } from "react-native-nitro-markdown";
|
|
233
|
+
|
|
234
|
+
function CodeBlock({ content, language }: CodeBlockRendererProps) {
|
|
235
|
+
return <Text>{`${language ?? "text"}: ${content}`}</Text>;
|
|
236
|
+
}
|
|
237
|
+
```
|
|
238
|
+
|
|
134
239
|
## Plugin Pipeline
|
|
135
240
|
|
|
136
241
|
```ts
|
|
@@ -148,9 +253,51 @@ const plugins: MarkdownPlugin[] = [
|
|
|
148
253
|
```
|
|
149
254
|
|
|
150
255
|
Pipeline order: `beforeParse` plugins, parse or `sourceAst`, `afterParse`
|
|
151
|
-
plugins, `astTransform`, then render.
|
|
152
|
-
|
|
153
|
-
|
|
256
|
+
plugins, `astTransform`, then render. Higher `priority` values run first, and
|
|
257
|
+
sorting is stable. `onError` receives `(error, phase, pluginName?)` for parser
|
|
258
|
+
and plugin failures.
|
|
259
|
+
|
|
260
|
+
## TypeScript Guidance
|
|
261
|
+
|
|
262
|
+
The public types are exported from the root package and the headless subpath.
|
|
263
|
+
Prefer package types over local object shapes so editors and AI tools can catch
|
|
264
|
+
invalid parser options, node names, renderer props, and stream session usage.
|
|
265
|
+
|
|
266
|
+
```tsx
|
|
267
|
+
import { Text } from "react-native";
|
|
268
|
+
import type {
|
|
269
|
+
CustomRendererPropsByNode,
|
|
270
|
+
MarkdownNode,
|
|
271
|
+
MarkdownPlugin,
|
|
272
|
+
MarkdownRenderers,
|
|
273
|
+
MarkdownStreamProps,
|
|
274
|
+
ParserOptions,
|
|
275
|
+
} from "react-native-nitro-markdown";
|
|
276
|
+
|
|
277
|
+
const options: ParserOptions = { gfm: true, math: true, html: false };
|
|
278
|
+
|
|
279
|
+
function HeadingRenderer({
|
|
280
|
+
children,
|
|
281
|
+
level,
|
|
282
|
+
}: CustomRendererPropsByNode["heading"]) {
|
|
283
|
+
return <Text accessibilityRole="header">{`${level}. ${children}`}</Text>;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
const renderers: MarkdownRenderers = {
|
|
287
|
+
heading: HeadingRenderer,
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
const plugin: MarkdownPlugin = {
|
|
291
|
+
name: "strip-tracking",
|
|
292
|
+
afterParse(ast: MarkdownNode) {
|
|
293
|
+
return ast;
|
|
294
|
+
},
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
const streamProps: Pick<MarkdownStreamProps, "updateStrategy"> = {
|
|
298
|
+
updateStrategy: "raf",
|
|
299
|
+
};
|
|
300
|
+
```
|
|
154
301
|
|
|
155
302
|
## API
|
|
156
303
|
|
|
@@ -159,13 +306,18 @@ Main export:
|
|
|
159
306
|
- `Markdown` for rendering complete markdown strings.
|
|
160
307
|
- `MarkdownStream` for incremental rendering.
|
|
161
308
|
- `MarkdownSession` and `useMarkdownSession()` for append/replace/reset flows.
|
|
309
|
+
- `useMarkdownStreamState()` for headless streaming text and AST state.
|
|
162
310
|
- `useStream()` for timestamped stream state.
|
|
163
311
|
- `defaultMarkdownTheme` and theme types.
|
|
164
312
|
- Renderer components such as `Paragraph`, `Heading`, `Link`, `CodeBlock`,
|
|
165
313
|
`List`, `Table`, and `Image`.
|
|
166
|
-
- Types including `MarkdownNode`, `MarkdownPlugin`, `
|
|
167
|
-
`
|
|
168
|
-
`MarkdownStreamProps
|
|
314
|
+
- Types including `MarkdownNode`, `MarkdownPlugin`, `CustomRenderers`,
|
|
315
|
+
`MarkdownRenderers`, `CustomRendererPropsByNode`, `ParserOptions`,
|
|
316
|
+
`MarkdownTheme`, `MarkdownSessionController`, `MarkdownStreamProps`,
|
|
317
|
+
`MarkdownStreamRenderProps`, `MarkdownStreamState`,
|
|
318
|
+
`MarkdownStreamSourceAstStatus`, `MarkdownStreamSourceAstDisabledReason`,
|
|
319
|
+
`UseMarkdownStreamStateOptions`, `CodeHighlighter`, `HighlightedToken`,
|
|
320
|
+
`TokenType`, and `UrlSafetyOptions`.
|
|
169
321
|
|
|
170
322
|
Headless export:
|
|
171
323
|
|
|
@@ -183,7 +335,7 @@ Headless export:
|
|
|
183
335
|
| iOS | Native parser through Nitro and md4c. |
|
|
184
336
|
| Android | Native parser through Nitro and md4c. |
|
|
185
337
|
| Expo | Development builds. |
|
|
186
|
-
| Web | Not
|
|
338
|
+
| Web | Not supported. The parser requires Nitro Modules (JSI); there is no web entrypoint and imports on web fail deterministically. |
|
|
187
339
|
|
|
188
340
|
## Troubleshooting
|
|
189
341
|
|
|
@@ -55,6 +55,13 @@ class HybridMarkdownSession: HybridMarkdownSessionSpec {
|
|
|
55
55
|
return (value as NSString).length
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
private func clampedIndex(_ value: Double, upperBound: Int) -> Int {
|
|
59
|
+
if value <= 0 { return 0 }
|
|
60
|
+
let upper = Double(upperBound)
|
|
61
|
+
if value >= upper { return upperBound }
|
|
62
|
+
return Int(value)
|
|
63
|
+
}
|
|
64
|
+
|
|
58
65
|
private func validateBufferSize(_ size: Int) throws {
|
|
59
66
|
if size > Self.maxBufferSize {
|
|
60
67
|
throw NSError(
|
|
@@ -120,8 +127,8 @@ class HybridMarkdownSession: HybridMarkdownSessionSpec {
|
|
|
120
127
|
|
|
121
128
|
let text = buffer as NSString
|
|
122
129
|
let length = text.length
|
|
123
|
-
let start =
|
|
124
|
-
let end = max(start,
|
|
130
|
+
let start = clampedIndex(from, upperBound: length)
|
|
131
|
+
let end = max(start, clampedIndex(to, upperBound: length))
|
|
125
132
|
return text.substring(with: NSRange(location: start, length: end - start))
|
|
126
133
|
}
|
|
127
134
|
|
|
@@ -179,8 +186,8 @@ class HybridMarkdownSession: HybridMarkdownSessionSpec {
|
|
|
179
186
|
}
|
|
180
187
|
let nsBuffer = NSMutableString(string: buffer)
|
|
181
188
|
let length = nsBuffer.length
|
|
182
|
-
start =
|
|
183
|
-
end = max(start,
|
|
189
|
+
start = clampedIndex(from, upperBound: length)
|
|
190
|
+
end = max(start, clampedIndex(to, upperBound: length))
|
|
184
191
|
try validateBufferSize(length - (end - start) + utf16Length(text))
|
|
185
192
|
nsBuffer.replaceCharacters(in: NSRange(location: start, length: end - start), with: text)
|
|
186
193
|
buffer = nsBuffer as String
|
|
@@ -9,9 +9,7 @@ var _theme = require("./theme.js");
|
|
|
9
9
|
const MarkdownContext = exports.MarkdownContext = /*#__PURE__*/(0, _react.createContext)({
|
|
10
10
|
renderers: {},
|
|
11
11
|
theme: _theme.defaultMarkdownTheme,
|
|
12
|
-
|
|
13
|
-
stylingStrategy: "opinionated",
|
|
14
|
-
onLinkPress: undefined
|
|
12
|
+
stylingStrategy: "opinionated"
|
|
15
13
|
});
|
|
16
14
|
const useMarkdownContext = () => (0, _react.useContext)(MarkdownContext);
|
|
17
15
|
exports.useMarkdownContext = useMarkdownContext;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","_theme","MarkdownContext","exports","createContext","renderers","theme","defaultMarkdownTheme","
|
|
1
|
+
{"version":3,"names":["_react","require","_theme","MarkdownContext","exports","createContext","renderers","theme","defaultMarkdownTheme","stylingStrategy","useMarkdownContext","useContext"],"sourceRoot":"../../src","sources":["MarkdownContext.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAOA,IAAAC,MAAA,GAAAD,OAAA;AAwIO,MAAME,eAAe,GAAAC,OAAA,CAAAD,eAAA,gBAAG,IAAAE,oBAAa,EAAuB;EACjEC,SAAS,EAAE,CAAC,CAAC;EACbC,KAAK,EAAEC,2BAAoB;EAC3BC,eAAe,EAAE;AACnB,CAAC,CAAC;AAEK,MAAMC,kBAAkB,GAAGA,CAAA,KAAM,IAAAC,iBAAU,EAACR,eAAe,CAAC;AAACC,OAAA,CAAAM,kBAAA,GAAAA,kBAAA","ignoreList":[]}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -195,6 +195,12 @@ Object.defineProperty(exports, "useMarkdownSession", {
|
|
|
195
195
|
return _useMarkdownStream.useMarkdownSession;
|
|
196
196
|
}
|
|
197
197
|
});
|
|
198
|
+
Object.defineProperty(exports, "useMarkdownStreamState", {
|
|
199
|
+
enumerable: true,
|
|
200
|
+
get: function () {
|
|
201
|
+
return _markdownStream.useMarkdownStreamState;
|
|
202
|
+
}
|
|
203
|
+
});
|
|
198
204
|
Object.defineProperty(exports, "useStream", {
|
|
199
205
|
enumerable: true,
|
|
200
206
|
get: function () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_headless","require","_markdown","_markdownStream","_MarkdownContext","_theme","_heading","_paragraph","_link","_blockquote","_horizontalRule","_code","_list","_table","_image","_math","_MarkdownSession","_useMarkdownStream","_codeHighlight"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_headless","require","_markdown","_markdownStream","_MarkdownContext","_theme","_heading","_paragraph","_link","_blockquote","_horizontalRule","_code","_list","_table","_image","_math","_MarkdownSession","_useMarkdownStream","_codeHighlight"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AAmBA,IAAAC,SAAA,GAAAD,OAAA;AASA,IAAAE,eAAA,GAAAF,OAAA;AAUA,IAAAG,gBAAA,GAAAH,OAAA;AAuBA,IAAAI,MAAA,GAAAJ,OAAA;AAYA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,UAAA,GAAAN,OAAA;AACA,IAAAO,KAAA,GAAAP,OAAA;AACA,IAAAQ,WAAA,GAAAR,OAAA;AACA,IAAAS,eAAA,GAAAT,OAAA;AACA,IAAAU,KAAA,GAAAV,OAAA;AACA,IAAAW,KAAA,GAAAX,OAAA;AACA,IAAAY,MAAA,GAAAZ,OAAA;AACA,IAAAa,MAAA,GAAAb,OAAA;AACA,IAAAc,KAAA,GAAAd,OAAA;AAEA,IAAAe,gBAAA,GAAAf,OAAA;AAEA,IAAAgB,kBAAA,GAAAhB,OAAA;AAQA,IAAAiB,cAAA,GAAAjB,OAAA","ignoreList":[]}
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.MarkdownStream = void 0;
|
|
7
|
+
exports.useMarkdownStreamState = useMarkdownStreamState;
|
|
7
8
|
var _react = require("react");
|
|
8
9
|
var _markdown = require("./markdown.js");
|
|
9
10
|
var _useMarkdownStream = require("./use-markdown-stream.js");
|
|
@@ -14,6 +15,20 @@ const normalizeOffset = value => {
|
|
|
14
15
|
if (value <= 0) return 0;
|
|
15
16
|
return Math.floor(value);
|
|
16
17
|
};
|
|
18
|
+
const normalizeParserOptions = options => {
|
|
19
|
+
if (!options) return undefined;
|
|
20
|
+
const gfm = options.gfm;
|
|
21
|
+
const math = options.math;
|
|
22
|
+
const html = options.html;
|
|
23
|
+
if (gfm === undefined && math === undefined && html === undefined) {
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
const normalized = {};
|
|
27
|
+
if (gfm !== undefined) normalized.gfm = gfm;
|
|
28
|
+
if (math !== undefined) normalized.math = math;
|
|
29
|
+
if (html !== undefined) normalized.html = html;
|
|
30
|
+
return normalized;
|
|
31
|
+
};
|
|
17
32
|
const resolveStreamText = ({
|
|
18
33
|
forceFullSync,
|
|
19
34
|
pendingFrom,
|
|
@@ -51,33 +66,41 @@ function warnStreamError(message, error) {
|
|
|
51
66
|
warn.call(console, message, error);
|
|
52
67
|
}
|
|
53
68
|
}
|
|
54
|
-
|
|
55
|
-
* A component that renders streaming Markdown from a MarkdownSession.
|
|
56
|
-
* It efficiently subscribes to session updates to minimize parent re-renders.
|
|
57
|
-
*/
|
|
58
|
-
const MarkdownStream = ({
|
|
69
|
+
function useMarkdownStreamState({
|
|
59
70
|
session,
|
|
60
71
|
updateIntervalMs = 50,
|
|
61
72
|
updateStrategy = "interval",
|
|
62
73
|
useTransitionUpdates = false,
|
|
63
74
|
incrementalParsing = true,
|
|
64
75
|
options,
|
|
65
|
-
plugins
|
|
66
|
-
|
|
67
|
-
}) => {
|
|
76
|
+
plugins
|
|
77
|
+
}) {
|
|
68
78
|
const activeSession = (0, _useMarkdownStream.resolveMarkdownSession)(session);
|
|
69
|
-
const
|
|
79
|
+
const parserOptionGfm = options?.gfm;
|
|
80
|
+
const parserOptionMath = options?.math;
|
|
81
|
+
const parserOptionHtml = options?.html;
|
|
82
|
+
const parserOptions = (0, _react.useMemo)(() => normalizeParserOptions(Object.assign({}, parserOptionGfm === undefined ? null : {
|
|
83
|
+
gfm: parserOptionGfm
|
|
84
|
+
}, parserOptionMath === undefined ? null : {
|
|
85
|
+
math: parserOptionMath
|
|
86
|
+
}, parserOptionHtml === undefined ? null : {
|
|
87
|
+
html: parserOptionHtml
|
|
88
|
+
})), [parserOptionGfm, parserOptionMath, parserOptionHtml]);
|
|
89
|
+
const parseText = (0, _react.useCallback)(text => (0, _incrementalAst.parseMarkdownAst)(text, parserOptions), [parserOptions]);
|
|
70
90
|
const createEmptyAst = () => ({
|
|
71
91
|
type: "document",
|
|
72
92
|
children: []
|
|
73
93
|
});
|
|
74
|
-
const initialText = activeSession.getAllText();
|
|
75
94
|
const hasBeforeParsePlugins = plugins?.some(plugin => typeof plugin.beforeParse === "function") ?? false;
|
|
76
|
-
const [renderState, setRenderState] = (0, _react.useState)(() =>
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
95
|
+
const [renderState, setRenderState] = (0, _react.useState)(() => {
|
|
96
|
+
const initialText = activeSession.getAllText();
|
|
97
|
+
return {
|
|
98
|
+
text: initialText,
|
|
99
|
+
ast: hasBeforeParsePlugins ? createEmptyAst() : parseText(initialText)
|
|
100
|
+
};
|
|
101
|
+
});
|
|
80
102
|
const renderStateRef = (0, _react.useRef)(renderState);
|
|
103
|
+
const didMountRef = (0, _react.useRef)(false);
|
|
81
104
|
const pendingUpdateRef = (0, _react.useRef)(false);
|
|
82
105
|
const pendingFromRef = (0, _react.useRef)(null);
|
|
83
106
|
const pendingToRef = (0, _react.useRef)(null);
|
|
@@ -96,6 +119,10 @@ const MarkdownStream = ({
|
|
|
96
119
|
};
|
|
97
120
|
}, []);
|
|
98
121
|
(0, _react.useEffect)(() => {
|
|
122
|
+
if (!didMountRef.current) {
|
|
123
|
+
didMountRef.current = true;
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
99
126
|
const initialText = activeSession.getAllText();
|
|
100
127
|
const initialState = {
|
|
101
128
|
text: initialText,
|
|
@@ -124,20 +151,28 @@ const MarkdownStream = ({
|
|
|
124
151
|
pendingFromRef.current = null;
|
|
125
152
|
pendingToRef.current = null;
|
|
126
153
|
forceFullSyncRef.current = false;
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
154
|
+
let latest;
|
|
155
|
+
try {
|
|
156
|
+
latest = resolveStreamText({
|
|
157
|
+
forceFullSync,
|
|
158
|
+
pendingFrom,
|
|
159
|
+
pendingTo,
|
|
160
|
+
previousText: previousState.text,
|
|
161
|
+
session: activeSession
|
|
162
|
+
});
|
|
163
|
+
} catch (error) {
|
|
164
|
+
warnStreamError("[NitroMarkdown] Failed to read stream session:", error);
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
134
167
|
if (latest === previousState.text) return;
|
|
135
168
|
const nextAst = hasBeforeParsePlugins ? previousState.ast : (0, _incrementalAst.getNextStreamAst)({
|
|
136
169
|
allowIncremental,
|
|
137
170
|
nextText: latest,
|
|
138
|
-
options,
|
|
139
171
|
previousAst: previousState.ast,
|
|
140
|
-
previousText: previousState.text
|
|
172
|
+
previousText: previousState.text,
|
|
173
|
+
...(parserOptions ? {
|
|
174
|
+
options: parserOptions
|
|
175
|
+
} : {})
|
|
141
176
|
});
|
|
142
177
|
const nextState = {
|
|
143
178
|
text: latest,
|
|
@@ -168,6 +203,7 @@ const MarkdownStream = ({
|
|
|
168
203
|
let unsubscribe = null;
|
|
169
204
|
try {
|
|
170
205
|
unsubscribe = activeSession.addListener((from, to) => {
|
|
206
|
+
if (!mountedRef.current) return;
|
|
171
207
|
const nextFrom = normalizeOffset(from);
|
|
172
208
|
const nextTo = normalizeOffset(to);
|
|
173
209
|
if (nextFrom === null || nextTo === null || nextTo < nextFrom) {
|
|
@@ -185,6 +221,10 @@ const MarkdownStream = ({
|
|
|
185
221
|
warnStreamError("[NitroMarkdown] Failed to subscribe to stream:", error);
|
|
186
222
|
}
|
|
187
223
|
return () => {
|
|
224
|
+
pendingUpdateRef.current = false;
|
|
225
|
+
pendingFromRef.current = null;
|
|
226
|
+
pendingToRef.current = null;
|
|
227
|
+
forceFullSyncRef.current = false;
|
|
188
228
|
try {
|
|
189
229
|
unsubscribe?.();
|
|
190
230
|
} catch (error) {
|
|
@@ -199,13 +239,57 @@ const MarkdownStream = ({
|
|
|
199
239
|
rafRef.current = null;
|
|
200
240
|
}
|
|
201
241
|
};
|
|
202
|
-
}, [allowIncremental, hasBeforeParsePlugins,
|
|
203
|
-
|
|
242
|
+
}, [allowIncremental, hasBeforeParsePlugins, parserOptions, activeSession, updateIntervalMs, updateStrategy, useTransitionUpdates]);
|
|
243
|
+
const streamState = {
|
|
244
|
+
text: renderState.text,
|
|
245
|
+
sourceAstStatus: hasBeforeParsePlugins ? "disabled" : "available"
|
|
246
|
+
};
|
|
247
|
+
if (hasBeforeParsePlugins) {
|
|
248
|
+
streamState.sourceAstDisabledReason = "beforeParse-plugin";
|
|
249
|
+
} else {
|
|
250
|
+
streamState.sourceAst = renderState.ast;
|
|
251
|
+
}
|
|
252
|
+
return streamState;
|
|
253
|
+
}
|
|
254
|
+
const MarkdownStream = ({
|
|
255
|
+
session,
|
|
256
|
+
updateIntervalMs = 50,
|
|
257
|
+
updateStrategy = "interval",
|
|
258
|
+
useTransitionUpdates = false,
|
|
259
|
+
incrementalParsing = true,
|
|
260
|
+
options,
|
|
261
|
+
plugins,
|
|
262
|
+
renderMarkdown,
|
|
263
|
+
...props
|
|
264
|
+
}) => {
|
|
265
|
+
const streamState = useMarkdownStreamState({
|
|
266
|
+
session,
|
|
267
|
+
updateIntervalMs,
|
|
268
|
+
updateStrategy,
|
|
269
|
+
useTransitionUpdates,
|
|
270
|
+
incrementalParsing,
|
|
271
|
+
...(options ? {
|
|
272
|
+
options
|
|
273
|
+
} : {}),
|
|
274
|
+
...(plugins ? {
|
|
275
|
+
plugins
|
|
276
|
+
} : {})
|
|
277
|
+
});
|
|
278
|
+
const markdownProps = {
|
|
204
279
|
...props,
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
280
|
+
children: streamState.text
|
|
281
|
+
};
|
|
282
|
+
if (options) markdownProps.options = options;
|
|
283
|
+
if (plugins) markdownProps.plugins = plugins;
|
|
284
|
+
if (streamState.sourceAst) markdownProps.sourceAst = streamState.sourceAst;
|
|
285
|
+
if (renderMarkdown) {
|
|
286
|
+
return renderMarkdown({
|
|
287
|
+
...streamState,
|
|
288
|
+
markdownProps
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_markdown.Markdown, {
|
|
292
|
+
...markdownProps
|
|
209
293
|
});
|
|
210
294
|
};
|
|
211
295
|
exports.MarkdownStream = MarkdownStream;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","_markdown","_useMarkdownStream","_incrementalAst","_jsxRuntime","normalizeOffset","value","Number","isFinite","Math","floor","resolveStreamText","forceFullSync","pendingFrom","pendingTo","previousText","session","getAllText","length","appendedChunk","getTextRange","warnStreamError","message","error","__DEV__","warn","Reflect","get","console","call","MarkdownStream","updateIntervalMs","updateStrategy","useTransitionUpdates","incrementalParsing","options","plugins","props","activeSession","resolveMarkdownSession","parseText","useCallback","text","parseMarkdownAst","createEmptyAst","type","children","initialText","hasBeforeParsePlugins","some","plugin","beforeParse","renderState","setRenderState","useState","ast","renderStateRef","useRef","pendingUpdateRef","pendingFromRef","pendingToRef","forceFullSyncRef","updateTimerRef","rafRef","mountedRef","allowIncremental","useEffect","current","initialState","flushUpdate","cancelAnimationFrame","previousState","latest","nextAst","getNextStreamAst","nextText","previousAst","nextState","startTransition","scheduleFlush","requestAnimationFrame","setTimeout","unsubscribe","addListener","from","to","nextFrom","nextTo","currentFrom","currentTo","min","max","clearTimeout","jsx","Markdown","sourceAst","undefined","exports"],"sourceRoot":"../../src","sources":["markdown-stream.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AASA,IAAAC,SAAA,GAAAD,OAAA;AAEA,IAAAE,kBAAA,GAAAF,OAAA;AAIA,IAAAG,eAAA,GAAAH,OAAA;AAA6E,IAAAI,WAAA,GAAAJ,OAAA;AAE7E,MAAMK,eAAe,GAAIC,KAAa,IAAoB;EACxD,IAAI,CAACC,MAAM,CAACC,QAAQ,CAACF,KAAK,CAAC,EAA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CAAC;MACjB,CAAC,CAAC;IACJ,CAAC,CAAC,OAAOxD,KAAK,EAAE;MACdF,eAAe,CAAC,gDAAgD,EAAEE,KAAK,CAAC;IAC1E;IAEA,OAAO,MAAM;MACX,IAAI;QACF2D,WAAW,GAAG,CAAC;MACjB,CAAC,CAAC,OAAO3D,KAAK,EAAE;QACdF,eAAe,CACb,oDAAoD,EACpDE,KACF,CAAC;MACH;MACA,IAAIuC,cAAc,CAACK,OAAO,EAAE;QAC1ByB,YAAY,CAAC9B,cAAc,CAACK,OAAO,CAAC;QACpCL,cAAc,CAACK,OAAO,GAAG,IAAI;MAC/B;MACA,IAAIJ,MAAM,CAACI,OAAO,KAAK,IAAI,EAAE;QAC3BG,oBAAoB,CAACP,MAAM,CAACI,OAAO,CAAC;QACpCJ,MAAM,CAACI,OAAO,GAAG,IAAI;MACvB;IACF,CAAC;EACH,CAAC,EAAE,CACDF,gBAAgB,EAChBjB,qBAAqB,EACrBb,OAAO,EACPC,OAAO,EACPE,aAAa,EACbP,gBAAgB,EAChBC,cAAc,EACdC,oBAAoB,CACrB,CAAC;EAEF,oBACE,IAAA7B,WAAA,CAAAyF,GAAA,EAAC5F,SAAA,CAAA6F,QAAQ;IAAA,GACHzD,KAAK;IACTF,OAAO,EAAEA,OAAQ;IACjBC,OAAO,EAAEA,OAAQ;IACjB2D,SAAS,EAAE/C,qBAAqB,GAAGgD,SAAS,GAAG5C,WAAW,CAACG,GAAI;IAAAT,QAAA,EAE9DM,WAAW,CAACV;EAAI,CACT,CAAC;AAEf,CAAC;AAACuD,OAAA,CAAAnE,cAAA,GAAAA,cAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_react","require","_markdown","_useMarkdownStream","_incrementalAst","_jsxRuntime","normalizeOffset","value","Number","isFinite","Math","floor","normalizeParserOptions","options","undefined","gfm","math","html","normalized","resolveStreamText","forceFullSync","pendingFrom","pendingTo","previousText","session","getAllText","length","appendedChunk","getTextRange","warnStreamError","message","error","__DEV__","warn","Reflect","get","console","call","useMarkdownStreamState","updateIntervalMs","updateStrategy","useTransitionUpdates","incrementalParsing","plugins","activeSession","resolveMarkdownSession","parserOptionGfm","parserOptionMath","parserOptionHtml","parserOptions","useMemo","Object","assign","parseText","useCallback","text","parseMarkdownAst","createEmptyAst","type","children","hasBeforeParsePlugins","some","plugin","beforeParse","renderState","setRenderState","useState","initialText","ast","renderStateRef","useRef","didMountRef","pendingUpdateRef","pendingFromRef","pendingToRef","forceFullSyncRef","updateTimerRef","rafRef","mountedRef","allowIncremental","useEffect","current","initialState","flushUpdate","cancelAnimationFrame","previousState","latest","nextAst","getNextStreamAst","nextText","previousAst","nextState","startTransition","scheduleFlush","requestAnimationFrame","setTimeout","unsubscribe","addListener","from","to","nextFrom","nextTo","currentFrom","currentTo","min","max","clearTimeout","streamState","sourceAstStatus","sourceAstDisabledReason","sourceAst","MarkdownStream","renderMarkdown","props","markdownProps","jsx","Markdown","exports"],"sourceRoot":"../../src","sources":["markdown-stream.tsx"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAYA,IAAAC,SAAA,GAAAD,OAAA;AAEA,IAAAE,kBAAA,GAAAF,OAAA;AAIA,IAAAG,eAAA,GAAAH,OAAA;AAA6E,IAAAI,WAAA,GAAAJ,OAAA;AAE7E,MAAMK,eAAe,GAAIC,KAAa,IAAoB;EACxD,IAAI,CAACC,MAAM,CAACC,QAAQ,CAACF,KAAK,CAAC,EAAE,OAAO,IAAI;EACxC,IAAIA,KAAK,IAAI,CAAC,EAAE,OAAO,CAAC;EACxB,OAAOG,IAAI,CAACC,KAAK,CAACJ,KAAK,CAAC;AAC1B,CAAC;AAED,MAAMK,sBAAsB,GAC1BC,OAAuB,IACO;EAC9B,IAAI,CAACA,OAAO,EAAE,OAAOC,SAAS;EAE9B,MAAMC,GAAG,GAAGF,OAAO,CAACE,GAAG;EACvB,MAAMC,IAAI,GAAGH,OAAO,CAACG,IAAI;EACzB,MAAMC,IAAI,GAAGJ,OAAO,C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