dou-ui 0.1.0-alpha.26 → 0.1.0-alpha.27

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.
@@ -1,7 +1,7 @@
1
1
  import { DouAlert } from "../alert/index.js";
2
2
  import { DouChatCitation } from "../chat-sources/index.js";
3
3
  import { DouCodeBlock } from "../code-block/index.js";
4
- import { Fragment, defineComponent, getCurrentInstance, h, inject } from "vue";
4
+ import { Fragment, defineComponent, getCurrentInstance, h, inject, onBeforeUnmount, onMounted, onUpdated, ref } from "vue";
5
5
  import { CheckIcon } from "@dou-ui/icons";
6
6
  // src/components/markdown/render.ts
7
7
  var markdownContextKey = Symbol("dou-markdown");
@@ -293,7 +293,8 @@ function renderDefault(ctx, node, tick, children) {
293
293
  }, children());
294
294
  case "table": {
295
295
  const entering = enter(ctx, node.start);
296
- return h("div", { class: [`${B}__table`, entering] }, children());
296
+ const content = children();
297
+ return h(MarkdownTableView, { entering }, { default: () => content });
297
298
  }
298
299
  case "code": return h(DouCodeBlock, {
299
300
  class: [`${B}__code`, enter(ctx, node.start)],
@@ -378,6 +379,65 @@ var MarkdownBlockView = defineComponent({
378
379
  };
379
380
  }
380
381
  });
