@svadmin/ai-elements 0.5.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.
Files changed (303) hide show
  1. package/README.md +18 -53
  2. package/THIRD_PARTY_NOTICES.md +67 -6
  3. package/dist/ai.css +149 -2740
  4. package/dist/ai.theme.css +1 -2771
  5. package/dist/class-properties.generated.d.ts +1 -0
  6. package/dist/class-properties.generated.js +2 -0
  7. package/dist/classnames.d.ts +8 -0
  8. package/dist/classnames.js +26 -0
  9. package/dist/components/AICommandBar.svelte +6 -4
  10. package/dist/components/ChatDialog.svelte +102 -125
  11. package/dist/components/ChatDialog.svelte.d.ts +3 -9
  12. package/dist/components/Conversation.svelte +34 -10
  13. package/dist/components/ConversationContent.svelte +1 -1
  14. package/dist/components/ConversationScrollButton.svelte +0 -1
  15. package/dist/components/CopilotPanel.svelte +8 -6
  16. package/dist/components/Message.svelte +1 -1
  17. package/dist/components/MessageActions.svelte +1 -1
  18. package/dist/components/MessageContent.svelte +1 -1
  19. package/dist/components/MessageToolbar.svelte +1 -1
  20. package/dist/components/Response.svelte +32 -12
  21. package/dist/components/Response.svelte.d.ts +3 -3
  22. package/dist/components/Tool.svelte +13 -13
  23. package/dist/components/Tool.svelte.d.ts +1 -1
  24. package/dist/components/action/Action.svelte +3 -1
  25. package/dist/components/artifact/ArtifactAction.svelte +3 -1
  26. package/dist/components/attachments/Attachment.svelte +4 -2
  27. package/dist/components/attachments/Attachments.svelte +3 -1
  28. package/dist/components/attachments/types.js +3 -2
  29. package/dist/components/audio-player/AudioPlayer.svelte.d.ts +1 -1
  30. package/dist/components/canvas/Canvas.svelte +1 -1
  31. package/dist/components/checkpoint/index.d.ts +2 -2
  32. package/dist/components/code/index.d.ts +9 -1
  33. package/dist/components/code/index.js +8 -1
  34. package/dist/components/code-block/CodeBlockLanguageSelector.svelte.d.ts +1 -1
  35. package/dist/components/code-block/highlight.js +11 -10
  36. package/dist/components/commit/Commit.svelte +23 -2
  37. package/dist/components/commit/CommitActions.svelte +2 -11
  38. package/dist/components/commit/CommitCopyButton.svelte +1 -1
  39. package/dist/components/commit/CommitHeader.svelte +12 -2
  40. package/dist/components/commit/context.svelte.d.ts +6 -0
  41. package/dist/components/commit/context.svelte.js +14 -0
  42. package/dist/components/context/Context.svelte +6 -4
  43. package/dist/components/context/TokensWithCost.svelte +2 -1
  44. package/dist/components/edge/Animated.svelte +6 -6
  45. package/dist/components/edge/Temporary.svelte +6 -5
  46. package/dist/components/file-tree/FileTree.svelte +7 -5
  47. package/dist/components/jsx-preview/parser.js +10 -10
  48. package/dist/components/message/MessageAction.svelte +3 -1
  49. package/dist/components/mic-selector/MicSelector.svelte.d.ts +1 -1
  50. package/dist/components/model-selector/ModelSelectorDialog.svelte +3 -1
  51. package/dist/components/open-in-chat/OpenInChatGPT.svelte +3 -1
  52. package/dist/components/open-in-chat/OpenInClaude.svelte +3 -1
  53. package/dist/components/open-in-chat/OpenInCursor.svelte +3 -1
  54. package/dist/components/open-in-chat/OpenInGitHub.svelte +3 -1
  55. package/dist/components/open-in-chat/OpenInScira.svelte +3 -1
  56. package/dist/components/open-in-chat/OpenInT3.svelte +3 -1
  57. package/dist/components/open-in-chat/OpenInv0.svelte +3 -1
  58. package/dist/components/package-info/PackageInfo.svelte +3 -1
  59. package/dist/components/prompt-input/PromptInput.svelte +8 -18
  60. package/dist/components/prompt-input/PromptInputCommand.svelte +2 -1
  61. package/dist/components/prompt-input/PromptInputSelect.svelte.d.ts +1 -1
  62. package/dist/components/prompt-input/PromptInputSubmit.svelte +5 -18
  63. package/dist/components/prompt-input/PromptInputTextarea.svelte +6 -11
  64. package/dist/components/prompt-input/context.svelte.d.ts +1 -8
  65. package/dist/components/prompt-input/files.js +3 -2
  66. package/dist/components/question/Question.svelte +3 -1
  67. package/dist/components/schema-display/SchemaDisplay.svelte +4 -2
  68. package/dist/components/schema-display/SchemaDisplayParameter.svelte +14 -1
  69. package/dist/components/schema-display/SchemaDisplayProperty.svelte +16 -1
  70. package/dist/components/snippet/index.d.ts +3 -3
  71. package/dist/components/stack-trace/StackTrace.svelte +7 -5
  72. package/dist/components/suggestion/index.d.ts +1 -1
  73. package/dist/components/terminal/Terminal.svelte +4 -2
  74. package/dist/components/terminal/ansi.js +9 -6
  75. package/dist/components/test-results/Test.svelte +1 -1
  76. package/dist/components/test-results/TestResults.svelte +1 -1
  77. package/dist/components/test-results/context.svelte.d.ts +1 -1
  78. package/dist/components/tool/ToolContent.svelte +1 -1
  79. package/dist/components/tool/ToolHeader.svelte +5 -5
  80. package/dist/components/tool/ToolInput.svelte +2 -4
  81. package/dist/components/tool/ToolOutput.svelte +2 -4
  82. package/dist/components/tool/ToolStatusBadge.svelte +2 -3
  83. package/dist/components/voice-selector/VoiceSelector.svelte +2 -1
  84. package/dist/components/voice-selector/VoiceSelector.svelte.d.ts +2 -2
  85. package/dist/components/voice-selector/context.svelte.d.ts +2 -1
  86. package/dist/components/web-preview/WebPreview.svelte +4 -3
  87. package/dist/contracts.d.ts +2 -2
  88. package/dist/generated-components.d.ts +15 -1
  89. package/dist/generated-components.js +20 -1
  90. package/dist/internal/Tooltip.svelte +2 -1
  91. package/dist/parity-manifest.d.ts +0 -1
  92. package/dist/parity-manifest.js +0 -97
  93. package/dist/utilities.css +3172 -0
  94. package/dist/utils.d.ts +1 -1
  95. package/dist/utils.js +1 -1
  96. package/package.json +37 -22
  97. package/vendor/streamdown/AnimatedText.svelte +93 -0
  98. package/vendor/streamdown/AnimatedText.svelte.d.ts +6 -0
  99. package/vendor/streamdown/Block.svelte +96 -0
  100. package/vendor/streamdown/Block.svelte.d.ts +11 -0
  101. package/vendor/streamdown/Elements/Alert.svelte +69 -0
  102. package/vendor/streamdown/Elements/Alert.svelte.d.ts +10 -0
  103. package/vendor/streamdown/Elements/Citation.svelte +260 -0
  104. package/vendor/streamdown/Elements/Citation.svelte.d.ts +7 -0
  105. package/vendor/streamdown/Elements/Code.svelte +226 -0
  106. package/vendor/streamdown/Elements/Code.svelte.d.ts +9 -0
  107. package/vendor/streamdown/Elements/Element.svelte +574 -0
  108. package/vendor/streamdown/Elements/Element.svelte.d.ts +10 -0
  109. package/vendor/streamdown/Elements/FootnoteRef.svelte +30 -0
  110. package/vendor/streamdown/Elements/FootnoteRef.svelte.d.ts +7 -0
  111. package/vendor/streamdown/Elements/Footnotes.svelte +54 -0
  112. package/vendor/streamdown/Elements/Footnotes.svelte.d.ts +7 -0
  113. package/vendor/streamdown/Elements/Image.svelte +200 -0
  114. package/vendor/streamdown/Elements/Image.svelte.d.ts +10 -0
  115. package/vendor/streamdown/Elements/Link.svelte +220 -0
  116. package/vendor/streamdown/Elements/Link.svelte.d.ts +10 -0
  117. package/vendor/streamdown/Elements/LinkSafetyModal.svelte +121 -0
  118. package/vendor/streamdown/Elements/LinkSafetyModal.svelte.d.ts +4 -0
  119. package/vendor/streamdown/Elements/Math.svelte +100 -0
  120. package/vendor/streamdown/Elements/Math.svelte.d.ts +9 -0
  121. package/vendor/streamdown/Elements/Mermaid.svelte +455 -0
  122. package/vendor/streamdown/Elements/Mermaid.svelte.d.ts +9 -0
  123. package/vendor/streamdown/Elements/MermaidDownload.svelte +145 -0
  124. package/vendor/streamdown/Elements/MermaidDownload.svelte.d.ts +8 -0
  125. package/vendor/streamdown/Elements/Slot.svelte +23 -0
  126. package/vendor/streamdown/Elements/Slot.svelte.d.ts +10 -0
  127. package/vendor/streamdown/Elements/Table.svelte +195 -0
  128. package/vendor/streamdown/Elements/Table.svelte.d.ts +9 -0
  129. package/vendor/streamdown/Elements/TableDownload.svelte +221 -0
  130. package/vendor/streamdown/Elements/TableDownload.svelte.d.ts +8 -0
  131. package/vendor/streamdown/Elements/fallbacks/CodeFallback.svelte +41 -0
  132. package/vendor/streamdown/Elements/fallbacks/CodeFallback.svelte.d.ts +9 -0
  133. package/vendor/streamdown/Elements/fallbacks/MathFallback.svelte +35 -0
  134. package/vendor/streamdown/Elements/fallbacks/MathFallback.svelte.d.ts +8 -0
  135. package/vendor/streamdown/Elements/fallbacks/MermaidFallback.svelte +36 -0
  136. package/vendor/streamdown/Elements/fallbacks/MermaidFallback.svelte.d.ts +9 -0
  137. package/vendor/streamdown/Elements/fallbacks/index.d.ts +3 -0
  138. package/vendor/streamdown/Elements/fallbacks/index.js +3 -0
  139. package/vendor/streamdown/Elements/icons.d.ts +31 -0
  140. package/vendor/streamdown/Elements/icons.js +200 -0
  141. package/vendor/streamdown/Elements/index.d.ts +8 -0
  142. package/vendor/streamdown/Elements/index.js +8 -0
  143. package/vendor/streamdown/Elements/popover.svelte.d.ts +8 -0
  144. package/vendor/streamdown/Elements/popover.svelte.js +45 -0
  145. package/vendor/streamdown/Elements/stepperState.svelte.d.ts +36 -0
  146. package/vendor/streamdown/Elements/stepperState.svelte.js +92 -0
  147. package/vendor/streamdown/IconProvider.svelte +11 -0
  148. package/vendor/streamdown/IconProvider.svelte.d.ts +30 -0
  149. package/vendor/streamdown/LICENSE +202 -0
  150. package/vendor/streamdown/PluginProvider.svelte +11 -0
  151. package/vendor/streamdown/PluginProvider.svelte.d.ts +30 -0
  152. package/vendor/streamdown/README.svadmin.md +5 -0
  153. package/vendor/streamdown/Streamdown.svelte +447 -0
  154. package/vendor/streamdown/Streamdown.svelte.d.ts +25 -0
  155. package/vendor/streamdown/block/BlockTokens.svelte +45 -0
  156. package/vendor/streamdown/block/BlockTokens.svelte.d.ts +9 -0
  157. package/vendor/streamdown/block/html.d.ts +14 -0
  158. package/vendor/streamdown/block/html.js +27 -0
  159. package/vendor/streamdown/block/text.d.ts +10 -0
  160. package/vendor/streamdown/block/text.js +31 -0
  161. package/vendor/streamdown/context-key.d.ts +1 -0
  162. package/vendor/streamdown/context-key.js +1 -0
  163. package/vendor/streamdown/context.svelte.d.ts +24 -0
  164. package/vendor/streamdown/context.svelte.js +75 -0
  165. package/vendor/streamdown/contracts/plugins.d.ts +26 -0
  166. package/vendor/streamdown/contracts/plugins.js +1 -0
  167. package/vendor/streamdown/contracts/streamdown.d.ts +374 -0
  168. package/vendor/streamdown/contracts/streamdown.js +29 -0
  169. package/vendor/streamdown/detect-direction.d.ts +1 -0
  170. package/vendor/streamdown/detect-direction.js +1 -0
  171. package/vendor/streamdown/icon-context.d.ts +36 -0
  172. package/vendor/streamdown/icon-context.js +52 -0
  173. package/vendor/streamdown/incomplete-code.d.ts +6 -0
  174. package/vendor/streamdown/incomplete-code.js +23 -0
  175. package/vendor/streamdown/index.d.ts +22 -0
  176. package/vendor/streamdown/index.js +20 -0
  177. package/vendor/streamdown/markdown-parse-cache.d.ts +37 -0
  178. package/vendor/streamdown/markdown-parse-cache.js +109 -0
  179. package/vendor/streamdown/markdown.d.ts +21 -0
  180. package/vendor/streamdown/markdown.js +214 -0
  181. package/vendor/streamdown/marked/index.d.ts +44 -0
  182. package/vendor/streamdown/marked/index.js +228 -0
  183. package/vendor/streamdown/marked/marked-alert.d.ts +13 -0
  184. package/vendor/streamdown/marked/marked-alert.js +47 -0
  185. package/vendor/streamdown/marked/marked-align.d.ts +10 -0
  186. package/vendor/streamdown/marked/marked-align.js +45 -0
  187. package/vendor/streamdown/marked/marked-br.d.ts +6 -0
  188. package/vendor/streamdown/marked/marked-br.js +15 -0
  189. package/vendor/streamdown/marked/marked-citations.d.ts +8 -0
  190. package/vendor/streamdown/marked/marked-citations.js +53 -0
  191. package/vendor/streamdown/marked/marked-cjk.d.ts +2 -0
  192. package/vendor/streamdown/marked/marked-cjk.js +165 -0
  193. package/vendor/streamdown/marked/marked-dl.d.ts +23 -0
  194. package/vendor/streamdown/marked/marked-dl.js +44 -0
  195. package/vendor/streamdown/marked/marked-footnotes.d.ts +26 -0
  196. package/vendor/streamdown/marked/marked-footnotes.js +101 -0
  197. package/vendor/streamdown/marked/marked-hr.d.ts +6 -0
  198. package/vendor/streamdown/marked/marked-hr.js +18 -0
  199. package/vendor/streamdown/marked/marked-list.d.ts +31 -0
  200. package/vendor/streamdown/marked/marked-list.js +330 -0
  201. package/vendor/streamdown/marked/marked-math.d.ts +13 -0
  202. package/vendor/streamdown/marked/marked-math.js +129 -0
  203. package/vendor/streamdown/marked/marked-mdx.d.ts +12 -0
  204. package/vendor/streamdown/marked/marked-mdx.js +124 -0
  205. package/vendor/streamdown/marked/marked-subsup.d.ts +22 -0
  206. package/vendor/streamdown/marked/marked-subsup.js +40 -0
  207. package/vendor/streamdown/marked/marked-table.d.ts +80 -0
  208. package/vendor/streamdown/marked/marked-table.js +527 -0
  209. package/vendor/streamdown/plugin-context.d.ts +19 -0
  210. package/vendor/streamdown/plugin-context.js +40 -0
  211. package/vendor/streamdown/plugins/cjk-shared.d.ts +1 -0
  212. package/vendor/streamdown/plugins/cjk-shared.js +1 -0
  213. package/vendor/streamdown/plugins.d.ts +19 -0
  214. package/vendor/streamdown/plugins.js +107 -0
  215. package/vendor/streamdown/provenance.json +229 -0
  216. package/vendor/streamdown/remend.d.ts +2 -0
  217. package/vendor/streamdown/remend.js +1 -0
  218. package/vendor/streamdown/security/html.d.ts +19 -0
  219. package/vendor/streamdown/security/html.js +329 -0
  220. package/vendor/streamdown/security/preprocess-custom-tags.d.ts +1 -0
  221. package/vendor/streamdown/security/preprocess-custom-tags.js +20 -0
  222. package/vendor/streamdown/security/preprocess-literal-tag-content.d.ts +1 -0
  223. package/vendor/streamdown/security/preprocess-literal-tag-content.js +16 -0
  224. package/vendor/streamdown/security/types.d.ts +1 -0
  225. package/vendor/streamdown/security/types.js +1 -0
  226. package/vendor/streamdown/site/SiteHeader.svelte +94 -0
  227. package/vendor/streamdown/site/SiteHeader.svelte.d.ts +6 -0
  228. package/vendor/streamdown/site/home/HomeDemo.svelte +122 -0
  229. package/vendor/streamdown/site/home/HomeDemo.svelte.d.ts +3 -0
  230. package/vendor/streamdown/site/home/HomePage.svelte +293 -0
  231. package/vendor/streamdown/site/home/HomePage.svelte.d.ts +3 -0
  232. package/vendor/streamdown/site/home/content.d.ts +69 -0
  233. package/vendor/streamdown/site/home/content.js +144 -0
  234. package/vendor/streamdown/site/metadata.d.ts +4 -0
  235. package/vendor/streamdown/site/metadata.js +4 -0
  236. package/vendor/streamdown/site/navigation.d.ts +6 -0
  237. package/vendor/streamdown/site/navigation.js +22 -0
  238. package/vendor/streamdown/streamdown/config.d.ts +41 -0
  239. package/vendor/streamdown/streamdown/config.js +125 -0
  240. package/vendor/streamdown/streamdown/context.d.ts +12 -0
  241. package/vendor/streamdown/streamdown/context.js +2 -0
  242. package/vendor/streamdown/streamdown/incomplete-markdown.d.ts +5 -0
  243. package/vendor/streamdown/streamdown/incomplete-markdown.js +79 -0
  244. package/vendor/streamdown/streamdown/pipeline.d.ts +95 -0
  245. package/vendor/streamdown/streamdown/pipeline.js +138 -0
  246. package/vendor/streamdown/streamdown/runtime.d.ts +59 -0
  247. package/vendor/streamdown/streamdown/runtime.js +112 -0
  248. package/vendor/streamdown/streaming.d.ts +5 -0
  249. package/vendor/streamdown/streaming.js +5 -0
  250. package/vendor/streamdown/theme.d.ts +486 -0
  251. package/vendor/streamdown/theme.js +370 -0
  252. package/vendor/streamdown/translations.d.ts +43 -0
  253. package/vendor/streamdown/translations.js +54 -0
  254. package/vendor/streamdown/url-policy.d.ts +1 -0
  255. package/vendor/streamdown/url-policy.js +1 -0
  256. package/vendor/streamdown/utils/bind.d.ts +8 -0
  257. package/vendor/streamdown/utils/bind.js +26 -0
  258. package/vendor/streamdown/utils/bundledLanguages.d.ts +1 -0
  259. package/vendor/streamdown/utils/bundledLanguages.js +1 -0
  260. package/vendor/streamdown/utils/code-block.d.ts +8 -0
  261. package/vendor/streamdown/utils/code-block.js +38 -0
  262. package/vendor/streamdown/utils/copy.svelte.d.ts +7 -0
  263. package/vendor/streamdown/utils/copy.svelte.js +38 -0
  264. package/vendor/streamdown/utils/darkMode.svelte.d.ts +3 -0
  265. package/vendor/streamdown/utils/darkMode.svelte.js +49 -0
  266. package/vendor/streamdown/utils/detectDirection.d.ts +1 -0
  267. package/vendor/streamdown/utils/detectDirection.js +19 -0
  268. package/vendor/streamdown/utils/get.d.ts +1 -0
  269. package/vendor/streamdown/utils/get.js +25 -0
  270. package/vendor/streamdown/utils/hightlighter.svelte.d.ts +30 -0
  271. package/vendor/streamdown/utils/hightlighter.svelte.js +524 -0
  272. package/vendor/streamdown/utils/index.d.ts +3 -0
  273. package/vendor/streamdown/utils/index.js +3 -0
  274. package/vendor/streamdown/utils/mermaid.d.ts +13 -0
  275. package/vendor/streamdown/utils/mermaid.js +49 -0
  276. package/vendor/streamdown/utils/panzoom.svelte.d.ts +35 -0
  277. package/vendor/streamdown/utils/panzoom.svelte.js +556 -0
  278. package/vendor/streamdown/utils/parse-incomplete-markdown.d.ts +2 -0
  279. package/vendor/streamdown/utils/parse-incomplete-markdown.js +2 -0
  280. package/vendor/streamdown/utils/runtime-env.d.ts +1 -0
  281. package/vendor/streamdown/utils/runtime-env.js +13 -0
  282. package/vendor/streamdown/utils/save.d.ts +1 -0
  283. package/vendor/streamdown/utils/save.js +14 -0
  284. package/vendor/streamdown/utils/scroll-lock.d.ts +2 -0
  285. package/vendor/streamdown/utils/scroll-lock.js +35 -0
  286. package/vendor/streamdown/utils/table.d.ts +8 -0
  287. package/vendor/streamdown/utils/table.js +176 -0
  288. package/vendor/streamdown/utils/url.d.ts +22 -0
  289. package/vendor/streamdown/utils/url.js +98 -0
  290. package/vendor/streamdown/utils/useClickOutside.svelte.d.ts +8 -0
  291. package/vendor/streamdown/utils/useClickOutside.svelte.js +41 -0
  292. package/vendor/streamdown/utils/useKeyDown.svelte.d.ts +5 -0
  293. package/vendor/streamdown/utils/useKeyDown.svelte.js +23 -0
  294. package/UPSTREAM_PARITY.md +0 -69
  295. package/dist/ai-theme.css +0 -28
  296. package/dist/components/code/code-variants.d.ts +0 -25
  297. package/dist/components/code/code-variants.js +0 -20
  298. package/dist/components/conversation/scroll.d.ts +0 -4
  299. package/dist/components/conversation/scroll.js +0 -85
  300. package/dist/components/message/content-polish-html.d.ts +0 -5
  301. package/dist/components/message/content-polish-html.js +0 -75
  302. package/dist/components/tool/content-polish-scroll-region.d.ts +0 -3
  303. package/dist/components/tool/content-polish-scroll-region.js +0 -22
