UNPKG

ant-design-x-vue-next

Version:

Ant Design X for Vue — community continuation aligned with @ant-design/x

39 lines (38 loc) 1.18 kB
import { ref as c, computed as s, toValue as o, watch as v } from "vue"; import { getInitialCache as l, processStreamingText as f } from "../streamCache.mjs"; function k(m, a) { const n = c(""), r = c(l()), p = s(() => { var e, t; return !!((t = (e = o(a)) == null ? void 0 : e.streaming) != null && t.hasNextChunk); }); return v( () => { var e, t; return { text: o(m), enable: p.value, streaming: (e = o(a)) == null ? void 0 : e.streaming, components: (t = o(a)) == null ? void 0 : t.components }; }, ({ text: e, enable: t, streaming: u, components: i }) => { if (typeof e != "string") { console.error(`X-Markdown: input must be string, not ${typeof e}.`), n.value = "", r.value = l(); return; } if (!t) { r.value = l(), n.value = e; return; } n.value = f(r.value, e, { incompleteMarkdownComponentMap: u == null ? void 0 : u.incompleteMarkdownComponentMap, componentNames: Object.keys(i || {}) }); }, { immediate: !0 } ), s(() => p.value ? n.value : o(m) || ""); } export { k as default, k as useStreaming };