382
+ var MarkdownTableView = defineComponent({
383
+ name: "DouMarkdownTable",
384
+ props: { entering: {
385
+ type: String,
386
+ default: void 0
387
+ } },
388
+ setup(props, { slots }) {
389
+ const frameRef = ref(null);
390
+ const cutStart = ref(false);
391
+ const cutEnd = ref(false);
392
+ let observer;
393
+ let observedTable = null;
394
+ function measure() {
395
+ const frame = frameRef.value;
396
+ if (!frame) return;
397
+ const hidden = frame.scrollWidth - frame.clientWidth;
398
+ const left = Math.abs(frame.scrollLeft);
399
+ cutStart.value = left > 1;
400
+ cutEnd.value = left < hidden - 1;
401
+ }
402
+ function syncObservedTable() {
403
+ const frame = frameRef.value;
404
+ if (!observer || !frame) return;
405
+ const table = frame.querySelector("table");
406
+ if (table === observedTable) return;
407
+ if (observedTable) observer.unobserve(observedTable);
408
+ observedTable = table;
409
+ if (observedTable) observer.observe(observedTable);
410
+ }
411
+ onMounted(() => {
412
+ const frame = frameRef.value;
413
+ if (!frame) return;
414
+ measure();
415
+ if (typeof ResizeObserver === "undefined") return;
416
+ observer = new ResizeObserver(measure);
417
+ observer.observe(frame);
418
+ syncObservedTable();
419
+ });
420
+ onUpdated(() => {
421
+ syncObservedTable();
422
+ measure();
423
+ });
424
+ onBeforeUnmount(() => {
425
+ observer?.disconnect();
426
+ observer = void 0;
427
+ observedTable = null;
428
+ });
429
+ return () => h("div", {
430
+ ref: frameRef,
431
+ class: [
432
+ `${B}__table`,
433
+ props.entering,
434
+ cutStart.value && "is-cut-start",
435
+ cutEnd.value && "is-cut-end"
436
+ ],
437
+ onScrollPassive: measure
438
+ }, slots.default?.());
439
+ }
440
+ });
381
441
  var MarkdownRowView = defineComponent({
382
442
  name: "DouMarkdownRow",
383
443
  props: {
@@ -1 +1 @@
1
- {"version":3,"file":"render.js","names":[],"sources":["../../../src/components/markdown/render.ts"],"sourcesContent":["import { CheckIcon } from '@dou-ui/icons'\nimport {\n defineComponent,\n Fragment,\n getCurrentInstance,\n h,\n inject,\n type ComponentInternalInstance,\n type InjectionKey,\n type PropType,\n type VNode,\n type VNodeChild,\n} from 'vue'\nimport type { Tone } from '../../utils/types'\n// through the installable entries, so ConfigProvider defaults reach them\nimport { DouAlert } from '../alert'\nimport { DouChatCitation } from '../chat-sources'\nimport type { ChatSource } from '../chat-sources/chat-sources'\nimport { DouCodeBlock } from '../code-block'\nimport type {\n MarkdownBlock,\n MarkdownContainer,\n MarkdownInline,\n MarkdownItem,\n MarkdownLinkTarget,\n MarkdownRow,\n MarkdownSlots,\n MarkdownUrlKind,\n} from './markdown'\n\n/** One reveal step: the text from `from` on arrived at `time`. */\nexport interface MarkdownCommit {\n from: number\n time: number\n}\n\n/** What the block components share; plain fields are read without tracking. */\nexport interface MarkdownRenderContext {\n readonly streaming: boolean\n readonly sources: ChatSource[] | undefined\n readonly linkTarget: MarkdownLinkTarget\n readonly slots: MarkdownSlots\n sanitize: (url: string, kind: MarkdownUrlKind) => string | undefined\n /** Reveal steps still fading in, oldest first. Empty when nothing animates. */\n commits: MarkdownCommit[]\n /** How long a fade lasts, in ms. */\n duration: number\n /** The time of the render in progress. */\n now: number\n /** `animation-delay` of each fading span, fixed when it is first drawn. */\n delays: Map<string, string>\n /** The block the caret follows, while streaming. */\n caret: object | null\n /** The block the `trailing` slot follows, when it is given. */\n end: object | null\n /** The block or row being drawn. */\n drawing: ComponentInternalInstance | null\n /** Blocks and rows drawn with fading spans, to draw again once the fades end. */\n fading: Set<ComponentInternalInstance>\n}\n\nexport const markdownContextKey: InjectionKey<MarkdownRenderContext> = Symbol('dou-markdown')\n\nconst B = 'dou-markdown'\ntype AnySlot = (props: Record<string, unknown>) => unknown\n\n/** The slot for a kind of node, the more specific name first. */\nfunction slotOf(ctx: MarkdownRenderContext, ...names: string[]): AnySlot | undefined {\n const slots = ctx.slots as Record<string, AnySlot | undefined>\n for (const name of names) if (Object.hasOwn(slots, name) && slots[name]) return slots[name]\n return undefined\n}\n\nconst group = (children: VNodeChild[]) => h(Fragment, children)\nconst output = (value: unknown) => h(Fragment, value as VNode[])\n\n// sources with their address checked, kept per source so citations stay the same object\nconst checkedSources = new WeakMap<ChatSource, { url?: string; source: ChatSource }>()\nfunction checkedSource(ctx: MarkdownRenderContext, source: ChatSource): ChatSource {\n if (!source.url) return source\n const hit = checkedSources.get(source)\n if (hit && hit.url === source.url) return hit.source\n const url = ctx.sanitize(source.url, 'source')\n const next = url === source.url ? source : { ...source, url }\n checkedSources.set(source, { url: source.url, source: next })\n return next\n}\nconst FRESH = `${B}__fresh`\nconst ENTER = `${B}__enter`\n\n/** The reveal step `offset` belongs to, while it is still fading. */\nfunction stepOf(ctx: MarkdownRenderContext, offset: number): MarkdownCommit | undefined {\n const commits = ctx.commits\n if (!commits.length || offset < commits[0]!.from) return undefined\n let found: MarkdownCommit | undefined\n for (const commit of commits) {\n if (commit.from > offset) break\n found = commit\n }\n return found && ctx.now - found.time < ctx.duration ? found : undefined\n}\n\n/** Class for a block that fades in as a whole when it first shows. */\nfunction enter(ctx: MarkdownRenderContext, offset: number): string | undefined {\n return stepOf(ctx, offset) ? ENTER : undefined\n}\n\nfunction caretNode() {\n return h('span', { class: `${B}__caret`, 'aria-hidden': 'true' })\n}\n\n/** The caret and the `trailing` slot, after the last word of `owner`. */\nfunction tail(ctx: MarkdownRenderContext, owner: object, out: VNodeChild[]) {\n if (ctx.caret === owner) out.push(caretNode())\n if (ctx.end === owner && ctx.slots.trailing)\n out.push(h('span', { class: `${B}__trailing` }, ctx.slots.trailing() as VNode[]))\n}\n\n/** Text, with the parts that are still fading in wrapped in spans. */\nfunction text(\n ctx: MarkdownRenderContext,\n value: string,\n at: number,\n out: VNodeChild[],\n fade: boolean,\n) {\n const commits = ctx.commits\n const end = at + value.length\n if (!fade || !commits.length || end <= commits[0]!.from) {\n out.push(value)\n return\n }\n let pos = 0\n for (let k = 0; k < commits.length; k++) {\n const commit = commits[k]!\n const to = commits[k + 1]?.from ?? Infinity\n const s = Math.max(commit.from, at) - at\n const e = Math.min(to, end) - at\n if (e <= s) continue\n if (s > pos) out.push(value.slice(pos, s))\n const age = ctx.now - commit.time\n if (age >= ctx.duration) out.push(value.slice(s, e))\n else {\n const key = `${at}:${commit.from}`\n let delay = ctx.delays.get(key)\n if (delay === undefined) {\n // drawn again from scratch, it picks up where the fade is\n delay = age >= 1 ? `${-Math.round(age)}ms` : ''\n ctx.delays.set(key, delay)\n }\n if (ctx.drawing) ctx.fading.add(ctx.drawing)\n out.push(\n h(\n 'span',\n { key, class: FRESH, style: delay ? { animationDelay: delay } : undefined },\n value.slice(s, e),\n ),\n )\n }\n pos = e\n }\n if (pos < value.length) out.push(value.slice(pos))\n}\n\n/** `[1]`, `[^1]`, `[1, 2]`, `[1、2]`. */\nconst CITATION = /\\[\\^?(\\d{1,3}(?:[ \\t]*[,,、][ \\t]*\\d{1,3})*)\\]/g\n// `a[1].b` or `m[1](x)` is code, not a citation\nconst CODE_BEFORE = /[A-Za-z0-9_)]/\nconst CODE_AFTER = /[A-Za-z0-9_.(=]/\n\nfunction citation(ctx: MarkdownRenderContext, index: number, source: ChatSource, at: number) {\n const checked = checkedSource(ctx, source)\n const slot = ctx.slots.citation\n if (slot)\n return h(Fragment, { key: `c${at}:${index}` }, slot({ index, source: checked }) as VNode[])\n return h(DouChatCitation, {\n key: `c${at}:${index}`,\n class: stepOf(ctx, at) ? ENTER : undefined,\n index,\n source: checked,\n })\n}\n\nfunction textWithCitations(\n ctx: MarkdownRenderContext,\n value: string,\n at: number,\n out: VNodeChild[],\n fade: boolean,\n) {\n const sources = ctx.sources\n if (!sources?.length || !value.includes('[')) {\n text(ctx, value, at, out, fade)\n return\n }\n let last = 0\n for (const match of value.matchAll(CITATION)) {\n const end = match.index + match[0].length\n if (CODE_BEFORE.test(value[match.index - 1] ?? '') && CODE_AFTER.test(value[end] ?? ''))\n continue\n const indexes = match[1]!.split(/[ \\t]*[,,、][ \\t]*/).map(Number)\n // a number without a source leaves the whole bracket as text\n if (!indexes.every((index) => index >= 1 && sources[index - 1])) continue\n if (match.index > last) text(ctx, value.slice(last, match.index), at + last, out, fade)\n for (const index of indexes)\n out.push(citation(ctx, index, sources[index - 1]!, at + match.index))\n last = end\n }\n if (last < value.length) text(ctx, value.slice(last), at + last, out, fade)\n}\n\n/** A full address, which opens at `linkTarget`; relative ones and anchors open in place. */\nconst isExternal = (href: string) => /^(?:https?:)?\\/\\//i.test(href)\n\nfunction inlines(\n ctx: MarkdownRenderContext,\n nodes: MarkdownInline[],\n fade: boolean,\n out: VNodeChild[] = [],\n inLink = false,\n): VNodeChild[] {\n for (const node of nodes) {\n switch (node.type) {\n case 'text':\n // a citation is a link itself, so none inside a link\n if (inLink) text(ctx, node.value, node.at, out, fade)\n else textWithCitations(ctx, node.value, node.at, out, fade)\n break\n case 'code': {\n const slot = ctx.slots['inline-code']\n out.push(\n slot\n ? output(slot({ code: node.value }))\n : h('code', { class: fade ? enter(ctx, node.at) : undefined }, node.value),\n )\n break\n }\n case 'strong':\n case 'em':\n case 'del': {\n const children = inlines(ctx, node.children, fade, [], inLink)\n const slot = ctx.slots[node.type]\n out.push(slot ? output(slot({ children: group(children) })) : h(node.type, children))\n break\n }\n case 'link': {\n const children = inlines(ctx, node.children, fade, [], true)\n // `[a]()` links nowhere: plain text\n if (node.href === '' && !ctx.slots.link) {\n out.push(...children)\n break\n }\n const href = node.href === undefined ? undefined : ctx.sanitize(node.href, 'link')\n const external = href !== undefined && isExternal(href)\n const slot = ctx.slots.link\n if (slot) {\n out.push(\n output(slot({ node, href, title: node.title, external, children: group(children) })),\n )\n break\n }\n if (href === undefined) {\n // an address still being written, or one that was dropped\n out.push(h('span', { class: `${B}__link` }, children))\n break\n }\n const target = external && ctx.linkTarget !== '_self' ? ctx.linkTarget : undefined\n out.push(\n h(\n 'a',\n {\n href,\n title: node.title,\n target,\n rel: target ? 'noopener noreferrer' : undefined,\n },\n children,\n ),\n )\n break\n }\n case 'image': {\n const src = ctx.sanitize(node.src, 'image')\n if (src === undefined) {\n if (node.alt) out.push(node.alt)\n break\n }\n const slot = ctx.slots.image\n out.push(\n slot\n ? output(slot({ src, alt: node.alt, title: node.title }))\n : h('img', { src, alt: node.alt, title: node.title, loading: 'lazy' }),\n )\n break\n }\n case 'break':\n out.push(h('br'))\n break\n case 'softbreak':\n if (!node.cjk) out.push('\\n')\n break\n }\n }\n return out\n}\n\nfunction leafContent(\n ctx: MarkdownRenderContext,\n owner: object,\n nodes: MarkdownInline[],\n fade = true,\n): VNodeChild[] {\n const out = inlines(ctx, nodes, fade)\n tail(ctx, owner, out)\n return out\n}\n\nfunction blockList(nodes: MarkdownBlock[], tick: number) {\n return nodes.map((node, index) =>\n h(MarkdownBlockView, {\n key: `${node.type}:${node.start}`,\n node,\n tick: index === nodes.length - 1 ? tick : 0,\n }),\n )\n}\n\nfunction renderItem(ctx: MarkdownRenderContext, item: MarkdownItem, tick: number): VNode {\n const children: VNodeChild[] = []\n const slot = ctx.slots.item\n if (item.checked !== null && !slot) {\n children.push(\n h('span', { class: `${B}__task` }, [\n h('input', {\n type: 'checkbox',\n class: `${B}__checkbox`,\n checked: item.checked,\n disabled: true,\n }),\n item.checked ? h(CheckIcon, { class: `${B}__check`, 'aria-hidden': 'true' }) : null,\n ]),\n )\n }\n const last = item.children.length - 1\n item.children.forEach((child, index) => {\n // a tight list shows its paragraphs without their own spacing\n if (item.tight && child.type === 'paragraph') {\n if (index > 0 && item.children[index - 1]!.type === 'paragraph') children.push(h('br'))\n children.push(...leafContent(ctx, child, child.children))\n } else {\n children.push(\n h(MarkdownBlockView, {\n key: `${child.type}:${child.start}`,\n node: child,\n tick: index === last ? tick : 0,\n }),\n )\n }\n })\n tail(ctx, item, children)\n if (slot) return output(slot({ node: item, checked: item.checked, children: group(children) }))\n return h(\n 'li',\n {\n class: [\n item.checked !== null && `${B}__task-item`,\n enter(ctx, item.start) && `${B}__item-enter`,\n ],\n },\n children,\n )\n}\n\nfunction renderRow(\n ctx: MarkdownRenderContext,\n row: MarkdownRow,\n align: string[],\n cell: 'th' | 'td',\n fade: boolean,\n): VNode {\n const entering = fade ? enter(ctx, row.start) : undefined\n return h(\n 'tr',\n { class: entering },\n row.cells.map((content, index) => {\n const out = inlines(ctx, content, fade && !entering)\n if (index === row.cells.length - 1) tail(ctx, row, out)\n return h(cell, { style: align[index] ? { textAlign: align[index] } : undefined }, out)\n }),\n )\n}\n\n/** Tones of the containers drawn as an Alert when no slot takes them. */\nconst CALLOUTS = new Map<string, Tone>([\n ['note', 'neutral'],\n ['info', 'primary'],\n ['tip', 'success'],\n ['warning', 'warning'],\n ['danger', 'danger'],\n])\n\nfunction renderContainer(ctx: MarkdownRenderContext, node: MarkdownContainer, tick: number) {\n const entering = enter(ctx, node.start)\n const tone = CALLOUTS.get(node.name)\n if (tone)\n return h(\n DouAlert,\n // the content is part of the text, not an announcement\n { class: [`${B}__callout`, entering], tone, title: node.title || undefined, role: 'note' },\n { default: () => blockList(node.children, tick) },\n )\n return h('div', { class: [`${B}__container`, entering], 'data-name': node.name }, [\n node.title ? h('p', { class: `${B}__container-title` }, node.title) : null,\n ...blockList(node.children, tick),\n ])\n}\n\nfunction renderDefault(\n ctx: MarkdownRenderContext,\n node: MarkdownBlock,\n tick: number,\n children: () => VNodeChild[],\n): VNode {\n switch (node.type) {\n case 'paragraph':\n return h('p', children())\n case 'heading':\n return h(`h${node.level}`, children())\n case 'hr':\n return h('hr', { class: enter(ctx, node.start) })\n case 'blockquote':\n return h('blockquote', { class: enter(ctx, node.start) }, children())\n case 'list':\n return h(\n node.ordered ? 'ol' : 'ul',\n {\n start: node.ordered && node.startNumber !== 1 ? node.startNumber : undefined,\n class: node.children.every((item) => item.checked !== null)\n ? `${B}__task-list`\n : undefined,\n },\n children(),\n )\n case 'table': {\n const entering = enter(ctx, node.start)\n return h('div', { class: [`${B}__table`, entering] }, children())\n }\n case 'code':\n return h(DouCodeBlock, {\n class: [`${B}__code`, enter(ctx, node.start)],\n code: node.value,\n lang: node.lang || 'text',\n streaming: ctx.streaming && !node.closed,\n })\n case 'container':\n return renderContainer(ctx, node, tick)\n }\n}\n\nfunction renderTable(\n ctx: MarkdownRenderContext,\n node: Extract<MarkdownBlock, { type: 'table' }>,\n tick: number,\n) {\n const fade = !enter(ctx, node.start)\n return h('table', [\n h('thead', [renderRow(ctx, node.head, node.align, 'th', fade)]),\n node.rows.length\n ? h(\n 'tbody',\n node.rows.map((row, index) =>\n h(MarkdownRowView, {\n key: row.start,\n row,\n align: node.align,\n fade,\n tick: index === node.rows.length - 1 ? tick : 0,\n }),\n ),\n )\n : null,\n ])\n}\n\n/** What a block holds: its text, or the blocks inside it. */\nfunction inner(ctx: MarkdownRenderContext, node: MarkdownBlock, tick: number): VNodeChild[] {\n switch (node.type) {\n case 'paragraph':\n case 'heading':\n return leafContent(ctx, node, node.children)\n case 'blockquote':\n case 'container':\n return blockList(node.children, tick)\n case 'list':\n return node.children.map((item, index) =>\n h(MarkdownBlockView, {\n key: `item:${item.start}`,\n node: item,\n tick: index === node.children.length - 1 ? tick : 0,\n }),\n )\n case 'table':\n return [renderTable(ctx, node, tick)]\n default:\n return []\n }\n}\n\nfunction renderBlock(ctx: MarkdownRenderContext, node: MarkdownBlock, tick: number): VNode {\n const slot =\n node.type === 'code'\n ? slotOf(ctx, `code-${node.lang}`, 'code')\n : node.type === 'container'\n ? slotOf(ctx, `container-${node.name}`, 'container')\n : slotOf(ctx, node.type)\n if (!slot) return renderDefault(ctx, node, tick, () => inner(ctx, node, tick))\n const streaming = ctx.streaming && 'closed' in node && !node.closed\n const props: Record<string, unknown> =\n node.type === 'code'\n ? { node, code: node.value, lang: node.lang, streaming }\n : node.type === 'container'\n ? { node, name: node.name, title: node.title, streaming }\n : node.type === 'heading'\n ? { node, level: node.level }\n : { node }\n if (node.type !== 'code' && node.type !== 'hr') props.children = group(inner(ctx, node, tick))\n // the slot's content takes the block's spacing and fades in like the block would\n return h(\n 'div',\n {\n class: [\n `${B}__custom`,\n node.type !== 'paragraph' && node.type !== 'heading' && enter(ctx, node.start),\n ],\n },\n slot(props) as VNode[],\n )\n}\n\n/**\n * One block. Its only input is the block object, which the parser hands\n * back unchanged while the block stays the same, so Vue skips it; `tick`\n * reaches only the last block on each level, which is where the stream\n * grows and where the caret sits.\n */\nexport const MarkdownBlockView = defineComponent({\n name: 'DouMarkdownBlock',\n props: {\n node: { type: Object as PropType<MarkdownBlock | MarkdownItem>, required: true },\n tick: { type: Number, default: 0 },\n },\n setup(props) {\n const ctx = inject(markdownContextKey)!\n const self = getCurrentInstance()\n return () => {\n ctx.drawing = self\n return props.node.type === 'item'\n ? renderItem(ctx, props.node, props.tick)\n : renderBlock(ctx, props.node, props.tick)\n }\n },\n})\n\nconst MarkdownRowView = defineComponent({\n name: 'DouMarkdownRow',\n props: {\n row: { type: Object as PropType<MarkdownRow>, required: true },\n align: { type: Array as PropType<string[]>, required: true },\n fade: { type: Boolean, default: true },\n tick: { type: Number, default: 0 },\n },\n setup(props) {\n const ctx = inject(markdownContextKey)!\n const self = getCurrentInstance()\n return () => {\n ctx.drawing = self\n return renderRow(ctx, props.row, props.align, 'td', props.fade)\n }\n },\n})\n\n/** A run of blocks. Runs that are complete keep the same array, so a long document re-renders only its end. */\nexport const MarkdownChunkView = defineComponent({\n name: 'DouMarkdownChunk',\n props: {\n blocks: { type: Array as PropType<MarkdownBlock[]>, required: true },\n tick: { type: Number, default: 0 },\n },\n setup(props) {\n return () => h(Fragment, blockList(props.blocks, props.tick))\n },\n})\n"],"mappings":";;;;;;AA6DA,IAAa,qBAA0D,OAAO,cAAc;AAE5F,IAAM,IAAI;;AAIV,SAAS,OAAO,KAA4B,GAAG,OAAsC;CACnF,MAAM,QAAQ,IAAI;CAClB,KAAK,MAAM,QAAQ,OAAO,IAAI,OAAO,OAAO,OAAO,IAAI,KAAK,MAAM,OAAO,OAAO,MAAM;AAExF;AAEA,IAAM,SAAS,aAA2B,EAAE,UAAU,QAAQ;AAC9D,IAAM,UAAU,UAAmB,EAAE,UAAU,KAAgB;AAG/D,IAAM,iCAAiB,IAAI,QAA0D;AACrF,SAAS,cAAc,KAA4B,QAAgC;CACjF,IAAI,CAAC,OAAO,KAAK,OAAO;CACxB,MAAM,MAAM,eAAe,IAAI,MAAM;CACrC,IAAI,OAAO,IAAI,QAAQ,OAAO,KAAK,OAAO,IAAI;CAC9C,MAAM,MAAM,IAAI,SAAS,OAAO,KAAK,QAAQ;CAC7C,MAAM,OAAO,QAAQ,OAAO,MAAM,SAAS;EAAE,GAAG;EAAQ;CAAI;CAC5D,eAAe,IAAI,QAAQ;EAAE,KAAK,OAAO;EAAK,QAAQ;CAAK,CAAC;CAC5D,OAAO;AACT;AACA,IAAM,QAAQ,GAAG,EAAE;AACnB,IAAM,QAAQ,GAAG,EAAE;;AAGnB,SAAS,OAAO,KAA4B,QAA4C;CACtF,MAAM,UAAU,IAAI;CACpB,I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AAE;CACnC;CACA,MAAM,OAAO;EACX,MAAM,MAAM,OAAO,kBAAkB;EACrC,MAAM,OAAO,mBAAmB;EAChC,aAAa;GACX,IAAI,UAAU;GACd,OAAO,UAAU,KAAK,MAAM,KAAK,MAAM,OAAO,MAAM,MAAM,IAAI;EAChE;CACF;AACF,CAAC;;AAGD,IAAa,oBAAoB,gBAAgB;CAC/C,MAAM;CACN,OAAO;EACL,QAAQ;GAAE,MAAM;GAAoC,UAAU;EAAK;EACnE,MAAM;GAAE,MAAM;GAAQ,SAAS;EAAE;CACnC;CACA,MAAM,OAAO;EACX,aAAa,EAAE,UAAU,UAAU,MAAM,QAAQ,MAAM,IAAI,CAAC;CAC9D;AACF,CAAC"}
1
+ {"version":3,"file":"render.js","names":[],"sources":["../../../src/components/markdown/render.ts"],"sourcesContent":["import { CheckIcon } from '@dou-ui/icons'\nimport {\n defineComponent,\n Fragment,\n getCurrentInstance,\n h,\n inject,\n onBeforeUnmount,\n onMounted,\n onUpdated,\n ref,\n type ComponentInternalInstance,\n type InjectionKey,\n type PropType,\n type VNode,\n type VNodeChild,\n} from 'vue'\nimport type { Tone } from '../../utils/types'\n// through the installable entries, so ConfigProvider defaults reach them\nimport { DouAlert } from '../alert'\nimport { DouChatCitation } from '../chat-sources'\nimport type { ChatSource } from '../chat-sources/chat-sources'\nimport { DouCodeBlock } from '../code-block'\nimport type {\n MarkdownBlock,\n MarkdownContainer,\n MarkdownInline,\n MarkdownItem,\n MarkdownLinkTarget,\n MarkdownRow,\n MarkdownSlots,\n MarkdownUrlKind,\n} from './markdown'\n\n/** One reveal step: the text from `from` on arrived at `time`. */\nexport interface MarkdownCommit {\n from: number\n time: number\n}\n\n/** What the block components share; plain fields are read without tracking. */\nexport interface MarkdownRenderContext {\n readonly streaming: boolean\n readonly sources: ChatSource[] | undefined\n readonly linkTarget: MarkdownLinkTarget\n readonly slots: MarkdownSlots\n sanitize: (url: string, kind: MarkdownUrlKind) => string | undefined\n /** Reveal steps still fading in, oldest first. Empty when nothing animates. */\n commits: MarkdownCommit[]\n /** How long a fade lasts, in ms. */\n duration: number\n /** The time of the render in progress. */\n now: number\n /** `animation-delay` of each fading span, fixed when it is first drawn. */\n delays: Map<string, string>\n /** The block the caret follows, while streaming. */\n caret: object | null\n /** The block the `trailing` slot follows, when it is given. */\n end: object | null\n /** The block or row being drawn. */\n drawing: ComponentInternalInstance | null\n /** Blocks and rows drawn with fading spans, to draw again once the fades end. */\n fading: Set<ComponentInternalInstance>\n}\n\nexport const markdownContextKey: InjectionKey<MarkdownRenderContext> = Symbol('dou-markdown')\n\nconst B = 'dou-markdown'\ntype AnySlot = (props: Record<string, unknown>) => unknown\n\n/** The slot for a kind of node, the more specific name first. */\nfunction slotOf(ctx: MarkdownRenderContext, ...names: string[]): AnySlot | undefined {\n const slots = ctx.slots as Record<string, AnySlot | undefined>\n for (const name of names) if (Object.hasOwn(slots, name) && slots[name]) return slots[name]\n return undefined\n}\n\nconst group = (children: VNodeChild[]) => h(Fragment, children)\nconst output = (value: unknown) => h(Fragment, value as VNode[])\n\n// sources with their address checked, kept per source so citations stay the same object\nconst checkedSources = new WeakMap<ChatSource, { url?: string; source: ChatSource }>()\nfunction checkedSource(ctx: MarkdownRenderContext, source: ChatSource): ChatSource {\n if (!source.url) return source\n const hit = checkedSources.get(source)\n if (hit && hit.url === source.url) return hit.source\n const url = ctx.sanitize(source.url, 'source')\n const next = url === source.url ? source : { ...source, url }\n checkedSources.set(source, { url: source.url, source: next })\n return next\n}\nconst FRESH = `${B}__fresh`\nconst ENTER = `${B}__enter`\n\n/** The reveal step `offset` belongs to, while it is still fading. */\nfunction stepOf(ctx: MarkdownRenderContext, offset: number): MarkdownCommit | undefined {\n const commits = ctx.commits\n if (!commits.length || offset < commits[0]!.from) return undefined\n let found: MarkdownCommit | undefined\n for (const commit of commits) {\n if (commit.from > offset) break\n found = commit\n }\n return found && ctx.now - found.time < ctx.duration ? found : undefined\n}\n\n/** Class for a block that fades in as a whole when it first shows. */\nfunction enter(ctx: MarkdownRenderContext, offset: number): string | undefined {\n return stepOf(ctx, offset) ? ENTER : undefined\n}\n\nfunction caretNode() {\n return h('span', { class: `${B}__caret`, 'aria-hidden': 'true' })\n}\n\n/** The caret and the `trailing` slot, after the last word of `owner`. */\nfunction tail(ctx: MarkdownRenderContext, owner: object, out: VNodeChild[]) {\n if (ctx.caret === owner) out.push(caretNode())\n if (ctx.end === owner && ctx.slots.trailing)\n out.push(h('span', { class: `${B}__trailing` }, ctx.slots.trailing() as VNode[]))\n}\n\n/** Text, with the parts that are still fading in wrapped in spans. */\nfunction text(\n ctx: MarkdownRenderContext,\n value: string,\n at: number,\n out: VNodeChild[],\n fade: boolean,\n) {\n const commits = ctx.commits\n const end = at + value.length\n if (!fade || !commits.length || end <= commits[0]!.from) {\n out.push(value)\n return\n }\n let pos = 0\n for (let k = 0; k < commits.length; k++) {\n const commit = commits[k]!\n const to = commits[k + 1]?.from ?? Infinity\n const s = Math.max(commit.from, at) - at\n const e = Math.min(to, end) - at\n if (e <= s) continue\n if (s > pos) out.push(value.slice(pos, s))\n const age = ctx.now - commit.time\n if (age >= ctx.duration) out.push(value.slice(s, e))\n else {\n const key = `${at}:${commit.from}`\n let delay = ctx.delays.get(key)\n if (delay === undefined) {\n // drawn again from scratch, it picks up where the fade is\n delay = age >= 1 ? `${-Math.round(age)}ms` : ''\n ctx.delays.set(key, delay)\n }\n if (ctx.drawing) ctx.fading.add(ctx.drawing)\n out.push(\n h(\n 'span',\n { key, class: FRESH, style: delay ? { animationDelay: delay } : undefined },\n value.slice(s, e),\n ),\n )\n }\n pos = e\n }\n if (pos < value.length) out.push(value.slice(pos))\n}\n\n/** `[1]`, `[^1]`, `[1, 2]`, `[1、2]`. */\nconst CITATION = /\\[\\^?(\\d{1,3}(?:[ \\t]*[,,、][ \\t]*\\d{1,3})*)\\]/g\n// `a[1].b` or `m[1](x)` is code, not a citation\nconst CODE_BEFORE = /[A-Za-z0-9_)]/\nconst CODE_AFTER = /[A-Za-z0-9_.(=]/\n\nfunction citation(ctx: MarkdownRenderContext, index: number, source: ChatSource, at: number) {\n const checked = checkedSource(ctx, source)\n const slot = ctx.slots.citation\n if (slot)\n return h(Fragment, { key: `c${at}:${index}` }, slot({ index, source: checked }) as VNode[])\n return h(DouChatCitation, {\n key: `c${at}:${index}`,\n class: stepOf(ctx, at) ? ENTER : undefined,\n index,\n source: checked,\n })\n}\n\nfunction textWithCitations(\n ctx: MarkdownRenderContext,\n value: string,\n at: number,\n out: VNodeChild[],\n fade: boolean,\n) {\n const sources = ctx.sources\n if (!sources?.length || !value.includes('[')) {\n text(ctx, value, at, out, fade)\n return\n }\n let last = 0\n for (const match of value.matchAll(CITATION)) {\n const end = match.index + match[0].length\n if (CODE_BEFORE.test(value[match.index - 1] ?? '') && CODE_AFTER.test(value[end] ?? ''))\n continue\n const indexes = match[1]!.split(/[ \\t]*[,,、][ \\t]*/).map(Number)\n // a number without a source leaves the whole bracket as text\n if (!indexes.every((index) => index >= 1 && sources[index - 1])) continue\n if (match.index > last) text(ctx, value.slice(last, match.index), at + last, out, fade)\n for (const index of indexes)\n out.push(citation(ctx, index, sources[index - 1]!, at + match.index))\n last = end\n }\n if (last < value.length) text(ctx, value.slice(last), at + last, out, fade)\n}\n\n/** A full address, which opens at `linkTarget`; relative ones and anchors open in place. */\nconst isExternal = (href: string) => /^(?:https?:)?\\/\\//i.test(href)\n\nfunction inlines(\n ctx: MarkdownRenderContext,\n nodes: MarkdownInline[],\n fade: boolean,\n out: VNodeChild[] = [],\n inLink = false,\n): VNodeChild[] {\n for (const node of nodes) {\n switch (node.type) {\n case 'text':\n // a citation is a link itself, so none inside a link\n if (inLink) text(ctx, node.value, node.at, out, fade)\n else textWithCitations(ctx, node.value, node.at, out, fade)\n break\n case 'code': {\n const slot = ctx.slots['inline-code']\n out.push(\n slot\n ? output(slot({ code: node.value }))\n : h('code', { class: fade ? enter(ctx, node.at) : undefined }, node.value),\n )\n break\n }\n case 'strong':\n case 'em':\n case 'del': {\n const children = inlines(ctx, node.children, fade, [], inLink)\n const slot = ctx.slots[node.type]\n out.push(slot ? output(slot({ children: group(children) })) : h(node.type, children))\n break\n }\n case 'link': {\n const children = inlines(ctx, node.children, fade, [], true)\n // `[a]()` links nowhere: plain text\n if (node.href === '' && !ctx.slots.link) {\n out.push(...children)\n break\n }\n const href = node.href === undefined ? undefined : ctx.sanitize(node.href, 'link')\n const external = href !== undefined && isExternal(href)\n const slot = ctx.slots.link\n if (slot) {\n out.push(\n output(slot({ node, href, title: node.title, external, children: group(children) })),\n )\n break\n }\n if (href === undefined) {\n // an address still being written, or one that was dropped\n out.push(h('span', { class: `${B}__link` }, children))\n break\n }\n const target = external && ctx.linkTarget !== '_self' ? ctx.linkTarget : undefined\n out.push(\n h(\n 'a',\n {\n href,\n title: node.title,\n target,\n rel: target ? 'noopener noreferrer' : undefined,\n },\n children,\n ),\n )\n break\n }\n case 'image': {\n const src = ctx.sanitize(node.src, 'image')\n if (src === undefined) {\n if (node.alt) out.push(node.alt)\n break\n }\n const slot = ctx.slots.image\n out.push(\n slot\n ? output(slot({ src, alt: node.alt, title: node.title }))\n : h('img', { src, alt: node.alt, title: node.title, loading: 'lazy' }),\n )\n break\n }\n case 'break':\n out.push(h('br'))\n break\n case 'softbreak':\n if (!node.cjk) out.push('\\n')\n break\n }\n }\n return out\n}\n\nfunction leafContent(\n ctx: MarkdownRenderContext,\n owner: object,\n nodes: MarkdownInline[],\n fade = true,\n): VNodeChild[] {\n const out = inlines(ctx, nodes, fade)\n tail(ctx, owner, out)\n return out\n}\n\nfunction blockList(nodes: MarkdownBlock[], tick: number) {\n return nodes.map((node, index) =>\n h(MarkdownBlockView, {\n key: `${node.type}:${node.start}`,\n node,\n tick: index === nodes.length - 1 ? tick : 0,\n }),\n )\n}\n\nfunction renderItem(ctx: MarkdownRenderContext, item: MarkdownItem, tick: number): VNode {\n const children: VNodeChild[] = []\n const slot = ctx.slots.item\n if (item.checked !== null && !slot) {\n children.push(\n h('span', { class: `${B}__task` }, [\n h('input', {\n type: 'checkbox',\n class: `${B}__checkbox`,\n checked: item.checked,\n disabled: true,\n }),\n item.checked ? h(CheckIcon, { class: `${B}__check`, 'aria-hidden': 'true' }) : null,\n ]),\n )\n }\n const last = item.children.length - 1\n item.children.forEach((child, index) => {\n // a tight list shows its paragraphs without their own spacing\n if (item.tight && child.type === 'paragraph') {\n if (index > 0 && item.children[index - 1]!.type === 'paragraph') children.push(h('br'))\n children.push(...leafContent(ctx, child, child.children))\n } else {\n children.push(\n h(MarkdownBlockView, {\n key: `${child.type}:${child.start}`,\n node: child,\n tick: index === last ? tick : 0,\n }),\n )\n }\n })\n tail(ctx, item, children)\n if (slot) return output(slot({ node: item, checked: item.checked, children: group(children) }))\n return h(\n 'li',\n {\n class: [\n item.checked !== null && `${B}__task-item`,\n enter(ctx, item.start) && `${B}__item-enter`,\n ],\n },\n children,\n )\n}\n\nfunction renderRow(\n ctx: MarkdownRenderContext,\n row: MarkdownRow,\n align: string[],\n cell: 'th' | 'td',\n fade: boolean,\n): VNode {\n const entering = fade ? enter(ctx, row.start) : undefined\n return h(\n 'tr',\n { class: entering },\n row.cells.map((content, index) => {\n const out = inlines(ctx, content, fade && !entering)\n if (index === row.cells.length - 1) tail(ctx, row, out)\n return h(cell, { style: align[index] ? { textAlign: align[index] } : undefined }, out)\n }),\n )\n}\n\n/** Tones of the containers drawn as an Alert when no slot takes them. */\nconst CALLOUTS = new Map<string, Tone>([\n ['note', 'neutral'],\n ['info', 'primary'],\n ['tip', 'success'],\n ['warning', 'warning'],\n ['danger', 'danger'],\n])\n\nfunction renderContainer(ctx: MarkdownRenderContext, node: MarkdownContainer, tick: number) {\n const entering = enter(ctx, node.start)\n const tone = CALLOUTS.get(node.name)\n if (tone)\n return h(\n DouAlert,\n // the content is part of the text, not an announcement\n { class: [`${B}__callout`, entering], tone, title: node.title || undefined, role: 'note' },\n { default: () => blockList(node.children, tick) },\n )\n return h('div', { class: [`${B}__container`, entering], 'data-name': node.name }, [\n node.title ? h('p', { class: `${B}__container-title` }, node.title) : null,\n ...blockList(node.children, tick),\n ])\n}\n\nfunction renderDefault(\n ctx: MarkdownRenderContext,\n node: MarkdownBlock,\n tick: number,\n children: () => VNodeChild[],\n): VNode {\n switch (node.type) {\n case 'paragraph':\n return h('p', children())\n case 'heading':\n return h(`h${node.level}`, children())\n case 'hr':\n return h('hr', { class: enter(ctx, node.start) })\n case 'blockquote':\n return h('blockquote', { class: enter(ctx, node.start) }, children())\n case 'list':\n return h(\n node.ordered ? 'ol' : 'ul',\n {\n start: node.ordered && node.startNumber !== 1 ? node.startNumber : undefined,\n class: node.children.every((item) => item.checked !== null)\n ? `${B}__task-list`\n : undefined,\n },\n children(),\n )\n case 'table': {\n const entering = enter(ctx, node.start)\n const content = children()\n return h(MarkdownTableView, { entering }, { default: () => content })\n }\n case 'code':\n return h(DouCodeBlock, {\n class: [`${B}__code`, enter(ctx, node.start)],\n code: node.value,\n lang: node.lang || 'text',\n streaming: ctx.streaming && !node.closed,\n })\n case 'container':\n return renderContainer(ctx, node, tick)\n }\n}\n\nfunction renderTable(\n ctx: MarkdownRenderContext,\n node: Extract<MarkdownBlock, { type: 'table' }>,\n tick: number,\n) {\n const fade = !enter(ctx, node.start)\n return h('table', [\n h('thead', [renderRow(ctx, node.head, node.align, 'th', fade)]),\n node.rows.length\n ? h(\n 'tbody',\n node.rows.map((row, index) =>\n h(MarkdownRowView, {\n key: row.start,\n row,\n align: node.align,\n fade,\n tick: index === node.rows.length - 1 ? tick : 0,\n }),\n ),\n )\n : null,\n ])\n}\n\n/** What a block holds: its text, or the blocks inside it. */\nfunction inner(ctx: MarkdownRenderContext, node: MarkdownBlock, tick: number): VNodeChild[] {\n switch (node.type) {\n case 'paragraph':\n case 'heading':\n return leafContent(ctx, node, node.children)\n case 'blockquote':\n case 'container':\n return blockList(node.children, tick)\n case 'list':\n return node.children.map((item, index) =>\n h(MarkdownBlockView, {\n key: `item:${item.start}`,\n node: item,\n tick: index === node.children.length - 1 ? tick : 0,\n }),\n )\n case 'table':\n return [renderTable(ctx, node, tick)]\n default:\n return []\n }\n}\n\nfunction renderBlock(ctx: MarkdownRenderContext, node: MarkdownBlock, tick: number): VNode {\n const slot =\n node.type === 'code'\n ? slotOf(ctx, `code-${node.lang}`, 'code')\n : node.type === 'container'\n ? slotOf(ctx, `container-${node.name}`, 'container')\n : slotOf(ctx, node.type)\n if (!slot) return renderDefault(ctx, node, tick, () => inner(ctx, node, tick))\n const streaming = ctx.streaming && 'closed' in node && !node.closed\n const props: Record<string, unknown> =\n node.type === 'code'\n ? { node, code: node.value, lang: node.lang, streaming }\n : node.type === 'container'\n ? { node, name: node.name, title: node.title, streaming }\n : node.type === 'heading'\n ? { node, level: node.level }\n : { node }\n if (node.type !== 'code' && node.type !== 'hr') props.children = group(inner(ctx, node, tick))\n // the slot's content takes the block's spacing and fades in like the block would\n return h(\n 'div',\n {\n class: [\n `${B}__custom`,\n node.type !== 'paragraph' && node.type !== 'heading' && enter(ctx, node.start),\n ],\n },\n slot(props) as VNode[],\n )\n}\n\n/**\n * One block. Its only input is the block object, which the parser hands\n * back unchanged while the block stays the same, so Vue skips it; `tick`\n * reaches only the last block on each level, which is where the stream\n * grows and where the caret sits.\n */\nexport const MarkdownBlockView = defineComponent({\n name: 'DouMarkdownBlock',\n props: {\n node: { type: Object as PropType<MarkdownBlock | MarkdownItem>, required: true },\n tick: { type: Number, default: 0 },\n },\n setup(props) {\n const ctx = inject(markdownContextKey)!\n const self = getCurrentInstance()\n return () => {\n ctx.drawing = self\n return props.node.type === 'item'\n ? renderItem(ctx, props.node, props.tick)\n : renderBlock(ctx, props.node, props.tick)\n }\n },\n})\n\nconst MarkdownTableView = defineComponent({\n name: 'DouMarkdownTable',\n props: {\n entering: { type: String, default: undefined },\n },\n setup(props, { slots }) {\n const frameRef = ref<HTMLElement | null>(null)\n const cutStart = ref(false)\n const cutEnd = ref(false)\n let observer: ResizeObserver | undefined\n let observedTable: Element | null = null\n\n function measure() {\n const frame = frameRef.value\n if (!frame) return\n const hidden = frame.scrollWidth - frame.clientWidth\n // `scrollLeft` is negative in right-to-left pages.\n const left = Math.abs(frame.scrollLeft)\n cutStart.value = left > 1\n cutEnd.value = left < hidden - 1\n }\n\n function syncObservedTable() {\n const frame = frameRef.value\n if (!observer || !frame) return\n const table = frame.querySelector('table')\n if (table === observedTable) return\n if (observedTable) observer.unobserve(observedTable)\n observedTable = table\n if (observedTable) observer.observe(observedTable)\n }\n\n onMounted(() => {\n const frame = frameRef.value\n if (!frame) return\n measure()\n if (typeof ResizeObserver === 'undefined') return\n observer = new ResizeObserver(measure)\n observer.observe(frame)\n syncObservedTable()\n })\n\n onUpdated(() => {\n syncObservedTable()\n measure()\n })\n\n onBeforeUnmount(() => {\n observer?.disconnect()\n observer = undefined\n observedTable = null\n })\n\n return () =>\n h(\n 'div',\n {\n ref: frameRef,\n class: [\n `${B}__table`,\n props.entering,\n cutStart.value && 'is-cut-start',\n cutEnd.value && 'is-cut-end',\n ],\n onScrollPassive: measure,\n },\n slots.default?.(),\n )\n },\n})\n\nconst MarkdownRowView = defineComponent({\n name: 'DouMarkdownRow',\n props: {\n row: { type: Object as PropType<MarkdownRow>, required: true },\n align: { type: Array as PropType<string[]>, required: true },\n fade: { type: Boolean, default: true },\n tick: { type: Number, default: 0 },\n },\n setup(props) {\n const ctx = inject(markdownContextKey)!\n const self = getCurrentInstance()\n return () => {\n ctx.drawing = self\n return renderRow(ctx, props.row, props.align, 'td', props.fade)\n }\n },\n})\n\n/** A run of blocks. Runs that are complete keep the same array, so a long document re-renders only its end. */\nexport const MarkdownChunkView = defineComponent({\n name: 'DouMarkdownChunk',\n props: {\n blocks: { type: Array as PropType<MarkdownBlock[]>, required: true },\n tick: { type: Number, default: 0 },\n },\n setup(props) {\n return () => h(Fragment, blockList(props.blocks, props.tick))\n },\n})\n"],"mappings":";;;;;;AAiEA,IAAa,qBAA0D,OAAO,cAAc;AAE5F,IAAM,IAAI;;AAIV,SAAS,OAAO,K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