@crafter/rn-ai-elements 0.0.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 (344) hide show
  1. package/lib/commonjs/chatbot/AIImage.js +126 -0
  2. package/lib/commonjs/chatbot/AIImage.js.map +1 -0
  3. package/lib/commonjs/chatbot/Attachments.js +317 -0
  4. package/lib/commonjs/chatbot/Attachments.js.map +1 -0
  5. package/lib/commonjs/chatbot/ChatErrorBoundary.js +201 -0
  6. package/lib/commonjs/chatbot/ChatErrorBoundary.js.map +1 -0
  7. package/lib/commonjs/chatbot/ChatMessageItem.js +169 -0
  8. package/lib/commonjs/chatbot/ChatMessageItem.js.map +1 -0
  9. package/lib/commonjs/chatbot/Conversation.js +415 -0
  10. package/lib/commonjs/chatbot/Conversation.js.map +1 -0
  11. package/lib/commonjs/chatbot/ConversationScrollButton.js +131 -0
  12. package/lib/commonjs/chatbot/ConversationScrollButton.js.map +1 -0
  13. package/lib/commonjs/chatbot/Message.js +203 -0
  14. package/lib/commonjs/chatbot/Message.js.map +1 -0
  15. package/lib/commonjs/chatbot/PromptInput.js +352 -0
  16. package/lib/commonjs/chatbot/PromptInput.js.map +1 -0
  17. package/lib/commonjs/chatbot/Reasoning.js +184 -0
  18. package/lib/commonjs/chatbot/Reasoning.js.map +1 -0
  19. package/lib/commonjs/chatbot/Shimmer.js +116 -0
  20. package/lib/commonjs/chatbot/Shimmer.js.map +1 -0
  21. package/lib/commonjs/chatbot/Sources.js +212 -0
  22. package/lib/commonjs/chatbot/Sources.js.map +1 -0
  23. package/lib/commonjs/chatbot/Suggestion.js +99 -0
  24. package/lib/commonjs/chatbot/Suggestion.js.map +1 -0
  25. package/lib/commonjs/chatbot/Tool.js +307 -0
  26. package/lib/commonjs/chatbot/Tool.js.map +1 -0
  27. package/lib/commonjs/chatbot/adapters/uiMessageAdapter.js +141 -0
  28. package/lib/commonjs/chatbot/adapters/uiMessageAdapter.js.map +1 -0
  29. package/lib/commonjs/chatbot/index.js +140 -0
  30. package/lib/commonjs/chatbot/index.js.map +1 -0
  31. package/lib/commonjs/chatbot/types.js +6 -0
  32. package/lib/commonjs/chatbot/types.js.map +1 -0
  33. package/lib/commonjs/hooks/index.js +34 -0
  34. package/lib/commonjs/hooks/index.js.map +1 -0
  35. package/lib/commonjs/hooks/useAutoScroll.js +39 -0
  36. package/lib/commonjs/hooks/useAutoScroll.js.map +1 -0
  37. package/lib/commonjs/hooks/useClipboard.js +44 -0
  38. package/lib/commonjs/hooks/useClipboard.js.map +1 -0
  39. package/lib/commonjs/hooks/useCollapsible.js +35 -0
  40. package/lib/commonjs/hooks/useCollapsible.js.map +1 -0
  41. package/lib/commonjs/hooks/useStickToBottom.js +68 -0
  42. package/lib/commonjs/hooks/useStickToBottom.js.map +1 -0
  43. package/lib/commonjs/index.js +257 -0
  44. package/lib/commonjs/index.js.map +1 -0
  45. package/lib/commonjs/package.json +1 -0
  46. package/lib/commonjs/primitives/Badge.js +119 -0
  47. package/lib/commonjs/primitives/Badge.js.map +1 -0
  48. package/lib/commonjs/primitives/Button.js +185 -0
  49. package/lib/commonjs/primitives/Button.js.map +1 -0
  50. package/lib/commonjs/primitives/Card.js +166 -0
  51. package/lib/commonjs/primitives/Card.js.map +1 -0
  52. package/lib/commonjs/primitives/Collapsible.js +137 -0
  53. package/lib/commonjs/primitives/Collapsible.js.map +1 -0
  54. package/lib/commonjs/primitives/ScrollArea.js +40 -0
  55. package/lib/commonjs/primitives/ScrollArea.js.map +1 -0
  56. package/lib/commonjs/primitives/index.js +83 -0
  57. package/lib/commonjs/primitives/index.js.map +1 -0
  58. package/lib/commonjs/streaming/StreamingMarkdown.js +252 -0
  59. package/lib/commonjs/streaming/StreamingMarkdown.js.map +1 -0
  60. package/lib/commonjs/streaming/index.js +13 -0
  61. package/lib/commonjs/streaming/index.js.map +1 -0
  62. package/lib/commonjs/streaming/parser.js +482 -0
  63. package/lib/commonjs/streaming/parser.js.map +1 -0
  64. package/lib/commonjs/streaming/renderers/BlockquoteRenderer.js +35 -0
  65. package/lib/commonjs/streaming/renderers/BlockquoteRenderer.js.map +1 -0
  66. package/lib/commonjs/streaming/renderers/CodeRenderer.js +128 -0
  67. package/lib/commonjs/streaming/renderers/CodeRenderer.js.map +1 -0
  68. package/lib/commonjs/streaming/renderers/HeadingRenderer.js +61 -0
  69. package/lib/commonjs/streaming/renderers/HeadingRenderer.js.map +1 -0
  70. package/lib/commonjs/streaming/renderers/ImageRenderer.js +53 -0
  71. package/lib/commonjs/streaming/renderers/ImageRenderer.js.map +1 -0
  72. package/lib/commonjs/streaming/renderers/LinkRenderer.js +49 -0
  73. package/lib/commonjs/streaming/renderers/LinkRenderer.js.map +1 -0
  74. package/lib/commonjs/streaming/renderers/ListRenderer.js +63 -0
  75. package/lib/commonjs/streaming/renderers/ListRenderer.js.map +1 -0
  76. package/lib/commonjs/streaming/renderers/TableRenderer.js +77 -0
  77. package/lib/commonjs/streaming/renderers/TableRenderer.js.map +1 -0
  78. package/lib/commonjs/streaming/renderers/TextRenderer.js +41 -0
  79. package/lib/commonjs/streaming/renderers/TextRenderer.js.map +1 -0
  80. package/lib/commonjs/streaming/renderers/index.js +76 -0
  81. package/lib/commonjs/streaming/renderers/index.js.map +1 -0
  82. package/lib/commonjs/streaming/renderers/renderInlineChildren.js +112 -0
  83. package/lib/commonjs/streaming/renderers/renderInlineChildren.js.map +1 -0
  84. package/lib/commonjs/streaming/renderers/renderNode.js +81 -0
  85. package/lib/commonjs/streaming/renderers/renderNode.js.map +1 -0
  86. package/lib/commonjs/theme/ThemeProvider.js +68 -0
  87. package/lib/commonjs/theme/ThemeProvider.js.map +1 -0
  88. package/lib/commonjs/theme/defaultTheme.js +96 -0
  89. package/lib/commonjs/theme/defaultTheme.js.map +1 -0
  90. package/lib/commonjs/theme/index.js +32 -0
  91. package/lib/commonjs/theme/index.js.map +1 -0
  92. package/lib/commonjs/theme/tokens.js +2 -0
  93. package/lib/commonjs/theme/tokens.js.map +1 -0
  94. package/lib/commonjs/types.d.js +2 -0
  95. package/lib/commonjs/types.d.js.map +1 -0
  96. package/lib/commonjs/voice/index.js +13 -0
  97. package/lib/commonjs/voice/index.js.map +1 -0
  98. package/lib/commonjs/voice/useSpeechRecognition.js +172 -0
  99. package/lib/commonjs/voice/useSpeechRecognition.js.map +1 -0
  100. package/lib/module/chatbot/AIImage.js +121 -0
  101. package/lib/module/chatbot/AIImage.js.map +1 -0
  102. package/lib/module/chatbot/Attachments.js +312 -0
  103. package/lib/module/chatbot/Attachments.js.map +1 -0
  104. package/lib/module/chatbot/ChatErrorBoundary.js +196 -0
  105. package/lib/module/chatbot/ChatErrorBoundary.js.map +1 -0
  106. package/lib/module/chatbot/ChatMessageItem.js +164 -0
  107. package/lib/module/chatbot/ChatMessageItem.js.map +1 -0
  108. package/lib/module/chatbot/Conversation.js +412 -0
  109. package/lib/module/chatbot/Conversation.js.map +1 -0
  110. package/lib/module/chatbot/ConversationScrollButton.js +126 -0
  111. package/lib/module/chatbot/ConversationScrollButton.js.map +1 -0
  112. package/lib/module/chatbot/Message.js +198 -0
  113. package/lib/module/chatbot/Message.js.map +1 -0
  114. package/lib/module/chatbot/PromptInput.js +347 -0
  115. package/lib/module/chatbot/PromptInput.js.map +1 -0
  116. package/lib/module/chatbot/Reasoning.js +179 -0
  117. package/lib/module/chatbot/Reasoning.js.map +1 -0
  118. package/lib/module/chatbot/Shimmer.js +111 -0
  119. package/lib/module/chatbot/Shimmer.js.map +1 -0
  120. package/lib/module/chatbot/Sources.js +207 -0
  121. package/lib/module/chatbot/Sources.js.map +1 -0
  122. package/lib/module/chatbot/Suggestion.js +94 -0
  123. package/lib/module/chatbot/Suggestion.js.map +1 -0
  124. package/lib/module/chatbot/Tool.js +303 -0
  125. package/lib/module/chatbot/Tool.js.map +1 -0
  126. package/lib/module/chatbot/adapters/uiMessageAdapter.js +137 -0
  127. package/lib/module/chatbot/adapters/uiMessageAdapter.js.map +1 -0
  128. package/lib/module/chatbot/index.js +39 -0
  129. package/lib/module/chatbot/index.js.map +1 -0
  130. package/lib/module/chatbot/types.js +4 -0
  131. package/lib/module/chatbot/types.js.map +1 -0
  132. package/lib/module/hooks/index.js +7 -0
  133. package/lib/module/hooks/index.js.map +1 -0
  134. package/lib/module/hooks/useAutoScroll.js +35 -0
  135. package/lib/module/hooks/useAutoScroll.js.map +1 -0
  136. package/lib/module/hooks/useClipboard.js +40 -0
  137. package/lib/module/hooks/useClipboard.js.map +1 -0
  138. package/lib/module/hooks/useCollapsible.js +31 -0
  139. package/lib/module/hooks/useCollapsible.js.map +1 -0
  140. package/lib/module/hooks/useStickToBottom.js +64 -0
  141. package/lib/module/hooks/useStickToBottom.js.map +1 -0
  142. package/lib/module/index.js +19 -0
  143. package/lib/module/index.js.map +1 -0
  144. package/lib/module/package.json +1 -0
  145. package/lib/module/primitives/Badge.js +114 -0
  146. package/lib/module/primitives/Badge.js.map +1 -0
  147. package/lib/module/primitives/Button.js +180 -0
  148. package/lib/module/primitives/Button.js.map +1 -0
  149. package/lib/module/primitives/Card.js +156 -0
  150. package/lib/module/primitives/Card.js.map +1 -0
  151. package/lib/module/primitives/Collapsible.js +130 -0
  152. package/lib/module/primitives/Collapsible.js.map +1 -0
  153. package/lib/module/primitives/ScrollArea.js +35 -0
  154. package/lib/module/primitives/ScrollArea.js.map +1 -0
  155. package/lib/module/primitives/index.js +8 -0
  156. package/lib/module/primitives/index.js.map +1 -0
  157. package/lib/module/streaming/StreamingMarkdown.js +246 -0
  158. package/lib/module/streaming/StreamingMarkdown.js.map +1 -0
  159. package/lib/module/streaming/index.js +4 -0
  160. package/lib/module/streaming/index.js.map +1 -0
  161. package/lib/module/streaming/parser.js +477 -0
  162. package/lib/module/streaming/parser.js.map +1 -0
  163. package/lib/module/streaming/renderers/BlockquoteRenderer.js +30 -0
  164. package/lib/module/streaming/renderers/BlockquoteRenderer.js.map +1 -0
  165. package/lib/module/streaming/renderers/CodeRenderer.js +123 -0
  166. package/lib/module/streaming/renderers/CodeRenderer.js.map +1 -0
  167. package/lib/module/streaming/renderers/HeadingRenderer.js +56 -0
  168. package/lib/module/streaming/renderers/HeadingRenderer.js.map +1 -0
  169. package/lib/module/streaming/renderers/ImageRenderer.js +48 -0
  170. package/lib/module/streaming/renderers/ImageRenderer.js.map +1 -0
  171. package/lib/module/streaming/renderers/LinkRenderer.js +44 -0
  172. package/lib/module/streaming/renderers/LinkRenderer.js.map +1 -0
  173. package/lib/module/streaming/renderers/ListRenderer.js +58 -0
  174. package/lib/module/streaming/renderers/ListRenderer.js.map +1 -0
  175. package/lib/module/streaming/renderers/TableRenderer.js +72 -0
  176. package/lib/module/streaming/renderers/TableRenderer.js.map +1 -0
  177. package/lib/module/streaming/renderers/TextRenderer.js +36 -0
  178. package/lib/module/streaming/renderers/TextRenderer.js.map +1 -0
  179. package/lib/module/streaming/renderers/index.js +13 -0
  180. package/lib/module/streaming/renderers/index.js.map +1 -0
  181. package/lib/module/streaming/renderers/renderInlineChildren.js +107 -0
  182. package/lib/module/streaming/renderers/renderInlineChildren.js.map +1 -0
  183. package/lib/module/streaming/renderers/renderNode.js +78 -0
  184. package/lib/module/streaming/renderers/renderNode.js.map +1 -0
  185. package/lib/module/theme/ThemeProvider.js +62 -0
  186. package/lib/module/theme/ThemeProvider.js.map +1 -0
  187. package/lib/module/theme/defaultTheme.js +92 -0
  188. package/lib/module/theme/defaultTheme.js.map +1 -0
  189. package/lib/module/theme/index.js +5 -0
  190. package/lib/module/theme/index.js.map +1 -0
  191. package/lib/module/theme/tokens.js +2 -0
  192. package/lib/module/theme/tokens.js.map +1 -0
  193. package/lib/module/types.d.js +2 -0
  194. package/lib/module/types.d.js.map +1 -0
  195. package/lib/module/voice/index.js +14 -0
  196. package/lib/module/voice/index.js.map +1 -0
  197. package/lib/module/voice/useSpeechRecognition.js +169 -0
  198. package/lib/module/voice/useSpeechRecognition.js.map +1 -0
  199. package/lib/typescript/src/chatbot/AIImage.d.ts +24 -0
  200. package/lib/typescript/src/chatbot/AIImage.d.ts.map +1 -0
  201. package/lib/typescript/src/chatbot/Attachments.d.ts +20 -0
  202. package/lib/typescript/src/chatbot/Attachments.d.ts.map +1 -0
  203. package/lib/typescript/src/chatbot/ChatErrorBoundary.d.ts +57 -0
  204. package/lib/typescript/src/chatbot/ChatErrorBoundary.d.ts.map +1 -0
  205. package/lib/typescript/src/chatbot/ChatMessageItem.d.ts +45 -0
  206. package/lib/typescript/src/chatbot/ChatMessageItem.d.ts.map +1 -0
  207. package/lib/typescript/src/chatbot/Conversation.d.ts +94 -0
  208. package/lib/typescript/src/chatbot/Conversation.d.ts.map +1 -0
  209. package/lib/typescript/src/chatbot/ConversationScrollButton.d.ts +62 -0
  210. package/lib/typescript/src/chatbot/ConversationScrollButton.d.ts.map +1 -0
  211. package/lib/typescript/src/chatbot/Message.d.ts +39 -0
  212. package/lib/typescript/src/chatbot/Message.d.ts.map +1 -0
  213. package/lib/typescript/src/chatbot/PromptInput.d.ts +93 -0
  214. package/lib/typescript/src/chatbot/PromptInput.d.ts.map +1 -0
  215. package/lib/typescript/src/chatbot/Reasoning.d.ts +14 -0
  216. package/lib/typescript/src/chatbot/Reasoning.d.ts.map +1 -0
  217. package/lib/typescript/src/chatbot/Shimmer.d.ts +13 -0
  218. package/lib/typescript/src/chatbot/Shimmer.d.ts.map +1 -0
  219. package/lib/typescript/src/chatbot/Sources.d.ts +17 -0
  220. package/lib/typescript/src/chatbot/Sources.d.ts.map +1 -0
  221. package/lib/typescript/src/chatbot/Suggestion.d.ts +15 -0
  222. package/lib/typescript/src/chatbot/Suggestion.d.ts.map +1 -0
  223. package/lib/typescript/src/chatbot/Tool.d.ts +30 -0
  224. package/lib/typescript/src/chatbot/Tool.d.ts.map +1 -0
  225. package/lib/typescript/src/chatbot/adapters/uiMessageAdapter.d.ts +24 -0
  226. package/lib/typescript/src/chatbot/adapters/uiMessageAdapter.d.ts.map +1 -0
  227. package/lib/typescript/src/chatbot/index.d.ts +29 -0
  228. package/lib/typescript/src/chatbot/index.d.ts.map +1 -0
  229. package/lib/typescript/src/chatbot/types.d.ts +49 -0
  230. package/lib/typescript/src/chatbot/types.d.ts.map +1 -0
  231. package/lib/typescript/src/hooks/index.d.ts +9 -0
  232. package/lib/typescript/src/hooks/index.d.ts.map +1 -0
  233. package/lib/typescript/src/hooks/useAutoScroll.d.ts +23 -0
  234. package/lib/typescript/src/hooks/useAutoScroll.d.ts.map +1 -0
  235. package/lib/typescript/src/hooks/useClipboard.d.ts +22 -0
  236. package/lib/typescript/src/hooks/useClipboard.d.ts.map +1 -0
  237. package/lib/typescript/src/hooks/useCollapsible.d.ts +28 -0
  238. package/lib/typescript/src/hooks/useCollapsible.d.ts.map +1 -0
  239. package/lib/typescript/src/hooks/useStickToBottom.d.ts +39 -0
  240. package/lib/typescript/src/hooks/useStickToBottom.d.ts.map +1 -0
  241. package/lib/typescript/src/index.d.ts +11 -0
  242. package/lib/typescript/src/index.d.ts.map +1 -0
  243. package/lib/typescript/src/primitives/Badge.d.ts +10 -0
  244. package/lib/typescript/src/primitives/Badge.d.ts.map +1 -0
  245. package/lib/typescript/src/primitives/Button.d.ts +16 -0
  246. package/lib/typescript/src/primitives/Button.d.ts.map +1 -0
  247. package/lib/typescript/src/primitives/Card.d.ts +33 -0
  248. package/lib/typescript/src/primitives/Card.d.ts.map +1 -0
  249. package/lib/typescript/src/primitives/Collapsible.d.ts +20 -0
  250. package/lib/typescript/src/primitives/Collapsible.d.ts.map +1 -0
  251. package/lib/typescript/src/primitives/ScrollArea.d.ts +10 -0
  252. package/lib/typescript/src/primitives/ScrollArea.d.ts.map +1 -0
  253. package/lib/typescript/src/primitives/index.d.ts +11 -0
  254. package/lib/typescript/src/primitives/index.d.ts.map +1 -0
  255. package/lib/typescript/src/streaming/StreamingMarkdown.d.ts +47 -0
  256. package/lib/typescript/src/streaming/StreamingMarkdown.d.ts.map +1 -0
  257. package/lib/typescript/src/streaming/index.d.ts +3 -0
  258. package/lib/typescript/src/streaming/index.d.ts.map +1 -0
  259. package/lib/typescript/src/streaming/parser.d.ts +41 -0
  260. package/lib/typescript/src/streaming/parser.d.ts.map +1 -0
  261. package/lib/typescript/src/streaming/renderers/BlockquoteRenderer.d.ts +7 -0
  262. package/lib/typescript/src/streaming/renderers/BlockquoteRenderer.d.ts.map +1 -0
  263. package/lib/typescript/src/streaming/renderers/CodeRenderer.d.ts +7 -0
  264. package/lib/typescript/src/streaming/renderers/CodeRenderer.d.ts.map +1 -0
  265. package/lib/typescript/src/streaming/renderers/HeadingRenderer.d.ts +7 -0
  266. package/lib/typescript/src/streaming/renderers/HeadingRenderer.d.ts.map +1 -0
  267. package/lib/typescript/src/streaming/renderers/ImageRenderer.d.ts +7 -0
  268. package/lib/typescript/src/streaming/renderers/ImageRenderer.d.ts.map +1 -0
  269. package/lib/typescript/src/streaming/renderers/LinkRenderer.d.ts +7 -0
  270. package/lib/typescript/src/streaming/renderers/LinkRenderer.d.ts.map +1 -0
  271. package/lib/typescript/src/streaming/renderers/ListRenderer.d.ts +7 -0
  272. package/lib/typescript/src/streaming/renderers/ListRenderer.d.ts.map +1 -0
  273. package/lib/typescript/src/streaming/renderers/TableRenderer.d.ts +7 -0
  274. package/lib/typescript/src/streaming/renderers/TableRenderer.d.ts.map +1 -0
  275. package/lib/typescript/src/streaming/renderers/TextRenderer.d.ts +7 -0
  276. package/lib/typescript/src/streaming/renderers/TextRenderer.d.ts.map +1 -0
  277. package/lib/typescript/src/streaming/renderers/index.d.ts +19 -0
  278. package/lib/typescript/src/streaming/renderers/index.d.ts.map +1 -0
  279. package/lib/typescript/src/streaming/renderers/renderInlineChildren.d.ts +12 -0
  280. package/lib/typescript/src/streaming/renderers/renderInlineChildren.d.ts.map +1 -0
  281. package/lib/typescript/src/streaming/renderers/renderNode.d.ts +8 -0
  282. package/lib/typescript/src/streaming/renderers/renderNode.d.ts.map +1 -0
  283. package/lib/typescript/src/theme/ThemeProvider.d.ts +14 -0
  284. package/lib/typescript/src/theme/ThemeProvider.d.ts.map +1 -0
  285. package/lib/typescript/src/theme/defaultTheme.d.ts +4 -0
  286. package/lib/typescript/src/theme/defaultTheme.d.ts.map +1 -0
  287. package/lib/typescript/src/theme/index.d.ts +5 -0
  288. package/lib/typescript/src/theme/index.d.ts.map +1 -0
  289. package/lib/typescript/src/theme/tokens.d.ts +66 -0
  290. package/lib/typescript/src/theme/tokens.d.ts.map +1 -0
  291. package/lib/typescript/src/voice/index.d.ts +3 -0
  292. package/lib/typescript/src/voice/index.d.ts.map +1 -0
  293. package/lib/typescript/src/voice/useSpeechRecognition.d.ts +77 -0
  294. package/lib/typescript/src/voice/useSpeechRecognition.d.ts.map +1 -0
  295. package/package.json +132 -0
  296. package/src/chatbot/AIImage.tsx +166 -0
  297. package/src/chatbot/Attachments.tsx +382 -0
  298. package/src/chatbot/ChatErrorBoundary.tsx +230 -0
  299. package/src/chatbot/ChatMessageItem.tsx +195 -0
  300. package/src/chatbot/Conversation.tsx +537 -0
  301. package/src/chatbot/ConversationScrollButton.tsx +149 -0
  302. package/src/chatbot/Message.tsx +266 -0
  303. package/src/chatbot/PromptInput.tsx +532 -0
  304. package/src/chatbot/Reasoning.tsx +198 -0
  305. package/src/chatbot/Shimmer.tsx +146 -0
  306. package/src/chatbot/Sources.tsx +263 -0
  307. package/src/chatbot/Suggestion.tsx +123 -0
  308. package/src/chatbot/Tool.tsx +340 -0
  309. package/src/chatbot/adapters/uiMessageAdapter.ts +177 -0
  310. package/src/chatbot/index.ts +97 -0
  311. package/src/chatbot/types.ts +66 -0
  312. package/src/hooks/index.ts +17 -0
  313. package/src/hooks/useAutoScroll.ts +43 -0
  314. package/src/hooks/useClipboard.ts +46 -0
  315. package/src/hooks/useCollapsible.ts +42 -0
  316. package/src/hooks/useStickToBottom.ts +82 -0
  317. package/src/index.ts +139 -0
  318. package/src/primitives/Badge.tsx +119 -0
  319. package/src/primitives/Button.tsx +213 -0
  320. package/src/primitives/Card.tsx +221 -0
  321. package/src/primitives/Collapsible.tsx +168 -0
  322. package/src/primitives/ScrollArea.tsx +53 -0
  323. package/src/primitives/index.ts +36 -0
  324. package/src/streaming/StreamingMarkdown.tsx +282 -0
  325. package/src/streaming/index.ts +2 -0
  326. package/src/streaming/parser.ts +506 -0
  327. package/src/streaming/renderers/BlockquoteRenderer.tsx +42 -0
  328. package/src/streaming/renderers/CodeRenderer.tsx +158 -0
  329. package/src/streaming/renderers/HeadingRenderer.tsx +64 -0
  330. package/src/streaming/renderers/ImageRenderer.tsx +62 -0
  331. package/src/streaming/renderers/LinkRenderer.tsx +53 -0
  332. package/src/streaming/renderers/ListRenderer.tsx +65 -0
  333. package/src/streaming/renderers/TableRenderer.tsx +103 -0
  334. package/src/streaming/renderers/TextRenderer.tsx +39 -0
  335. package/src/streaming/renderers/index.ts +26 -0
  336. package/src/streaming/renderers/renderInlineChildren.tsx +115 -0
  337. package/src/streaming/renderers/renderNode.tsx +72 -0
  338. package/src/theme/ThemeProvider.tsx +77 -0
  339. package/src/theme/defaultTheme.ts +93 -0
  340. package/src/theme/index.ts +4 -0
  341. package/src/theme/tokens.ts +69 -0
  342. package/src/types.d.ts +71 -0
  343. package/src/voice/index.ts +15 -0
  344. package/src/voice/useSpeechRecognition.ts +230 -0
