@superlc/md-vue 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.
@@ -0,0 +1,85 @@
1
+ import { VNode, PropType } from 'vue';
2
+ import { PluginConfig } from '@superlc/md-core';
3
+ import { MarkdownComponents } from './types';
4
+
5
+ /**
6
+ * Vue Markdown 渲染组件
7
+ */
8
+ export declare const Markdown: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
9
+ content: {
10
+ type: StringConstructor;
11
+ required: true;
12
+ };
13
+ class: {
14
+ type: StringConstructor;
15
+ default: string;
16
+ };
17
+ gfm: {
18
+ type: BooleanConstructor;
19
+ default: boolean;
20
+ };
21
+ highlight: {
22
+ type: BooleanConstructor;
23
+ default: boolean;
24
+ };
25
+ math: {
26
+ type: BooleanConstructor;
27
+ default: boolean;
28
+ };
29
+ components: {
30
+ type: PropType<MarkdownComponents>;
31
+ default: () => {};
32
+ };
33
+ remarkPlugins: {
34
+ type: PropType<PluginConfig[]>;
35
+ default: () => never[];
36
+ };
37
+ rehypePlugins: {
38
+ type: PropType<PluginConfig[]>;
39
+ default: () => never[];
40
+ };
41
+ }>, () => string | VNode<import('vue').RendererNode, import('vue').RendererElement, {
42
+ [key: string]: any;
43
+ }> | null, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
44
+ content: {
45
+ type: StringConstructor;
46
+ required: true;
47
+ };
48
+ class: {
49
+ type: StringConstructor;
50
+ default: string;
51
+ };
52
+ gfm: {
53
+ type: BooleanConstructor;
54
+ default: boolean;
55
+ };
56
+ highlight: {
57
+ type: BooleanConstructor;
58
+ default: boolean;
59
+ };
60
+ math: {
61
+ type: BooleanConstructor;
62
+ default: boolean;
63
+ };
64
+ components: {
65
+ type: PropType<MarkdownComponents>;
66
+ default: () => {};
67
+ };
68
+ remarkPlugins: {
69
+ type: PropType<PluginConfig[]>;
70
+ default: () => never[];
71
+ };
72
+ rehypePlugins: {
73
+ type: PropType<PluginConfig[]>;
74
+ default: () => never[];
75
+ };
76
+ }>> & Readonly<{}>, {
77
+ components: MarkdownComponents;
78
+ class: string;
79
+ gfm: boolean;
80
+ highlight: boolean;
81
+ math: boolean;
82
+ remarkPlugins: PluginConfig[];
83
+ rehypePlugins: PluginConfig[];
84
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
85
+ //# sourceMappingURL=Markdown.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Markdown.d.ts","sourceRoot":"","sources":["../src/Markdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuC,KAAK,KAAK,EAAE,KAAK,QAAQ,EAAE,MAAM,KAAK,CAAC;AACrF,OAAO,EAAe,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAElE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAKlD;;GAEG;AACH,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;cAwBC,QAAQ,CAAC,kBAAkB,CAAC;;;;cAI7B,QAAQ,CAAC,YAAY,EAAE,CAAC;;;;cAIxB,QAAQ,CAAC,YAAY,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;cARvB,QAAQ,CAAC,kBAAkB,CAAC;;;;cAI7B,QAAQ,CAAC,YAAY,EAAE,CAAC;;;;cAIxB,QAAQ,CAAC,YAAY,EAAE,CAAC;;;;;;;;;;;4EAmF3C,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * 检查 KaTeX CSS 是否已加载
3
+ */
4
+ export declare function isKatexCssLoaded(): boolean;
5
+ /**
6
+ * 预加载 KaTeX CSS
7
+ */
8
+ export declare function preloadKatexCss(): Promise<void>;
9
+ //# sourceMappingURL=MathProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MathProvider.d.ts","sourceRoot":"","sources":["../src/MathProvider.ts"],"names":[],"mappings":"AA4BA;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,OAAO,CAE1C;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC,CAE/C"}
package/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";var E=Object.create;var O=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var H=Object.getOwnPropertyNames;var _=Object.getPrototypeOf,$=Object.prototype.hasOwnProperty;var W=(e,r,n,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of H(r))!$.call(e,i)&&i!==n&&O(e,i,{get:()=>r[i],enumerable:!(t=I(r,i))||t.enumerable});return e};var z=(e,r,n)=>(n=e!=null?E(_(e)):{},W(r||!e||!e.__esModule?O(n,"default",{value:e,enumerable:!0}):n,e));Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("vue"),N=require("@superlc/md-core");let b=!1,w=null;async function D(){if(!b)return w||(w=(async()=>{await import("katex/dist/katex.min.css"),b=!0})(),w)}function G(){return b}function U(){return D()}const j=a.defineComponent({name:"Markdown",props:{content:{type:String,required:!0},class:{type:String,default:""},gfm:{type:Boolean,default:!0},highlight:{type:Boolean,default:!0},math:{type:Boolean,default:!1},components:{type:Object,default:()=>({})},remarkPlugins:{type:Array,default:()=>[]},rehypePlugins:{type:Array,default:()=>[]}},setup(e){a.watch(()=>e.math,t=>{t&&U()},{immediate:!0});function r(t,i={}){if(t.type==="text")return t.value;if(t.type==="comment")return null;if(t.type==="root"){const l=t.children.map(s=>r(s,i)).filter(s=>s!==null);return a.h("div",{class:e.class},l)}if(t.type==="element"){const{tagName:l,properties:s,children:o}=t,c=i[l]||l,d={};if(s)for(const[m,u]of Object.entries(s))m==="className"?d.class=Array.isArray(u)?u.join(" "):u:d[m]=u;const p=o.map(m=>r(m,i)).filter(m=>m!==null);return typeof c=="string"?a.h(c,d,p):a.h(c,d,()=>p)}return null}const n=a.computed(()=>{if(!e.content)return null;const t=N.parseToHast(e.content,{gfm:e.gfm,highlight:e.highlight,math:e.math,remarkPlugins:e.remarkPlugins,rehypePlugins:e.rehypePlugins});return r(t,e.components)});return()=>n.value?n.value:null}});function M(e,r){if(e.type==="text")return e.value;if(e.type==="root"){const n=e.children.map(t=>M(t,r)).filter(t=>t!==null);return a.h("div",{},n)}if(e.type==="element"){const n=e,t=n.tagName,i=r==null?void 0:r[t],l={...n.properties};l.className&&(l.class=Array.isArray(l.className)?l.className.join(" "):l.className,delete l.className);const s=n.children.map(o=>M(o,r)).filter(o=>o!==null);return i?a.h(i,l,()=>s):a.h(t,l,s)}return null}function J(e={}){const{components:r,minUpdateInterval:n=16,immediate:t=!1,outputRate:i="medium",...l}=e,s=N.createStreamingParser(l),o=new N.OutputRateController(i),c=a.ref(0),d=a.ref(!1),p=a.ref(0),m=a.ref("idle");let u=0,f=null;const v=()=>{const g=performance.now(),C=g-u;t||C>=n?(u=g,c.value++):f===null&&(f=requestAnimationFrame(()=>{f=null,u=performance.now(),c.value++}))},h=g=>{s.append(g),v()},y=g=>{s.reset(),d.value=!1,p.value=0,m.value="running",o.start(g,C=>{C&&s.append(C),p.value=o.progress,v()},()=>{s.finish(),d.value=!0,p.value=1,m.value="complete",v()})},A=()=>{o.pause(),m.value=o.status},S=()=>{o.resume(),m.value=o.status},F=()=>{o.skipToEnd(),m.value=o.status,p.value=1},R=()=>{o.stop(),s.finish(),d.value=!0,m.value="complete",f!==null&&(cancelAnimationFrame(f),f=null),c.value++},V=()=>{o.stop(),s.reset(),d.value=!1,p.value=0,m.value="idle",f!==null&&(cancelAnimationFrame(f),f=null),c.value++};a.onUnmounted(()=>{o.stop(),f!==null&&cancelAnimationFrame(f)});const q=a.computed(()=>(c.value,s.getState().blocks)),K=a.computed(()=>(c.value,s.getStats())),L=a.computed(()=>(c.value,s.getContent()));return{vnode:a.computed(()=>{c.value;const g=s.getState();if(g.blocks.length===0)return null;const C=g.blocks.map(k=>k.hast?a.h("div",{key:k.key,"data-block-key":k.key,"data-pending":!k.stable||void 0},[M(k.hast,r)]):null).filter(k=>k!==null);return a.h("div",{"data-streaming":!d.value},C)}),append:h,start:y,pause:A,resume:S,skipToEnd:F,reset:V,finish:R,blocks:q,stats:K,isComplete:d,content:L,progress:p,outputStatus:m}}function x(e,r){if(e.type==="text")return e.value;if(e.type==="root"){const n=e.children.map(t=>x(t,r)).filter(t=>t!==null);return a.h("div",{},n)}if(e.type==="element"){const n=e,t=n.tagName,i=r==null?void 0:r[t],l={...n.properties};l.className&&(l.class=Array.isArray(l.className)?l.className.join(" "):l.className,delete l.className);const s=n.children.map(o=>x(o,r)).filter(o=>o!==null);return i?a.h(i,l,()=>s):a.h(t,l,s)}return null}const B=a.defineComponent({name:"StreamingMarkdown",props:{content:{type:String,default:void 0},source:{type:String,default:void 0},outputRate:{type:[String,Object],default:"medium"},isComplete:{type:Boolean,default:!1},components:{type:Object,default:void 0},class:{type:String,default:void 0},minUpdateInterval:{type:Number,default:16},autoStart:{type:Boolean,default:!0},gfm:{type:Boolean,default:!0},highlight:{type:Boolean,default:!0},math:{type:Boolean,default:!1}},emits:["complete","blockStable","progress"],setup(e,{emit:r}){a.watch(()=>e.math,u=>{u&&U()},{immediate:!0});const n=N.createStreamingParser({gfm:e.gfm,highlight:e.highlight,math:e.math}),t=new N.OutputRateController(e.outputRate),i=a.ref(0),l=a.ref(""),s=a.ref(void 0),o=a.ref([]),c=a.ref(!1);let d=0,p=null;const m=()=>{const u=performance.now();u-d>=e.minUpdateInterval?(d=u,i.value++):p===null&&(p=requestAnimationFrame(()=>{p=null,d=performance.now(),i.value++}))};return a.watch(()=>e.source,u=>{u!==void 0&&u!==s.value&&(s.value=u,e.autoStart&&u&&(n.reset(),l.value="",c.value=!1,t.start(u,f=>{f&&(n.append(f),l.value+=f),r("progress",t.progress),m()},()=>{n.finish(),c.value=!0,r("complete"),m()})))},{immediate:!0}),a.watch(()=>e.content,u=>{if(e.source!==void 0)return;const f=l.value,v=u||"";if(v!==f){if(v.startsWith(f)){const y=v.slice(f.length);y&&n.append(y)}else n.reset(),v&&n.append(v);l.value=v,m();const h=n.getState().blocks;h.forEach((y,A)=>{const S=o.value[A];y.stable&&(!S||!S.stable)&&r("blockStable",y)}),o.value=h}},{immediate:!0}),a.watch(()=>e.isComplete,u=>{e.source===void 0&&u&&(n.finish(),p!==null&&(cancelAnimationFrame(p),p=null),i.value++,r("complete"))}),a.watch(()=>e.outputRate,u=>{t.setRate(u)}),a.onUnmounted(()=>{t.stop(),p!==null&&cancelAnimationFrame(p)}),()=>{i.value;const u=n.getState(),f=e.source!==void 0?c.value:e.isComplete,v=u.blocks.map(h=>h.hast?a.h("div",{key:h.key,"data-block-key":h.key,"data-pending":!h.stable||void 0},[x(h.hast,e.components)]):null).filter(h=>h!==null);return a.h("div",{class:e.class,"data-streaming":!f},v)}}});function P(e,r={}){if(e.type==="text")return e.value;if(e.type==="comment")return null;if(e.type==="root"){const n=e.children.map(t=>P(t,r)).filter(t=>t!==null);return a.h("div",{},n)}if(e.type==="element"){const{tagName:n,properties:t,children:i}=e,l=r[n]||n,s={};if(t)for(const[c,d]of Object.entries(t))c==="className"?s.class=Array.isArray(d)?d.join(" "):d:s[c]=d;const o=i.map(c=>P(c,r)).filter(c=>c!==null);return a.h(l,s,()=>o)}return null}function Q(e,r={}){const{components:n={},...t}=r;return a.computed(()=>{const i=e();if(!i)return null;const l=N.parseToHast(i,t);return P(l,n)})}function T(e){e.component("Markdown",j),e.component("StreamingMarkdown",B)}const X={install:T,Markdown:j,StreamingMarkdown:B};exports.Markdown=j;exports.StreamingMarkdown=B;exports.default=X;exports.install=T;exports.isKatexCssLoaded=G;exports.preloadKatexCss=U;exports.useMarkdown=Q;exports.useStreamingMarkdown=J;
@@ -0,0 +1,205 @@
1
+ import { App } from 'vue';
2
+ import { Markdown } from './Markdown';
3
+
4
+ export { Markdown };
5
+ export { useMarkdown } from './useMarkdown';
6
+ export type { MarkdownProps, MarkdownComponents, UseMarkdownOptions } from './types';
7
+ export { useStreamingMarkdown, StreamingMarkdown } from './streaming';
8
+ export type { UseStreamingMarkdownOptions, UseStreamingMarkdownResult, StreamingMarkdownProps, StreamingMarkdownEmits, } from './streaming';
9
+ export { preloadKatexCss, isKatexCssLoaded } from './MathProvider';
10
+ export type { ProcessorOptions, PluginConfig, BlockInfo, ParserStats, OutputRate, OutputRatePreset, OutputRateCustom, OutputRateStatus, InlineType, InlinePredictionOptions, } from '@superlc/md-core';
11
+ /**
12
+ * Vue 插件安装函数
13
+ */
14
+ export declare function install(app: App): void;
15
+ declare const _default: {
16
+ install: typeof install;
17
+ Markdown: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
18
+ content: {
19
+ type: StringConstructor;
20
+ required: true;
21
+ };
22
+ class: {
23
+ type: StringConstructor;
24
+ default: string;
25
+ };
26
+ gfm: {
27
+ type: BooleanConstructor;
28
+ default: boolean;
29
+ };
30
+ highlight: {
31
+ type: BooleanConstructor;
32
+ default: boolean;
33
+ };
34
+ math: {
35
+ type: BooleanConstructor;
36
+ default: boolean;
37
+ };
38
+ components: {
39
+ type: import('vue').PropType<import('./types').MarkdownComponents>;
40
+ default: () => {};
41
+ };
42
+ remarkPlugins: {
43
+ type: import('vue').PropType<import('@superlc/md-core').PluginConfig[]>;
44
+ default: () => never[];
45
+ };
46
+ rehypePlugins: {
47
+ type: import('vue').PropType<import('@superlc/md-core').PluginConfig[]>;
48
+ default: () => never[];
49
+ };
50
+ }>, () => string | import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
51
+ [key: string]: any;
52
+ }> | null, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
53
+ content: {
54
+ type: StringConstructor;
55
+ required: true;
56
+ };
57
+ class: {
58
+ type: StringConstructor;
59
+ default: string;
60
+ };
61
+ gfm: {
62
+ type: BooleanConstructor;
63
+ default: boolean;
64
+ };
65
+ highlight: {
66
+ type: BooleanConstructor;
67
+ default: boolean;
68
+ };
69
+ math: {
70
+ type: BooleanConstructor;
71
+ default: boolean;
72
+ };
73
+ components: {
74
+ type: import('vue').PropType<import('./types').MarkdownComponents>;
75
+ default: () => {};
76
+ };
77
+ remarkPlugins: {
78
+ type: import('vue').PropType<import('@superlc/md-core').PluginConfig[]>;
79
+ default: () => never[];
80
+ };
81
+ rehypePlugins: {
82
+ type: import('vue').PropType<import('@superlc/md-core').PluginConfig[]>;
83
+ default: () => never[];
84
+ };
85
+ }>> & Readonly<{}>, {
86
+ components: import('./types').MarkdownComponents;
87
+ class: string;
88
+ gfm: boolean;
89
+ highlight: boolean;
90
+ math: boolean;
91
+ remarkPlugins: import('@superlc/md-core').PluginConfig[];
92
+ rehypePlugins: import('@superlc/md-core').PluginConfig[];
93
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
94
+ StreamingMarkdown: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
95
+ content: {
96
+ type: StringConstructor;
97
+ default: undefined;
98
+ };
99
+ source: {
100
+ type: StringConstructor;
101
+ default: undefined;
102
+ };
103
+ outputRate: {
104
+ type: import('vue').PropType<import('@superlc/md-core').OutputRate>;
105
+ default: string;
106
+ };
107
+ isComplete: {
108
+ type: BooleanConstructor;
109
+ default: boolean;
110
+ };
111
+ components: {
112
+ type: import('vue').PropType<import('./types').MarkdownComponents>;
113
+ default: undefined;
114
+ };
115
+ class: {
116
+ type: StringConstructor;
117
+ default: undefined;
118
+ };
119
+ minUpdateInterval: {
120
+ type: NumberConstructor;
121
+ default: number;
122
+ };
123
+ autoStart: {
124
+ type: BooleanConstructor;
125
+ default: boolean;
126
+ };
127
+ gfm: {
128
+ type: BooleanConstructor;
129
+ default: boolean;
130
+ };
131
+ highlight: {
132
+ type: BooleanConstructor;
133
+ default: boolean;
134
+ };
135
+ math: {
136
+ type: BooleanConstructor;
137
+ default: boolean;
138
+ };
139
+ }>, () => import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
140
+ [key: string]: any;
141
+ }>, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, ("progress" | "complete" | "blockStable")[], "progress" | "complete" | "blockStable", import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
142
+ content: {
143
+ type: StringConstructor;
144
+ default: undefined;
145
+ };
146
+ source: {
147
+ type: StringConstructor;
148
+ default: undefined;
149
+ };
150
+ outputRate: {
151
+ type: import('vue').PropType<import('@superlc/md-core').OutputRate>;
152
+ default: string;
153
+ };
154
+ isComplete: {
155
+ type: BooleanConstructor;
156
+ default: boolean;
157
+ };
158
+ components: {
159
+ type: import('vue').PropType<import('./types').MarkdownComponents>;
160
+ default: undefined;
161
+ };
162
+ class: {
163
+ type: StringConstructor;
164
+ default: undefined;
165
+ };
166
+ minUpdateInterval: {
167
+ type: NumberConstructor;
168
+ default: number;
169
+ };
170
+ autoStart: {
171
+ type: BooleanConstructor;
172
+ default: boolean;
173
+ };
174
+ gfm: {
175
+ type: BooleanConstructor;
176
+ default: boolean;
177
+ };
178
+ highlight: {
179
+ type: BooleanConstructor;
180
+ default: boolean;
181
+ };
182
+ math: {
183
+ type: BooleanConstructor;
184
+ default: boolean;
185
+ };
186
+ }>> & Readonly<{
187
+ onProgress?: ((...args: any[]) => any) | undefined;
188
+ onComplete?: ((...args: any[]) => any) | undefined;
189
+ onBlockStable?: ((...args: any[]) => any) | undefined;
190
+ }>, {
191
+ content: string;
192
+ components: import('./types').MarkdownComponents;
193
+ class: string;
194
+ gfm: boolean;
195
+ highlight: boolean;
196
+ math: boolean;
197
+ source: string;
198
+ minUpdateInterval: number;
199
+ outputRate: import('@superlc/md-core').OutputRate;
200
+ isComplete: boolean;
201
+ autoStart: boolean;
202
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
203
+ };
204
+ export default _default;
205
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGtC,OAAO,EAAE,QAAQ,EAAE,CAAC;AACpB,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,YAAY,EAAE,aAAa,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAGrF,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACtE,YAAY,EACV,2BAA2B,EAC3B,0BAA0B,EAC1B,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGnE,YAAY,EACV,gBAAgB,EAChB,YAAY,EACZ,SAAS,EACT,WAAW,EACX,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,UAAU,EACV,uBAAuB,GACxB,MAAM,kBAAkB,CAAC;AAE1B;;GAEG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,CAGtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAED,wBAIE"}
package/dist/index.js ADDED
@@ -0,0 +1,379 @@
1
+ import { defineComponent as M, watch as S, computed as A, h as p, ref as y, onUnmounted as O } from "vue";
2
+ import { parseToHast as F, createStreamingParser as T, OutputRateController as R } from "@superlc/md-core";
3
+ let B = !1, b = null;
4
+ async function z() {
5
+ if (!B)
6
+ return b || (b = (async () => {
7
+ await import("katex/dist/katex.min.css"), B = !0;
8
+ })(), b);
9
+ }
10
+ function X() {
11
+ return B;
12
+ }
13
+ function V() {
14
+ return z();
15
+ }
16
+ const q = M({
17
+ name: "Markdown",
18
+ props: {
19
+ content: {
20
+ type: String,
21
+ required: !0
22
+ },
23
+ class: {
24
+ type: String,
25
+ default: ""
26
+ },
27
+ gfm: {
28
+ type: Boolean,
29
+ default: !0
30
+ },
31
+ highlight: {
32
+ type: Boolean,
33
+ default: !0
34
+ },
35
+ math: {
36
+ type: Boolean,
37
+ default: !1
38
+ },
39
+ components: {
40
+ type: Object,
41
+ default: () => ({})
42
+ },
43
+ remarkPlugins: {
44
+ type: Array,
45
+ default: () => []
46
+ },
47
+ rehypePlugins: {
48
+ type: Array,
49
+ default: () => []
50
+ }
51
+ },
52
+ setup(e) {
53
+ S(
54
+ () => e.math,
55
+ (t) => {
56
+ t && V();
57
+ },
58
+ { immediate: !0 }
59
+ );
60
+ function r(t, c = {}) {
61
+ if (t.type === "text")
62
+ return t.value;
63
+ if (t.type === "comment")
64
+ return null;
65
+ if (t.type === "root") {
66
+ const a = t.children.map((l) => r(l, c)).filter((l) => l !== null);
67
+ return p("div", { class: e.class }, a);
68
+ }
69
+ if (t.type === "element") {
70
+ const { tagName: a, properties: l, children: i } = t, u = c[a] || a, f = {};
71
+ if (l)
72
+ for (const [m, s] of Object.entries(l))
73
+ m === "className" ? f.class = Array.isArray(s) ? s.join(" ") : s : f[m] = s;
74
+ const d = i.map((m) => r(m, c)).filter((m) => m !== null);
75
+ return typeof u == "string" ? p(u, f, d) : p(u, f, () => d);
76
+ }
77
+ return null;
78
+ }
79
+ const n = A(() => {
80
+ if (!e.content) return null;
81
+ const t = F(e.content, {
82
+ gfm: e.gfm,
83
+ highlight: e.highlight,
84
+ math: e.math,
85
+ remarkPlugins: e.remarkPlugins,
86
+ rehypePlugins: e.rehypePlugins
87
+ });
88
+ return r(t, e.components);
89
+ });
90
+ return () => n.value ? n.value : null;
91
+ }
92
+ });
93
+ function U(e, r) {
94
+ if (e.type === "text")
95
+ return e.value;
96
+ if (e.type === "root") {
97
+ const n = e.children.map((t) => U(t, r)).filter((t) => t !== null);
98
+ return p("div", {}, n);
99
+ }
100
+ if (e.type === "element") {
101
+ const n = e, t = n.tagName, c = r == null ? void 0 : r[t], a = { ...n.properties };
102
+ a.className && (a.class = Array.isArray(a.className) ? a.className.join(" ") : a.className, delete a.className);
103
+ const l = n.children.map((i) => U(i, r)).filter((i) => i !== null);
104
+ return c ? p(c, a, () => l) : p(t, a, l);
105
+ }
106
+ return null;
107
+ }
108
+ function Y(e = {}) {
109
+ const {
110
+ components: r,
111
+ minUpdateInterval: n = 16,
112
+ immediate: t = !1,
113
+ outputRate: c = "medium",
114
+ ...a
115
+ } = e, l = T(a), i = new R(c), u = y(0), f = y(!1), d = y(0), m = y("idle");
116
+ let s = 0, o = null;
117
+ const v = () => {
118
+ const h = performance.now(), C = h - s;
119
+ t || C >= n ? (s = h, u.value++) : o === null && (o = requestAnimationFrame(() => {
120
+ o = null, s = performance.now(), u.value++;
121
+ }));
122
+ }, g = (h) => {
123
+ l.append(h), v();
124
+ }, k = (h) => {
125
+ l.reset(), f.value = !1, d.value = 0, m.value = "running", i.start(
126
+ h,
127
+ (C) => {
128
+ C && l.append(C), d.value = i.progress, v();
129
+ },
130
+ () => {
131
+ l.finish(), f.value = !0, d.value = 1, m.value = "complete", v();
132
+ }
133
+ );
134
+ }, x = () => {
135
+ i.pause(), m.value = i.status;
136
+ }, w = () => {
137
+ i.resume(), m.value = i.status;
138
+ }, I = () => {
139
+ i.skipToEnd(), m.value = i.status, d.value = 1;
140
+ }, K = () => {
141
+ i.stop(), l.finish(), f.value = !0, m.value = "complete", o !== null && (cancelAnimationFrame(o), o = null), u.value++;
142
+ }, L = () => {
143
+ i.stop(), l.reset(), f.value = !1, d.value = 0, m.value = "idle", o !== null && (cancelAnimationFrame(o), o = null), u.value++;
144
+ };
145
+ O(() => {
146
+ i.stop(), o !== null && cancelAnimationFrame(o);
147
+ });
148
+ const $ = A(() => (u.value, l.getState().blocks)), H = A(() => (u.value, l.getStats())), W = A(() => (u.value, l.getContent()));
149
+ return {
150
+ vnode: A(() => {
151
+ u.value;
152
+ const h = l.getState();
153
+ if (h.blocks.length === 0)
154
+ return null;
155
+ const C = h.blocks.map((N) => N.hast ? p(
156
+ "div",
157
+ {
158
+ key: N.key,
159
+ "data-block-key": N.key,
160
+ "data-pending": !N.stable || void 0
161
+ },
162
+ [U(N.hast, r)]
163
+ ) : null).filter((N) => N !== null);
164
+ return p("div", { "data-streaming": !f.value }, C);
165
+ }),
166
+ append: g,
167
+ start: k,
168
+ pause: x,
169
+ resume: w,
170
+ skipToEnd: I,
171
+ reset: L,
172
+ finish: K,
173
+ blocks: $,
174
+ stats: H,
175
+ isComplete: f,
176
+ content: W,
177
+ progress: d,
178
+ outputStatus: m
179
+ };
180
+ }
181
+ function j(e, r) {
182
+ if (e.type === "text")
183
+ return e.value;
184
+ if (e.type === "root") {
185
+ const n = e.children.map((t) => j(t, r)).filter((t) => t !== null);
186
+ return p("div", {}, n);
187
+ }
188
+ if (e.type === "element") {
189
+ const n = e, t = n.tagName, c = r == null ? void 0 : r[t], a = { ...n.properties };
190
+ a.className && (a.class = Array.isArray(a.className) ? a.className.join(" ") : a.className, delete a.className);
191
+ const l = n.children.map((i) => j(i, r)).filter((i) => i !== null);
192
+ return c ? p(c, a, () => l) : p(t, a, l);
193
+ }
194
+ return null;
195
+ }
196
+ const E = M({
197
+ name: "StreamingMarkdown",
198
+ props: {
199
+ content: {
200
+ type: String,
201
+ default: void 0
202
+ },
203
+ source: {
204
+ type: String,
205
+ default: void 0
206
+ },
207
+ outputRate: {
208
+ type: [String, Object],
209
+ default: "medium"
210
+ },
211
+ isComplete: {
212
+ type: Boolean,
213
+ default: !1
214
+ },
215
+ components: {
216
+ type: Object,
217
+ default: void 0
218
+ },
219
+ class: {
220
+ type: String,
221
+ default: void 0
222
+ },
223
+ minUpdateInterval: {
224
+ type: Number,
225
+ default: 16
226
+ },
227
+ autoStart: {
228
+ type: Boolean,
229
+ default: !0
230
+ },
231
+ gfm: {
232
+ type: Boolean,
233
+ default: !0
234
+ },
235
+ highlight: {
236
+ type: Boolean,
237
+ default: !0
238
+ },
239
+ math: {
240
+ type: Boolean,
241
+ default: !1
242
+ }
243
+ },
244
+ emits: ["complete", "blockStable", "progress"],
245
+ setup(e, { emit: r }) {
246
+ S(
247
+ () => e.math,
248
+ (s) => {
249
+ s && V();
250
+ },
251
+ { immediate: !0 }
252
+ );
253
+ const n = T({
254
+ gfm: e.gfm,
255
+ highlight: e.highlight,
256
+ math: e.math
257
+ }), t = new R(e.outputRate), c = y(0), a = y(""), l = y(void 0), i = y([]), u = y(!1);
258
+ let f = 0, d = null;
259
+ const m = () => {
260
+ const s = performance.now();
261
+ s - f >= e.minUpdateInterval ? (f = s, c.value++) : d === null && (d = requestAnimationFrame(() => {
262
+ d = null, f = performance.now(), c.value++;
263
+ }));
264
+ };
265
+ return S(
266
+ () => e.source,
267
+ (s) => {
268
+ s !== void 0 && s !== l.value && (l.value = s, e.autoStart && s && (n.reset(), a.value = "", u.value = !1, t.start(
269
+ s,
270
+ (o) => {
271
+ o && (n.append(o), a.value += o), r("progress", t.progress), m();
272
+ },
273
+ () => {
274
+ n.finish(), u.value = !0, r("complete"), m();
275
+ }
276
+ )));
277
+ },
278
+ { immediate: !0 }
279
+ ), S(
280
+ () => e.content,
281
+ (s) => {
282
+ if (e.source !== void 0)
283
+ return;
284
+ const o = a.value, v = s || "";
285
+ if (v !== o) {
286
+ if (v.startsWith(o)) {
287
+ const k = v.slice(o.length);
288
+ k && n.append(k);
289
+ } else
290
+ n.reset(), v && n.append(v);
291
+ a.value = v, m();
292
+ const g = n.getState().blocks;
293
+ g.forEach((k, x) => {
294
+ const w = i.value[x];
295
+ k.stable && (!w || !w.stable) && r("blockStable", k);
296
+ }), i.value = g;
297
+ }
298
+ },
299
+ { immediate: !0 }
300
+ ), S(
301
+ () => e.isComplete,
302
+ (s) => {
303
+ e.source === void 0 && s && (n.finish(), d !== null && (cancelAnimationFrame(d), d = null), c.value++, r("complete"));
304
+ }
305
+ ), S(
306
+ () => e.outputRate,
307
+ (s) => {
308
+ t.setRate(s);
309
+ }
310
+ ), O(() => {
311
+ t.stop(), d !== null && cancelAnimationFrame(d);
312
+ }), () => {
313
+ c.value;
314
+ const s = n.getState(), o = e.source !== void 0 ? u.value : e.isComplete, v = s.blocks.map((g) => g.hast ? p(
315
+ "div",
316
+ {
317
+ key: g.key,
318
+ "data-block-key": g.key,
319
+ "data-pending": !g.stable || void 0
320
+ },
321
+ [j(g.hast, e.components)]
322
+ ) : null).filter((g) => g !== null);
323
+ return p(
324
+ "div",
325
+ {
326
+ class: e.class,
327
+ "data-streaming": !o
328
+ },
329
+ v
330
+ );
331
+ };
332
+ }
333
+ });
334
+ function P(e, r = {}) {
335
+ if (e.type === "text")
336
+ return e.value;
337
+ if (e.type === "comment")
338
+ return null;
339
+ if (e.type === "root") {
340
+ const n = e.children.map((t) => P(t, r)).filter((t) => t !== null);
341
+ return p("div", {}, n);
342
+ }
343
+ if (e.type === "element") {
344
+ const { tagName: n, properties: t, children: c } = e, a = r[n] || n, l = {};
345
+ if (t)
346
+ for (const [u, f] of Object.entries(t))
347
+ u === "className" ? l.class = Array.isArray(f) ? f.join(" ") : f : l[u] = f;
348
+ const i = c.map((u) => P(u, r)).filter((u) => u !== null);
349
+ return p(a, l, () => i);
350
+ }
351
+ return null;
352
+ }
353
+ function Z(e, r = {}) {
354
+ const { components: n = {}, ...t } = r;
355
+ return A(() => {
356
+ const c = e();
357
+ if (!c) return null;
358
+ const a = F(c, t);
359
+ return P(a, n);
360
+ });
361
+ }
362
+ function D(e) {
363
+ e.component("Markdown", q), e.component("StreamingMarkdown", E);
364
+ }
365
+ const _ = {
366
+ install: D,
367
+ Markdown: q,
368
+ StreamingMarkdown: E
369
+ };
370
+ export {
371
+ q as Markdown,
372
+ E as StreamingMarkdown,
373
+ _ as default,
374
+ D as install,
375
+ X as isKatexCssLoaded,
376
+ V as preloadKatexCss,
377
+ Z as useMarkdown,
378
+ Y as useStreamingMarkdown
379
+ };
@@ -0,0 +1,117 @@
1
+ import { PropType, VNode } from 'vue';
2
+ import { OutputRate } from '@superlc/md-core';
3
+ import { MarkdownComponents } from '../types';
4
+
5
+ /**
6
+ * 流式 Markdown 渲染组件
7
+ */
8
+ export declare const StreamingMarkdown: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
9
+ content: {
10
+ type: StringConstructor;
11
+ default: undefined;
12
+ };
13
+ source: {
14
+ type: StringConstructor;
15
+ default: undefined;
16
+ };
17
+ outputRate: {
18
+ type: PropType<OutputRate>;
19
+ default: string;
20
+ };
21
+ isComplete: {
22
+ type: BooleanConstructor;
23
+ default: boolean;
24
+ };
25
+ components: {
26
+ type: PropType<MarkdownComponents>;
27
+ default: undefined;
28
+ };
29
+ class: {
30
+ type: StringConstructor;
31
+ default: undefined;
32
+ };
33
+ minUpdateInterval: {
34
+ type: NumberConstructor;
35
+ default: number;
36
+ };
37
+ autoStart: {
38
+ type: BooleanConstructor;
39
+ default: boolean;
40
+ };
41
+ gfm: {
42
+ type: BooleanConstructor;
43
+ default: boolean;
44
+ };
45
+ highlight: {
46
+ type: BooleanConstructor;
47
+ default: boolean;
48
+ };
49
+ math: {
50
+ type: BooleanConstructor;
51
+ default: boolean;
52
+ };
53
+ }>, () => VNode<import('vue').RendererNode, import('vue').RendererElement, {
54
+ [key: string]: any;
55
+ }>, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, ("progress" | "complete" | "blockStable")[], "progress" | "complete" | "blockStable", import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
56
+ content: {
57
+ type: StringConstructor;
58
+ default: undefined;
59
+ };
60
+ source: {
61
+ type: StringConstructor;
62
+ default: undefined;
63
+ };
64
+ outputRate: {
65
+ type: PropType<OutputRate>;
66
+ default: string;
67
+ };
68
+ isComplete: {
69
+ type: BooleanConstructor;
70
+ default: boolean;
71
+ };
72
+ components: {
73
+ type: PropType<MarkdownComponents>;
74
+ default: undefined;
75
+ };
76
+ class: {
77
+ type: StringConstructor;
78
+ default: undefined;
79
+ };
80
+ minUpdateInterval: {
81
+ type: NumberConstructor;
82
+ default: number;
83
+ };
84
+ autoStart: {
85
+ type: BooleanConstructor;
86
+ default: boolean;
87
+ };
88
+ gfm: {
89
+ type: BooleanConstructor;
90
+ default: boolean;
91
+ };
92
+ highlight: {
93
+ type: BooleanConstructor;
94
+ default: boolean;
95
+ };
96
+ math: {
97
+ type: BooleanConstructor;
98
+ default: boolean;
99
+ };
100
+ }>> & Readonly<{
101
+ onProgress?: ((...args: any[]) => any) | undefined;
102
+ onComplete?: ((...args: any[]) => any) | undefined;
103
+ onBlockStable?: ((...args: any[]) => any) | undefined;
104
+ }>, {
105
+ content: string;
106
+ components: MarkdownComponents;
107
+ class: string;
108
+ gfm: boolean;
109
+ highlight: boolean;
110
+ math: boolean;
111
+ source: string;
112
+ minUpdateInterval: number;
113
+ outputRate: OutputRate;
114
+ isComplete: boolean;
115
+ autoStart: boolean;
116
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
117
+ //# sourceMappingURL=StreamingMarkdown.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StreamingMarkdown.d.ts","sourceRoot":"","sources":["../../src/streaming/StreamingMarkdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,QAAQ,EACb,KAAK,KAAK,EACX,MAAM,KAAK,CAAC;AACb,OAAO,EAML,KAAK,UAAU,EAChB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAgDnD;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;cAaE,QAAQ,CAAC,UAAU,CAAC;;;;;;;;cAQ9B,QAAQ,CAAC,kBAAkB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cARlB,QAAQ,CAAC,UAAU,CAAC;;;;;;;;cAQ9B,QAAQ,CAAC,kBAAkB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4EA2NhD,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * 流式渲染模块
3
+ */
4
+ export { useStreamingMarkdown } from './useStreamingMarkdown';
5
+ export { StreamingMarkdown } from './StreamingMarkdown';
6
+ export type { UseStreamingMarkdownOptions, UseStreamingMarkdownResult, StreamingMarkdownProps, StreamingMarkdownEmits, } from './types';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/streaming/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,YAAY,EACV,2BAA2B,EAC3B,0BAA0B,EAC1B,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,SAAS,CAAC"}
@@ -0,0 +1,83 @@
1
+ import { VNode, Ref } from 'vue';
2
+ import { StreamingParserOptions, ParserStats, BlockInfo, OutputRate, OutputRateStatus } from '@superlc/md-core';
3
+ import { MarkdownComponents } from '../types';
4
+
5
+ /**
6
+ * useStreamingMarkdown Composable 配置
7
+ */
8
+ export interface UseStreamingMarkdownOptions extends StreamingParserOptions {
9
+ /** 自定义组件映射 */
10
+ components?: MarkdownComponents;
11
+ /** 最小更新间隔 (ms),默认 16 (约 60fps) */
12
+ minUpdateInterval?: number;
13
+ /** 是否禁用批处理,每次 append 立即更新 */
14
+ immediate?: boolean;
15
+ /** 输出速率配置 */
16
+ outputRate?: OutputRate;
17
+ }
18
+ /**
19
+ * useStreamingMarkdown Composable 返回值
20
+ */
21
+ export interface UseStreamingMarkdownResult {
22
+ /** 渲染后的 VNode */
23
+ vnode: Ref<VNode | null>;
24
+ /** 追加内容(手动模式) */
25
+ append: (chunk: string) => void;
26
+ /** 开始按速率输出(速率控制模式) */
27
+ start: (source: string) => void;
28
+ /** 暂停输出 */
29
+ pause: () => void;
30
+ /** 恢复输出 */
31
+ resume: () => void;
32
+ /** 跳过到结束 */
33
+ skipToEnd: () => void;
34
+ /** 重置解析器 */
35
+ reset: () => void;
36
+ /** 标记完成 */
37
+ finish: () => void;
38
+ /** 当前块信息 */
39
+ blocks: Ref<BlockInfo[]>;
40
+ /** 性能统计 */
41
+ stats: Ref<ParserStats>;
42
+ /** 是否已完成 */
43
+ isComplete: Ref<boolean>;
44
+ /** 累积的内容 */
45
+ content: Ref<string>;
46
+ /** 输出进度 (0-1) */
47
+ progress: Ref<number>;
48
+ /** 输出状态 */
49
+ outputStatus: Ref<OutputRateStatus>;
50
+ }
51
+ /**
52
+ * StreamingMarkdown 组件 Props
53
+ */
54
+ export interface StreamingMarkdownProps extends StreamingParserOptions {
55
+ /** 当前累积的 Markdown 内容(外部控制模式) */
56
+ content?: string;
57
+ /** 完整的 Markdown 源内容(内置速率控制模式) */
58
+ source?: string;
59
+ /** 输出速率配置,默认 'medium' */
60
+ outputRate?: OutputRate;
61
+ /** 是否已完成流式输入 */
62
+ isComplete?: boolean;
63
+ /** 自定义组件映射 */
64
+ components?: MarkdownComponents;
65
+ /** 容器 class */
66
+ class?: string;
67
+ /** 最小更新间隔 (ms) */
68
+ minUpdateInterval?: number;
69
+ /** 是否自动开始输出(仅 source 模式) */
70
+ autoStart?: boolean;
71
+ }
72
+ /**
73
+ * StreamingMarkdown 组件 Emits
74
+ */
75
+ export interface StreamingMarkdownEmits {
76
+ /** 完成事件 */
77
+ (e: 'complete'): void;
78
+ /** 块稳定事件 */
79
+ (e: 'blockStable', block: BlockInfo): void;
80
+ /** 进度变化事件 */
81
+ (e: 'progress', progress: number): void;
82
+ }
83
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/streaming/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AACtC,OAAO,KAAK,EAAE,sBAAsB,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACrH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAEnD;;GAEG;AACH,MAAM,WAAW,2BAA4B,SAAQ,sBAAsB;IACzE,cAAc;IACd,UAAU,CAAC,EAAE,kBAAkB,CAAC;IAChC,kCAAkC;IAClC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,6BAA6B;IAC7B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,aAAa;IACb,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,iBAAiB;IACjB,KAAK,EAAE,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC;IACzB,iBAAiB;IACjB,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,sBAAsB;IACtB,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,WAAW;IACX,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,WAAW;IACX,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,YAAY;IACZ,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,YAAY;IACZ,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,WAAW;IACX,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,YAAY;IACZ,MAAM,EAAE,GAAG,CAAC,SAAS,EAAE,CAAC,CAAC;IACzB,WAAW;IACX,KAAK,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC;IACxB,YAAY;IACZ,UAAU,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IACzB,YAAY;IACZ,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACrB,iBAAiB;IACjB,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACtB,WAAW;IACX,YAAY,EAAE,GAAG,CAAC,gBAAgB,CAAC,CAAC;CACrC;AAED;;GAEG;AACH,MAAM,WAAW,sBAAuB,SAAQ,sBAAsB;IACpE,gCAAgC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iCAAiC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,yBAAyB;IACzB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,gBAAgB;IAChB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,cAAc;IACd,UAAU,CAAC,EAAE,kBAAkB,CAAC;IAChC,eAAe;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kBAAkB;IAClB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,4BAA4B;IAC5B,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,WAAW;IACX,CAAC,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC;IACtB,YAAY;IACZ,CAAC,CAAC,EAAE,aAAa,EAAE,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;IAC3C,aAAa;IACb,CAAC,CAAC,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzC"}
@@ -0,0 +1,7 @@
1
+ import { UseStreamingMarkdownOptions, UseStreamingMarkdownResult } from './types';
2
+
3
+ /**
4
+ * 流式 Markdown 渲染 Composable
5
+ */
6
+ export declare function useStreamingMarkdown(options?: UseStreamingMarkdownOptions): UseStreamingMarkdownResult;
7
+ //# sourceMappingURL=useStreamingMarkdown.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useStreamingMarkdown.d.ts","sourceRoot":"","sources":["../../src/streaming/useStreamingMarkdown.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,2BAA2B,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAC;AAgDvF;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,GAAE,2BAAgC,GACxC,0BAA0B,CA4K5B"}
@@ -0,0 +1,62 @@
1
+ import { Component } from 'vue';
2
+ import { ProcessorOptions } from '@superlc/md-core';
3
+
4
+ export type { PluginConfig } from '@superlc/md-core';
5
+ /**
6
+ * 自定义组件映射表
7
+ * 可用于覆盖默认 HTML 元素的渲染方式
8
+ */
9
+ export interface MarkdownComponents {
10
+ /** 标题 h1-h6 */
11
+ h1?: Component;
12
+ h2?: Component;
13
+ h3?: Component;
14
+ h4?: Component;
15
+ h5?: Component;
16
+ h6?: Component;
17
+ /** 段落 */
18
+ p?: Component;
19
+ /** 链接 */
20
+ a?: Component;
21
+ /** 图片 */
22
+ img?: Component;
23
+ /** 代码块 */
24
+ pre?: Component;
25
+ code?: Component;
26
+ /** 列表 */
27
+ ul?: Component;
28
+ ol?: Component;
29
+ li?: Component;
30
+ /** 引用 */
31
+ blockquote?: Component;
32
+ /** 表格 */
33
+ table?: Component;
34
+ thead?: Component;
35
+ tbody?: Component;
36
+ tr?: Component;
37
+ th?: Component;
38
+ td?: Component;
39
+ /** 水平线 */
40
+ hr?: Component;
41
+ /** 其他自定义元素 */
42
+ [key: string]: Component | undefined;
43
+ }
44
+ /**
45
+ * Markdown 组件 Props
46
+ */
47
+ export interface MarkdownProps extends ProcessorOptions {
48
+ /** Markdown 源文本 */
49
+ content: string;
50
+ /** 自定义组件映射 */
51
+ components?: MarkdownComponents;
52
+ /** 容器 class */
53
+ class?: string;
54
+ }
55
+ /**
56
+ * useMarkdown Composable 配置
57
+ */
58
+ export interface UseMarkdownOptions extends ProcessorOptions {
59
+ /** 自定义组件映射 */
60
+ components?: MarkdownComponents;
61
+ }
62
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AACrC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAGzD,YAAY,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAErD;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,eAAe;IACf,EAAE,CAAC,EAAE,SAAS,CAAC;IACf,EAAE,CAAC,EAAE,SAAS,CAAC;IACf,EAAE,CAAC,EAAE,SAAS,CAAC;IACf,EAAE,CAAC,EAAE,SAAS,CAAC;IACf,EAAE,CAAC,EAAE,SAAS,CAAC;IACf,EAAE,CAAC,EAAE,SAAS,CAAC;IACf,SAAS;IACT,CAAC,CAAC,EAAE,SAAS,CAAC;IACd,SAAS;IACT,CAAC,CAAC,EAAE,SAAS,CAAC;IACd,SAAS;IACT,GAAG,CAAC,EAAE,SAAS,CAAC;IAChB,UAAU;IACV,GAAG,CAAC,EAAE,SAAS,CAAC;IAChB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,SAAS;IACT,EAAE,CAAC,EAAE,SAAS,CAAC;IACf,EAAE,CAAC,EAAE,SAAS,CAAC;IACf,EAAE,CAAC,EAAE,SAAS,CAAC;IACf,SAAS;IACT,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,SAAS;IACT,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,EAAE,CAAC,EAAE,SAAS,CAAC;IACf,EAAE,CAAC,EAAE,SAAS,CAAC;IACf,EAAE,CAAC,EAAE,SAAS,CAAC;IACf,UAAU;IACV,EAAE,CAAC,EAAE,SAAS,CAAC;IACf,cAAc;IACd,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAAC;CACtC;AAED;;GAEG;AACH,MAAM,WAAW,aAAc,SAAQ,gBAAgB;IACrD,mBAAmB;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc;IACd,UAAU,CAAC,EAAE,kBAAkB,CAAC;IAChC,eAAe;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAmB,SAAQ,gBAAgB;IAC1D,cAAc;IACd,UAAU,CAAC,EAAE,kBAAkB,CAAC;CACjC"}
@@ -0,0 +1,27 @@
1
+ import { VNode, ComputedRef } from 'vue';
2
+ import { UseMarkdownOptions } from './types';
3
+
4
+ /**
5
+ * 将 Markdown 转换为 Vue VNode 的 Composable
6
+ *
7
+ * @param content - Markdown 源文本(响应式 ref 或 getter)
8
+ * @param options - 配置选项
9
+ * @returns 计算属性,返回 Vue VNode
10
+ *
11
+ * @example
12
+ * ```vue
13
+ * <script setup>
14
+ * import { ref } from 'vue';
15
+ * import { useMarkdown } from '@superlc/md-vue';
16
+ *
17
+ * const content = ref('# Hello World');
18
+ * const vnode = useMarkdown(() => content.value);
19
+ * </script>
20
+ *
21
+ * <template>
22
+ * <component :is="vnode" />
23
+ * </template>
24
+ * ```
25
+ */
26
+ export declare function useMarkdown(content: () => string, options?: UseMarkdownOptions): ComputedRef<VNode | null>;
27
+ //# sourceMappingURL=useMarkdown.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMarkdown.d.ts","sourceRoot":"","sources":["../src/useMarkdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,KAAK,EAAE,KAAK,WAAW,EAAE,MAAM,KAAK,CAAC;AAGhE,OAAO,KAAK,EAAE,kBAAkB,EAAsB,MAAM,SAAS,CAAC;AAiDtE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE,MAAM,MAAM,EACrB,OAAO,GAAE,kBAAuB,GAC/B,WAAW,CAAC,KAAK,GAAG,IAAI,CAAC,CAY3B"}
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@superlc/md-vue",
3
+ "version": "0.1.0",
4
+ "description": "基于 @superlc/md-core 的 Vue 3 Markdown 渲染组件",
5
+ "type": "module",
6
+ "main": "./dist/index.cjs",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": "./dist/index.js",
12
+ "require": "./dist/index.cjs",
13
+ "types": "./dist/index.d.ts"
14
+ },
15
+ "./styles.css": "@superlc/md-core/styles.css"
16
+ },
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "scripts": {
21
+ "build": "vite build",
22
+ "dev": "vite build --watch",
23
+ "test": "vitest",
24
+ "test:run": "vitest run"
25
+ },
26
+ "dependencies": {
27
+ "@superlc/md-core": "workspace:*",
28
+ "katex": "^0.16.28"
29
+ },
30
+ "peerDependencies": {
31
+ "vue": ">=3.3.0"
32
+ },
33
+ "devDependencies": {
34
+ "@types/hast": "^3.0.0",
35
+ "vue": "^3.4.0"
36
+ },
37
+ "keywords": [
38
+ "markdown",
39
+ "vue",
40
+ "vue3",
41
+ "component",
42
+ "unified"
43
+ ],
44
+ "license": "MIT"
45
+ }