react-native-nitro-markdown 0.1.2 → 0.2.1

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 (238) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +142 -84
  3. package/android/src/main/cpp/cpp-adapter.cpp +1 -1
  4. package/android/src/main/java/com/margelo/nitro/com/nitromarkdown/HybridMarkdownSession.kt +61 -0
  5. package/android/src/main/java/com/nitromarkdown/NitroMarkdownPackage.kt +5 -1
  6. package/cpp/bindings/HybridMarkdownParser.cpp +2 -2
  7. package/cpp/bindings/HybridMarkdownParser.hpp +2 -2
  8. package/cpp/bindings/HybridMarkdownSession.cpp +0 -0
  9. package/cpp/core/MarkdownSessionCore.cpp +0 -0
  10. package/ios/HybridMarkdownSession.swift +64 -0
  11. package/lib/commonjs/MarkdownContext.js +21 -0
  12. package/lib/commonjs/MarkdownContext.js.map +1 -0
  13. package/lib/commonjs/MarkdownSession.js +11 -0
  14. package/lib/commonjs/MarkdownSession.js.map +1 -0
  15. package/lib/commonjs/default-markdown-renderer.js +220 -0
  16. package/lib/commonjs/default-markdown-renderer.js.map +1 -0
  17. package/lib/commonjs/headless.js +50 -0
  18. package/lib/commonjs/headless.js.map +1 -0
  19. package/lib/commonjs/index.js +185 -13
  20. package/lib/commonjs/index.js.map +1 -1
  21. package/lib/commonjs/markdown-stream.js +32 -0
  22. package/lib/commonjs/markdown-stream.js.map +1 -0
  23. package/lib/commonjs/markdown.js +326 -0
  24. package/lib/commonjs/markdown.js.map +1 -0
  25. package/lib/commonjs/package.json +1 -0
  26. package/lib/commonjs/renderers/blockquote.js +36 -0
  27. package/lib/commonjs/renderers/blockquote.js.map +1 -0
  28. package/lib/commonjs/renderers/code.js +92 -0
  29. package/lib/commonjs/renderers/code.js.map +1 -0
  30. package/lib/commonjs/renderers/heading.js +62 -0
  31. package/lib/commonjs/renderers/heading.js.map +1 -0
  32. package/lib/commonjs/renderers/horizontal-rule.js +27 -0
  33. package/lib/commonjs/renderers/horizontal-rule.js.map +1 -0
  34. package/lib/commonjs/renderers/image.js +159 -0
  35. package/lib/commonjs/renderers/image.js.map +1 -0
  36. package/lib/commonjs/renderers/link.js +37 -0
  37. package/lib/commonjs/renderers/link.js.map +1 -0
  38. package/lib/commonjs/renderers/list.js +114 -0
  39. package/lib/commonjs/renderers/list.js.map +1 -0
  40. package/lib/commonjs/renderers/math.js +151 -0
  41. package/lib/commonjs/renderers/math.js.map +1 -0
  42. package/lib/commonjs/renderers/paragraph.js +44 -0
  43. package/lib/commonjs/renderers/paragraph.js.map +1 -0
  44. package/lib/commonjs/renderers/table.js +283 -0
  45. package/lib/commonjs/renderers/table.js.map +1 -0
  46. package/lib/commonjs/specs/MarkdownSession.nitro.js +6 -0
  47. package/lib/commonjs/specs/MarkdownSession.nitro.js.map +1 -0
  48. package/lib/commonjs/theme.js +58 -0
  49. package/lib/commonjs/theme.js.map +1 -0
  50. package/lib/commonjs/use-markdown-stream.js +71 -0
  51. package/lib/commonjs/use-markdown-stream.js.map +1 -0
  52. package/lib/module/MarkdownContext.js +17 -0
  53. package/lib/module/MarkdownContext.js.map +1 -0
  54. package/lib/module/MarkdownSession.js +7 -0
  55. package/lib/module/MarkdownSession.js.map +1 -0
  56. package/lib/module/default-markdown-renderer.js +215 -0
  57. package/lib/module/default-markdown-renderer.js.map +1 -0
  58. package/lib/module/headless.js +44 -0
  59. package/lib/module/headless.js.map +1 -0
  60. package/lib/module/index.js +36 -10
  61. package/lib/module/index.js.map +1 -1
  62. package/lib/module/markdown-stream.js +27 -0
  63. package/lib/module/markdown-stream.js.map +1 -0
  64. package/lib/module/markdown.js +321 -0
  65. package/lib/module/markdown.js.map +1 -0
  66. package/lib/module/package.json +1 -0
  67. package/lib/module/renderers/blockquote.js +31 -0
  68. package/lib/module/renderers/blockquote.js.map +1 -0
  69. package/lib/module/renderers/code.js +86 -0
  70. package/lib/module/renderers/code.js.map +1 -0
  71. package/lib/module/renderers/heading.js +57 -0
  72. package/lib/module/renderers/heading.js.map +1 -0
  73. package/lib/module/renderers/horizontal-rule.js +22 -0
  74. package/lib/module/renderers/horizontal-rule.js.map +1 -0
  75. package/lib/module/renderers/image.js +154 -0
  76. package/lib/module/renderers/image.js.map +1 -0
  77. package/lib/module/renderers/link.js +32 -0
  78. package/lib/module/renderers/link.js.map +1 -0
  79. package/lib/module/renderers/list.js +107 -0
  80. package/lib/module/renderers/list.js.map +1 -0
  81. package/lib/module/renderers/math.js +145 -0
  82. package/lib/module/renderers/math.js.map +1 -0
  83. package/lib/module/renderers/paragraph.js +39 -0
  84. package/lib/module/renderers/paragraph.js.map +1 -0
  85. package/lib/module/renderers/table.js +278 -0
  86. package/lib/module/renderers/table.js.map +1 -0
  87. package/lib/module/specs/MarkdownSession.nitro.js +4 -0
  88. package/lib/module/specs/MarkdownSession.nitro.js.map +1 -0
  89. package/lib/module/theme.js +54 -0
  90. package/lib/module/theme.js.map +1 -0
  91. package/lib/module/use-markdown-stream.js +66 -0
  92. package/lib/module/use-markdown-stream.js.map +1 -0
  93. package/lib/typescript/commonjs/Markdown.nitro.d.ts.map +1 -0
  94. package/lib/typescript/commonjs/MarkdownContext.d.ts +26 -0
  95. package/lib/typescript/commonjs/MarkdownContext.d.ts.map +1 -0
  96. package/lib/typescript/commonjs/MarkdownSession.d.ts +4 -0
  97. package/lib/typescript/commonjs/MarkdownSession.d.ts.map +1 -0
  98. package/lib/typescript/commonjs/default-markdown-renderer.d.ts +10 -0
  99. package/lib/typescript/commonjs/default-markdown-renderer.d.ts.map +1 -0
  100. package/lib/typescript/commonjs/headless.d.ts +50 -0
  101. package/lib/typescript/commonjs/headless.d.ts.map +1 -0
  102. package/lib/typescript/commonjs/index.d.ts +34 -0
  103. package/lib/typescript/commonjs/index.d.ts.map +1 -0
  104. package/lib/typescript/commonjs/markdown-stream.d.ts +15 -0
  105. package/lib/typescript/commonjs/markdown-stream.d.ts.map +1 -0
  106. package/lib/typescript/commonjs/markdown.d.ts +29 -0
  107. package/lib/typescript/commonjs/markdown.d.ts.map +1 -0
  108. package/lib/typescript/commonjs/package.json +1 -0
  109. package/lib/typescript/commonjs/renderers/blockquote.d.ts +9 -0
  110. package/lib/typescript/commonjs/renderers/blockquote.d.ts.map +1 -0
  111. package/lib/typescript/commonjs/renderers/code.d.ts +15 -0
  112. package/lib/typescript/commonjs/renderers/code.d.ts.map +1 -0
  113. package/lib/typescript/commonjs/renderers/heading.d.ts +10 -0
  114. package/lib/typescript/commonjs/renderers/heading.d.ts.map +1 -0
  115. package/lib/typescript/commonjs/renderers/horizontal-rule.d.ts +3 -0
  116. package/lib/typescript/commonjs/renderers/horizontal-rule.d.ts.map +1 -0
  117. package/lib/typescript/commonjs/renderers/image.d.ts +11 -0
  118. package/lib/typescript/commonjs/renderers/image.d.ts.map +1 -0
  119. package/lib/typescript/commonjs/renderers/link.d.ts +10 -0
  120. package/lib/typescript/commonjs/renderers/link.d.ts.map +1 -0
  121. package/lib/typescript/commonjs/renderers/list.d.ts +22 -0
  122. package/lib/typescript/commonjs/renderers/list.d.ts.map +1 -0
  123. package/lib/typescript/commonjs/renderers/math.d.ts +15 -0
  124. package/lib/typescript/commonjs/renderers/math.d.ts.map +1 -0
  125. package/lib/typescript/commonjs/renderers/paragraph.d.ts +15 -0
  126. package/lib/typescript/commonjs/renderers/paragraph.d.ts.map +1 -0
  127. package/lib/typescript/commonjs/renderers/table.d.ts +10 -0
  128. package/lib/typescript/commonjs/renderers/table.d.ts.map +1 -0
  129. package/lib/typescript/commonjs/specs/MarkdownSession.nitro.d.ts +12 -0
  130. package/lib/typescript/commonjs/specs/MarkdownSession.nitro.d.ts.map +1 -0
  131. package/lib/typescript/commonjs/theme.d.ts +52 -0
  132. package/lib/typescript/commonjs/theme.d.ts.map +1 -0
  133. package/lib/typescript/commonjs/use-markdown-stream.d.ts +22 -0
  134. package/lib/typescript/commonjs/use-markdown-stream.d.ts.map +1 -0
  135. package/lib/typescript/module/Markdown.nitro.d.ts +13 -0
  136. package/lib/typescript/module/Markdown.nitro.d.ts.map +1 -0
  137. package/lib/typescript/module/MarkdownContext.d.ts +26 -0
  138. package/lib/typescript/module/MarkdownContext.d.ts.map +1 -0
  139. package/lib/typescript/module/MarkdownSession.d.ts +4 -0
  140. package/lib/typescript/module/MarkdownSession.d.ts.map +1 -0
  141. package/lib/typescript/module/default-markdown-renderer.d.ts +10 -0
  142. package/lib/typescript/module/default-markdown-renderer.d.ts.map +1 -0
  143. package/lib/typescript/module/headless.d.ts +50 -0
  144. package/lib/typescript/module/headless.d.ts.map +1 -0
  145. package/lib/typescript/module/index.d.ts +34 -0
  146. package/lib/typescript/module/index.d.ts.map +1 -0
  147. package/lib/typescript/module/markdown-stream.d.ts +15 -0
  148. package/lib/typescript/module/markdown-stream.d.ts.map +1 -0
  149. package/lib/typescript/module/markdown.d.ts +29 -0
  150. package/lib/typescript/module/markdown.d.ts.map +1 -0
  151. package/lib/typescript/module/package.json +1 -0
  152. package/lib/typescript/module/renderers/blockquote.d.ts +9 -0
  153. package/lib/typescript/module/renderers/blockquote.d.ts.map +1 -0
  154. package/lib/typescript/module/renderers/code.d.ts +15 -0
  155. package/lib/typescript/module/renderers/code.d.ts.map +1 -0
  156. package/lib/typescript/module/renderers/heading.d.ts +10 -0
  157. package/lib/typescript/module/renderers/heading.d.ts.map +1 -0
  158. package/lib/typescript/module/renderers/horizontal-rule.d.ts +3 -0
  159. package/lib/typescript/module/renderers/horizontal-rule.d.ts.map +1 -0
  160. package/lib/typescript/module/renderers/image.d.ts +11 -0
  161. package/lib/typescript/module/renderers/image.d.ts.map +1 -0
  162. package/lib/typescript/module/renderers/link.d.ts +10 -0
  163. package/lib/typescript/module/renderers/link.d.ts.map +1 -0
  164. package/lib/typescript/module/renderers/list.d.ts +22 -0
  165. package/lib/typescript/module/renderers/list.d.ts.map +1 -0
  166. package/lib/typescript/module/renderers/math.d.ts +15 -0
  167. package/lib/typescript/module/renderers/math.d.ts.map +1 -0
  168. package/lib/typescript/module/renderers/paragraph.d.ts +15 -0
  169. package/lib/typescript/module/renderers/paragraph.d.ts.map +1 -0
  170. package/lib/typescript/module/renderers/table.d.ts +10 -0
  171. package/lib/typescript/module/renderers/table.d.ts.map +1 -0
  172. package/lib/typescript/module/specs/MarkdownSession.nitro.d.ts +12 -0
  173. package/lib/typescript/module/specs/MarkdownSession.nitro.d.ts.map +1 -0
  174. package/lib/typescript/module/theme.d.ts +52 -0
  175. package/lib/typescript/module/theme.d.ts.map +1 -0
  176. package/lib/typescript/module/use-markdown-stream.d.ts +22 -0
  177. package/lib/typescript/module/use-markdown-stream.d.ts.map +1 -0
  178. package/nitro.json +5 -2
  179. package/nitrogen/generated/android/NitroMarkdown+autolinking.cmake +3 -2
  180. package/nitrogen/generated/android/NitroMarkdown+autolinking.gradle +1 -1
  181. package/nitrogen/generated/android/NitroMarkdownOnLoad.cpp +17 -5
  182. package/nitrogen/generated/android/NitroMarkdownOnLoad.hpp +4 -4
  183. package/nitrogen/generated/android/c++/JFunc_void.hpp +75 -0
  184. package/nitrogen/generated/android/c++/JHybridMarkdownSessionSpec.cpp +91 -0
  185. package/nitrogen/generated/android/c++/JHybridMarkdownSessionSpec.hpp +70 -0
  186. package/nitrogen/generated/android/kotlin/com/margelo/nitro/com/nitromarkdown/Func_void.kt +80 -0
  187. package/nitrogen/generated/android/kotlin/com/margelo/nitro/com/nitromarkdown/HybridMarkdownSessionSpec.kt +78 -0
  188. package/nitrogen/generated/android/kotlin/com/margelo/nitro/com/nitromarkdown/NitroMarkdownOnLoad.kt +1 -1
  189. package/nitrogen/generated/ios/NitroMarkdown+autolinking.rb +2 -2
  190. package/nitrogen/generated/ios/NitroMarkdown-Swift-Cxx-Bridge.cpp +28 -4
  191. package/nitrogen/generated/ios/NitroMarkdown-Swift-Cxx-Bridge.hpp +72 -6
  192. package/nitrogen/generated/ios/NitroMarkdown-Swift-Cxx-Umbrella.hpp +11 -4
  193. package/nitrogen/generated/ios/NitroMarkdownAutolinking.mm +11 -3
  194. package/nitrogen/generated/ios/NitroMarkdownAutolinking.swift +16 -3
  195. package/nitrogen/generated/ios/c++/HybridMarkdownSessionSpecSwift.cpp +11 -0
  196. package/nitrogen/generated/ios/c++/HybridMarkdownSessionSpecSwift.hpp +108 -0
  197. package/nitrogen/generated/ios/swift/Func_void.swift +47 -0
  198. package/nitrogen/generated/ios/swift/HybridMarkdownSessionSpec.swift +59 -0
  199. package/nitrogen/generated/ios/swift/HybridMarkdownSessionSpec_cxx.swift +190 -0
  200. package/nitrogen/generated/shared/c++/HybridMarkdownParserSpec.cpp +3 -3
  201. package/nitrogen/generated/shared/c++/HybridMarkdownParserSpec.hpp +4 -4
  202. package/nitrogen/generated/shared/c++/HybridMarkdownSessionSpec.cpp +26 -0
  203. package/nitrogen/generated/shared/c++/HybridMarkdownSessionSpec.hpp +67 -0
  204. package/nitrogen/generated/shared/c++/ParserOptions.hpp +22 -14
  205. package/package.json +45 -7
  206. package/react-native-nitro-markdown.podspec +5 -5
  207. package/src/MarkdownContext.ts +41 -0
  208. package/src/MarkdownSession.ts +8 -0
  209. package/src/default-markdown-renderer.tsx +266 -0
  210. package/src/headless.ts +106 -0
  211. package/src/index.ts +41 -59
  212. package/src/markdown-stream.tsx +32 -0
  213. package/src/markdown.tsx +415 -0
  214. package/src/renderers/blockquote.tsx +31 -0
  215. package/src/renderers/code.tsx +88 -0
  216. package/src/renderers/heading.tsx +66 -0
  217. package/src/renderers/horizontal-rule.tsx +20 -0
  218. package/src/renderers/image.tsx +160 -0
  219. package/src/renderers/link.tsx +38 -0
  220. package/src/renderers/list.tsx +125 -0
  221. package/src/renderers/math.tsx +164 -0
  222. package/src/renderers/paragraph.tsx +53 -0
  223. package/src/renderers/table.tsx +345 -0
  224. package/src/specs/MarkdownSession.nitro.ts +16 -0
  225. package/src/theme.ts +52 -0
  226. package/src/use-markdown-stream.ts +83 -0
  227. package/ios/NitroMarkdown-Bridging-Header.h +0 -14
  228. package/lib/commonjs/MarkdownJS.reference.js +0 -114
  229. package/lib/commonjs/MarkdownJS.reference.js.map +0 -1
  230. package/lib/module/MarkdownJS.reference.js +0 -107
  231. package/lib/module/MarkdownJS.reference.js.map +0 -1
  232. package/lib/typescript/Markdown.nitro.d.ts.map +0 -1
  233. package/lib/typescript/MarkdownJS.reference.d.ts +0 -33
  234. package/lib/typescript/MarkdownJS.reference.d.ts.map +0 -1
  235. package/lib/typescript/index.d.ts +0 -22
  236. package/lib/typescript/index.d.ts.map +0 -1
  237. package/src/MarkdownJS.reference.ts +0 -122
  238. /package/lib/typescript/{Markdown.nitro.d.ts → commonjs/Markdown.nitro.d.ts} +0 -0