@@ -0,0 +1,75 @@
1
+ import { getContext, onMount, setContext } from 'svelte';
2
+ import { STREAMDOWN_CONTEXT_KEY } from './context-key.js';
3
+ export { normalizeMermaidControls } from './contracts/streamdown.js';
4
+ import { defineRuntimeSectionBridge, StreamdownParseRuntime, StreamdownRenderRuntime, StreamdownSecurityRuntime, StreamdownUiConfigRuntime } from './streamdown/runtime.js';
5
+ export class StreamdownContext {
6
+ footnotes = {
7
+ refs: new Map(),
8
+ footnotes: new Map()
9
+ };
10
+ isMounted = false;
11
+ parse;
12
+ security;
13
+ render;
14
+ uiConfig;
15
+ get animationTextStyle() {
16
+ return getContext('POPOVER')
17
+ ? undefined
18
+ : this.animation.enabled
19
+ ? `--sd-animation:sd-${this.animation.type};
20
+ --sd-duration:${this.animation.duration}ms;
21
+ --sd-easing:${this.animation.timingFunction};
22
+ animation-name: var(--sd-animation);
23
+ animation-duration: var(--sd-duration);
24
+ animation-timing-function: var(--sd-easing);
25
+ animation-delay: var(--sd-delay, 0ms);
26
+ animation-iteration-count: 1;
27
+ animation-fill-mode: forwards;
28
+ white-space: pre-wrap;
29
+ display: inline-block;
30
+ text-decoration: inherit;`
31
+ : undefined;
32
+ }
33
+ get animationBlockStyle() {
34
+ return getContext('POPOVER')
35
+ ? undefined
36
+ : this.animation.enabled
37
+ ? `--sd-animation:sd-${this.animation.type};
38
+ --sd-duration:${this.animation.duration}ms;
39
+ --sd-easing:${this.animation.timingFunction};
40
+ animation-name: var(--sd-animation);
41
+ animation-duration: var(--sd-duration);
42
+ animation-timing-function: var(--sd-easing);
43
+ animation-delay: var(--sd-delay, 0ms);
44
+ animation-iteration-count: 1;
45
+ animation-fill-mode: forwards;`
46
+ : undefined;
47
+ }
48
+ constructor(props) {
49
+ this.parse = new StreamdownParseRuntime(props.parse);
50
+ this.security = new StreamdownSecurityRuntime(props.security);
51
+ this.render = new StreamdownRenderRuntime(props.render);
52
+ this.uiConfig = new StreamdownUiConfigRuntime(props.uiConfig);
53
+ defineRuntimeSectionBridge(this, 'parse', () => this.parse);
54
+ defineRuntimeSectionBridge(this, 'security', () => this.security);
55
+ defineRuntimeSectionBridge(this, 'render', () => this.render);
56
+ defineRuntimeSectionBridge(this, 'uiConfig', () => this.uiConfig);
57
+ setContext(STREAMDOWN_CONTEXT_KEY, this);
58
+ if (this.animation.animateOnMount) {
59
+ this.isMounted = true;
60
+ }
61
+ onMount(() => {
62
+ this.isMounted = true;
63
+ });
64
+ $effect(() => {
65
+ this.isMounted = this.animation.enabled;
66
+ });
67
+ }
68
+ }
69
+ export const useStreamdown = () => {
70
+ const context = getContext(STREAMDOWN_CONTEXT_KEY);
71
+ if (!context) {
72
+ throw new Error('Streamdown context not found');
73
+ }
74
+ return context;
75
+ };
@@ -0,0 +1,26 @@
1
+ import type { Component } from 'svelte';
2
+ import type { LanguageInfo } from '../utils/bundledLanguages.js';
3
+ import type { CjkPlugin } from '../plugins/cjk-shared.js';
4
+ import type { CodeHighlighterPlugin, DiagramPlugin, HighlightOptions, HighlightResult, HighlightToken, LanguageDefinition, MathPlugin, MathPluginOptions, MermaidInstance, MermaidPluginOptions, ThemeInput } from '@streamdown-svelte/plugin-core';
5
+ export type { CodeHighlighterPlugin, DiagramPlugin, HighlightOptions, HighlightResult, HighlightToken, LanguageDefinition, MathPlugin, MathPluginOptions, MermaidInstance, MermaidPluginOptions, ThemeInput };
6
+ export type CustomRendererProps = {
7
+ code: string;
8
+ isIncomplete: boolean;
9
+ language: string;
10
+ meta?: string;
11
+ };
12
+ export interface CustomRenderer {
13
+ component: Component<CustomRendererProps>;
14
+ language: string | string[];
15
+ }
16
+ export interface PluginConfig {
17
+ cjk?: CjkPlugin;
18
+ code?: CodeHighlighterPlugin;
19
+ math?: MathPlugin;
20
+ mermaid?: DiagramPlugin;
21
+ renderers?: CustomRenderer[];
22
+ }
23
+ export interface CodePluginOptions {
24
+ themes?: [ThemeInput, ThemeInput];
25
+ languages?: LanguageInfo[];
26
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,374 @@
1
+ import type { Component, Snippet } from 'svelte';
2
+ import type { MermaidConfig } from 'mermaid';
3
+ import type { KatexOptions } from 'katex';
4
+ import type { ThemeRegistration } from 'shiki';
5
+ import type { Tokens } from 'marked';
6
+ import type { DeepPartialTheme, Theme } from '../theme.js';
7
+ import type { LanguageInfo } from '../utils/bundledLanguages.js';
8
+ import type { StreamdownTranslations } from '../translations.js';
9
+ import type { AllowedTags } from '../security/types.js';
10
+ import { carets } from '../streaming.js';
11
+ import type { PluginConfig, ThemeInput } from '../plugins.js';
12
+ import type { AllowElement, UrlTransform } from '../markdown.js';
13
+ import type { RemendOptions } from '@streamdown-svelte/remend';
14
+ import type { AlertToken, CitationToken, Extension, GenericToken, MathToken, MdxToken, SubSupToken, TableToken, TBody, TD, TFoot, TH, THead, THeadRow, TRow } from '../marked/index.js';
15
+ import type { ListItemToken, ListToken } from '../marked/marked-list.js';
16
+ import type { Footnote, FootnoteRef, FootnoteToken } from '../marked/marked-footnotes.js';
17
+ import type { DescriptionDetailToken, DescriptionListToken, DescriptionTermToken, DescriptionToken } from '../marked/marked-dl.js';
18
+ export interface AnimateOptions {
19
+ animation?: 'fadeIn' | 'blurIn' | 'slideUp' | (string & {});
20
+ duration?: number;
21
+ easing?: string;
22
+ sep?: 'word' | 'char';
23
+ stagger?: number;
24
+ }
25
+ export interface LinkSafetyModalProps {
26
+ url: string;
27
+ isOpen: boolean;
28
+ onClose: () => void;
29
+ onConfirm: () => void;
30
+ }
31
+ export interface LinkSafetyConfig {
32
+ enabled?: boolean;
33
+ onLinkCheck?: (href: string) => boolean | Promise<boolean>;
34
+ renderModal?: (props: LinkSafetyModalProps) => unknown;
35
+ }
36
+ export type { AllowedTags } from '../security/types.js';
37
+ export type BlockProps = {
38
+ content: string;
39
+ shouldParseIncompleteMarkdown: boolean;
40
+ shouldNormalizeHtmlIndentation: boolean;
41
+ index: number;
42
+ isIncomplete: boolean;
43
+ dir?: 'ltr' | 'rtl';
44
+ children?: Snippet;
45
+ };
46
+ export interface ResolvedAnimationConfig {
47
+ enabled: boolean;
48
+ animateOnMount?: boolean;
49
+ type?: string;
50
+ duration?: number;
51
+ timingFunction?: string;
52
+ tokenize?: 'word' | 'char';
53
+ stagger?: number;
54
+ }
55
+ export type TableControlsConfig = boolean | {
56
+ copy?: boolean;
57
+ download?: boolean;
58
+ fullscreen?: boolean;
59
+ };
60
+ export type CodeControlsConfig = boolean | {
61
+ copy?: boolean;
62
+ download?: boolean;
63
+ };
64
+ export type MermaidControls = boolean | {
65
+ download?: boolean;
66
+ fullscreen?: boolean;
67
+ panZoom?: boolean;
68
+ mouseWheelZoom?: boolean;
69
+ };
70
+ export type StreamdownControlsConfig = boolean | {
71
+ code?: CodeControlsConfig;
72
+ mermaid?: MermaidControls;
73
+ table?: TableControlsConfig;
74
+ };
75
+ export type ControlsConfig = StreamdownControlsConfig;
76
+ export type NormalizedMermaidControls = {
77
+ enabled: boolean;
78
+ download: boolean;
79
+ fullscreen: boolean;
80
+ panZoom: boolean;
81
+ mouseWheelZoom: boolean;
82
+ };
83
+ export type MermaidErrorComponentProps = {
84
+ chart: string;
85
+ error: string;
86
+ id: string;
87
+ retry: () => void;
88
+ };
89
+ export interface MermaidOptions {
90
+ config?: MermaidConfig;
91
+ errorComponent?: Component<MermaidErrorComponentProps, any, any>;
92
+ }
93
+ export interface IconMap {
94
+ CheckIcon?: Snippet<[]>;
95
+ CopyIcon?: Snippet<[]>;
96
+ DownloadIcon?: Snippet<[]>;
97
+ ExternalLinkIcon?: Snippet<[]>;
98
+ Loader2Icon?: Snippet<[]>;
99
+ Maximize2Icon?: Snippet<[]>;
100
+ RotateCcwIcon?: Snippet<[]>;
101
+ XIcon?: Snippet<[]>;
102
+ ZoomInIcon?: Snippet<[]>;
103
+ ZoomOutIcon?: Snippet<[]>;
104
+ check?: Snippet<[]>;
105
+ copy?: Snippet<[]>;
106
+ download?: Snippet<[]>;
107
+ fullscreen?: Snippet<[]>;
108
+ zoomIn?: Snippet<[]>;
109
+ zoomOut?: Snippet<[]>;
110
+ fitView?: Snippet<[]>;
111
+ note?: Snippet<[]>;
112
+ tip?: Snippet<[]>;
113
+ warning?: Snippet<[]>;
114
+ caution?: Snippet<[]>;
115
+ important?: Snippet<[]>;
116
+ chevronLeft?: Snippet<[]>;
117
+ chevronRight?: Snippet<[]>;
118
+ }
119
+ type TokenSnippet = {
120
+ heading: Tokens.Heading;
121
+ paragraph: Tokens.Paragraph;
122
+ blockquote: Tokens.Blockquote;
123
+ code: Tokens.Code;
124
+ codespan: Tokens.Codespan;
125
+ ul: ListToken;
126
+ ol: ListToken;
127
+ li: ListItemToken;
128
+ table: TableToken;
129
+ thead: THead;
130
+ tbody: TBody;
131
+ tfoot: TFoot;
132
+ tr: THeadRow | TRow;
133
+ td: TD;
134
+ th: TH;
135
+ image: Tokens.Image;
136
+ link: Tokens.Link;
137
+ strong: Tokens.Strong;
138
+ em: Tokens.Em;
139
+ del: Tokens.Del;
140
+ hr: Tokens.Hr;
141
+ br: Tokens.Br;
142
+ math: MathToken;
143
+ alert: AlertToken;
144
+ mermaid: Tokens.Code;
145
+ footnoteRef: FootnoteRef;
146
+ footnotePopover: FootnoteToken;
147
+ sup: SubSupToken;
148
+ sub: SubSupToken;
149
+ descriptionList: DescriptionListToken;
150
+ description: DescriptionToken;
151
+ descriptionTerm: DescriptionTermToken;
152
+ descriptionDetail: DescriptionDetailToken;
153
+ inlineCitation: CitationToken;
154
+ inlineCitationPopover: CitationToken;
155
+ inlineCitationContent: CitationToken;
156
+ inlineCitationPreview: CitationToken;
157
+ mdx: MdxToken;
158
+ };
159
+ type PredefinedElements = keyof TokenSnippet;
160
+ export type Snippets<Source extends Record<string, any> = Record<string, any>> = {
161
+ [K in PredefinedElements]?: Snippet<[
162
+ {
163
+ children: Snippet;
164
+ token: TokenSnippet[K];
165
+ } & (K extends 'inlineCitationContent' ? {
166
+ source: Source;
167
+ key: string;
168
+ } : K extends 'mdx' ? {
169
+ props: Record<string, number | string | boolean | null | undefined>;
170
+ } : {})
171
+ ]>;
172
+ };
173
+ export type CompatSnippetKeys<Source extends Record<string, any> = Record<string, any>> = keyof Omit<Snippets<Source>, 'mermaid'>;
174
+ type ComponentOverrideProps<Token> = {
175
+ children?: Snippet;
176
+ token: Token;
177
+ class?: string;
178
+ style?: string;
179
+ };
180
+ type HeadingComponentProps = ComponentOverrideProps<Tokens.Heading>;
181
+ type ParagraphComponentProps = ComponentOverrideProps<Tokens.Paragraph>;
182
+ type LinkComponentProps = ComponentOverrideProps<Tokens.Link> & {
183
+ href?: string;
184
+ target?: string;
185
+ rel?: string;
186
+ title?: string | null;
187
+ };
188
+ type ImageComponentProps = ComponentOverrideProps<Tokens.Image> & {
189
+ src?: string | null;
190
+ alt?: string;
191
+ onload?: () => void;
192
+ onerror?: () => void;
193
+ };
194
+ type BlockquoteComponentProps = ComponentOverrideProps<Tokens.Blockquote>;
195
+ type ListComponentProps = ComponentOverrideProps<ListToken>;
196
+ type ListItemComponentProps = ComponentOverrideProps<ListItemToken>;
197
+ type TableComponentProps = ComponentOverrideProps<TableToken>;
198
+ type TableHeadComponentProps = ComponentOverrideProps<THead>;
199
+ type TableBodyComponentProps = ComponentOverrideProps<TBody>;
200
+ type TableFootComponentProps = ComponentOverrideProps<TFoot>;
201
+ type TableRowComponentProps = ComponentOverrideProps<THeadRow | TRow>;
202
+ type TableCellComponentProps = ComponentOverrideProps<TD>;
203
+ type TableHeaderCellComponentProps = ComponentOverrideProps<TH>;
204
+ type InlineCodeComponentProps = ComponentOverrideProps<Tokens.Codespan>;
205
+ type StrongComponentProps = ComponentOverrideProps<Tokens.Strong>;
206
+ type EmphasisComponentProps = ComponentOverrideProps<Tokens.Em>;
207
+ type DeleteComponentProps = ComponentOverrideProps<Tokens.Del>;
208
+ type HrComponentProps = ComponentOverrideProps<Tokens.Hr>;
209
+ type BrComponentProps = ComponentOverrideProps<Tokens.Br>;
210
+ type SubSupComponentProps = ComponentOverrideProps<SubSupToken>;
211
+ export type Components = {
212
+ h1?: Component<HeadingComponentProps, any, any>;
213
+ h2?: Component<HeadingComponentProps, any, any>;
214
+ h3?: Component<HeadingComponentProps, any, any>;
215
+ h4?: Component<HeadingComponentProps, any, any>;
216
+ h5?: Component<HeadingComponentProps, any, any>;
217
+ h6?: Component<HeadingComponentProps, any, any>;
218
+ p?: Component<ParagraphComponentProps, any, any>;
219
+ blockquote?: Component<BlockquoteComponentProps, any, any>;
220
+ a?: Component<LinkComponentProps, any, any>;
221
+ img?: Component<ImageComponentProps, any, any>;
222
+ ul?: Component<ListComponentProps, any, any>;
223
+ ol?: Component<ListComponentProps, any, any>;
224
+ li?: Component<ListItemComponentProps, any, any>;
225
+ table?: Component<TableComponentProps, any, any>;
226
+ thead?: Component<TableHeadComponentProps, any, any>;
227
+ tbody?: Component<TableBodyComponentProps, any, any>;
228
+ tfoot?: Component<TableFootComponentProps, any, any>;
229
+ tr?: Component<TableRowComponentProps, any, any>;
230
+ td?: Component<TableCellComponentProps, any, any>;
231
+ th?: Component<TableHeaderCellComponentProps, any, any>;
232
+ inlineCode?: Component<InlineCodeComponentProps, any, any>;
233
+ strong?: Component<StrongComponentProps, any, any>;
234
+ em?: Component<EmphasisComponentProps, any, any>;
235
+ del?: Component<DeleteComponentProps, any, any>;
236
+ hr?: Component<HrComponentProps, any, any>;
237
+ br?: Component<BrComponentProps, any, any>;
238
+ sub?: Component<SubSupComponentProps, any, any>;
239
+ sup?: Component<SubSupComponentProps, any, any>;
240
+ code?: Component<{
241
+ token: Tokens.Code;
242
+ id: string;
243
+ }, any, any>;
244
+ mermaid?: Component<{
245
+ token: Tokens.Code;
246
+ id: string;
247
+ }, any, any>;
248
+ mermaidError?: Component<MermaidErrorComponentProps, any, any>;
249
+ math?: Component<{
250
+ token: MathToken;
251
+ id: string;
252
+ }, any, any>;
253
+ };
254
+ export type StreamdownComponents = Components;
255
+ export type StreamdownProps<Source extends Record<string, any> = Record<string, any>> = {
256
+ streamdown?: StreamdownContext<Source>;
257
+ static?: boolean;
258
+ mode?: 'static' | 'streaming';
259
+ isAnimating?: boolean;
260
+ animated?: boolean | AnimateOptions;
261
+ caret?: keyof typeof carets;
262
+ onAnimationStart?: () => void;
263
+ onAnimationEnd?: () => void;
264
+ BlockComponent?: Component<BlockProps, any, any>;
265
+ parseMarkdownIntoBlocksFn?: (markdown: string) => string[];
266
+ dir?: 'auto' | 'ltr' | 'rtl';
267
+ sources?: {
268
+ [key: string]: Source;
269
+ };
270
+ inlineCitationsMode?: 'list' | 'carousel';
271
+ element?: HTMLElement;
272
+ content: string;
273
+ class?: string;
274
+ className?: string;
275
+ parseIncompleteMarkdown?: boolean;
276
+ remend?: RemendOptions;
277
+ defaultOrigin?: string;
278
+ allowedLinkPrefixes?: string[];
279
+ allowedImagePrefixes?: string[];
280
+ linkSafety?: LinkSafetyConfig;
281
+ allowedTags?: AllowedTags;
282
+ allowedElements?: readonly string[];
283
+ allowElement?: AllowElement;
284
+ disallowedElements?: readonly string[];
285
+ literalTagContent?: string[];
286
+ normalizeHtmlIndentation?: boolean;
287
+ skipHtml?: boolean;
288
+ unwrapDisallowed?: boolean;
289
+ urlTransform?: UrlTransform;
290
+ prefix?: string;
291
+ lineNumbers?: boolean;
292
+ theme?: DeepPartialTheme;
293
+ baseTheme?: 'tailwind' | 'shadcn';
294
+ mergeTheme?: boolean;
295
+ shikiTheme?: ThemeInput | [ThemeInput, ThemeInput];
296
+ shikiLanguages?: LanguageInfo[];
297
+ shikiThemes?: Record<string, ThemeRegistration>;
298
+ mermaid?: MermaidOptions;
299
+ mermaidConfig?: MermaidConfig;
300
+ katexConfig?: KatexOptions | ((inline: boolean) => KatexOptions);
301
+ plugins?: PluginConfig;
302
+ translations?: Partial<StreamdownTranslations>;
303
+ controls?: ControlsConfig;
304
+ renderHtml?: boolean | ((token: Tokens.HTML | Tokens.Tag) => string);
305
+ animation?: {
306
+ animateOnMount?: boolean;
307
+ enabled?: boolean;
308
+ type?: 'fade' | 'blur' | 'slideUp' | 'slideDown';
309
+ duration?: number;
310
+ timingFunction?: 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'linear';
311
+ tokenize?: 'word' | 'char';
312
+ stagger?: number;
313
+ };
314
+ icons?: Partial<IconMap>;
315
+ extensions?: Extension[];
316
+ children?: Snippet<[
317
+ {
318
+ streamdown: StreamdownContext<Source>;
319
+ token: GenericToken;
320
+ children: Snippet;
321
+ }
322
+ ]>;
323
+ mdxComponents?: Record<string, Component<{
324
+ token: MdxToken;
325
+ children: Snippet;
326
+ props: any;
327
+ }, any, any>>;
328
+ components?: Components;
329
+ } & Partial<Omit<Snippets<Source>, 'mermaid'>>;
330
+ export interface StreamdownContext<Source extends Record<string, any> = Record<string, any>> extends Omit<StreamdownProps<Source>, CompatSnippetKeys<Source> | 'animation' | 'class' | 'theme' | 'shikiTheme' | 'inlineCitationsMode' | 'translations'> {
331
+ snippets: Snippets<Source>;
332
+ shikiTheme: string;
333
+ theme: Theme;
334
+ translations: StreamdownTranslations;
335
+ lineNumbers: boolean;
336
+ isAnimating: boolean;
337
+ controls: {
338
+ code: boolean;
339
+ mermaid: NormalizedMermaidControls;
340
+ table: TableControlsConfig;
341
+ };
342
+ plugins?: PluginConfig;
343
+ codeControls: {
344
+ copy: boolean;
345
+ download: boolean;
346
+ };
347
+ inlineCitationsMode: 'list' | 'carousel';
348
+ mode: 'static' | 'streaming';
349
+ animation: ResolvedAnimationConfig;
350
+ footnotes: {
351
+ refs: Map<string, FootnoteRef>;
352
+ footnotes: Map<string, Footnote>;
353
+ };
354
+ }
355
+ export type StreamdownContextInit<Source extends Record<string, any> = Record<string, any>> = Omit<StreamdownProps<Source>, CompatSnippetKeys<Source> | 'animation' | 'class' | 'theme' | 'shikiTheme' | 'inlineCitationsMode' | 'translations'> & {
356
+ snippets: Snippets<Source>;
357
+ shikiTheme: string;
358
+ theme: Theme | DeepPartialTheme | undefined;
359
+ translations: StreamdownTranslations;
360
+ lineNumbers: boolean;
361
+ isAnimating: boolean;
362
+ controls: {
363
+ code: boolean;
364
+ mermaid: NormalizedMermaidControls;
365
+ table: TableControlsConfig;
366
+ };
367
+ codeControls: {
368
+ copy: boolean;
369
+ download: boolean;
370
+ };
371
+ inlineCitationsMode: 'list' | 'carousel';
372
+ animation: ResolvedAnimationConfig;
373
+ };
374
+ export declare const normalizeMermaidControls: (controls: MermaidControls | undefined) => NormalizedMermaidControls;
@@ -0,0 +1,29 @@
1
+ import { carets } from '../streaming.js';
2
+ export const normalizeMermaidControls = (controls) => {
3
+ if (controls === false) {
4
+ return {
5
+ enabled: false,
6
+ download: false,
7
+ fullscreen: false,
8
+ panZoom: false,
9
+ mouseWheelZoom: false
10
+ };
11
+ }
12
+ if (controls === true || controls === undefined) {
13
+ return {
14
+ enabled: true,
15
+ download: true,
16
+ fullscreen: true,
17
+ panZoom: true,
18
+ mouseWheelZoom: true
19
+ };
20
+ }
21
+ const panZoom = controls.panZoom !== false;
22
+ return {
23
+ enabled: true,
24
+ download: controls.download !== false,
25
+ fullscreen: controls.fullscreen !== false,
26
+ panZoom,
27
+ mouseWheelZoom: panZoom && controls.mouseWheelZoom !== false
28
+ };
29
+ };
@@ -0,0 +1 @@
1
+ export { detectTextDirection } from './utils/detectDirection.js';
@@ -0,0 +1 @@
1
+ export { detectTextDirection } from './utils/detectDirection.js';
@@ -0,0 +1,36 @@
1
+ import { type Snippet } from 'svelte';
2
+ import type { IconMap } from './context.svelte.js';
3
+ export type { IconMap } from './context.svelte.js';
4
+ export { checkIcon, chevronLeft, chevronRight, copyIcon, downloadIcon, fitViewIcon, fullscreenIcon, resolveIcon, type IconSnippet, type ResolvedIconName, zoomInIcon, zoomOutIcon } from './Elements/icons.js';
5
+ import { resolveIcon } from './Elements/icons.js';
6
+ type IconContextGetter = {
7
+ getValue: () => IconMap;
8
+ };
9
+ declare const defaultIcons: {
10
+ CheckIcon: import("./Elements/icons.js").IconSnippet;
11
+ CopyIcon: import("./Elements/icons.js").IconSnippet;
12
+ DownloadIcon: import("./Elements/icons.js").IconSnippet;
13
+ Maximize2Icon: import("./Elements/icons.js").IconSnippet;
14
+ RotateCcwIcon: import("./Elements/icons.js").IconSnippet;
15
+ ZoomInIcon: import("./Elements/icons.js").IconSnippet;
16
+ ZoomOutIcon: import("./Elements/icons.js").IconSnippet;
17
+ check: import("./Elements/icons.js").IconSnippet;
18
+ copy: import("./Elements/icons.js").IconSnippet;
19
+ download: import("./Elements/icons.js").IconSnippet;
20
+ fullscreen: import("./Elements/icons.js").IconSnippet;
21
+ zoomIn: import("./Elements/icons.js").IconSnippet;
22
+ zoomOut: import("./Elements/icons.js").IconSnippet;
23
+ fitView: import("./Elements/icons.js").IconSnippet;
24
+ chevronLeft: import("./Elements/icons.js").IconSnippet;
25
+ chevronRight: import("./Elements/icons.js").IconSnippet;
26
+ };
27
+ export { defaultIcons };
28
+ export type IconComponent = Snippet<[]>;
29
+ export declare const IconContext: {
30
+ key: symbol;
31
+ provide(getValue: () => Partial<IconMap> | undefined): IconContextGetter;
32
+ set(icons: Partial<IconMap> | undefined): IconContextGetter;
33
+ get(): IconMap;
34
+ };
35
+ export declare function useIcons(): IconMap;
36
+ export declare function resolveProvidedIcon(name: Parameters<typeof resolveIcon>[1], fallback: Snippet<[]>): import("./Elements/icons.js").IconSnippet;
@@ -0,0 +1,52 @@
1
+ import { getContext, setContext } from 'svelte';
2
+ export { checkIcon, chevronLeft, chevronRight, copyIcon, downloadIcon, fitViewIcon, fullscreenIcon, resolveIcon, zoomInIcon, zoomOutIcon } from './Elements/icons.js';
3
+ import { checkIcon, chevronLeft, chevronRight, copyIcon, downloadIcon, fitViewIcon, fullscreenIcon, resolveIcon, zoomInIcon, zoomOutIcon } from './Elements/icons.js';
4
+ const ICON_CONTEXT_KEY = Symbol('streamdown.icons');
5
+ const defaultIcons = {
6
+ CheckIcon: checkIcon,
7
+ CopyIcon: copyIcon,
8
+ DownloadIcon: downloadIcon,
9
+ Maximize2Icon: fullscreenIcon,
10
+ RotateCcwIcon: fitViewIcon,
11
+ ZoomInIcon: zoomInIcon,
12
+ ZoomOutIcon: zoomOutIcon,
13
+ check: checkIcon,
14
+ copy: copyIcon,
15
+ download: downloadIcon,
16
+ fullscreen: fullscreenIcon,
17
+ zoomIn: zoomInIcon,
18
+ zoomOut: zoomOutIcon,
19
+ fitView: fitViewIcon,
20
+ chevronLeft,
21
+ chevronRight
22
+ };
23
+ const mergeIcons = (icons) => ({
24
+ ...defaultIcons,
25
+ ...(icons ?? {})
26
+ });
27
+ const defaultIconGetter = {
28
+ getValue: () => defaultIcons
29
+ };
30
+ export { defaultIcons };
31
+ export const IconContext = {
32
+ key: ICON_CONTEXT_KEY,
33
+ provide(getValue) {
34
+ const value = {
35
+ getValue: () => mergeIcons(getValue())
36
+ };
37
+ setContext(ICON_CONTEXT_KEY, value);
38
+ return value;
39
+ },
40
+ set(icons) {
41
+ return this.provide(() => icons);
42
+ },
43
+ get() {
44
+ return (getContext(ICON_CONTEXT_KEY) ?? defaultIconGetter).getValue();
45
+ }
46
+ };
47
+ export function useIcons() {
48
+ return IconContext.get();
49
+ }
50
+ export function resolveProvidedIcon(name, fallback) {
51
+ return resolveIcon(useIcons(), name, fallback);
52
+ }
@@ -0,0 +1,6 @@
1
+ import { hasIncompleteCodeFence as detectIncompleteCodeFence } from './utils/code-block.js';
2
+ export declare const STREAMDOWN_BLOCK_CONTEXT = "STREAMDOWN_BLOCK";
3
+ export declare const hasIncompleteCodeFence: typeof detectIncompleteCodeFence;
4
+ export declare const hasTable: (markdown: string) => boolean;
5
+ export declare function useIsCodeFenceIncomplete(): boolean;
6
+ export declare function useStreamdownBlockRaw(): string | undefined;
@@ -0,0 +1,23 @@
1
+ import { getContext } from 'svelte';
2
+ import { hasIncompleteCodeFence as detectIncompleteCodeFence } from './utils/code-block.js';
3
+ export const STREAMDOWN_BLOCK_CONTEXT = 'STREAMDOWN_BLOCK';
4
+ const TABLE_DELIMITER_PATTERN = /^\|?[ \t]*:?-{1,}:?[ \t]*(\|[ \t]*:?-{1,}:?[ \t]*)*\|?$/;
5
+ export const hasIncompleteCodeFence = detectIncompleteCodeFence;
6
+ export const hasTable = (markdown) => {
7
+ for (const line of markdown.split('\n')) {
8
+ const trimmed = line.trim();
9
+ if (trimmed.length === 0 || !trimmed.includes('|')) {
10
+ continue;
11
+ }
12
+ if (TABLE_DELIMITER_PATTERN.test(trimmed)) {
13
+ return true;
14
+ }
15
+ }
16
+ return false;
17
+ };
18
+ export function useIsCodeFenceIncomplete() {
19
+ return Boolean(getContext(STREAMDOWN_BLOCK_CONTEXT)?.isIncompleteCodeFence);
20
+ }
21
+ export function useStreamdownBlockRaw() {
22
+ return getContext(STREAMDOWN_BLOCK_CONTEXT)?.rawBlock;
23
+ }
@@ -0,0 +1,22 @@
1
+ export { default as Streamdown } from './Streamdown.svelte';
2
+ export { STREAMDOWN_CONTEXT_KEY } from './context-key.js';
3
+ export type { AllowedTags, AnimateOptions, BlockProps, CodeControlsConfig, Components, ControlsConfig, IconMap, LinkSafetyConfig, LinkSafetyModalProps, MermaidControls, MermaidErrorComponentProps, MermaidOptions, NormalizedMermaidControls, ResolvedAnimationConfig, Snippets, StreamdownComponents, StreamdownContext as StreamdownContextType, StreamdownControlsConfig, StreamdownProps, TableControlsConfig } from './contracts/streamdown.js';
4
+ export { StreamdownContext, useStreamdown } from './context.svelte.js';
5
+ export { default as IconProvider } from './IconProvider.svelte';
6
+ export { default as PluginProvider } from './PluginProvider.svelte';
7
+ export { detectTextDirection } from './detect-direction.js';
8
+ export { hasIncompleteCodeFence, hasTable, useIsCodeFenceIncomplete } from './incomplete-code.js';
9
+ export { defaultIcons, IconContext, type IconComponent, useIcons } from './icon-context.js';
10
+ export { defaultUrlTransform, type AllowElement, type UrlTransform } from './markdown.js';
11
+ export { type Extension, type StreamdownToken, lex, parseBlocks } from './marked/index.js';
12
+ export { PluginContext, useCjkPlugin, useCodePlugin, useCustomRenderer, useMathPlugin, useMermaidPlugin, usePlugins } from './plugin-context.js';
13
+ export { cjk, code, createCjkPlugin, createCodePlugin, createMathPlugin, createMermaidPlugin, findCustomRenderer, getThemeName, math, mermaid, type CjkPlugin, type CodeHighlighterPlugin, type CustomRenderer, type CustomRendererProps, type DiagramPlugin, type HighlightOptions, type HighlightResult, type HighlightToken, type MathPlugin, type MermaidInstance, type PluginConfig, type ThemeInput } from './plugins.js';
14
+ export { normalizeHtmlIndentation } from './security/html.js';
15
+ export { cn, theme, shadcnTheme, mergeTheme, type Theme } from './theme.js';
16
+ export { parseIncompleteMarkdown, type Plugin, IncompleteMarkdownParser } from './remend.js';
17
+ export { bundledLanguagesInfo, createLanguageSet, type LanguageInfo } from './utils/bundledLanguages.js';
18
+ export { isPathRelativeUrl, parseUrl, transformUrl, type TransformUrlOptions, type UrlPolicyKind } from './url-policy.js';
19
+ export { save } from './utils/index.js';
20
+ export { defaultTranslations, mergeTranslations, type StreamdownTranslations } from './translations.js';
21
+ export { extractTableDataFromElement, tableDataToCSV, tableDataToMarkdown, tableDataToTSV, type TableData } from './utils/table.js';
22
+ export type { LinkMode, RemendHandler, RemendOptions } from '@streamdown-svelte/remend';