@svadmin/ai-elements 0.7.4 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -4
- package/THIRD_PARTY_NOTICES.md +67 -6
- package/dist/ai.css +1 -5
- package/dist/ai.theme.css +1 -0
- package/dist/class-properties.generated.d.ts +1 -0
- package/dist/class-properties.generated.js +2 -0
- package/dist/classnames.d.ts +8 -0
- package/dist/classnames.js +26 -0
- package/dist/components/Response.svelte +2 -2
- package/dist/components/Response.svelte.d.ts +1 -1
- package/dist/components/code/index.d.ts +9 -18
- package/dist/components/code/index.js +8 -11
- package/dist/components/code-block/highlight.js +1 -1
- package/dist/utilities.css +3172 -0
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +1 -1
- package/package.json +36 -11
- package/vendor/streamdown/AnimatedText.svelte +93 -0
- package/vendor/streamdown/AnimatedText.svelte.d.ts +6 -0
- package/vendor/streamdown/Block.svelte +96 -0
- package/vendor/streamdown/Block.svelte.d.ts +11 -0
- package/vendor/streamdown/Elements/Alert.svelte +69 -0
- package/vendor/streamdown/Elements/Alert.svelte.d.ts +10 -0
- package/vendor/streamdown/Elements/Citation.svelte +260 -0
- package/vendor/streamdown/Elements/Citation.svelte.d.ts +7 -0
- package/vendor/streamdown/Elements/Code.svelte +226 -0
- package/vendor/streamdown/Elements/Code.svelte.d.ts +9 -0
- package/vendor/streamdown/Elements/Element.svelte +574 -0
- package/vendor/streamdown/Elements/Element.svelte.d.ts +10 -0
- package/vendor/streamdown/Elements/FootnoteRef.svelte +30 -0
- package/vendor/streamdown/Elements/FootnoteRef.svelte.d.ts +7 -0
- package/vendor/streamdown/Elements/Footnotes.svelte +54 -0
- package/vendor/streamdown/Elements/Footnotes.svelte.d.ts +7 -0
- package/vendor/streamdown/Elements/Image.svelte +200 -0
- package/vendor/streamdown/Elements/Image.svelte.d.ts +10 -0
- package/vendor/streamdown/Elements/Link.svelte +220 -0
- package/vendor/streamdown/Elements/Link.svelte.d.ts +10 -0
- package/vendor/streamdown/Elements/LinkSafetyModal.svelte +121 -0
- package/vendor/streamdown/Elements/LinkSafetyModal.svelte.d.ts +4 -0
- package/vendor/streamdown/Elements/Math.svelte +100 -0
- package/vendor/streamdown/Elements/Math.svelte.d.ts +9 -0
- package/vendor/streamdown/Elements/Mermaid.svelte +455 -0
- package/vendor/streamdown/Elements/Mermaid.svelte.d.ts +9 -0
- package/vendor/streamdown/Elements/MermaidDownload.svelte +145 -0
- package/vendor/streamdown/Elements/MermaidDownload.svelte.d.ts +8 -0
- package/vendor/streamdown/Elements/Slot.svelte +23 -0
- package/vendor/streamdown/Elements/Slot.svelte.d.ts +10 -0
- package/vendor/streamdown/Elements/Table.svelte +195 -0
- package/vendor/streamdown/Elements/Table.svelte.d.ts +9 -0
- package/vendor/streamdown/Elements/TableDownload.svelte +221 -0
- package/vendor/streamdown/Elements/TableDownload.svelte.d.ts +8 -0
- package/vendor/streamdown/Elements/fallbacks/CodeFallback.svelte +41 -0
- package/vendor/streamdown/Elements/fallbacks/CodeFallback.svelte.d.ts +9 -0
- package/vendor/streamdown/Elements/fallbacks/MathFallback.svelte +35 -0
- package/vendor/streamdown/Elements/fallbacks/MathFallback.svelte.d.ts +8 -0
- package/vendor/streamdown/Elements/fallbacks/MermaidFallback.svelte +36 -0
- package/vendor/streamdown/Elements/fallbacks/MermaidFallback.svelte.d.ts +9 -0
- package/vendor/streamdown/Elements/fallbacks/index.d.ts +3 -0
- package/vendor/streamdown/Elements/fallbacks/index.js +3 -0
- package/vendor/streamdown/Elements/icons.d.ts +31 -0
- package/vendor/streamdown/Elements/icons.js +200 -0
- package/vendor/streamdown/Elements/index.d.ts +8 -0
- package/vendor/streamdown/Elements/index.js +8 -0
- package/vendor/streamdown/Elements/popover.svelte.d.ts +8 -0
- package/vendor/streamdown/Elements/popover.svelte.js +45 -0
- package/vendor/streamdown/Elements/stepperState.svelte.d.ts +36 -0
- package/vendor/streamdown/Elements/stepperState.svelte.js +92 -0
- package/vendor/streamdown/IconProvider.svelte +11 -0
- package/vendor/streamdown/IconProvider.svelte.d.ts +30 -0
- package/vendor/streamdown/LICENSE +202 -0
- package/vendor/streamdown/PluginProvider.svelte +11 -0
- package/vendor/streamdown/PluginProvider.svelte.d.ts +30 -0
- package/vendor/streamdown/README.svadmin.md +5 -0
- package/vendor/streamdown/Streamdown.svelte +447 -0
- package/vendor/streamdown/Streamdown.svelte.d.ts +25 -0
- package/vendor/streamdown/block/BlockTokens.svelte +45 -0
- package/vendor/streamdown/block/BlockTokens.svelte.d.ts +9 -0
- package/vendor/streamdown/block/html.d.ts +14 -0
- package/vendor/streamdown/block/html.js +27 -0
- package/vendor/streamdown/block/text.d.ts +10 -0
- package/vendor/streamdown/block/text.js +31 -0
- package/vendor/streamdown/context-key.d.ts +1 -0
- package/vendor/streamdown/context-key.js +1 -0
- package/vendor/streamdown/context.svelte.d.ts +24 -0
- package/vendor/streamdown/context.svelte.js +75 -0
- package/vendor/streamdown/contracts/plugins.d.ts +26 -0
- package/vendor/streamdown/contracts/plugins.js +1 -0
- package/vendor/streamdown/contracts/streamdown.d.ts +374 -0
- package/vendor/streamdown/contracts/streamdown.js +29 -0
- package/vendor/streamdown/detect-direction.d.ts +1 -0
- package/vendor/streamdown/detect-direction.js +1 -0
- package/vendor/streamdown/icon-context.d.ts +36 -0
- package/vendor/streamdown/icon-context.js +52 -0
- package/vendor/streamdown/incomplete-code.d.ts +6 -0
- package/vendor/streamdown/incomplete-code.js +23 -0
- package/vendor/streamdown/index.d.ts +22 -0
- package/vendor/streamdown/index.js +20 -0
- package/vendor/streamdown/markdown-parse-cache.d.ts +37 -0
- package/vendor/streamdown/markdown-parse-cache.js +109 -0
- package/vendor/streamdown/markdown.d.ts +21 -0
- package/vendor/streamdown/markdown.js +214 -0
- package/vendor/streamdown/marked/index.d.ts +44 -0
- package/vendor/streamdown/marked/index.js +228 -0
- package/vendor/streamdown/marked/marked-alert.d.ts +13 -0
- package/vendor/streamdown/marked/marked-alert.js +47 -0
- package/vendor/streamdown/marked/marked-align.d.ts +10 -0
- package/vendor/streamdown/marked/marked-align.js +45 -0
- package/vendor/streamdown/marked/marked-br.d.ts +6 -0
- package/vendor/streamdown/marked/marked-br.js +15 -0
- package/vendor/streamdown/marked/marked-citations.d.ts +8 -0
- package/vendor/streamdown/marked/marked-citations.js +53 -0
- package/vendor/streamdown/marked/marked-cjk.d.ts +2 -0
- package/vendor/streamdown/marked/marked-cjk.js +165 -0
- package/vendor/streamdown/marked/marked-dl.d.ts +23 -0
- package/vendor/streamdown/marked/marked-dl.js +44 -0
- package/vendor/streamdown/marked/marked-footnotes.d.ts +26 -0
- package/vendor/streamdown/marked/marked-footnotes.js +101 -0
- package/vendor/streamdown/marked/marked-hr.d.ts +6 -0
- package/vendor/streamdown/marked/marked-hr.js +18 -0
- package/vendor/streamdown/marked/marked-list.d.ts +31 -0
- package/vendor/streamdown/marked/marked-list.js +330 -0
- package/vendor/streamdown/marked/marked-math.d.ts +13 -0
- package/vendor/streamdown/marked/marked-math.js +129 -0
- package/vendor/streamdown/marked/marked-mdx.d.ts +12 -0
- package/vendor/streamdown/marked/marked-mdx.js +124 -0
- package/vendor/streamdown/marked/marked-subsup.d.ts +22 -0
- package/vendor/streamdown/marked/marked-subsup.js +40 -0
- package/vendor/streamdown/marked/marked-table.d.ts +80 -0
- package/vendor/streamdown/marked/marked-table.js +527 -0
- package/vendor/streamdown/plugin-context.d.ts +19 -0
- package/vendor/streamdown/plugin-context.js +40 -0
- package/vendor/streamdown/plugins/cjk-shared.d.ts +1 -0
- package/vendor/streamdown/plugins/cjk-shared.js +1 -0
- package/vendor/streamdown/plugins.d.ts +19 -0
- package/vendor/streamdown/plugins.js +107 -0
- package/vendor/streamdown/provenance.json +229 -0
- package/vendor/streamdown/remend.d.ts +2 -0
- package/vendor/streamdown/remend.js +1 -0
- package/vendor/streamdown/security/html.d.ts +19 -0
- package/vendor/streamdown/security/html.js +329 -0
- package/vendor/streamdown/security/preprocess-custom-tags.d.ts +1 -0
- package/vendor/streamdown/security/preprocess-custom-tags.js +20 -0
- package/vendor/streamdown/security/preprocess-literal-tag-content.d.ts +1 -0
- package/vendor/streamdown/security/preprocess-literal-tag-content.js +16 -0
- package/vendor/streamdown/security/types.d.ts +1 -0
- package/vendor/streamdown/security/types.js +1 -0
- package/vendor/streamdown/site/SiteHeader.svelte +94 -0
- package/vendor/streamdown/site/SiteHeader.svelte.d.ts +6 -0
- package/vendor/streamdown/site/home/HomeDemo.svelte +122 -0
- package/vendor/streamdown/site/home/HomeDemo.svelte.d.ts +3 -0
- package/vendor/streamdown/site/home/HomePage.svelte +293 -0
- package/vendor/streamdown/site/home/HomePage.svelte.d.ts +3 -0
- package/vendor/streamdown/site/home/content.d.ts +69 -0
- package/vendor/streamdown/site/home/content.js +144 -0
- package/vendor/streamdown/site/metadata.d.ts +4 -0
- package/vendor/streamdown/site/metadata.js +4 -0
- package/vendor/streamdown/site/navigation.d.ts +6 -0
- package/vendor/streamdown/site/navigation.js +22 -0
- package/vendor/streamdown/streamdown/config.d.ts +41 -0
- package/vendor/streamdown/streamdown/config.js +125 -0
- package/vendor/streamdown/streamdown/context.d.ts +12 -0
- package/vendor/streamdown/streamdown/context.js +2 -0
- package/vendor/streamdown/streamdown/incomplete-markdown.d.ts +5 -0
- package/vendor/streamdown/streamdown/incomplete-markdown.js +79 -0
- package/vendor/streamdown/streamdown/pipeline.d.ts +95 -0
- package/vendor/streamdown/streamdown/pipeline.js +138 -0
- package/vendor/streamdown/streamdown/runtime.d.ts +59 -0
- package/vendor/streamdown/streamdown/runtime.js +112 -0
- package/vendor/streamdown/streaming.d.ts +5 -0
- package/vendor/streamdown/streaming.js +5 -0
- package/vendor/streamdown/theme.d.ts +486 -0
- package/vendor/streamdown/theme.js +370 -0
- package/vendor/streamdown/translations.d.ts +43 -0
- package/vendor/streamdown/translations.js +54 -0
- package/vendor/streamdown/url-policy.d.ts +1 -0
- package/vendor/streamdown/url-policy.js +1 -0
- package/vendor/streamdown/utils/bind.d.ts +8 -0
- package/vendor/streamdown/utils/bind.js +26 -0
- package/vendor/streamdown/utils/bundledLanguages.d.ts +1 -0
- package/vendor/streamdown/utils/bundledLanguages.js +1 -0
- package/vendor/streamdown/utils/code-block.d.ts +8 -0
- package/vendor/streamdown/utils/code-block.js +38 -0
- package/vendor/streamdown/utils/copy.svelte.d.ts +7 -0
- package/vendor/streamdown/utils/copy.svelte.js +38 -0
- package/vendor/streamdown/utils/darkMode.svelte.d.ts +3 -0
- package/vendor/streamdown/utils/darkMode.svelte.js +49 -0
- package/vendor/streamdown/utils/detectDirection.d.ts +1 -0
- package/vendor/streamdown/utils/detectDirection.js +19 -0
- package/vendor/streamdown/utils/get.d.ts +1 -0
- package/vendor/streamdown/utils/get.js +25 -0
- package/vendor/streamdown/utils/hightlighter.svelte.d.ts +30 -0
- package/vendor/streamdown/utils/hightlighter.svelte.js +524 -0
- package/vendor/streamdown/utils/index.d.ts +3 -0
- package/vendor/streamdown/utils/index.js +3 -0
- package/vendor/streamdown/utils/mermaid.d.ts +13 -0
- package/vendor/streamdown/utils/mermaid.js +49 -0
- package/vendor/streamdown/utils/panzoom.svelte.d.ts +35 -0
- package/vendor/streamdown/utils/panzoom.svelte.js +556 -0
- package/vendor/streamdown/utils/parse-incomplete-markdown.d.ts +2 -0
- package/vendor/streamdown/utils/parse-incomplete-markdown.js +2 -0
- package/vendor/streamdown/utils/runtime-env.d.ts +1 -0
- package/vendor/streamdown/utils/runtime-env.js +13 -0
- package/vendor/streamdown/utils/save.d.ts +1 -0
- package/vendor/streamdown/utils/save.js +14 -0
- package/vendor/streamdown/utils/scroll-lock.d.ts +2 -0
- package/vendor/streamdown/utils/scroll-lock.js +35 -0
- package/vendor/streamdown/utils/table.d.ts +8 -0
- package/vendor/streamdown/utils/table.js +176 -0
- package/vendor/streamdown/utils/url.d.ts +22 -0
- package/vendor/streamdown/utils/url.js +98 -0
- package/vendor/streamdown/utils/useClickOutside.svelte.d.ts +8 -0
- package/vendor/streamdown/utils/useClickOutside.svelte.js +41 -0
- package/vendor/streamdown/utils/useKeyDown.svelte.d.ts +5 -0
- package/vendor/streamdown/utils/useKeyDown.svelte.js +23 -0
|
@@ -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';
|