@@ -0,0 +1,278 @@
1
+ "use strict";
2
+
3
+ import { useMemo, useRef, useState, useCallback, useEffect } from "react";
4
+ import { View, Text, StyleSheet, ScrollView } from "react-native";
5
+ import { useMarkdownContext } from "../MarkdownContext.js";
6
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
7
+ const extractTableData = node => {
8
+ const headers = [];
9
+ const rows = [];
10
+ const alignments = [];
11
+ const head = node.children?.find(c => c.type === "table_head");
12
+ const body = node.children?.find(c => c.type === "table_body");
13
+
14
+ // Extract Headers
15
+ head?.children?.forEach(row => {
16
+ if (row.type === "table_row") {
17
+ row.children?.forEach(cell => {
18
+ if (cell.type === "table_cell") {
19
+ headers.push(cell);
20
+ alignments.push(cell.align);
21
+ }
22
+ });
23
+ }
24
+ });
25
+
26
+ // Extract Body Rows
27
+ body?.children?.forEach(row => {
28
+ if (row.type === "table_row") {
29
+ const rowCells = [];
30
+ row.children?.forEach(cell => {
31
+ if (cell.type === "table_cell") {
32
+ rowCells.push(cell);
33
+ }
34
+ });
35
+ if (rowCells.length > 0) rows.push(rowCells);
36
+ }
37
+ });
38
+ return {
39
+ headers,
40
+ rows,
41
+ alignments
42
+ };
43
+ };
44
+ export const TableRenderer = ({
45
+ node,
46
+ Renderer
47
+ }) => {
48
+ const {
49
+ theme
50
+ } = useMarkdownContext();
51
+ const {
52
+ headers,
53
+ rows,
54
+ alignments
55
+ } = useMemo(() => extractTableData(node), [node]);
56
+ const columnCount = headers.length;
57
+ const styles = useMemo(() => createTableStyles(theme), [theme]);
58
+ const [columnWidths, setColumnWidths] = useState([]);
59
+ const measuredWidths = useRef(new Map());
60
+ const hasAppliedWidths = useRef(false);
61
+ const calculateAndApplyWidths = useCallback(() => {
62
+ if (columnCount === 0) return;
63
+ const finalWidths = new Array(columnCount).fill(0);
64
+ for (let col = 0; col < columnCount; col++) {
65
+ let maxWidth = measuredWidths.current.get(`h-${col}`) || 0;
66
+ for (let row = 0; row < rows.length; row++) {
67
+ const cellWidth = measuredWidths.current.get(`c-${row}-${col}`) || 0;
68
+ if (cellWidth > maxWidth) maxWidth = cellWidth;
69
+ }
70
+ // Apply padding and min-width
71
+ finalWidths[col] = Math.max(maxWidth + 32, 100);
72
+ }
73
+ setColumnWidths(finalWidths);
74
+ hasAppliedWidths.current = true;
75
+ }, [columnCount, rows.length]);
76
+ useEffect(() => {
77
+ if (columnCount === 0) return;
78
+ const timer = setTimeout(() => {
79
+ if (!hasAppliedWidths.current) {
80
+ calculateAndApplyWidths();
81
+ }
82
+ }, 400);
83
+ return () => clearTimeout(timer);
84
+ }, [columnCount, rows.length, calculateAndApplyWidths]);
85
+ const onLayout = (key, width) => {
86
+ if (hasAppliedWidths.current) return;
87
+ measuredWidths.current.set(key, width);
88
+ const expectedCount = columnCount + rows.length * columnCount;
89
+ if (measuredWidths.current.size >= expectedCount) {
90
+ calculateAndApplyWidths();
91
+ }
92
+ };
93
+ const getAlignStyle = index => {
94
+ const align = alignments[index];
95
+ if (align === "center") return {
96
+ alignItems: "center",
97
+ textAlign: "center"
98
+ };
99
+ if (align === "right") return {
100
+ alignItems: "flex-end",
101
+ textAlign: "right"
102
+ };
103
+ return {
104
+ alignItems: "flex-start",
105
+ textAlign: "left"
106
+ };
107
+ };
108
+ if (columnCount === 0) return null;
109
+ return /*#__PURE__*/_jsxs(View, {
110
+ style: styles.container,
111
+ children: [!hasAppliedWidths.current && /*#__PURE__*/_jsxs(View, {
112
+ style: styles.measurementWrapper,
113
+ pointerEvents: "none",
114
+ children: [/*#__PURE__*/_jsx(View, {
115
+ style: styles.row,
116
+ children: headers.map((cell, i) => /*#__PURE__*/_jsx(View, {
117
+ onLayout: e => onLayout(`h-${i}`, e.nativeEvent.layout.width),
118
+ style: styles.measuringCell,
119
+ children: /*#__PURE__*/_jsx(CellContent, {
120
+ node: cell,
121
+ Renderer: Renderer,
122
+ styles: styles
123
+ })
124
+ }, `m-h-${i}`))
125
+ }), rows.map((row, ri) => /*#__PURE__*/_jsx(View, {
126
+ style: styles.row,
127
+ children: row.map((cell, ci) => /*#__PURE__*/_jsx(View, {
128
+ onLayout: e => onLayout(`c-${ri}-${ci}`, e.nativeEvent.layout.width),
129
+ style: styles.measuringCell,
130
+ children: /*#__PURE__*/_jsx(CellContent, {
131
+ node: cell,
132
+ Renderer: Renderer,
133
+ styles: styles
134
+ })
135
+ }, `m-c-${ri}-${ci}`))
136
+ }, `m-r-${ri}`))]
137
+ }), /*#__PURE__*/_jsx(ScrollView, {
138
+ horizontal: true,
139
+ showsHorizontalScrollIndicator: true,
140
+ bounces: false,
141
+ style: styles.tableScroll,
142
+ children: /*#__PURE__*/_jsxs(View, {
143
+ style: styles.table,
144
+ children: [/*#__PURE__*/_jsx(View, {
145
+ style: styles.headerRow,
146
+ children: headers.map((cell, i) => /*#__PURE__*/_jsx(View, {
147
+ style: [styles.headerCell, {
148
+ width: columnWidths[i] || 120
149
+ }, getAlignStyle(i), i === columnCount - 1 && styles.lastCell],
150
+ children: /*#__PURE__*/_jsx(CellContent, {
151
+ node: cell,
152
+ Renderer: Renderer,
153
+ styles: styles,
154
+ textStyle: styles.headerText
155
+ })
156
+ }, `h-${i}`))
157
+ }), rows.map((row, ri) => /*#__PURE__*/_jsx(View, {
158
+ style: [styles.bodyRow, ri === rows.length - 1 && styles.lastRow, ri % 2 === 1 && styles.oddRow],
159
+ children: row.map((cell, ci) => /*#__PURE__*/_jsx(View, {
160
+ style: [styles.bodyCell, {
161
+ width: columnWidths[ci] || 120
162
+ }, getAlignStyle(ci), ci === columnCount - 1 && styles.lastCell],
163
+ children: /*#__PURE__*/_jsx(CellContent, {
164
+ node: cell,
165
+ Renderer: Renderer,
166
+ styles: styles,
167
+ textStyle: styles.cellText
168
+ })
169
+ }, `c-${ri}-${ci}`))
170
+ }, `r-${ri}`))]
171
+ })
172
+ })]
173
+ });
174
+ };
175
+ const CellContent = ({
176
+ node,
177
+ Renderer,
178
+ styles,
179
+ textStyle
180
+ }) => {
181
+ if (!node.children || node.children.length === 0) {
182
+ return /*#__PURE__*/_jsx(Text, {
183
+ style: textStyle,
184
+ children: node.content ?? ""
185
+ });
186
+ }
187
+ return /*#__PURE__*/_jsx(View, {
188
+ style: styles.cellContentWrapper,
189
+ children: node.children.map((child, idx) => /*#__PURE__*/_jsx(Renderer, {
190
+ node: child,
191
+ depth: 0,
192
+ inListItem: false,
193
+ parentIsText: false
194
+ }, idx))
195
+ });
196
+ };
197
+ const createTableStyles = theme => {
198
+ const colors = theme?.colors || {};
199
+ return StyleSheet.create({
200
+ container: {
201
+ marginVertical: 12
202
+ },
203
+ measurementWrapper: {
204
+ position: "absolute",
205
+ top: 0,
206
+ left: 0,
207
+ opacity: 0,
208
+ zIndex: -1
209
+ },
210
+ measuringCell: {
211
+ paddingHorizontal: 16,
212
+ paddingVertical: 12,
213
+ alignSelf: "flex-start"
214
+ },
215
+ tableScroll: {
216
+ borderRadius: 12,
217
+ borderWidth: 1,
218
+ borderColor: colors.tableBorder || "#374151"
219
+ },
220
+ table: {
221
+ backgroundColor: colors.surface || "#111827"
222
+ },
223
+ row: {
224
+ flexDirection: "row"
225
+ },
226
+ headerRow: {
227
+ flexDirection: "row",
228
+ backgroundColor: colors.tableHeader || "#1f2937",
229
+ borderBottomWidth: 2,
230
+ borderBottomColor: colors.tableBorder || "#374151"
231
+ },
232
+ bodyRow: {
233
+ flexDirection: "row",
234
+ borderBottomWidth: 1,
235
+ borderBottomColor: colors.tableBorder || "#374151"
236
+ },
237
+ oddRow: {
238
+ backgroundColor: colors.tableRowOdd || "rgba(255,255,255,0.02)"
239
+ },
240
+ lastRow: {
241
+ borderBottomWidth: 0
242
+ },
243
+ headerCell: {
244
+ paddingVertical: 14,
245
+ paddingHorizontal: 16,
246
+ borderRightWidth: 1,
247
+ borderRightColor: colors.tableBorder || "#374151"
248
+ },
249
+ bodyCell: {
250
+ paddingVertical: 12,
251
+ paddingHorizontal: 16,
252
+ borderRightWidth: 1,
253
+ borderRightColor: colors.tableBorder || "#374151",
254
+ justifyContent: "center"
255
+ },
256
+ lastCell: {
257
+ borderRightWidth: 0
258
+ },
259
+ headerText: {
260
+ color: colors.tableHeaderText || "#9ca3af",
261
+ fontSize: 12,
262
+ fontWeight: "700",
263
+ textTransform: "uppercase",
264
+ letterSpacing: 1
265
+ },
266
+ cellText: {
267
+ color: colors.text || "#e5e7eb",
268
+ fontSize: 14,
269
+ lineHeight: 20
270
+ },
271
+ cellContentWrapper: {
272
+ flexDirection: "row",
273
+ flexWrap: "wrap",
274
+ alignItems: "center"
275
+ }
276
+ });
277
+ };
278
+ //# sourceMappingURL=table.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useMemo","useRef","useState","useCallback","useEffect","View","Text","StyleSheet","ScrollView","useMarkdownContext","jsx","_jsx","jsxs","_jsxs","extractTableData","node","headers","rows","alignments","head","children","find","c","type","body","forEach","row","cell","push","align","rowCells","length","TableRenderer","Renderer","theme","columnCount","styles","createTableStyles","columnWidths","setColumnWidths","measuredWidths","Map","hasAppliedWidths","calculateAndApplyWidths","finalWidths","Array","fill","col","maxWidth","current","get","cellWidth","Math","max","timer","setTimeout","clearTimeout","onLayout","key","width","set","expectedCount","size","getAlignStyle","index","alignItems","textAlign","style","container","measurementWrapper","pointerEvents","map","i","e","nativeEvent","layout","measuringCell","CellContent","ri","ci","horizontal","showsHorizontalScrollIndicator","bounces","tableScroll","table","headerRow","headerCell","lastCell","textStyle","headerText","bodyRow","lastRow","oddRow","bodyCell","cellText","content","cellContentWrapper","child","idx","depth","inListItem","parentIsText","colors","create","marginVertical","position","top","left","opacity","zIndex","paddingHorizontal","paddingVertical","alignSelf","borderRadius","borderWidth","borderColor","tableBorder","backgroundColor","surface","flexDirection","tableHeader","borderBottomWidth","borderBottomColor","tableRowOdd","borderRightWidth","borderRightColor","justifyContent","color","tableHeaderText","fontSize","fontWeight","textTransform","letterSpacing","text","lineHeight","flexWrap"],"sourceRoot":"../../../src","sources":["renderers/table.tsx"],"mappings":";;AAAA,SACEA,OAAO,EACPC,MAAM,EACNC,QAAQ,EACRC,WAAW,EACXC,SAAS,QAGJ,OAAO;AACd,SACEC,IAAI,EACJC,IAAI,EACJC,UAAU,EACVC,UAAU,QAGL,cAAc;AAGrB,SAASC,kBAAkB,QAAgC,uBAAoB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAShF,MAAMC,gBAAgB,GAAIC,IAAkB,IAAgB;EAC1D,MAAMC,OAAuB,GAAG,EAAE;EAClC,MAAMC,IAAsB,GAAG,EAAE;EACjC,MAAMC,UAAkC,GAAG,EAAE;EAE7C,MAAMC,IAAI,GAAGJ,IAAI,CAACK,QAAQ,EAAEC,IAAI,CAAEC,CAAC,IAAKA,CAAC,CAACC,IAAI,KAAK,YAAY,CAAC;EAChE,MAAMC,IAAI,GAAGT,IAAI,CAACK,QAAQ,EAAEC,IAAI,CAAEC,CAAC,IAAKA,CAAC,CAACC,IAAI,KAAK,YAAY,CAAC;;EAEhE;EACAJ,IAAI,EAAEC,QAAQ,EAAEK,OAAO,CAAEC,GAAG,IAAK;IAC/B,IAAIA,GAAG,CAACH,IAAI,KAAK,WAAW,EAAE;MAC5BG,GAAG,CAACN,QAAQ,EAAEK,OAAO,CAAEE,IAAI,IAAK;QAC9B,IAAIA,IAAI,CAACJ,IAAI,KAAK,YAAY,EAAE;UAC9BP,OAAO,CAACY,IAAI,CAACD,IAAI,CA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B,MAAM,CAACc,WAAW,IAAI,SAAS;MACjDU,cAAc,EAAE;IAClB,CAAC;IACDvC,QAAQ,EAAE;MACRqC,gBAAgB,EAAE;IACpB,CAAC;IACDnC,UAAU,EAAE;MACVsC,KAAK,EAAEzB,MAAM,CAAC0B,eAAe,IAAI,SAAS;MAC1CC,QAAQ,EAAE,EAAE;MACZC,UAAU,EAAE,KAAK;MACjBC,aAAa,EAAE,WAAW;MAC1BC,aAAa,EAAE;IACjB,CAAC;IACDtC,QAAQ,EAAE;MACRiC,KAAK,EAAEzB,MAAM,CAAC+B,IAAI,IAAI,SAAS;MAC/BJ,QAAQ,EAAE,EAAE;MACZK,UAAU,EAAE;IACd,CAAC;IACDtC,kBAAkB,EAAE;MAClBuB,aAAa,EAAE,KAAK;MACpBgB,QAAQ,EAAE,MAAM;MAChBtE,UAAU,EAAE;IACd;EACF,CAAC,CAAC;AACJ,CAAC","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+
3
+ export {};
4
+ //# sourceMappingURL=MarkdownSession.nitro.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["specs/MarkdownSession.nitro.ts"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Default theme configuration for the Markdown components.
5
+ * Optimized for a modern dark mode aesthetic.
6
+ */
7
+ export const defaultMarkdownTheme = {
8
+ /** Colors used throughout the markdown renderer */
9
+ colors: {
10
+ text: "#e0e0e0",
11
+ textMuted: "#888",
12
+ heading: "#f0f0f0",
13
+ link: "#60a5fa",
14
+ code: "#fbbf24",
15
+ codeBackground: "#1a1a2e",
16
+ blockquote: "#3b82f6",
17
+ border: "#252525",
18
+ surface: "#151515",
19
+ surfaceLight: "#1a1a1a",
20
+ accent: "#4ade80",
21
+ tableBorder: "#334155",
22
+ tableHeader: "#0f172a",
23
+ tableHeaderText: "#94a3b8",
24
+ tableRowEven: "#0f172a",
25
+ tableRowOdd: "#1e293b"
26
+ },
27
+ /** Standard spacing increments */
28
+ spacing: {
29
+ xs: 4,
30
+ s: 8,
31
+ m: 12,
32
+ l: 16,
33
+ xl: 24
34
+ },
35
+ /** Font sizes for different text elements */
36
+ fontSizes: {
37
+ xs: 12,
38
+ s: 14,
39
+ m: 16,
40
+ l: 18,
41
+ xl: 22,
42
+ h1: 32,
43
+ h2: 26,
44
+ h3: 22,
45
+ h4: 18,
46
+ h5: 16,
47
+ h6: 14
48
+ }
49
+ };
50
+
51
+ /**
52
+ * Type definition for the Markdown theme.
53
+ */
54
+ //# sourceMappingURL=theme.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["defaultMarkdownTheme","colors","text","textMuted","heading","link","code","codeBackground","blockquote","border","surface","surfaceLight","accent","tableBorder","tableHeader","tableHeaderText","tableRowEven","tableRowOdd","spacing","xs","s","m","l","xl","fontSizes","h1","h2","h3","h4","h5","h6"],"sourceRoot":"../../src","sources":["theme.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA,OAAO,MAAMA,oBAAoB,GAAG;EAClC;EACAC,MAAM,EAAE;IACNC,IAAI,EAAE,SAAS;IACfC,SAAS,EAAE,MAAM;IACjBC,OAAO,EAAE,SAAS;IAClBC,IAAI,EAAE,SAAS;IACfC,IAAI,EAAE,SAAS;IACfC,cAAc,EAAE,SAAS;IACzBC,UAAU,EAAE,SAAS;IACrBC,MAAM,EAAE,SAAS;IACjBC,OAAO,EAAE,SAAS;IAClBC,YAAY,EAAE,SAAS;IACvBC,MAAM,EAAE,SAAS;IACjBC,WAAW,EAAE,SAAS;IACtBC,WAAW,EAAE,SAAS;IACtBC,eAAe,EAAE,SAAS;IAC1BC,YAAY,EAAE,SAAS;IACvBC,WAAW,EAAE;EACf,CAAC;EACD;EACAC,OAAO,EAAE;IACPC,EAAE,EAAE,CAAC;IACLC,CAAC,EAAE,CAAC;IACJC,CAAC,EAAE,EAAE;IACLC,CAAC,EAAE,EAAE;IACLC,EAAE,EAAE;EACN,CAAC;EACD;EACAC,SAAS,EAAE;IACTL,EAAE,EAAE,EAAE;IACNC,CAAC,EAAE,EAAE;IACLC,CAAC,EAAE,EAAE;IACLC,CAAC,EAAE,EAAE;IACLC,EAAE,EAAE,EAAE;IACNE,EAAE,EAAE,EAAE;IACNC,EAAE,EAAE,EAAE;IACNC,EAAE,EAAE,EAAE;IACNC,EAAE,EAAE,EAAE;IACNC,EAAE,EAAE,EAAE;IACNC,EAAE,EAAE;EACN;AACF,CAAC;;AAED;AACA;AACA","ignoreList":[]}
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+
3
+ import { useRef, useCallback, useState, useEffect } from "react";
4
+ import { createMarkdownSession } from "./MarkdownSession.js";
5
+ export function useMarkdownSession() {
6
+ const sessionRef = useRef(null);
7
+ if (sessionRef.current === null) {
8
+ sessionRef.current = createMarkdownSession();
9
+ }
10
+ const [isStreaming, setIsStreaming] = useState(false);
11
+ useEffect(() => {
12
+ const session = sessionRef.current;
13
+ return () => {
14
+ session.clear();
15
+ };
16
+ }, []);
17
+ const stop = useCallback(() => {
18
+ setIsStreaming(false);
19
+ }, []);
20
+ const clear = useCallback(() => {
21
+ stop();
22
+ sessionRef.current.clear();
23
+ sessionRef.current.highlightPosition = 0;
24
+ }, [stop]);
25
+ const setHighlight = useCallback(position => {
26
+ sessionRef.current.highlightPosition = position;
27
+ }, []);
28
+ const getSession = useCallback(() => sessionRef.current, []);
29
+ return {
30
+ getSession,
31
+ isStreaming,
32
+ setIsStreaming,
33
+ stop,
34
+ clear,
35
+ setHighlight
36
+ };
37
+ }
38
+ export function useStream(timestamps) {
39
+ const engine = useMarkdownSession();
40
+ const [isPlaying, setIsPlaying] = useState(false);
41
+ const sortedKeys = useRef([]);
42
+ useEffect(() => {
43
+ if (timestamps) {
44
+ sortedKeys.current = Object.keys(timestamps).map(Number).sort((a, b) => a - b);
45
+ }
46
+ }, [timestamps]);
47
+ const sync = useCallback(currentTimeMs => {
48
+ if (!timestamps) return;
49
+ let wordIdx = 0;
50
+ for (const idx of sortedKeys.current) {
51
+ if (currentTimeMs >= timestamps[idx]) {
52
+ wordIdx = idx + 1;
53
+ } else {
54
+ break;
55
+ }
56
+ }
57
+ engine.setHighlight(wordIdx);
58
+ }, [timestamps, engine]);
59
+ return {
60
+ ...engine,
61
+ isPlaying,
62
+ setIsPlaying,
63
+ sync
64
+ };
65
+ }
66
+ //# sourceMappingURL=use-markdown-stream.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useRef","useCallback","useState","useEffect","createMarkdownSession","useMarkdownSession","sessionRef","current","isStreaming","setIsStreaming","session","clear","stop","highlightPosition","setHighlight","position","getSession","useStream","timestamps","engine","isPlaying","setIsPlaying","sortedKeys","Object","keys","map","Number","sort","a","b","sync","currentTimeMs","wordIdx","idx"],"sourceRoot":"../../src","sources":["use-markdown-stream.ts"],"mappings":";;AAAA,SAASA,MAAM,EAAEC,WAAW,EAAEC,QAAQ,EAAEC,SAAS,QAAQ,OAAO;AAChE,SAASC,qBAAqB,QAAQ,sBAAmB;AAIzD,OAAO,SAASC,kBAAkBA,CAAA,EAAG;EACnC,MAAMC,UAAU,GAAGN,MAAM,CAAyB,IAAI,CAAC;EACvD,IAAIM,UAAU,CAACC,OAAO,KAAK,IAAI,EAAE;IAC/BD,UAAU,CAACC,OAAO,GAAGH,qBAAqB,CAAC,CAAC;EAC9C;EAEA,MAAM,CAACI,WAAW,EAAEC,cAAc,CAAC,GAAGP,QAAQ,CAAC,KAAK,CAAC;EAErDC,SAAS,CAAC,MAAM;IACd,MAAMO,OAAO,GAAGJ,UAAU,CAACC,OAAQ;IACnC,OAAO,MAAM;MACXG,OAAO,CAACC,KAAK,CAAC,CAAC;IACjB,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;EAEN,MAAMC,IAAI,GAAGX,WAAW,CAAC,MAAM;IAC7BQ,cAAc,CAAC,KAAK,CAAC;EACvB,CAAC,EAAE,EAAE,CAAC;EAEN,MAAME,KAAK,GAAGV,WAAW,C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D,OAAO,GAAGC,GAAG,GAAG,CAAC;MACnB,CAAC,MAAM;QACL;MACF;IACF;IACAd,MAAM,CAACL,YAAY,CAACkB,OAAO,CAAC;EAC9B,CAAC,EACD,CAACd,UAAU,EAAEC,MAAM,CACrB,CAAC;EAED,OAAO;IACL,GAAGA,MAAM;IACTC,SAAS;IACTC,YAAY;IACZS;EACF,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Markdown.nitro.d.ts","sourceRoot":"","sources":["../../../src/Markdown.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE/D,MAAM,WAAW,aAAa;IAC5B,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,cACf,SAAQ,YAAY,CAAC;IAAE,GAAG,EAAE,KAAK,CAAC;IAAC,OAAO,EAAE,KAAK,CAAA;CAAE,CAAC;IACpD,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,MAAM,CAAC;CAChE"}
@@ -0,0 +1,26 @@
1
+ import { type ReactNode, type ComponentType } from "react";
2
+ import { type MarkdownTheme } from "./theme";
3
+ import type { MarkdownNode } from "./headless";
4
+ export interface NodeRendererProps {
5
+ node: MarkdownNode;
6
+ depth: number;
7
+ inListItem: boolean;
8
+ parentIsText?: boolean;
9
+ }
10
+ export interface CustomRendererProps {
11
+ node: MarkdownNode;
12
+ children: ReactNode;
13
+ Renderer: ComponentType<NodeRendererProps>;
14
+ }
15
+ export type CustomRenderer = (props: CustomRendererProps) => ReactNode | undefined;
16
+ /**
17
+ * Object mapping node types to custom renderers.
18
+ */
19
+ export type CustomRenderers = Partial<Record<MarkdownNode["type"], CustomRenderer>>;
20
+ export interface MarkdownContextValue {
21
+ renderers: CustomRenderers;
22
+ theme: MarkdownTheme;
23
+ }
24
+ export declare const MarkdownContext: import("react").Context<MarkdownContextValue>;
25
+ export declare const useMarkdownContext: () => MarkdownContextValue;
26
+ //# sourceMappingURL=MarkdownContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarkdownContext.d.ts","sourceRoot":"","sources":["../../../src/MarkdownContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,KAAK,SAAS,EAAE,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;AACtF,OAAO,EAAwB,KAAK,aAAa,EAAE,MAAM,SAAS,CAAC;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,YAAY,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,OAAO,CAAC;IACpB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,YAAY,CAAC;IACnB,QAAQ,EAAE,SAAS,CAAC;IACpB,QAAQ,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC;CAC5C;AAED,MAAM,MAAM,cAAc,GAAG,CAC3B,KAAK,EAAE,mBAAmB,KACvB,SAAS,GAAG,SAAS,CAAC;AAE3B;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,OAAO,CACnC,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,cAAc,CAAC,CAC7C,CAAC;AAGF,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,eAAe,CAAC;IAC3B,KAAK,EAAE,aAAa,CAAC;CACtB;AAED,eAAO,MAAM,eAAe,+CAG1B,CAAC;AAEH,eAAO,MAAM,kBAAkB,4BAAoC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { MarkdownSession as MarkdownSessionSpec } from "./specs/MarkdownSession.nitro";
2
+ export type MarkdownSession = MarkdownSessionSpec;
3
+ export declare function createMarkdownSession(): MarkdownSession;
4
+ //# sourceMappingURL=MarkdownSession.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarkdownSession.d.ts","sourceRoot":"","sources":["../../../src/MarkdownSession.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,IAAI,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAE5F,MAAM,MAAM,eAAe,GAAG,mBAAmB,CAAC;AAElD,wBAAgB,qBAAqB,IAAI,eAAe,CAEvD"}
@@ -0,0 +1,10 @@
1
+ import { type FC } from "react";
2
+ import type { MarkdownNode } from "./headless";
3
+ interface MarkdownRendererProps {
4
+ node: MarkdownNode;
5
+ depth?: number;
6
+ inListItem?: boolean;
7
+ }
8
+ export declare const DefaultMarkdownRenderer: FC<MarkdownRendererProps>;
9
+ export {};
10
+ //# sourceMappingURL=default-markdown-renderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default-markdown-renderer.d.ts","sourceRoot":"","sources":["../../../src/default-markdown-renderer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAEhD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAa/C,UAAU,qBAAqB;IAC7B,IAAI,EAAE,YAAY,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAsBD,eAAO,MAAM,uBAAuB,EAAE,EAAE,CAAC,qBAAqB,CA8M7D,CAAC"}
@@ -0,0 +1,50 @@
1
+ import type { MarkdownParser, ParserOptions } from "./Markdown.nitro";
2
+ export type { ParserOptions } from "./Markdown.nitro";
3
+ /**
4
+ * Represents a node in the Markdown AST (Abstract Syntax Tree).
5
+ * Each node has a type and optional properties depending on the node type.
6
+ */
7
+ export interface MarkdownNode {
8
+ /** The type of markdown element this node represents. Used to decide how to render the node. */
9
+ type: "document" | "heading" | "paragraph" | "text" | "bold" | "italic" | "strikethrough" | "link" | "image" | "code_inline" | "code_block" | "blockquote" | "horizontal_rule" | "line_break" | "soft_break" | "table" | "table_head" | "table_body" | "table_row" | "table_cell" | "list" | "list_item" | "task_list_item" | "math_inline" | "math_block" | "html_block" | "html_inline";
10
+ /** Text content for text, code, and similar nodes. */
11
+ content?: string;
12
+ /** Heading level (1-6) for heading nodes. */
13
+ level?: number;
14
+ /** URL for link and image nodes. */
15
+ href?: string;
16
+ /** Title attribute for link and image nodes. */
17
+ title?: string;
18
+ /** Alt text for image nodes. */
19
+ alt?: string;
20
+ /** Programming language for code blocks (e.g., 'typescript', 'javascript'). */
21
+ language?: string;
22
+ /** Whether a list is ordered (numbered) or unordered. */
23
+ ordered?: boolean;
24
+ /** The starting number for ordered lists. */
25
+ start?: number;
26
+ /** Whether a task list item is currently checked. */
27
+ checked?: boolean;
28
+ /** Whether a table cell is part of the header row. */
29
+ isHeader?: boolean;
30
+ /** Text alignment for table cells: 'left', 'center', or 'right'. */
31
+ align?: string;
32
+ /** Nested child nodes for hierarchical elements like paragraphs, lists, and tables. */
33
+ children?: MarkdownNode[];
34
+ }
35
+ export declare const MarkdownParserModule: MarkdownParser;
36
+ /**
37
+ * Parse markdown text into an AST.
38
+ * @param text - The markdown text to parse
39
+ * @returns The root node of the parsed AST
40
+ */
41
+ export declare function parseMarkdown(text: string): MarkdownNode;
42
+ /**
43
+ * Parse markdown text with custom options.
44
+ * @param text - The markdown text to parse
45
+ * @param options - Parser options (gfm, math)
46
+ * @returns The root node of the parsed AST
47
+ */
48
+ export declare function parseMarkdownWithOptions(text: string, options: ParserOptions): MarkdownNode;
49
+ export { MarkdownParser };
50
+ //# sourceMappingURL=headless.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"headless.d.ts","sourceRoot":"","sources":["../../../src/headless.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEtE,YAA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AO,EAAE,aAAa,GACrB,YAAY,CAGd;AAED,OAAO,EAAE,cAAc,EAAE,CAAC"}
@@ -0,0 +1,34 @@
1
+ export * from "./headless";
2
+ /** Low-level renderer component for custom implementations */
3
+ export { DefaultMarkdownRenderer } from "./default-markdown-renderer";
4
+ /**
5
+ * High-level Markdown component with optional custom renderers.
6
+ * @example
7
+ * ```tsx
8
+ * <Markdown>{'# Hello World'}</Markdown>
9
+ * ```
10
+ */
11
+ export { Markdown } from "./markdown";
12
+ /**
13
+ * Markdown component that supports streaming updates.
14
+ */
15
+ export { MarkdownStream } from "./markdown-stream";
16
+ export { useMarkdownContext } from "./MarkdownContext";
17
+ export type { CustomRenderer, CustomRenderers, CustomRendererProps, NodeRendererProps, } from "./MarkdownContext";
18
+ /** Default theme configuration */
19
+ export { defaultMarkdownTheme } from "./theme";
20
+ export type { MarkdownTheme } from "./theme";
21
+ export { Heading } from "./renderers/heading";
22
+ export { Paragraph } from "./renderers/paragraph";
23
+ export { Link } from "./renderers/link";
24
+ export { Blockquote } from "./renderers/blockquote";
25
+ export { HorizontalRule } from "./renderers/horizontal-rule";
26
+ export { CodeBlock, InlineCode } from "./renderers/code";
27
+ export { List, ListItem, TaskListItem } from "./renderers/list";
28
+ export { TableRenderer } from "./renderers/table";
29
+ export { Image } from "./renderers/image";
30
+ export { MathInline, MathBlock } from "./renderers/math";
31
+ export { createMarkdownSession } from "./MarkdownSession";
32
+ export type { MarkdownSession } from "./MarkdownSession";
33
+ export { useMarkdownSession, useStream } from "./use-markdown-stream";
34
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAE3B,8DAA8D;AAC9D,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAEtE;;;;;;GAMG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC;;GAEG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,YAAY,EACV,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAE3B,kCAAkC;AAClC,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAC/C,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAG7C,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAGzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,YAAY,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { type FC } from "react";
2
+ import { type MarkdownProps } from "./markdown";
3
+ import type { MarkdownSession } from "./specs/MarkdownSession.nitro";
4
+ export interface MarkdownStreamProps extends Omit<MarkdownProps, "children"> {
5
+ /**
6
+ * The active MarkdownSession to stream content from.
7
+ */
8
+ session: MarkdownSession;
9
+ }
10
+ /**
11
+ * A component that renders streaming Markdown from a MarkdownSession.
12
+ * It efficiently subscribes to session updates to minimize parent re-renders.
13
+ */
14
+ export declare const MarkdownStream: FC<MarkdownStreamProps>;
15
+ //# sourceMappingURL=markdown-stream.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markdown-stream.d.ts","sourceRoot":"","sources":["../../../src/markdown-stream.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,EAAY,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAErE,MAAM,WAAW,mBAAoB,SAAQ,IAAI,CAAC,aAAa,EAAE,UAAU,CAAC;IAC1E;;OAEG;IACH,OAAO,EAAE,eAAe,CAAC;CAC1B;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,EAAE,CAAC,mBAAmB,CAgBlD,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { type MarkdownTheme } from "./theme";
2
+ import { type FC } from "react";
3
+ import { type StyleProp, type ViewStyle } from "react-native";
4
+ import type { ParserOptions } from "./Markdown.nitro";
5
+ import { type CustomRenderers } from "./MarkdownContext";
6
+ export interface MarkdownProps {
7
+ /**
8
+ * The markdown string to parse and render.
9
+ */
10
+ children: string;
11
+ /**
12
+ * Parser options to enable GFM or Math support.
13
+ */
14
+ options?: ParserOptions;
15
+ /**
16
+ * Custom renderers for specific markdown node types.
17
+ */
18
+ renderers?: CustomRenderers;
19
+ /**
20
+ * Custom theme to override default styles.
21
+ */
22
+ theme?: Partial<MarkdownTheme>;
23
+ /**
24
+ * Optional style for the container view.
25
+ */
26
+ style?: StyleProp<ViewStyle>;
27
+ }
28
+ export declare const Markdown: FC<MarkdownProps>;
29
+ //# sourceMappingURL=markdown.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../../src/markdown.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAwB,KAAK,aAAa,EAAE,MAAM,SAAS,CAAC;AACnE,OAAO,EAA2B,KAAK,EAAE,EAAY,MAAM,OAAO,CAAC;AACnE,OAAO,EAIL,KAAK,SAAS,EACd,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAMtB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAGL,KAAK,eAAe,EAErB,MAAM,mBAAmB,CAAC;AAa3B,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB;;OAEG;IACH,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;IAC/B;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC9B;AAED,eAAO,MAAM,QAAQ,EAAE,EAAE,CAAC,aAAa,CAyCtC,CAAC"}
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}