@@ -0,0 +1,130 @@
1
+ "use strict";
2
+
3
+ import React, { createContext, useCallback, useContext, useState } from 'react';
4
+ import { Pressable, StyleSheet } from 'react-native';
5
+ import Animated, { useAnimatedStyle, useDerivedValue, useSharedValue, withTiming } from 'react-native-reanimated';
6
+
7
+ // ---------------------------------------------------------------------------
8
+ // Context
9
+ // ---------------------------------------------------------------------------
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+ const CollapsibleContext = /*#__PURE__*/createContext(null);
12
+ function useCollapsibleContext() {
13
+ const ctx = useContext(CollapsibleContext);
14
+ if (!ctx) {
15
+ throw new Error('Collapsible compound components must be used within a <Collapsible>.');
16
+ }
17
+ return ctx;
18
+ }
19
+
20
+ // ---------------------------------------------------------------------------
21
+ // Prop types
22
+ // ---------------------------------------------------------------------------
23
+
24
+ // ---------------------------------------------------------------------------
25
+ // Collapsible (parent)
26
+ // ---------------------------------------------------------------------------
27
+
28
+ export function Collapsible({
29
+ open: controlledOpen,
30
+ onOpenChange,
31
+ children,
32
+ style
33
+ }) {
34
+ const [internalOpen, setInternalOpen] = useState(false);
35
+ const isControlled = controlledOpen !== undefined;
36
+ const open = isControlled ? controlledOpen : internalOpen;
37
+ const onToggle = useCallback(() => {
38
+ const next = !open;
39
+ if (!isControlled) {
40
+ setInternalOpen(next);
41
+ }
42
+ onOpenChange?.(next);
43
+ }, [open, isControlled, onOpenChange]);
44
+ return /*#__PURE__*/_jsx(CollapsibleContext.Provider, {
45
+ value: {
46
+ open,
47
+ onToggle
48
+ },
49
+ children: /*#__PURE__*/_jsx(Animated.View, {
50
+ style: style,
51
+ children: children
52
+ })
53
+ });
54
+ }
55
+
56
+ // ---------------------------------------------------------------------------
57
+ // CollapsibleTrigger
58
+ // ---------------------------------------------------------------------------
59
+
60
+ export function CollapsibleTrigger({
61
+ children,
62
+ style
63
+ }) {
64
+ const {
65
+ onToggle
66
+ } = useCollapsibleContext();
67
+ return /*#__PURE__*/_jsx(Pressable, {
68
+ onPress: onToggle,
69
+ style: ({
70
+ pressed
71
+ }) => [pressed && styles.pressed, style],
72
+ children: children
73
+ });
74
+ }
75
+
76
+ // ---------------------------------------------------------------------------
77
+ // CollapsibleContent (animated)
78
+ // ---------------------------------------------------------------------------
79
+
80
+ export function CollapsibleContent({
81
+ children,
82
+ style
83
+ }) {
84
+ const {
85
+ open
86
+ } = useCollapsibleContext();
87
+ const measuredHeight = useSharedValue(0);
88
+ const progress = useDerivedValue(() => withTiming(open ? 1 : 0, {
89
+ duration: 250
90
+ }));
91
+ const animatedContainerStyle = useAnimatedStyle(() => ({
92
+ height: progress.value * measuredHeight.value,
93
+ opacity: progress.value,
94
+ overflow: 'hidden'
95
+ }));
96
+ const onLayout = useCallback(event => {
97
+ const layoutHeight = event.nativeEvent.layout.height;
98
+ if (layoutHeight > 0) {
99
+ measuredHeight.value = layoutHeight;
100
+ }
101
+ }, [measuredHeight]);
102
+ return /*#__PURE__*/_jsx(Animated.View, {
103
+ style: [animatedContainerStyle, style],
104
+ children: /*#__PURE__*/_jsx(Animated.View, {
105
+ style: styles.inner,
106
+ onLayout: onLayout,
107
+ children: children
108
+ })
109
+ });
110
+ }
111
+
112
+ // ---------------------------------------------------------------------------
113
+ // Styles
114
+ // ---------------------------------------------------------------------------
115
+
116
+ const styles = StyleSheet.create({
117
+ pressed: {
118
+ opacity: 0.7
119
+ },
120
+ inner: {
121
+ // Position absolute so we can measure the natural height without
122
+ // the parent constraining it while collapsed. Once the parent animates
123
+ // to the full measured height the content is fully visible.
124
+ position: 'absolute',
125
+ width: '100%',
126
+ top: 0,
127
+ left: 0
128
+ }
129
+ });
130
+ //# sourceMappingURL=Collapsible.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","createContext","useCallback","useContext","useState","Pressable","StyleSheet","Animated","useAnimatedStyle","useDerivedValue","useSharedValue","withTiming","jsx","_jsx","CollapsibleContext","useCollapsibleContext","ctx","Error","Collapsible","open","controlledOpen","onOpenChange","children","style","internalOpen","setInternalOpen","isControlled","undefined","onToggle","next","Provider","value","View","CollapsibleTrigger","onPress","pressed","styles","CollapsibleContent","measuredHeight","progress","duration","animatedContainerStyle","height","opacity","overflow","onLayout","event","layoutHeight","nativeEvent","layout","inner","create","position","width","top","left"],"sourceRoot":"../../../src","sources":["primitives/Collapsible.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IACVC,aAAa,EACbC,WAAW,EACXC,UAAU,EACVC,QAAQ,QAEH,OAAO;AACd,SAASC,SAAS,EAAEC,UAAU,QAAwC,cAAc;AACpF,OAAOC,QAAQ,IACbC,gBAAgB,EAChBC,eAAe,EACfC,cAAc,EACdC,UAAU,QACL,yBAAyB;;AAEhC;AACA;AACA;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAOA,MAAMC,kBAAkB,gBAAGb,aAAa,CAAiC,IAA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B;;AAEA;AACA;AACA;;AAEA,MAAMc,MAAM,GAAG9B,UAAU,CAAC6C,MAAM,CAAC;EAC/BhB,OAAO,EAAE;IACPQ,OAAO,EAAE;EACX,CAAC;EACDO,KAAK,EAAE;IACL;IACA;IACA;IACAE,QAAQ,EAAE,UAAU;IACpBC,KAAK,EAAE,MAAM;IACbC,GAAG,EAAE,CAAC;IACNC,IAAI,EAAE;EACR;AACF,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ import React from 'react';
4
+ import { ScrollView, StyleSheet } from 'react-native';
5
+ import { useAIElementsTheme } from '../theme';
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ export function ScrollArea({
8
+ horizontal = false,
9
+ style,
10
+ contentContainerStyle,
11
+ children,
12
+ ...scrollViewProps
13
+ }) {
14
+ const theme = useAIElementsTheme();
15
+ return /*#__PURE__*/_jsx(ScrollView, {
16
+ ...scrollViewProps,
17
+ horizontal: horizontal,
18
+ showsVerticalScrollIndicator: false,
19
+ showsHorizontalScrollIndicator: false,
20
+ style: [styles.base, {
21
+ backgroundColor: theme.colors.background
22
+ }, style],
23
+ contentContainerStyle: [styles.contentContainer, contentContainerStyle],
24
+ children: children
25
+ });
26
+ }
27
+ const styles = StyleSheet.create({
28
+ base: {
29
+ flex: 1
30
+ },
31
+ contentContainer: {
32
+ flexGrow: 1
33
+ }
34
+ });
35
+ //# sourceMappingURL=ScrollArea.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","ScrollView","StyleSheet","useAIElementsTheme","jsx","_jsx","ScrollArea","horizontal","style","contentContainerStyle","children","scrollViewProps","theme","showsVerticalScrollIndicator","showsHorizontalScrollIndicator","styles","base","backgroundColor","colors","background","contentContainer","create","flex","flexGrow"],"sourceRoot":"../../../src","sources":["primitives/ScrollArea.tsx"],"mappings":";;AAAA,OAAOA,KAAK,MAA0B,OAAO;AAC7C,SACEC,UAAU,EACVC,UAAU,QAIL,cAAc;AACrB,SAASC,kBAAkB,QAAQ,UAAU;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAU9C,OAAO,SAASC,UAAUA,CAAC;EACzBC,UAAU,GAAG,KAAK;EAClBC,KAAK;EACLC,qBAAqB;EACrBC,QAAQ;EACR,GAAGC;AACY,CAAC,EAAE;EAClB,MAAMC,KAAK,GAAGT,kBAAkB,CAAC,CAAC;EAElC,oBACEE,IAAA,CAACJ,UAAU;IAAA,GACLU,eAAe;IACnBJ,UAAU,EAAEA,UAAW;IACvBM,4BAA4B,EAAE,KAAM;IACpCC,8BAA8B,EAAE,KAAM;IACtCN,KAAK,EAAE,CACLO,MAAM,CAACC,IAAI,EACX;MAAEC,eAAe,EAAEL,KAAK,CAACM,MAAM,CAACC;IAAW,CAAC,EAC5CX,KAAK,CACL;IACFC,qBAAqB,EAAE,CAACM,MAAM,CAACK,gBAAgB,EAAEX,qBAAqB,CAAE;IAAAC,QAAA,EAEvEA;EAAQ,CACC,CAAC;AAEjB;AAEA,MAAMK,MAAM,GAAGb,UAAU,CAACmB,MAAM,CAAC;EAC/BL,IAAI,EAAE;IACJM,IAAI,EAAE;EACR,CAAC;EACDF,gBAAgB,EAAE;IAChBG,QAAQ,EAAE;EACZ;AACF,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+
3
+ export { Button } from './Button';
4
+ export { Badge } from './Badge';
5
+ export { Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter } from './Card';
6
+ export { Collapsible, CollapsibleTrigger, CollapsibleContent } from './Collapsible';
7
+ export { ScrollArea } from './ScrollArea';
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Button","Badge","Card","CardHeader","CardTitle","CardDescription","CardContent","CardFooter","Collapsible","CollapsibleTrigger","CollapsibleContent","ScrollArea"],"sourceRoot":"../../../src","sources":["primitives/index.ts"],"mappings":";;AAAA,SAASA,MAAM,QAAQ,UAAU;AAGjC,SAASC,KAAK,QAAQ,SAAS;AAG/B,SACEC,IAAI,EACJC,UAAU,EACVC,SAAS,EACTC,eAAe,EACfC,WAAW,EACXC,UAAU,QACL,QAAQ;AAUf,SACEC,WAAW,EACXC,kBAAkB,EAClBC,kBAAkB,QACb,eAAe;AAOtB,SAASC,UAAU,QAAQ,cAAc","ignoreList":[]}
@@ -0,0 +1,246 @@
1
+ "use strict";
2
+
3
+ import React, { memo, useCallback, useMemo } from 'react';
4
+ import { Linking, StyleSheet, View } from 'react-native';
5
+ import Markdown from 'react-native-markdown-display';
6
+ import { useAIElementsTheme } from '../theme';
7
+ import { jsx as _jsx } from "react/jsx-runtime";
8
+ /**
9
+ * Closes any dangling markdown constructs that the parser would otherwise
10
+ * mis-render mid-stream. Most importantly: an unclosed fenced code block
11
+ * causes everything after the opening ``` to be rendered as code until the
12
+ * closing fence arrives, which produces a jarring flicker.
13
+ *
14
+ * This is correctness, not animation — keep it even in the "simple" version.
15
+ */
16
+ function stabilizePartialMarkdown(content) {
17
+ const fenceMatches = content.match(/^```/gm);
18
+ const fenceCount = fenceMatches?.length ?? 0;
19
+ if (fenceCount % 2 === 1) {
20
+ const needsNewline = !content.endsWith('\n');
21
+ return `${content}${needsNewline ? '\n' : ''}\`\`\``;
22
+ }
23
+ return content;
24
+ }
25
+ function createMarkdownStyles(theme) {
26
+ return {
27
+ body: {
28
+ color: theme.colors.foreground,
29
+ fontSize: 12,
30
+ lineHeight: 12 * theme.typography.lineHeight.normal,
31
+ fontFamily: theme.typography.fontFamily
32
+ },
33
+ heading1: {
34
+ color: theme.colors.foreground,
35
+ fontSize: theme.typography.fontSize['2xl'],
36
+ fontWeight: theme.typography.fontWeight.bold,
37
+ lineHeight: theme.typography.fontSize['2xl'] * theme.typography.lineHeight.tight,
38
+ marginTop: theme.spacing.lg,
39
+ marginBottom: theme.spacing.md
40
+ },
41
+ heading2: {
42
+ color: theme.colors.foreground,
43
+ fontSize: theme.typography.fontSize.xl,
44
+ fontWeight: theme.typography.fontWeight.bold,
45
+ lineHeight: theme.typography.fontSize.xl * theme.typography.lineHeight.tight,
46
+ marginTop: theme.spacing.lg,
47
+ marginBottom: theme.spacing.sm
48
+ },
49
+ heading3: {
50
+ color: theme.colors.foreground,
51
+ fontSize: theme.typography.fontSize.lg,
52
+ fontWeight: theme.typography.fontWeight.semibold,
53
+ lineHeight: theme.typography.fontSize.lg * theme.typography.lineHeight.tight,
54
+ marginTop: theme.spacing.md,
55
+ marginBottom: theme.spacing.sm
56
+ },
57
+ heading4: {
58
+ color: theme.colors.foreground,
59
+ fontSize: theme.typography.fontSize.md,
60
+ fontWeight: theme.typography.fontWeight.semibold,
61
+ marginTop: theme.spacing.md,
62
+ marginBottom: theme.spacing.xs
63
+ },
64
+ strong: {
65
+ fontWeight: theme.typography.fontWeight.bold
66
+ },
67
+ em: {
68
+ fontStyle: 'italic'
69
+ },
70
+ link: {
71
+ color: theme.colors.primary,
72
+ textDecorationLine: 'underline'
73
+ },
74
+ code_inline: {
75
+ backgroundColor: theme.colors.muted,
76
+ color: theme.colors.foreground,
77
+ fontFamily: theme.typography.monoFontFamily,
78
+ fontSize: theme.typography.fontSize.sm,
79
+ paddingHorizontal: 4,
80
+ paddingVertical: 2,
81
+ borderRadius: theme.radius.sm
82
+ },
83
+ code_block: {
84
+ backgroundColor: theme.dark ? '#1E1E1E' : '#F8F8F8',
85
+ color: theme.colors.foreground,
86
+ fontFamily: theme.typography.monoFontFamily,
87
+ fontSize: theme.typography.fontSize.sm,
88
+ lineHeight: theme.typography.fontSize.sm * theme.typography.lineHeight.relaxed,
89
+ padding: theme.spacing.md,
90
+ borderRadius: theme.radius.md,
91
+ marginVertical: theme.spacing.sm
92
+ },
93
+ fence: {
94
+ backgroundColor: theme.dark ? '#1E1E1E' : '#F8F8F8',
95
+ color: theme.colors.foreground,
96
+ fontFamily: theme.typography.monoFontFamily,
97
+ fontSize: theme.typography.fontSize.sm,
98
+ lineHeight: theme.typography.fontSize.sm * theme.typography.lineHeight.relaxed,
99
+ padding: theme.spacing.md,
100
+ borderRadius: theme.radius.md,
101
+ marginVertical: theme.spacing.sm
102
+ },
103
+ blockquote: {
104
+ backgroundColor: theme.colors.muted,
105
+ borderLeftColor: theme.colors.border,
106
+ borderLeftWidth: 3,
107
+ paddingHorizontal: theme.spacing.md,
108
+ paddingVertical: theme.spacing.sm,
109
+ marginVertical: theme.spacing.sm,
110
+ borderRadius: theme.radius.sm
111
+ },
112
+ bullet_list: {
113
+ marginVertical: theme.spacing.xs
114
+ },
115
+ ordered_list: {
116
+ marginVertical: theme.spacing.xs
117
+ },
118
+ list_item: {
119
+ flexDirection: 'row',
120
+ marginVertical: 2
121
+ },
122
+ bullet_list_icon: {
123
+ color: theme.colors.mutedForeground,
124
+ fontSize: theme.typography.fontSize.md,
125
+ lineHeight: theme.typography.fontSize.md * theme.typography.lineHeight.normal,
126
+ marginRight: theme.spacing.sm
127
+ },
128
+ ordered_list_icon: {
129
+ color: theme.colors.mutedForeground,
130
+ fontSize: theme.typography.fontSize.md,
131
+ lineHeight: theme.typography.fontSize.md * theme.typography.lineHeight.normal,
132
+ marginRight: theme.spacing.sm
133
+ },
134
+ table: {
135
+ borderWidth: StyleSheet.hairlineWidth,
136
+ borderColor: theme.colors.border,
137
+ borderRadius: theme.radius.sm,
138
+ marginVertical: theme.spacing.sm
139
+ },
140
+ thead: {
141
+ backgroundColor: theme.colors.muted
142
+ },
143
+ th: {
144
+ padding: theme.spacing.sm,
145
+ borderRightWidth: StyleSheet.hairlineWidth,
146
+ borderColor: theme.colors.border,
147
+ fontWeight: theme.typography.fontWeight.semibold
148
+ },
149
+ tr: {
150
+ borderBottomWidth: StyleSheet.hairlineWidth,
151
+ borderColor: theme.colors.border
152
+ },
153
+ td: {
154
+ padding: theme.spacing.sm,
155
+ borderRightWidth: StyleSheet.hairlineWidth,
156
+ borderColor: theme.colors.border
157
+ },
158
+ hr: {
159
+ backgroundColor: theme.colors.border,
160
+ height: 1,
161
+ marginVertical: theme.spacing.lg
162
+ },
163
+ paragraph: {
164
+ marginVertical: theme.spacing.xs
165
+ },
166
+ image: {
167
+ borderRadius: theme.radius.md
168
+ }
169
+ };
170
+ }
171
+ /**
172
+ * Memoized markdown body. Re-renders only when the content string or theme
173
+ * styles change — mirroring the `memo(MessageResponse)` pattern that Vercel
174
+ * ai-elements uses around `Streamdown`
175
+ * (opensrc/.../vercel/ai-elements/packages/elements/src/message.tsx:326).
176
+ */
177
+ const MemoMarkdown = /*#__PURE__*/memo(({
178
+ content,
179
+ styles,
180
+ onLinkPress
181
+ }) => /*#__PURE__*/_jsx(Markdown, {
182
+ style: styles,
183
+ mergeStyle: true,
184
+ onLinkPress: onLinkPress,
185
+ children: content
186
+ }), (prev, next) => prev.content === next.content && prev.styles === next.styles && prev.onLinkPress === next.onLinkPress);
187
+ MemoMarkdown.displayName = 'MemoMarkdown';
188
+
189
+ /**
190
+ * StreamingMarkdown — renders markdown content using react-native-markdown-display.
191
+ *
192
+ * Deliberately matches the simplicity of Vercel ai-elements'
193
+ * `MessageResponse` (a memoized wrapper around `Streamdown`): no custom
194
+ * fade animations, no block-level entrance effects, no opacity tricks,
195
+ * **no additional throttling**. Content re-renders as it grows and the
196
+ * visual "streaming" feel comes from the tokens arriving incrementally
197
+ * from the network.
198
+ *
199
+ * **Why no RAF throttling?** We used to throttle updates to ~60fps via
200
+ * `requestAnimationFrame` inside this component. That sounds good on
201
+ * paper but stacks badly with `useChat`'s own `experimental_throttle`:
202
+ * the two timers drift out of phase, and you end up seeing "first word,
203
+ * then the rest of the text all at once" on subsequent messages. Vercel
204
+ * ai-elements trusts `useChat` entirely and does the same — see
205
+ * `opensrc/.../vercel/ai-elements/packages/elements/src/message.tsx:326`.
206
+ * If you need to throttle the re-render rate, set
207
+ * `experimental_throttle: 25` (or whatever) on the `useChat` call. Don't
208
+ * layer a second throttler here.
209
+ *
210
+ * What IS preserved:
211
+ * - `stabilizePartialMarkdown` — closes unclosed code fences mid-stream
212
+ * so the parser doesn't swallow the rest of the message as code.
213
+ * Pure correctness, not visual.
214
+ * - `MemoMarkdown` — shallow-equal memoization so identical content
215
+ * doesn't re-parse. Matches `memo(MessageResponse)` in ai-elements.
216
+ */
217
+ export function StreamingMarkdown({
218
+ content,
219
+ isStreaming = false,
220
+ style
221
+ }) {
222
+ const theme = useAIElementsTheme();
223
+ const markdownStyles = useMemo(() => createMarkdownStyles(theme), [theme]);
224
+ const handleLinkPress = useCallback(url => {
225
+ Linking.openURL(url).catch(() => {});
226
+ return false;
227
+ }, []);
228
+ const displayContent = useMemo(() => isStreaming ? stabilizePartialMarkdown(content) : content, [content, isStreaming]);
229
+ if (displayContent.length === 0) {
230
+ return null;
231
+ }
232
+ return /*#__PURE__*/_jsx(View, {
233
+ style: [styles.container, style],
234
+ children: /*#__PURE__*/_jsx(MemoMarkdown, {
235
+ content: displayContent,
236
+ styles: markdownStyles,
237
+ onLinkPress: handleLinkPress
238
+ })
239
+ });
240
+ }
241
+ const styles = StyleSheet.create({
242
+ container: {
243
+ flexShrink: 1
244
+ }
245
+ });
246
+ //# sourceMappingURL=StreamingMarkdown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","memo","useCallback","useMemo","Linking","StyleSheet","View","Markdown","useAIElementsTheme","jsx","_jsx","stabilizePartialMarkdown","content","fenceMatches","match","fenceCount","length","needsNewline","endsWith","createMarkdownStyles","theme","body","color","colors","foreground","fontSize","lineHeight","typography","normal","fontFamily","heading1","fontWeight","bold","tight","marginTop","spacing","lg","marginBottom","md","heading2","xl","sm","heading3","semibold","heading4","xs","strong","em","fontStyle","link","primary","textDecorationLine","code_inline","backgroundColor","muted","monoFontFamily","paddingHorizontal","paddingVertical","borderRadius","radius","code_block","dark","relaxed","padding","marginVertical","fence","blockquote","borderLeftColor","border","borderLeftWidth","bullet_list","ordered_list","list_item","flexDirection","bullet_list_icon","mutedForeground","marginRight","ordered_list_icon","table","borderWidth","hairlineWidth","borderColor","thead","th","borderRightWidth","tr","borderBottomWidth","td","hr","height","paragraph","image","MemoMarkdown","styles","onLinkPress","style","mergeStyle","children","prev","next","displayName","StreamingMarkdown","isStreaming","markdownStyles","handleLinkPress","url","openURL","catch","displayContent","container","create","flexShrink"],"sourceRoot":"../../../src","sources":["streaming/StreamingMarkdown.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,IAAI,EAAEC,WAAW,EAAEC,OAAO,QAAQ,OAAO;AACzD,SAASC,OAAO,EAAEC,UAAU,EAAEC,IAAI,QAAwC,cAAc;AACxF,OAAOC,QAAQ,MAAM,+BAA+B;AACpD,SAASC,kBAAkB,QAAQ,UAAU;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAG9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,wBAAwBA,CAACC,OAAe,EAAU;EACzD,MAAMC,YAAY,GAAGD,OAAO,CAACE,KAAK,CAAC,QAAQ,CAAC;EAC5C,MAAMC,UAAU,GAAGF,YAAY,EAAEG,MAAM,IAAI,CAAC;EAC5C,IAAID,UAAU,GAAG,CAAC,KAAK,CAAC,EAAE;IACxB,MAAME,YAAY,GAAG,CAACL,OAAO,CAACM,QAAQ,CAAC,IAAI,CAAC;IAC5C,OAAO,GAAGN,OAAO,GAAGK,YAAY,GAAG,IAAI,GAAG,EAAE,QAAQ;EACtD;EACA,OAAOL,OAAO;AAChB;AAmBA,SAASO,oBAAoBA,CAACC,KAAsB,EAAE;EACpD,OAAO;IACLC,IAAI,EAAE;MACJC,KAAK,EAAEF,KAAK,CAACG,MAAM,CAACC,UAAU;MAC9BC,QAAQ,EAAE,EAAE;MACZC,UAAU,EAAE,EAAE,GAAGN,KAAK,CAACO,UAAU,CAACD,UAAU,CAACE,MAAM;MACnDC,UAAU,EAAET,KAAK,CAACO,UAAU,CAACE;IAC/B,CAAC;IACDC,QAAQ,EAAE;MACRR,KAAK,EAAEF,KAAK,CAACG,MAAM,CAACC,UAAU;MAC9BC,QAAQ,EAAEL,KAAK,CAACO,UAAU,CAACF,QAAQ,CAAC,KAAK,CAAC;M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;AACA;AACA;AACA;AACA,OAAO,SAASC,iBAAiBA,CAAC;EAChCzF,OAAO;EACP0F,WAAW,GAAG,KAAK;EACnBP;AACsB,CAAC,EAAE;EACzB,MAAM3E,KAAK,GAAGZ,kBAAkB,CAAC,CAAC;EAElC,MAAM+F,cAAc,GAAGpG,OAAO,CAAC,MAAMgB,oBAAoB,CAACC,KAAK,CAAC,EAAE,CAACA,KAAK,CAAC,CAAC;EAE1E,MAAMoF,eAAe,GAAGtG,WAAW,CAAEuG,GAAW,IAAK;IACnDrG,OAAO,CAACsG,OAAO,CAACD,GAAG,CAAC,CAACE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;IACpC,OAAO,KAAK;EACd,CAAC,EAAE,EAAE,CAAC;EAEN,MAAMC,cAAc,GAAGzG,OAAO,CAC5B,MAAOmG,WAAW,GAAG3F,wBAAwB,CAACC,OAAO,CAAC,GAAGA,OAAQ,EACjE,CAACA,OAAO,EAAE0F,WAAW,CACvB,CAAC;EAED,IAAIM,cAAc,CAAC5F,MAAM,KAAK,CAAC,EAAE;IAC/B,OAAO,IAAI;EACb;EAEA,oBACEN,IAAA,CAACJ,IAAI;IAACyF,KAAK,EAAE,CAACF,MAAM,CAACgB,SAAS,EAAEd,KAAK,CAAE;IAAAE,QAAA,eACrCvF,IAAA,CAACkF,YAAY;MACXhF,OAAO,EAAEgG,cAAe;MACxBf,MAAM,EAAEU,cAAe;MACvBT,WAAW,EAAEU;IAAgB,CAC9B;EAAC,CACE,CAAC;AAEX;AAEA,MAAMX,MAAM,GAAGxF,UAAU,CAACyG,MAAM,CAAC;EAC/BD,SAAS,EAAE;IACTE,UAAU,EAAE;EACd;AACF,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+
3
+ export { StreamingMarkdown } from './StreamingMarkdown';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["StreamingMarkdown"],"sourceRoot":"../../../src","sources":["streaming/index.ts"],"mappings":";;AAAA,SAASA,iBAAiB,QAAQ,qBAAqB","ignoreList":[]}