@octanejs/streamdown 0.1.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/LICENSE +13 -0
- package/README.md +39 -0
- package/UPSTREAM.md +15 -0
- package/dist/client/chunks/chunk-6IDAODM4.js +4809 -0
- package/dist/client/chunks/highlighted-body-PYQZ7NZ4.js +69 -0
- package/dist/client/chunks/mermaid-I6WR5JDC.js +7 -0
- package/dist/client/cjk.js +104 -0
- package/dist/client/code.js +115 -0
- package/dist/client/index.js +57 -0
- package/dist/client/math.js +30 -0
- package/dist/client/mermaid.js +46 -0
- package/dist/server/chunks/chunk-55X6YY2C.js +4526 -0
- package/dist/server/chunks/highlighted-body-NLELYOBH.js +60 -0
- package/dist/server/chunks/mermaid-SICAYVAP.js +7 -0
- package/dist/server/cjk.js +104 -0
- package/dist/server/code.js +115 -0
- package/dist/server/index.js +57 -0
- package/dist/server/math.js +30 -0
- package/dist/server/mermaid.js +46 -0
- package/dist/styles.css +35 -0
- package/dist/types/cjk.d.ts +32 -0
- package/dist/types/code.d.ts +58 -0
- package/dist/types/hooks/use-deferred-render.d.ts +60 -0
- package/dist/types/index.d.ts +161 -0
- package/dist/types/lib/animate.d.ts +33 -0
- package/dist/types/lib/block-incomplete-context.d.ts +15 -0
- package/dist/types/lib/code-block/body.d.ts +12 -0
- package/dist/types/lib/code-block/container.d.ts +10 -0
- package/dist/types/lib/code-block/context.d.ts +7 -0
- package/dist/types/lib/code-block/copy-button.d.ts +10 -0
- package/dist/types/lib/code-block/download-button.d.ts +10 -0
- package/dist/types/lib/code-block/header.d.ts +6 -0
- package/dist/types/lib/code-block/highlighted-body.d.ts +12 -0
- package/dist/types/lib/code-block/index.d.ts +14 -0
- package/dist/types/lib/code-block/skeleton.d.ts +2 -0
- package/dist/types/lib/components.d.ts +3 -0
- package/dist/types/lib/detect-direction.d.ts +14 -0
- package/dist/types/lib/icon-context.d.ts +25 -0
- package/dist/types/lib/icons.d.ts +17 -0
- package/dist/types/lib/image.d.ts +6 -0
- package/dist/types/lib/incomplete-code-utils.d.ts +25 -0
- package/dist/types/lib/link-modal.d.ts +9 -0
- package/dist/types/lib/markdown.d.ts +33 -0
- package/dist/types/lib/mermaid/download-button.d.ts +13 -0
- package/dist/types/lib/mermaid/fullscreen-button.d.ts +11 -0
- package/dist/types/lib/mermaid/index.d.ts +11 -0
- package/dist/types/lib/mermaid/pan-zoom.d.ts +14 -0
- package/dist/types/lib/mermaid/utils.d.ts +7 -0
- package/dist/types/lib/parse-blocks.d.ts +2 -0
- package/dist/types/lib/plugin-context.d.ts +30 -0
- package/dist/types/lib/plugin-types.d.ts +151 -0
- package/dist/types/lib/prefix-context.d.ts +13 -0
- package/dist/types/lib/preprocess-custom-tags.d.ts +20 -0
- package/dist/types/lib/preprocess-literal-tag-content.d.ts +25 -0
- package/dist/types/lib/rehype/literal-tag-content.d.ts +13 -0
- package/dist/types/lib/remark/code-meta.d.ts +10 -0
- package/dist/types/lib/remark/escape-html.d.ts +4 -0
- package/dist/types/lib/scroll-lock.d.ts +3 -0
- package/dist/types/lib/table/copy-dropdown.d.ts +10 -0
- package/dist/types/lib/table/download-dropdown.d.ts +18 -0
- package/dist/types/lib/table/fullscreen-button.d.ts +10 -0
- package/dist/types/lib/table/index.d.ts +10 -0
- package/dist/types/lib/table/utils.d.ts +11 -0
- package/dist/types/lib/translations-context.d.ts +35 -0
- package/dist/types/lib/types.d.ts +17 -0
- package/dist/types/lib/utils.d.ts +19 -0
- package/dist/types/math.d.ts +44 -0
- package/dist/types/mermaid-plugin.d.ts +44 -0
- package/package.json +121 -0
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
// Generated by scripts/generate-tsrx-types.mjs for the built package.
|
|
2
|
+
import type { MermaidConfig } from 'mermaid';
|
|
3
|
+
import type { ComponentBody } from 'octane';
|
|
4
|
+
import type { BundledLanguage, BundledTheme, ThemeRegistrationAny } from 'shiki';
|
|
5
|
+
import type { Pluggable } from 'unified';
|
|
6
|
+
export type ThemeInput = BundledTheme | ThemeRegistrationAny;
|
|
7
|
+
/**
|
|
8
|
+
* A single token in a highlighted line
|
|
9
|
+
*/
|
|
10
|
+
export interface HighlightToken {
|
|
11
|
+
bgColor?: string;
|
|
12
|
+
color?: string;
|
|
13
|
+
content: string;
|
|
14
|
+
htmlAttrs?: Record<string, string>;
|
|
15
|
+
htmlStyle?: Record<string, string>;
|
|
16
|
+
offset?: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Result from code highlighting (compatible with shiki's TokensResult)
|
|
20
|
+
*/
|
|
21
|
+
export interface HighlightResult {
|
|
22
|
+
bg?: string;
|
|
23
|
+
fg?: string;
|
|
24
|
+
rootStyle?: string | false;
|
|
25
|
+
tokens: HighlightToken[][];
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Options for highlighting code
|
|
29
|
+
*/
|
|
30
|
+
export interface HighlightOptions {
|
|
31
|
+
code: string;
|
|
32
|
+
language: BundledLanguage;
|
|
33
|
+
themes: [ThemeInput, ThemeInput];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Plugin for code syntax highlighting (Shiki)
|
|
37
|
+
*/
|
|
38
|
+
export interface CodeHighlighterPlugin {
|
|
39
|
+
/**
|
|
40
|
+
* Get list of supported languages
|
|
41
|
+
*/
|
|
42
|
+
getSupportedLanguages: () => BundledLanguage[];
|
|
43
|
+
/**
|
|
44
|
+
* Get the configured themes
|
|
45
|
+
*/
|
|
46
|
+
getThemes: () => [ThemeInput, ThemeInput];
|
|
47
|
+
/**
|
|
48
|
+
* Highlight code and return tokens
|
|
49
|
+
* Returns null if highlighting not ready yet (async loading)
|
|
50
|
+
* Use callback for async result
|
|
51
|
+
*/
|
|
52
|
+
highlight: (options: HighlightOptions, callback?: (result: HighlightResult) => void) => HighlightResult | null;
|
|
53
|
+
name: 'shiki';
|
|
54
|
+
/**
|
|
55
|
+
* Check if language is supported
|
|
56
|
+
*/
|
|
57
|
+
supportsLanguage: (language: BundledLanguage) => boolean;
|
|
58
|
+
type: 'code-highlighter';
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Mermaid instance interface
|
|
62
|
+
*/
|
|
63
|
+
export interface MermaidInstance {
|
|
64
|
+
initialize: (config: MermaidConfig) => void;
|
|
65
|
+
render: (id: string, source: string) => Promise<{
|
|
66
|
+
svg: string;
|
|
67
|
+
}>;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Plugin for diagram rendering (Mermaid)
|
|
71
|
+
*/
|
|
72
|
+
export interface DiagramPlugin {
|
|
73
|
+
/**
|
|
74
|
+
* Get the mermaid instance (initialized with optional config)
|
|
75
|
+
*/
|
|
76
|
+
getMermaid: (config?: MermaidConfig) => MermaidInstance;
|
|
77
|
+
/**
|
|
78
|
+
* Language identifier for code blocks
|
|
79
|
+
*/
|
|
80
|
+
language: string;
|
|
81
|
+
name: 'mermaid';
|
|
82
|
+
type: 'diagram';
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Plugin for math rendering (KaTeX)
|
|
86
|
+
*/
|
|
87
|
+
export interface MathPlugin {
|
|
88
|
+
/**
|
|
89
|
+
* Get CSS styles for math rendering (injected into head)
|
|
90
|
+
*/
|
|
91
|
+
getStyles?: () => string;
|
|
92
|
+
name: 'katex';
|
|
93
|
+
/**
|
|
94
|
+
* Get rehype plugin for rendering math
|
|
95
|
+
*/
|
|
96
|
+
rehypePlugin: Pluggable;
|
|
97
|
+
/**
|
|
98
|
+
* Get remark plugin for parsing math syntax
|
|
99
|
+
*/
|
|
100
|
+
remarkPlugin: Pluggable;
|
|
101
|
+
type: 'math';
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Plugin for CJK text handling
|
|
105
|
+
*/
|
|
106
|
+
export interface CjkPlugin {
|
|
107
|
+
name: 'cjk';
|
|
108
|
+
/**
|
|
109
|
+
* @deprecated Use remarkPluginsBefore and remarkPluginsAfter instead
|
|
110
|
+
* All remark plugins (for backwards compatibility)
|
|
111
|
+
*/
|
|
112
|
+
remarkPlugins: Pluggable[];
|
|
113
|
+
/**
|
|
114
|
+
* Remark plugins that must run AFTER remarkGfm
|
|
115
|
+
* (e.g., autolink boundary splitting, strikethrough enhancements)
|
|
116
|
+
*/
|
|
117
|
+
remarkPluginsAfter: Pluggable[];
|
|
118
|
+
/**
|
|
119
|
+
* Remark plugins that must run BEFORE remarkGfm
|
|
120
|
+
* (e.g., remark-cjk-friendly which modifies emphasis handling)
|
|
121
|
+
*/
|
|
122
|
+
remarkPluginsBefore: Pluggable[];
|
|
123
|
+
type: 'cjk';
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Union type for all plugins
|
|
127
|
+
*/
|
|
128
|
+
export type StreamdownPlugin = CodeHighlighterPlugin | DiagramPlugin | MathPlugin | CjkPlugin;
|
|
129
|
+
export interface CustomRendererProps {
|
|
130
|
+
code: string;
|
|
131
|
+
isIncomplete: boolean;
|
|
132
|
+
language: string;
|
|
133
|
+
/** Raw metastring from the code fence (everything after the language identifier).
|
|
134
|
+
* e.g. ```rust {1} title="foo" → meta = '{1} title="foo"'
|
|
135
|
+
* Undefined when no metastring is present. */
|
|
136
|
+
meta?: string;
|
|
137
|
+
}
|
|
138
|
+
export interface CustomRenderer {
|
|
139
|
+
component: ComponentBody<CustomRendererProps>;
|
|
140
|
+
language: string | string[];
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Plugin configuration passed to Streamdown
|
|
144
|
+
*/
|
|
145
|
+
export interface PluginConfig {
|
|
146
|
+
cjk?: CjkPlugin;
|
|
147
|
+
code?: CodeHighlighterPlugin;
|
|
148
|
+
math?: MathPlugin;
|
|
149
|
+
mermaid?: DiagramPlugin;
|
|
150
|
+
renderers?: CustomRenderer[];
|
|
151
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Generated by scripts/generate-tsrx-types.mjs for the built package.
|
|
2
|
+
import { type CnFunction } from './utils';
|
|
3
|
+
/**
|
|
4
|
+
* Context for providing a prefix-aware `cn` function to all components.
|
|
5
|
+
* Defaults to the standard `cn` (no prefix) for zero-overhead when unused.
|
|
6
|
+
*/
|
|
7
|
+
export declare const PrefixContext: import("octane").Context<CnFunction>;
|
|
8
|
+
/**
|
|
9
|
+
* Hook to access the prefix-aware `cn` function.
|
|
10
|
+
* When a prefix is set via `<Streamdown prefix="...">`, this returns
|
|
11
|
+
* a `cn` that prepends the prefix to all class names.
|
|
12
|
+
*/
|
|
13
|
+
export declare const useCn: () => CnFunction;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Generated by scripts/generate-tsrx-types.mjs for the built package.
|
|
2
|
+
/**
|
|
3
|
+
* Preprocesses markdown to prevent custom tag blocks from being broken apart
|
|
4
|
+
* by the CommonMark parser. Two issues are addressed:
|
|
5
|
+
*
|
|
6
|
+
* 1. **Inline content after opening tag**: In CommonMark, HTML block types 6/7
|
|
7
|
+
* require the opening tag to start a line on its own (or be followed only by
|
|
8
|
+
* whitespace). When content appears on the same line as the opening tag
|
|
9
|
+
* (e.g. `<custom>content`), the parser treats it as inline HTML inside a
|
|
10
|
+
* paragraph instead of an HTML block, causing the tag to lose its structure.
|
|
11
|
+
* This function ensures the opening tag, content, and closing tag each
|
|
12
|
+
* occupy their own lines.
|
|
13
|
+
*
|
|
14
|
+
* 2. **Blank lines inside tag content**: HTML blocks end at blank lines, which
|
|
15
|
+
* causes custom tags with blank lines in their content to be split across
|
|
16
|
+
* multiple tokens. This function replaces blank lines within matched custom
|
|
17
|
+
* tag pairs with HTML comments (`<!---->`), so the markdown parser treats
|
|
18
|
+
* the entire tag block as a single unit.
|
|
19
|
+
*/
|
|
20
|
+
export declare const preprocessCustomTags: (markdown: string, tagNames: string[]) => string;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Generated by scripts/generate-tsrx-types.mjs for the built package.
|
|
2
|
+
/**
|
|
3
|
+
* Escapes markdown metacharacters inside the content of specified custom tags,
|
|
4
|
+
* so that markdown inside those tags is rendered as plain text rather than
|
|
5
|
+
* being interpreted as formatting.
|
|
6
|
+
*
|
|
7
|
+
* This must run BEFORE the markdown parser sees the string, because by the time
|
|
8
|
+
* rehype plugins execute the markdown has already been parsed and structural
|
|
9
|
+
* information (e.g. underscores around emphasis) is lost.
|
|
10
|
+
*
|
|
11
|
+
* Note: content that already contains backslash escapes (e.g. `\_`) will be
|
|
12
|
+
* double-escaped and render with a visible backslash. This is acceptable since
|
|
13
|
+
* the intended use case is raw data labels (usernames, handles) that should
|
|
14
|
+
* not contain markdown escape sequences.
|
|
15
|
+
*
|
|
16
|
+
* Example:
|
|
17
|
+
* Input: `<mention user_id="123">_some_username_</mention>`
|
|
18
|
+
* Output: `<mention user_id="123">\_some\_username\_</mention>`
|
|
19
|
+
* Rendered: literal `_some_username_`
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* For each tag in `tagNames`, escapes markdown metacharacters inside the tag's
|
|
23
|
+
* content so that the parser treats the children as plain text.
|
|
24
|
+
*/
|
|
25
|
+
export declare const preprocessLiteralTagContent: (markdown: string, tagNames: string[]) => string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Generated by scripts/generate-tsrx-types.mjs for the built package.
|
|
2
|
+
import type { Root } from 'hast';
|
|
3
|
+
import type { Plugin } from 'unified';
|
|
4
|
+
/**
|
|
5
|
+
* rehype plugin — replaces children of elements whose tag names are in
|
|
6
|
+
* `tagNames` with a single plain-text node. Run this after rehype-raw and
|
|
7
|
+
* rehype-sanitize so the custom elements already exist as proper HAST nodes.
|
|
8
|
+
*
|
|
9
|
+
* Works in tandem with `preprocessLiteralTagContent`, which escapes markdown
|
|
10
|
+
* syntax before remark parses it, ensuring the text value here reflects the
|
|
11
|
+
* original literal content (not stripped markdown markers).
|
|
12
|
+
*/
|
|
13
|
+
export declare const rehypeLiteralTagContent: Plugin<[string[]], Root>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Generated by scripts/generate-tsrx-types.mjs for the built package.
|
|
2
|
+
import type { Root } from 'mdast';
|
|
3
|
+
import type { Plugin } from 'unified';
|
|
4
|
+
/**
|
|
5
|
+
* Remark plugin that forwards code fence meta strings to hast properties.
|
|
6
|
+
* This makes the meta string available as a `metastring` prop to the custom
|
|
7
|
+
* code component, enabling features like custom starting line numbers
|
|
8
|
+
* (e.g. `startLine=10`).
|
|
9
|
+
*/
|
|
10
|
+
export declare const remarkCodeMeta: Plugin<[], Root>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Generated by scripts/generate-tsrx-types.mjs for the built package.
|
|
2
|
+
import type { OctaneNode } from 'octane';
|
|
3
|
+
export interface TableCopyDropdownProps {
|
|
4
|
+
children?: OctaneNode;
|
|
5
|
+
className?: string;
|
|
6
|
+
onCopy?: (format: 'csv' | 'tsv' | 'md') => void;
|
|
7
|
+
onError?: (error: Error) => void;
|
|
8
|
+
timeout?: number;
|
|
9
|
+
}
|
|
10
|
+
export declare const TableCopyDropdown: ({ children, className, onCopy, onError, timeout, }: TableCopyDropdownProps) => import("octane/jsx-runtime").Octane.JSX.Element;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Generated by scripts/generate-tsrx-types.mjs for the built package.
|
|
2
|
+
import type { OctaneNode } from 'octane';
|
|
3
|
+
export interface TableDownloadButtonProps {
|
|
4
|
+
children?: OctaneNode;
|
|
5
|
+
className?: string;
|
|
6
|
+
filename?: string;
|
|
7
|
+
format?: 'csv' | 'markdown';
|
|
8
|
+
onDownload?: () => void;
|
|
9
|
+
onError?: (error: Error) => void;
|
|
10
|
+
}
|
|
11
|
+
export declare const TableDownloadButton: ({ children, className, onDownload, onError, format, filename, }: TableDownloadButtonProps) => import("octane/jsx-runtime").Octane.JSX.Element;
|
|
12
|
+
export interface TableDownloadDropdownProps {
|
|
13
|
+
children?: OctaneNode;
|
|
14
|
+
className?: string;
|
|
15
|
+
onDownload?: (format: 'csv' | 'markdown') => void;
|
|
16
|
+
onError?: (error: Error) => void;
|
|
17
|
+
}
|
|
18
|
+
export declare const TableDownloadDropdown: ({ children, className, onDownload, onError, }: TableDownloadDropdownProps) => import("octane/jsx-runtime").Octane.JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Generated by scripts/generate-tsrx-types.mjs for the built package.
|
|
2
|
+
import type { OctaneNode } from 'octane';
|
|
3
|
+
interface TableFullscreenButtonProps {
|
|
4
|
+
children: OctaneNode;
|
|
5
|
+
className?: string;
|
|
6
|
+
showCopy?: boolean;
|
|
7
|
+
showDownload?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare const TableFullscreenButton: ({ children, className, showCopy, showDownload, }: TableFullscreenButtonProps) => import("octane/jsx-runtime").Octane.JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Generated by scripts/generate-tsrx-types.mjs for the built package.
|
|
2
|
+
import type { ComponentProps } from '../types';
|
|
3
|
+
type TableProps = ComponentProps<'table'> & {
|
|
4
|
+
showControls?: boolean;
|
|
5
|
+
showCopy?: boolean;
|
|
6
|
+
showDownload?: boolean;
|
|
7
|
+
showFullscreen?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare const Table: ({ children, className, showControls, showCopy, showDownload, showFullscreen, ...props }: TableProps) => import("octane/jsx-runtime").Octane.JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Generated by scripts/generate-tsrx-types.mjs for the built package.
|
|
2
|
+
export interface TableData {
|
|
3
|
+
headers: string[];
|
|
4
|
+
rows: string[][];
|
|
5
|
+
}
|
|
6
|
+
export declare const findTableForControl: (control: Element | null) => HTMLTableElement | null;
|
|
7
|
+
export declare const extractTableDataFromElement: (tableElement: HTMLElement) => TableData;
|
|
8
|
+
export declare const tableDataToCSV: (data: TableData) => string;
|
|
9
|
+
export declare const tableDataToTSV: (data: TableData) => string;
|
|
10
|
+
export declare const escapeMarkdownTableCell: (cell: string) => string;
|
|
11
|
+
export declare const tableDataToMarkdown: (data: TableData) => string;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// Generated by scripts/generate-tsrx-types.mjs for the built package.
|
|
2
|
+
export interface StreamdownTranslations {
|
|
3
|
+
close: string;
|
|
4
|
+
copied: string;
|
|
5
|
+
copyCode: string;
|
|
6
|
+
copyLink: string;
|
|
7
|
+
copyTable: string;
|
|
8
|
+
copyTableAsCsv: string;
|
|
9
|
+
copyTableAsMarkdown: string;
|
|
10
|
+
copyTableAsTsv: string;
|
|
11
|
+
downloadDiagram: string;
|
|
12
|
+
downloadDiagramAsMmd: string;
|
|
13
|
+
downloadDiagramAsPng: string;
|
|
14
|
+
downloadDiagramAsSvg: string;
|
|
15
|
+
downloadFile: string;
|
|
16
|
+
downloadImage: string;
|
|
17
|
+
downloadTable: string;
|
|
18
|
+
downloadTableAsCsv: string;
|
|
19
|
+
downloadTableAsMarkdown: string;
|
|
20
|
+
exitFullscreen: string;
|
|
21
|
+
externalLinkWarning: string;
|
|
22
|
+
imageNotAvailable: string;
|
|
23
|
+
mermaidFormatMmd: string;
|
|
24
|
+
mermaidFormatPng: string;
|
|
25
|
+
mermaidFormatSvg: string;
|
|
26
|
+
openExternalLink: string;
|
|
27
|
+
openLink: string;
|
|
28
|
+
tableFormatCsv: string;
|
|
29
|
+
tableFormatMarkdown: string;
|
|
30
|
+
tableFormatTsv: string;
|
|
31
|
+
viewFullscreen: string;
|
|
32
|
+
}
|
|
33
|
+
export declare const defaultTranslations: StreamdownTranslations;
|
|
34
|
+
export declare const TranslationsContext: import("octane").Context<StreamdownTranslations>;
|
|
35
|
+
export declare const useTranslations: () => StreamdownTranslations;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Generated by scripts/generate-tsrx-types.mjs for the built package.
|
|
2
|
+
import type { Octane } from 'octane/jsx-runtime';
|
|
3
|
+
export type ComponentProps<Tag extends keyof Octane.JSX.IntrinsicElements> = Octane.JSX.IntrinsicElements[Tag];
|
|
4
|
+
export type CSSProperties = Exclude<Octane.JSX.IntrinsicElements['div']['style'], string | undefined>;
|
|
5
|
+
export type DetailedHTMLProps<E, T> = Octane.DetailedHTMLProps<E, T>;
|
|
6
|
+
export type HTMLAttributes<T> = Octane.HTMLAttributes<T>;
|
|
7
|
+
export type ImgHTMLAttributes<T> = Octane.ImgHTMLAttributes<T>;
|
|
8
|
+
export type SVGProps<T> = Octane.SVGProps<T>;
|
|
9
|
+
export type NativeMouseEvent<T extends Element> = globalThis.MouseEvent & {
|
|
10
|
+
currentTarget: T;
|
|
11
|
+
};
|
|
12
|
+
export type NativePointerEvent<T extends Element> = globalThis.PointerEvent & {
|
|
13
|
+
currentTarget: T;
|
|
14
|
+
};
|
|
15
|
+
export type NativeEventHandler<T extends Element> = (event: Event & {
|
|
16
|
+
currentTarget: T;
|
|
17
|
+
}) => void;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Generated by scripts/generate-tsrx-types.mjs for the built package.
|
|
2
|
+
import { type ClassValue } from 'clsx';
|
|
3
|
+
export declare const cn: (...inputs: ClassValue[]) => string;
|
|
4
|
+
export type CnFunction = (...inputs: ClassValue[]) => string;
|
|
5
|
+
/**
|
|
6
|
+
* Prepends a prefix to each Tailwind utility class in a class string.
|
|
7
|
+
* Used to support Tailwind v4's `prefix()` feature.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* prefixClasses("tw", "flex items-center") // "tw:flex tw:items-center"
|
|
11
|
+
* prefixClasses("tw", "dark:bg-red-500") // "tw:dark:bg-red-500"
|
|
12
|
+
*/
|
|
13
|
+
export declare const prefixClasses: (prefix: string, classString: string) => string;
|
|
14
|
+
/**
|
|
15
|
+
* Creates a prefix-aware `cn` function. When no prefix is provided,
|
|
16
|
+
* returns the standard `cn` with zero overhead.
|
|
17
|
+
*/
|
|
18
|
+
export declare const createCn: (prefix?: string) => CnFunction;
|
|
19
|
+
export declare const save: (filename: string, content: string | Blob, mimeType: string) => void;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Generated by scripts/generate-tsrx-types.mjs for the built package.
|
|
2
|
+
import type { Pluggable } from 'unified';
|
|
3
|
+
/**
|
|
4
|
+
* Plugin for math rendering (KaTeX)
|
|
5
|
+
*/
|
|
6
|
+
export interface MathPlugin {
|
|
7
|
+
/**
|
|
8
|
+
* Get CSS styles path for math rendering
|
|
9
|
+
*/
|
|
10
|
+
getStyles?: () => string;
|
|
11
|
+
name: 'katex';
|
|
12
|
+
/**
|
|
13
|
+
* Rehype plugin for rendering math
|
|
14
|
+
*/
|
|
15
|
+
rehypePlugin: Pluggable;
|
|
16
|
+
/**
|
|
17
|
+
* Remark plugin for parsing math syntax
|
|
18
|
+
*/
|
|
19
|
+
remarkPlugin: Pluggable;
|
|
20
|
+
type: 'math';
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Options for creating a math plugin
|
|
24
|
+
*/
|
|
25
|
+
export interface MathPluginOptions {
|
|
26
|
+
/**
|
|
27
|
+
* KaTeX error color
|
|
28
|
+
* @default "var(--color-muted-foreground)"
|
|
29
|
+
*/
|
|
30
|
+
errorColor?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Enable single dollar sign for inline math ($...$)
|
|
33
|
+
* @default false
|
|
34
|
+
*/
|
|
35
|
+
singleDollarTextMath?: boolean;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Create a math plugin with optional configuration
|
|
39
|
+
*/
|
|
40
|
+
export declare function createMathPlugin(options?: MathPluginOptions): MathPlugin;
|
|
41
|
+
/**
|
|
42
|
+
* Pre-configured math plugin with default settings
|
|
43
|
+
*/
|
|
44
|
+
export declare const math: MathPlugin;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Generated by scripts/generate-tsrx-types.mjs for the built package.
|
|
2
|
+
import type { MermaidConfig } from 'mermaid';
|
|
3
|
+
/**
|
|
4
|
+
* Mermaid instance interface
|
|
5
|
+
*/
|
|
6
|
+
export interface MermaidInstance {
|
|
7
|
+
initialize: (config: MermaidConfig) => void;
|
|
8
|
+
render: (id: string, source: string) => Promise<{
|
|
9
|
+
svg: string;
|
|
10
|
+
}>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Plugin for diagram rendering (Mermaid)
|
|
14
|
+
*/
|
|
15
|
+
export interface DiagramPlugin {
|
|
16
|
+
/**
|
|
17
|
+
* Get the mermaid instance (initialized with optional config)
|
|
18
|
+
*/
|
|
19
|
+
getMermaid: (config?: MermaidConfig) => MermaidInstance;
|
|
20
|
+
/**
|
|
21
|
+
* Language identifier for code blocks
|
|
22
|
+
*/
|
|
23
|
+
language: string;
|
|
24
|
+
name: 'mermaid';
|
|
25
|
+
type: 'diagram';
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Options for creating a Mermaid plugin
|
|
29
|
+
*/
|
|
30
|
+
export interface MermaidPluginOptions {
|
|
31
|
+
/**
|
|
32
|
+
* Default Mermaid configuration
|
|
33
|
+
*/
|
|
34
|
+
config?: MermaidConfig;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Create a Mermaid plugin with optional configuration
|
|
38
|
+
*/
|
|
39
|
+
export declare function createMermaidPlugin(options?: MermaidPluginOptions): DiagramPlugin;
|
|
40
|
+
/**
|
|
41
|
+
* Pre-configured Mermaid plugin with default settings
|
|
42
|
+
*/
|
|
43
|
+
export declare const mermaid: DiagramPlugin;
|
|
44
|
+
export type { MermaidConfig } from 'mermaid';
|
package/package.json
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@octanejs/streamdown",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"sideEffects": [
|
|
7
|
+
"./dist/styles.css"
|
|
8
|
+
],
|
|
9
|
+
"engines": {
|
|
10
|
+
"node": ">=22"
|
|
11
|
+
},
|
|
12
|
+
"description": "Complete Streamdown 2.5 bindings for Octane, including code, math, Mermaid, and CJK plugin entry points.",
|
|
13
|
+
"author": {
|
|
14
|
+
"name": "Dominic Gannaway",
|
|
15
|
+
"email": "dg@domgan.com"
|
|
16
|
+
},
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"access": "public"
|
|
19
|
+
},
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/octanejs/octane.git",
|
|
23
|
+
"directory": "packages/streamdown"
|
|
24
|
+
},
|
|
25
|
+
"main": "dist/server/index.js",
|
|
26
|
+
"module": "dist/client/index.js",
|
|
27
|
+
"types": "dist/types/index.d.ts",
|
|
28
|
+
"files": [
|
|
29
|
+
"dist",
|
|
30
|
+
"LICENSE",
|
|
31
|
+
"README.md",
|
|
32
|
+
"UPSTREAM.md"
|
|
33
|
+
],
|
|
34
|
+
"exports": {
|
|
35
|
+
".": {
|
|
36
|
+
"types": "./dist/types/index.d.ts",
|
|
37
|
+
"browser": "./dist/client/index.js",
|
|
38
|
+
"node": "./dist/server/index.js",
|
|
39
|
+
"default": "./dist/client/index.js"
|
|
40
|
+
},
|
|
41
|
+
"./code": {
|
|
42
|
+
"types": "./dist/types/code.d.ts",
|
|
43
|
+
"browser": "./dist/client/code.js",
|
|
44
|
+
"node": "./dist/server/code.js",
|
|
45
|
+
"default": "./dist/client/code.js"
|
|
46
|
+
},
|
|
47
|
+
"./math": {
|
|
48
|
+
"types": "./dist/types/math.d.ts",
|
|
49
|
+
"browser": "./dist/client/math.js",
|
|
50
|
+
"node": "./dist/server/math.js",
|
|
51
|
+
"default": "./dist/client/math.js"
|
|
52
|
+
},
|
|
53
|
+
"./mermaid": {
|
|
54
|
+
"types": "./dist/types/mermaid-plugin.d.ts",
|
|
55
|
+
"browser": "./dist/client/mermaid.js",
|
|
56
|
+
"node": "./dist/server/mermaid.js",
|
|
57
|
+
"default": "./dist/client/mermaid.js"
|
|
58
|
+
},
|
|
59
|
+
"./cjk": {
|
|
60
|
+
"types": "./dist/types/cjk.d.ts",
|
|
61
|
+
"browser": "./dist/client/cjk.js",
|
|
62
|
+
"node": "./dist/server/cjk.js",
|
|
63
|
+
"default": "./dist/client/cjk.js"
|
|
64
|
+
},
|
|
65
|
+
"./styles.css": "./dist/styles.css"
|
|
66
|
+
},
|
|
67
|
+
"dependencies": {
|
|
68
|
+
"@types/hast": "^3.0.4",
|
|
69
|
+
"@types/mdast": "^4.0.4",
|
|
70
|
+
"@types/unist": "^3.0.3",
|
|
71
|
+
"clsx": "^2.1.1",
|
|
72
|
+
"hast-util-to-jsx-runtime": "^2.3.6",
|
|
73
|
+
"html-url-attributes": "^3.0.1",
|
|
74
|
+
"katex": "^0.16.27",
|
|
75
|
+
"marked": "^17.0.1",
|
|
76
|
+
"mermaid": "^11.12.2",
|
|
77
|
+
"rehype-harden": "^1.1.8",
|
|
78
|
+
"rehype-katex": "^7.0.1",
|
|
79
|
+
"rehype-raw": "^7.0.0",
|
|
80
|
+
"rehype-sanitize": "^6.0.0",
|
|
81
|
+
"remark-cjk-friendly": "^2.0.1",
|
|
82
|
+
"remark-cjk-friendly-gfm-strikethrough": "^2.0.1",
|
|
83
|
+
"remark-gfm": "^4.0.1",
|
|
84
|
+
"remark-math": "^6.0.0",
|
|
85
|
+
"remark-parse": "^11.0.0",
|
|
86
|
+
"remark-rehype": "^11.1.2",
|
|
87
|
+
"remend": "^1.3.0",
|
|
88
|
+
"shiki": "^3.23.0",
|
|
89
|
+
"tailwind-merge": "3.6.0",
|
|
90
|
+
"unified": "^11.0.5",
|
|
91
|
+
"unist-util-visit": "^5.0.0",
|
|
92
|
+
"unist-util-visit-parents": "^6.0.0"
|
|
93
|
+
},
|
|
94
|
+
"peerDependencies": {
|
|
95
|
+
"octane": "0.1.21"
|
|
96
|
+
},
|
|
97
|
+
"devDependencies": {
|
|
98
|
+
"@testing-library/jest-dom": "^6.9.1",
|
|
99
|
+
"@tsrx/react": "^0.2.56",
|
|
100
|
+
"@types/react": "^19.2.17",
|
|
101
|
+
"@types/react-dom": "^19.2.3",
|
|
102
|
+
"esbuild": "^0.28.1",
|
|
103
|
+
"react": "^19.2.7",
|
|
104
|
+
"react-dom": "^19.2.7",
|
|
105
|
+
"streamdown": "2.5.0",
|
|
106
|
+
"@streamdown/code": "1.1.1",
|
|
107
|
+
"@streamdown/math": "1.0.2",
|
|
108
|
+
"@streamdown/mermaid": "1.0.2",
|
|
109
|
+
"@streamdown/cjk": "1.0.3",
|
|
110
|
+
"vitest": "^4.1.10",
|
|
111
|
+
"octane": "0.1.21",
|
|
112
|
+
"@octanejs/testing-library": "0.1.18"
|
|
113
|
+
},
|
|
114
|
+
"scripts": {
|
|
115
|
+
"build": "node scripts/build.mjs",
|
|
116
|
+
"test": "vitest run --root ../.. --project streamdown --project streamdown-ssr",
|
|
117
|
+
"typecheck": "tsrx-tsc --noEmit -p tsconfig.json && tsgo --noEmit -p typetests/tsconfig.json",
|
|
118
|
+
"types:check": "node scripts/generate-tsrx-types.mjs --check && node scripts/check-public-types.mjs",
|
|
119
|
+
"types:generate": "node scripts/generate-tsrx-types.mjs"
|
|
120
|
+
}
|
|
121
|
+
}
|