@copilotkit/markdown 2.0.0-rc.20 → 2.0.0-rc.22
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 +24 -7
- package/dist/dom/index.cjs +255 -0
- package/dist/dom/index.cjs.map +1 -0
- package/dist/dom/index.d.cts +93 -0
- package/dist/dom/index.d.cts.map +1 -0
- package/dist/dom/index.d.mts +93 -0
- package/dist/dom/index.d.mts.map +1 -0
- package/dist/dom/index.mjs +254 -0
- package/dist/dom/index.mjs.map +1 -0
- package/dist/index.cjs +522 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +271 -4
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +271 -4
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +512 -12
- package/dist/index.mjs.map +1 -1
- package/dist/react/index.cjs +66 -458
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +13 -22
- package/dist/react/index.d.cts.map +1 -1
- package/dist/react/index.d.mts +13 -22
- package/dist/react/index.d.mts.map +1 -1
- package/dist/react/index.mjs +67 -459
- package/dist/react/index.mjs.map +1 -1
- package/dist/react-native/index.cjs.map +1 -1
- package/dist/react-native/index.d.cts.map +1 -1
- package/dist/react-native/index.d.mts.map +1 -1
- package/dist/react-native/index.mjs.map +1 -1
- package/dist/vue/index.cjs +86 -199
- package/dist/vue/index.cjs.map +1 -1
- package/dist/vue/index.d.cts +46 -16
- package/dist/vue/index.d.cts.map +1 -1
- package/dist/vue/index.d.mts +46 -16
- package/dist/vue/index.d.mts.map +1 -1
- package/dist/vue/index.mjs +88 -201
- package/dist/vue/index.mjs.map +1 -1
- package/package.json +6 -2
package/dist/vue/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as vue from "vue";
|
|
2
2
|
import { PropType, VNode } from "vue";
|
|
3
|
-
import { StreamingMarkdownAstNode, StreamingMarkdownParserOptions } from "@copilotkit/markdown";
|
|
3
|
+
import { StreamingMarkdownAstNode, StreamingMarkdownCitationRenderData, StreamingMarkdownNodeClassNames, StreamingMarkdownParserOptions } from "@copilotkit/markdown";
|
|
4
4
|
|
|
5
5
|
//#region src/vue/streaming-markdown-renderer.d.ts
|
|
6
6
|
/**
|
|
@@ -14,17 +14,28 @@ type VueStreamingMarkdownNodeRenderer = (node: StreamingMarkdownAstNode, default
|
|
|
14
14
|
*
|
|
15
15
|
* @public
|
|
16
16
|
*/
|
|
17
|
-
type VueStreamingMarkdownNodeRendererKey = "paragraph" | "heading" | "blockquote" | "list" | "listItem" | "codeBlock" | "table" | "tableRow" | "tableCell" | "thematicBreak" | "em" | "strong" | "strikethrough" | "inlineCode" | "hardBreak" | "image" | "link" | "autolink" | "citation";
|
|
17
|
+
type VueStreamingMarkdownNodeRendererKey = "paragraph" | "heading" | "blockquote" | "list" | "listItem" | "codeBlock" | "table" | "tableRow" | "tableCell" | "thematicBreak" | "em" | "strong" | "strikethrough" | "inlineCode" | "hardBreak" | "image" | "link" | "autolink" | "citation" | "math";
|
|
18
18
|
/**
|
|
19
19
|
* Optional map of node-type renderer keys to custom Vue render functions.
|
|
20
20
|
* @public
|
|
21
21
|
*/
|
|
22
22
|
type VueStreamingMarkdownNodeRenderers = Partial<Record<VueStreamingMarkdownNodeRendererKey, VueStreamingMarkdownNodeRenderer>>;
|
|
23
|
+
/**
|
|
24
|
+
* Called when a link or autolink is clicked.
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
type VueStreamingMarkdownLinkClickHandler = (event: MouseEvent, url: string, node: StreamingMarkdownAstNode) => void;
|
|
28
|
+
/**
|
|
29
|
+
* Called when a citation reference is clicked.
|
|
30
|
+
* @public
|
|
31
|
+
*/
|
|
32
|
+
type VueStreamingMarkdownCitationClickHandler = (event: MouseEvent, citation: StreamingMarkdownCitationRenderData, node: StreamingMarkdownAstNode) => void;
|
|
23
33
|
/**
|
|
24
34
|
* Vue 3 streaming markdown renderer.
|
|
25
35
|
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
36
|
+
* Parses with `@copilotkit/markdown` and renders the shared render tree with
|
|
37
|
+
* `h()`, so markup, sanitization, caret placement, and the per-token fade-in
|
|
38
|
+
* match the React and DOM renderers.
|
|
28
39
|
*
|
|
29
40
|
* @public
|
|
30
41
|
*/
|
|
@@ -46,8 +57,7 @@ declare const StreamingMarkdownRenderer: vue.DefineComponent<vue.ExtractPropType
|
|
|
46
57
|
default: undefined;
|
|
47
58
|
};
|
|
48
59
|
/**
|
|
49
|
-
* When true, renders a
|
|
50
|
-
* Animation niceties are left to CSS; this just inserts the element.
|
|
60
|
+
* When true, renders a caret inside the deepest open node while streaming.
|
|
51
61
|
*/
|
|
52
62
|
caret: {
|
|
53
63
|
type: PropType<boolean>;
|
|
@@ -57,17 +67,26 @@ declare const StreamingMarkdownRenderer: vue.DefineComponent<vue.ExtractPropType
|
|
|
57
67
|
* Optional map of node-type keys to custom Vue render functions.
|
|
58
68
|
* Each function receives the AST node and the default VNode and can return
|
|
59
69
|
* a replacement VNode (or the defaultVNode to keep the default).
|
|
60
|
-
* Supported keys: paragraph, heading, blockquote, list, listItem, codeBlock,
|
|
61
|
-
* table, tableRow, tableCell, thematicBreak, em, strong, strikethrough,
|
|
62
|
-
* inlineCode, hardBreak, link, image, autolink, citation.
|
|
63
70
|
*/
|
|
64
71
|
nodeRenderers: {
|
|
65
72
|
type: PropType<VueStreamingMarkdownNodeRenderers>;
|
|
66
73
|
default: undefined;
|
|
74
|
+
}; /** Extra classes for the default element of a node type. */
|
|
75
|
+
nodeClassNames: {
|
|
76
|
+
type: PropType<StreamingMarkdownNodeClassNames>;
|
|
77
|
+
default: undefined;
|
|
78
|
+
}; /** Called when a link or autolink is clicked. */
|
|
79
|
+
onLinkClick: {
|
|
80
|
+
type: PropType<VueStreamingMarkdownLinkClickHandler>;
|
|
81
|
+
default: undefined;
|
|
82
|
+
}; /** Called when a citation reference with a URL is clicked. */
|
|
83
|
+
onCitationClick: {
|
|
84
|
+
type: PropType<VueStreamingMarkdownCitationClickHandler>;
|
|
85
|
+
default: undefined;
|
|
67
86
|
};
|
|
68
87
|
}>, () => VNode<vue.RendererNode, vue.RendererElement, {
|
|
69
88
|
[key: string]: any;
|
|
70
|
-
}
|
|
89
|
+
}>[], {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
71
90
|
/** The full markdown source string, which may grow over time during streaming. */content: {
|
|
72
91
|
type: PropType<string>;
|
|
73
92
|
required: true;
|
|
@@ -85,8 +104,7 @@ declare const StreamingMarkdownRenderer: vue.DefineComponent<vue.ExtractPropType
|
|
|
85
104
|
default: undefined;
|
|
86
105
|
};
|
|
87
106
|
/**
|
|
88
|
-
* When true, renders a
|
|
89
|
-
* Animation niceties are left to CSS; this just inserts the element.
|
|
107
|
+
* When true, renders a caret inside the deepest open node while streaming.
|
|
90
108
|
*/
|
|
91
109
|
caret: {
|
|
92
110
|
type: PropType<boolean>;
|
|
@@ -96,13 +114,22 @@ declare const StreamingMarkdownRenderer: vue.DefineComponent<vue.ExtractPropType
|
|
|
96
114
|
* Optional map of node-type keys to custom Vue render functions.
|
|
97
115
|
* Each function receives the AST node and the default VNode and can return
|
|
98
116
|
* a replacement VNode (or the defaultVNode to keep the default).
|
|
99
|
-
* Supported keys: paragraph, heading, blockquote, list, listItem, codeBlock,
|
|
100
|
-
* table, tableRow, tableCell, thematicBreak, em, strong, strikethrough,
|
|
101
|
-
* inlineCode, hardBreak, link, image, autolink, citation.
|
|
102
117
|
*/
|
|
103
118
|
nodeRenderers: {
|
|
104
119
|
type: PropType<VueStreamingMarkdownNodeRenderers>;
|
|
105
120
|
default: undefined;
|
|
121
|
+
}; /** Extra classes for the default element of a node type. */
|
|
122
|
+
nodeClassNames: {
|
|
123
|
+
type: PropType<StreamingMarkdownNodeClassNames>;
|
|
124
|
+
default: undefined;
|
|
125
|
+
}; /** Called when a link or autolink is clicked. */
|
|
126
|
+
onLinkClick: {
|
|
127
|
+
type: PropType<VueStreamingMarkdownLinkClickHandler>;
|
|
128
|
+
default: undefined;
|
|
129
|
+
}; /** Called when a citation reference with a URL is clicked. */
|
|
130
|
+
onCitationClick: {
|
|
131
|
+
type: PropType<VueStreamingMarkdownCitationClickHandler>;
|
|
132
|
+
default: undefined;
|
|
106
133
|
};
|
|
107
134
|
}>> & Readonly<{}>, {
|
|
108
135
|
isComplete: boolean;
|
|
@@ -110,7 +137,10 @@ declare const StreamingMarkdownRenderer: vue.DefineComponent<vue.ExtractPropType
|
|
|
110
137
|
class: string;
|
|
111
138
|
caret: boolean;
|
|
112
139
|
nodeRenderers: Partial<Record<VueStreamingMarkdownNodeRendererKey, VueStreamingMarkdownNodeRenderer>>;
|
|
140
|
+
nodeClassNames: StreamingMarkdownNodeClassNames;
|
|
141
|
+
onLinkClick: VueStreamingMarkdownLinkClickHandler;
|
|
142
|
+
onCitationClick: VueStreamingMarkdownCitationClickHandler;
|
|
113
143
|
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
114
144
|
//#endregion
|
|
115
|
-
export { StreamingMarkdownRenderer, type VueStreamingMarkdownNodeRenderer, type VueStreamingMarkdownNodeRendererKey, type VueStreamingMarkdownNodeRenderers };
|
|
145
|
+
export { StreamingMarkdownRenderer, type VueStreamingMarkdownCitationClickHandler, type VueStreamingMarkdownLinkClickHandler, type VueStreamingMarkdownNodeRenderer, type VueStreamingMarkdownNodeRendererKey, type VueStreamingMarkdownNodeRenderers };
|
|
116
146
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/vue/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/vue/streaming-markdown-renderer.ts"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/vue/streaming-markdown-renderer.ts"],"mappings":";;;;;;;;AA6BA;KAAY,gCAAA,IACV,IAAA,EAAM,wBAAA,EACN,YAAA,EAAc,KAAA,qBACX,KAAA;;;;;;;KAQO,mCAAA;;;;;KA0BA,iCAAA,GAAoC,OAAA,CAC9C,MAAA,CAAO,mCAAA,EAAqC,gCAAA;;AA3B9C;;;KAkCY,oCAAA,IACV,KAAA,EAAO,UAAA,EACP,GAAA,UACA,IAAA,EAAM,wBAAA;;AAXR;;;KAkBY,wCAAA,IACV,KAAA,EAAO,UAAA,EACP,QAAA,EAAU,mCAAA,EACV,IAAA,EAAM,wBAAA;;;;;;;;;;cA8HK,yBAAA,MAAyB,eAAA,CAqDN,GAAA,CArDM,gBAAA;EAlJwC;UAyJxD,QAAA;;KAjJb;;UAsJc,QAAA;;KApJS;;UAyJV,QAAA,CAAS,OAAA,CAAQ,8BAAA;;KAjJ9B;;UAsJa,QAAA;;;EAtJb;;;;UA6Jc,QAAA;;;EA3JS;AA8HhC;;;;;UAsCsB,QAAA,CAAS,iCAAA;;KAhBT;;UAqBA,QAAA,CAAS,+BAAA;;KAAT;;UAKE,QAAA,CAAS,oCAAA;;KAKD;;UAAR,QAAA,CAAS,wCAAA;;;gBArDK,GAAA,CAAA,YAAA;;8GAqDN,GAAA,CAAA,gBAAA;EAzCT;UALD,QAAA;;KAsBC;;UAjBA,QAAA;;KAoCU;;UA/BX,QAAA,CAAS,OAAA,CAAQ,8BAAA;;;;UAKjB,QAAA;;;;;;;UAOC,QAAA;;;EA7Be;;;;;;UAsChB,QAAA,CAAS,iCAAA;;;;UAKT,QAAA,CAAS,+BAAA;;KA1BT;;UA+BE,QAAA,CAAS,oCAAA;;;;UAKT,QAAA,CAAS,wCAAA"}
|
package/dist/vue/index.mjs
CHANGED
|
@@ -1,182 +1,78 @@
|
|
|
1
|
-
import { computed, defineComponent, h } from "vue";
|
|
2
|
-
import {
|
|
1
|
+
import { computed, defineComponent, h, isVNode } from "vue";
|
|
2
|
+
import { STREAMING_MARKDOWN_CARET_ATTRS, STREAMING_MARKDOWN_CARET_STYLE, STREAMING_MARKDOWN_ROOT_CLASS, buildStreamingMarkdownRenderTree, getStreamingMarkdownStyles, updateStreamingMarkdownParserSession } from "@copilotkit/markdown";
|
|
3
3
|
|
|
4
4
|
//#region src/vue/streaming-markdown-renderer.ts
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
const VUE_RENDERER_KEYS = new Set([
|
|
6
|
+
"paragraph",
|
|
7
|
+
"heading",
|
|
8
|
+
"blockquote",
|
|
9
|
+
"list",
|
|
10
|
+
"listItem",
|
|
11
|
+
"codeBlock",
|
|
12
|
+
"table",
|
|
13
|
+
"tableRow",
|
|
14
|
+
"tableCell",
|
|
15
|
+
"thematicBreak",
|
|
16
|
+
"em",
|
|
17
|
+
"strong",
|
|
18
|
+
"strikethrough",
|
|
19
|
+
"inlineCode",
|
|
20
|
+
"hardBreak",
|
|
21
|
+
"image",
|
|
22
|
+
"link",
|
|
23
|
+
"autolink",
|
|
24
|
+
"citation",
|
|
25
|
+
"math"
|
|
26
|
+
]);
|
|
27
|
+
function isVueRendererKey(key) {
|
|
28
|
+
return VUE_RENDERER_KEYS.has(key);
|
|
10
29
|
}
|
|
11
|
-
function
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const DEFAULT_OPTIONS = {
|
|
16
|
-
segmenter: true,
|
|
17
|
-
enableTables: true,
|
|
18
|
-
enableAutolinks: true
|
|
19
|
-
};
|
|
20
|
-
function normalizeOptions(options) {
|
|
21
|
-
return {
|
|
22
|
-
segmenter: options?.segmenter ?? DEFAULT_OPTIONS.segmenter,
|
|
23
|
-
enableTables: options?.enableTables ?? DEFAULT_OPTIONS.enableTables,
|
|
24
|
-
enableAutolinks: options?.enableAutolinks ?? DEFAULT_OPTIONS.enableAutolinks
|
|
30
|
+
function elementProps(element, context) {
|
|
31
|
+
const props = {
|
|
32
|
+
key: element.key,
|
|
33
|
+
...element.attrs
|
|
25
34
|
};
|
|
35
|
+
const action = element.action;
|
|
36
|
+
if (action?.type === "link") props.onClick = (event) => context.onLinkClick?.(event, action.url, action.node);
|
|
37
|
+
if (action?.type === "citation") props.onClick = (event) => context.onCitationClick?.(event, action.citation, action.node);
|
|
38
|
+
return props;
|
|
26
39
|
}
|
|
27
|
-
function
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
}, segment.noBreakBefore ? `${segment.text}` : segment.text));
|
|
40
|
-
}
|
|
41
|
-
function renderChildren(childIds, nodeById, nodeRenderers) {
|
|
42
|
-
return childIds.map((id) => {
|
|
43
|
-
const child = nodeById.get(id);
|
|
44
|
-
return child ? renderNode(child, nodeById, nodeRenderers) : null;
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
function renderNode(node, nodeById, nodeRenderers) {
|
|
48
|
-
function withOverride(key, defaultVNode) {
|
|
49
|
-
const override = nodeRenderers?.[key];
|
|
50
|
-
return override ? override(node, defaultVNode) : defaultVNode;
|
|
51
|
-
}
|
|
52
|
-
switch (node.type) {
|
|
53
|
-
case "document": return h("span", { style: "display:contents" }, renderChildren(node.children, nodeById, nodeRenderers));
|
|
54
|
-
case "paragraph": return withOverride("paragraph", h("p", {
|
|
55
|
-
"data-streaming-markdown-node": "paragraph",
|
|
56
|
-
"data-node-open": String(!node.closed)
|
|
57
|
-
}, renderChildren(node.children, nodeById, nodeRenderers)));
|
|
58
|
-
case "heading": return withOverride("heading", h(`h${node.level}`, {
|
|
59
|
-
"data-streaming-markdown-node": "heading",
|
|
60
|
-
"data-node-open": String(!node.closed)
|
|
61
|
-
}, renderChildren(node.children, nodeById, nodeRenderers)));
|
|
62
|
-
case "blockquote": return withOverride("blockquote", h("blockquote", {
|
|
63
|
-
"data-streaming-markdown-node": "blockquote",
|
|
64
|
-
"data-node-open": String(!node.closed)
|
|
65
|
-
}, renderChildren(node.children, nodeById, nodeRenderers)));
|
|
66
|
-
case "list": {
|
|
67
|
-
const tag = node.ordered ? "ol" : "ul";
|
|
68
|
-
const attrs = {
|
|
69
|
-
"data-streaming-markdown-node": "list",
|
|
70
|
-
"data-node-open": String(!node.closed),
|
|
71
|
-
"data-list-tight": String(node.tight)
|
|
72
|
-
};
|
|
73
|
-
if (node.ordered && node.start != null) attrs.start = node.start;
|
|
74
|
-
return withOverride("list", h(tag, attrs, renderChildren(node.children, nodeById, nodeRenderers)));
|
|
75
|
-
}
|
|
76
|
-
case "list-item": return withOverride("listItem", h("li", {
|
|
77
|
-
"data-streaming-markdown-node": "list-item",
|
|
78
|
-
"data-node-open": String(!node.closed)
|
|
79
|
-
}, renderChildren(node.children, nodeById, nodeRenderers)));
|
|
80
|
-
case "code-block": return withOverride("codeBlock", h("pre", {
|
|
81
|
-
"data-streaming-markdown-node": "code-block",
|
|
82
|
-
"data-node-open": String(!node.closed)
|
|
83
|
-
}, [h("code", { "data-code-info": node.info ?? void 0 }, node.text)]));
|
|
84
|
-
case "table": return withOverride("table", h("table", {
|
|
85
|
-
"data-streaming-markdown-node": "table",
|
|
86
|
-
"data-node-open": String(!node.closed)
|
|
87
|
-
}, [h("tbody", renderChildren(node.children, nodeById, nodeRenderers))]));
|
|
88
|
-
case "table-row": return withOverride("tableRow", h("tr", {
|
|
89
|
-
"data-streaming-markdown-node": "table-row",
|
|
90
|
-
"data-node-open": String(!node.closed)
|
|
91
|
-
}, renderChildren(node.children, nodeById, nodeRenderers)));
|
|
92
|
-
case "table-cell": {
|
|
93
|
-
const parent = node.parentId != null ? nodeById.get(node.parentId) : void 0;
|
|
94
|
-
return withOverride("tableCell", h(parent?.type === "table-row" && parent.isHeader ? "th" : "td", {
|
|
95
|
-
"data-streaming-markdown-node": "table-cell",
|
|
96
|
-
"data-node-open": String(!node.closed)
|
|
97
|
-
}, renderChildren(node.children, nodeById, nodeRenderers)));
|
|
98
|
-
}
|
|
99
|
-
case "thematic-break": return withOverride("thematicBreak", h("hr", {
|
|
100
|
-
"data-streaming-markdown-node": "thematic-break",
|
|
101
|
-
"data-node-open": String(!node.closed)
|
|
102
|
-
}));
|
|
103
|
-
case "text": return h("span", { style: "display:contents" }, renderTextSegments(node));
|
|
104
|
-
case "em": return withOverride("em", h("em", {
|
|
105
|
-
"data-streaming-markdown-node": "em",
|
|
106
|
-
"data-node-open": String(!node.closed)
|
|
107
|
-
}, renderChildren(node.children, nodeById, nodeRenderers)));
|
|
108
|
-
case "strong": return withOverride("strong", h("strong", {
|
|
109
|
-
"data-streaming-markdown-node": "strong",
|
|
110
|
-
"data-node-open": String(!node.closed)
|
|
111
|
-
}, renderChildren(node.children, nodeById, nodeRenderers)));
|
|
112
|
-
case "strikethrough": return withOverride("strikethrough", h("del", {
|
|
113
|
-
"data-streaming-markdown-node": "strikethrough",
|
|
114
|
-
"data-node-open": String(!node.closed)
|
|
115
|
-
}, renderChildren(node.children, nodeById, nodeRenderers)));
|
|
116
|
-
case "inline-code": return withOverride("inlineCode", h("code", {
|
|
117
|
-
"data-streaming-markdown-node": "inline-code",
|
|
118
|
-
"data-node-open": String(!node.closed)
|
|
119
|
-
}, node.text));
|
|
120
|
-
case "soft-break": return "\n";
|
|
121
|
-
case "hard-break": return withOverride("hardBreak", h("br", {
|
|
122
|
-
"data-streaming-markdown-node": "hard-break",
|
|
123
|
-
"data-node-open": String(!node.closed)
|
|
124
|
-
}));
|
|
125
|
-
case "link": {
|
|
126
|
-
const safeHref = sanitizeHref(node.url);
|
|
127
|
-
const attrs = {
|
|
128
|
-
"data-streaming-markdown-node": "link",
|
|
129
|
-
"data-node-open": String(!node.closed),
|
|
130
|
-
target: "_blank",
|
|
131
|
-
rel: "noopener noreferrer"
|
|
132
|
-
};
|
|
133
|
-
if (safeHref != null) attrs.href = safeHref;
|
|
134
|
-
if (node.title) attrs.title = node.title;
|
|
135
|
-
return withOverride("link", h("a", attrs, renderChildren(node.children, nodeById, nodeRenderers)));
|
|
136
|
-
}
|
|
137
|
-
case "image": {
|
|
138
|
-
const safeSrc = sanitizeImgSrc(node.url);
|
|
139
|
-
const attrs = {
|
|
140
|
-
"data-streaming-markdown-node": "image",
|
|
141
|
-
"data-node-open": String(!node.closed),
|
|
142
|
-
alt: node.alt
|
|
143
|
-
};
|
|
144
|
-
if (safeSrc != null) attrs.src = safeSrc;
|
|
145
|
-
if (node.title) attrs.title = node.title;
|
|
146
|
-
return withOverride("image", h("img", attrs));
|
|
147
|
-
}
|
|
148
|
-
case "autolink": {
|
|
149
|
-
const safeHref = sanitizeHref(node.url);
|
|
150
|
-
const attrs = {
|
|
151
|
-
"data-streaming-markdown-node": "autolink",
|
|
152
|
-
"data-node-open": String(!node.closed),
|
|
153
|
-
target: "_blank",
|
|
154
|
-
rel: "noopener noreferrer"
|
|
155
|
-
};
|
|
156
|
-
if (safeHref != null) attrs.href = safeHref;
|
|
157
|
-
return withOverride("autolink", h("a", attrs, node.text));
|
|
158
|
-
}
|
|
159
|
-
case "citation": return withOverride("citation", h("sup", {
|
|
160
|
-
"data-streaming-markdown-node": "citation",
|
|
161
|
-
"data-node-open": String(!node.closed),
|
|
162
|
-
class: "cpk-streaming-markdown-citation"
|
|
163
|
-
}, [h("span", {
|
|
164
|
-
role: "doc-noteref",
|
|
165
|
-
class: "cpk-streaming-markdown-citation-label"
|
|
166
|
-
}, String(node.number ?? node.idRef))]));
|
|
167
|
-
default: return null;
|
|
40
|
+
function renderChild(child, context, slot) {
|
|
41
|
+
switch (child.kind) {
|
|
42
|
+
case "node": return renderRenderNode(child, context);
|
|
43
|
+
case "element": return h(child.tag, elementProps(child, context), child.children.flatMap((entry) => renderChild(entry, context, slot)));
|
|
44
|
+
case "text": return child.text;
|
|
45
|
+
case "caret": return h("span", {
|
|
46
|
+
key: child.key,
|
|
47
|
+
...STREAMING_MARKDOWN_CARET_ATTRS,
|
|
48
|
+
style: STREAMING_MARKDOWN_CARET_STYLE
|
|
49
|
+
});
|
|
50
|
+
case "slot": return slot;
|
|
51
|
+
default: return child;
|
|
168
52
|
}
|
|
169
53
|
}
|
|
54
|
+
function renderRenderNode(renderNode, context) {
|
|
55
|
+
const children = (renderNode.children ?? []).flatMap((entry) => renderChild(entry, context, []));
|
|
56
|
+
const output = renderNode.output.flatMap((entry) => renderChild(entry, context, children));
|
|
57
|
+
const key = renderNode.rendererKey;
|
|
58
|
+
const override = isVueRendererKey(key) ? context.nodeRenderers?.[key] : void 0;
|
|
59
|
+
if (!override) return output;
|
|
60
|
+
const [first] = output;
|
|
61
|
+
const defaultVNode = isVNode(first) || typeof first === "string" ? first : null;
|
|
62
|
+
return [override(renderNode.node, defaultVNode)];
|
|
63
|
+
}
|
|
170
64
|
/**
|
|
171
65
|
* Vue 3 streaming markdown renderer.
|
|
172
66
|
*
|
|
173
|
-
*
|
|
174
|
-
*
|
|
67
|
+
* Parses with `@copilotkit/markdown` and renders the shared render tree with
|
|
68
|
+
* `h()`, so markup, sanitization, caret placement, and the per-token fade-in
|
|
69
|
+
* match the React and DOM renderers.
|
|
175
70
|
*
|
|
176
71
|
* @public
|
|
177
72
|
*/
|
|
178
73
|
const StreamingMarkdownRenderer = defineComponent({
|
|
179
74
|
name: "StreamingMarkdownRenderer",
|
|
75
|
+
inheritAttrs: false,
|
|
180
76
|
props: {
|
|
181
77
|
content: {
|
|
182
78
|
type: String,
|
|
@@ -201,51 +97,42 @@ const StreamingMarkdownRenderer = defineComponent({
|
|
|
201
97
|
nodeRenderers: {
|
|
202
98
|
type: Object,
|
|
203
99
|
default: void 0
|
|
100
|
+
},
|
|
101
|
+
nodeClassNames: {
|
|
102
|
+
type: Object,
|
|
103
|
+
default: void 0
|
|
104
|
+
},
|
|
105
|
+
onLinkClick: {
|
|
106
|
+
type: Function,
|
|
107
|
+
default: void 0
|
|
108
|
+
},
|
|
109
|
+
onCitationClick: {
|
|
110
|
+
type: Function,
|
|
111
|
+
default: void 0
|
|
204
112
|
}
|
|
205
113
|
},
|
|
206
|
-
setup(props) {
|
|
114
|
+
setup(props, { attrs }) {
|
|
115
|
+
let session = null;
|
|
207
116
|
const parserState = computed(() => {
|
|
208
|
-
|
|
209
|
-
return
|
|
210
|
-
});
|
|
211
|
-
const nodeById = computed(() => {
|
|
212
|
-
const map = /* @__PURE__ */ new Map();
|
|
213
|
-
for (const node of parserState.value.nodes) map.set(node.id, node);
|
|
214
|
-
return map;
|
|
117
|
+
session = updateStreamingMarkdownParserSession(session, props.content ?? "", props.options, props.isComplete);
|
|
118
|
+
return session.parserState;
|
|
215
119
|
});
|
|
216
120
|
return () => {
|
|
217
|
-
const
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
const renderers = props.nodeRenderers;
|
|
221
|
-
const rootClass = props.class ? `cpk-streaming-markdown-root ${props.class}` : "cpk-streaming-markdown-root";
|
|
222
|
-
if (!rootNode) return h("div", {
|
|
223
|
-
class: rootClass,
|
|
224
|
-
"data-streaming-markdown-root": true
|
|
121
|
+
const tree = buildStreamingMarkdownRenderTree(parserState.value, {
|
|
122
|
+
caret: props.caret,
|
|
123
|
+
nodeClassNames: props.nodeClassNames
|
|
225
124
|
});
|
|
226
|
-
const
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
style: {
|
|
235
|
-
display: "inline-block",
|
|
236
|
-
width: "0.48em",
|
|
237
|
-
height: "0.48em",
|
|
238
|
-
marginInlineStart: "0.08em",
|
|
239
|
-
verticalAlign: "-0.08em",
|
|
240
|
-
borderRadius: "999px",
|
|
241
|
-
backgroundColor: "currentColor",
|
|
242
|
-
opacity: "0.55"
|
|
243
|
-
}
|
|
244
|
-
}));
|
|
245
|
-
return h("div", {
|
|
125
|
+
const content = tree.root ? renderRenderNode(tree.root, {
|
|
126
|
+
nodeRenderers: props.nodeRenderers,
|
|
127
|
+
onLinkClick: props.onLinkClick,
|
|
128
|
+
onCitationClick: props.onCitationClick
|
|
129
|
+
}) : [];
|
|
130
|
+
const rootClass = props.class ? `${STREAMING_MARKDOWN_ROOT_CLASS} ${props.class}` : STREAMING_MARKDOWN_ROOT_CLASS;
|
|
131
|
+
return [h("style", getStreamingMarkdownStyles()), h("div", {
|
|
132
|
+
...attrs,
|
|
246
133
|
class: rootClass,
|
|
247
134
|
"data-streaming-markdown-root": true
|
|
248
|
-
},
|
|
135
|
+
}, content)];
|
|
249
136
|
};
|
|
250
137
|
}
|
|
251
138
|
});
|
package/dist/vue/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/vue/streaming-markdown-renderer.ts"],"sourcesContent":["import { computed, defineComponent, h } from \"vue\";\nimport type { PropType, VNode } from \"vue\";\nimport {\n createStreamingMarkdownParserState,\n finalizeStreamingMarkdown,\n parseStreamingMarkdownChunk,\n} from \"@copilotkit/markdown\";\nimport type {\n StreamingMarkdownAstNode,\n StreamingMarkdownParserOptions,\n StreamingMarkdownParserState,\n TextSegment,\n} from \"@copilotkit/markdown\";\n\n// ---------------------------------------------------------------------------\n// URL sanitization (allowlisted href and image src schemes)\n// ---------------------------------------------------------------------------\n\nconst SAFE_HREF = /^(https?:|mailto:|tel:|#|\\/|\\.\\/|\\.\\.\\/)/i;\nconst SAFE_IMG_SRC = /^(https?:|data:image\\/(?!svg)|\\/|\\.\\/|\\.\\.\\/)/i;\n\nfunction sanitizeHref(href: string | undefined): string | undefined {\n if (!href) return undefined;\n return SAFE_HREF.test(href.trim()) ? href : undefined;\n}\n\nfunction sanitizeImgSrc(src: string | undefined): string | undefined {\n if (!src) return undefined;\n return SAFE_IMG_SRC.test(src.trim()) ? src : undefined;\n}\n\n// ---------------------------------------------------------------------------\n// Parser helpers (full re-parse approach — simple and correct)\n// ---------------------------------------------------------------------------\n\nconst DEFAULT_OPTIONS: StreamingMarkdownParserOptions = {\n segmenter: true,\n enableTables: true,\n enableAutolinks: true,\n};\n\nfunction normalizeOptions(\n options?: Partial<StreamingMarkdownParserOptions>,\n): StreamingMarkdownParserOptions {\n return {\n segmenter: options?.segmenter ?? DEFAULT_OPTIONS.segmenter,\n enableTables: options?.enableTables ?? DEFAULT_OPTIONS.enableTables,\n enableAutolinks:\n options?.enableAutolinks ?? DEFAULT_OPTIONS.enableAutolinks,\n };\n}\n\nfunction buildParserState(\n content: string,\n options: StreamingMarkdownParserOptions,\n isComplete: boolean,\n): StreamingMarkdownParserState {\n const state = createStreamingMarkdownParserState(options);\n const parsed =\n content.length > 0 ? parseStreamingMarkdownChunk(state, content) : state;\n return isComplete ? finalizeStreamingMarkdown(parsed) : parsed;\n}\n\n// ---------------------------------------------------------------------------\n// AST → VNode walker\n// ---------------------------------------------------------------------------\n\ntype NodeById = Map<number, StreamingMarkdownAstNode>;\n\ntype TextNode = Extract<StreamingMarkdownAstNode, { type: \"text\" }>;\n\nfunction renderTextSegments(node: TextNode): (VNode | string)[] {\n if (node.text.length === 0) return [];\n if (node.segments.length === 0) {\n return [h(\"span\", { class: \"cpk-streaming-markdown-segment\" }, node.text)];\n }\n return node.segments.map((segment: TextSegment) =>\n h(\n \"span\",\n {\n class: \"cpk-streaming-markdown-segment\",\n \"data-streaming-markdown-segment-kind\": segment.kind,\n \"data-streaming-markdown-whitespace\": String(segment.isWhitespace),\n },\n segment.noBreakBefore ? `${segment.text}` : segment.text,\n ),\n );\n}\n\nfunction renderChildren(\n childIds: number[],\n nodeById: NodeById,\n nodeRenderers?: VueStreamingMarkdownNodeRenderers,\n): (VNode | string | null)[] {\n return childIds.map((id) => {\n const child = nodeById.get(id);\n return child ? renderNode(child, nodeById, nodeRenderers) : null;\n });\n}\n\nfunction renderNode(\n node: StreamingMarkdownAstNode,\n nodeById: NodeById,\n nodeRenderers?: VueStreamingMarkdownNodeRenderers,\n): VNode | string | null {\n // Helper: apply a nodeRenderers override if one is registered for this node type.\n function withOverride(\n key: VueStreamingMarkdownNodeRendererKey,\n defaultVNode: VNode | string | null,\n ): VNode | string | null {\n const override = nodeRenderers?.[key];\n return override ? override(node, defaultVNode) : defaultVNode;\n }\n\n switch (node.type) {\n case \"document\": {\n // Document is transparent — render children directly as a Fragment via array\n // We wrap in a div for the root element, handled at the top level.\n // Here just return children inlined (will be wrapped by root div).\n return h(\n \"span\",\n { style: \"display:contents\" },\n renderChildren(node.children, nodeById, nodeRenderers),\n );\n }\n\n case \"paragraph\": {\n const defaultVNode = h(\n \"p\",\n {\n \"data-streaming-markdown-node\": \"paragraph\",\n \"data-node-open\": String(!node.closed),\n },\n renderChildren(node.children, nodeById, nodeRenderers),\n );\n return withOverride(\"paragraph\", defaultVNode);\n }\n\n case \"heading\": {\n const tag = `h${node.level}` as \"h1\" | \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\";\n const defaultVNode = h(\n tag,\n {\n \"data-streaming-markdown-node\": \"heading\",\n \"data-node-open\": String(!node.closed),\n },\n renderChildren(node.children, nodeById, nodeRenderers),\n );\n return withOverride(\"heading\", defaultVNode);\n }\n\n case \"blockquote\": {\n const defaultVNode = h(\n \"blockquote\",\n {\n \"data-streaming-markdown-node\": \"blockquote\",\n \"data-node-open\": String(!node.closed),\n },\n renderChildren(node.children, nodeById, nodeRenderers),\n );\n return withOverride(\"blockquote\", defaultVNode);\n }\n\n case \"list\": {\n const tag = node.ordered ? \"ol\" : \"ul\";\n const attrs: Record<string, unknown> = {\n \"data-streaming-markdown-node\": \"list\",\n \"data-node-open\": String(!node.closed),\n \"data-list-tight\": String(node.tight),\n };\n if (node.ordered && node.start != null) {\n attrs.start = node.start;\n }\n const defaultVNode = h(\n tag,\n attrs,\n renderChildren(node.children, nodeById, nodeRenderers),\n );\n return withOverride(\"list\", defaultVNode);\n }\n\n case \"list-item\": {\n const defaultVNode = h(\n \"li\",\n {\n \"data-streaming-markdown-node\": \"list-item\",\n \"data-node-open\": String(!node.closed),\n },\n renderChildren(node.children, nodeById, nodeRenderers),\n );\n return withOverride(\"listItem\", defaultVNode);\n }\n\n case \"code-block\": {\n const defaultVNode = h(\n \"pre\",\n {\n \"data-streaming-markdown-node\": \"code-block\",\n \"data-node-open\": String(!node.closed),\n },\n [h(\"code\", { \"data-code-info\": node.info ?? undefined }, node.text)],\n );\n return withOverride(\"codeBlock\", defaultVNode);\n }\n\n case \"table\": {\n const defaultVNode = h(\n \"table\",\n {\n \"data-streaming-markdown-node\": \"table\",\n \"data-node-open\": String(!node.closed),\n },\n [h(\"tbody\", renderChildren(node.children, nodeById, nodeRenderers))],\n );\n return withOverride(\"table\", defaultVNode);\n }\n\n case \"table-row\": {\n const defaultVNode = h(\n \"tr\",\n {\n \"data-streaming-markdown-node\": \"table-row\",\n \"data-node-open\": String(!node.closed),\n },\n renderChildren(node.children, nodeById, nodeRenderers),\n );\n return withOverride(\"tableRow\", defaultVNode);\n }\n\n case \"table-cell\": {\n const parent =\n node.parentId != null ? nodeById.get(node.parentId) : undefined;\n const isHeader = parent?.type === \"table-row\" && parent.isHeader;\n const tag = isHeader ? \"th\" : \"td\";\n const defaultVNode = h(\n tag,\n {\n \"data-streaming-markdown-node\": \"table-cell\",\n \"data-node-open\": String(!node.closed),\n },\n renderChildren(node.children, nodeById, nodeRenderers),\n );\n return withOverride(\"tableCell\", defaultVNode);\n }\n\n case \"thematic-break\": {\n const defaultVNode = h(\"hr\", {\n \"data-streaming-markdown-node\": \"thematic-break\",\n \"data-node-open\": String(!node.closed),\n });\n return withOverride(\"thematicBreak\", defaultVNode);\n }\n\n case \"text\": {\n return h(\"span\", { style: \"display:contents\" }, renderTextSegments(node));\n }\n\n case \"em\": {\n const defaultVNode = h(\n \"em\",\n {\n \"data-streaming-markdown-node\": \"em\",\n \"data-node-open\": String(!node.closed),\n },\n renderChildren(node.children, nodeById, nodeRenderers),\n );\n return withOverride(\"em\", defaultVNode);\n }\n\n case \"strong\": {\n const defaultVNode = h(\n \"strong\",\n {\n \"data-streaming-markdown-node\": \"strong\",\n \"data-node-open\": String(!node.closed),\n },\n renderChildren(node.children, nodeById, nodeRenderers),\n );\n return withOverride(\"strong\", defaultVNode);\n }\n\n case \"strikethrough\": {\n const defaultVNode = h(\n \"del\",\n {\n \"data-streaming-markdown-node\": \"strikethrough\",\n \"data-node-open\": String(!node.closed),\n },\n renderChildren(node.children, nodeById, nodeRenderers),\n );\n return withOverride(\"strikethrough\", defaultVNode);\n }\n\n case \"inline-code\": {\n const defaultVNode = h(\n \"code\",\n {\n \"data-streaming-markdown-node\": \"inline-code\",\n \"data-node-open\": String(!node.closed),\n },\n node.text,\n );\n return withOverride(\"inlineCode\", defaultVNode);\n }\n\n case \"soft-break\": {\n return \"\\n\";\n }\n\n case \"hard-break\": {\n const defaultVNode = h(\"br\", {\n \"data-streaming-markdown-node\": \"hard-break\",\n \"data-node-open\": String(!node.closed),\n });\n return withOverride(\"hardBreak\", defaultVNode);\n }\n\n case \"link\": {\n const safeHref = sanitizeHref(node.url);\n const attrs: Record<string, unknown> = {\n \"data-streaming-markdown-node\": \"link\",\n \"data-node-open\": String(!node.closed),\n target: \"_blank\",\n rel: \"noopener noreferrer\",\n };\n if (safeHref != null) {\n attrs.href = safeHref;\n }\n if (node.title) {\n attrs.title = node.title;\n }\n const defaultVNode = h(\n \"a\",\n attrs,\n renderChildren(node.children, nodeById, nodeRenderers),\n );\n return withOverride(\"link\", defaultVNode);\n }\n\n case \"image\": {\n const safeSrc = sanitizeImgSrc(node.url);\n const attrs: Record<string, unknown> = {\n \"data-streaming-markdown-node\": \"image\",\n \"data-node-open\": String(!node.closed),\n alt: node.alt,\n };\n if (safeSrc != null) {\n attrs.src = safeSrc;\n }\n if (node.title) {\n attrs.title = node.title;\n }\n const defaultVNode = h(\"img\", attrs);\n return withOverride(\"image\", defaultVNode);\n }\n\n case \"autolink\": {\n const safeHref = sanitizeHref(node.url);\n const attrs: Record<string, unknown> = {\n \"data-streaming-markdown-node\": \"autolink\",\n \"data-node-open\": String(!node.closed),\n target: \"_blank\",\n rel: \"noopener noreferrer\",\n };\n if (safeHref != null) {\n attrs.href = safeHref;\n }\n const defaultVNode = h(\"a\", attrs, node.text);\n return withOverride(\"autolink\", defaultVNode);\n }\n\n case \"citation\": {\n // Render as a superscript with the citation reference\n const defaultVNode = h(\n \"sup\",\n {\n \"data-streaming-markdown-node\": \"citation\",\n \"data-node-open\": String(!node.closed),\n class: \"cpk-streaming-markdown-citation\",\n },\n [\n h(\n \"span\",\n {\n role: \"doc-noteref\",\n class: \"cpk-streaming-markdown-citation-label\",\n },\n String(node.number ?? node.idRef),\n ),\n ],\n );\n return withOverride(\"citation\", defaultVNode);\n }\n\n default: {\n return null;\n }\n }\n}\n\n// ---------------------------------------------------------------------------\n// Vue component props types (exported for consumer use)\n// ---------------------------------------------------------------------------\n\n/**\n * Custom Vue render function for a specific AST node.\n * @public\n */\nexport type VueStreamingMarkdownNodeRenderer = (\n node: StreamingMarkdownAstNode,\n defaultVNode: VNode | string | null,\n) => VNode | string | null;\n\n/**\n * Supported key names for Vue `nodeRenderers`.\n * CamelCase, matching `StreamingMarkdownNodeRendererKey` on the React renderer.\n *\n * @public\n */\nexport type VueStreamingMarkdownNodeRendererKey =\n | \"paragraph\"\n | \"heading\"\n | \"blockquote\"\n | \"list\"\n | \"listItem\"\n | \"codeBlock\"\n | \"table\"\n | \"tableRow\"\n | \"tableCell\"\n | \"thematicBreak\"\n | \"em\"\n | \"strong\"\n | \"strikethrough\"\n | \"inlineCode\"\n | \"hardBreak\"\n | \"image\"\n | \"link\"\n | \"autolink\"\n | \"citation\";\n\n/**\n * Optional map of node-type renderer keys to custom Vue render functions.\n * @public\n */\nexport type VueStreamingMarkdownNodeRenderers = Partial<\n Record<VueStreamingMarkdownNodeRendererKey, VueStreamingMarkdownNodeRenderer>\n>;\n\n// ---------------------------------------------------------------------------\n// StreamingMarkdownRenderer — Vue 3 Composition API component (.ts)\n// ---------------------------------------------------------------------------\n\n/**\n * Vue 3 streaming markdown renderer.\n *\n * Drives the `@copilotkit/markdown` zero-dep parser and walks the\n * resulting AST into VNodes via `h()`.\n *\n * @public\n */\nexport const StreamingMarkdownRenderer = defineComponent({\n name: \"StreamingMarkdownRenderer\",\n\n props: {\n /** The full markdown source string, which may grow over time during streaming. */\n content: {\n type: String as PropType<string>,\n required: true,\n },\n /** When true, finalizes the parser state (end of stream). */\n isComplete: {\n type: Boolean as PropType<boolean>,\n default: false,\n },\n /** Optional parser option overrides. */\n options: {\n type: Object as PropType<Partial<StreamingMarkdownParserOptions>>,\n default: undefined,\n },\n /** Optional CSS class applied to the root wrapper element. */\n class: {\n type: String as PropType<string>,\n default: undefined,\n },\n /**\n * When true, renders a trailing cursor span after the last open node.\n * Animation niceties are left to CSS; this just inserts the element.\n */\n caret: {\n type: Boolean as PropType<boolean>,\n default: false,\n },\n /**\n * Optional map of node-type keys to custom Vue render functions.\n * Each function receives the AST node and the default VNode and can return\n * a replacement VNode (or the defaultVNode to keep the default).\n * Supported keys: paragraph, heading, blockquote, list, listItem, codeBlock,\n * table, tableRow, tableCell, thematicBreak, em, strong, strikethrough,\n * inlineCode, hardBreak, link, image, autolink, citation.\n */\n nodeRenderers: {\n type: Object as PropType<VueStreamingMarkdownNodeRenderers>,\n default: undefined,\n },\n },\n\n setup(props) {\n const parserState = computed<StreamingMarkdownParserState>(() => {\n const opts = normalizeOptions(props.options);\n return buildParserState(props.content ?? \"\", opts, props.isComplete);\n });\n\n const nodeById = computed<NodeById>(() => {\n const map = new Map<number, StreamingMarkdownAstNode>();\n for (const node of parserState.value.nodes) {\n map.set(node.id, node);\n }\n return map;\n });\n\n return () => {\n const state = parserState.value;\n const byId = nodeById.value;\n const rootNode =\n state.rootId != null ? byId.get(state.rootId) : undefined;\n const renderers = props.nodeRenderers;\n\n const rootClass = props.class\n ? `cpk-streaming-markdown-root ${props.class}`\n : \"cpk-streaming-markdown-root\";\n\n if (!rootNode) {\n return h(\"div\", {\n class: rootClass,\n \"data-streaming-markdown-root\": true,\n });\n }\n\n // Render children of document directly (skip the transparent document wrapper)\n const children: (VNode | string | null)[] =\n rootNode.type === \"document\"\n ? rootNode.children.map((id) => {\n const child = byId.get(id);\n return child ? renderNode(child, byId, renderers) : null;\n })\n : [renderNode(rootNode, byId, renderers)];\n\n // Append caret if requested and not complete\n if (props.caret && !state.isComplete) {\n children.push(\n h(\"span\", {\n \"aria-hidden\": true,\n class: \"cpk-streaming-markdown-caret\",\n \"data-streaming-markdown-caret\": true,\n style: {\n display: \"inline-block\",\n width: \"0.48em\",\n height: \"0.48em\",\n marginInlineStart: \"0.08em\",\n verticalAlign: \"-0.08em\",\n borderRadius: \"999px\",\n backgroundColor: \"currentColor\",\n opacity: \"0.55\",\n },\n }),\n );\n }\n\n return h(\n \"div\",\n {\n class: rootClass,\n \"data-streaming-markdown-root\": true,\n },\n children,\n );\n };\n },\n});\n"],"mappings":";;;;AAkBA,MAAM,YAAY;AAClB,MAAM,eAAe;AAErB,SAAS,aAAa,MAA8C;AAClE,KAAI,CAAC,KAAM,QAAO;AAClB,QAAO,UAAU,KAAK,KAAK,MAAM,CAAC,GAAG,OAAO;;AAG9C,SAAS,eAAe,KAA6C;AACnE,KAAI,CAAC,IAAK,QAAO;AACjB,QAAO,aAAa,KAAK,IAAI,MAAM,CAAC,GAAG,MAAM;;AAO/C,MAAM,kBAAkD;CACtD,WAAW;CACX,cAAc;CACd,iBAAiB;CAClB;AAED,SAAS,iBACP,SACgC;AAChC,QAAO;EACL,WAAW,SAAS,aAAa,gBAAgB;EACjD,cAAc,SAAS,gBAAgB,gBAAgB;EACvD,iBACE,SAAS,mBAAmB,gBAAgB;EAC/C;;AAGH,SAAS,iBACP,SACA,SACA,YAC8B;CAC9B,MAAM,QAAQ,mCAAmC,QAAQ;CACzD,MAAM,SACJ,QAAQ,SAAS,IAAI,4BAA4B,OAAO,QAAQ,GAAG;AACrE,QAAO,aAAa,0BAA0B,OAAO,GAAG;;AAW1D,SAAS,mBAAmB,MAAoC;AAC9D,KAAI,KAAK,KAAK,WAAW,EAAG,QAAO,EAAE;AACrC,KAAI,KAAK,SAAS,WAAW,EAC3B,QAAO,CAAC,EAAE,QAAQ,EAAE,OAAO,kCAA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I,KAAK;AAExB,UAAO;IACP;AAEF,eAAa;GACX,MAAM,QAAQ,YAAY;GAC1B,MAAM,OAAO,SAAS;GACtB,MAAM,WACJ,MAAM,UAAU,OAAO,KAAK,IAAI,MAAM,OAAO,GAAG;GAClD,MAAM,YAAY,MAAM;GAExB,MAAM,YAAY,MAAM,QACpB,+BAA+B,MAAM,UACrC;AAEJ,OAAI,CAAC,SACH,QAAO,EAAE,OAAO;IACd,OAAO;IACP,gCAAgC;IACjC,CAAC;GAIJ,MAAM,WACJ,SAAS,SAAS,aACd,SAAS,SAAS,KAAK,OAAO;IAC5B,MAAM,QAAQ,KAAK,IAAI,GAAG;AAC1B,WAAO,QAAQ,WAAW,OAAO,MAAM,UAAU,GAAG;KACpD,GACF,CAAC,WAAW,UAAU,MAAM,UAAU,CAAC;AAG7C,OAAI,MAAM,SAAS,CAAC,MAAM,WACxB,UAAS,KACP,EAAE,QAAQ;IACR,eAAe;IACf,OAAO;IACP,iCAAiC;IACjC,OAAO;KACL,SAAS;KACT,OAAO;KACP,QAAQ;KACR,mBAAmB;KACnB,eAAe;KACf,cAAc;KACd,iBAAiB;KACjB,SAAS;KACV;IACF,CAAC,CACH;AAGH,UAAO,EACL,OACA;IACE,OAAO;IACP,gCAAgC;IACjC,EACD,SACD;;;CAGN,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/vue/streaming-markdown-renderer.ts"],"sourcesContent":["import { computed, defineComponent, h, isVNode } from \"vue\";\nimport type { PropType, VNode, VNodeChild } from \"vue\";\nimport {\n STREAMING_MARKDOWN_CARET_ATTRS,\n STREAMING_MARKDOWN_CARET_STYLE,\n STREAMING_MARKDOWN_ROOT_CLASS,\n buildStreamingMarkdownRenderTree,\n getStreamingMarkdownStyles,\n updateStreamingMarkdownParserSession,\n} from \"@copilotkit/markdown\";\nimport type {\n StreamingMarkdownAstNode,\n StreamingMarkdownCitationRenderData,\n StreamingMarkdownNodeClassNames,\n StreamingMarkdownParserOptions,\n StreamingMarkdownParserSession,\n StreamingMarkdownRenderChild,\n StreamingMarkdownRenderElement,\n StreamingMarkdownRenderNode,\n} from \"@copilotkit/markdown\";\n\n// ---------------------------------------------------------------------------\n// Vue component props types (exported for consumer use)\n// ---------------------------------------------------------------------------\n\n/**\n * Custom Vue render function for a specific AST node.\n * @public\n */\nexport type VueStreamingMarkdownNodeRenderer = (\n node: StreamingMarkdownAstNode,\n defaultVNode: VNode | string | null,\n) => VNode | string | null;\n\n/**\n * Supported key names for Vue `nodeRenderers`.\n * CamelCase, matching `StreamingMarkdownNodeRendererKey` on the React renderer.\n *\n * @public\n */\nexport type VueStreamingMarkdownNodeRendererKey =\n | \"paragraph\"\n | \"heading\"\n | \"blockquote\"\n | \"list\"\n | \"listItem\"\n | \"codeBlock\"\n | \"table\"\n | \"tableRow\"\n | \"tableCell\"\n | \"thematicBreak\"\n | \"em\"\n | \"strong\"\n | \"strikethrough\"\n | \"inlineCode\"\n | \"hardBreak\"\n | \"image\"\n | \"link\"\n | \"autolink\"\n | \"citation\"\n | \"math\";\n\n/**\n * Optional map of node-type renderer keys to custom Vue render functions.\n * @public\n */\nexport type VueStreamingMarkdownNodeRenderers = Partial<\n Record<VueStreamingMarkdownNodeRendererKey, VueStreamingMarkdownNodeRenderer>\n>;\n\n/**\n * Called when a link or autolink is clicked.\n * @public\n */\nexport type VueStreamingMarkdownLinkClickHandler = (\n event: MouseEvent,\n url: string,\n node: StreamingMarkdownAstNode,\n) => void;\n\n/**\n * Called when a citation reference is clicked.\n * @public\n */\nexport type VueStreamingMarkdownCitationClickHandler = (\n event: MouseEvent,\n citation: StreamingMarkdownCitationRenderData,\n node: StreamingMarkdownAstNode,\n) => void;\n\n// ---------------------------------------------------------------------------\n// Render tree → VNodes\n// ---------------------------------------------------------------------------\n\ntype RenderContext = {\n nodeRenderers: VueStreamingMarkdownNodeRenderers | undefined;\n onLinkClick: VueStreamingMarkdownLinkClickHandler | undefined;\n onCitationClick: VueStreamingMarkdownCitationClickHandler | undefined;\n};\n\nconst VUE_RENDERER_KEYS = new Set<string>([\n \"paragraph\",\n \"heading\",\n \"blockquote\",\n \"list\",\n \"listItem\",\n \"codeBlock\",\n \"table\",\n \"tableRow\",\n \"tableCell\",\n \"thematicBreak\",\n \"em\",\n \"strong\",\n \"strikethrough\",\n \"inlineCode\",\n \"hardBreak\",\n \"image\",\n \"link\",\n \"autolink\",\n \"citation\",\n \"math\",\n] satisfies VueStreamingMarkdownNodeRendererKey[]);\n\nfunction isVueRendererKey(\n key: string,\n): key is VueStreamingMarkdownNodeRendererKey {\n return VUE_RENDERER_KEYS.has(key);\n}\n\nfunction elementProps(\n element: StreamingMarkdownRenderElement,\n context: RenderContext,\n) {\n const props: Record<string, unknown> = { key: element.key, ...element.attrs };\n const action = element.action;\n if (action?.type === \"link\") {\n props.onClick = (event: MouseEvent) =>\n context.onLinkClick?.(event, action.url, action.node);\n }\n if (action?.type === \"citation\") {\n props.onClick = (event: MouseEvent) =>\n context.onCitationClick?.(event, action.citation, action.node);\n }\n return props;\n}\n\nfunction renderChild(\n child: StreamingMarkdownRenderChild,\n context: RenderContext,\n slot: VNodeChild[],\n): VNodeChild | VNodeChild[] {\n switch (child.kind) {\n case \"node\":\n return renderRenderNode(child, context);\n case \"element\":\n return h(\n child.tag,\n elementProps(child, context),\n child.children.flatMap((entry) => renderChild(entry, context, slot)),\n );\n case \"text\":\n return child.text;\n case \"caret\":\n return h(\"span\", {\n key: child.key,\n ...STREAMING_MARKDOWN_CARET_ATTRS,\n style: STREAMING_MARKDOWN_CARET_STYLE,\n });\n case \"slot\":\n return slot;\n default: {\n const unreachable: never = child;\n return unreachable;\n }\n }\n}\n\nfunction renderRenderNode(\n renderNode: StreamingMarkdownRenderNode,\n context: RenderContext,\n): VNodeChild[] {\n const children = (renderNode.children ?? []).flatMap((entry) =>\n renderChild(entry, context, []),\n );\n const output = renderNode.output.flatMap((entry) =>\n renderChild(entry, context, children),\n );\n const key = renderNode.rendererKey;\n const override = isVueRendererKey(key)\n ? context.nodeRenderers?.[key]\n : undefined;\n if (!override) {\n return output;\n }\n const [first] = output;\n const defaultVNode =\n isVNode(first) || typeof first === \"string\" ? first : null;\n return [override(renderNode.node, defaultVNode)];\n}\n\n// ---------------------------------------------------------------------------\n// StreamingMarkdownRenderer — Vue 3 Composition API component (.ts)\n// ---------------------------------------------------------------------------\n\n/**\n * Vue 3 streaming markdown renderer.\n *\n * Parses with `@copilotkit/markdown` and renders the shared render tree with\n * `h()`, so markup, sanitization, caret placement, and the per-token fade-in\n * match the React and DOM renderers.\n *\n * @public\n */\nexport const StreamingMarkdownRenderer = defineComponent({\n name: \"StreamingMarkdownRenderer\",\n inheritAttrs: false,\n\n props: {\n /** The full markdown source string, which may grow over time during streaming. */\n content: {\n type: String as PropType<string>,\n required: true,\n },\n /** When true, finalizes the parser state (end of stream). */\n isComplete: {\n type: Boolean as PropType<boolean>,\n default: false,\n },\n /** Optional parser option overrides. */\n options: {\n type: Object as PropType<Partial<StreamingMarkdownParserOptions>>,\n default: undefined,\n },\n /** Optional CSS class applied to the root wrapper element. */\n class: {\n type: String as PropType<string>,\n default: undefined,\n },\n /**\n * When true, renders a caret inside the deepest open node while streaming.\n */\n caret: {\n type: Boolean as PropType<boolean>,\n default: false,\n },\n /**\n * Optional map of node-type keys to custom Vue render functions.\n * Each function receives the AST node and the default VNode and can return\n * a replacement VNode (or the defaultVNode to keep the default).\n */\n nodeRenderers: {\n type: Object as PropType<VueStreamingMarkdownNodeRenderers>,\n default: undefined,\n },\n /** Extra classes for the default element of a node type. */\n nodeClassNames: {\n type: Object as PropType<StreamingMarkdownNodeClassNames>,\n default: undefined,\n },\n /** Called when a link or autolink is clicked. */\n onLinkClick: {\n type: Function as PropType<VueStreamingMarkdownLinkClickHandler>,\n default: undefined,\n },\n /** Called when a citation reference with a URL is clicked. */\n onCitationClick: {\n type: Function as PropType<VueStreamingMarkdownCitationClickHandler>,\n default: undefined,\n },\n },\n\n setup(props, { attrs }) {\n // Not reactive on purpose: the previous session only seeds the next parse.\n let session: StreamingMarkdownParserSession | null = null;\n const parserState = computed(() => {\n session = updateStreamingMarkdownParserSession(\n session,\n props.content ?? \"\",\n props.options,\n props.isComplete,\n );\n return session.parserState;\n });\n\n return () => {\n const tree = buildStreamingMarkdownRenderTree(parserState.value, {\n caret: props.caret,\n nodeClassNames: props.nodeClassNames,\n });\n const content = tree.root\n ? renderRenderNode(tree.root, {\n nodeRenderers: props.nodeRenderers,\n onLinkClick: props.onLinkClick,\n onCitationClick: props.onCitationClick,\n })\n : [];\n\n const rootClass = props.class\n ? `${STREAMING_MARKDOWN_ROOT_CLASS} ${props.class}`\n : STREAMING_MARKDOWN_ROOT_CLASS;\n\n return [\n h(\"style\", getStreamingMarkdownStyles()),\n h(\n \"div\",\n { ...attrs, class: rootClass, \"data-streaming-markdown-root\": true },\n content,\n ),\n ];\n };\n },\n});\n"],"mappings":";;;;AAoGA,MAAM,oBAAoB,IAAI,IAAY;CACxC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAiD;AAElD,SAAS,iBACP,KAC4C;AAC5C,QAAO,kBAAkB,IAAI,IAAI;;AAGnC,SAAS,aACP,SACA,SACA;CACA,MAAM,QAAiC;EAAE,KAAK,QAAQ;EAAK,GAAG,QAAQ;EAAO;CAC7E,MAAM,SAAS,QAAQ;AACvB,KAAI,QAAQ,SAAS,OACnB,OAAM,WAAW,UACf,QAAQ,cAAc,OAAO,OAAO,KAAK,OAAO,KAAK;AAEzD,KAAI,QAAQ,SAAS,WACnB,OAAM,WAAW,UACf,QAAQ,kBAAkB,OAAO,OAAO,UAAU,OAAO,KAAK;AAElE,QAAO;;AAGT,SAAS,YACP,OACA,SACA,MAC2B;AAC3B,SAAQ,MAAM,MAAd;EACE,KAAK,OACH,QAAO,iBAAiB,OAAO,QAAQ;EACzC,KAAK,UACH,QAAO,EACL,MAAM,KACN,aAAa,OAAO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UAAO,QAAQ;IACf;AAEF,eAAa;GACX,MAAM,OAAO,iCAAiC,YAAY,OAAO;IAC/D,OAAO,MAAM;IACb,gBAAgB,MAAM;IACvB,CAAC;GACF,MAAM,UAAU,KAAK,OACjB,iBAAiB,KAAK,MAAM;IAC1B,eAAe,MAAM;IACrB,aAAa,MAAM;IACnB,iBAAiB,MAAM;IACxB,CAAC,GACF,EAAE;GAEN,MAAM,YAAY,MAAM,QACpB,GAAG,8BAA8B,GAAG,MAAM,UAC1C;AAEJ,UAAO,CACL,EAAE,SAAS,4BAA4B,CAAC,EACxC,EACE,OACA;IAAE,GAAG;IAAO,OAAO;IAAW,gCAAgC;IAAM,EACpE,QACD,CACF;;;CAGN,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@copilotkit/markdown",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
4
|
-
"description": "Zero-dependency streaming markdown parser and
|
|
3
|
+
"version": "2.0.0-rc.22",
|
|
4
|
+
"description": "Zero-dependency streaming markdown parser and renderers (React, Vue, React Native, DOM) for CopilotKit",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -28,6 +28,10 @@
|
|
|
28
28
|
"import": "./dist/vue/index.mjs",
|
|
29
29
|
"require": "./dist/vue/index.cjs"
|
|
30
30
|
},
|
|
31
|
+
"./dom": {
|
|
32
|
+
"import": "./dist/dom/index.mjs",
|
|
33
|
+
"require": "./dist/dom/index.cjs"
|
|
34
|
+
},
|
|
31
35
|
"./package.json": "./package.json"
|
|
32
36
|
},
|
|
33
37
|
"publishConfig": {
|